Commit 51148790f26e42ef1fd4a1a8d056bf0252539525
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>
Showing 17 changed files with 619 additions and 132 deletions Side-by-side Diff
- .gitignore
- Makefile
- arch/m68k/cpu/mcf52x2/config.mk
- arch/m68k/cpu/mcf532x/config.mk
- arch/m68k/cpu/mcf5445x/config.mk
- arch/powerpc/cpu/ppc4xx/config.mk
- config.mk
- include/.gitignore
- scripts/Makefile
- scripts/Makefile.autoconf
- scripts/Makefile.build
- scripts/Makefile.spl
- scripts/basic/fixdep.c
- scripts/kconfig/confdata.c
- scripts/multiconfig.py
- tools/Makefile
- tools/env/Makefile
... | ... | @@ -166,9 +166,6 @@ |
166 | 166 | |
167 | 167 | export srctree objtree VPATH |
168 | 168 | |
169 | -MKCONFIG := $(srctree)/mkconfig | |
170 | -export MKCONFIG | |
171 | - | |
172 | 169 | # Make sure CDPATH settings don't interfere |
173 | 170 | unexport CDPATH |
174 | 171 | |
... | ... | @@ -189,9 +186,6 @@ |
189 | 186 | |
190 | 187 | export HOSTARCH HOSTOS |
191 | 188 | |
192 | -# Deal with colliding definitions from tcsh etc. | |
193 | -VENDOR= | |
194 | - | |
195 | 189 | ######################################################################### |
196 | 190 | |
197 | 191 | # set default to nothing for native builds |
... | ... | @@ -199,6 +193,9 @@ |
199 | 193 | CROSS_COMPILE ?= |
200 | 194 | endif |
201 | 195 | |
196 | +KCONFIG_CONFIG ?= .config | |
197 | +export KCONFIG_CONFIG | |
198 | + | |
202 | 199 | # SHELL used by kbuild |
203 | 200 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ |
204 | 201 | else if [ -x /bin/bash ]; then echo /bin/bash; \ |
... | ... | @@ -341,6 +338,7 @@ |
341 | 338 | OBJDUMP = $(CROSS_COMPILE)objdump |
342 | 339 | AWK = awk |
343 | 340 | PERL = perl |
341 | +PYTHON = python | |
344 | 342 | DTC = dtc |
345 | 343 | CHECK = sparse |
346 | 344 | |
... | ... | @@ -362,7 +360,7 @@ |
362 | 360 | export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR |
363 | 361 | export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC |
364 | 362 | export CPP AR NM LDR STRIP OBJCOPY OBJDUMP |
365 | -export MAKE AWK PERL | |
363 | +export MAKE AWK PERL PYTHON | |
366 | 364 | export HOSTCXX HOSTCXXFLAGS DTC CHECK CHECKFLAGS |
367 | 365 | |
368 | 366 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS |
369 | 367 | |
370 | 368 | |
371 | 369 | |
372 | 370 | |
373 | 371 | |
374 | 372 | |
... | ... | @@ -460,31 +458,49 @@ |
460 | 458 | # *config targets only - make sure prerequisites are updated, and descend |
461 | 459 | # in scripts/kconfig to make the *config target |
462 | 460 | |
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 | |
466 | 463 | |
467 | -%_config:: outputmakefile | |
468 | - @$(MKCONFIG) -A $(@:_config=) | |
464 | +config: scripts_basic outputmakefile FORCE | |
465 | + +$(Q)$(PYTHON) $(srctree)/scripts/multiconfig.py $@ | |
469 | 466 | |
467 | +%config: scripts_basic outputmakefile FORCE | |
468 | + +$(Q)$(PYTHON) $(srctree)/scripts/multiconfig.py $@ | |
469 | + | |
470 | 470 | else |
471 | 471 | # =========================================================================== |
472 | 472 | # Build targets only - this includes vmlinux, arch specific targets, clean |
473 | 473 | # targets and others. In general all targets except *config targets. |
474 | 474 | |
475 | -# load ARCH, BOARD, and CPU configuration | |
476 | --include include/config.mk | |
477 | - | |
478 | 475 | ifeq ($(dot-config),1) |
479 | 476 | # 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 | + | |
480 | 493 | -include include/autoconf.mk |
481 | 494 | -include include/autoconf.mk.dep |
482 | 495 | |
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),) | |
484 | 503 | include $(srctree)/config.mk |
485 | - | |
486 | -ifeq ($(wildcard include/config.mk),) | |
487 | -$(error "System not configured - see README") | |
488 | 504 | endif |
489 | 505 | |
490 | 506 | # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use |
... | ... | @@ -513,8 +529,8 @@ |
513 | 529 | endif |
514 | 530 | |
515 | 531 | else |
516 | - | |
517 | - | |
532 | +# Dummy target needed, because used as prerequisite | |
533 | +include/config/auto.conf: ; | |
518 | 534 | endif # $(dot-config) |
519 | 535 | |
520 | 536 | KBUILD_CFLAGS += -Os #-fomit-frame-pointer |
... | ... | @@ -563,7 +579,8 @@ |
563 | 579 | UBOOTINCLUDE := \ |
564 | 580 | -Iinclude \ |
565 | 581 | $(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 | |
567 | 584 | |
568 | 585 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
569 | 586 | CHECKFLAGS += $(NOSTDINC_FLAGS) |
... | ... | @@ -1024,7 +1041,7 @@ |
1024 | 1041 | endef |
1025 | 1042 | |
1026 | 1043 | # 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 | |
1028 | 1045 | $(call filechk,uboot.release) |
1029 | 1046 | |
1030 | 1047 | |
... | ... | @@ -1042,8 +1059,8 @@ |
1042 | 1059 | # 1) Check that make has not been executed in the kernel src $(srctree) |
1043 | 1060 | prepare3: include/config/uboot.release |
1044 | 1061 | 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 \ | |
1047 | 1064 | echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ |
1048 | 1065 | echo >&2 " in the '$(srctree)' directory.";\ |
1049 | 1066 | /bin/false; \ |
... | ... | @@ -1053,7 +1070,8 @@ |
1053 | 1070 | # prepare2 creates a makefile if using a separate output directory |
1054 | 1071 | prepare2: prepare3 outputmakefile |
1055 | 1072 | |
1056 | -prepare1: prepare2 $(version_h) $(timestamp_h) | |
1073 | +prepare1: prepare2 $(version_h) $(timestamp_h) \ | |
1074 | + include/config/auto.conf | |
1057 | 1075 | ifeq ($(__HAVE_ARCH_GENERIC_BOARD),) |
1058 | 1076 | ifeq ($(CONFIG_SYS_GENERIC_BOARD),y) |
1059 | 1077 | @echo >&2 " Your architecture does not support generic board." |
... | ... | @@ -1095,29 +1113,6 @@ |
1095 | 1113 | $(timestamp_h): $(srctree)/Makefile FORCE |
1096 | 1114 | $(call filechk,timestamp.h) |
1097 | 1115 | |
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 | - | |
1121 | 1116 | # --------------------------------------------------------------------------- |
1122 | 1117 | |
1123 | 1118 | PHONY += depend dep |
... | ... | @@ -1141,7 +1136,7 @@ |
1141 | 1136 | @: |
1142 | 1137 | |
1143 | 1138 | 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 | |
1145 | 1140 | |
1146 | 1141 | TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include) |
1147 | 1142 | |
1148 | 1143 | |
1149 | 1144 | |
1150 | 1145 | |
... | ... | @@ -1216,20 +1211,18 @@ |
1216 | 1211 | |
1217 | 1212 | # Directories & files removed with 'make clean' |
1218 | 1213 | 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 | |
1222 | 1215 | |
1223 | 1216 | # 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)))) | |
1225 | 1219 | CLOBBER_FILES += u-boot* MLO* SPL System.map |
1226 | 1220 | |
1227 | 1221 | # Directories & files removed with 'make mrproper' |
1228 | -MRPROPER_DIRS += include/config include/generated \ | |
1222 | +MRPROPER_DIRS += include/config include/generated spl tpl \ | |
1229 | 1223 | .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 | |
1233 | 1226 | |
1234 | 1227 | # clean - Delete most, but leave enough to build external modules |
1235 | 1228 | # |
... | ... | @@ -1306,10 +1299,9 @@ |
1306 | 1299 | @echo ' mrproper - Remove all generated files + config + various backup files' |
1307 | 1300 | @echo ' distclean - mrproper + remove editor backup and patch files' |
1308 | 1301 | @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 '' | |
1313 | 1305 | @echo 'Other generic targets:' |
1314 | 1306 | @echo ' all - Build all necessary images depending on configuration' |
1315 | 1307 | @echo ' u-boot - Build the bare u-boot' |
... | ... | @@ -7,14 +7,14 @@ |
7 | 7 | # SPDX-License-Identifier: GPL-2.0+ |
8 | 8 | # |
9 | 9 | |
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)) | |
18 | 18 | |
19 | 19 | ifneq (,$(findstring CONFIG_M5208,$(is5208))) |
20 | 20 | PLATFORM_CPPFLAGS += -mcpu=5208 |
... | ... | @@ -7,9 +7,9 @@ |
7 | 7 | # SPDX-License-Identifier: GPL-2.0+ |
8 | 8 | # |
9 | 9 | |
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)) | |
13 | 13 | |
14 | 14 | ifneq (,$(findstring CONFIG_MCF5301x,$(is5301x))) |
15 | 15 | PLATFORM_CPPFLAGS += -mcpu=53015 -fPIC |
... | ... | @@ -9,8 +9,8 @@ |
9 | 9 | # SPDX-License-Identifier: GPL-2.0+ |
10 | 10 | # |
11 | 11 | |
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)) | |
14 | 14 | |
15 | 15 | ifneq (,$(findstring CONFIG_MCF5441x,$(is5441x))) |
16 | 16 | PLATFORM_CPPFLAGS += -mcpu=54418 -fPIC |
... | ... | @@ -7,8 +7,8 @@ |
7 | 7 | |
8 | 8 | PLATFORM_CPPFLAGS += -DCONFIG_4xx -mstring -msoft-float |
9 | 9 | |
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)) | |
12 | 12 | |
13 | 13 | ifneq (,$(findstring CONFIG_440,$(is440))) |
14 | 14 | PLATFORM_CPPFLAGS += -Wa,-m440 -mcpu=440 |
... | ... | @@ -20,6 +20,16 @@ |
20 | 20 | OBJCOPYFLAGS := |
21 | 21 | ######################################################################### |
22 | 22 | |
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 | + | |
23 | 33 | # Some architecture config.mk files need to know what CPUDIR is set to, |
24 | 34 | # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files. |
25 | 35 | # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains |
1 | +# This helper makefile is used for creating | |
2 | +# - symbolic links (arch/$ARCH/include/asm/arch | |
3 | +# - include/autoconf.mk, {spl,tpl}/include/autoconf.mk | |
4 | +# - include/config.h | |
5 | +# | |
6 | +# When our migration to Kconfig is done | |
7 | +# (= When we move all CONFIGs from header files to Kconfig) | |
8 | +# this makefile can be deleted. | |
9 | + | |
10 | +# obj is "include" or "spl/include" or "tpl/include" | |
11 | +# for non-SPL, SPL, TPL, respectively | |
12 | +include $(obj)/config/auto.conf | |
13 | + | |
14 | +include scripts/Kbuild.include | |
15 | + | |
16 | +# Need to define CC and CPP again here in case the top Makefile did not | |
17 | +# include config.mk. Some architectures expect CROSS_COMPILE to be defined | |
18 | +# in arch/$(ARCH)/config.mk | |
19 | +CC = $(CROSS_COMPILE)gcc | |
20 | +CPP = $(CC) -E | |
21 | + | |
22 | +include config.mk | |
23 | + | |
24 | +UBOOTINCLUDE := \ | |
25 | + -I$(obj) \ | |
26 | + -Iinclude \ | |
27 | + $(if $(KBUILD_SRC), -I$(srctree)/include) \ | |
28 | + -I$(srctree)/arch/$(ARCH)/include \ | |
29 | + -include $(srctree)/include/linux/kconfig.h | |
30 | + | |
31 | +c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \ | |
32 | + $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) | |
33 | + | |
34 | +quiet_cmd_autoconf_dep = GEN $@ | |
35 | + cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \ | |
36 | + -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || { \ | |
37 | + rm $@; false; \ | |
38 | + } | |
39 | +include/autoconf.mk.dep: FORCE | |
40 | + $(call cmd,autoconf_dep) | |
41 | + | |
42 | +# We are migrating from board headers to Kconfig little by little. | |
43 | +# In the interim, we use both of | |
44 | +# - include/config/auto.conf (generated by Kconfig) | |
45 | +# - include/autoconf.mk (used in the U-Boot conventional configuration) | |
46 | +# The following rule creates autoconf.mk | |
47 | +# include/config/auto.conf is grepped in order to avoid duplication of the | |
48 | +# same CONFIG macros | |
49 | +quiet_cmd_autoconf = GEN $@ | |
50 | + cmd_autoconf = \ | |
51 | + $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \ | |
52 | + sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \ | |
53 | + while read line; do \ | |
54 | + if ! grep -q "$${line%=*}=" $(obj)/config/auto.conf; then \ | |
55 | + echo "$$line"; \ | |
56 | + fi \ | |
57 | + done > $@; \ | |
58 | + rm $@.tmp; \ | |
59 | + } || { \ | |
60 | + rm $@.tmp; false; \ | |
61 | + } | |
62 | + | |
63 | +$(obj)/autoconf.mk: FORCE | |
64 | + $(call cmd,autoconf) | |
65 | + | |
66 | +include/autoconf.mk include/autoconf.mk.dep: include/config.h | |
67 | + | |
68 | +# include/config.h | |
69 | +# Prior to Kconfig, it was generated by mkconfig. Now it is created here. | |
70 | +define filechk_config_h | |
71 | + (echo "/* Automatically generated - do not edit */"; \ | |
72 | + for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \ | |
73 | + echo \#define CONFIG_$$i \ | |
74 | + | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \ | |
75 | + done; \ | |
76 | + echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\ | |
77 | + echo \#include \<config_cmd_defaults.h\>; \ | |
78 | + echo \#include \<config_defaults.h\>; \ | |
79 | + echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \ | |
80 | + echo \#include \<asm/config.h\>; \ | |
81 | + echo \#include \<config_fallbacks.h\>; \ | |
82 | + echo \#include \<config_uncmd_spl.h\>; ) | |
83 | +endef | |
84 | + | |
85 | +include/config.h: scripts/Makefile.autoconf create_symlink FORCE | |
86 | + $(call filechk,config_h) | |
87 | + | |
88 | +# symbolic links | |
89 | +PHONY += create_symlink | |
90 | +create_symlink: | |
91 | +ifneq ($(KBUILD_SRC),) | |
92 | + $(Q)mkdir -p include/asm | |
93 | +endif | |
94 | + $(Q)ln -fsn $(srctree)/arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)) \ | |
95 | + $(if $(KBUILD_SRC),,arch/$(ARCH)/)include/asm/arch | |
96 | + | |
97 | +PHONY += FORCE | |
98 | +FORCE: | |
99 | + | |
100 | +.PHONY: $(PHONY) |
... | ... | @@ -3,15 +3,15 @@ |
3 | 3 | # ========================================================================== |
4 | 4 | |
5 | 5 | # Modified for U-Boot |
6 | -ifeq ($(CONFIG_TPL_BUILD),y) | |
7 | - src := $(patsubst tpl/%,%,$(obj)) | |
8 | -else | |
9 | - ifeq ($(CONFIG_SPL_BUILD),y) | |
10 | - src := $(patsubst spl/%,%,$(obj)) | |
11 | - else | |
12 | - src := $(obj) | |
13 | - endif | |
6 | +prefix := tpl | |
7 | +src := $(patsubst $(prefix)/%,%,$(obj)) | |
8 | +ifeq ($(obj),$(src)) | |
9 | +prefix := spl | |
10 | +src := $(patsubst $(prefix)/%,%,$(obj)) | |
11 | +ifeq ($(obj),$(src)) | |
12 | +prefix := . | |
14 | 13 | endif |
14 | +endif | |
15 | 15 | |
16 | 16 | PHONY := __build |
17 | 17 | __build: |
... | ... | @@ -40,18 +40,9 @@ |
40 | 40 | subdir-ccflags-y := |
41 | 41 | |
42 | 42 | # Read auto.conf if it exists, otherwise ignore |
43 | --include include/config/auto.conf | |
44 | - | |
45 | -# Added for U-Boot: Load U-Boot configuration | |
46 | -ifeq ($(CONFIG_TPL_BUILD),y) | |
47 | - -include include/tpl-autoconf.mk | |
48 | -else | |
49 | - ifeq ($(CONFIG_SPL_BUILD),y) | |
50 | - -include include/spl-autoconf.mk | |
51 | - else | |
52 | - -include include/autoconf.mk | |
53 | - endif | |
54 | -endif | |
43 | +# Modified for U-Boot | |
44 | +-include $(prefix)/include/config/auto.conf | |
45 | +-include $(prefix)/include/autoconf.mk | |
55 | 46 | |
56 | 47 | include scripts/Kbuild.include |
57 | 48 |
... | ... | @@ -21,13 +21,10 @@ |
21 | 21 | |
22 | 22 | include $(srctree)/scripts/Kbuild.include |
23 | 23 | |
24 | -CONFIG_SPL_BUILD := y | |
25 | -export CONFIG_SPL_BUILD | |
24 | +UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE) | |
26 | 25 | |
27 | -KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD | |
28 | -ifeq ($(CONFIG_TPL_BUILD),y) | |
29 | -KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD | |
30 | -endif | |
26 | +-include $(obj)/include/config/auto.conf | |
27 | +-include $(obj)/include/autoconf.mk | |
31 | 28 | |
32 | 29 | ifeq ($(CONFIG_TPL_BUILD),y) |
33 | 30 | export CONFIG_TPL_BUILD |
... | ... | @@ -36,14 +33,6 @@ |
36 | 33 | SPL_BIN := u-boot-spl |
37 | 34 | endif |
38 | 35 | |
39 | -include include/config.mk | |
40 | - | |
41 | -ifeq ($(CONFIG_TPL_BUILD),y) | |
42 | - -include include/tpl-autoconf.mk | |
43 | -else | |
44 | - -include include/spl-autoconf.mk | |
45 | -endif | |
46 | - | |
47 | 36 | include $(srctree)/config.mk |
48 | 37 | |
49 | 38 | # Enable garbage collection of un-used sections for SPL |
... | ... | @@ -53,20 +42,6 @@ |
53 | 42 | # FIX ME |
54 | 43 | cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ |
55 | 44 | $(NOSTDINC_FLAGS) |
56 | -c_flags := $(KBUILD_CFLAGS) $(cpp_flags) | |
57 | - | |
58 | -# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) | |
59 | -quiet_cmd_autoconf = GEN $@ | |
60 | - cmd_autoconf = \ | |
61 | - $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ | |
62 | - sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ | |
63 | - rm $@.tmp | |
64 | - | |
65 | -include/tpl-autoconf.mk: include/config.h | |
66 | - $(call cmd,autoconf) | |
67 | - | |
68 | -include/spl-autoconf.mk: include/config.h | |
69 | - $(call cmd,autoconf) | |
70 | 45 | |
71 | 46 | HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) |
72 | 47 |
... | ... | @@ -221,7 +221,11 @@ |
221 | 221 | |
222 | 222 | define_config(m, slen, hash); |
223 | 223 | |
224 | - printf(" $(wildcard include/config/"); | |
224 | + /* printf(" $(wildcard include/config/"); */ | |
225 | + /* modified for U-Boot */ | |
226 | + printf(" $(wildcard %sinclude/config/", | |
227 | + strncmp(depfile, "spl/", 4) ? | |
228 | + (strncmp(depfile, "tpl/", 4) ? "" : "tpl/") : "spl/"); | |
225 | 229 | for (i = 0; i < slen; i++) { |
226 | 230 | c = m[i]; |
227 | 231 | if (c == '_') |
... | ... | @@ -951,6 +951,14 @@ |
951 | 951 | FILE *out, *tristate, *out_h; |
952 | 952 | int i; |
953 | 953 | |
954 | + /* | |
955 | + * Added for U-Boot SPL/TPL | |
956 | + */ | |
957 | + name = getenv("KCONFIG_OBJDIR"); | |
958 | + if (name && name[0]) | |
959 | + if (chdir(name)) | |
960 | + return 1; | |
961 | + | |
954 | 962 | sym_clear_all_valid(); |
955 | 963 | |
956 | 964 | file_write_dep("include/config/auto.conf.cmd"); |
1 | +#!/usr/bin/env python | |
2 | +# | |
3 | +# Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com> | |
4 | +# | |
5 | +# SPDX-License-Identifier: GPL-2.0+ | |
6 | +# | |
7 | + | |
8 | +""" | |
9 | +A wrapper script to adjust Kconfig for U-Boot | |
10 | + | |
11 | +The biggest difference between Linux Kernel and U-Boot in terms of the | |
12 | +board configuration is that U-Boot has to configure multiple boot images | |
13 | +per board: Normal, SPL, TPL. | |
14 | +We need to expand the functions of Kconfig to handle multiple boot | |
15 | +images. | |
16 | + | |
17 | +Instead of touching various parts under the scripts/kconfig/ directory, | |
18 | +pushing necessary adjustments into this single script would be better | |
19 | +for code maintainance. All the make targets related to the configuration | |
20 | +(make %config) should be invoked via this script. | |
21 | + | |
22 | +Let's see what is different from the original Kconfig. | |
23 | + | |
24 | +- config, menuconfig, etc. | |
25 | + | |
26 | +The commands 'make config', 'make menuconfig', etc. are used to create | |
27 | +or modify the .config file, which stores configs for Normal boot image. | |
28 | + | |
29 | +The location of the one for SPL, TPL image is spl/.config, tpl/.config, | |
30 | +respectively. Use 'make spl/config', 'make spl/menuconfig', etc. | |
31 | +to create or modify the spl/.config file, which contains configs | |
32 | +for SPL image. | |
33 | +Do likewise for the tpl/.config file. | |
34 | +The generic syntax for SPL, TPL configuration is | |
35 | +'make <target_image>/<config_command>'. | |
36 | + | |
37 | +- silentoldconfig | |
38 | + | |
39 | +The command 'make silentoldconfig' updates .config, if necessary, and | |
40 | +additionally updates include/generated/autoconf.h and files under | |
41 | +include/configs/ directory. In U-Boot, it should do the same things for | |
42 | +SPL, TPL images for boards supporting them. | |
43 | +Depending on whether CONFIG_SPL, CONFIG_TPL is defined or not, | |
44 | +'make silentoldconfig' iterates three times at most changing the target | |
45 | +directory. | |
46 | + | |
47 | +To sum up, 'make silentoldconfig' possibly updates | |
48 | + - .config, include/generated/autoconf.h, include/config/* | |
49 | + - spl/.config, spl/include/generated/autoconf.h, spl/include/config/* | |
50 | + (in case CONFIG_SPL=y) | |
51 | + - tpl/.config, tpl/include/generated/autoconf.h, tpl/include/config/* | |
52 | + (in case CONFIG_TPL=y) | |
53 | + | |
54 | +- defconfig, <board>_defconfig | |
55 | + | |
56 | +The command 'make <board>_defconfig' creates a new .config based on the | |
57 | +file configs/<board>_defconfig. The command 'make defconfig' is the same | |
58 | +but the difference is it uses the file specified with KBUILD_DEFCONFIG | |
59 | +environment. | |
60 | + | |
61 | +We need to create .config, spl/.config, tpl/.config for boards where SPL | |
62 | +and TPL images are supported. One possible solution for that is to have | |
63 | +multiple defconfig files per board, but it would produce duplication | |
64 | +among the defconfigs. | |
65 | +The approach chosen here is to expand the feature and support | |
66 | +conditional definition in defconfig, that is, each line in defconfig | |
67 | +files has the form of: | |
68 | +<condition>:<macro definition> | |
69 | + | |
70 | +The '<condition>:' prefix specifies which image the line is valid for. | |
71 | +The '<condition>:' is one of: | |
72 | + None - the line is valid only for Normal image | |
73 | + S: - the line is valid only for SPL image | |
74 | + T: - the line is valid only for TPL image | |
75 | + ST: - the line is valid for SPL and TPL images | |
76 | + +S: - the line is valid for Normal and SPL images | |
77 | + +T: - the line is valid for Normal and TPL images | |
78 | + +ST: - the line is valid for Normal, SPL and SPL images | |
79 | + | |
80 | +So, if neither CONFIG_SPL nor CONFIG_TPL is defined, the defconfig file | |
81 | +has no '<condition>:' part and therefore has the same form of that of | |
82 | +Linux Kernel. | |
83 | + | |
84 | +In U-Boot, for example, a defconfig file can be written like this: | |
85 | + | |
86 | + CONFIG_FOO=100 | |
87 | + S:CONFIG_FOO=200 | |
88 | + T:CONFIG_FOO=300 | |
89 | + ST:CONFIG_BAR=y | |
90 | + +S:CONFIG_BAZ=y | |
91 | + +T:CONFIG_QUX=y | |
92 | + +ST:CONFIG_QUUX=y | |
93 | + | |
94 | +The defconfig above is parsed by this script and internally divided into | |
95 | +three temporary defconfig files. | |
96 | + | |
97 | + - Temporary defconfig for Normal image | |
98 | + CONFIG_FOO=100 | |
99 | + CONFIG_BAZ=y | |
100 | + CONFIG_QUX=y | |
101 | + CONFIG_QUUX=y | |
102 | + | |
103 | + - Temporary defconfig for SPL image | |
104 | + CONFIG_FOO=200 | |
105 | + CONFIG_BAR=y | |
106 | + CONFIG_BAZ=y | |
107 | + CONFIG_QUUX=y | |
108 | + | |
109 | + - Temporary defconfig for TPL image | |
110 | + CONFIG_FOO=300 | |
111 | + CONFIG_BAR=y | |
112 | + CONFIG_QUX=y | |
113 | + CONFIG_QUUX=y | |
114 | + | |
115 | +They are passed to scripts/kconfig/conf, each is used for generating | |
116 | +.config, spl/.config, tpl/.config, respectively. | |
117 | + | |
118 | +- savedefconfig | |
119 | + | |
120 | +This is the reverse operation of 'make defconfig'. | |
121 | +If neither CONFIG_SPL nor CONFIG_TPL is defined in the .config file, | |
122 | +it works as 'make savedefconfig' in Linux Kernel: create the minimal set | |
123 | +of config based on the .config and save it into 'defconfig' file. | |
124 | + | |
125 | +If CONFIG_SPL or CONFIG_TPL is defined, the common lines among .config, | |
126 | +spl/.config, tpl/.config are coalesced together and output to the file | |
127 | +'defconfig' in the form like: | |
128 | + | |
129 | + CONFIG_FOO=100 | |
130 | + S:CONFIG_FOO=200 | |
131 | + T:CONFIG_FOO=300 | |
132 | + ST:CONFIG_BAR=y | |
133 | + +S:CONFIG_BAZ=y | |
134 | + +T:CONFIG_QUX=y | |
135 | + +ST:CONFIG_QUUX=y | |
136 | + | |
137 | +This can be used as an input of 'make <board>_defconfig' command. | |
138 | +""" | |
139 | + | |
140 | +import errno | |
141 | +import os | |
142 | +import re | |
143 | +import subprocess | |
144 | +import sys | |
145 | + | |
146 | +# Constant variables | |
147 | +SUB_IMAGES = ('spl', 'tpl') | |
148 | +IMAGES = ('',) + SUB_IMAGES | |
149 | +SYMBOL_MAP = {'': '+', 'spl': 'S', 'tpl': 'T'} | |
150 | +PATTERN_SYMBOL = re.compile(r'(\+?)(S?)(T?):(.*)') | |
151 | + | |
152 | +# Environment variables (should be defined in the top Makefile) | |
153 | +# .get('key', 'default_value') method is useful for standalone testing. | |
154 | +MAKE = os.environ.get('MAKE', 'make') | |
155 | +srctree = os.environ.get('srctree', '.') | |
156 | +KCONFIG_CONFIG = os.environ.get('KCONFIG_CONFIG', '.config') | |
157 | + | |
158 | +# Useful shorthand | |
159 | +build = '%s -f %s/scripts/Makefile.build obj=scripts/kconfig %%s' % (MAKE, srctree) | |
160 | +autoconf = '%s -f %s/scripts/Makefile.autoconf obj=%%s %%s' % (MAKE, srctree) | |
161 | + | |
162 | +### helper functions ### | |
163 | +def mkdirs(*dirs): | |
164 | + """Make directories ignoring 'File exists' error.""" | |
165 | + for d in dirs: | |
166 | + try: | |
167 | + os.makedirs(d) | |
168 | + except OSError as exception: | |
169 | + # Ignore 'File exists' error | |
170 | + if exception.errno != errno.EEXIST: | |
171 | + raise | |
172 | + | |
173 | +def rmfiles(*files): | |
174 | + """Remove files ignoring 'No such file or directory' error.""" | |
175 | + for f in files: | |
176 | + try: | |
177 | + os.remove(f) | |
178 | + except OSError as exception: | |
179 | + # Ignore 'No such file or directory' error | |
180 | + if exception.errno != errno.ENOENT: | |
181 | + raise | |
182 | + | |
183 | +def rmdirs(*dirs): | |
184 | + """Remove directories ignoring 'No such file or directory' | |
185 | + and 'Directory not empty' error. | |
186 | + """ | |
187 | + for d in dirs: | |
188 | + try: | |
189 | + os.rmdir(d) | |
190 | + except OSError as exception: | |
191 | + # Ignore 'No such file or directory' | |
192 | + # and 'Directory not empty' error | |
193 | + if exception.errno != errno.ENOENT and \ | |
194 | + exception.errno != errno.ENOTEMPTY: | |
195 | + raise | |
196 | + | |
197 | +def error(msg): | |
198 | + """Output the given argument to stderr and exit with return code 1.""" | |
199 | + print >> sys.stderr, msg | |
200 | + sys.exit(1) | |
201 | + | |
202 | +def run_command(command, callback_on_error=None): | |
203 | + """Run the given command in a sub-shell (and exit if it fails). | |
204 | + | |
205 | + Arguments: | |
206 | + command: A string of the command | |
207 | + callback_on_error: Callback handler invoked just before exit | |
208 | + when the command fails (Default=None) | |
209 | + """ | |
210 | + retcode = subprocess.call(command, shell=True) | |
211 | + if retcode: | |
212 | + if callback_on_error: | |
213 | + callback_on_error() | |
214 | + error("'%s' Failed" % command) | |
215 | + | |
216 | +def run_make_config(cmd, objdir, callback_on_error=None): | |
217 | + """Run the make command in a sub-shell (and exit if it fails). | |
218 | + | |
219 | + Arguments: | |
220 | + cmd: Make target such as 'config', 'menuconfig', 'defconfig', etc. | |
221 | + objdir: Target directory where the make command is run. | |
222 | + Typically '', 'spl', 'tpl' for Normal, SPL, TPL image, | |
223 | + respectively. | |
224 | + callback_on_error: Callback handler invoked just before exit | |
225 | + when the command fails (Default=None) | |
226 | + """ | |
227 | + # Linux expects defconfig files in arch/$(SRCARCH)/configs/ directory, | |
228 | + # but U-Boot puts them in configs/ directory. | |
229 | + # Give SRCARCH=.. to fake scripts/kconfig/Makefile. | |
230 | + options = 'SRCARCH=.. KCONFIG_OBJDIR=%s' % objdir | |
231 | + if objdir: | |
232 | + options += ' KCONFIG_CONFIG=%s/%s' % (objdir, KCONFIG_CONFIG) | |
233 | + mkdirs(objdir) | |
234 | + run_command(build % cmd + ' ' + options, callback_on_error) | |
235 | + | |
236 | +def get_enabled_subimages(ignore_error=False): | |
237 | + """Parse .config file to detect if CONFIG_SPL, CONFIG_TPL is enabled | |
238 | + and return a tuple of enabled subimages. | |
239 | + | |
240 | + Arguments: | |
241 | + ignore_error: Specify the behavior when '.config' is not found; | |
242 | + Raise an exception if this flag is False. | |
243 | + Return a null tuple if this flag is True. | |
244 | + | |
245 | + Returns: | |
246 | + A tuple of enabled subimages as follows: | |
247 | + () if neither CONFIG_SPL nor CONFIG_TPL is defined | |
248 | + ('spl',) if CONFIG_SPL is defined but CONFIG_TPL is not | |
249 | + ('spl', 'tpl') if both CONFIG_SPL and CONFIG_TPL are defined | |
250 | + """ | |
251 | + enabled = () | |
252 | + match_patterns = [ (img, 'CONFIG_' + img.upper() + '=y\n') | |
253 | + for img in SUB_IMAGES ] | |
254 | + try: | |
255 | + f = open(KCONFIG_CONFIG) | |
256 | + except IOError as exception: | |
257 | + if not ignore_error or exception.errno != errno.ENOENT: | |
258 | + raise | |
259 | + return enabled | |
260 | + with f: | |
261 | + for line in f: | |
262 | + for img, pattern in match_patterns: | |
263 | + if line == pattern: | |
264 | + enabled += (img,) | |
265 | + return enabled | |
266 | + | |
267 | +def do_silentoldconfig(cmd): | |
268 | + """Run 'make silentoldconfig' for all the enabled images. | |
269 | + | |
270 | + Arguments: | |
271 | + cmd: should always be a string 'silentoldconfig' | |
272 | + """ | |
273 | + run_make_config(cmd, '') | |
274 | + subimages = get_enabled_subimages() | |
275 | + for obj in subimages: | |
276 | + mkdirs(os.path.join(obj, 'include', 'config'), | |
277 | + os.path.join(obj, 'include', 'generated')) | |
278 | + run_make_config(cmd, obj) | |
279 | + remove_auto_conf = lambda : rmfiles('include/config/auto.conf') | |
280 | + # If the following part failed, include/config/auto.conf should be deleted | |
281 | + # so 'make silentoldconfig' will be re-run on the next build. | |
282 | + run_command(autoconf % | |
283 | + ('include', 'include/autoconf.mk include/autoconf.mk.dep'), | |
284 | + remove_auto_conf) | |
285 | + # include/config.h has been updated after 'make silentoldconfig'. | |
286 | + # We need to touch include/config/auto.conf so it gets newer | |
287 | + # than include/config.h. | |
288 | + # Otherwise, 'make silentoldconfig' would be invoked twice. | |
289 | + os.utime('include/config/auto.conf', None) | |
290 | + for obj in subimages: | |
291 | + run_command(autoconf % (obj + '/include', | |
292 | + obj + '/include/autoconf.mk'), | |
293 | + remove_auto_conf) | |
294 | + | |
295 | +def do_tmp_defconfig(output_lines, img): | |
296 | + """Helper function for do_board_defconfig(). | |
297 | + | |
298 | + Write the defconfig contents into a file '.tmp_defconfig' and | |
299 | + invoke 'make .tmp_defconfig'. | |
300 | + | |
301 | + Arguments: | |
302 | + output_lines: A sequence of defconfig lines of each image | |
303 | + img: Target image. Typically '', 'spl', 'tpl' for | |
304 | + Normal, SPL, TPL images, respectively. | |
305 | + """ | |
306 | + TMP_DEFCONFIG = '.tmp_defconfig' | |
307 | + TMP_DIRS = ('arch', 'configs') | |
308 | + defconfig_path = os.path.join('configs', TMP_DEFCONFIG) | |
309 | + mkdirs(*TMP_DIRS) | |
310 | + with open(defconfig_path, 'w') as f: | |
311 | + f.write(''.join(output_lines[img])) | |
312 | + cleanup = lambda: (rmfiles(defconfig_path), rmdirs(*TMP_DIRS)) | |
313 | + run_make_config(TMP_DEFCONFIG, img, cleanup) | |
314 | + cleanup() | |
315 | + | |
316 | +def do_board_defconfig(cmd): | |
317 | + """Run 'make <board>_defconfig'. | |
318 | + | |
319 | + Arguments: | |
320 | + cmd: should be a string '<board>_defconfig' | |
321 | + """ | |
322 | + defconfig_path = os.path.join(srctree, 'configs', cmd) | |
323 | + output_lines = dict([ (img, []) for img in IMAGES ]) | |
324 | + with open(defconfig_path) as f: | |
325 | + for line in f: | |
326 | + m = PATTERN_SYMBOL.match(line) | |
327 | + if m: | |
328 | + for idx, img in enumerate(IMAGES): | |
329 | + if m.group(idx + 1): | |
330 | + output_lines[img].append(m.group(4) + '\n') | |
331 | + continue | |
332 | + output_lines[''].append(line) | |
333 | + do_tmp_defconfig(output_lines, '') | |
334 | + for img in get_enabled_subimages(): | |
335 | + do_tmp_defconfig(output_lines, img) | |
336 | + | |
337 | +def do_defconfig(cmd): | |
338 | + """Run 'make defconfig'. | |
339 | + | |
340 | + Arguments: | |
341 | + cmd: should always be a string 'defconfig' | |
342 | + """ | |
343 | + KBUILD_DEFCONFIG = os.environ['KBUILD_DEFCONFIG'] | |
344 | + print "*** Default configuration is based on '%s'" % KBUILD_DEFCONFIG | |
345 | + do_board_defconfig(KBUILD_DEFCONFIG) | |
346 | + | |
347 | +def do_savedefconfig(cmd): | |
348 | + """Run 'make savedefconfig'. | |
349 | + | |
350 | + Arguments: | |
351 | + cmd: should always be a string 'savedefconfig' | |
352 | + """ | |
353 | + DEFCONFIG = 'defconfig' | |
354 | + # Continue even if '.config' does not exist | |
355 | + subimages = get_enabled_subimages(True) | |
356 | + run_make_config(cmd, '') | |
357 | + output_lines = [] | |
358 | + prefix = {} | |
359 | + with open(DEFCONFIG) as f: | |
360 | + for line in f: | |
361 | + output_lines.append(line) | |
362 | + prefix[line] = '+' | |
363 | + for img in subimages: | |
364 | + run_make_config(cmd, img) | |
365 | + unmatched_lines = [] | |
366 | + with open(DEFCONFIG) as f: | |
367 | + for line in f: | |
368 | + if line in output_lines: | |
369 | + index = output_lines.index(line) | |
370 | + output_lines[index:index] = unmatched_lines | |
371 | + unmatched_lines = [] | |
372 | + prefix[line] += SYMBOL_MAP[img] | |
373 | + else: | |
374 | + ummatched_lines.append(line) | |
375 | + prefix[line] = SYMBOL_MAP[img] | |
376 | + with open(DEFCONFIG, 'w') as f: | |
377 | + for line in output_lines: | |
378 | + if prefix[line] == '+': | |
379 | + f.write(line) | |
380 | + else: | |
381 | + f.write(prefix[line] + ':' + line) | |
382 | + | |
383 | +def do_others(cmd): | |
384 | + """Run the make command other than 'silentoldconfig', 'defconfig', | |
385 | + '<board>_defconfig' and 'savedefconfig'. | |
386 | + | |
387 | + Arguments: | |
388 | + cmd: Make target in the form of '<target_image>/<config_command>' | |
389 | + The field '<target_image>/' is typically empty, 'spl/', 'tpl/' | |
390 | + for Normal, SPL, TPL images, respectively. | |
391 | + The field '<config_command>' is make target such as 'config', | |
392 | + 'menuconfig', etc. | |
393 | + """ | |
394 | + objdir, _, cmd = cmd.rpartition('/') | |
395 | + run_make_config(cmd, objdir) | |
396 | + | |
397 | +cmd_list = {'silentoldconfig': do_silentoldconfig, | |
398 | + 'defconfig': do_defconfig, | |
399 | + 'savedefconfig': do_savedefconfig} | |
400 | + | |
401 | +def main(): | |
402 | + cmd = sys.argv[1] | |
403 | + if cmd.endswith('_defconfig'): | |
404 | + do_board_defconfig(cmd) | |
405 | + else: | |
406 | + func = cmd_list.get(cmd, do_others) | |
407 | + func(cmd) | |
408 | + | |
409 | +if __name__ == '__main__': | |
410 | + main() |
... | ... | @@ -193,7 +193,7 @@ |
193 | 193 | # Define _GNU_SOURCE to obtain the getline prototype from stdio.h |
194 | 194 | # |
195 | 195 | HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \ |
196 | - $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \ | |
196 | + $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \ | |
197 | 197 | -I$(srctree)/lib/libfdt \ |
198 | 198 | -I$(srctree)/tools \ |
199 | 199 | -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \ |
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | HOSTCC = $(CC) |
12 | 12 | |
13 | 13 | # Compile for a hosted environment on the target |
14 | -HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \ | |
14 | +HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \ | |
15 | 15 | -idirafter $(srctree)/tools/env \ |
16 | 16 | -DUSE_HOSTCC \ |
17 | 17 | -DTEXT_BASE=$(TEXT_BASE) |
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291
-
mentioned in commit 3ff291