Masahiro Yamada | 60bb734 | 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. |
Tom Rini | c11fe7d | 2016-01-14 18:24:44 -0500 | [diff] [blame] | 9 | # |
| 10 | # SPDX-License-Identifier: GPL-2.0 |
| 11 | # |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 12 | |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 13 | __all: include/autoconf.mk include/autoconf.mk.dep |
| 14 | |
| 15 | ifeq ($(shell grep -q '^CONFIG_SPL=y' include/config/auto.conf 2>/dev/null && echo y),y) |
| 16 | __all: spl/include/autoconf.mk |
| 17 | endif |
| 18 | |
| 19 | ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && echo y),y) |
| 20 | __all: tpl/include/autoconf.mk |
| 21 | endif |
| 22 | |
| 23 | include include/config/auto.conf |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 24 | |
| 25 | include 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 |
| 30 | CC = $(CROSS_COMPILE)gcc |
| 31 | CPP = $(CC) -E |
| 32 | |
| 33 | include config.mk |
| 34 | |
| 35 | UBOOTINCLUDE := \ |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 36 | -Iinclude \ |
| 37 | $(if $(KBUILD_SRC), -I$(srctree)/include) \ |
| 38 | -I$(srctree)/arch/$(ARCH)/include \ |
| 39 | -include $(srctree)/include/linux/kconfig.h |
| 40 | |
| 41 | c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \ |
| 42 | $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) |
| 43 | |
| 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 > $@ || { \ |
| 47 | rm $@; false; \ |
| 48 | } |
| 49 | include/autoconf.mk.dep: FORCE |
| 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 |
| 59 | quiet_cmd_autoconf = GEN $@ |
| 60 | cmd_autoconf = \ |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 61 | $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \ |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 62 | sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \ |
| 63 | while read line; do \ |
Joe Hershberger | 765442b | 2015-05-19 13:21:18 -0500 | [diff] [blame] | 64 | if [ -n "${KCONFIG_IGNORE_DUPLICATES}" ] || \ |
| 65 | ! grep -q "$${line%=*}=" include/config/auto.conf; then \ |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 66 | echo "$$line"; \ |
| 67 | fi \ |
| 68 | done > $@; \ |
| 69 | rm $@.tmp; \ |
| 70 | } || { \ |
| 71 | rm $@.tmp; false; \ |
| 72 | } |
| 73 | |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 74 | include/autoconf.mk: FORCE |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 75 | $(call cmd,autoconf) |
| 76 | |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 77 | spl/include/autoconf.mk: FORCE |
| 78 | $(Q)mkdir -p $(dir $@) |
| 79 | $(call cmd,autoconf,-DCONFIG_SPL_BUILD) |
| 80 | |
| 81 | tpl/include/autoconf.mk: FORCE |
| 82 | $(Q)mkdir -p $(dir $@) |
| 83 | $(call cmd,autoconf,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD) |
| 84 | |
| 85 | include/autoconf.mk include/autoconf.mk.dep \ |
| 86 | spl/include/autoconf.mk tpl/include/autoconf.mk: include/config.h |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 87 | |
| 88 | # include/config.h |
| 89 | # Prior to Kconfig, it was generated by mkconfig. Now it is created here. |
| 90 | define filechk_config_h |
| 91 | (echo "/* Automatically generated - do not edit */"; \ |
| 92 | for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \ |
| 93 | echo \#define CONFIG_$$i \ |
| 94 | | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \ |
| 95 | done; \ |
| 96 | echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\ |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 97 | echo \#include \<config_defaults.h\>; \ |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 98 | echo \#include \<config_uncmd_spl.h\>; \ |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 99 | echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \ |
| 100 | echo \#include \<asm/config.h\>; \ |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 101 | echo \#include \<config_fallbacks.h\>;) |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 102 | endef |
| 103 | |
| 104 | include/config.h: scripts/Makefile.autoconf create_symlink FORCE |
| 105 | $(call filechk,config_h) |
| 106 | |
| 107 | # symbolic links |
Masahiro Yamada | 2fa3dd9 | 2015-02-20 17:04:12 +0900 | [diff] [blame] | 108 | # If arch/$(ARCH)/mach-$(SOC)/include/mach exists, |
| 109 | # make a symbolic link to that directory. |
| 110 | # Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC). |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 111 | PHONY += create_symlink |
| 112 | create_symlink: |
Masahiro Yamada | 5865450 | 2015-07-15 20:59:29 +0900 | [diff] [blame] | 113 | ifdef CONFIG_CREATE_ARCH_SYMLINK |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 114 | ifneq ($(KBUILD_SRC),) |
| 115 | $(Q)mkdir -p include/asm |
Masahiro Yamada | 2fa3dd9 | 2015-02-20 17:04:12 +0900 | [diff] [blame] | 116 | $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \ |
| 117 | dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \ |
| 118 | else \ |
| 119 | dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \ |
| 120 | fi; \ |
| 121 | ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch |
Masahiro Yamada | 4e1c3c7 | 2014-10-30 11:06:11 +0900 | [diff] [blame] | 122 | else |
Masahiro Yamada | 2fa3dd9 | 2015-02-20 17:04:12 +0900 | [diff] [blame] | 123 | $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \ |
| 124 | dest=../../mach-$(SOC)/include/mach; \ |
| 125 | else \ |
| 126 | dest=arch-$(if $(SOC),$(SOC),$(CPU)); \ |
| 127 | fi; \ |
| 128 | ln -fsn $$dest arch/$(ARCH)/include/asm/arch |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 129 | endif |
Masahiro Yamada | 5865450 | 2015-07-15 20:59:29 +0900 | [diff] [blame] | 130 | endif |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 131 | |
| 132 | PHONY += FORCE |
| 133 | FORCE: |
| 134 | |
| 135 | .PHONY: $(PHONY) |