
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 each configuration input.
Our approach is like this:
Every board has a signle defconfig file under "configs" directory. SPL/TPL image, if it is supported, shares the same defconfig file with the full U-boot image.
First, you need to configure for the target baord like this.
make ARCH=<arch> <board_name>_defconfig
(Please not ARCH= must be provided from the command line)
A file ".config" will be created, storing configs setting for all the images of the target board. You can use "make config", "make menuconfig" etc. to create a new .config or modify the existing one.
And then run "make ARCH=<arch>".
Kbuild will automatically invoke "make silentoldconfig" if auto.conf is missing or need to be updated. The full, SPL, TPL image has its own auto.conf: - include/config/auto.conf (for full image) - spl/include/config/auto.conf (for SPL) - tpl/include/config/auto.conf (for TPL)
How to generate three different auto.conf file from the same .config ?
The key is CONFIG_SPL_BUILD and CONFIG_TPL_BUILD. CONFIG_SPL_BUILD is defined for both SPL and TPL, while CONFIG_TPL is only for TPL image.
Some config macros only make sense for the full U-Boot.
For instance,
If you describe Kconfig entry like this:
config SYS_HUSH_PARSER bool "Hush Parser" depends on !SPL_BUILD
CONFIG_SYS_HUSH_PARSER will be conceiled from SPL/TPL auto.conf.
If you want to set a config macro for each image separately, you need to define another CONFIG. Maybe CONFIG_SPL_ or CPNFIG_TPL_ prefix would be better for clarification. For example, CONFIG_SYS_TEXT_BASE, CONFIG_SPL_TEXT_BASE, CONFIG_TPL_TEXT_BASE, respectively.
I have to admit duplicating config macros is painful but we get a single defconfig file in return.
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 define a set of configs.
We expect a very long term to move existing config macros to Kconfig. Two different infractructure must coexist in the interim.
In our former configuration scheme, include/autoconf.mk was generated for the use in makefiles. It is still generated in include/, spl/include/, tpl/include/ directory for the full, SPL, TPL image, respectively.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
.gitignore | 2 - Makefile | 154 ++++++++++++++++++++------------------ arch/blackfin/config.mk | 2 + 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 | 23 +++++- include/.gitignore | 1 - scripts/Makefile | 2 +- scripts/Makefile.autoconf | 100 +++++++++++++++++++++++++ scripts/Makefile.build | 31 +++----- scripts/basic/fixdep.c | 6 +- scripts/kconfig/Makefile | 4 + scripts/kconfig/confdata.c | 8 ++ scripts/silentoldconfig.sh | 71 ++++++++++++++++++ spl/Makefile | 31 +------- tools/Makefile | 2 +- tools/env/Makefile | 2 +- 19 files changed, 324 insertions(+), 145 deletions(-) create mode 100644 scripts/Makefile.autoconf 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 76b090d..5666907 100644 --- a/Makefile +++ b/Makefile @@ -166,13 +166,29 @@ 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
-######################################################################### +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) + +ARCH ?= $(SUBARCH) +SRCARCH := $(ARCH) + +# Additional ARCH settings for ARM +ifeq ($(ARCH),arm64) + SRCARCH := arm +endif
HOSTARCH := $(shell uname -m | \ sed -e s/i.86/x86/ \ @@ -189,9 +205,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 +212,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; \ @@ -361,6 +377,15 @@ CHECK = sparse CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
+ +# Use UBOOTINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O= option +UBOOTINCLUDE := \ + -Iinclude \ + $(if $(KBUILD_SRC), -I$(srctree)/include) \ + -I$(srctree)/arch/$(ARCH)/include \ + -include $(srctree)/include/linux/kconfig.h + KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ @@ -373,7 +398,7 @@ UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null) UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION -export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR +export ARCH SRCARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC export CPP AR NM LDR STRIP OBJCOPY OBJDUMP export MAKE AWK PERL @@ -477,30 +502,45 @@ 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' +include $(srctree)/arch/$(SRCARCH)/config.mk +export KBUILD_DEFCONFIG KBUILD_KCONFIG + +config: scripts_basic outputmakefile FORCE + $(Q)mkdir -p include/linux include/config + $(Q)$(MAKE) $(build)=scripts/kconfig $@
-%_config:: outputmakefile - @$(MKCONFIG) -A $(@:_config=) +%config: scripts_basic outputmakefile FORCE + $(Q)mkdir -p include/linux include/config + $(Q)$(MAKE) $(build)=scripts/kconfig $@
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)$(CONFIG_SHELL) $(srctree)/scripts/silentoldconfig.sh + -include include/autoconf.mk -include include/autoconf.mk.dep
-# load other configuration 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 # that (or fail if absent). Otherwise, search for a linker script in a # standard location. @@ -533,8 +573,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 @@ -578,6 +618,10 @@ KBUILD_AFLAGS += -Wa,-gstabs,-S endif endif
+# arch Makefile may override CC so keep this after arch Makefile is included +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +CHECKFLAGS += $(NOSTDINC_FLAGS) + # Prohibit date/time macros, which would make the build non-deterministic KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
@@ -592,16 +636,6 @@ KBUILD_CPPFLAGS += $(KCPPFLAGS) KBUILD_AFLAGS += $(KAFLAGS) KBUILD_CFLAGS += $(KCFLAGS)
-# Use UBOOTINCLUDE when you must reference the include/ directory. -# Needed to be compatible with the O= option -UBOOTINCLUDE := \ - -Iinclude \ - $(if $(KBUILD_SRC), -I$(srctree)/include) \ - -I$(srctree)/arch/$(ARCH)/include - -NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) -CHECKFLAGS += $(NOSTDINC_FLAGS) - # FIX ME cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ $(NOSTDINC_FLAGS) @@ -1033,7 +1067,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 +1085,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 +1096,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 +1139,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 +1176,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,29 +1251,28 @@ 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 # clean: rm-dirs := $(CLEAN_DIRS) clean: rm-files := $(CLEAN_FILES)
-clean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f)) +clean-dirs := $(foreach f, $(filter %/, $(u-boot-alldirs)),\ + $(if $(wildcard $(srctree)/$f/Makefile),$f))
clean-dirs := $(addprefix _clean_, $(clean-dirs) doc/DocBook)
@@ -1333,10 +1344,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/blackfin/config.mk b/arch/blackfin/config.mk index fcaa44f..c9927b8 100644 --- a/arch/blackfin/config.mk +++ b/arch/blackfin/config.mk @@ -12,9 +12,11 @@ endif CONFIG_STANDALONE_LOAD_ADDR ?= 0x1000 -m elf32bfin
ifeq ($(CONFIG_BFIN_CPU),) +ifneq ($(BOARD),) CONFIG_BFIN_CPU := \ $(shell awk '$$2 == "CONFIG_BFIN_CPU" { print $$3 }' \ $(srctree)/include/configs/$(BOARD).h) +endif else CONFIG_BFIN_CPU := $(strip $(CONFIG_BFIN_CPU:"%"=%)) endif 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..12eef99 100644 --- a/config.mk +++ b/config.mk @@ -20,16 +20,33 @@ LDFLAGS_FINAL := OBJCOPYFLAGS := #########################################################################
+# We want to define CPU, BOARD, VENDOR, SOC 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 macro would be set 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),) +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 +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 # CPU-specific code. -CPUDIR=arch/$(ARCH)/cpu/$(CPU) +CPUDIR=arch/$(SRCARCH)/cpu/$(CPU) ifneq ($(srctree)/$(CPUDIR),$(wildcard $(srctree)/$(CPUDIR))) -CPUDIR=arch/$(ARCH)/cpu +CPUDIR=arch/$(SRCARCH)/cpu endif
-sinclude $(srctree)/arch/$(ARCH)/config.mk # include architecture dependend rules +sinclude $(srctree)/arch/$(SRCARCH)/config.mk # include architecture dependend rules sinclude $(srctree)/$(CPUDIR)/config.mk # include CPU specific rules
ifdef SOC 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..3072231 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -14,6 +14,10 @@ endif # We need this, in case the user has it in its environment unexport CONFIG_
+# Added for U-Boot +KCONFIG_OBJDIR := +export KCONFIG_OBJDIR + xconfig: $(obj)/qconf $< $(Kconfig)
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/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)