1 # Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
3 # Makefile support for the menuconfig system
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 #Find all Kconfig files for all components
18 COMPONENT_KCONFIGS
:= $(foreach component
,$(COMPONENT_PATHS
),$(wildcard $(component
)/Kconfig
))
19 COMPONENT_KCONFIGS_PROJBUILD
:= $(foreach component
,$(COMPONENT_PATHS
),$(wildcard $(component
)/Kconfig.projbuild
))
21 #For doing make menuconfig etc
22 KCONFIG_TOOL_DIR
=$(IDF_PATH
)/tools
/kconfig
24 # set SDKCONFIG to the project's sdkconfig,
25 # unless it's overriden (happens for bootloader)
26 SDKCONFIG ?
= $(PROJECT_PATH
)/sdkconfig
28 # SDKCONFIG_DEFAULTS is an optional file containing default
29 # overrides (usually used for esp-idf examples)
30 SDKCONFIG_DEFAULTS ?
= $(PROJECT_PATH
)/sdkconfig.defaults
32 # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
33 $(KCONFIG_TOOL_DIR
)/mconf
$(KCONFIG_TOOL_DIR
)/conf
: $(wildcard $(KCONFIG_TOOL_DIR
)/*.c
)
34 MAKEFLAGS
="" CC
=$(HOSTCC
) LD
=$(HOSTLD
) \
35 $(MAKE
) -C
$(KCONFIG_TOOL_DIR
)
37 ifeq ("$(wildcard $(SDKCONFIG))","")
38 ifeq ("$(filter defconfig clean% %clean, $(MAKECMDGOALS))","")
39 # if no configuration file is present and defconfig or clean
40 # is not a named target, run defconfig then menuconfig to get the initial config
41 $(SDKCONFIG
): menuconfig
44 # otherwise, just run defconfig
45 $(SDKCONFIG
): defconfig
49 # macro for the commands to run kconfig tools conf or mconf.
50 # $1 is the name (& args) of the conf tool to run
52 mkdir
-p
$(BUILD_DIR_BASE
)/include/config
53 cd
$(BUILD_DIR_BASE
); KCONFIG_AUTOHEADER
=$(abspath
$(BUILD_DIR_BASE
)/include/sdkconfig.h
) \
54 COMPONENT_KCONFIGS
="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG
=$(SDKCONFIG
) \
55 COMPONENT_KCONFIGS_PROJBUILD
="$(COMPONENT_KCONFIGS_PROJBUILD)" \
56 $(KCONFIG_TOOL_DIR
)/$1 $(IDF_PATH
)/Kconfig
60 # menuconfig, defconfig and "GENCONFIG" configuration generation only
61 # ever run on the first make pass, subsequent passes don't run these
62 # (make often wants to re-run them as the conf tool can regenerate the
63 # sdkconfig input file as an output file, but this is not what the
64 # user wants - a single config pass is enough to produce all output
67 # To prevent problems missing genconfig, ensure none of these targets
68 # depend on any prerequisite that may cause a make restart as part of
69 # the prerequisite's own recipe.
71 menuconfig
: $(KCONFIG_TOOL_DIR
)/mconf
74 @echo
"Can't run interactive configuration inside non-interactive build process."
76 @echo
"Open a command line terminal and run 'make menuconfig' from there."
77 @echo
"See esp-idf documentation for more details."
83 # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
84 defconfig
: $(KCONFIG_TOOL_DIR
)/conf
86 ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
87 cat
$(SDKCONFIG_DEFAULTS
) >> $(SDKCONFIG
) # append defaults to sdkconfig, will override existing values
89 $(call RunConf
,conf
--olddefconfig
)
91 # if neither defconfig or menuconfig are requested, use the GENCONFIG rule to
92 # ensure generated config files are up to date
93 $(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
)
95 ifdef BATCH_BUILD
# can't prompt for new config values like on terminal
96 $(call RunConf
,conf
--olddefconfig
)
98 $(call RunConf
,conf
--silentoldconfig
)
99 touch
$(SDKCONFIG_MAKEFILE
) $(BUILD_DIR_BASE
)/include/sdkconfig.h
# ensure newer than sdkconfig
101 else # "$(MAKE_RESTARTS)" != ""
102 # on subsequent make passes, skip config generation entirely
107 .PHONY
: config-clean defconfig menuconfig
110 MAKEFLAGS
="" $(MAKE
) -C
$(KCONFIG_TOOL_DIR
) clean
111 rm -rf
$(BUILD_DIR_BASE
)/include/config
$(BUILD_DIR_BASE
)/include/sdkconfig.h