Skip to content

Commit 5114879

Browse files
masahir0ytrini
authored andcommitted
kconfig: switch to Kconfig
This commit enables Kconfig. Going forward, we use Kconfig for the 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 boot images (Normal, SPL, TPL) from one source tree. Each image needs its own configuration input. Usage: Run "make <board>_defconfig" to do the board configuration. It will create the .config file and additionally spl/.config, tpl/.config if SPL, TPL is enabled, respectively. You can use "make config", "make menuconfig" etc. to create a new .config or modify the existing one. Use "make spl/config", "make spl/menuconfig" etc. for spl/.config and do likewise for tpl/.config file. The generic syntax of configuration targets for SPL, TPL is: <target_image>/<config_command> Here, <target_image> is either 'spl' or 'tpl' <config_command> is 'config', 'menuconfig', 'xconfig', etc. When the configuration is done, run "make". (Or "make <board>_defconfig all" will do the configuration and build in one time.) For futher information of how Kconfig works in U-Boot, please read the comment block of scripts/multiconfig.py. 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 Normal, SPL, TPL image, respectively. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Simon Glass <sjg@chromium.org>
1 parent 4ce9957 commit 5114879

17 files changed

Lines changed: 619 additions & 132 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
#
5454
/include/config/
5555
/include/generated/
56-
/include/spl-autoconf.mk
57-
/include/tpl-autoconf.mk
5856

5957
# stgit generated dirs
6058
patches-*

Makefile

Lines changed: 54 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
166166

167167
export srctree objtree VPATH
168168

169-
MKCONFIG := $(srctree)/mkconfig
170-
export MKCONFIG
171-
172169
# Make sure CDPATH settings don't interfere
173170
unexport CDPATH
174171

@@ -189,16 +186,16 @@ HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
189186

190187
export HOSTARCH HOSTOS
191188

192-
# Deal with colliding definitions from tcsh etc.
193-
VENDOR=
194-
195189
#########################################################################
196190

197191
# set default to nothing for native builds
198192
ifeq ($(HOSTARCH),$(ARCH))
199193
CROSS_COMPILE ?=
200194
endif
201195

196+
KCONFIG_CONFIG ?= .config
197+
export KCONFIG_CONFIG
198+
202199
# SHELL used by kbuild
203200
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
204201
else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -341,6 +338,7 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
341338
OBJDUMP = $(CROSS_COMPILE)objdump
342339
AWK = awk
343340
PERL = perl
341+
PYTHON = python
344342
DTC = dtc
345343
CHECK = sparse
346344

@@ -362,7 +360,7 @@ export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION
362360
export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR
363361
export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
364362
export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
365-
export MAKE AWK PERL
363+
export MAKE AWK PERL PYTHON
366364
export HOSTCXX HOSTCXXFLAGS DTC CHECK CHECKFLAGS
367365

368366
export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS
@@ -460,31 +458,49 @@ ifeq ($(config-targets),1)
460458
# *config targets only - make sure prerequisites are updated, and descend
461459
# in scripts/kconfig to make the *config target
462460

463-
# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
464-
# KBUILD_DEFCONFIG may point out an alternative default configuration
465-
# used for 'make defconfig'
461+
KBUILD_DEFCONFIG := sandbox_defconfig
462+
export KBUILD_DEFCONFIG KBUILD_KCONFIG
466463

467-
%_config:: outputmakefile
468-
@$(MKCONFIG) -A $(@:_config=)
464+
config: scripts_basic outputmakefile FORCE
465+
+$(Q)$(PYTHON) $(srctree)/scripts/multiconfig.py $@
466+
467+
%config: scripts_basic outputmakefile FORCE
468+
+$(Q)$(PYTHON) $(srctree)/scripts/multiconfig.py $@
469469

470470
else
471471
# ===========================================================================
472472
# Build targets only - this includes vmlinux, arch specific targets, clean
473473
# targets and others. In general all targets except *config targets.
474474

