mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 14:44:32 +02:00
build system: Fix parallel & double menuconfig issues when sdkconfig missing
Fixes misbehaviour of default menuconfig when sdkconfig is missing. (Either appearing twice, or breaking if make -jN is used.)
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
# (Note that we only rebuild this makefile automatically for some
|
# (Note that we only rebuild this makefile automatically for some
|
||||||
# targets, see project_config.mk for details.)
|
# targets, see project_config.mk for details.)
|
||||||
SDKCONFIG_MAKEFILE ?= $(BUILD_DIR_BASE)/include/config/auto.conf
|
SDKCONFIG_MAKEFILE ?= $(abspath $(BUILD_DIR_BASE)/include/config/auto.conf)
|
||||||
include $(SDKCONFIG_MAKEFILE)
|
include $(SDKCONFIG_MAKEFILE)
|
||||||
export SDKCONFIG_MAKEFILE # sub-makes (like bootloader) will reuse this path
|
export SDKCONFIG_MAKEFILE # sub-makes (like bootloader) will reuse this path
|
||||||
|
|
||||||
|
@@ -20,44 +20,66 @@ $(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
|
|||||||
MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \
|
MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \
|
||||||
$(MAKE) -C $(KCONFIG_TOOL_DIR)
|
$(MAKE) -C $(KCONFIG_TOOL_DIR)
|
||||||
|
|
||||||
# use a wrapper environment for where we run Kconfig tools
|
|
||||||
KCONFIG_TOOL_ENV=KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
|
|
||||||
COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
|
|
||||||
COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)"
|
|
||||||
|
|
||||||
menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(call prereq_if_explicit,defconfig)
|
|
||||||
$(summary) MENUCONFIG
|
|
||||||
$(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
|
|
||||||
|
|
||||||
ifeq ("$(wildcard $(SDKCONFIG))","")
|
ifeq ("$(wildcard $(SDKCONFIG))","")
|
||||||
ifeq ("$(call prereq_if_explicit,defconfig)","")
|
ifeq ("$(filter defconfig, $(MAKECMDGOALS))","")
|
||||||
# if not configuration is present and defconfig is not a target, run defconfig then menuconfig
|
# if no configuration file is present and defconfig is not a named
|
||||||
$(SDKCONFIG): defconfig menuconfig
|
# target, run defconfig then menuconfig to get the initial config
|
||||||
|
$(SDKCONFIG): menuconfig
|
||||||
|
menuconfig: defconfig
|
||||||
else
|
else
|
||||||
# otherwise, just defconfig
|
# otherwise, just run defconfig
|
||||||
$(SDKCONFIG): defconfig
|
$(SDKCONFIG): defconfig
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# macro for the commands to run kconfig tools conf or mconf.
|
||||||
|
# $1 is the name (& args) of the conf tool to run
|
||||||
|
define RunConf
|
||||||
|
mkdir -p $(BUILD_DIR_BASE)/include/config
|
||||||
|
cd $(BUILD_DIR_BASE); KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
|
||||||
|
COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
|
||||||
|
COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
|
||||||
|
$(KCONFIG_TOOL_DIR)/$1 $(IDF_PATH)/Kconfig
|
||||||
|
endef
|
||||||
|
|
||||||
|
ifeq ("$(MAKE_RESTARTS)","")
|
||||||
|
# menuconfig, defconfig and "GENCONFIG" configuration generation only
|
||||||
|
# ever run on the first make pass, subsequent passes don't run these
|
||||||
|
# (make often wants to re-run them as the conf tool can regenerate the
|
||||||
|
# sdkconfig input file as an output file, but this is not what the
|
||||||
|
# user wants - a single config pass is enough to produce all output
|
||||||
|
# files.)
|
||||||
|
#
|
||||||
|
# To prevent problems missing genconfig, ensure none of these targets
|
||||||
|
# depend on any prerequisite that may cause a make restart as part of
|
||||||
|
# the prerequisite's own recipe.
|
||||||
|
|
||||||
|
menuconfig: $(KCONFIG_TOOL_DIR)/mconf
|
||||||
|
$(summary) MENUCONFIG
|
||||||
|
$(call RunConf,mconf)
|
||||||
|
|
||||||
# defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
|
# defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
|
||||||
defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
|
defconfig: $(KCONFIG_TOOL_DIR)/conf
|
||||||
$(summary) DEFCONFIG
|
$(summary) DEFCONFIG
|
||||||
ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
|
ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
|
||||||
cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG) # append defaults to sdkconfig, will override existing values
|
cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG) # append defaults to sdkconfig, will override existing values
|
||||||
endif
|
endif
|
||||||
mkdir -p $(BUILD_DIR_BASE)/include/config
|
$(call RunConf,conf --olddefconfig)
|
||||||
$(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig
|
|
||||||
|
|
||||||
$(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(SDKCONFIG) $(KCONFIG_TOOL_DIR)/conf $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD)
|
# if neither defconfig or menuconfig are requested, use the GENCONFIG rule to
|
||||||
|
# ensure generated config files are up to date
|
||||||
|
$(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(KCONFIG_TOOL_DIR)/conf $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig)
|
||||||
$(summary) GENCONFIG
|
$(summary) GENCONFIG
|
||||||
mkdir -p $(BUILD_DIR_BASE)/include/config
|
$(call RunConf,conf --silentoldconfig)
|
||||||
cd $(BUILD_DIR_BASE); $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --silentoldconfig $(IDF_PATH)/Kconfig
|
touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h # ensure newer than sdkconfig
|
||||||
touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h
|
|
||||||
# touch to ensure both output files are newer - as 'conf' can also update sdkconfig (a dependency). Without this,
|
|
||||||
# sometimes you can get an infinite make loop on Windows where sdkconfig always gets regenerated newer
|
|
||||||
# than the target(!)
|
|
||||||
|
|
||||||
.PHONY: config-clean
|
else # "$(MAKE_RESTARTS)" != ""
|
||||||
|
# on subsequent make passes, skip config generation entirely
|
||||||
|
defconfig:
|
||||||
|
menuconfig:
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: config-clean defconfig menuconfig
|
||||||
config-clean:
|
config-clean:
|
||||||
$(summary RM CONFIG)
|
$(summary RM CONFIG)
|
||||||
$(MAKE) -C $(KCONFIG_TOOL_DIR) clean
|
$(MAKE) -C $(KCONFIG_TOOL_DIR) clean
|
||||||
|
Reference in New Issue
Block a user