2 ## This file is part of the coreinfo project.
4 ## Copyright (C) 2008 Advanced Micro Devices, Inc.
5 ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
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.
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.
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
21 export src := $(shell pwd)
22 export srctree := $(src)
23 export srck := $(src)/util/kconfig
24 export obj := $(src)/build
25 export objk := $(src)/build/util/kconfig
27 export KERNELVERSION := 0.1.0
28 export KCONFIG_AUTOHEADER := $(obj)/config.h
29 export KCONFIG_AUTOCONFIG := $(obj)/auto.conf
32 KBUILD_DEFCONFIG := configs/defconfig
33 UNAME_RELEASE := $(shell uname -r)
34 HAVE_DOTCONFIG := $(wildcard .config)
35 MAKEFLAGS += -rR --no-print-directory
37 # Make is silent per default, but 'make V=1' will show all compiler calls.
44 HOSTCFLAGS := -I$(srck) -I$(objk)
45 HOSTCXXFLAGS := -I$(srck) -I$(objk)
49 INCLUDES = -I../libpayload/include \
50 -I$(shell $(CC) $(CROSS_CFLAGS) -print-search-dirs | \
51 head -n 1 | cut -d' ' -f2)include
52 LIBPAYLOAD = ../libpayload/libpayload.a
53 LIBGCC := $(shell $(CC) $(CROSS_CFLAGS) -print-libgcc-file-name)
54 CFLAGS := -Wall -Werror -Os -fno-stack-protector -nostdinc $(INCLUDES)
55 MODULES = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o
57 OBJS = $(patsubst %,$(obj)/%,$(OBJECTS)) $(patsubst %,$(obj)/%,$(MODULES))
58 TARGET = $(obj)/coreinfo.elf
60 ifeq ($(strip $(HAVE_DOTCONFIG)),)
63 $(Q)printf "Please run make config/menuconfig/xconfig/gconfig first.\n"
67 include $(src)/.config
72 $(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
73 $(Q)#ld --verbose -T ../libpayload/libpayload.ldscript -o $@ $(OBJS) \
74 #--whole-archive $(LIBPAYLOAD) --no-whole-archive $(LIBGCC)
75 $(Q)ld -T ../libpayload/libpayload.ldscript -o $@ $(OBJS) \
76 ../libpayload/i386/head.o $(LIBPAYLOAD) $(LIBGCC)
77 $(Q)printf " STRIP $(subst $(shell pwd)/,,$(@))\n"
80 $(obj)/%.S.o: $(src)/%.S
81 $(Q)printf " AS $(subst $(shell pwd)/,,$(@))\n"
82 $(Q)$(AS) --32 -o $@ $<
84 $(obj)/%.o: $(src)/%.c
85 $(Q)printf " CC $(subst $(shell pwd)/,,$(@))\n"
86 $(Q)$(CC) $(CROSS_CFLAGS) $(CFLAGS) -c -o $@ $<
91 $(Q)mkdir -p $(obj)/util/kconfig/lxdialog
97 $(Q)rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig*
99 include util/kconfig/Makefile
101 .PHONY: $(PHONY) prepare clean distclean