475-
# load ARCH, BOARD, and CPU configuration
476-
-include include/config.mk
477-
478475
ifeq ($(dot-config),1)
479476
# Read in config
477+
-include include/config/auto.conf
478+
479+
# Read in dependencies to all Kconfig* files, make sure to run
480+
# oldconfig if changes are detected.
481+
-include include/config/auto.conf.cmd
482+
483+
# To avoid any implicit rule to kick in, define an empty command
484+
$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
485+
486+
# If .config is newer than include/config/auto.conf, someone tinkered
487+
# with it and forgot to run make oldconfig.
488+
# if auto.conf.cmd is missing then we are probably in a cleaned tree so
489+
# we execute the config step to be sure to catch updated Kconfig files
490+
include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
491+
$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
492+
480493
-include include/autoconf.mk
481494
-include include/autoconf.mk.dep
482495

483-
# load other configuration
496+
# We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf
497+
# is up-to-date. When we switch to a different board configuration, old CONFIG
498+
# macros are still remaining in include/config/auto.conf. Without the following
499+
# gimmick, wrong config.mk would be included leading nasty warnings/errors.
500+
autoconf_is_current := $(if $(wildcard $(KCONFIG_CONFIG)),$(shell find . \
501+
-path ./include/config/auto.conf -newer $(KCONFIG_CONFIG)))
502+
ifneq ($(autoconf_is_current),)
484503
include $(srctree)/config.mk
485-
486-
ifeq ($(wildcard include/config.mk),)
487-
$(error "System not configured - see README")
488504
endif
489505

490506
# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
@@ -513,8 +529,8 @@ ifndef LDSCRIPT
513529
endif
514530

515531
else
516-
517-
532+
# Dummy target needed, because used as prerequisite
533+
include/config/auto.conf: ;
518534
endif # $(dot-config)
519535

520536
KBUILD_CFLAGS += -Os #-fomit-frame-pointer
@@ -563,7 +579,8 @@ KBUILD_CFLAGS += $(KCFLAGS)
563579
UBOOTINCLUDE := \
564580
-Iinclude \
565581
$(if $(KBUILD_SRC), -I$(srctree)/include) \
566-
-I$(srctree)/arch/$(ARCH)/include
582+
-I$(srctree)/arch/$(ARCH)/include \
583+
-include $(srctree)/include/linux/kconfig.h
567584

568585
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
569586
CHECKFLAGS += $(NOSTDINC_FLAGS)
@@ -1024,7 +1041,7 @@ define filechk_uboot.release
10241041
endef
10251042

10261043
# Store (new) UBOOTRELEASE string in include/config/uboot.release
1027-
include/config/uboot.release: Makefile FORCE
1044+
include/config/uboot.release: include/config/auto.conf FORCE
10281045
$(call filechk,uboot.release)
10291046

10301047

@@ -1042,8 +1059,8 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
10421059
# 1) Check that make has not been executed in the kernel src $(srctree)
10431060
prepare3: include/config/uboot.release
10441061
ifneq ($(KBUILD_SRC),)
1045-
@$(kecho) ' Using $(srctree) as source for u-boot'
1046-
$(Q)if [ -f $(srctree)/include/config.mk ]; then \
1062+
@$(kecho) ' Using $(srctree) as source for U-Boot'
1063+
$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
10471064
echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
10481065
echo >&2 " in the '$(srctree)' directory.";\
10491066
/bin/false; \
@@ -1053,7 +1070,8 @@ endif
10531070
# prepare2 creates a makefile if using a separate output directory
10541071
prepare2: prepare3 outputmakefile
10551072

1056-
prepare1: prepare2 $(version_h) $(timestamp_h)
1073+
prepare1: prepare2 $(version_h) $(timestamp_h) \
1074+
include/config/auto.conf
10571075
ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
10581076
ifeq ($(CONFIG_SYS_GENERIC_BOARD),y)
10591077
@echo >&2 " Your architecture does not support generic board."
@@ -1095,29 +1113,6 @@ $(version_h): include/config/uboot.release FORCE
10951113
$(timestamp_h): $(srctree)/Makefile FORCE
10961114
$(call filechk,timestamp.h)
10971115

