1 # SPDX-License-Identifier: GPL-2.0
2 # This helper makefile is used for creating
3 # - symbolic links (arch/$ARCH/include/asm/arch
4 # - include/autoconf.mk, {spl,tpl}/include/autoconf.mk
7 # When our migration to Kconfig is done
8 # (= When we move all CONFIGs from header files to Kconfig)
9 # this makefile can be deleted.
11 __all: include/autoconf.mk include/autoconf.mk.dep
13 ifeq ($(shell grep -q '^CONFIG_SPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
14 __all: spl/include/autoconf.mk
17 ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
18 __all: tpl/include/autoconf.mk
21 ifeq ($(shell grep -q '^CONFIG_VPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
22 __all: vpl/include/autoconf.mk
25 include include/config/auto.conf
27 include scripts/Kbuild.include
29 # Need to define CC and CPP again here in case the top Makefile did not
30 # include config.mk. Some architectures expect CROSS_COMPILE to be defined
31 # in arch/$(ARCH)/config.mk
32 CC = $(CROSS_COMPILE)gcc
39 $(if $(KBUILD_SRC), -I$(srctree)/include) \
40 -I$(srctree)/arch/$(ARCH)/include \
41 -include $(srctree)/include/linux/kconfig.h
43 c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \
44 $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
46 quiet_cmd_autoconf_dep = GEN $@
47 cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \
48 -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || { \
51 include/autoconf.mk.dep: include/config.h FORCE
52 $(call cmd,autoconf_dep)
54 # We are migrating from board headers to Kconfig little by little.
55 # In the interim, we use both of
56 # - include/config/auto.conf (generated by Kconfig)
57 # - include/autoconf.mk (used in the U-Boot conventional configuration)
58 # The following rule creates autoconf.mk
59 # include/config/auto.conf is grepped in order to avoid duplication of the
61 quiet_cmd_autoconf = GEN $@
63 sed -n -f $(srctree)/tools/scripts/define2mk.sed $< | \
65 if [ -n "${KCONFIG_IGNORE_DUPLICATES}" ] || \
66 ! grep -q "$${line%=*}=" include/config/auto.conf; then \
71 quiet_cmd_u_boot_cfg = CFG $@
73 $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h >
[email protected] && { \
75 sed '/define CONFIG_IS_ENABLED(/d;/define CONFIG_IF_ENABLED_INT(/d;/define CONFIG_VAL(/d;' > $@; \
81 u-boot.cfg: include/config.h FORCE
82 $(call cmd,u_boot_cfg)
84 spl/u-boot.cfg: include/config.h FORCE
85 $(Q)mkdir -p $(dir $@)
86 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD)
88 tpl/u-boot.cfg: include/config.h FORCE
89 $(Q)mkdir -p $(dir $@)
90 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
92 vpl/u-boot.cfg: include/config.h FORCE
93 $(Q)mkdir -p $(dir $@)
94 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_VPL_BUILD)
96 include/autoconf.mk: u-boot.cfg
99 spl/include/autoconf.mk: spl/u-boot.cfg
100 $(Q)mkdir -p $(dir $@)
103 tpl/include/autoconf.mk: tpl/u-boot.cfg
104 $(Q)mkdir -p $(dir $@)
107 vpl/include/autoconf.mk: vpl/u-boot.cfg
108 $(Q)mkdir -p $(dir $@)
112 # Prior to Kconfig, it was generated by mkconfig. Now it is created here.
113 define filechk_config_h
114 (echo "/* Automatically generated - do not edit */"; \
115 echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
116 echo \#include \<config_uncmd_spl.h\>; \
117 echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
118 echo \#include \<asm/config.h\>; \
119 echo \#include \<linux/kconfig.h\>; \
120 echo \#include \<config_fallbacks.h\>;)
123 include/config.h: scripts/Makefile.autoconf create_symlink FORCE
124 $(call filechk,config_h)
127 # If arch/$(ARCH)/mach-$(SOC)/include/mach exists,
128 # make a symbolic link to that directory.
129 # Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC).
130 PHONY += create_symlink
132 ifdef CONFIG_CREATE_ARCH_SYMLINK
133 ifneq ($(KBUILD_SRC),)
134 $(Q)mkdir -p include/asm
135 $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
136 dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \
138 dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \
140 ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch
142 $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
143 dest=../../mach-$(SOC)/include/mach; \
145 dest=arch-$(if $(SOC),$(SOC),$(CPU)); \
147 ln -fsn $$dest arch/$(ARCH)/include/asm/arch