1 # This helper makefile is used for creating
2 # - symbolic links (arch/$ARCH/include/asm/arch
3 # - include/autoconf.mk, {spl,tpl}/include/autoconf.mk
6 # When our migration to Kconfig is done
7 # (= When we move all CONFIGs from header files to Kconfig)
8 # this makefile can be deleted.
10 # SPDX-License-Identifier: GPL-2.0
13 __all: include/autoconf.mk include/autoconf.mk.dep
15 ifeq ($(shell grep -q '^CONFIG_SPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
16 __all: spl/include/autoconf.mk
19 ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
20 __all: tpl/include/autoconf.mk
23 include include/config/auto.conf
25 include scripts/Kbuild.include
27 # Need to define CC and CPP again here in case the top Makefile did not
28 # include config.mk. Some architectures expect CROSS_COMPILE to be defined
29 # in arch/$(ARCH)/config.mk
30 CC = $(CROSS_COMPILE)gcc
37 $(if $(KBUILD_SRC), -I$(srctree)/include) \
38 -I$(srctree)/arch/$(ARCH)/include \
39 -include $(srctree)/include/linux/kconfig.h
41 c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \
42 $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
44 quiet_cmd_autoconf_dep = GEN $@
45 cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \
46 -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || { \
49 include/autoconf.mk.dep: include/config.h FORCE
50 $(call cmd,autoconf_dep)
52 # We are migrating from board headers to Kconfig little by little.
53 # In the interim, we use both of
54 # - include/config/auto.conf (generated by Kconfig)
55 # - include/autoconf.mk (used in the U-Boot conventional configuration)
56 # The following rule creates autoconf.mk
57 # include/config/auto.conf is grepped in order to avoid duplication of the
59 quiet_cmd_autoconf = GEN $@
61 sed -n -f $(srctree)/tools/scripts/define2mk.sed $< | \
63 if [ -n "${KCONFIG_IGNORE_DUPLICATES}" ] || \
64 ! grep -q "$${line%=*}=" include/config/auto.conf; then \
69 quiet_cmd_u_boot_cfg = CFG $@
71 $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \
72 grep 'define CONFIG_' $@.tmp > $@; \
78 u-boot.cfg: include/config.h FORCE
79 $(call cmd,u_boot_cfg)
81 spl/u-boot.cfg: include/config.h FORCE
82 $(Q)mkdir -p $(dir $@)
83 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD)
85 tpl/u-boot.cfg: include/config.h FORCE
86 $(Q)mkdir -p $(dir $@)
87 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
89 include/autoconf.mk: u-boot.cfg
92 spl/include/autoconf.mk: spl/u-boot.cfg
93 $(Q)mkdir -p $(dir $@)
96 tpl/include/autoconf.mk: tpl/u-boot.cfg
97 $(Q)mkdir -p $(dir $@)
101 # Prior to Kconfig, it was generated by mkconfig. Now it is created here.
102 define filechk_config_h
103 (echo "/* Automatically generated - do not edit */"; \
104 for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \
105 echo \#define CONFIG_$$i \
106 | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \
108 echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
109 echo \#include \<config_defaults.h\>; \
110 echo \#include \<config_uncmd_spl.h\>; \
111 echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
112 echo \#include \<asm/config.h\>; \
113 echo \#include \<config_fallbacks.h\>;)
116 include/config.h: scripts/Makefile.autoconf create_symlink FORCE
117 $(call filechk,config_h)
120 # If arch/$(ARCH)/mach-$(SOC)/include/mach exists,
121 # make a symbolic link to that directory.
122 # Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC).
123 PHONY += create_symlink
125 ifdef CONFIG_CREATE_ARCH_SYMLINK
126 ifneq ($(KBUILD_SRC),)
127 $(Q)mkdir -p include/asm
128 $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
129 dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \
131 dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \
133 ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch
135 $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
136 dest=../../mach-$(SOC)/include/mach; \
138 dest=arch-$(if $(SOC),$(SOC),$(CPU)); \
140 ln -fsn $$dest arch/$(ARCH)/include/asm/arch