1098-
#
1099-
# Auto-generate the autoconf.mk file (which is included by all makefiles)
1100-
#
1101-
# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
1102-
# the dep file is only include in this top level makefile to determine when
1103-
# to regenerate the autoconf.mk file.
1104-
1105-
quiet_cmd_autoconf_dep = GEN $@
1106-
cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
1107-
-MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
1108-
1109-
include/autoconf.mk.dep: include/config.h include/common.h
1110-
$(call cmd,autoconf_dep)
1111-
1112-
quiet_cmd_autoconf = GEN $@
1113-
cmd_autoconf = \
1114-
$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
1115-
sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
1116-
rm $@.tmp
1117-
1118-
include/autoconf.mk: include/config.h
1119-
$(call cmd,autoconf)
1120-
11211116
# ---------------------------------------------------------------------------
11221117

11231118
PHONY += depend dep
@@ -1141,7 +1136,7 @@ spl/sunxi-spl.bin: spl/u-boot-spl
11411136
@:
11421137

11431138
tpl/u-boot-tpl.bin: tools prepare
1144-
$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all CONFIG_TPL_BUILD=y
1139+
$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
11451140

11461141
TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
11471142

@@ -1216,20 +1211,18 @@ include/license.h: tools/bin2header COPYING
12161211

12171212
# Directories & files removed with 'make clean'
12181213
CLEAN_DIRS += $(MODVERDIR)
1219-
CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h \
1220-
include/autoconf.mk* include/spl-autoconf.mk \
1221-
include/tpl-autoconf.mk
1214+
CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h
12221215

12231216
# Directories & files removed with 'make clobber'
1224-
CLOBBER_DIRS += spl tpl
1217+
CLOBBER_DIRS += $(foreach d, spl tpl, $(patsubst %,$d/%, \
1218+
$(filter-out include, $(shell ls -1 $d 2>/dev/null))))
12251219
CLOBBER_FILES += u-boot* MLO* SPL System.map
12261220

12271221
# Directories & files removed with 'make mrproper'
1228-
MRPROPER_DIRS += include/config include/generated \
1222+
MRPROPER_DIRS += include/config include/generated spl tpl \
12291223
.tmp_objdiff
1230-
MRPROPER_FILES += .config .config.old \
1231-
ctags etags cscope* GPATH GTAGS GRTAGS GSYMS \
1232-
include/config.h include/config.mk
1224+
MRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h \
1225+
ctags etags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
12331226

12341227
# clean - Delete most, but leave enough to build external modules
12351228
#
@@ -1306,10 +1299,9 @@ help:
13061299
@echo ' mrproper - Remove all generated files + config + various backup files'
13071300
@echo ' distclean - mrproper + remove editor backup and patch files'
13081301
@echo ''
1309-
# uncomment after adding Kconfig feature
1310-
# @echo 'Configuration targets:'
1311-
# @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1312-
# @echo ''
1302+
@echo 'Configuration targets:'
1303+
@$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1304+
@echo ''
13131305
@echo 'Other generic targets:'
13141306
@echo ' all - Build all necessary images depending on configuration'
13151307
@echo ' u-boot - Build the bare u-boot'

arch/m68k/cpu/mcf52x2/config.mk

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
# SPDX-License-Identifier: GPL-2.0+
88
#
99

