Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 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. |
| 9 | |
Masahiro Yamada | e02ee25 | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 10 | __all: include/autoconf.mk include/autoconf.mk.dep |
| 11 | |
| 12 | ifeq ($(shell grep -q '^CONFIG_SPL=y' include/config/auto.conf 2>/dev/null && echo y),y) |
| 13 | __all: spl/include/autoconf.mk |
| 14 | endif |
| 15 | |
| 16 | ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && echo y),y) |
| 17 | __all: tpl/include/autoconf.mk |
| 18 | endif |
| 19 | |
| 20 | include include/config/auto.conf |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 21 | |
| 22 | include scripts/Kbuild.include |
| 23 | |
| 24 | # Need to define CC and CPP again here in case the top Makefile did not |
| 25 | # include config.mk. Some architectures expect CROSS_COMPILE to be defined |
| 26 | # in arch/$(ARCH)/config.mk |
| 27 | CC = $(CROSS_COMPILE)gcc |
| 28 | CPP = $(CC) -E |
| 29 | |
| 30 | include config.mk |
| 31 | |
| 32 | UBOOTINCLUDE := \ |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 33 | -Iinclude \ |
| 34 | $(if $(KBUILD_SRC), -I$(srctree)/include) \ |
| 35 | -I$(srctree)/arch/$(ARCH)/include \ |
| 36 | -include $(srctree)/include/linux/kconfig.h |
| 37 | |
| 38 | c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \ |
| 39 | $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) |
| 40 | |
| 41 | quiet_cmd_autoconf_dep = GEN $@ |
| 42 | cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \ |
| 43 | -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || { \ |
| 44 | rm $@; false; \ |
| 45 | } |
| 46 | include/autoconf.mk.dep: FORCE |
| 47 | $(call cmd,autoconf_dep) |
| 48 | |
| 49 | # We are migrating from board headers to Kconfig little by little. |
| 50 | # In the interim, we use both of |
| 51 | # - include/config/auto.conf (generated by Kconfig) |
| 52 | # - include/autoconf.mk (used in the U-Boot conventional configuration) |
| 53 | # The following rule creates autoconf.mk |
| 54 | # include/config/auto.conf is grepped in order to avoid duplication of the |
| 55 | # same CONFIG macros |
| 56 | quiet_cmd_autoconf = GEN $@ |
| 57 | cmd_autoconf = \ |
Masahiro Yamada | e02ee25 | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 58 | $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \ |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 59 | sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \ |
| 60 | while read line; do \ |
Joe Hershberger | 7740f65 | 2015-05-19 13:21:18 -0500 | [diff] [blame] | 61 | if [ -n "${KCONFIG_IGNORE_DUPLICATES}" ] || \ |
| 62 | ! grep -q "$${line%=*}=" include/config/auto.conf; then \ |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 63 | echo "$$line"; \ |
| 64 | fi \ |
| 65 | done > $@; \ |
| 66 | rm $@.tmp; \ |
| 67 | } || { \ |
| 68 | rm $@.tmp; false; \ |
| 69 | } |
| 70 | |
Masahiro Yamada | e02ee25 | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 71 | include/autoconf.mk: FORCE |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 72 | $(call cmd,autoconf) |
| 73 | |
Masahiro Yamada | e02ee25 | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 74 | spl/include/autoconf.mk: FORCE |
| 75 | $(Q)mkdir -p $(dir $@) |
| 76 | $(call cmd,autoconf,-DCONFIG_SPL_BUILD) |
| 77 | |
| 78 | tpl/include/autoconf.mk: FORCE |
| 79 | $(Q)mkdir -p $(dir $@) |
| 80 | $(call cmd,autoconf,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD) |
| 81 | |
| 82 | include/autoconf.mk include/autoconf.mk.dep \ |
| 83 | spl/include/autoconf.mk tpl/include/autoconf.mk: include/config.h |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 84 | |
| 85 | # include/config.h |
| 86 | # Prior to Kconfig, it was generated by mkconfig. Now it is created here. |
| 87 | define filechk_config_h |
| 88 | (echo "/* Automatically generated - do not edit */"; \ |
| 89 | for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \ |
| 90 | echo \#define CONFIG_$$i \ |
| 91 | | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \ |
| 92 | done; \ |
| 93 | echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\ |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 94 | echo \#include \<config_defaults.h\>; \ |
Masahiro Yamada | e02ee25 | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 95 | echo \#include \<config_uncmd_spl.h\>; \ |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 96 | echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \ |
| 97 | echo \#include \<asm/config.h\>; \ |
Masahiro Yamada | e02ee25 | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 98 | echo \#include \<config_fallbacks.h\>;) |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 99 | endef |
| 100 | |
| 101 | include/config.h: scripts/Makefile.autoconf create_symlink FORCE |
| 102 | $(call filechk,config_h) |
| 103 | |
| 104 | # symbolic links |
Masahiro Yamada | 0e7368c | 2015-02-20 17:04:12 +0900 | [diff] [blame] | 105 | # If arch/$(ARCH)/mach-$(SOC)/include/mach exists, |
| 106 | # make a symbolic link to that directory. |
| 107 | # Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC). |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 108 | PHONY += create_symlink |
| 109 | create_symlink: |
Masahiro Yamada | a350c6a | 2015-07-15 20:59:29 +0900 | [diff] [blame] | 110 | ifdef CONFIG_CREATE_ARCH_SYMLINK |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 111 | ifneq ($(KBUILD_SRC),) |
| 112 | $(Q)mkdir -p include/asm |
Masahiro Yamada | 0e7368c | 2015-02-20 17:04:12 +0900 | [diff] [blame] | 113 | $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \ |
| 114 | dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \ |
| 115 | else \ |
| 116 | dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \ |
| 117 | fi; \ |
| 118 | ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch |
Masahiro Yamada | ffe29eb | 2014-10-30 11:06:11 +0900 | [diff] [blame] | 119 | else |
Masahiro Yamada | 0e7368c | 2015-02-20 17:04:12 +0900 | [diff] [blame] | 120 | $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \ |
| 121 | dest=../../mach-$(SOC)/include/mach; \ |
| 122 | else \ |
| 123 | dest=arch-$(if $(SOC),$(SOC),$(CPU)); \ |
| 124 | fi; \ |
| 125 | ln -fsn $$dest arch/$(ARCH)/include/asm/arch |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 126 | endif |
Masahiro Yamada | a350c6a | 2015-07-15 20:59:29 +0900 | [diff] [blame] | 127 | endif |
Masahiro Yamada | 5114879 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 128 | |
| 129 | PHONY += FORCE |
| 130 | FORCE: |
| 131 | |
| 132 | .PHONY: $(PHONY) |