+
+# config file list used for compiling
+LINUX_KCONFIG_LIST := $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(TOPDIR)/env/kernel-config)
+
+# default config list for reconfiguring
+# defaults to subtarget if subtarget exists and target does not
+# defaults to target otherwise
+ifeq ($(if $(wildcard $(LINUX_TARGET_CONFIG)),,$(if $(LINUX_SUBTARGET_CONFIG),1)),1)
+ LINUX_RECONFIG_LIST := $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG))
+ LINUX_RECONFIG_TARGET := $(LINUX_SUBTARGET_CONFIG)
+else
+ LINUX_RECONFIG_LIST := $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG))
+ LINUX_RECONFIG_TARGET := $(LINUX_TARGET_CONFIG)
+endif
+
+# select the config file to be cahnged by kernel_menuconfig/kernel_oldconfig
+ifeq ($(CONFIG_TARGET),platform)
+ LINUX_RECONFIG_LIST := $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG))
+ LINUX_RECONFIG_TARGET := $(LINUX_TARGET_CONFIG)
+endif
+ifeq ($(CONFIG_TARGET),subtarget)
+ ifeq ($(wildcard $(LINUX_SUBTARGET_CONFIG)),)
+ $(error Subtarget not available, cannot reconfigure)
+ else
+ LINUX_RECONFIG_LIST := $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG))
+ LINUX_RECONFIG_TARGET := $(LINUX_SUBTARGET_CONFIG)
+ endif
+endif
+ifeq ($(CONFIG_TARGET),env)
+ LINUX_RECONFIG_LIST := $(LINUX_KCONFIG_LIST)
+ LINUX_RECONFIG_TARGET := $(TOPDIR)/env/kernel-config
+endif
+
+__linux_confcmd = $(SCRIPT_DIR)/kconfig.pl $(2) $(patsubst %,+,$(wordlist 2,9999,$(1))) $(1)
+
+LINUX_CONF_CMD = $(call __linux_confcmd,$(LINUX_KCONFIG_LIST),)
+LINUX_RECONF_CMD = $(call __linux_confcmd,$(LINUX_RECONFIG_LIST),)
+LINUX_RECONF_DIFF = $(call __linux_confcmd,$(filter-out $(LINUX_RECONFIG_TARGET),$(LINUX_RECONFIG_LIST)),'>')