]> granicus.if.org Git - esp-idf/blob - make/project_config.mk
Merge branch 'bugfix/btdm_fix_stop_adv_error_in_dual_core' 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
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 # Workaround to run make parallel (-j). mconf and conf cannot be made simultaneously
19 $(KCONFIG_TOOL_DIR)/mconf: $(KCONFIG_TOOL_DIR)/conf
20
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)
25
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
32 menuconfig: defconfig
33 else
34 # otherwise, just run defconfig
35 $(SDKCONFIG): defconfig
36 endif
37 endif
38
39 # macro for the commands to run kconfig tools conf or mconf.
40 # $1 is the name (& args) of the conf tool to run
41 define RunConf
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
47 endef
48
49 ifndef MAKE_RESTARTS
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
55 # files.)
56 #
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.
60
61 menuconfig: $(KCONFIG_TOOL_DIR)/mconf
62         $(summary) MENUCONFIG
63 ifdef BATCH_BUILD
64         @echo "Can't run interactive configuration inside non-interactive build process."
65         @echo ""
66         @echo "Open a command line terminal and run 'make menuconfig' from there."
67         @echo "See esp-idf documentation for more details."
68         @exit 1
69 else
70         $(call RunConf,mconf)
71 endif
72
73 # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
74 defconfig: $(KCONFIG_TOOL_DIR)/conf
75         $(summary) DEFCONFIG
76 ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
77         cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG)  # append defaults to sdkconfig, will override existing values
78 endif
79         $(call RunConf,conf --olddefconfig)
80
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)
84         $(summary) GENCONFIG
85 ifdef BATCH_BUILD  # can't prompt for new config values like on terminal
86         $(call RunConf,conf --olddefconfig)
87 endif
88         $(call RunConf,conf --silentoldconfig)
89         touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h  # ensure newer than sdkconfig
90
91 else  # "$(MAKE_RESTARTS)" != ""
92 # on subsequent make passes, skip config generation entirely
93 defconfig:
94 menuconfig:
95 endif
96
97 .PHONY: config-clean defconfig menuconfig
98 config-clean:
99         $(summary) RM CONFIG
100         MAKEFLAGS="" $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
101         rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h