]> granicus.if.org Git - esp-idf/blob - make/project_config.mk
Merge branch 'bugfix/fix_mesh_proxy_adv_with_wrong_dev_name' into 'master'
[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 COMPONENT_SDKCONFIG_RENAMES := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/sdkconfig.rename))
7
8 ifeq ($(OS),Windows_NT)
9 # kconfiglib requires Windows-style paths for kconfig files
10 COMPONENT_KCONFIGS := $(shell cygpath -m $(COMPONENT_KCONFIGS))
11 COMPONENT_KCONFIGS_PROJBUILD := $(shell cygpath -m $(COMPONENT_KCONFIGS_PROJBUILD))
12 COMPONENT_SDKCONFIG_RENAMES := $(shell cygpath -m $(COMPONENT_SDKCONFIG_RENAMES))
13 endif
14
15 #For doing make menuconfig etc
16 KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
17
18 # set SDKCONFIG to the project's sdkconfig,
19 # unless it's overriden (happens for bootloader)
20 SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
21
22 SDKCONFIG_RENAME ?= $(IDF_PATH)/sdkconfig.rename
23
24 # SDKCONFIG_DEFAULTS is an optional file containing default
25 # overrides (usually used for esp-idf examples)
26 SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults
27
28 # Workaround to run make parallel (-j). mconf-idf and conf-idf cannot be made simultaneously
29 $(KCONFIG_TOOL_DIR)/mconf-idf: $(KCONFIG_TOOL_DIR)/conf-idf
30
31 # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
32 $(KCONFIG_TOOL_DIR)/mconf-idf $(KCONFIG_TOOL_DIR)/conf-idf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c)
33         MAKEFLAGS="" CC=$(HOSTCC) LD=$(HOSTLD) \
34         $(MAKE) -C $(KCONFIG_TOOL_DIR)
35
36 ifeq ("$(wildcard $(SDKCONFIG))","")
37 # if no configuration file is present we need a rule for it
38 ifeq ("$(filter $(NON_INTERACTIVE_TARGET), $(MAKECMDGOALS))","")
39 # if special non-interactive item is not a named target (eg. 'defconfig', 'clean')
40 # run defconfig then menuconfig to get the initial config
41 $(SDKCONFIG): menuconfig
42 menuconfig: defconfig
43 else
44 # otherwise, just run defconfig
45 $(SDKCONFIG): defconfig
46 endif
47 endif
48
49 ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
50 ifeq ($(OS),Windows_NT)
51 DEFAULTS_ARG:=--defaults $(shell cygpath -m $(SDKCONFIG_DEFAULTS))
52 else
53 DEFAULTS_ARG:=--defaults $(SDKCONFIG_DEFAULTS)
54 endif
55 else
56 DEFAULTS_ARG:=
57 endif
58
59 # macro for running confgen.py
60 define RunConfGen
61         mkdir -p $(BUILD_DIR_BASE)/include/config
62         $(PYTHON) $(IDF_PATH)/tools/kconfig_new/confgen.py \
63                 --kconfig $(IDF_PATH)/Kconfig \
64                 --config $(SDKCONFIG) \
65                 --sdkconfig-rename $(SDKCONFIG_RENAME) \
66                 --env "COMPONENT_KCONFIGS=$(strip $(COMPONENT_KCONFIGS))" \
67                 --env "COMPONENT_KCONFIGS_PROJBUILD=$(strip $(COMPONENT_KCONFIGS_PROJBUILD))" \
68                 --env "COMPONENT_SDKCONFIG_RENAMES=$(strip $(COMPONENT_SDKCONFIG_RENAMES))" \
69                 --env "IDF_CMAKE=n" \
70                 $(DEFAULTS_ARG) \
71                 --output config ${SDKCONFIG} \
72                 --output makefile $(SDKCONFIG_MAKEFILE) \
73                 --output header $(BUILD_DIR_BASE)/include/sdkconfig.h
74 endef
75
76 # macro for the commands to run kconfig tools conf-idf or mconf-idf.
77 # $1 is the name (& args) of the conf tool to run
78 # Note: Currently only mconf-idf is used for compatibility with the CMake build system. The header file used is also
79 # the same.
80 define RunConf
81         mkdir -p $(BUILD_DIR_BASE)/include/config
82         cd $(BUILD_DIR_BASE); KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
83         COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
84         COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
85         IDF_CMAKE=n \
86         $(KCONFIG_TOOL_DIR)/$1 $(IDF_PATH)/Kconfig
87 endef
88
89 ifndef MAKE_RESTARTS
90 # menuconfig, defconfig and "GENCONFIG" configuration generation only
91 # ever run on the first make pass, subsequent passes don't run these
92 # (make often wants to re-run them as the conf tool can regenerate the
93 # sdkconfig input file as an output file, but this is not what the
94 # user wants - a single config pass is enough to produce all output
95 # files.)
96 #
97 # To prevent problems missing genconfig, ensure none of these targets
98 # depend on any prerequisite that may cause a make restart as part of
99 # the prerequisite's own recipe.
100
101 menuconfig: $(KCONFIG_TOOL_DIR)/mconf-idf | check_python_dependencies
102         $(summary) MENUCONFIG
103 ifdef BATCH_BUILD
104         @echo "Can't run interactive configuration inside non-interactive build process."
105         @echo ""
106         @echo "Open a command line terminal and run 'make menuconfig' from there."
107         @echo "See esp-idf documentation for more details."
108         @exit 1
109 else
110         $(call RunConfGen)
111         # RunConfGen before mconf-idf ensures that deprecated options won't be ignored (they've got renamed)
112         $(call RunConf,mconf-idf)
113         # RunConfGen after mconf-idf ensures that deprecated options are appended to $(SDKCONFIG) for backward compatibility
114         $(call RunConfGen)
115 endif
116
117 # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
118 defconfig: | check_python_dependencies
119         $(summary) DEFCONFIG
120         $(call RunConfGen)
121
122 # if neither defconfig or menuconfig are requested, use the GENCONFIG rule to
123 # ensure generated config files are up to date
124 $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | check_python_dependencies $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig)
125         $(summary) GENCONFIG
126         $(call RunConfGen)
127         touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h  # ensure newer than sdkconfig
128
129 else  # "$(MAKE_RESTARTS)" != ""
130 # on subsequent make passes, skip config generation entirely
131 defconfig:
132 menuconfig:
133 endif
134
135 .PHONY: config-clean defconfig menuconfig
136 config-clean:
137         $(summary) RM CONFIG
138         MAKEFLAGS="" $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
139         rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h