[U-Boot] [PATCH v2 06/11] kconfig: switch to Kconfig
Masahiro Yamada
yamada.m at jp.panasonic.com
Wed May 28 15:05:07 CEST 2014
This commit enables Kconfig.
Going forward, we use Kconfig for board configuration.
mkconfig will never be used. Nor will include/config.mk be generated.
Kconfig must be adjusted for U-Boot because our situation is
a little more complicated than Linux Kernel.
We have to generate multiple binary images (Full U-Boot, SPL, TPL)
from one source tree.
Each image needs its own configuration input.
In order to keep this scheme in Kconfig, some files must be modified.
But the modification should be minimum.
The location of Kconfig related files is as follows:
[1] Full U-Boot image
- configs/<board>_defconfig (default configuration)
- .config (saved config list)
- include/config/auto.conf (for use in makefiles)
- include/generated/autoconf.h (for use in C sources)
- include/config/* (for if_changed_dep)
[2] SPL
- configs/spl/<board>_defconfig (default configuration)
- spl/.config (saved config list)
- spl/include/config/auto.conf (for use in makefiles)
- spl/include/generated/autoconf.h (for use in C sources)
- spl/include/config/* (for if_changed_dep)
[3] TPL
- configs/tpl/<board>_defconfig (default configuration)
- tpl/.config (saved config list)
- tpl/include/config/auto.conf (for use in makefiles)
- tpl/include/generated/autoconf.h (for use in C sources)
- tpl/include/config/* (for if_changed_dep)
Usage:
Execute "make <board>_defconfig" to configure board and then run "make".
Or "make <board>_defconfig all" to configure and build in one time.
You can use "make config", "make menuconfig" etc. to create
a new .config or modify the existing one.
In Kconfig for U-boot, the configuration is done on three levels at most.
By the way, there is another item worth remarking here:
coexistence of Kconfig and board herder files.
Prior to Kconfig, we used C headers to define a set of configs.
We expect a very long term to migrate from C headers to Kconfig.
Two different infractructure must coexist in the interim.
In our former configuration scheme, include/autoconf.mk was generated
for use in makefiles.
It is still generated under include/, spl/include/, tpl/include/ directory
for the full, SPL, TPL image, respectively.
Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---
Changes in v2:
- Put dirty build rule into scripts/multiple_config.sh and
scripts/Makefile.autoconf
- Fix dependency tracking.
In v1, any change to Kconfig triggered re-complile of all objects.
In this version, re-compile is kept at a minimum.
- Fix a clean-source check
In v1, clean source tree check did not work correctly for
out-of-tree build.
.gitignore | 2 -
Makefile | 119 ++++++++++++++++++--------------------
arch/m68k/cpu/mcf52x2/config.mk | 16 ++---
arch/m68k/cpu/mcf532x/config.mk | 6 +-
arch/m68k/cpu/mcf5445x/config.mk | 4 +-
arch/powerpc/cpu/ppc4xx/config.mk | 4 +-
config.mk | 10 ++++
include/.gitignore | 1 -
scripts/Makefile | 2 +-
scripts/Makefile.autoconf | 100 ++++++++++++++++++++++++++++++++
scripts/Makefile.build | 31 ++++------
scripts/basic/fixdep.c | 6 +-
scripts/kconfig/Makefile | 11 +++-
scripts/kconfig/confdata.c | 8 +++
scripts/multiple_config.sh | 57 ++++++++++++++++++
scripts/silentoldconfig.sh | 71 +++++++++++++++++++++++
spl/Makefile | 31 +---------
tools/Makefile | 2 +-
tools/env/Makefile | 2 +-
19 files changed, 349 insertions(+), 134 deletions(-)
create mode 100644 scripts/Makefile.autoconf
create mode 100644 scripts/multiple_config.sh
create mode 100644 scripts/silentoldconfig.sh
diff --git a/.gitignore b/.gitignore
index a6b2d1c..abb92cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,8 +56,6 @@
#
/include/config/
/include/generated/
-/include/spl-autoconf.mk
-/include/tpl-autoconf.mk
# stgit generated dirs
patches-*
diff --git a/Makefile b/Makefile
index e38fd2f..d5488d2 100644
--- a/Makefile
+++ b/Makefile
@@ -166,9 +166,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH
-MKCONFIG := $(srctree)/mkconfig
-export MKCONFIG
-
# Make sure CDPATH settings don't interfere
unexport CDPATH
@@ -189,9 +186,6 @@ HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
export HOSTARCH HOSTOS
-# Deal with colliding definitions from tcsh etc.
-VENDOR=
-
#########################################################################
# set default to nothing for native builds
@@ -199,6 +193,9 @@ ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?=
endif
+KCONFIG_CONFIG ?= .config
+export KCONFIG_CONFIG
+
# SHELL used by kbuild
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -474,31 +471,53 @@ ifeq ($(config-targets),1)
# *config targets only - make sure prerequisites are updated, and descend
# in scripts/kconfig to make the *config target
-# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
-# KBUILD_DEFCONFIG may point out an alternative default configuration
-# used for 'make defconfig'
+KBUILD_DEFCONFIG := sandbox_defconfig
+export KBUILD_DEFCONFIG KBUILD_KCONFIG
-%_config:: outputmakefile
- @$(MKCONFIG) -A $(@:_config=)
+config: scripts_basic outputmakefile FORCE
+ $(Q)mkdir -p include/config
+ $(Q)$(MAKE) $(build)=scripts/kconfig $@
+ +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiple_config.sh $@
+
+%config: scripts_basic outputmakefile FORCE
+ $(Q)mkdir -p include/config
+ $(Q)$(MAKE) $(build)=scripts/kconfig $@
+ +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiple_config.sh $@
else
# ===========================================================================
# Build targets only - this includes vmlinux, arch specific targets, clean
# targets and others. In general all targets except *config targets.
-# load ARCH, BOARD, and CPU configuration
--include include/config.mk
-
ifeq ($(dot-config),1)
# Read in config
+-include include/config/auto.conf
+
+# Read in dependencies to all Kconfig* files, make sure to run
+# oldconfig if changes are detected.
+-include include/config/auto.conf.cmd
+
+# To avoid any implicit rule to kick in, define an empty command
+$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
+
+# If .config is newer than include/config/auto.conf, someone tinkered
+# with it and forgot to run make oldconfig.
+# if auto.conf.cmd is missing then we are probably in a cleaned tree so
+# we execute the config step to be sure to catch updated Kconfig files
+include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
+ $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
+
-include include/autoconf.mk
-include include/autoconf.mk.dep
-# load other configuration
+# We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf
+# is up-to-date. When we switch to a different board configuration, old CONFIG
+# macros are still remaining in include/config/auto.conf. Without the following
+# gimmick, wrong config.mk would be included leading nasty warnings/errors.
+autoconf_is_update := $(if $(wildcard $(KCONFIG_CONFIG)),$(shell find \
+ include/config -name auto.conf -newer $(KCONFIG_CONFIG)))
+ifneq ($(autoconf_is_update),)
include $(srctree)/config.mk
-
-ifeq ($(wildcard include/config.mk),)
-$(error "System not configured - see README")
endif
# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
@@ -533,8 +552,8 @@ ifndef LDSCRIPT
endif
else
-
-
+# Dummy target needed, because used as prerequisite
+include/config/auto.conf: ;
endif # $(dot-config)
KBUILD_CFLAGS += -Os #-fomit-frame-pointer
@@ -597,7 +616,8 @@ KBUILD_CFLAGS += $(KCFLAGS)
UBOOTINCLUDE := \
-Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
- -I$(srctree)/arch/$(ARCH)/include
+ -I$(srctree)/arch/$(ARCH)/include \
+ -include $(srctree)/include/linux/kconfig.h
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)
@@ -1033,7 +1053,7 @@ define filechk_uboot.release
endef
# Store (new) UBOOTRELEASE string in include/config/uboot.release
-include/config/uboot.release: Makefile FORCE
+include/config/uboot.release: include/config/auto.conf FORCE
$(call filechk,uboot.release)
@@ -1051,8 +1071,8 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
# 1) Check that make has not been executed in the kernel src $(srctree)
prepare3: include/config/uboot.release
ifneq ($(KBUILD_SRC),)
- @$(kecho) ' Using $(srctree) as source for u-boot'
- $(Q)if [ -f $(srctree)/include/config.mk ]; then \
+ @$(kecho) ' Using $(srctree) as source for U-Boot'
+ $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
echo >&2 " in the '$(srctree)' directory.";\
/bin/false; \
@@ -1062,7 +1082,8 @@ endif
# prepare2 creates a makefile if using a separate output directory
prepare2: prepare3 outputmakefile
-prepare1: prepare2 $(version_h) $(timestamp_h)
+prepare1: prepare2 $(version_h) $(timestamp_h) \
+ include/config/auto.conf
ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
ifeq ($(CONFIG_SYS_GENERIC_BOARD),y)
@echo >&2 " Your architecture does not support generic board."
@@ -1104,29 +1125,6 @@ $(version_h): include/config/uboot.release FORCE
$(timestamp_h): $(srctree)/Makefile FORCE
$(call filechk,timestamp.h)
-#
-# Auto-generate the autoconf.mk file (which is included by all makefiles)
-#
-# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
-# the dep file is only include in this top level makefile to determine when
-# to regenerate the autoconf.mk file.
-
-quiet_cmd_autoconf_dep = GEN $@
- cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
- -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
-
-include/autoconf.mk.dep: include/config.h include/common.h
- $(call cmd,autoconf_dep)
-
-quiet_cmd_autoconf = GEN $@
- cmd_autoconf = \
- $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
- sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
- rm $@.tmp
-
-include/autoconf.mk: include/config.h
- $(call cmd,autoconf)
-
# ---------------------------------------------------------------------------
PHONY += depend dep
@@ -1164,7 +1162,7 @@ spl/u-boot-spl: tools prepare
$(Q)$(MAKE) obj=spl -f $(srctree)/spl/Makefile all
tpl/u-boot-tpl.bin: tools prepare
- $(Q)$(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
+ $(Q)$(MAKE) obj=tpl -f $(srctree)/spl/Makefile all
TAG_SUBDIRS := $(u-boot-dirs) include
@@ -1239,22 +1237,20 @@ include/license.h: tools/bin2header COPYING
# Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR)
-CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h \
- include/autoconf.mk* include/spl-autoconf.mk \
- include/tpl-autoconf.mk
+CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h
# Directories & files removed with 'make clobber'
-CLOBBER_DIRS += $(patsubst %,spl/%, $(filter-out Makefile, \
+CLOBBER_DIRS += $(patsubst %,spl/%, $(filter-out Makefile include, \
$(shell ls -1 spl 2>/dev/null))) \
- tpl
+ $(patsubst %,tpl/%, $(filter-out include, \
+ $(shell ls -1 tpl 2>/dev/null)))
CLOBBER_FILES += u-boot* MLO* SPL System.map nand_spl/u-boot*
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config include/generated \
+MRPROPER_DIRS += include/config include/generated spl/include tpl \
.tmp_objdiff
-MRPROPER_FILES += .config .config.old \
- tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
- include/config.h include/config.mk
+MRPROPER_FILES += .config* spl/.config* include/autoconf.mk* include/config.h \
+ tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
# clean - Delete most, but leave enough to build external modules
#
@@ -1333,10 +1329,9 @@ help:
@echo ' mrproper - Remove all generated files + config + various backup files'
@echo ' distclean - mrproper + remove editor backup and patch files'
@echo ''
-# uncomment after adding Kconfig feature
-# @echo 'Configuration targets:'
-# @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
-# @echo ''
+ @echo 'Configuration targets:'
+ @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
+ @echo ''
@echo 'Other generic targets:'
@echo ' all - Build all necessary images depending on configuration'
@echo ' u-boot - Build the bare u-boot'
diff --git a/arch/m68k/cpu/mcf52x2/config.mk b/arch/m68k/cpu/mcf52x2/config.mk
index 34ad99e..f66000b 100644
--- a/arch/m68k/cpu/mcf52x2/config.mk
+++ b/arch/m68k/cpu/mcf52x2/config.mk
@@ -7,14 +7,14 @@
# SPDX-License-Identifier: GPL-2.0+
#
-cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
-is5208:=$(shell grep CONFIG_M5208 $(srctree)/include/$(cfg))
-is5249:=$(shell grep CONFIG_M5249 $(srctree)/include/$(cfg))
-is5253:=$(shell grep CONFIG_M5253 $(srctree)/include/$(cfg))
-is5271:=$(shell grep CONFIG_M5271 $(srctree)/include/$(cfg))
-is5272:=$(shell grep CONFIG_M5272 $(srctree)/include/$(cfg))
-is5275:=$(shell grep CONFIG_M5275 $(srctree)/include/$(cfg))
-is5282:=$(shell grep CONFIG_M5282 $(srctree)/include/$(cfg))
+cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
+is5208:=$(shell grep CONFIG_M5208 $(cfg))
+is5249:=$(shell grep CONFIG_M5249 $(cfg))
+is5253:=$(shell grep CONFIG_M5253 $(cfg))
+is5271:=$(shell grep CONFIG_M5271 $(cfg))
+is5272:=$(shell grep CONFIG_M5272 $(cfg))
+is5275:=$(shell grep CONFIG_M5275 $(cfg))
+is5282:=$(shell grep CONFIG_M5282 $(cfg))
ifneq (,$(findstring CONFIG_M5208,$(is5208)))
PLATFORM_CPPFLAGS += -mcpu=5208
diff --git a/arch/m68k/cpu/mcf532x/config.mk b/arch/m68k/cpu/mcf532x/config.mk
index af94354..2efb60f 100644
--- a/arch/m68k/cpu/mcf532x/config.mk
+++ b/arch/m68k/cpu/mcf532x/config.mk
@@ -7,9 +7,9 @@
# SPDX-License-Identifier: GPL-2.0+
#
-cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
-is5301x:=$(shell grep CONFIG_MCF5301x $(srctree)/include/$(cfg))
-is532x:=$(shell grep CONFIG_MCF532x $(srctree)/include/$(cfg))
+cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
+is5301x:=$(shell grep CONFIG_MCF5301x $(cfg))
+is532x:=$(shell grep CONFIG_MCF532x $(cfg))
ifneq (,$(findstring CONFIG_MCF5301x,$(is5301x)))
PLATFORM_CPPFLAGS += -mcpu=53015 -fPIC
diff --git a/arch/m68k/cpu/mcf5445x/config.mk b/arch/m68k/cpu/mcf5445x/config.mk
index 5fd0d4d..13f8a9f 100644
--- a/arch/m68k/cpu/mcf5445x/config.mk
+++ b/arch/m68k/cpu/mcf5445x/config.mk
@@ -9,8 +9,8 @@
# SPDX-License-Identifier: GPL-2.0+
#
-cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
-is5441x:=$(shell grep CONFIG_MCF5441x $(srctree)/include/$(cfg))
+cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
+is5441x:=$(shell grep CONFIG_MCF5441x $(cfg))
ifneq (,$(findstring CONFIG_MCF5441x,$(is5441x)))
PLATFORM_CPPFLAGS += -mcpu=54418 -fPIC
diff --git a/arch/powerpc/cpu/ppc4xx/config.mk b/arch/powerpc/cpu/ppc4xx/config.mk
index 102f069..a7253b2 100644
--- a/arch/powerpc/cpu/ppc4xx/config.mk
+++ b/arch/powerpc/cpu/ppc4xx/config.mk
@@ -7,8 +7,8 @@
PLATFORM_CPPFLAGS += -DCONFIG_4xx -mstring -msoft-float
-cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
-is440:=$(shell grep CONFIG_440 $(srctree)/include/$(cfg))
+cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
+is440:=$(shell grep CONFIG_440 $(cfg))
ifneq (,$(findstring CONFIG_440,$(is440)))
PLATFORM_CPPFLAGS += -Wa,-m440 -mcpu=440
diff --git a/config.mk b/config.mk
index 05864aa..3b74e99 100644
--- a/config.mk
+++ b/config.mk
@@ -20,6 +20,16 @@ LDFLAGS_FINAL :=
OBJCOPYFLAGS :=
#########################################################################
+ARCH := $(CONFIG_SYS_ARCH:"%"=%)
+CPU := $(CONFIG_SYS_CPU:"%"=%)
+BOARD := $(CONFIG_SYS_BOARD:"%"=%)
+ifneq ($(CONFIG_SYS_VENDOR),)
+VENDOR := $(CONFIG_SYS_VENDOR:"%"=%)
+endif
+ifneq ($(CONFIG_SYS_SOC),)
+SOC := $(CONFIG_SYS_SOC:"%"=%)
+endif
+
# Some architecture config.mk files need to know what CPUDIR is set to,
# so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
# Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
diff --git a/include/.gitignore b/include/.gitignore
index bf142fc..8e41a95 100644
--- a/include/.gitignore
+++ b/include/.gitignore
@@ -2,4 +2,3 @@
/bmp_logo.h
/bmp_logo_data.h
/config.h
-/config.mk
diff --git a/scripts/Makefile b/scripts/Makefile
index 68c998e..efe25bf 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -13,4 +13,4 @@ build_docproc: $(obj)/docproc
@:
# Let clean descend into subdirs
-subdir- += basic
+subdir- += basic kconfig
diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
new file mode 100644
index 0000000..db62c70
--- /dev/null
+++ b/scripts/Makefile.autoconf
@@ -0,0 +1,100 @@
+# This helper makefile is used for creating
+# - symbolic links (arch/$ARCH/include/asm/{arch,proc}
+# - include/autoconf.mk, {spl,tpl}/include/autoconf.mk
+# - include/config.h
+#
+# When our migration to Kconfig is done
+# (= When we move all CONFIGs from header files to Kconfig)
+# this makefile can be deleted.
+
+# obj is "include" or "spl/include" or "tpl/include"
+# for non-SPL, SPL, TPL, respectively
+include $(obj)/config/auto.conf
+
+include scripts/Kbuild.include
+
+# Need to define CC and CPP again here because config.mk may not
+# be included from the top Makefile. Some architectures expect
+# CROSS_COMPILE to be defined in arch/$(ARCH)/config.mk
+CC = $(CROSS_COMPILE)gcc
+CPP = $(CC) -E
+
+include config.mk
+
+UBOOTINCLUDE := \
+ -I$(obj) \
+ -Iinclude \
+ $(if $(KBUILD_SRC), -I$(srctree)/include) \
+ -I$(srctree)/arch/$(ARCH)/include \
+ -include $(srctree)/include/linux/kconfig.h
+
+c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \
+ $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
+
+quiet_cmd_autoconf_dep = GEN $@
+ cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \
+ -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || rm $@
+
+include/autoconf.mk.dep: FORCE
+ $(call cmd,autoconf_dep)
+
+# We are migrating from board headers to Kconfig little by little.
+# In the interim, we use both of
+# - include/config/auto.conf (generated by Kconfig)
+# - include/autoconf.mk (used in the U-Boot conventional configuration)
+# The following rule creates autoconf.mk
+# include/config/auto.conf is grepped in order to avoid duplication of the
+# same CONFIG macros
+quiet_cmd_autoconf = GEN $@
+ cmd_autoconf = \
+ $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \
+ while read line; do \
+ if ! grep -q "$${line%=*}=" $(obj)/config/auto.conf; then \
+ echo "$$line"; \
+ fi \
+ done > $@; \
+ rm $@.tmp
+
+$(obj)/autoconf.mk: FORCE
+ $(call cmd,autoconf)
+
+include/autoconf.mk include/autoconf.mk.dep: include/config.h
+
+# include/config.h
+# Prior to Kconfig, it was generated by mkconfig. Now it is created here.
+define filechk_config_h
+ (echo "/* Automatically generated - do not edit */"; \
+ for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \
+ echo \#define CONFIG_$$i \
+ | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \
+ done; \
+ echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
+ echo \#include \<config_cmd_defaults.h\>; \
+ echo \#include \<config_defaults.h\>; \
+ echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
+ echo \#include \<asm/config.h\>; \
+ echo \#include \<config_fallbacks.h\>; \
+ echo \#include \<config_uncmd_spl.h\>; )
+endef
+
+include/config.h: scripts/Makefile.autoconf create_symlink FORCE
+ $(call filechk,config_h)
+
+# symbolic links
+PHONY += create_symlink
+create_symlink:
+ifneq ($(KBUILD_SRC),)
+ $(Q)mkdir -p include/asm
+endif
+ $(Q)ln -fsn $(srctree)/arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)) \
+ $(if $(KBUILD_SRC),,arch/$(ARCH)/)include/asm/arch
+ifeq ($(ARCH),arm)
+ $(Q)ln -fsn $(srctree)/arch/$(ARCH)/include/asm/proc-armv \
+ $(if $(KBUILD_SRC),,arch/$(ARCH)/)include/asm/proc
+endif
+
+PHONY += FORCE
+FORCE:
+
+.PHONY: $(PHONY)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 6416c1a..650cef1 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -3,14 +3,14 @@
# ==========================================================================
# Modified for U-Boot
-ifeq ($(CONFIG_TPL_BUILD),y)
- src := $(patsubst tpl/%,%,$(obj))
-else
- ifeq ($(CONFIG_SPL_BUILD),y)
- src := $(patsubst spl/%,%,$(obj))
- else
- src := $(obj)
- endif
+prefix := tpl
+src := $(patsubst $(prefix)/%,%,$(obj))
+ifeq ($(obj),$(src))
+prefix := spl
+src := $(patsubst $(prefix)/%,%,$(obj))
+ifeq ($(obj),$(src))
+prefix := .
+endif
endif
PHONY := __build
@@ -40,18 +40,9 @@ subdir-asflags-y :=
subdir-ccflags-y :=
# Read auto.conf if it exists, otherwise ignore
--include include/config/auto.conf
-
-# Added for U-Boot: Load U-Boot configuration
-ifeq ($(CONFIG_TPL_BUILD),y)
- -include include/tpl-autoconf.mk
-else
- ifeq ($(CONFIG_SPL_BUILD),y)
- -include include/spl-autoconf.mk
- else
- -include include/autoconf.mk
- endif
-endif
+# Modified for U-Boot
+-include $(prefix)/include/config/auto.conf
+-include $(prefix)/include/autoconf.mk
include scripts/Kbuild.include
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 078fe1d..3cff12d 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -221,7 +221,11 @@ static void use_config(const char *m, int slen)
define_config(m, slen, hash);
- printf(" $(wildcard include/config/");
+ /* printf(" $(wildcard include/config/"); */
+ /* modified for U-Boot */
+ printf(" $(wildcard %sinclude/config/",
+ strncmp(depfile, "spl/", 4) ?
+ (strncmp(depfile, "tpl/", 4) ? "" : "tpl/") : "spl/");
for (i = 0; i < slen; i++) {
c = m[i];
if (c == '_')
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 844bc9d..53a5ce4 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -14,6 +14,9 @@ endif
# We need this, in case the user has it in its environment
unexport CONFIG_
+# Added for U-Boot
+export KCONFIG_OBJDIR :=
+
xconfig: $(obj)/qconf
$< $(Kconfig)
@@ -98,11 +101,15 @@ ifeq ($(KBUILD_DEFCONFIG),)
$< --defconfig $(Kconfig)
else
@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
- $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
+ @: Modified for U-Boot
+ @: $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
+ $(Q)$< --defconfig=configs/$(KBUILD_DEFCONFIG) $(Kconfig)
endif
%_defconfig: $(obj)/conf
- $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
+ @: Modified for U-Boot
+ @: $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
+ $(Q)$< --defconfig=configs/$@ $(Kconfig)
# Help text used by make help
help:
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..ae6ce66 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -951,6 +951,14 @@ int conf_write_autoconf(void)
FILE *out, *tristate, *out_h;
int i;
+ /*
+ * Added for U-Boot SPL/TPL
+ */
+ name = getenv("KCONFIG_OBJDIR");
+ if (name && name[0])
+ if (chdir(name))
+ return 1;
+
sym_clear_all_valid();
file_write_dep("include/config/auto.conf.cmd");
diff --git a/scripts/multiple_config.sh b/scripts/multiple_config.sh
new file mode 100644
index 0000000..1fd2ccf
--- /dev/null
+++ b/scripts/multiple_config.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+set -e
+
+if grep -q "CONFIG_SPL=y" $KCONFIG_CONFIG; then
+ spl=y
+else
+ spl=
+fi
+
+if grep -q "CONFIG_TPL=y" $KCONFIG_CONFIG; then
+ tpl=y
+else
+ tpl=
+fi
+
+if [ "$spl" = "y" ]; then
+ mkdir -p spl/include/config spl/include/generated
+ $MAKE -f $srctree/scripts/Makefile.build obj=scripts/kconfig \
+ KCONFIG_OBJDIR=spl/ KCONFIG_CONFIG=spl/$KCONFIG_CONFIG $1
+fi
+
+if [ "$tpl" = "y" ]; then
+ mkdir -p tpl/include/config tpl/include/generated
+ $MAKE -f $srctree/scripts/Makefile.build obj=scripts/kconfig \
+ KCONFIG_OBJDIR=tpl/ KCONFIG_CONFIG=tpl/$KCONFIG_CONFIG $1
+fi
+
+if [ "$1" != "silentoldconfig" ]; then
+ exit 0
+fi
+
+# The following lines create or update
+# - symbolic links (arch/$ARCH/include/asm/{arch,proc}
+# - include/autoconf.mk, {spl,tpl}/include/autoconf.mk
+# - include/config.h
+# We are still relying on U-Boot conventional configuration,
+# which is based on header files (include/configs/<board_name>.h)
+# We can delete the following lines after moving all CONFIG
+# from header files to Kconfig.
+$MAKE -f $srctree/scripts/Makefile.autoconf obj=include \
+ include/autoconf.mk include/autoconf.mk.dep
+
+# include/config.h is updated after "make silentoldconfig".
+# We need to touch include/config/auto.conf so it gets newer than
+# include/config.h. Otherwise, "make silentoldconfig" is run twice.
+touch include/config/auto.conf
+
+if [ "$spl" = "y" ]; then
+ $MAKE -f $srctree/scripts/Makefile.autoconf obj=spl/include \
+ spl/include/autoconf.mk
+fi
+
+if [ "$tpl" = "y" ]; then
+ $MAKE -f $srctree/scripts/Makefile.autoconf obj=tpl/include \
+ tpl/include/autoconf.mk
+fi
diff --git a/scripts/silentoldconfig.sh b/scripts/silentoldconfig.sh
new file mode 100644
index 0000000..3c5d2ff
--- /dev/null
+++ b/scripts/silentoldconfig.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+set -e
+
+if grep -q "CONFIG_SPL=y" $KCONFIG_CONFIG; then
+ spl=y
+else
+ spl=
+fi
+
+if grep -q "CONFIG_TPL=y" $KCONFIG_CONFIG; then
+ tpl=y
+else
+ tpl=
+fi
+
+$MAKE -f $srctree/Makefile silentoldconfig
+
+if [ "$spl" = "y" ]; then
+ mkdir -p spl/include/linux spl/include/config spl/include/generated
+ # "make silentoldconfig" updates ".config".
+ # So we need to copy it to spl/.config
+ cp $KCONFIG_CONFIG spl/$KCONFIG_CONFIG
+ # "make silentoldconfig" creates or updates
+ # - spl/include/config/auto.conf
+ # - spl/include/generated/autoconf.h.
+ # - spl/include/config/*/*.h (used for scripts/basic/fixdep)
+ $MAKE -f $srctree/Makefile KCONFIG_OBJDIR=spl/ \
+ KCONFIG_CONFIG=spl/$KCONFIG_CONFIG silentoldconfig >/dev/null
+ rm spl/$KCONFIG_CONFIG
+fi
+
+if [ "$tpl" = "y" ]; then
+ mkdir -p tpl/include/linux tpl/include/config tpl/include/generated
+ # "make silentoldconfig" updates ".config".
+ # So we need to copy it to tpl/.config
+ cp $KCONFIG_CONFIG tpl/$KCONFIG_CONFIG
+ # "make silentoldconfig" creates or updates
+ # - tpl/include/config/auto.conf
+ # - tpl/include/generated/autoconf.h.
+ # - tpl/include/config/*/*.h (used for scripts/basic/fixdep)
+ $MAKE -f $srctree/Makefile KCONFIG_OBJDIR=tpl/ \
+ KCONFIG_CONFIG=tpl/$KCONFIG_CONFIG silentoldconfig >/dev/null
+ rm tpl/$KCONFIG_CONFIG
+fi
+
+# The following lines create or update
+# - symbolic links (arch/$ARCH/include/asm/{arch,proc}
+# - include/autoconf.mk, {spl,tpl}/include/autoconf.mk
+# - include/config.h
+# We are still relying U-Boot conventional configuration,
+# which is based on header files (include/configs/<board_name>.h)
+# We can delete the following lines after moving all CONFIG
+# from header files to Kconfig.
+$MAKE -f $srctree/scripts/Makefile.autoconf obj=include \
+ include/autoconf.mk include/autoconf.mk.dep
+
+# include/config.h is updated after "make silentoldconfig".
+# We need to touch include/config/auto.conf so it gets newer than
+#include/config.h. Otherwise, "make silentoldconfig" is run twice.
+touch include/config/auto.conf
+
+if [ "$spl" = "y" ]; then
+ $MAKE -f $srctree/scripts/Makefile.autoconf obj=spl/include \
+ spl/include/autoconf.mk
+fi
+
+if [ "$tpl" = "y" ]; then
+ $MAKE -f $srctree/scripts/Makefile.autoconf obj=tpl/include \
+ tpl/include/autoconf.mk
+fi
diff --git a/spl/Makefile b/spl/Makefile
index 55500fd..7baced9 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -21,13 +21,10 @@ _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
include $(srctree)/scripts/Kbuild.include
-CONFIG_SPL_BUILD := y
-export CONFIG_SPL_BUILD
+UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
-KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
-ifeq ($(CONFIG_TPL_BUILD),y)
-KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
-endif
+-include $(obj)/include/config/auto.conf
+-include $(obj)/include/autoconf.mk
ifeq ($(CONFIG_TPL_BUILD),y)
export CONFIG_TPL_BUILD
@@ -36,14 +33,6 @@ else
SPL_BIN := u-boot-spl
endif
-include include/config.mk
-
-ifeq ($(CONFIG_TPL_BUILD),y)
- -include include/tpl-autoconf.mk
-else
- -include include/spl-autoconf.mk
-endif
-
include $(srctree)/config.mk
# Enable garbage collection of un-used sections for SPL
@@ -53,20 +42,6 @@ LDFLAGS_FINAL += --gc-sections
# FIX ME
cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
$(NOSTDINC_FLAGS)
-c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
-
-# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
-quiet_cmd_autoconf = GEN $@
- cmd_autoconf = \
- $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
- sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
- rm $@.tmp
-
-include/tpl-autoconf.mk: include/config.h
- $(call cmd,autoconf)
-
-include/spl-autoconf.mk: include/config.h
- $(call cmd,autoconf)
HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
diff --git a/tools/Makefile b/tools/Makefile
index 6e43a01..b55b378 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -185,7 +185,7 @@ endif # !LOGO_BMP
# Define _GNU_SOURCE to obtain the getline prototype from stdio.h
#
HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
- $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
+ $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
-I$(srctree)/lib/libfdt \
-I$(srctree)/tools \
-DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
diff --git a/tools/env/Makefile b/tools/env/Makefile
index f5368bc..4927489 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -11,7 +11,7 @@
HOSTCC = $(CC)
# Compile for a hosted environment on the target
-HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
+HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
-idirafter $(srctree)/tools/env \
-DUSE_HOSTCC \
-DTEXT_BASE=$(TEXT_BASE)
--
1.9.1
More information about the U-Boot
mailing list