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.
19 srck
:= $(src
)/..
/..
/util
/kconfig
20 coreinfo_obj
:= $(src
)/build
21 objk
:= $(src
)/build
/util
/kconfig
23 ifeq ($(filter %clean,$(MAKECMDGOALS
)),)
24 export KERNELVERSION
:= 0.1.0
25 export KCONFIG_AUTOHEADER
:= $(coreinfo_obj
)/config.h
26 export KCONFIG_AUTOCONFIG
:= $(coreinfo_obj
)/auto.conf
27 export KCONFIG_DEPENDENCIES
:= $(coreinfo_obj
)/auto.conf.cmd
28 export KCONFIG_SPLITCONFIG
:= $(coreinfo_obj
)/config
29 export KCONFIG_TRISTATE
:= $(coreinfo_obj
)/tristate.conf
30 export KCONFIG_CONFIG
:= $(CURDIR
)/.config
31 export KCONFIG_NEGATIVES
:= 1
32 export Kconfig
:= Kconfig
37 KBUILD_DEFCONFIG
:= configs
/defconfig
38 UNAME_RELEASE
:= $(shell uname
-r
)
39 HAVE_DOTCONFIG
:= $(wildcard .config
)
40 MAKEFLAGS
+= -rR
--no-print-directory
42 # Make is silent per default, but 'make V=1' will show all compiler calls.
49 HOSTCFLAGS
:= -I
$(srck
) -I
$(objk
)
50 HOSTCXXFLAGS
:= -I
$(srck
) -I
$(objk
)
52 LIBPAYLOAD_PATH
:= $(realpath ..
/libpayload
)
53 LIBPAYLOAD_OBJ
:= $(coreinfo_obj
)/libpayload
54 HAVE_LIBPAYLOAD
:= $(wildcard $(LIBPAYLOAD_OBJ
)/lib
/libpayload.a
)
55 LIBPAYLOAD_CONFIG ?
= configs
/defconfig-tinycurses
58 INCLUDES
= -I
$(coreinfo_obj
) -include $(LIBPAYLOAD_OBJ
)/include/kconfig.h
-I
$(src
)/..
/..
/src
/commonlib
/include
59 OBJECTS
= cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
60 nvram_module.o bootlog_module.o ramdump_module.o \
61 multiboot_module.o cbfs_module.o timestamps_module.o coreinfo.o
62 OBJS
= $(patsubst %,$(coreinfo_obj
)/%,$(OBJECTS
))
63 TARGET
= $(coreinfo_obj
)/coreinfo.elf
67 # in addition to the dependency below, create the file if it doesn't exist
68 # to silence warnings about a file that would be generated anyway.
69 $(if
$(wildcard .xcompile
),,$(eval
$(shell ..
/..
/util
/xcompile
/xcompile
$(XGCCPATH
) > .xcompile ||
rm -f .xcompile
)))
70 .xcompile
: ..
/..
/util
/xcompile
/xcompile
71 $< $(XGCCPATH
) > $@.tmp
72 \mv
-f
$@.tmp
$@
2> /dev
/null ||
rm -f
$@.tmp
$@
74 CONFIG_COMPILER_GCC
:= y
81 OBJCOPY
:= $(OBJCOPY_
$(ARCH-y
))
83 LPCC
:= CC
="$(CC)" $(LIBPAYLOAD_OBJ
)/bin
/lpgcc
84 LPAS
:= AS
="$(AS)" $(LIBPAYLOAD_OBJ
)/bin
/lpas
86 CFLAGS
+= -Wall
-Wextra
-Wmissing-prototypes
-Werror
87 CFLAGS
+= -Os
-fno-builtin
$(CFLAGS_
$(ARCH-y
)) $(INCLUDES
)
89 ifneq ($(strip $(HAVE_DOTCONFIG
)),)
90 include $(src
)/.config
93 $(TARGET
): $(src
)/.config
$(coreinfo_obj
)/config.h
$(OBJS
) libpayload
94 printf
" LPCC $(subst $(CURDIR)/,,$(@)) (LINK)\n"
96 $(OBJCOPY
) --only-keep-debug
$@
$(TARGET
).debug
97 $(OBJCOPY
) --strip-debug
$@
98 $(OBJCOPY
) --add-gnu-debuglink
=$(TARGET
).debug
$@
100 $(coreinfo_obj
)/%.S.o
: $(src
)/%.S libpayload
101 printf
" LPAS $(subst $(CURDIR)/,,$(@))\n"
104 $(coreinfo_obj
)/%.o
: $(src
)/%.c libpayload
105 printf
" LPCC $(subst $(CURDIR)/,,$(@))\n"
106 $(LPCC
) $(CFLAGS
) -c
-o
$@
$<
116 ifneq ($(strip $(HAVE_LIBPAYLOAD
)),)
118 printf
"Found Libpayload $(LIBPAYLOAD_OBJ).\n"
120 LPOPTS
=obj
="$(CURDIR)/lpbuild" DOTCONFIG
="$(CURDIR)/lp.config"
122 printf
"Building libpayload @ $(LIBPAYLOAD_PATH).\n"
123 $(MAKE
) -C
$(LIBPAYLOAD_PATH
) $(LPOPTS
) distclean coreinfo_obj
=$(coreinfo_obj
)/libptmp
124 $(MAKE
) -C
$(LIBPAYLOAD_PATH
) $(LPOPTS
) defconfig KBUILD_DEFCONFIG
=$(LIBPAYLOAD_CONFIG
)
125 $(MAKE
) -C
$(LIBPAYLOAD_PATH
) $(LPOPTS
) install DESTDIR
=$(coreinfo_obj
)
128 $(coreinfo_obj
)/config.h
:
131 $(shell mkdir
-p
$(coreinfo_obj
) $(objk
)/lxdialog
$(KCONFIG_SPLITCONFIG
))
133 include $(srck
)/Makefile
135 .PHONY
: $(PHONY
) prepare
140 rm -rf build
/*.elf build
/*.o .xcompile
144 rm -f .config
* lp.config
*
146 .PHONY
: clean distclean