]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
kconfig: switch to single .config configuration
authorMasahiro Yamada <yamada.m@jp.panasonic.com>
Tue, 24 Feb 2015 13:26:20 +0000 (22:26 +0900)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 12:00:16 +0000 (14:00 +0200)
When Kconfig for U-boot was examined, one of the biggest issues was
how to support multiple images (Normal, SPL, TPL).  There were
actually two options, "single .config" and "multiple .config".
After some discussions and thought experiments, I chose the latter,
i.e. to create ".config", "spl/.config", "tpl/.config" for Normal,
SPL, TPL, respectively.

It is true that the "multiple .config" strategy provided us the
maximum flexibility and helped to avoid duplicating CONFIGs among
Normal, SPL, TPL, but I have noticed some fatal problems:

[1] It is impossible to share CONFIG options across the images.
  If you change the configuration of Main image, you often have to
  adjust some SPL configurations correspondingly.  Currently, we
  cannot handle the dependencies between them.  It means one of the
  biggest advantages of Kconfig is lost.

[2] It is too painful to change both ".config" and "spl/.config".
  Sunxi guys started to work around this problem by creating a new
  configuration target.  Commit cbdd9a9737cc (sunxi: kconfig: Add
  %_felconfig rule to enable FEL build of sunxi platforms.) added
  "make *_felconfig" to enable CONFIG_SPL_FEL on both images.
  Changing the configuration of multiple images in one command is a
  generic demand.  The current implementation cannot propose any
  good solution about this.

[3] Kconfig files are getting ugly and difficult to understand.
  Commit b724bd7d6349 (dm: Kconfig: Move CONFIG_SYS_MALLOC_F_LEN to
  Kconfig) has sprinkled "if !SPL_BUILD" over the Kconfig files.

[4] The build system got more complicated than it should be.
  To adjust Linux-originated Kconfig to U-Boot, the helper script
  "scripts/multiconfig.sh" was introduced.  Writing a complicated
  text processor is a shell script sometimes caused problems.

Now I believe the "single .config" will serve us better.  With it,
all the problems above would go away.  Instead, we will have to add
some CONFIG_SPL_* (and CONFIG_TPL_*) options such as CONFIG_SPL_DM,
but we will not have much.  Anyway, this is what we do now in
scripts/Makefile.spl.

I admit my mistake with my apology and this commit switches to the
single .config configuration.

It is not so difficult to do that:

 - Remove unnecessary processings from scripts/multiconfig.sh
  This file will remain for a while to support the current defconfig
  format.  It will be removed after more cleanups are done.

 - Adjust some makefiles and Kconfigs

 - Add some entries to include/config_uncmd_spl.h and the new file
   scripts/Makefile.uncmd_spl.  Some CONFIG options that are not
   supported on SPL must be disabled because one .config is shared
   between SPL and U-Boot proper going forward.  I know this is not
   a beautiful solution and I think we can do better, but let's see
   how much we will have to describe them.

 - update doc/README.kconfig

More cleaning up patches will follow this.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 files changed:
Kconfig
arch/arm/cpu/armv7/uniphier/Kconfig
arch/arm/mach-tegra/Kconfig
config.mk
configs/ph1_ld4_defconfig
configs/ph1_pro4_defconfig
configs/ph1_sld8_defconfig
doc/README.kconfig
drivers/core/Kconfig
drivers/mtd/nand/Kconfig
include/config_uncmd_spl.h
scripts/Makefile.autoconf
scripts/Makefile.build
scripts/Makefile.spl
scripts/Makefile.uncmd_spl [new file with mode: 0644]
scripts/multiconfig.sh

diff --git a/Kconfig b/Kconfig
index 85e8fa7309696ecb2e69c732c1afe85ee6597d3d..8ae22be31880669cf0b5813688cdc5cb9feb0d04 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -8,10 +8,6 @@ config UBOOTVERSION
        string
        option env="UBOOTVERSION"
 
-config KCONFIG_OBJDIR
-       string
-       option env="KCONFIG_OBJDIR"
-
 # Allow defaults in arch-specific code to override any given here
 source "arch/Kconfig"
 
