blob: 077aaa22762da64160badf0c2a81ed4ea8a7e7a7 [file] [log] [blame]
Jordan Crouse7249f792008-03-20 00:11:05 +00001##
2## This file is part of the coreinfo project.
3##
4## Copyright (C) 2008 Advanced Micro Devices, Inc.
Uwe Hermann2216d1b2008-03-24 15:47:49 +00005## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
Jordan Crouse7249f792008-03-20 00:11:05 +00006##
7## This program is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; version 2 of the License.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
17## along with this program; if not, write to the Free Software
18## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19##
20
Uwe Hermann2216d1b2008-03-24 15:47:49 +000021export src := $(shell pwd)
22export srctree := $(src)
23export srck := $(src)/util/kconfig
24export obj := $(src)/build
25export objk := $(src)/build/util/kconfig
26
27export KERNELVERSION := 0.1.0
28export KCONFIG_AUTOHEADER := $(obj)/config.h
29export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
30
31CONFIG_SHELL := sh
32KBUILD_DEFCONFIG := configs/defconfig
33UNAME_RELEASE := $(shell uname -r)
34HAVE_DOTCONFIG := $(wildcard .config)
35MAKEFLAGS += -rR --no-print-directory
36
37# Make is silent per default, but 'make V=1' will show all compiler calls.
38ifneq ($(V),1)
39Q := @
40endif
41
42HOSTCC = gcc
43HOSTCXX = g++
44HOSTCFLAGS := -I$(srck) -I$(objk)
45HOSTCXXFLAGS := -I$(srck) -I$(objk)
46
Jordan Crouse1cb92bc2008-04-10 00:05:41 +000047LIBPAYLOAD_DIR := ../libpayload
Stefan Reinauerc3591242008-08-07 15:22:01 +000048XCC := CC=$(CC) $(LIBPAYLOAD_DIR)/bin/lpgcc
Jordan Crouse1cb92bc2008-04-10 00:05:41 +000049AS = $(LIBPAYLOAD_DIR)/bin/lpas
Stefan Reinauerc3591242008-08-07 15:22:01 +000050STRIP ?= strip
Jordan Crouse1cb92bc2008-04-10 00:05:41 +000051
52INCLUDES = -Ibuild
53CFLAGS := -Wall -Werror -Os $(INCLUDES)
Uwe Hermannab5b3e02008-03-31 20:30:18 +000054OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
Uwe Hermann2fbbb292008-07-08 16:18:38 +000055 nvram_module.o bootlog_module.o ramdump_module.o lar_module.o \
56 coreinfo.o
Uwe Hermannab5b3e02008-03-31 20:30:18 +000057OBJS = $(patsubst %,$(obj)/%,$(OBJECTS))
Uwe Hermann2216d1b2008-03-24 15:47:49 +000058TARGET = $(obj)/coreinfo.elf
59
60ifeq ($(strip $(HAVE_DOTCONFIG)),)
61
Uwe Hermannc7582272008-04-03 22:20:35 +000062all: config
Uwe Hermann2216d1b2008-03-24 15:47:49 +000063
64else
65
66include $(src)/.config
Jordan Crouse7249f792008-03-20 00:11:05 +000067
Uwe Hermanna0c00932008-03-27 20:46:49 +000068all: prepare $(TARGET)
Jordan Crouse7249f792008-03-20 00:11:05 +000069
Uwe Hermann134aaae2008-05-11 15:51:31 +000070$(TARGET): $(src)/.config $(OBJS)
Uwe Hermann2216d1b2008-03-24 15:47:49 +000071 $(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
Stefan Reinauerc3591242008-08-07 15:22:01 +000072 $(Q)$(XCC) -o $@ $(OBJS)
Uwe Hermann2216d1b2008-03-24 15:47:49 +000073 $(Q)printf " STRIP $(subst $(shell pwd)/,,$(@))\n"
Stefan Reinauerc3591242008-08-07 15:22:01 +000074 $(Q)$(STRIP) -s $@
Uwe Hermann2216d1b2008-03-24 15:47:49 +000075
76$(obj)/%.S.o: $(src)/%.S
77 $(Q)printf " AS $(subst $(shell pwd)/,,$(@))\n"
Jordan Crouse1cb92bc2008-04-10 00:05:41 +000078 $(Q)$(AS) -o $@ $<
Uwe Hermann2216d1b2008-03-24 15:47:49 +000079
80$(obj)/%.o: $(src)/%.c
81 $(Q)printf " CC $(subst $(shell pwd)/,,$(@))\n"
Stefan Reinauerc3591242008-08-07 15:22:01 +000082 $(Q)$(XCC) $(CFLAGS) -c -o $@ $<
Uwe Hermann2216d1b2008-03-24 15:47:49 +000083
84endif
85
86prepare:
87 $(Q)mkdir -p $(obj)/util/kconfig/lxdialog
88
Jordan Crouse7249f792008-03-20 00:11:05 +000089clean:
Uwe Hermann134aaae2008-05-11 15:51:31 +000090 $(Q)rm -rf build/*.elf build/*.o
Jordan Crouse7249f792008-03-20 00:11:05 +000091
Uwe Hermann2216d1b2008-03-24 15:47:49 +000092distclean: clean
Uwe Hermannc7582272008-04-03 22:20:35 +000093 $(Q)rm -rf build
Uwe Hermann2216d1b2008-03-24 15:47:49 +000094 $(Q)rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig*
Jordan Crouse7249f792008-03-20 00:11:05 +000095
Uwe Hermann2216d1b2008-03-24 15:47:49 +000096include util/kconfig/Makefile
Jordan Crouse7249f792008-03-20 00:11:05 +000097
Uwe Hermann2216d1b2008-03-24 15:47:49 +000098.PHONY: $(PHONY) prepare clean distclean
99