]> granicus.if.org Git - esp-idf/blob - make/project_config.mk
component/bt: stop to initiate AVDTP connection on failure of A2DP service discovery
[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-idf and conf-idf cannot be made simultaneously
19 $(KCONFIG_TOOL_DIR)/mconf-idf: $(KCONFIG_TOOL_DIR)/conf-idf
20
21 # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
22 $(KCONFIG_TOOL_DIR)/mconf-idf $(KCONFIG_TOOL_DIR)/conf-idf: $(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-idf or mconf-idf.
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         IDF_CMAKE=n \
47         $(KCONFIG_TOOL_DIR)/$1 $(IDF_PATH)/Kconfig
48 endef
49
50 ifndef MAKE_RESTARTS
51 # menuconfig, defconfig and "GENCONFIG" configuration generation only
52 # ever run on the first make pass, subsequent passes don't run these
53 # (make often wants to re-run them as the conf tool can regenerate the
54 # sdkconfig input file as an output file, but this is not what the
55 # user wants - a single config pass is enough to produce all output
56 # files.)
57 #
58 # To prevent problems missing genconfig, ensure none of these targets
59 # depend on any prerequisite that may cause a make restart as part of
60 # the prerequisite's own recipe.
61
62 menuconfig: $(KCONFIG_TOOL_DIR)/mconf-idf
63         $(summary) MENUCONFIG
64 ifdef BATCH_BUILD
65         @echo "Can't run interactive configuration inside non-interactive build process."
66         @echo ""
67         @echo "Open a command line terminal and run 'make menuconfig' from there."
68         @echo "See esp-idf documentation for more details."
69         @exit 1
70 else
71         $(call RunConf,mconf-idf)
72 endif
73
74 # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
75 defconfig: $(KCONFIG_TOOL_DIR)/conf-idf
76         $(summary) DEFCONFIG
77 ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
78         cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG)  # append defaults to sdkconfig, will override existing values
79 endif
80         $(call RunConf,conf-idf --olddefconfig)
81
82 # if neither defconfig or menuconfig are requested, use the GENCONFIG rule to
83 # ensure generated config files are up to date
84 $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(KCONFIG_TOOL_DIR)/conf-idf $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig)
85         $(summary) GENCONFIG
86 ifdef BATCH_BUILD  # can't prompt for new config values like on terminal
87         $(call RunConf,conf-idf --olddefconfig)
88 endif
89         $(call RunConf,conf-idf --silentoldconfig)
90         touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h  # ensure newer than sdkconfig
91
92 else  # "$(MAKE_RESTARTS)" != ""
93 # on subsequent make passes, skip config generation entirely
94 defconfig:
95 menuconfig:
96 endif
97
98 .PHONY: config-clean defconfig menuconfig
99 config-clean:
100         $(summary) RM CONFIG
101         MAKEFLAGS="" $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
102         rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h