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))
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
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
|
|
|
|
|
2016-10-06 03:29:34 -04:00
|
|
|
# reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
|
2016-08-17 11:08:22 -04:00
|
|
|
$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
|
2016-10-06 03:29:34 -04:00
|
|
|
MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \
|
2016-08-17 11:08:22 -04:00
|
|
|
$(MAKE) -C $(KCONFIG_TOOL_DIR)
|
|
|
|
|
2016-10-04 00:03:48 -04:00
|
|
|
# use a wrapper environment for where we run Kconfig tools
|
2016-10-06 03:05:51 -04:00
|
|
|
KCONFIG_TOOL_ENV=KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
|
2016-10-04 00:38:20 -04:00
|
|
|
COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
|
2016-10-04 00:03:48 -04:00
|
|
|
COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)"
|
|
|
|
|
2017-01-08 18:09:05 -05:00
|
|
|
menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(call prereq_if_explicit,defconfig)
|
2016-10-04 00:03:48 -04:00
|
|
|
$(summary) MENUCONFIG
|
2016-11-10 20:29:38 -05:00
|
|
|
$(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
|
2016-08-17 11:08:22 -04:00
|
|
|
|
2016-10-04 00:38:20 -04:00
|
|
|
ifeq ("$(wildcard $(SDKCONFIG))","")
|
2016-12-22 00:32:19 -05:00
|
|
|
ifeq ("$(call prereq_if_explicit,defconfig)","")
|
2016-12-20 20:46:24 -05:00
|
|
|
# if not configuration is present and defconfig is not a target, run defconfig then menuconfig
|
|
|
|
$(SDKCONFIG): defconfig menuconfig
|
2016-11-09 04:38:16 -05:00
|
|
|
else
|
2016-12-20 20:46:24 -05:00
|
|
|
# otherwise, just defconfig
|
2016-11-09 04:38:16 -05:00
|
|
|
$(SDKCONFIG): defconfig
|
|
|
|
endif
|
2016-08-17 11:08:22 -04:00
|
|
|
endif
|
|
|
|
|
2016-12-20 20:46:24 -05:00
|
|
|
# defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
|
2016-08-23 04:18:36 -04:00
|
|
|
defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
|
2016-08-24 01:02:24 -04:00
|
|
|
$(summary) DEFCONFIG
|
2016-12-20 20:46:24 -05:00
|
|
|
ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
|
2017-01-08 18:09:05 -05:00
|
|
|
cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG) # append defaults to sdkconfig, will override existing values
|
2016-12-20 20:46:24 -05:00
|
|
|
endif
|
2016-11-10 20:29:38 -05:00
|
|
|
mkdir -p $(BUILD_DIR_BASE)/include/config
|
|
|
|
$(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig
|
2016-08-17 11:08:22 -04:00
|
|
|
|
|
|
|
# Work out of whether we have to build the Kconfig makefile
|
|
|
|
# (auto.conf), or if we're in a situation where we don't need it
|
2016-11-08 20:51:55 -05:00
|
|
|
NON_CONFIG_TARGETS := clean %-clean help menuconfig defconfig
|
2016-11-09 21:20:55 -05:00
|
|
|
AUTO_CONF_REGEN_TARGET := $(SDKCONFIG_MAKEFILE)
|
2016-08-17 11:08:22 -04:00
|
|
|
|
|
|
|
# disable AUTO_CONF_REGEN_TARGET if all targets are non-config targets
|
|
|
|
# (and not building default target)
|
|
|
|
ifneq ("$(MAKECMDGOALS)","")
|
|
|
|
ifeq ($(filter $(NON_CONFIG_TARGETS), $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
|
|
|
AUTO_CONF_REGEN_TARGET :=
|
|
|
|
# dummy target
|
2016-11-09 21:20:55 -05:00
|
|
|
$(SDKCONFIG_MAKEFILE):
|
2016-08-17 11:08:22 -04:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2016-10-04 00:38:20 -04:00
|
|
|
$(AUTO_CONF_REGEN_TARGET) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(SDKCONFIG) $(KCONFIG_TOOL_DIR)/conf $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD)
|
2016-08-24 01:02:24 -04:00
|
|
|
$(summary) GENCONFIG
|
2016-11-10 20:29:38 -05:00
|
|
|
mkdir -p $(BUILD_DIR_BASE)/include/config
|
|
|
|
cd $(BUILD_DIR_BASE); $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --silentoldconfig $(IDF_PATH)/Kconfig
|
|
|
|
touch $(AUTO_CONF_REGEN_TARGET) $(BUILD_DIR_BASE)/include/sdkconfig.h
|
2016-08-17 11:08:22 -04:00
|
|
|
# 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
|
|
|
|
config-clean:
|
2016-08-24 01:02:24 -04:00
|
|
|
$(summary RM CONFIG)
|
2016-08-17 11:08:22 -04:00
|
|
|
$(MAKE) -C $(KCONFIG_TOOL_DIR) clean
|
2016-11-10 20:29:38 -05:00
|
|
|
rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h
|