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