diff --git a/make/defs-cpp.mk b/make/defs-cpp.mk index f903b210..9f98e46d 100644 --- a/make/defs-cpp.mk +++ b/make/defs-cpp.mk @@ -76,6 +76,66 @@ ifeq ($(USE_VERSION_MACROS),true) BUILD_CPPFLAGS += -DVERSION=$(HEX_VERSION) -DVERSION_STR=\"$(VERSION)\" endif +ifneq ($(findstring cortex-m3,$(TAGGED_TMPL_TAGS)),) + + # -- set jw-build mcu choices + MCU_CPU ?= cortex-m3 + + # -- set flags + + # don't wrap error message lines + #PROJECT_LDFLAGS += -fmessage-length=0 + + # don't know what kind of optimization that is + #PROJECT_LDFLAGS += -Og + + # stick with what janware code tends to expect + PROJECT_LDFLAGS += -fsigned-char + + # I have no clue which part would evaluate these names + PROJECT_LDFLAGS += -ffunction-sections + PROJECT_LDFLAGS += -fdata-sections + PROJECT_LDFLAGS += -ffreestanding + PROJECT_LDFLAGS += -fno-move-loop-invariants + + # skip any automatic initialization + PROJECT_LDFLAGS += -nostartfiles + + # garbage collect unused input sections + PROJECT_LDFLAGS += -Xlinker --gc-sections + + # create map file + PROJECT_LDFLAGS += -Wl,-Map,"$(EXE_MAP)" + + # use newlib-nano, provides symbols _write _close _fstat _isatty _lseek (at least) + # (TODO: No -Wl necessary?) + PROJECT_LDFLAGS += --specs=nano.specs + PROJECT_LDFLAGS += --specs=nosys.specs + +endif + +ifneq ($(findstring gnu-mcu-eclipse,$(TAGGED_TMPL_TAGS)),) + LD_DEFINE_SYMBOLS += _sbrk +endif + +# ----- build options based on product choices + +ifneq ($(findstring $(MCU_CPU),cortex-m3),) + + PROJECT_CPPFLAGS += -mcpu=cortex-m3 -mthumb + PROJECT_LDFLAGS += -mcpu=cortex-m3 -mthumb + +endif + +# ----- tagged templates +#MCU_LD_DIR = $(wildcard $(firstword $(call $(TAGGED_TMPL_DIRS),ld))) +#MCU_LD_DIR = $(firstword $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(wildcard $(repo)/$(tag)/ld)))) +#MCU_LD_DIR = $(firstword $(wildcard $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(repo)/$(tag)/ld)))) +MCU_LD_CHECK_DIRS = $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(repo)/$(tag)/ld)) +MCU_LD_DIRS = $(wildcard $(MCU_LD_CHECK_DIRS)) +MCU_LD_DIR = $(firstword $(MCU_LD_DIRS)) + +PROJECT_LDFLAGS += -L$(MCU_LD_DIR) $(addprefix -T ,$(sort $(notdir $(wildcard $(MCU_LD_DIR)/*.ld)))) # ----- tool chain ifneq ($(TARGET_TRIPLET),$(HOST_TRIPLET)) # we're cross-compiling @@ -123,7 +183,6 @@ endif ifeq ($(TARGET_TRIPLET),arm-none-eabi) USE_DISABLE_COMPILER_OPTIMISATION_OPTS = false USE_EXCEPTIONS_IN_C = false - ARM_NONE_EABI_ALLFLAGS += -mcpu=cortex-m3 -mthumb ARM_NONE_EABI_ALLFLAGS += -fno-exceptions ARM_NONE_EABI_ALLFLAGS += -Os BUILD_LDFLAGS += $(ARM_NONE_EABI_ALLFLAGS) diff --git a/make/mcu-defs.mk b/make/mcu-defs.mk index 880b5109..cac26308 100644 --- a/make/mcu-defs.mk +++ b/make/mcu-defs.mk @@ -6,8 +6,6 @@ # endif #endef -include $(MODDIR)/make/mcu-tags.mk - ifneq ($(MAKECMDGOALS),clean) ifeq ($(MCU_BOARD_MODEL),) $(error MCU_BOARD_MODEL not specified) diff --git a/make/mcu-tags.mk b/make/mcu-tags.mk deleted file mode 100644 index c228387e..00000000 --- a/make/mcu-tags.mk +++ /dev/null @@ -1,62 +0,0 @@ -# ----- product specific part - -ifneq ($(findstring cortex-m3,$(TAGGED_TMPL_TAGS)),) - - # -- set jw-build mcu choices - MCU_CPU ?= cortex-m3 - - # -- set flags - - # don't wrap error message lines - #PROJECT_LDFLAGS += -fmessage-length=0 - - # don't know what kind of optimization that is - #PROJECT_LDFLAGS += -Og - - # stick with what janware code tends to expect - PROJECT_LDFLAGS += -fsigned-char - - # I have no clue which part would evaluate these names - PROJECT_LDFLAGS += -ffunction-sections - PROJECT_LDFLAGS += -fdata-sections - PROJECT_LDFLAGS += -ffreestanding - PROJECT_LDFLAGS += -fno-move-loop-invariants - - # skip any automatic initialization - PROJECT_LDFLAGS += -nostartfiles - - # garbage collect unused input sections - PROJECT_LDFLAGS += -Xlinker --gc-sections - - # create map file - PROJECT_LDFLAGS += -Wl,-Map,"$(EXE_MAP)" - - # use newlib-nano, provides symbols _write _close _fstat _isatty _lseek (at least) - # (TODO: No -Wl necessary?) - PROJECT_LDFLAGS += --specs=nano.specs - PROJECT_LDFLAGS += --specs=nosys.specs - -endif - -ifneq ($(findstring gnu-mcu-eclipse,$(TAGGED_TMPL_TAGS)),) - LD_DEFINE_SYMBOLS += _sbrk -endif - -# ----- build options based on product choices - -ifneq ($(findstring $(MCU_CPU),cortex-m3),) - - PROJECT_LDFLAGS += -mcpu=cortex-m3 - PROJECT_LDFLAGS += -mthumb - -endif - -# ----- tagged templates -#MCU_LD_DIR = $(wildcard $(firstword $(call $(TAGGED_TMPL_DIRS),ld))) -#MCU_LD_DIR = $(firstword $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(wildcard $(repo)/$(tag)/ld)))) -#MCU_LD_DIR = $(firstword $(wildcard $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(repo)/$(tag)/ld)))) -MCU_LD_CHECK_DIRS = $(foreach tag,$(TAGGED_TMPL_TAGS),$(foreach repo,$(TOPDIR)/tmpl/tagged $(MODDIR)/tmpl/tagged,$(repo)/$(tag)/ld)) -MCU_LD_DIRS = $(wildcard $(MCU_LD_CHECK_DIRS)) -MCU_LD_DIR = $(firstword $(MCU_LD_DIRS)) - -PROJECT_LDFLAGS += -L$(MCU_LD_DIR) $(addprefix -T ,$(sort $(notdir $(wildcard $(MCU_LD_DIR)/*.ld))))