project_config.mk 2.9 KB

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