3 ## Copyright (C) 2008 Advanced Micro Devices, Inc.
4 ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
6 ## SPDX-License-Identifier: GPL-2.0-only
10 srck
:= $(src
)/..
/..
/util
/kconfig
11 coreinfo_obj
:= $(src
)/build
12 objk
:= $(src
)/build
/util
/kconfig
14 ifeq ($(filter %clean,$(MAKECMDGOALS
)),)
15 export KERNELVERSION
:= 0.1.0
16 export KCONFIG_AUTOHEADER
:= $(coreinfo_obj
)/config.h
17 export KCONFIG_AUTOCONFIG
:= $(coreinfo_obj
)/auto.conf
18 export KCONFIG_DEPENDENCIES
:= $(coreinfo_obj
)/auto.conf.cmd
19 export KCONFIG_SPLITCONFIG
:= $(coreinfo_obj
)/config
20 export KCONFIG_TRISTATE
:= $(coreinfo_obj
)/tristate.conf
21 export KCONFIG_CONFIG
:= $(CURDIR
)/.config
22 export KCONFIG_NEGATIVES
:= 1
23 export Kconfig
:= Kconfig
28 KBUILD_DEFCONFIG
:= configs
/defconfig
29 UNAME_RELEASE
:= $(shell uname
-r
)
30 HAVE_DOTCONFIG
:= $(wildcard .config
)
31 MAKEFLAGS
+= -rR
--no-print-directory
33 # Make is silent per default, but 'make V=1' will show all compiler calls.
40 HOSTCFLAGS
:= -I
$(srck
) -I
$(objk
)
41 HOSTCXXFLAGS
:= -I
$(srck
) -I
$(objk
)
43 LIBPAYLOAD_PATH
:= $(realpath ..
/libpayload
)
44 LIBPAYLOAD_OBJ
:= $(coreinfo_obj
)/libpayload
45 HAVE_LIBPAYLOAD
:= $(wildcard $(LIBPAYLOAD_OBJ
)/lib
/libpayload.a
)
46 LIBPAYLOAD_CONFIG ?
= configs
/defconfig-tinycurses
49 INCLUDES
= -I
$(coreinfo_obj
) -include $(LIBPAYLOAD_OBJ
)/include/kconfig.h
-I
$(src
)/..
/..
/src
/commonlib
/include
50 OBJECTS
= cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
51 nvram_module.o bootlog_module.o ramdump_module.o \
52 multiboot_module.o cbfs_module.o timestamps_module.o coreinfo.o
53 OBJS
= $(patsubst %,$(coreinfo_obj
)/%,$(OBJECTS
))
54 TARGET
= $(coreinfo_obj
)/coreinfo.elf
58 # in addition to the dependency below, create the file if it doesn't exist
59 # to silence warnings about a file that would be generated anyway.
60 $(if
$(wildcard .xcompile
),,$(eval
$(shell ..
/..
/util
/xcompile
/xcompile
$(XGCCPATH
) > .xcompile ||
rm -f .xcompile
)))
61 .xcompile
: ..
/..
/util
/xcompile
/xcompile
62 $< $(XGCCPATH
) > $@.tmp
63 \mv
-f
$@.tmp
$@
2> /dev
/null ||
rm -f
$@.tmp
$@
65 CONFIG_COMPILER_GCC
:= y
72 OBJCOPY
:= $(OBJCOPY_
$(ARCH-y
))
74 LPCC
:= CC
="$(CC)" $(LIBPAYLOAD_OBJ
)/bin
/lpgcc
75 LPAS
:= AS
="$(AS)" $(LIBPAYLOAD_OBJ
)/bin
/lpas
77 CFLAGS
+= -Wall
-Wextra
-Wmissing-prototypes
-Wvla
-Werror
78 CFLAGS
+= -Os
-fno-builtin
$(CFLAGS_
$(ARCH-y
)) $(INCLUDES
)
80 ifneq ($(strip $(HAVE_DOTCONFIG
)),)
81 include $(src
)/.config
84 $(TARGET
): $(src
)/.config
$(coreinfo_obj
)/config.h
$(OBJS
) libpayload
85 printf
" LPCC $(subst $(CURDIR)/,,$(@)) (LINK)\n"
87 $(OBJCOPY
) --only-keep-debug
$@
$(TARGET
).debug
88 $(OBJCOPY
) --strip-debug
$@
89 $(OBJCOPY
) --add-gnu-debuglink
=$(TARGET
).debug
$@
91 $(coreinfo_obj
)/%.S.o
: $(src
)/%.S libpayload
92 printf
" LPAS $(subst $(CURDIR)/,,$(@))\n"
95 $(coreinfo_obj
)/%.o
: $(src
)/%.c libpayload
96 printf
" LPCC $(subst $(CURDIR)/,,$(@))\n"
97 $(LPCC
) $(CFLAGS
) -c
-o
$@
$<
107 ifneq ($(strip $(HAVE_LIBPAYLOAD
)),)
109 printf
"Found Libpayload $(LIBPAYLOAD_OBJ).\n"
111 LPOPTS
=obj
="$(CURDIR)/lpbuild" DOTCONFIG
="$(CURDIR)/lp.config"
113 printf
"Building libpayload @ $(LIBPAYLOAD_PATH).\n"
114 $(MAKE
) -C
$(LIBPAYLOAD_PATH
) $(LPOPTS
) distclean coreinfo_obj
=$(coreinfo_obj
)/libptmp
115 $(MAKE
) -C
$(LIBPAYLOAD_PATH
) $(LPOPTS
) defconfig KBUILD_DEFCONFIG
=$(LIBPAYLOAD_CONFIG
)
116 $(MAKE
) -C
$(LIBPAYLOAD_PATH
) $(LPOPTS
) install DESTDIR
=$(coreinfo_obj
)
119 $(coreinfo_obj
)/config.h
:
122 $(shell mkdir
-p
$(coreinfo_obj
) $(objk
)/lxdialog
$(KCONFIG_SPLITCONFIG
))
124 include $(srck
)/Makefile
126 .PHONY
: $(PHONY
) prepare
131 rm -rf build lpbuild .xcompile
134 rm -f .config
* lp.config
*
136 .PHONY
: clean distclean