2016-08-17 11:08:22 -04: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-07-16 10:39:12 -04:00
|
|
|
COMPONENT_SDKCONFIG_RENAMES := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/sdkconfig.rename))
|
2019-09-10 03:58:52 -04:00
|
|
|
COMPONENT_KCONFIGS_SOURCE_FILE:=$(BUILD_DIR_BASE)/kconfigs.in
|
|
|
|
COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE:=$(BUILD_DIR_BASE)/kconfigs_projbuild.in
|
|
|
|
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2019-05-05 12:12:33 -04:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2018-11-20 01:25:20 -05:00
|
|
|
# kconfiglib requires Windows-style paths for kconfig files
|
2019-09-16 23:47:05 -04:00
|
|
|
COMPONENT_KCONFIGS := $(shell cygpath -m $(COMPONENT_KCONFIGS))
|
|
|
|
COMPONENT_KCONFIGS_PROJBUILD := $(shell cygpath -m $(COMPONENT_KCONFIGS_PROJBUILD))
|
|
|
|
COMPONENT_SDKCONFIG_RENAMES := $(shell cygpath -m $(COMPONENT_SDKCONFIG_RENAMES))
|
2019-09-10 03:58:52 -04:00
|
|
|
COMPONENT_KCONFIGS_SOURCE_FILE := $(shell cygpath -m $(COMPONENT_KCONFIGS_SOURCE_FILE))
|
|
|
|
COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE := $(shell cygpath -m $(COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE))
|
2018-11-20 01:25:20 -05:00
|
|
|
endif
|
|
|
|
|
2016-08-17 11:08:22 -04:00
|
|
|
#For doing make menuconfig etc
|
2016-08-19 02:32:35 -04:00
|
|
|
KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2016-10-04 00:38:20 -04:00
|
|
|
# set SDKCONFIG to the project's sdkconfig,
|
|
|
|
# unless it's overriden (happens for bootloader)
|
|
|
|
SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
|
|
|
|
|
2019-07-16 10:39:12 -04:00
|
|
|
SDKCONFIG_RENAME ?= $(IDF_PATH)/sdkconfig.rename
|
|
|
|
|
2016-12-20 20:46:24 -05:00
|
|
|
# SDKCONFIG_DEFAULTS is an optional file containing default
|
|
|
|
# overrides (usually used for esp-idf examples)
|
|
|
|
SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults
|
|
|
|
|
2018-05-23 23:32:34 -04: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 01:13:35 -04:00
|
|
|
|
2016-10-06 03:29:34 -04:00
|
|
|
# reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
|
2019-11-08 08:40:28 -05:00
|
|
|
$(KCONFIG_TOOL_DIR)/mconf-idf $(KCONFIG_TOOL_DIR)/conf-idf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c) $(wildcard $(KCONFIG_TOOL_DIR)/*.y)
|
2019-09-10 03:58:52 -04:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
# mconf-idf is used only in MSYS
|
2016-12-03 17:11:22 -05:00
|
|
|
MAKEFLAGS="" CC=$(HOSTCC) LD=$(HOSTLD) \
|
2016-08-17 11:08:22 -04:00
|
|
|
$(MAKE) -C $(KCONFIG_TOOL_DIR)
|
2019-09-10 03:58:52 -04:00
|
|
|
else
|
|
|
|
@echo "mconf-idf is not required on this platform"
|
|
|
|
endif
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2016-10-04 00:38:20 -04:00
|
|
|
ifeq ("$(wildcard $(SDKCONFIG))","")
|
2018-03-27 01:13:35 -04: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 01:02:07 -05:00
|
|
|
$(SDKCONFIG): menuconfig
|
|
|
|
menuconfig: defconfig
|
2016-11-09 04:38:16 -05:00
|
|
|
else
|
2017-02-06 01:02:07 -05:00
|
|
|
# otherwise, just run defconfig
|
2016-11-09 04:38:16 -05:00
|
|
|
$(SDKCONFIG): defconfig
|
|
|
|
endif
|
2016-08-17 11:08:22 -04:00
|
|
|
endif
|
|
|
|
|
2019-09-10 03:58:52 -04:00
|
|
|
ifeq ("$(PYTHON)","")
|
|
|
|
# fallback value when menuconfig is called without a build directory and sdkconfig file
|
|
|
|
PYTHON=python
|
|
|
|
endif
|
|
|
|
|
2019-10-29 10:12:15 -04:00
|
|
|
SDKCONFIG_DEFAULTS_FILES := $(foreach f,$(SDKCONFIG_DEFAULTS),$(wildcard $(f)))
|
|
|
|
# for each sdkconfig.defaults file, also add sdkconfig.defaults.IDF_TARGET, if it exists
|
|
|
|
SDKCONFIG_DEFAULTS_FILES += $(foreach f,$(SDKCONFIG_DEFAULTS_FILES),$(wildcard $(f).$(IDF_TARGET)))
|
|
|
|
|
2019-09-25 09:58:02 -04:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2019-11-08 08:40:28 -05:00
|
|
|
# -i is for ignore missing arguments in case SDKCONFIG_DEFAULTS_FILES is empty
|
|
|
|
SDKCONFIG_DEFAULTS_FILES := $(shell cygpath -i -m $(SDKCONFIG_DEFAULTS_FILES))
|
2019-09-25 09:58:02 -04:00
|
|
|
endif
|
2019-10-29 10:12:15 -04:00
|
|
|
DEFAULTS_ARG := $(foreach f,$(SDKCONFIG_DEFAULTS_FILES),--defaults $(f))
|
2019-09-25 09:58:02 -04:00
|
|
|
|
2019-10-21 07:44:19 -04:00
|
|
|
prepare_kconfig_files:
|
|
|
|
mkdir -p $(BUILD_DIR_BASE)
|
|
|
|
$(PYTHON) $(IDF_PATH)/tools/kconfig_new/prepare_kconfig_files.py \
|
|
|
|
--env "COMPONENT_KCONFIGS=$(strip $(COMPONENT_KCONFIGS))" \
|
|
|
|
--env "COMPONENT_KCONFIGS_PROJBUILD=$(strip $(COMPONENT_KCONFIGS_PROJBUILD))" \
|
|
|
|
--env "COMPONENT_KCONFIGS_SOURCE_FILE=$(COMPONENT_KCONFIGS_SOURCE_FILE)" \
|
|
|
|
--env "COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=$(COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE)"
|
|
|
|
|
2019-03-14 04:54:04 -04:00
|
|
|
# macro for running confgen.py
|
|
|
|
define RunConfGen
|
|
|
|
mkdir -p $(BUILD_DIR_BASE)/include/config
|
|
|
|
$(PYTHON) $(IDF_PATH)/tools/kconfig_new/confgen.py \
|
|
|
|
--kconfig $(IDF_PATH)/Kconfig \
|
|
|
|
--config $(SDKCONFIG) \
|
2019-07-16 10:39:12 -04:00
|
|
|
--sdkconfig-rename $(SDKCONFIG_RENAME) \
|
2019-03-14 04:54:04 -04:00
|
|
|
--env "COMPONENT_KCONFIGS=$(strip $(COMPONENT_KCONFIGS))" \
|
|
|
|
--env "COMPONENT_KCONFIGS_PROJBUILD=$(strip $(COMPONENT_KCONFIGS_PROJBUILD))" \
|
2019-09-10 03:58:52 -04:00
|
|
|
--env "COMPONENT_KCONFIGS_SOURCE_FILE=$(COMPONENT_KCONFIGS_SOURCE_FILE)" \
|
|
|
|
--env "COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=$(COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE)" \
|
2019-07-16 10:39:12 -04:00
|
|
|
--env "COMPONENT_SDKCONFIG_RENAMES=$(strip $(COMPONENT_SDKCONFIG_RENAMES))" \
|
2019-03-14 04:54:04 -04:00
|
|
|
--env "IDF_CMAKE=n" \
|
2020-06-25 05:52:35 -04:00
|
|
|
--env "IDF_ENV_FPGA=n" \
|
2019-09-25 09:58:02 -04:00
|
|
|
$(DEFAULTS_ARG) \
|
2019-03-14 04:54:04 -04:00
|
|
|
--output config ${SDKCONFIG} \
|
|
|
|
--output makefile $(SDKCONFIG_MAKEFILE) \
|
2019-11-08 08:40:28 -05:00
|
|
|
--output header $(BUILD_DIR_BASE)/include/sdkconfig.h \
|
|
|
|
$1
|
2019-03-14 04:54:04 -04:00
|
|
|
endef
|
|
|
|
|
2019-11-22 09:05:46 -05:00
|
|
|
export MENUCONFIG_STYLE ?= aquatic
|
|
|
|
|
2019-09-10 03:58:52 -04:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
MENUCONFIG_CMD := $(KCONFIG_TOOL_DIR)/mconf-idf
|
|
|
|
else
|
2019-11-22 09:05:46 -05:00
|
|
|
MENUCONFIG_CMD := $(PYTHON) $(IDF_PATH)/tools/kconfig_new/menuconfig.py
|
2019-09-10 03:58:52 -04:00
|
|
|
endif
|
|
|
|
|
2019-11-15 06:51:18 -05:00
|
|
|
.PHONY: term_check
|
|
|
|
term_check:
|
|
|
|
ifneq ($(OS),Windows_NT)
|
|
|
|
${PYTHON} ${IDF_PATH}/tools/check_term.py
|
|
|
|
endif
|
|
|
|
|
2019-09-10 03:58:52 -04:00
|
|
|
# macro for running menuconfig
|
|
|
|
define RunMenuConf
|
2017-02-06 01:02:07 -05:00
|
|
|
mkdir -p $(BUILD_DIR_BASE)/include/config
|
|
|
|
cd $(BUILD_DIR_BASE); KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
|
2019-09-10 03:58:52 -04:00
|
|
|
KCONFIG_CONFIG=$(SDKCONFIG) \
|
|
|
|
COMPONENT_KCONFIGS_SOURCE_FILE="$(COMPONENT_KCONFIGS_SOURCE_FILE)" \
|
|
|
|
COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE="$(COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE)" \
|
2018-05-06 22:01:16 -04:00
|
|
|
IDF_CMAKE=n \
|
2020-06-25 05:52:35 -04:00
|
|
|
IDF_ENV_FPGA=n \
|
2019-09-10 03:58:52 -04:00
|
|
|
$(MENUCONFIG_CMD) $(IDF_PATH)/Kconfig
|
2017-02-06 01:02:07 -05:00
|
|
|
endef
|
|
|
|
|
2016-12-03 17:11:22 -05:00
|
|
|
ifndef MAKE_RESTARTS
|
2017-02-06 01:02:07 -05: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.
|
|
|
|
|
2019-11-15 06:51:18 -05:00
|
|
|
menuconfig: $(KCONFIG_TOOL_DIR)/mconf-idf | check_python_dependencies term_check prepare_kconfig_files
|
2017-02-06 01:02:07 -05:00
|
|
|
$(summary) MENUCONFIG
|
2017-02-10 01:38:24 -05: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
|
2019-11-08 08:40:28 -05:00
|
|
|
$(call RunConfGen,--dont-write-deprecated)
|
2019-09-10 03:58:52 -04:00
|
|
|
# RunConfGen before menuconfig ensures that deprecated options won't be ignored (they've got renamed)
|
|
|
|
$(call RunMenuConf)
|
|
|
|
# RunConfGen after menuconfig ensures that deprecated options are appended to $(SDKCONFIG) for backward compatibility
|
2019-11-08 08:40:28 -05:00
|
|
|
$(call RunConfGen,)
|
2017-02-10 01:38:24 -05:00
|
|
|
endif
|
2017-02-06 01:02:07 -05:00
|
|
|
|
2016-12-20 20:46:24 -05:00
|
|
|
# defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
|
2019-10-21 07:44:19 -04:00
|
|
|
defconfig: | check_python_dependencies prepare_kconfig_files
|
2016-08-24 01:02:24 -04:00
|
|
|
$(summary) DEFCONFIG
|
2019-11-08 08:40:28 -05:00
|
|
|
$(call RunConfGen,)
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2017-02-06 01:02:07 -05:00
|
|
|
# if neither defconfig or menuconfig are requested, use the GENCONFIG rule to
|
|
|
|
# ensure generated config files are up to date
|
2019-10-21 07:44:19 -04:00
|
|
|
$(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | check_python_dependencies prepare_kconfig_files $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig)
|
2016-08-24 01:02:24 -04:00
|
|
|
$(summary) GENCONFIG
|
2019-11-08 08:40:28 -05:00
|
|
|
$(call RunConfGen,)
|
2017-02-06 01:02:07 -05: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 11:08:22 -04:00
|
|
|
|
2017-02-06 01:02:07 -05:00
|
|
|
.PHONY: config-clean defconfig menuconfig
|
2016-08-17 11:08:22 -04:00
|
|
|
config-clean:
|
2016-12-03 17:11:22 -05:00
|
|
|
$(summary) RM CONFIG
|
2019-11-27 04:11:52 -05:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2016-12-03 17:11:22 -05:00
|
|
|
MAKEFLAGS="" $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
|
2019-11-27 04:11:52 -05:00
|
|
|
endif
|
2019-09-10 03:58:52 -04:00
|
|
|
rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h \
|
|
|
|
$(COMPONENT_KCONFIGS_SOURCE_FILE) $(COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE)
|