2016-08-17 15:08:22 +00:00
|
|
|
# Makefile support for the menuconfig system
|
|
|
|
|
|
|
|
#Find all Kconfig files for all components
|
|
|
|
COMPONENT_KCONFIGS := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/Kconfig))
|
|
|
|
COMPONENT_KCONFIGS_PROJBUILD := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/Kconfig.projbuild))
|
|
|
|
|
2019-05-05 16:12:33 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2018-11-20 06:25:20 +00:00
|
|
|
# kconfiglib requires Windows-style paths for kconfig files
|
|
|
|
COMPONENT_KCONFIGS := $(shell cygpath -w $(COMPONENT_KCONFIGS))
|
|
|
|
COMPONENT_KCONFIGS_PROJBUILD := $(shell cygpath -w $(COMPONENT_KCONFIGS_PROJBUILD))
|
|
|
|
endif
|
|
|
|
|
2016-08-17 15:08:22 +00:00
|
|
|
#For doing make menuconfig etc
|
2016-08-19 06:32:35 +00:00
|
|
|
KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2016-10-04 04:38:20 +00:00
|
|
|
# set SDKCONFIG to the project's sdkconfig,
|
|
|
|
# unless it's overriden (happens for bootloader)
|
|
|
|
SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
|
|
|
|
|
2016-12-21 01:46:24 +00:00
|
|
|
# SDKCONFIG_DEFAULTS is an optional file containing default
|
|
|
|
# overrides (usually used for esp-idf examples)
|
|
|
|
SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults
|
|
|
|
|
2018-05-24 03:32:34 +00:00
|
|
|
# Workaround to run make parallel (-j). mconf-idf and conf-idf cannot be made simultaneously
|
|
|
|
$(KCONFIG_TOOL_DIR)/mconf-idf: $(KCONFIG_TOOL_DIR)/conf-idf
|
2018-03-27 05:13:35 +00:00
|
|
|
|
2016-10-06 07:29:34 +00:00
|
|
|
# reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
|
2018-05-24 03:32:34 +00:00
|
|
|
$(KCONFIG_TOOL_DIR)/mconf-idf $(KCONFIG_TOOL_DIR)/conf-idf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c)
|
2016-12-03 22:11:22 +00:00
|
|
|
MAKEFLAGS="" CC=$(HOSTCC) LD=$(HOSTLD) \
|
2016-08-17 15:08:22 +00:00
|
|
|
$(MAKE) -C $(KCONFIG_TOOL_DIR)
|
|
|
|
|
2016-10-04 04:38:20 +00:00
|
|
|
ifeq ("$(wildcard $(SDKCONFIG))","")
|
2018-03-27 05:13:35 +00:00
|
|
|
# if no configuration file is present we need a rule for it
|
|
|
|
ifeq ("$(filter $(NON_INTERACTIVE_TARGET), $(MAKECMDGOALS))","")
|
|
|
|
# if special non-interactive item is not a named target (eg. 'defconfig', 'clean')
|
|
|
|
# run defconfig then menuconfig to get the initial config
|
2017-02-06 06:02:07 +00:00
|
|
|
$(SDKCONFIG): menuconfig
|
|
|
|
menuconfig: defconfig
|
2016-11-09 09:38:16 +00:00
|
|
|
else
|
2017-02-06 06:02:07 +00:00
|
|
|
# otherwise, just run defconfig
|
2016-11-09 09:38:16 +00:00
|
|
|
$(SDKCONFIG): defconfig
|
|
|
|
endif
|
2016-08-17 15:08:22 +00:00
|
|
|
endif
|
|
|
|
|
2018-05-24 03:32:34 +00:00
|
|
|
# macro for the commands to run kconfig tools conf-idf or mconf-idf.
|
2017-02-06 06:02:07 +00:00
|
|
|
# $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)" \
|
2018-05-07 02:01:16 +00:00
|
|
|
IDF_CMAKE=n \
|
2017-02-06 06:02:07 +00:00
|
|
|
$(KCONFIG_TOOL_DIR)/$1 $(IDF_PATH)/Kconfig
|
|
|
|
endef
|
|
|
|
|
2016-12-03 22:11:22 +00:00
|
|
|
ifndef MAKE_RESTARTS
|
2017-02-06 06:02:07 +00:00
|
|
|
# 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.
|
|
|
|
|
2018-05-24 03:32:34 +00:00
|
|
|
menuconfig: $(KCONFIG_TOOL_DIR)/mconf-idf
|
2017-02-06 06:02:07 +00:00
|
|
|
$(summary) MENUCONFIG
|
2017-02-10 06:38:24 +00:00
|
|
|
ifdef BATCH_BUILD
|
|
|
|
@echo "Can't run interactive configuration inside non-interactive build process."
|
|
|
|
@echo ""
|
|
|
|
@echo "Open a command line terminal and run 'make menuconfig' from there."
|
|
|
|
@echo "See esp-idf documentation for more details."
|
|
|
|
@exit 1
|
|
|
|
else
|
2018-05-24 03:32:34 +00:00
|
|
|
$(call RunConf,mconf-idf)
|
2017-02-10 06:38:24 +00:00
|
|
|
endif
|
2017-02-06 06:02:07 +00:00
|
|
|
|
2016-12-21 01:46:24 +00:00
|
|
|
# defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
|
2018-05-24 03:32:34 +00:00
|
|
|
defconfig: $(KCONFIG_TOOL_DIR)/conf-idf
|
2016-08-24 05:02:24 +00:00
|
|
|
$(summary) DEFCONFIG
|
2016-12-21 01:46:24 +00:00
|
|
|
ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
|
2017-01-08 23:09:05 +00:00
|
|
|
cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG) # append defaults to sdkconfig, will override existing values
|
2016-12-21 01:46:24 +00:00
|
|
|
endif
|
2018-05-24 03:32:34 +00:00
|
|
|
$(call RunConf,conf-idf --olddefconfig)
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2017-02-06 06:02:07 +00:00
|
|
|
# if neither defconfig or menuconfig are requested, use the GENCONFIG rule to
|
|
|
|
# ensure generated config files are up to date
|
2018-05-24 03:32:34 +00:00
|
|
|
$(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(KCONFIG_TOOL_DIR)/conf-idf $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig)
|
2016-08-24 05:02:24 +00:00
|
|
|
$(summary) GENCONFIG
|
2017-02-10 06:38:24 +00:00
|
|
|
ifdef BATCH_BUILD # can't prompt for new config values like on terminal
|
2018-05-24 03:32:34 +00:00
|
|
|
$(call RunConf,conf-idf --olddefconfig)
|
2017-02-10 06:38:24 +00:00
|
|
|
endif
|
2018-05-24 03:32:34 +00:00
|
|
|
$(call RunConf,conf-idf --silentoldconfig)
|
2017-02-06 06:02:07 +00:00
|
|
|
touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h # ensure newer than sdkconfig
|
|
|
|
|
|
|
|
else # "$(MAKE_RESTARTS)" != ""
|
|
|
|
# on subsequent make passes, skip config generation entirely
|
|
|
|
defconfig:
|
|
|
|
menuconfig:
|
|
|
|
endif
|
2016-08-17 15:08:22 +00:00
|
|
|
|
2017-02-06 06:02:07 +00:00
|
|
|
.PHONY: config-clean defconfig menuconfig
|
2016-08-17 15:08:22 +00:00
|
|
|
config-clean:
|
2016-12-03 22:11:22 +00:00
|
|
|
$(summary) RM CONFIG
|
|
|
|
MAKEFLAGS="" $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
|
2016-11-11 01:29:38 +00:00
|
|
|
rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h
|