From 1d7773938c946f7dc621f57eda5efdd581547263 Mon Sep 17 00:00:00 2001 From: George Harker Date: Fri, 4 Nov 2016 11:21:02 -0700 Subject: [PATCH] make it work with modern arduino and teensyduino scripts --- Arduino.mk | 4 ++-- Teensy.mk | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Arduino.mk b/Arduino.mk index 1c0debb..d974eb2 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -1293,7 +1293,7 @@ endif $(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS) @$(MKDIR) $(dir $@) -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom='alloc,load' \ - --change-section-lma .eeprom=0 -O ihex $< $@ + --no-change-warnings --change-section-lma .eeprom=0 -O ihex $< $@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(COMMON_DEPS) @$(MKDIR) $(dir $@) @@ -1439,7 +1439,7 @@ pre-build: $(call runscript_if_exists,$(PRE_BUILD_HOOK)) $(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) - $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm $(LINKER_SCRIPTS) + $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS) -lc -lm $(LINKER_SCRIPTS) $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS) $(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS) diff --git a/Teensy.mk b/Teensy.mk index 3676c78..c33c7be 100644 --- a/Teensy.mk +++ b/Teensy.mk @@ -34,8 +34,8 @@ endif include $(ARDMK_DIR)/Common.mk ARDMK_VENDOR = teensy -ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/cores/teensy3 -BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/boards.txt +ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3 +BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt ifndef F_CPU F_CPU=96000000 @@ -152,11 +152,26 @@ ifeq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.elide_constructors)", "true") CXXFLAGS += -felide-constructors endif -LDFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.linkoption) $(call PARSE_TEENSY,$(BOARD_TAG),build.additionalobject) +CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common) +CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) +CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs) +CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpp) -ifneq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.linkscript)",) - LDFLAGS += -T$(ARDUINO_CORE_PATH)/$(call PARSE_TEENSY,$(BOARD_TAG),build.linkscript) -endif +CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common) +CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) +CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs) + +ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common) +ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) +ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs) +ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.S) + +LDFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) + +AMCU := $(call PARSE_TEENSY,$(BOARD_TAG),build.mcu) +LDFLAGS += -Wl,--gc-sections,--relax +LINKER_SCRIPTS = -T${ARDUINO_CORE_PATH}/${AMCU}.ld +OTHER_LIBS = $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.libs) ######################################################################## # some fairly odd settings so that 'make upload' works @@ -171,3 +186,4 @@ RESET_CMD = nohup $(ARDUINO_DIR)/hardware/tools/teensy_post_compile -board=$(BOA # automatially include Arduino.mk for the user include $(ARDMK_DIR)/Arduino.mk +