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