blob: 58e1642fb93182ee543363fde0b0573595a9180c [file] [log] [blame]
Masahiro Yamada51148792014-07-30 14:08:17 +09001# 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.
9
10# obj is "include" or "spl/include" or "tpl/include"
11# for non-SPL, SPL, TPL, respectively
12include $(obj)/config/auto.conf
13
14include scripts/Kbuild.include
15
16# Need to define CC and CPP again here in case the top Makefile did not
17# include config.mk. Some architectures expect CROSS_COMPILE to be defined
18# in arch/$(ARCH)/config.mk
19CC = $(CROSS_COMPILE)gcc
20CPP = $(CC) -E
21
22include config.mk
23
24UBOOTINCLUDE := \
25 -I$(obj) \
26 -Iinclude \
27 $(if $(KBUILD_SRC), -I$(srctree)/include) \
28 -I$(srctree)/arch/$(ARCH)/include \
29 -include $(srctree)/include/linux/kconfig.h
30
31c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \
32 $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
33
34quiet_cmd_autoconf_dep = GEN $@
35 cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \
36 -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || { \
37 rm $@; false; \
38 }
39include/autoconf.mk.dep: FORCE
40 $(call cmd,autoconf_dep)
41
42# We are migrating from board headers to Kconfig little by little.
43# In the interim, we use both of
44# - include/config/auto.conf (generated by Kconfig)
45# - include/autoconf.mk (used in the U-Boot conventional configuration)
46# The following rule creates autoconf.mk
47# include/config/auto.conf is grepped in order to avoid duplication of the
48# same CONFIG macros
49quiet_cmd_autoconf = GEN $@
50 cmd_autoconf = \
51 $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \
52 sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \
53 while read line; do \
54 if ! grep -q "$${line%=*}=" $(obj)/config/auto.conf; then \
55 echo "$$line"; \
56 fi \
57 done > $@; \
58 rm $@.tmp; \
59 } || { \
60 rm $@.tmp; false; \
61 }
62
63$(obj)/autoconf.mk: FORCE
64 $(call cmd,autoconf)
65
66include/autoconf.mk include/autoconf.mk.dep: include/config.h
67
68# include/config.h
69# Prior to Kconfig, it was generated by mkconfig. Now it is created here.
70define filechk_config_h
71 (echo "/* Automatically generated - do not edit */"; \
72 for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \
73 echo \#define CONFIG_$$i \
74 | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \
75 done; \
76 echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
Masahiro Yamada51148792014-07-30 14:08:17 +090077 echo \#include \<config_defaults.h\>; \
78 echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
79 echo \#include \<asm/config.h\>; \
80 echo \#include \<config_fallbacks.h\>; \
81 echo \#include \<config_uncmd_spl.h\>; )
82endef
83
84include/config.h: scripts/Makefile.autoconf create_symlink FORCE
85 $(call filechk,config_h)
86
87# symbolic links
Masahiro Yamada0e7368c2015-02-20 17:04:12 +090088# If arch/$(ARCH)/mach-$(SOC)/include/mach exists,
89# make a symbolic link to that directory.
90# Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC).
Masahiro Yamada51148792014-07-30 14:08:17 +090091PHONY += create_symlink
92create_symlink:
93ifneq ($(KBUILD_SRC),)
94 $(Q)mkdir -p include/asm
Masahiro Yamada0e7368c2015-02-20 17:04:12 +090095 $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
96 dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \
97 else \
98 dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \
99 fi; \
100 ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch
Masahiro Yamadaffe29eb2014-10-30 11:06:11 +0900101else
Masahiro Yamada0e7368c2015-02-20 17:04:12 +0900102 $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
103 dest=../../mach-$(SOC)/include/mach; \
104 else \
105 dest=arch-$(if $(SOC),$(SOC),$(CPU)); \
106 fi; \
107 ln -fsn $$dest arch/$(ARCH)/include/asm/arch
Masahiro Yamada51148792014-07-30 14:08:17 +0900108endif
Masahiro Yamada51148792014-07-30 14:08:17 +0900109
110PHONY += FORCE
111FORCE:
112
113.PHONY: $(PHONY)