@@ -90,15 +86,6 @@ endmenu              # General setup
 
 menu "Boot images"
 
-config SPL_BUILD
-       bool
-       default y if $KCONFIG_OBJDIR="spl" || $KCONFIG_OBJDIR="tpl"
-
-config TPL_BUILD
-       bool
-       depends on $KCONFIG_OBJDIR="tpl"
-       default y
-
 config SUPPORT_SPL
        bool
 
index 8fdef28c02d5434984cc32d89cfb4dfdf1172826..9bbc011eeea0dae0815569bc65dbc1f72af664b7 100644 (file)
@@ -71,7 +71,6 @@ config CMD_DDRPHY_DUMP
 
 choice
        prompt "DDR3 Frequency select"
-       depends on SPL_BUILD
 
 config DDR_FREQ_1600
        bool "DDR3 1600"
index 3a8e2b19d67c73b4cb81931712007bd97c55c358..8569167369c5b709062fb1a72918c3995939b81b 100644 (file)
@@ -24,7 +24,7 @@ config SYS_MALLOC_F_LEN
        default 0x1800
 
 config USE_PRIVATE_LIBGCC
-       default y if SPL_BUILD
+       default y
 
 config DM
        default y if !SPL_BUILD
index 64c2951ac1eb1e6942d5bb5b3100cb871d4ef34a..6282919482bc8b8cc7c879e44e3814858573fa9a 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -24,6 +24,11 @@ VENDOR :=
 
 ARCH := $(CONFIG_SYS_ARCH:"%"=%)
 CPU := $(CONFIG_SYS_CPU:"%"=%)
+ifdef CONFIG_SPL_BUILD
+ifdef CONFIG_TEGRA
+CPU := arm720t
+endif
+endif
 BOARD := $(CONFIG_SYS_BOARD:"%"=%)
 ifneq ($(CONFIG_SYS_VENDOR),)
 VENDOR := $(CONFIG_SYS_VENDOR:"%"=%)
index 86b4b15724b1da02bd7019ac360f4ec2b01a0f79..fa8d291ca190744f3426a480d251932541bbb94c 100644 (file)
@@ -39,4 +39,4 @@ CONFIG_DM_I2C=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
-S:CONFIG_SPL_NAND_DENALI=y
+CONFIG_SPL_NAND_DENALI=y
index 242bcf926359cd0f962aea04f0061fb84f1ad50e..12f069400f04ade69a7abcbc88d4ffbec7189503 100644 (file)
@@ -39,4 +39,4 @@ CONFIG_DM_I2C=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
-S:CONFIG_SPL_NAND_DENALI=y
+CONFIG_SPL_NAND_DENALI=y
index 8e95f17e6d101a200776f35adc3400ff7506e9d9..e66d16656629e5ec9cdcf1493242c379162db15f 100644 (file)
@@ -39,4 +39,4 @@ CONFIG_DM_I2C=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
-S:CONFIG_SPL_NAND_DENALI=y
+CONFIG_SPL_NAND_DENALI=y
index 69dc45970b8393edf238b68dc5ce27500dc06d90..288d17d2324ba529362f27987dcb9678dc79e64c 100644 (file)
@@ -17,109 +17,45 @@ source directory for a basic specification of Kconfig.
 Difference from Linux's Kconfig
 -------------------------------
 
