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