2018-04-18 02:57:45 +00:00
|
|
|
# Makefile to support the linker script generation mechanism
|
|
|
|
|
|
|
|
LDGEN_SECTIONS_INFO_FILES = $(foreach lib, $(COMPONENT_LIBRARIES), $(BUILD_DIR_BASE)/$(lib)/lib$(lib).a.sections_info)
|
|
|
|
LDGEN_FRAGMENT_FILES = $(COMPONENT_LDFRAGMENTS)
|
|
|
|
|
2018-12-17 04:58:29 +00:00
|
|
|
ON_WINDOWS:=n
|
|
|
|
|
|
|
|
ifdef OS
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
ON_WINDOWS:=y
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-04-18 02:57:45 +00:00
|
|
|
# Target to generate linker script generator from fragments presented by each of
|
|
|
|
# the components
|
2018-12-17 04:58:29 +00:00
|
|
|
ifeq ($(ON_WINDOWS),y)
|
2018-04-18 02:57:45 +00:00
|
|
|
define ldgen_process_template
|
2018-12-05 07:29:44 +00:00
|
|
|
$(BUILD_DIR_BASE)/ldgen.section_infos: $(LDGEN_SECTIONS_INFO_FILES) $(IDF_PATH)/make/ldgen.mk
|
2018-12-13 10:19:59 +00:00
|
|
|
printf "$(foreach info,$(LDGEN_SECTIONS_INFO_FILES),$(subst \,/,$(shell cygpath -w $(info)))\n)" > $(BUILD_DIR_BASE)/ldgen.section_infos
|
2018-12-01 14:22:45 +00:00
|
|
|
|
2019-02-21 06:11:09 +00:00
|
|
|
$(2): $(1) $(LDGEN_FRAGMENT_FILES) $(SDKCONFIG) $(BUILD_DIR_BASE)/ldgen.section_infos
|
2018-04-18 02:57:45 +00:00
|
|
|
@echo 'Generating $(notdir $(2))'
|
2018-12-13 10:19:59 +00:00
|
|
|
$(PYTHON) $(IDF_PATH)/tools/ldgen/ldgen.py \
|
|
|
|
--input $(1) \
|
|
|
|
--config $(SDKCONFIG) \
|
|
|
|
--fragments $(LDGEN_FRAGMENT_FILES) \
|
|
|
|
--output $(2) \
|
|
|
|
--sections $(BUILD_DIR_BASE)/ldgen.section_infos \
|
|
|
|
--kconfig $(IDF_PATH)/Kconfig \
|
|
|
|
--env "COMPONENT_KCONFIGS=$(foreach k, $(COMPONENT_KCONFIGS), $(shell cygpath -w $(k)))" \
|
|
|
|
--env "COMPONENT_KCONFIGS_PROJBUILD=$(foreach k, $(COMPONENT_KCONFIGS_PROJBUILD), $(shell cygpath -w $(k)))" \
|
|
|
|
--env "IDF_CMAKE=n"
|
2018-12-17 04:58:29 +00:00
|
|
|
endef
|
|
|
|
else # ON_WINDOWS
|
|
|
|
define ldgen_process_template
|
|
|
|
$(BUILD_DIR_BASE)/ldgen.section_infos: $(LDGEN_SECTIONS_INFO_FILES) $(IDF_PATH)/make/ldgen.mk
|
|
|
|
printf "$(foreach info,$(LDGEN_SECTIONS_INFO_FILES),$(info)\n)" > $(BUILD_DIR_BASE)/ldgen.section_infos
|
|
|
|
|
2019-02-21 06:11:09 +00:00
|
|
|
$(2): $(1) $(LDGEN_FRAGMENT_FILES) $(SDKCONFIG) $(BUILD_DIR_BASE)/ldgen.section_infos
|
2018-12-17 04:58:29 +00:00
|
|
|
@echo 'Generating $(notdir $(2))'
|
2018-04-18 02:57:45 +00:00
|
|
|
$(PYTHON) $(IDF_PATH)/tools/ldgen/ldgen.py \
|
|
|
|
--input $(1) \
|
|
|
|
--config $(SDKCONFIG) \
|
|
|
|
--fragments $(LDGEN_FRAGMENT_FILES) \
|
|
|
|
--output $(2) \
|
2018-12-01 14:22:45 +00:00
|
|
|
--sections $(BUILD_DIR_BASE)/ldgen.section_infos \
|
2018-04-18 02:57:45 +00:00
|
|
|
--kconfig $(IDF_PATH)/Kconfig \
|
|
|
|
--env "COMPONENT_KCONFIGS=$(COMPONENT_KCONFIGS)" \
|
|
|
|
--env "COMPONENT_KCONFIGS_PROJBUILD=$(COMPONENT_KCONFIGS_PROJBUILD)" \
|
2018-11-29 05:21:31 +00:00
|
|
|
--env "IDF_CMAKE=n"
|
2018-04-18 02:57:45 +00:00
|
|
|
endef
|
2018-12-17 04:58:29 +00:00
|
|
|
endif # ON_WINDOWS
|
2018-04-18 02:57:45 +00:00
|
|
|
|
|
|
|
define ldgen_create_commands
|
|
|
|
$(foreach lib, $(COMPONENT_LIBRARIES), \
|
|
|
|
$(eval $(call ldgen_generate_target_sections_info, $(BUILD_DIR_BASE)/$(lib)/lib$(lib).a)))
|
|
|
|
|
|
|
|
ldgen-clean:
|
|
|
|
rm -f $(LDGEN_SECTIONS_INFO_FILES)
|
2018-12-01 14:22:45 +00:00
|
|
|
rm -f $(BUILD_DIR_BASE)/ldgen.section_infos
|
2018-04-18 02:57:45 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Target to generate sections info file from objdump of component archive
|
|
|
|
define ldgen_generate_target_sections_info
|
|
|
|
$(1).sections_info: $(1)
|
2018-12-01 14:22:45 +00:00
|
|
|
@echo 'Generating $(notdir $(1).sections_info)'
|
2018-04-18 02:57:45 +00:00
|
|
|
$(OBJDUMP) -h $(1) > $(1).sections_info
|
|
|
|
endef
|