1 # Makefile support for the menuconfig system
3 #Find all Kconfig files for all components
4 COMPONENT_KCONFIGS := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/Kconfig))
5 COMPONENT_KCONFIGS_PROJBUILD := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/Kconfig.projbuild))
7 #For doing make menuconfig etc
8 KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
10 # set SDKCONFIG to the project's sdkconfig,
11 # unless it's overriden (happens for bootloader)
12 SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
14 # SDKCONFIG_DEFAULTS is an optional file containing default
15 # overrides (usually used for esp-idf examples)
16 SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults
18 # Workaround to run make parallel (-j). mconf and conf cannot be made simultaneously
19 $(KCONFIG_TOOL_DIR)/mconf: $(KCONFIG_TOOL_DIR)/conf
21 # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
22 $(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c)
23 MAKEFLAGS="" CC=$(HOSTCC) LD=$(HOSTLD) \
24 $(MAKE) -C $(KCONFIG_TOOL_DIR)
26 ifeq ("$(wildcard $(SDKCONFIG))","")
27 # if no configuration file is present we need a rule for it
28 ifeq ("$(filter $(NON_INTERACTIVE_TARGET), $(MAKECMDGOALS))","")
29 # if special non-interactive item is not a named target (eg. 'defconfig', 'clean')
30 # run defconfig then menuconfig to get the initial config
31 $(SDKCONFIG): menuconfig
34 # otherwise, just run defconfig
35 $(SDKCONFIG): defconfig
39 # macro for the commands to run kconfig tools conf or mconf.
40 # $1 is the name (& args) of the conf tool to run
42 mkdir -p $(BUILD_DIR_BASE)/include/config
43 cd $(BUILD_DIR_BASE); KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
44 COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
45 COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
46 $(KCONFIG_TOOL_DIR)/$1 $(IDF_PATH)/Kconfig
50 # menuconfig, defconfig and "GENCONFIG" configuration generation only
51 # ever run on the first make pass, subsequent passes don't run these
52 # (make often wants to re-run them as the conf tool can regenerate the
53 # sdkconfig input file as an output file, but this is not what the
54 # user wants - a single config pass is enough to produce all output
57 # To prevent problems missing genconfig, ensure none of these targets
58 # depend on any prerequisite that may cause a make restart as part of
59 # the prerequisite's own recipe.
61 menuconfig: $(KCONFIG_TOOL_DIR)/mconf
64 @echo "Can't run interactive configuration inside non-interactive build process."
66 @echo "Open a command line terminal and run 'make menuconfig' from there."
67 @echo "See esp-idf documentation for more details."
73 # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
74 defconfig: $(KCONFIG_TOOL_DIR)/conf
76 ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
77 cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG) # append defaults to sdkconfig, will override existing values
79 $(call RunConf,conf --olddefconfig)
81 # if neither defconfig or menuconfig are requested, use the GENCONFIG rule to
82 # ensure generated config files are up to date
83 $(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)
85 ifdef BATCH_BUILD # can't prompt for new config values like on terminal
86 $(call RunConf,conf --olddefconfig)
88 $(call RunConf,conf --silentoldconfig)
89 touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h # ensure newer than sdkconfig
91 else # "$(MAKE_RESTARTS)" != ""
92 # on subsequent make passes, skip config generation entirely
97 .PHONY: config-clean defconfig menuconfig
100 MAKEFLAGS="" $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
101 rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h