]> granicus.if.org Git - esp-idf/blob - make/project_config.mk
build system: Probable fix for errors due to bad config bypassing components
[esp-idf] / make / project_config.mk
1 # Makefile support for the menuconfig system
2
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))
6
7 #For doing make menuconfig etc
8 KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
9
10 # set SDKCONFIG to the project's sdkconfig,
11 # unless it's overriden (happens for bootloader)
12 SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
13
14 # SDKCONFIG_DEFAULTS is an optional file containing default
15 # overrides (usually used for esp-idf examples)
16 SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults
17
18 # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
19 $(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
20         MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \
21         $(MAKE) -C $(KCONFIG_TOOL_DIR)
22
23 # use a wrapper environment for where we run Kconfig tools
24 KCONFIG_TOOL_ENV=KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
25         COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
26         COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)"
27
28 menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(call prereq_if_explicit,defconfig)
29         $(summary) MENUCONFIG
30         $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
31
32 ifeq ("$(wildcard $(SDKCONFIG))","")
33 ifeq ("$(call prereq_if_explicit,defconfig)","")
34 # if not configuration is present and defconfig is not a target, run defconfig then menuconfig
35 $(SDKCONFIG): defconfig menuconfig
36 else
37 # otherwise, just defconfig
38 $(SDKCONFIG): defconfig
39 endif
40 endif
41
42 # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
43 defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
44         $(summary) DEFCONFIG
45 ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
46         cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG)  # append defaults to sdkconfig, will override existing values
47 endif
48         mkdir -p $(BUILD_DIR_BASE)/include/config
49         $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig
50
51 $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(SDKCONFIG) $(KCONFIG_TOOL_DIR)/conf $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD)
52         $(summary) GENCONFIG
53         mkdir -p $(BUILD_DIR_BASE)/include/config
54         cd $(BUILD_DIR_BASE); $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --silentoldconfig $(IDF_PATH)/Kconfig
55         touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h
56 # touch to ensure both output files are newer - as 'conf' can also update sdkconfig (a dependency). Without this,
57 # sometimes you can get an infinite make loop on Windows where sdkconfig always gets regenerated newer
58 # than the target(!)
59
60 .PHONY: config-clean
61 config-clean:
62         $(summary RM CONFIG)
63         $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
64         rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h