@@ -166,9 +166,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
166166
167167export srctree objtree VPATH
168168
169- MKCONFIG := $(srctree ) /mkconfig
170- export MKCONFIG
171-
172169# Make sure CDPATH settings don't interfere
173170unexport CDPATH
174171
@@ -189,16 +186,16 @@ HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
189186
190187export HOSTARCH HOSTOS
191188
192- # Deal with colliding definitions from tcsh etc.
193- VENDOR =
194-
195189# ########################################################################
196190
197191# set default to nothing for native builds
198192ifeq ($(HOSTARCH ) ,$(ARCH ) )
199193CROSS_COMPILE ?=
200194endif
201195
196+ KCONFIG_CONFIG ?= .config
197+ export KCONFIG_CONFIG
198+
202199# SHELL used by kbuild
203200CONFIG_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
341338OBJDUMP = $(CROSS_COMPILE ) objdump
342339AWK = awk
343340PERL = perl
341+ PYTHON = python
344342DTC = dtc
345343CHECK = sparse
346344
@@ -362,7 +360,7 @@ export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION
362360export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR
363361export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
364362export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
365- export MAKE AWK PERL
363+ export MAKE AWK PERL PYTHON
366364export HOSTCXX HOSTCXXFLAGS DTC CHECK CHECKFLAGS
367365
368366export 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
470470else
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-
478475ifeq ($(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 ) ,)
484503include $(srctree ) /config.mk
485-
486- ifeq ($(wildcard include/config.mk) ,)
487- $(error "System not configured - see README")
488504endif
489505
490506# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
@@ -513,8 +529,8 @@ ifndef LDSCRIPT
513529endif
514530
515531else
516-
517-
532+ # Dummy target needed, because used as prerequisite
533+ include/config/auto.conf : ;
518534endif # $(dot-config)
519535
520536KBUILD_CFLAGS += -Os # -fomit-frame-pointer
@@ -563,7 +579,8 @@ KBUILD_CFLAGS += $(KCFLAGS)
563579UBOOTINCLUDE := \
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
568585NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC ) -print-file-name=include)
569586CHECKFLAGS += $(NOSTDINC_FLAGS )
@@ -1024,7 +1041,7 @@ define filechk_uboot.release
10241041endef
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)
10431060prepare3 : include/config/uboot.release
10441061ifneq ($(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
10541071prepare2 : prepare3 outputmakefile
10551072
1056- prepare1 : prepare2 $(version_h ) $(timestamp_h )
1073+ prepare1 : prepare2 $(version_h ) $(timestamp_h ) \
1074+ include /config/auto.conf
10571075ifeq ($(__HAVE_ARCH_GENERIC_BOARD ) ,)
10581076ifeq ($(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
11231118PHONY += depend dep
@@ -1141,7 +1136,7 @@ spl/sunxi-spl.bin: spl/u-boot-spl
11411136 @:
11421137
11431138tpl/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
11461141TAG_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'
12181213CLEAN_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) ) ) )
12251219CLOBBER_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'
0 commit comments