[U-Boot] [PATCH 06/11] kconfig: switch to Kconfig
Masahiro Yamada
yamada.m at jp.panasonic.com
Thu Apr 24 07:04:17 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 3 images at most: Main image, SPL, TPL.
And each of them can have a different set of CONFIG macros.
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] Main
- .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
- 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
- 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.
To modify configuration, run "make config", "make menuconfig", etc.
To see the other configuration targets execute "make help".
In Kconfig for U-boot, the configuration is done on three levels at most.
"make menuconfig" will show a menu with a blue background for the
main configuration.
Enable "Build SPL image", "Build TPL image" under "General setup"
to build SPL, TPL, respectively.
After modifying settings, choose <Exit>.
CONFIG macros will be saved into ".config" file.
If SPL build is enabled, the second menu for SPL configuration
will come up.
And if TPL build is also enabled, the third menu for TPL will
be displayed.
By the way, there is another item worth remarking here:
coexistence of Kconfig and board herder files.
To define the set of CONFIG macros, we have used C headers.
We expect long term to move existing CONFIG macros to Kconfig.
Two different infractructure must coexist in the interim.
Prior to Kconfig, include/autoconf.mk, include/spl-autoconf.mk,
include/tpl-autoconf.mk were generated from the config header
for the use in makefiles.
They are still supported in Kconfig for U-Boot.
They are created at the beginning of the build and merged into
include/config/auto.conf, spl/include/config/auto.conf,
tpl/include/config/auto.conf, respectively.
Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---
.gitignore | 2 -
Makefile | 173 +++++++++++++++++++++++++++-----------
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.build | 30 +++----
scripts/basic/fixdep.c | 6 +-
scripts/kconfig/Makefile | 16 +++-
scripts/kconfig/confdata.c | 8 ++
spl/Makefile | 60 ++++++++-----
tools/Makefile | 2 +-
tools/env/Makefile | 2 +-
16 files changed, 227 insertions(+), 115 deletions(-)
diff --git a/.gitignore b/.gitignore
index cba5eac..8b13894 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 0191869..a622cd3 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; \
@@ -477,28 +474,81 @@ ifeq ($(config-targets),1)
# 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=)
+define splconfig_rule
+ $(Q)mkdir -p spl/include/linux spl/include/config
+ $(Q)$(MAKE) KCONFIG_OBJDIR=spl/ KCONFIG_CONFIG=spl/$(KCONFIG_CONFIG) \
+ MENUCONFIG_COLOR=blackbg $(build)=scripts/kconfig $(@:spl%=%)
+endef
+
+define tplconfig_rule
+ $(Q)mkdir -p tpl/include/linux tpl/include/config
+ $(Q)$(MAKE) KCONFIG_OBJDIR=tpl/ KCONFIG_CONFIG=tpl/$(KCONFIG_CONFIG) \
+ MENUCONFIG_COLOR=mono $(build)=scripts/kconfig $(@:tpl%=%)
+endef
+
+define config_rule
+ $(Q)mkdir -p include/linux include/config
+ $(Q)$(MAKE) KCONFIG_OBJDIR= $(build)=scripts/kconfig $@
+ $(Q)if grep -q "CONFIG_SPL=y" $(KCONFIG_CONFIG); then \
+ $(MAKE) -f $(srctree)/Makefile spl$@; fi
+ $(Q)if grep -q "CONFIG_TPL=y" $(KCONFIG_CONFIG); then \
+ $(MAKE) -f $(srctree)/Makefile tpl$@; fi
+endef
+
+config splconfig tplconfig: scripts_basic outputmakefile FORCE
+ +$(call $@_rule)
+
+spl%config: scripts_basic outputmakefile FORCE
+ +$(call splconfig_rule)
+
+tpl%config: scripts_basic outputmakefile FORCE
+ +$(call tplconfig_rule)
+
+%config: scripts_basic outputmakefile FORCE
+ +$(call config_rule)
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/autoconf.mk
--include include/autoconf.mk.dep
-
-# load other configuration
+-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
+ $(Q)$(MAKE) -f $(srctree)/Makefile include/autoconf.mk include/autoconf.mk.dep
+ $(Q)cat include/autoconf.mk.dep >> $@.cmd
+ $(Q)echo "# This file a concatenation of two files:" > $@.tmp
+ $(Q)echo "# [1] include/autoconf.mk (U-boot conventional config)" >> $@.tmp
+ $(Q)echo "# [2] include/config/auto.conf (generated by silentoldconfig)" >> $@.tmp
+ $(Q)cat include/autoconf.mk $@ >> $@.tmp
+ $(Q)mv $@.tmp $@
+ $(Q)rm -f spl/include/config/auto.conf tpl/include/config/auto.conf
+
+# 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 +583,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
@@ -594,7 +644,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)
@@ -992,7 +1043,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)
@@ -1021,7 +1072,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."
@@ -1063,29 +1115,57 @@ $(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.
+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: $(srctree)/Makefile FORCE
+ $(call filechk,config_h)
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 $@
+ 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: include/config.h include/common.h
+include/autoconf.mk.dep: include/config.h create_symlink
$(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 > $@; \
+ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \
+ while read line; do \
+ if ! grep -q "$${line%=*}=" include/config/auto.conf; then \
+ echo "$$line"; \
+ fi \
+ done > $@; \
rm $@.tmp
-include/autoconf.mk: include/config.h
+include/autoconf.mk: include/config.h create_symlink
$(call cmd,autoconf)
+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 += depend dep
@@ -1123,7 +1203,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
@@ -1199,21 +1279,21 @@ 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
+ include/autoconf.mk* spl/include/autoconf.mk* \
+ tpl/include/autoconf.mk* include/config.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/include \
.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* tpl/.config* \
+ tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
# clean - Delete most, but leave enough to build external modules
#
@@ -1292,10 +1372,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.build b/scripts/Makefile.build
index 6416c1a..23a3a37 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,8 @@ 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 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..0698685 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -33,7 +33,9 @@ oldconfig: $(obj)/conf
$< --$@ $(Kconfig)
silentoldconfig: $(obj)/conf
- $(Q)mkdir -p include/generated
+ @# Modified for U-Boot
+ @# $(Q)mkdir -p include/generated
+ $(Q)mkdir -p $(KCONFIG_OBJDIR)include/generated
$< --$@ $(Kconfig)
localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
@@ -91,18 +93,24 @@ oldnoconfig: $(obj)/conf
$< --olddefconfig $(Kconfig)
savedefconfig: $(obj)/conf
- $< --$@=defconfig $(Kconfig)
+ @# Modified for U-Boot
+ @# $< --$@=defconfig $(Kconfig)
+ $< --$@=$(KCONFIG_OBJDIR)defconfig $(Kconfig)
defconfig: $(obj)/conf
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/$(KCONFIG_OBJDIR)$(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_OBJDIR)$@ $(Kconfig)
# Help text used by make help
help:
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 87f7238..457332e 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/spl/Makefile b/spl/Makefile
index 6fec252..271b8d4 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -21,13 +21,26 @@ _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
+
+# Read in dependencies to all Kconfig* files, make sure to run
+# oldconfig if changes are detected.
+-include $(obj)/include/config/auto.conf.cmd
+
+# To avoid any implicit rule to kick in, define an empty command
+$(obj)/$(KCONFIG_CONFIG) $(obj)/include/config/auto.conf.cmd: ;
+
+$(obj)/include/config/%.conf: $(obj)/$(KCONFIG_CONFIG) $(obj)/include/config/auto.conf.cmd
+ $(Q)$(MAKE) -f $(srctree)/Makefile $(obj)silentoldconfig
+ $(Q)$(MAKE) -f $(srctree)/spl/Makefile $(obj)/include/autoconf.mk $(obj)/include/autoconf.mk.dep
+ $(Q)cat include/autoconf.mk.dep >> $@.cmd
+ $(Q)echo "# This file a concatenation of two files:" > $@.tmp
+ $(Q)echo "# [1] $(obj)/include/autoconf.mk (U-boot conventional config)" >> $@.tmp
+ $(Q)echo "# [2] $(obj)/include/config/auto.conf (generated by silentoldconfig)" >> $@.tmp
+ $(Q)cat $(obj)/include/autoconf.mk $@ >> $@.tmp
+ $(Q)mv $@.tmp $@
ifeq ($(CONFIG_TPL_BUILD),y)
export CONFIG_TPL_BUILD
@@ -36,15 +49,11 @@ 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
-
+autoconf_is_update := $(if $(wildcard $(obj)/$(KCONFIG_CONFIG)),$(shell find \
+ $(obj)/include/config -name auto.conf -newer $(obj)/$(KCONFIG_CONFIG)))
+ifneq ($(autoconf_is_update),)
include $(srctree)/config.mk
+endif
# Enable garbage collection of un-used sections for SPL
KBUILD_CFLAGS += -ffunction-sections -fdata-sections
@@ -55,17 +64,24 @@ 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_dep = GEN $@
+ cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \
+ -MQ $(obj)/include/config/auto.conf $(srctree)/include/common.h > $@ || rm $@
+
+$(obj)/include/autoconf.mk.dep: include/config.h FORCE
+ $(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/tpl-autoconf.mk: include/config.h
- $(call cmd,autoconf)
-
-include/spl-autoconf.mk: include/config.h
+ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \
+ while read line; do \
+ if ! grep -q "$${line%=*}=" $(obj)/include/config/auto.conf; then \
+ echo $$line; \
+ fi \
+ done > $@; \
+
+$(obj)/include/autoconf.mk: include/config.h FORCE
$(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 c34df4f..a1a8ca2 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -183,7 +183,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.8.3.2
More information about the U-Boot
mailing list