-The biggest difference between Linux Kernel and U-Boot in terms of the
-configuration is that U-Boot has to configure multiple boot images per board:
-Normal, SPL, TPL.
-Kconfig functions need to be expanded for U-Boot to handle multiple images.
-The files scripts/kconfig/* were imported from Linux Kernel and adjusted
-for that purpose.
+Here are some worth-mentioning configuration targets.
 
-See below for how each configuration target works in U-Boot:
+- silentoldconfig
 
-- config, nconfig, menuconfig, xconfig, gconfig
+  This target updates .config, include/generated/autoconf.h and
+  include/configs/* as in Linux.  In U-Boot, it also does the followings
+  for the compatibility with the old configuration system:
 
-  These targets are used to configure Normal and create (or modify) the
-  .config file.  For SPL configuration, the configutation targets are prefixed
-  with "spl/", for example "make spl/config", "make spl/menuconfig", etc.
-  Those targets create or modify the spl/.config file.  Likewise, run
-  "make tpl/config", "make tpl/menuconfig", etc. for TPL.
+   * create a symbolic link "arch/${ARCH}/include/asm/arch" pointing to
+     the SoC/CPU specific header directory
+   * create include/config.h
+   * create include/autoconf.mk
+   * create spl/include/autoconf.mk (SPL and TPL only)
+   * create tpl/include/autoconf.mk (TPL only)
 
-- silentoldconfig
+   If we could completely switch to Kconfig in a long run
+   (i.e. remove all the include/configs/*.h), those additional processings
+   above would be removed.
 
-  This target updates .config, include/generated/autoconf.h and
-  include/configs/*.  In U-Boot, the same thing is done for SPL, TPL,
-  if supported by the target board.  Depending on whether CONFIG_SPL and
-  CONFIG_TPL are defined, "make silentoldconfig" iterates three times at most
-  changing the work directory.
-
-  To sum up, "make silentoldconfig" possibly updates:
-  - .config, include/generated/autoconf.h, include/config/*
-  - spl/.config, spl/include/generated/autoconf.h, spl/include/config/*
-    (in case CONFIG_SPL=y)
-  - tpl/.config, tpl/include/generated/autoconf.h, tpl/include/config/*
-    (in case CONFIG_TPL=y)
-
-- defconfig, <board>_defconfig
-
-  The target "<board>_defconfig" is used to create the .config based on the
-  file configs/<board>_defconfig.  The "defconfig" target is the same
-  except it checks for a file specified with KBUILD_DEFCONFIG environment.
-
-  Note:
-  The defconfig files are placed under the "configs" directory,
-  not "arch/$(ARCH)/configs".  This is because "ARCH" is not necessarily
-  given from the command line for the U-Boot configuration and build.
-
-  The defconfig file format in U-Boot has the special syntax; each line has
-  "<condition>:" prefix to show which image(s) the line is valid for.
-  For example,
-
-  CONFIG_FOO=100
-  S:CONFIG_FOO=200
-  T:CONFIG_FOO=300
-  ST:CONFIG_BAR=y
-  +S:CONFIG_BAZ=y
-  +T:CONFIG_QUX=y
-  +ST:CONFIG_QUUX=y
-
-  Here, the "<condition>:" prefix is one of:
-  None  - the line is valid only for Normal image
-  S:    - the line is valid only for SPL image
-  T:    - the line is valid only for TPL image
-  ST:   - the line is valid for SPL and TPL images
-  +S:   - the line is valid for Normal and SPL images
-  +T:   - the line is valid for Normal and TPL images
-  +ST:  - the line is valid for Normal, SPL and TPL images
-
-  So, if neither CONFIG_SPL nor CONFIG_TPL is defined, the defconfig file
-  has no "<condition>:" part and therefore has the same form as in Linux.
-  From the example defconfig shown above, three separete configuration sets
-  are generated and used for creating .config, spl/.config and tpl/.config.
-
-  - Input for the default configuration of Normal
-     CONFIG_FOO=100
-     CONFIG_BAZ=y
-     CONFIG_QUX=y
-     CONFIG_QUUX=y
-
-  - Input for the default configuration of SPL
-     CONFIG_FOO=200
-     CONFIG_BAR=y
-     CONFIG_BAZ=y
-     CONFIG_QUUX=y
-
-  - Input for the default configuration of TPL
-     CONFIG_FOO=300
-     CONFIG_BAR=y
-     CONFIG_QUX=y
-     CONFIG_QUUX=y
-
-- savedefconfig
-
-  This is the reverse operation of "make defconfig".  If neither CONFIG_SPL
-  nor CONFIG_TPL is defined in the .config file, it works like "savedefconfig"
-  in Linux Kernel: creates the minimal set of config based on the .config
-  and saves it into the "defconfig" file.  If CONFIG_SPL (and CONFIG_TPL) is
-  defined, the common lines among .config, spl/.config (and tpl/.config) are
-  coalesced together with "<condition:>" prefix for each line as shown above.
-  This file can be used as an input of "defconfig" target.
+- defconfig
+
+  In U-Boot, "make defconfig" is a shorthand of "make sandbox_defconfig"
+
+- <board>_defconfig
+
+  Now it works as in Linux.
+  The prefixes such as "+S:" in *_defconfig are deprecated.
+  You can simply remove the prefixes.  Do not add them for new boards.
 
 - <board>_config
 
   This does not exist in Linux's Kconfig.
+  "make <board>_config" works the same as "make <board>_defconfig".
   Prior to Kconfig, in U-Boot, "make <board>_config" was used for the
-  configuration.  It is still supported for backward compatibility and
-  its behavior is the same as "make <board>_defconfig".
+  configuration.  It is still supported for backward compatibility, so
+  we do not need to update the distro recipes.
+
+
+The other configuration targets work as in Linux Kernel.
 
 
 Migration steps to Kconfig
@@ -137,14 +73,10 @@ based configuration as follows:
 
 Configuration files for use in C sources
   - include/generated/autoconf.h     (generated by Kconfig for Normal)
-  - spl/include/generated/autoconf.h (generated by Kconfig for SPL)
-  - tpl/include/generated/autoconf.h (generated by Kconfig for TPL)
   - include/configs/<board>.h        (exists for all boards)
 
 Configuration file for use in makefiles
-  - include/config/auto.conf         (generated by Kconfig for Normal)
-  - spl/include/config/auto.conf     (generated by Kconfig for SPL)
-  - tpl/include/config/auto.conf     (generated by Kconfig for TPL)
+  - include/config/auto.conf         (generated by Kconfig)
   - include/autoconf.mk              (generated by the old config for Normal)
   - spl/include/autoconfig.mk        (generated by the old config for SPL)
   - tpl/include/autoconfig.mk        (generated by the old config for TPL)
@@ -215,8 +147,8 @@ TODO
   CONFIG_SYS_EXTRA_OPTIONS should not be used for new boards.
 
 - In the pre-Kconfig, a single board had multiple entries in the boards.cfg
-  file with differences in the option fields.  The correspoing defconfig files
-  were auto-generated when switching to Kconfig.  Now we have too many
+  file with differences in the option fields.  The corresponding defconfig
+  files were auto-generated when switching to Kconfig.  Now we have too many
   defconfig files compared with the number of the supported boards.  It is
   recommended to have only one defconfig per board and allow users to select
   the config options.
index f0d611007af98921f4ca85cb2f770faf560e74ad..b6180f180f2c4475bc552855fc3d419ea787a285 100644 (file)
@@ -29,7 +29,6 @@ config DM_WARN
          when called.
        depends on DM
        default y if !SPL_BUILD
-       default n if SPL_BUILD
 
 config DM_DEVICE_REMOVE
        bool "Support device removal"
@@ -39,7 +38,6 @@ config DM_DEVICE_REMOVE
          option is disabled for SPL.
        depends on DM
        default y if !SPL_BUILD
-       default n if SPL_BUILD
 
 config DM_STDIO
        bool "Support stdio registration"
@@ -49,4 +47,3 @@ config DM_STDIO
          we can omit this feature.
        depends on DM
        default y if !SPL_BUILD
-       default n if SPL_BUILD
index 3a5ffc1c226e0136747f2444936792051a01b8e2..cf3299ac18c87ed15a5bb80347b5d50c77c0d23a 100644 (file)
@@ -42,7 +42,7 @@ config NAND_DENALI_SPARE_AREA_SKIP_BYTES
 
 endif
 
-if SPL_BUILD
+if SPL
 
 config SPL_NAND_DENALI
        bool "Support Denali NAND controller for SPL"
index 9cb7a9a1fcf81977722c33f2a33a8682c5a8afe1..9f0fe44443319ecdcf501122da15a3be3bf87155 100644 (file)
 #undef CONFIG_CMD_SNTP
 #undef CONFIG_CMD_TFTPPUT
 #undef CONFIG_CMD_TFTPSRV
+#undef CONFIG_OF_CONTROL
+
+#ifndef CONFIG_SPL_DM
+#undef CONFIG_DM_SERIAL
+#undef CONFIG_DM_GPIO
+#undef CONFIG_DM_I2C
+#undef CONFIG_DM_SPI
+#endif
+
 #endif /* CONFIG_SPL_BUILD */
 #endif /* __CONFIG_UNCMD_SPL_H__ */