10-
cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
11-
is5208:=$(shell grep CONFIG_M5208 $(srctree)/include/$(cfg))
12-
is5249:=$(shell grep CONFIG_M5249 $(srctree)/include/$(cfg))
13-
is5253:=$(shell grep CONFIG_M5253 $(srctree)/include/$(cfg))
14-
is5271:=$(shell grep CONFIG_M5271 $(srctree)/include/$(cfg))
15-
is5272:=$(shell grep CONFIG_M5272 $(srctree)/include/$(cfg))
16-
is5275:=$(shell grep CONFIG_M5275 $(srctree)/include/$(cfg))
17-
is5282:=$(shell grep CONFIG_M5282 $(srctree)/include/$(cfg))
10+
cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
11+
is5208:=$(shell grep CONFIG_M5208 $(cfg))
12+
is5249:=$(shell grep CONFIG_M5249 $(cfg))
13+
is5253:=$(shell grep CONFIG_M5253 $(cfg))
14+
is5271:=$(shell grep CONFIG_M5271 $(cfg))
15+
is5272:=$(shell grep CONFIG_M5272 $(cfg))
16+
is5275:=$(shell grep CONFIG_M5275 $(cfg))
17+
is5282:=$(shell grep CONFIG_M5282 $(cfg))
1818

1919
ifneq (,$(findstring CONFIG_M5208,$(is5208)))
2020
PLATFORM_CPPFLAGS += -mcpu=5208

arch/m68k/cpu/mcf532x/config.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# SPDX-License-Identifier: GPL-2.0+
88
#
99

10-
cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
11-
is5301x:=$(shell grep CONFIG_MCF5301x $(srctree)/include/$(cfg))
12-
is532x:=$(shell grep CONFIG_MCF532x $(srctree)/include/$(cfg))
10+
cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
11+
is5301x:=$(shell grep CONFIG_MCF5301x $(cfg))
12+
is532x:=$(shell grep CONFIG_MCF532x $(cfg))
1313

1414
ifneq (,$(findstring CONFIG_MCF5301x,$(is5301x)))
1515
PLATFORM_CPPFLAGS += -mcpu=53015 -fPIC

arch/m68k/cpu/mcf5445x/config.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# SPDX-License-Identifier: GPL-2.0+
1010
#
1111

12-
cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
13-
is5441x:=$(shell grep CONFIG_MCF5441x $(srctree)/include/$(cfg))
12+
cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
13+
is5441x:=$(shell grep CONFIG_MCF5441x $(cfg))
1414

1515
ifneq (,$(findstring CONFIG_MCF5441x,$(is5441x)))
1616
PLATFORM_CPPFLAGS += -mcpu=54418 -fPIC

arch/powerpc/cpu/ppc4xx/config.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
PLATFORM_CPPFLAGS += -DCONFIG_4xx -mstring -msoft-float
99

10-
cfg=$(shell grep configs $(objtree)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
11-
is440:=$(shell grep CONFIG_440 $(srctree)/include/$(cfg))
10+
cfg=$(srctree)/include/configs/$(CONFIG_SYS_CONFIG_NAME:"%"=%).h
11+
is440:=$(shell grep CONFIG_440 $(cfg))
1212

1313
ifneq (,$(findstring CONFIG_440,$(is440)))
1414
PLATFORM_CPPFLAGS += -Wa,-m440 -mcpu=440

config.mk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ LDFLAGS_FINAL :=
2020
OBJCOPYFLAGS :=
2121
#########################################################################
2222

23+
ARCH := $(CONFIG_SYS_ARCH:"%"=%)
24+
CPU := $(CONFIG_SYS_CPU:"%"=%)
25+
BOARD := $(CONFIG_SYS_BOARD:"%"=%)
26+
ifneq ($(CONFIG_SYS_VENDOR),)
27+
VENDOR := $(CONFIG_SYS_VENDOR:"%"=%)
28+
endif
29+
ifneq ($(CONFIG_SYS_SOC),)
30+
SOC := $(CONFIG_SYS_SOC:"%"=%)
31+
endif
32+
2333
# Some architecture config.mk files need to know what CPUDIR is set to,
2434
# so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
2535
# Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains

include/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
/bmp_logo.h
33
/bmp_logo_data.h
44
/config.h
5-
/config.mk

scripts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ build_docproc: $(obj)/docproc
1313
@:
1414

1515
# Let clean descend into subdirs
16-
subdir- += basic
16+
subdir- += basic kconfig

0 commit comments

Comments
 (0)