]> git.ipfire.org Git - thirdparty/u-boot.git/blame - scripts/Makefile.autoconf
Merge tag 'v2024.04-rc5' into next
[thirdparty/u-boot.git] / scripts / Makefile.autoconf
CommitLineData
83d290c5 1# SPDX-License-Identifier: GPL-2.0
51148790
MY
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
5# - include/config.h
6#
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.
10
e02ee254
MY
11__all: include/autoconf.mk include/autoconf.mk.dep
12
13ifeq ($(shell grep -q '^CONFIG_SPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
14__all: spl/include/autoconf.mk
15endif
16
17ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
18__all: tpl/include/autoconf.mk
19endif
20
f86ca5ad
SG
21ifeq ($(shell grep -q '^CONFIG_VPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
22__all: vpl/include/autoconf.mk
23endif
24
e02ee254 25include include/config/auto.conf
51148790
MY
26
27include scripts/Kbuild.include
28
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
32CC = $(CROSS_COMPILE)gcc
33CPP = $(CC) -E
34
35include config.mk
36
37UBOOTINCLUDE := \
51148790
MY
38 -Iinclude \
39 $(if $(KBUILD_SRC), -I$(srctree)/include) \
40 -I$(srctree)/arch/$(ARCH)/include \
41 -include $(srctree)/include/linux/kconfig.h
42
43c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \
44 $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
45
46quiet_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 > $@ || { \
49 rm $@; false; \
50 }
1406992f 51include/autoconf.mk.dep: include/config.h FORCE
51148790
MY
52 $(call cmd,autoconf_dep)
53
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
60# same CONFIG macros
61quiet_cmd_autoconf = GEN $@
62 cmd_autoconf = \
e19b0fb4 63 sed -n -f $(srctree)/tools/scripts/define2mk.sed $< | \
51148790 64 while read line; do \
7740f653
JH
65 if [ -n "${KCONFIG_IGNORE_DUPLICATES}" ] || \
66 ! grep -q "$${line%=*}=" include/config/auto.conf; then \
51148790 67 echo "$$line"; \
5130102f 68 fi; \
e19b0fb4
MY
69 done > $@
70
71quiet_cmd_u_boot_cfg = CFG $@
72 cmd_u_boot_cfg = \
73 $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \
ff062765 74 grep 'define CONFIG_' $@.tmp | \
097ff01f 75 sed '/define CONFIG_IS_ENABLED(/d;/define CONFIG_IF_ENABLED_INT(/d;/define CONFIG_VAL(/d;' > $@; \
e19b0fb4
MY
76 rm $@.tmp; \
77 } || { \
78 rm $@.tmp; false; \
51148790
MY
79 }
80
e19b0fb4
MY
81u-boot.cfg: include/config.h FORCE
82 $(call cmd,u_boot_cfg)
83
84spl/u-boot.cfg: include/config.h FORCE
85 $(Q)mkdir -p $(dir $@)
86 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD)
87
88tpl/u-boot.cfg: include/config.h FORCE
89 $(Q)mkdir -p $(dir $@)
90 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
91
f86ca5ad
SG
92vpl/u-boot.cfg: include/config.h FORCE
93 $(Q)mkdir -p $(dir $@)
94 $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_VPL_BUILD)
95
e19b0fb4 96include/autoconf.mk: u-boot.cfg
51148790
MY
97 $(call cmd,autoconf)
98
e19b0fb4 99spl/include/autoconf.mk: spl/u-boot.cfg
e02ee254 100 $(Q)mkdir -p $(dir $@)
e19b0fb4 101 $(call cmd,autoconf)
e02ee254 102
e19b0fb4 103tpl/include/autoconf.mk: tpl/u-boot.cfg
e02ee254 104 $(Q)mkdir -p $(dir $@)
e19b0fb4 105 $(call cmd,autoconf)
e02ee254 106
f86ca5ad
SG
107vpl/include/autoconf.mk: vpl/u-boot.cfg
108 $(Q)mkdir -p $(dir $@)
109 $(call cmd,autoconf)
110
51148790
MY
111# include/config.h
112# Prior to Kconfig, it was generated by mkconfig. Now it is created here.
113define filechk_config_h
114 (echo "/* Automatically generated - do not edit */"; \
207972ac 115 echo \#define CFG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
bcd8bce5 116 $(if $(CONFIG_SYS_CONFIG_NAME),echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\> ;) \
51148790 117 echo \#include \<asm/config.h\>; \
4ac96345 118 echo \#include \<linux/kconfig.h\>; \
e02ee254 119 echo \#include \<config_fallbacks.h\>;)
51148790
MY
120endef
121
122include/config.h: scripts/Makefile.autoconf create_symlink FORCE
123 $(call filechk,config_h)
124
125# symbolic links
0e7368c6
MY
126# If arch/$(ARCH)/mach-$(SOC)/include/mach exists,
127# make a symbolic link to that directory.
128# Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC).
51148790
MY
129PHONY += create_symlink
130create_symlink:
a350c6a6 131ifdef CONFIG_CREATE_ARCH_SYMLINK
51148790
MY
132ifneq ($(KBUILD_SRC),)
133 $(Q)mkdir -p include/asm
0e7368c6
MY
134 $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
135 dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \
136 else \
137 dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \
138 fi; \
139 ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch
ffe29ebc 140else
0e7368c6
MY
141 $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
142 dest=../../mach-$(SOC)/include/mach; \
143 else \
144 dest=arch-$(if $(SOC),$(SOC),$(CPU)); \
145 fi; \
146 ln -fsn $$dest arch/$(ARCH)/include/asm/arch
51148790 147endif
a350c6a6 148endif
51148790
MY
149
150PHONY += FORCE
151FORCE:
152
153.PHONY: $(PHONY)