index 58e1642fb93182ee543363fde0b0573595a9180c..f054081c98959ccbfd0cbd3acbd660fd2b40637c 100644 (file)
@@ -7,9 +7,17 @@
 # (= 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
+__all: include/autoconf.mk include/autoconf.mk.dep
+
+ifeq ($(shell grep -q '^CONFIG_SPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
+__all: spl/include/autoconf.mk
+endif
+
+ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
+__all: tpl/include/autoconf.mk
+endif
+
+include include/config/auto.conf
 
 include scripts/Kbuild.include
 
@@ -22,7 +30,6 @@ CPP           = $(CC) -E
 include config.mk
 
 UBOOTINCLUDE    := \
-               -I$(obj) \
                -Iinclude \
                $(if $(KBUILD_SRC), -I$(srctree)/include) \
                -I$(srctree)/arch/$(ARCH)/include \
@@ -48,10 +55,10 @@ include/autoconf.mk.dep: FORCE
 # same CONFIG macros
 quiet_cmd_autoconf = GEN     $@
       cmd_autoconf = \
-       $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && {  \
+       $(CPP) $(c_flags) $2 -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       \
+                       if ! grep -q "$${line%=*}=" include/config/auto.conf; then      \
                                echo "$$line";                                          \
                        fi                                                              \
                done > $@;                                                              \
@@ -60,10 +67,19 @@ quiet_cmd_autoconf = GEN     $@
                rm $@.tmp; false;                                                       \
        }
 
-$(obj)/autoconf.mk: FORCE
+include/autoconf.mk: FORCE
        $(call cmd,autoconf)
 
-include/autoconf.mk include/autoconf.mk.dep: include/config.h
+spl/include/autoconf.mk: FORCE
+       $(Q)mkdir -p $(dir $@)
+       $(call cmd,autoconf,-DCONFIG_SPL_BUILD)
+
+tpl/include/autoconf.mk: FORCE
+       $(Q)mkdir -p $(dir $@)
+       $(call cmd,autoconf,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
+
+include/autoconf.mk include/autoconf.mk.dep \
+       spl/include/autoconf.mk tpl/include/autoconf.mk: include/config.h
 
 # include/config.h
 # Prior to Kconfig, it was generated by mkconfig. Now it is created here.
@@ -75,10 +91,10 @@ define filechk_config_h
        done;                                                           \
        echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
        echo \#include \<config_defaults.h\>;                           \
+       echo \#include \<config_uncmd_spl.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\>; )
+       echo \#include \<config_fallbacks.h\>;)
 endef
 
 include/config.h: scripts/Makefile.autoconf create_symlink FORCE
index 14cf0925d2fedcdb6d4c6662b7c7fe7f23f1e4a8..ac0554eeae170bd78ff9187ea54ad0f66ec88e52 100644 (file)
@@ -41,8 +41,9 @@ subdir-ccflags-y :=
 
 # Read auto.conf if it exists, otherwise ignore
 # Modified for U-Boot
--include $(prefix)/include/config/auto.conf
+-include include/config/auto.conf
 -include $(prefix)/include/autoconf.mk
+include scripts/Makefile.uncmd_spl
 
 include scripts/Kbuild.include
 
index cc189adc0c604bdb2440dc3b5f9b1bc8e1a8d543..fcacb7fcb49b0269428577de1cce180239d7db72 100644 (file)
@@ -21,13 +21,15 @@ _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 
 include $(srctree)/scripts/Kbuild.include
 
-UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
-
--include $(obj)/include/config/auto.conf
+-include include/config/auto.conf
 -include $(obj)/include/autoconf.mk
 
+KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
+ifeq ($(CONFIG_TPL_BUILD),y)
+KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
+endif
+
 ifeq ($(CONFIG_TPL_BUILD),y)
-export CONFIG_TPL_BUILD
 SPL_BIN := u-boot-tpl
 else
 SPL_BIN := u-boot-spl
diff --git a/scripts/Makefile.uncmd_spl b/scripts/Makefile.uncmd_spl
new file mode 100644 (file)
index 0000000..86c938e
--- /dev/null
@@ -0,0 +1,16 @@
+# Makefile version of include/config_uncmd_spl.h
+#
+# TODO: Invent a better way
+
+ifdef CONFIG_SPL_BUILD
+CONFIG_OF_CONTROL=
+
+ifndef CONFIG_SPL_DM
+CONFIG_DM_SERIAL=
+CONFIG_DM_GPIO=
+CONIFG_DM_I2C=
+CONFIG_DM_SPI=
+CONFIG_DM_SPI_FLASH=
+endif
+
+endif
index 366e8faaa669ab6f97fab11d420eea26ec5f3d74..cc8a787f88602a9d1e88e7b3d4a1515380e1184b 100755 (executable)
@@ -2,11 +2,7 @@
 #
 # A wrapper script to adjust Kconfig for U-Boot
 #
-# Instead of touching various parts under the scripts/kconfig/ directory,
-# pushing necessary adjustments into this single script would be better
-# for code maintainance.  All the make targets related to the configuration
-# (make %config) should be invoked via this script.
-# See doc/README.kconfig for further information of Kconfig.
+# This file will be removed after cleaning up defconfig files
 #
 # Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
 #
 
 set -e
 
-# Set "DEBUG" enavironment variable to show debug messages
-debug () {
-       if [ $DEBUG ]; then
-               echo "$@"
-       fi
-}
-
-# Useful shorthands
-build () {
-       debug $progname: $MAKE -f $srctree/scripts/Makefile.build obj="$@"
-       $MAKE -f $srctree/scripts/Makefile.build obj="$@"
-}
-
-autoconf () {
-       debug $progname: $MAKE -f $srctree/scripts/Makefile.autoconf obj="$@"
-       $MAKE -f $srctree/scripts/Makefile.autoconf obj="$@"
-}
-
 # Make a configuration target
 # Usage:
 #   run_make_config <target> <objdir>
 # <target>: Make target such as "config", "menuconfig", "defconfig", etc.
-# <objdir>: Target directory where the make command is run.
-#           Typically "", "spl", "tpl" for Normal, SPL, TPL, respectively.
 run_make_config () {
-       target=$1
-       objdir=$2
-
        # Linux expects defconfig files in arch/$(SRCARCH)/configs/ directory,
        # but U-Boot has them in configs/ directory.
        # Give SRCARCH=.. to fake scripts/kconfig/Makefile.
-       options="SRCARCH=.. KCONFIG_OBJDIR=$objdir"
-       if [ "$objdir" ]; then
-               options="$options KCONFIG_CONFIG=$objdir/$KCONFIG_CONFIG"
-               mkdir -p $objdir
-       fi
-
-       build scripts/kconfig $options $target
-}
-
-# Parse .config file to detect if CONFIG_SPL, CONFIG_TPL is enabled
-# and returns:
-#   ""        if neither CONFIG_SPL nor CONFIG_TPL is defined
-#   "spl"     if CONFIG_SPL is defined but CONFIG_TPL is not
-#   "spl tpl" if both CONFIG_SPL and CONFIG_TPL are defined
-get_enabled_subimages() {
-       if [ ! -r "$KCONFIG_CONFIG" ]; then
-               # This should never happen
-               echo "$progname: $KCONFIG_CONFIG not found" >&2
-               exit 1
-       fi
-
-       # CONFIG_SPL=y -> spl
-       # CONFIG_TPL=y -> tpl
-       sed -n -e 's/^CONFIG_SPL=y$/spl/p' -e 's/^CONFIG_TPL=y$/tpl/p' \
-                                                        $KCONFIG_CONFIG
+       $MAKE -f $srctree/scripts/Makefile.build obj=scripts/kconfig SRCARCH=.. $1
 }
 
 do_silentoldconfig () {
        run_make_config silentoldconfig
-       subimages=$(get_enabled_subimages)
-
-       for obj in $subimages
-       do
-               mkdir -p $obj/include/config $obj/include/generated
-               run_make_config silentoldconfig $obj
-       done
 
        # If the following part fails, include/config/auto.conf should be
        # deleted so "make silentoldconfig" will be re-run on the next build.
-       autoconf include include/autoconf.mk include/autoconf.mk.dep || {
+       $MAKE -f $srctree/scripts/Makefile.autoconf || {
                rm -f include/config/auto.conf
                exit 1
        }
@@ -95,14 +37,6 @@ do_silentoldconfig () {
        # than include/config.h.
        # Otherwise, 'make silentoldconfig' would be invoked twice.
        touch include/config/auto.conf
-
-       for obj in $subimages
-       do
-               autoconf $obj/include $obj/include/autoconf.mk || {
-                       rm -f include/config/auto.conf
-                       exit 1
-               }
-       done
 }
 
 cleanup_after_defconfig () {
@@ -116,7 +50,6 @@ cleanup_after_defconfig () {
 #  do_board_defconfig <board>_defconfig
 do_board_defconfig () {
        defconfig_path=$srctree/configs/$1
-       tmp_defconfig_path=configs/.tmp_defconfig
 
        if [ ! -r $defconfig_path ]; then
                echo >&2 "***"
@@ -126,42 +59,17 @@ do_board_defconfig () {
        fi
 
        mkdir -p arch configs
-       # defconfig for Normal:
-       #  pick lines without prefixes and lines starting '+' prefix
-       #  and rip the prefixes off.
-       sed -n -e '/^[+A-Z]*:/!p' -e 's/^+[A-Z]*://p' $defconfig_path \
-                                               > configs/.tmp_defconfig
+       # prefix "*:" is deprecated.  Drop it simply.
+       sed -e 's/^[+A-Z]*://' $defconfig_path > configs/.tmp_defconfig
 
        run_make_config .tmp_defconfig || {
                cleanup_after_defconfig
                exit 1
        }
 
-       for img in $(get_enabled_subimages)
-       do
-               symbol=$(echo $img | cut -c 1 | tr '[a-z]' '[A-Z]')
-               # defconfig for SPL, TPL:
-               #   pick lines with 'S', 'T' prefix and rip the prefixes off
-               sed -n -e 's/^[+A-Z]*'$symbol'[A-Z]*://p' $defconfig_path \
-                                               > configs/.tmp_defconfig
-               run_make_config .tmp_defconfig $img || {
-                       cleanup_after_defconfig
-                       exit 1
-               }
-       done
-
        cleanup_after_defconfig
 }
 
-do_defconfig () {
-       if [ "$KBUILD_DEFCONFIG" ]; then
-               do_board_defconfig $KBUILD_DEFCONFIG
-               echo "*** Default configuration is based on '$KBUILD_DEFCONFIG'"
-       else
-               run_make_config defconfig
-       fi
-}
-
 do_board_felconfig () {
     do_board_defconfig ${1%%_felconfig}_defconfig
     if ! grep -q CONFIG_ARCH_SUNXI=y .config || ! grep -q CONFIG_SPL=y .config ; then
@@ -169,162 +77,11 @@ do_board_felconfig () {
        exit 1
     fi
     sed -i -e 's/\# CONFIG_SPL_FEL is not set/CONFIG_SPL_FEL=y\nCONFIG_UART0_PORT_F=n/g' \
-       .config spl/.config
+       .config
 }
 
-do_savedefconfig () {
-       if [ -r "$KCONFIG_CONFIG" ]; then
-               subimages=$(get_enabled_subimages)
-       else
-               subimages=
-       fi
-
-       run_make_config savedefconfig
-
-       output_lines=
-
-       # -r option is necessay because some string-type configs may include
-       # backslashes as an escape character
-       while read -r line
-       do
-               output_lines="$output_lines%$line"
-       done < defconfig
-
-       for img in $subimages
-       do
-               run_make_config savedefconfig $img
-
-               symbol=$(echo $img | cut -c 1 | tr '[a-z]' '[A-Z]')
-               unmatched=
-
-               while read -r line
-               do
-                       tmp=
-                       match=
-
-                       # "# CONFIG_FOO is not set" should not be divided.
-                       # Use "%" as a separator, instead of a whitespace.
-                       # "%" is unlikely to appear in defconfig context.
-                       save_IFS=$IFS
-                       IFS=%
-                       # coalesce common lines together
-                       for i in $output_lines
-                       do
-                               case "$i" in
-                               [+A-Z]*:$line)
-                                       tmp="$tmp%$unmatched"
-                                       i=$(echo "$i" | \
-                                           sed -e "s/^\([^:]*\)/\1$symbol/")
-                                       tmp="$tmp%$i"
-                                       match=1
-                                       ;;
-                               $line)
-                                       tmp="$tmp%$unmatched"
-                                       tmp="$tmp%+$symbol:$i"
-                                       match=1
-                                       ;;
-                               *)
-                                       tmp="$tmp%$i"
-                                       ;;
-                               esac
-                       done
-
-                       # Restore the default separator for the outer for loop.
-                       IFS=$save_IFS
-
-                       if [ "$match" ]; then
-                               output_lines="$tmp"
-                               unmatched=
-                       else
-                               unmatched="$unmatched%$symbol:$line"
-                       fi
-               done < defconfig
-
-               output_lines="$output_lines%$unmatched"
-       done
-
-       rm -f defconfig
-       touch defconfig
-
-       save_IFS=$IFS
-       IFS=%
-
-       for line in $output_lines
-       do
-               case "$line" in
-               "")
-                       # do not output blank lines
-                       ;;
-               *)
-                       echo $line >> defconfig
-                       ;;
-               esac
-       done
-
-       IFS=$save_IFS
-}
-
-# Some sanity checks before running "make <objdir>/<target>",
-# where <objdir> should be either "spl" or "tpl".
-# Doing "make spl/menuconfig" etc. on a non-SPL board makes no sense.
-# It should be allowed only when ".config" exists and "CONFIG_SPL" is enabled.
-#
-# Usage:
-#   check_enabled_sumbimage <objdir>/<target> <objdir>
-check_enabled_subimage () {
-
-       case $2 in
-       spl|tpl) ;;
-       *)
-               echo >&2 "***"
-               echo >&2 "*** \"make $1\" is not supported."
-               echo >&2 "***"
-               exit 1
-               ;;
-       esac
-       test -r "$KCONFIG_CONFIG" && get_enabled_subimages | grep -q $2 || {
-               config=CONFIG_$(echo $2 | tr '[a-z]' '[A-Z]')
-
-               echo >&2 "***"
-               echo >&2 "*** Create \"$KCONFIG_CONFIG\" with \"$config\" enabled"
-               echo >&2 "*** before \"make $1\"."
-               echo >&2 "***"
-               exit 1
-       }
-}
-
-# Usage:
-#   do_others <objdir>/<target>
-# The field "<objdir>/" is typically empy, "spl/", "tpl/" for Normal, SPL, TPL,
-# respectively.
-# The field "<target>" is a configuration target such as "config",
-# "menuconfig", etc.
 do_others () {
-       target=${1##*/}
-
-       if [ "$target" = "$1" ]; then
-               objdir=
-       else
-               objdir=${1%/*}
-               check_enabled_subimage $1 $objdir
-
-               if [ -f "$objdir/$KCONFIG_CONFIG" ]; then
-                       timestamp_before=$(stat --printf="%Y" \
-                                               $objdir/$KCONFIG_CONFIG)
-               fi
-       fi
-
-       run_make_config $target $objdir
-
-       if [ "$timestamp_before" -a -f "$objdir/$KCONFIG_CONFIG" ]; then
-               timestamp_after=$(stat --printf="%Y" $objdir/$KCONFIG_CONFIG)
-
-               if [ "$timestamp_after" -gt "$timestamp_before" ]; then
-                       # $objdir/.config has been updated.
-                       # touch .config to invoke "make silentoldconfig"
-                       touch $KCONFIG_CONFIG
-               fi
-       fi
+       run_make_config $1
 }
 
 progname=$(basename $0)
@@ -340,10 +97,6 @@ case $target in
        do_board_defconfig ${target%_config}_defconfig;;
 silentoldconfig)
        do_silentoldconfig;;
-defconfig)
-       do_defconfig;;
-savedefconfig)
-       do_savedefconfig;;
 *)
        do_others $target;;
 esac