project_config.mk 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Makefile support for the menuconfig system
  2. #Find all Kconfig files for all components
  3. COMPONENT_KCONFIGS := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/Kconfig))
  4. COMPONENT_KCONFIGS_PROJBUILD := $(foreach component,$(COMPONENT_PATHS),$(wildcard $(component)/Kconfig.projbuild))
  5. #For doing make menuconfig etc
  6. KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
  7. # set SDKCONFIG to the project's sdkconfig,
  8. # unless it's overriden (happens for bootloader)
  9. SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
  10. # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
  11. $(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
  12. MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \
  13. $(MAKE) -C $(KCONFIG_TOOL_DIR)
  14. # use a wrapper environment for where we run Kconfig tools
  15. KCONFIG_TOOL_ENV=KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \
  16. COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
  17. COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)"
  18. menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
  19. $(summary) MENUCONFIG
  20. $(Q) $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
  21. ifeq ("$(wildcard $(SDKCONFIG))","")
  22. #No sdkconfig found. Need to run menuconfig to make this if we need it.
  23. $(SDKCONFIG): menuconfig
  24. endif
  25. defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
  26. $(summary) DEFCONFIG
  27. $(Q) mkdir -p $(BUILD_DIR_BASE)/include/config
  28. $(Q) $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig
  29. # Work out of whether we have to build the Kconfig makefile
  30. # (auto.conf), or if we're in a situation where we don't need it
  31. NON_CONFIG_TARGETS := clean %-clean get_variable help menuconfig defconfig
  32. AUTO_CONF_REGEN_TARGET := $(BUILD_DIR_BASE)/include/config/auto.conf
  33. # disable AUTO_CONF_REGEN_TARGET if all targets are non-config targets
  34. # (and not building default target)
  35. ifneq ("$(MAKECMDGOALS)","")
  36. ifeq ($(filter $(NON_CONFIG_TARGETS), $(MAKECMDGOALS)),$(MAKECMDGOALS))
  37. AUTO_CONF_REGEN_TARGET :=
  38. # dummy target
  39. $(BUILD_DIR_BASE)/include/config/auto.conf:
  40. endif
  41. endif
  42. $(AUTO_CONF_REGEN_TARGET) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(SDKCONFIG) $(KCONFIG_TOOL_DIR)/conf $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD)
  43. $(summary) GENCONFIG
  44. $(Q) mkdir -p $(BUILD_DIR_BASE)/include/config
  45. $(Q) cd $(BUILD_DIR_BASE); $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --silentoldconfig $(IDF_PATH)/Kconfig
  46. $(Q) touch $(AUTO_CONF_REGEN_TARGET) $(BUILD_DIR_BASE)/include/sdkconfig.h
  47. # touch to ensure both output files are newer - as 'conf' can also update sdkconfig (a dependency). Without this,
  48. # sometimes you can get an infinite make loop on Windows where sdkconfig always gets regenerated newer
  49. # than the target(!)
  50. clean: config-clean
  51. .PHONY: config-clean
  52. config-clean:
  53. $(summary RM CONFIG)
  54. $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
  55. $(Q) rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h