project_config.mk 3.1 KB

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