project_config.mk 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. # clear MAKEFLAGS as the menuconfig makefile uses implicit compile rules
  8. $(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
  9. MAKEFLAGS="" \
  10. CFLAGS="" \
  11. LDFLAGS="" \
  12. CC=$(HOSTCC) LD=$(HOSTLD) \
  13. $(MAKE) -C $(KCONFIG_TOOL_DIR)
  14. menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
  15. $(summary) MENUCONFIG
  16. $(Q) KCONFIG_AUTOHEADER=$(PROJECT_PATH)/build/include/sdkconfig.h \
  17. KCONFIG_CONFIG=$(PROJECT_PATH)/sdkconfig \
  18. COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" \
  19. COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
  20. $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
  21. ifeq ("$(wildcard $(PROJECT_PATH)/sdkconfig)","")
  22. #No sdkconfig found. Need to run menuconfig to make this if we need it.
  23. $(PROJECT_PATH)/sdkconfig: menuconfig
  24. endif
  25. defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
  26. $(summary) DEFCONFIG
  27. $(Q) mkdir -p $(PROJECT_PATH)/build/include/config
  28. $(Q) KCONFIG_AUTOHEADER=$(PROJECT_PATH)/build/include/sdkconfig.h \
  29. KCONFIG_CONFIG=$(PROJECT_PATH)/sdkconfig \
  30. COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" \
  31. COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
  32. $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig
  33. # Work out of whether we have to build the Kconfig makefile
  34. # (auto.conf), or if we're in a situation where we don't need it
  35. NON_CONFIG_TARGETS := clean %-clean get_variable help menuconfig defconfig
  36. AUTO_CONF_REGEN_TARGET := $(PROJECT_PATH)/build/include/config/auto.conf
  37. # disable AUTO_CONF_REGEN_TARGET if all targets are non-config targets
  38. # (and not building default target)
  39. ifneq ("$(MAKECMDGOALS)","")
  40. ifeq ($(filter $(NON_CONFIG_TARGETS), $(MAKECMDGOALS)),$(MAKECMDGOALS))
  41. AUTO_CONF_REGEN_TARGET :=
  42. # dummy target
  43. $(PROJECT_PATH)/build/include/config/auto.conf:
  44. endif
  45. endif
  46. $(AUTO_CONF_REGEN_TARGET) $(PROJECT_PATH)/build/include/sdkconfig.h: $(PROJECT_PATH)/sdkconfig $(KCONFIG_TOOL_DIR)/conf $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD)
  47. $(summary) GENCONFIG
  48. $(Q) mkdir -p $(PROJECT_PATH)/build/include/config
  49. $(Q) cd build; KCONFIG_AUTOHEADER="$(PROJECT_PATH)/build/include/sdkconfig.h" \
  50. KCONFIG_CONFIG=$(PROJECT_PATH)/sdkconfig \
  51. COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" \
  52. COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
  53. $(KCONFIG_TOOL_DIR)/conf --silentoldconfig $(IDF_PATH)/Kconfig
  54. $(Q) touch $(AUTO_CONF_REGEN_TARGET) $(PROJECT_PATH)/build/include/sdkconfig.h
  55. # touch to ensure both output files are newer - as 'conf' can also update sdkconfig (a dependency). Without this,
  56. # sometimes you can get an infinite make loop on Windows where sdkconfig always gets regenerated newer
  57. # than the target(!)
  58. clean: config-clean
  59. .PHONY: config-clean
  60. config-clean:
  61. $(summary RM CONFIG)
  62. $(MAKE) -C $(KCONFIG_TOOL_DIR) clean
  63. $(Q) rm -rf $(PROJECT_PATH)/build/include/config $(PROJECT_PATH)/build/include/sdkconfig.h