Merge remote-tracking branch 'org/master' into move_core_link_last

This commit is contained in:
Pieter du Preez 2018-10-02 22:53:12 +02:00
commit d4d3d3d6c3
8 changed files with 233 additions and 368 deletions

View file

@ -388,28 +388,129 @@ endif
######################################################################## ########################################################################
# Arduino and system paths # Arduino and system paths
# Third party hardware and core like ATtiny or ATmega 16
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE,[USER])
ifndef ALTERNATE_CORE_PATH
ALTERNATE_CORE_PATH = $(ARDUINO_SKETCHBOOK)/hardware/$(ALTERNATE_CORE)/$(ARCHITECTURE)
endif
endif
ifdef ALTERNATE_CORE_PATH
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE_PATH,[COMPUTED], (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE))
else
$(call show_config_variable,ALTERNATE_CORE_PATH,[USER])
endif
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
else
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,ARDUINO_VAR_PATH,[USER])
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,BOARDS_TXT,[USER])
endif
endif
ifeq (,$(wildcard $(BOARDS_TXT)))
$(error Currently BOARDS_TXT='$(BOARDS_TXT)', which is not an existing file or an invalid filename.)
endif
ifndef TOOL_PREFIX
TOOL_PREFIX = avr
endif
ifndef CC_NAME ifndef CC_NAME
CC_NAME = avr-gcc CC_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gcc)
ifndef CC_NAME
CC_NAME := $(TOOL_PREFIX)-gcc
else
$(call show_config_variable,CC_NAME,[COMPUTED])
endif
endif endif
ifndef CXX_NAME ifndef CXX_NAME
CXX_NAME = avr-g++ CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.g++)
ifndef CXX_NAME
CXX_NAME := $(TOOL_PREFIX)-g++
else
$(call show_config_variable,CXX_NAME,[COMPUTED])
endif
endif
ifndef AS_NAME
AS_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.as)
ifndef AS_NAME
AS_NAME := $(TOOL_PREFIX)-as
else
$(call show_config_variable,AS_NAME,[COMPUTED])
endif
endif endif
ifndef OBJCOPY_NAME ifndef OBJCOPY_NAME
OBJCOPY_NAME = avr-objcopy OBJCOPY_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objcopy)
ifndef OBJCOPY_NAME
OBJCOPY_NAME := $(TOOL_PREFIX)-objcopy
else
$(call show_config_variable,OBJCOPY_NAME,[COMPUTED])
endif
endif endif
ifndef OBJDUMP_NAME ifndef OBJDUMP_NAME
OBJDUMP_NAME = avr-objdump OBJDUMP_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objdump)
ifndef OBJDUMP_NAME
OBJDUMP_NAME := $(TOOL_PREFIX)-objdump
else
$(call show_config_variable,OBJDUMP_NAME,[COMPUTED])
endif
endif
ifndef AR_NAME
AR_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.ar)
ifndef AR_NAME
AR_NAME := $(TOOL_PREFIX)-ar
else
$(call show_config_variable,AR_NAME,[COMPUTED])
endif
endif endif
ifndef SIZE_NAME ifndef SIZE_NAME
SIZE_NAME = avr-size SIZE_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.size)
ifndef SIZE_NAME
SIZE_NAME := $(TOOL_PREFIX)-size
else
$(call show_config_variable,SIZE_NAME,[COMPUTED])
endif
endif endif
ifndef NM_NAME ifndef NM_NAME
NM_NAME = avr-nm NM_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.nm)
ifndef NM_NAME
NM_NAME := $(TOOL_PREFIX)-nm
else
$(call show_config_variable,NM_NAME,[COMPUTED])
endif
endif endif
ifndef AVR_TOOLS_DIR ifndef AVR_TOOLS_DIR
@ -457,8 +558,8 @@ ifndef AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
$(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
else else
# One last attempt using avr-gcc in case using arm # One last attempt using $(TOOL_PREFIX)-gcc in case using arm
SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $(avr-gcc)))/..)) SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $($(TOOL_PREFIX)-gcc)))/..))
ifdef SYSTEMPATH_AVR_TOOLS_DIR ifdef SYSTEMPATH_AVR_TOOLS_DIR
AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
$(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
@ -483,8 +584,8 @@ else
endif #ndef AVR_TOOLS_DIR endif #ndef AVR_TOOLS_DIR
ifndef AVR_TOOLS_PATH ifndef TOOLS_PATH
AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin TOOLS_PATH = $(AVR_TOOLS_DIR)/bin
endif endif
ifndef ARDUINO_LIB_PATH ifndef ARDUINO_LIB_PATH
@ -505,51 +606,6 @@ else
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER]) $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER])
endif endif
# Third party hardware and core like ATtiny or ATmega 16
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE,[USER])
ifndef ALTERNATE_CORE_PATH
ALTERNATE_CORE_PATH = $(ARDUINO_SKETCHBOOK)/hardware/$(ALTERNATE_CORE)/$(ARCHITECTURE)
endif
endif
ifdef ALTERNATE_CORE_PATH
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE_PATH,[COMPUTED], (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE))
else
$(call show_config_variable,ALTERNATE_CORE_PATH,[USER])
endif
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ALTERNATE_CORE_PATH))
endif
else
ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/variants
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,ARDUINO_VAR_PATH,[USER])
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,BOARDS_TXT,[USER])
endif
endif
######################################################################## ########################################################################
# Miscellaneous # Miscellaneous
@ -585,11 +641,6 @@ else
$(call show_config_variable,BOARD_TAG,[USER]) $(call show_config_variable,BOARD_TAG,[USER])
endif endif
ifndef PARSE_BOARD
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_BOARD = $(shell grep -Ev '^\#' $(BOARDS_TXT) | grep -E "^[ \t]*$(1).$(2)=" | cut -d = -f 2 | cut -d : -f 2)
endif
# If NO_CORE is set, then we don't have to parse boards.txt file # If NO_CORE is set, then we don't have to parse boards.txt file
# But the user might have to define MCU, F_CPU etc # But the user might have to define MCU, F_CPU etc
ifeq ($(strip $(NO_CORE)),) ifeq ($(strip $(NO_CORE)),)
@ -826,7 +877,7 @@ endif
ifeq ($(strip $(NO_CORE)),) ifeq ($(strip $(NO_CORE)),)
ifdef ARDUINO_CORE_PATH ifdef ARDUINO_CORE_PATH
CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c) CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c)
CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/avr-libc/*.c) CORE_C_SRCS += $(wildcard $(ARDUINO_CORE_PATH)/$(TOOL_PREFIX)-libc/*.c)
CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
CORE_AS_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.S) CORE_AS_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.S)
@ -936,18 +987,22 @@ TARGET_EEP = $(OBJDIR)/$(TARGET).eep
TARGET_BIN = $(OBJDIR)/$(TARGET).bin TARGET_BIN = $(OBJDIR)/$(TARGET).bin
CORE_LIB = $(OBJDIR)/libcore.a CORE_LIB = $(OBJDIR)/libcore.a
# Names of executables - chipKIT needs to override all to set paths to PIC32 # Names of executables
# tools, and we can't use "?=" assignment because these are already implicitly # In the rare case of wanting to override a path and/or excecutable
# name, the OVERRIDE_EXECUTABLES variable must be defned and _all_
# the excecutables (CC, CXX, AS, OBJCOPY, OBJDUMP AR, SIZE and NM)
# _must_ be defined in the calling makefile.
# We can't use "?=" assignment because these are already implicitly
# defined by Make (e.g. $(CC) == cc). # defined by Make (e.g. $(CC) == cc).
ifndef OVERRIDE_EXECUTABLES ifndef OVERRIDE_EXECUTABLES
CC = $(AVR_TOOLS_PATH)/$(CC_NAME) CC = $(TOOLS_PATH)/$(CC_NAME)
CXX = $(AVR_TOOLS_PATH)/$(CXX_NAME) CXX = $(TOOLS_PATH)/$(CXX_NAME)
AS = $(AVR_TOOLS_PATH)/$(AS_NAME) AS = $(TOOLS_PATH)/$(AS_NAME)
OBJCOPY = $(AVR_TOOLS_PATH)/$(OBJCOPY_NAME) OBJCOPY = $(TOOLS_PATH)/$(OBJCOPY_NAME)
OBJDUMP = $(AVR_TOOLS_PATH)/$(OBJDUMP_NAME) OBJDUMP = $(TOOLS_PATH)/$(OBJDUMP_NAME)
AR = $(AVR_TOOLS_PATH)/$(AR_NAME) AR = $(TOOLS_PATH)/$(AR_NAME)
SIZE = $(AVR_TOOLS_PATH)/$(SIZE_NAME) SIZE = $(TOOLS_PATH)/$(SIZE_NAME)
NM = $(AVR_TOOLS_PATH)/$(NM_NAME) NM = $(TOOLS_PATH)/$(NM_NAME)
endif endif
REMOVE = rm -rf REMOVE = rm -rf
@ -1083,15 +1138,15 @@ ifneq ($(CATERINA),)
CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID)
endif endif
# avr-gcc version that we can do maths on # $(TOOL_PREFIX)-gcc version that we can do maths on
CC_VERNUM = $(shell $(CC) -dumpversion | sed 's/\.//g') CC_VERNUM = $(shell $(CC) -dumpversion | sed 's/\.//g')
# moved from above so we can find version-dependant ar # moved from above so we can find version-dependant ar
ifndef AR_NAME ifeq ($(TOOL_PREFIX), avr)
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
AR_NAME = avr-gcc-ar AR_NAME := $(TOOL_PREFIX)-gcc-ar
else else
AR_NAME = avr-ar AR_NAME := $(TOOL_PREFIX)-ar
endif endif
endif endif
@ -1409,7 +1464,7 @@ CTAGS_CMD = $(CTAGS_EXEC) $(CTAGS_OPTS) -auf
# If avrdude is installed separately, it can find its own config file # If avrdude is installed separately, it can find its own config file
ifndef AVRDUDE ifndef AVRDUDE
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude AVRDUDE = $(TOOLS_PATH)/avrdude
endif endif
# Default avrdude options # Default avrdude options
@ -1691,7 +1746,7 @@ else
endif endif
debug_init: debug_init:
$(OPENOCD) $(OPENOCD) $(OPENOCD_OPTS)
debug: debug:
$(GDB) $(GDB_OPTS) $(GDB) $(GDB_OPTS)
@ -1752,7 +1807,7 @@ help:
make debug_init - start openocd gdb server\n\ make debug_init - start openocd gdb server\n\
make debug - connect to gdb target and begin debugging\n\ make debug - connect to gdb target and begin debugging\n\
make size - show the size of the compiled output (relative to\n\ make size - show the size of the compiled output (relative to\n\
resources, if you have a patched avr-size).\n\ resources, if you have a patched $(TOOL_PREFIX)-size).\n\
make verify_size - verify that the size of the final file is less than\n\ make verify_size - verify that the size of the final file is less than\n\
the capacity of the micro controller.\n\ the capacity of the micro controller.\n\
make symbol_sizes - generate a .sym file containing symbols and their\n\ make symbol_sizes - generate a .sym file containing symbols and their\n\

View file

@ -5,6 +5,17 @@ COMMON_INCLUDED = TRUE
# (directory and optional filename) exists # (directory and optional filename) exists
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
ifndef PARSE_BOARD
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \
then \
grep -Ev '^\#' $(BOARDS_TXT) | \
grep -E "^[ \t]*$(1).$(2)=" | \
cut -d = -f 2 | \
cut -d : -f 2; \
fi)
endif
# Run a shell script if it exists. Stops make on error. # Run a shell script if it exists. Stops make on error.
runscript_if_exists = \ runscript_if_exists = \
$(if $(wildcard $(1)), \ $(if $(wildcard $(1)), \

View file

@ -22,6 +22,8 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
- New: Compatibility with deprecated pgmspace.h API can now be disabled since it sometimes causes bogus compiler warnings (issue #546) - New: Compatibility with deprecated pgmspace.h API can now be disabled since it sometimes causes bogus compiler warnings (issue #546)
- New: Support Arduino ARM SAMD devices (Zero, M0 Pro, Feather M0). (https://github.com/tuna-f1sh) - New: Support Arduino ARM SAMD devices (Zero, M0 Pro, Feather M0). (https://github.com/tuna-f1sh)
- New: Support Arduino ARM SAM devices (Due). (https://github.com/tuna-f1sh) - New: Support Arduino ARM SAM devices (Due). (https://github.com/tuna-f1sh)
- New: Moved the PARSE_BOARD macro to Common.mk and use only this to parse the boards.txt file. (https://github.com/wingunder)
- New: Added the TOOL_PREFIX variable for setting up the executable tools centrally and generically. (https://github.com/wingunder)
### 1.6.0 (2017-07-11) ### 1.6.0 (2017-07-11)
- Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278) - Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278)

View file

@ -44,17 +44,12 @@ ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/boards.txt BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/boards.txt
endif endif
ifndef PARSE_OPENCM
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_OPENCM = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
endif
ifndef F_CPU ifndef F_CPU
F_CPU := $(call PARSE_OPENCM,$(BOARD_TAG),build.f_cpu) F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
endif endif
# if boards.txt gets modified, look there, else hard code it # if boards.txt gets modified, look there, else hard code it
ARCHITECTURE = $(call PARSE_OPENCM,$(BOARD_TAG),build.architecture) ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
ifeq ($(strip $(ARCHITECTURE)),) ifeq ($(strip $(ARCHITECTURE)),)
ARCHITECTURE = arm ARCHITECTURE = arm
endif endif
@ -74,81 +69,11 @@ endif
######################################################################## ########################################################################
# command names # command names
ifndef CC_NAME TOOL_PREFIX = arm-none-eabi
CC_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.gcc)
ifndef CC_NAME
CC_NAME := arm-none-eabi-gcc
else
$(call show_config_variable,CC_NAME,[COMPUTED])
endif
endif
ifndef CXX_NAME
CXX_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.g++)
ifndef CXX_NAME
CXX_NAME := arm-none-eabi-g++
else
$(call show_config_variable,CXX_NAME,[COMPUTED])
endif
endif
ifndef AS_NAME
AS_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.as)
ifndef AS_NAME
AS_NAME := arm-none-eabi-as
else
$(call show_config_variable,AS_NAME,[COMPUTED])
endif
endif
ifndef OBJDUMP_NAME
OBJDUMP_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.objdump)
ifndef OBJDUMP_NAME
OBJDUMP_NAME := arm-none-eabi-objdump
else
$(call show_config_variable,OBJDUMP_NAME,[COMPUTED])
endif
endif
ifndef AR_NAME
AR_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.ar)
ifndef AR_NAME
AR_NAME := arm-none-eabi-ar
else
$(call show_config_variable,AR_NAME,[COMPUTED])
endif
endif
ifndef SIZE_NAME
SIZE_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.size)
ifndef SIZE_NAME
SIZE_NAME := arm-none-eabi-size
else
$(call show_config_variable,SIZE_NAME,[COMPUTED])
endif
endif
ifndef NM_NAME
NM_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.nm)
ifndef NM_NAME
NM_NAME := arm-none-eabi-nm
else
$(call show_config_variable,NM_NAME,[COMPUTED])
endif
endif
ifndef OBJCOPY_NAME
OBJCOPY_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.objcopy)
ifndef OBJCOPY_NAME
OBJCOPY_NAME := arm-none-eabi-objcopy
else
$(call show_config_variable,OBJCOPY_NAME,[COMPUTED])
endif
endif
# processor stuff # processor stuff
ifndef MCU ifndef MCU
MCU := $(call PARSE_OPENCM,$(BOARD_TAG),build.family) MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.family)
endif endif
ifndef MCU_FLAG_NAME ifndef MCU_FLAG_NAME
@ -161,20 +86,20 @@ ifndef USB_TYPE
USB_TYPE = USB_SERIAL USB_TYPE = USB_SERIAL
endif endif
CPPFLAGS += -DBOARD_$(call PARSE_OPENCM,$(BOARD_TAG),build.board) CPPFLAGS += -DBOARD_$(call PARSE_BOARD,$(BOARD_TAG),build.board)
CPPFLAGS += -DMCU_$(call PARSE_OPENCM,$(BOARD_TAG),build.mcu) CPPFLAGS += -DMCU_$(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
CPPFLAGS += -DSTM32_MEDIUM_DENSITY -DVECT_TAB_FLASH CPPFLAGS += -DSTM32_MEDIUM_DENSITY -DVECT_TAB_FLASH
CPPFLAGS += $(call PARSE_OPENCM,$(BOARD_TAG),build.option) CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
CXXFLAGS += -fno-rtti CXXFLAGS += -fno-rtti
CXXFLAGS += $(call PARSE_OPENCM,$(BOARD_TAG),build.cppoption) CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_OPENCM,$(BOARD_TAG),build.gnu0x)","true") ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
CXXFLAGS_STD += -std=gnu++0x CXXFLAGS_STD += -std=gnu++0x
endif endif
ifeq ("$(call PARSE_OPENCM,$(BOARD_TAG),build.elide_constructors)", "true") ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
CXXFLAGS += -felide-constructors CXXFLAGS += -felide-constructors
endif endif
@ -209,7 +134,7 @@ ifeq ($(CURRENT_OS), WINDOWS)
else else
override AVRDUDE_ARD_OPTS = $(call get_monitor_port) override AVRDUDE_ARD_OPTS = $(call get_monitor_port)
endif endif
override AVRDUDE_UPLOAD_HEX = $(TARGET_HEX) override AVRDUDE_UPLOAD_HEX = $(TARGET_HEX)
######################################################################## ########################################################################

87
Sam.mk
View file

@ -167,7 +167,7 @@ endif
# Use arm-toolchain from Arduino install if exists and user has not defined global version # Use arm-toolchain from Arduino install if exists and user has not defined global version
ifndef ARM_TOOLS_DIR ifndef ARM_TOOLS_DIR
ARM_TOOLS_DIR = $(call dir_if_exists,$(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/arm-none-eabi-gcc/*)) ARM_TOOLS_DIR = $(call dir_if_exists,$(wildcard $(ARDUINO_PACKAGE_DIR)/$(ARDMK_VENDOR)/tools/$(TOOL_PREFIX)-gcc/*))
$(call show_config_variable,ARM_TOOLS_DIR,[COMPUTED],(from ARDUINO_PACKAGE_DIR)) $(call show_config_variable,ARM_TOOLS_DIR,[COMPUTED],(from ARDUINO_PACKAGE_DIR))
else else
$(call show_config_variable,ARM_TOOLS_DIR,[USER]) $(call show_config_variable,ARM_TOOLS_DIR,[USER])
@ -182,82 +182,12 @@ endif
######################################################################## ########################################################################
# command names # command names
ifndef CC_NAME TOOL_PREFIX = arm-none-eabi
CC_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gcc)
ifndef CC_NAME
CC_NAME := arm-none-eabi-gcc
else
$(call show_config_variable,CC_NAME,[COMPUTED])
endif
endif
ifndef CXX_NAME
CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.g\+\+)
ifndef CXX_NAME
CXX_NAME := arm-none-eabi-g++
else
$(call show_config_variable,CXX_NAME,[COMPUTED])
endif
endif
ifndef AS_NAME
AS_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.as)
ifndef AS_NAME
AS_NAME := arm-none-eabi-gcc-as
else
$(call show_config_variable,AS_NAME,[COMPUTED])
endif
endif
ifndef OBJCOPY_NAME
OBJCOPY_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objcopy)
ifndef OBJCOPY_NAME
OBJCOPY_NAME := arm-none-eabi-objcopy
else
$(call show_config_variable,OBJCOPY_NAME,[COMPUTED])
endif
endif
ifndef OBJDUMP_NAME
OBJDUMP_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objdump)
ifndef OBJDUMP_NAME
OBJDUMP_NAME := arm-none-eabi-objdump
else
$(call show_config_variable,OBJDUMP_NAME,[COMPUTED])
endif
endif
ifndef AR_NAME
AR_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.ar)
ifndef AR_NAME
AR_NAME := arm-none-eabi-ar
else
$(call show_config_variable,AR_NAME,[COMPUTED])
endif
endif
ifndef SIZE_NAME
SIZE_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.size)
ifndef SIZE_NAME
SIZE_NAME := arm-none-eabi-size
else
$(call show_config_variable,SIZE_NAME,[COMPUTED])
endif
endif
ifndef NM_NAME
NM_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.nm)
ifndef NM_NAME
NM_NAME := arm-none-eabi-gcc-nm
else
$(call show_config_variable,NM_NAME,[COMPUTED])
endif
endif
ifndef GDB_NAME ifndef GDB_NAME
GDB_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gdb) GDB_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gdb)
ifndef GDB_NAME ifndef GDB_NAME
GDB_NAME := arm-none-eabi-gdb GDB_NAME := $(TOOL_PREFIX)-gdb
else else
$(call show_config_variable,GDB_NAME,[COMPUTED]) $(call show_config_variable,GDB_NAME,[COMPUTED])
endif endif
@ -385,17 +315,8 @@ endif
######################################################################## ########################################################################
# EXECUTABLES # EXECUTABLES
# Define them here to use ARM_TOOLS_PATH and allow auto finding of AVR_TOOLS_PATH # Define them here to use ARM_TOOLS_PATH and allow auto finding of AVR_TOOLS_PATH
OVERRIDE_EXECUTABLES = 1
ARM_TOOLS_PATH := $(ARM_TOOLS_DIR)/bin AVR_TOOLS_DIR := $(ARM_TOOLS_DIR)
CC = $(ARM_TOOLS_PATH)/$(CC_NAME)
CXX = $(ARM_TOOLS_PATH)/$(CXX_NAME)
AS = $(ARM_TOOLS_PATH)/$(AS_NAME)
OBJCOPY = $(ARM_TOOLS_PATH)/$(OBJCOPY_NAME)
OBJDUMP = $(ARM_TOOLS_PATH)/$(OBJDUMP_NAME)
AR = $(ARM_TOOLS_PATH)/$(AR_NAME)
SIZE = $(ARM_TOOLS_PATH)/$(SIZE_NAME)
NM = $(ARM_TOOLS_PATH)/$(NM_NAME)
#GDB = $(ARM_TOOLS_PATH)/$(GDB_NAME) #GDB = $(ARM_TOOLS_PATH)/$(GDB_NAME)
# Use system gdb for now as Arduino supplied has lib error? # Use system gdb for now as Arduino supplied has lib error?
GDB = $(GDB_NAME) GDB = $(GDB_NAME)

124
Teensy.mk
View file

@ -38,25 +38,19 @@ ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt
ifndef PARSE_TEENSY
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_TEENSY = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
endif
ifndef F_CPU ifndef F_CPU
ifndef BOARD_SUB ifndef BOARD_SUB
SPEEDS := $(call PARSE_TEENSY,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies. SPEEDS := $(call PARSE_BOARD,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies.
SPEEDS := $(shell printf "%d\n" $(SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works. SPEEDS := $(shell printf "%d\n" $(SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works.
F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed. F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed.
#$(info "speeds is " $(SPEEDS)) # Good for debugging #$(info "speeds is " $(SPEEDS)) # Good for debugging
else else
F_CPU := $(call PARSE_TEENSY,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu) F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
endif endif
endif endif
# if boards.txt gets modified, look there, else hard code it # if boards.txt gets modified, look there, else hard code it
ARCHITECTURE = $(call PARSE_TEENSY,$(BOARD_TAG),build.architecture) ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
ifeq ($(strip $(ARCHITECTURE)),) ifeq ($(strip $(ARCHITECTURE)),)
ARCHITECTURE = arm ARCHITECTURE = arm
endif endif
@ -72,81 +66,11 @@ endif
######################################################################## ########################################################################
# command names # command names
ifndef CC_NAME TOOL_PREFIX = arm-none-eabi
CC_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.gcc)
ifndef CC_NAME
CC_NAME := arm-none-eabi-gcc
else
$(call show_config_variable,CC_NAME,[COMPUTED])
endif
endif
ifndef CXX_NAME
CXX_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.g++)
ifndef CXX_NAME
CXX_NAME := arm-none-eabi-g++
else
$(call show_config_variable,CXX_NAME,[COMPUTED])
endif
endif
ifndef AS_NAME
AS_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.as)
ifndef AS_NAME
AS_NAME := arm-none-eabi-gcc-as
else
$(call show_config_variable,AS_NAME,[COMPUTED])
endif
endif
ifndef OBJCOPY_NAME
OBJCOPY_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.objcopy)
ifndef OBJCOPY_NAME
OBJCOPY_NAME := arm-none-eabi-objcopy
else
$(call show_config_variable,OBJCOPY_NAME,[COMPUTED])
endif
endif
ifndef OBJDUMP_NAME
OBJDUMP_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.objdump)
ifndef OBJDUMP_NAME
OBJDUMP_NAME := arm-none-eabi-objdump
else
$(call show_config_variable,OBJDUMP_NAME,[COMPUTED])
endif
endif
ifndef AR_NAME
AR_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.ar)
ifndef AR_NAME
AR_NAME := arm-none-eabi-ar
else
$(call show_config_variable,AR_NAME,[COMPUTED])
endif
endif
ifndef SIZE_NAME
SIZE_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.size)
ifndef SIZE_NAME
SIZE_NAME := arm-none-eabi-size
else
$(call show_config_variable,SIZE_NAME,[COMPUTED])
endif
endif
ifndef NM_NAME
NM_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.nm)
ifndef NM_NAME
NM_NAME := arm-none-eabi-gcc-nm
else
$(call show_config_variable,NM_NAME,[COMPUTED])
endif
endif
# processor stuff # processor stuff
ifndef MCU ifndef MCU
MCU := $(call PARSE_TEENSY,$(BOARD_TAG),build.mcu) MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
endif endif
ifndef MCU_FLAG_NAME ifndef MCU_FLAG_NAME
@ -161,39 +85,39 @@ endif
CPPFLAGS += -DLAYOUT_US_ENGLISH -D$(USB_TYPE) CPPFLAGS += -DLAYOUT_US_ENGLISH -D$(USB_TYPE)
CPPFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.option) CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.cppoption) CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.gnu0x)","true") ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
CXXFLAGS_STD += -std=gnu++0x CXXFLAGS_STD += -std=gnu++0x
endif endif
ifeq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.elide_constructors)", "true") ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
CXXFLAGS += -felide-constructors CXXFLAGS += -felide-constructors
endif endif
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common) CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs) CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpp) CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpp)
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common) CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs) CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common) ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs) ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.S) ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.S)
LDFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) LDFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
AMCU := $(call PARSE_TEENSY,$(BOARD_TAG),build.mcu) AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
LDFLAGS += -Wl,--gc-sections,--relax LDFLAGS += -Wl,--gc-sections,--relax
LINKER_SCRIPTS = -T${ARDUINO_CORE_PATH}/${AMCU}.ld LINKER_SCRIPTS = -T${ARDUINO_CORE_PATH}/${AMCU}.ld
OTHER_LIBS = $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.libs) OTHER_LIBS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.libs)
CPUFLAGS = $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu) CPUFLAGS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
# usually defined as per teensy31.build.mcu=mk20dx256 but that isn't valid switch # usually defined as per teensy31.build.mcu=mk20dx256 but that isn't valid switch
MCU := $(shell echo ${CPUFLAGS} | sed -n -e 's/.*-mcpu=\([a-zA-Z0-9_-]*\).*/\1/p') MCU := $(shell echo ${CPUFLAGS} | sed -n -e 's/.*-mcpu=\([a-zA-Z0-9_-]*\).*/\1/p')

View file

@ -810,6 +810,37 @@ CC_NAME = pic32-gcc
---- ----
## Compiler/Executable variables
### TOOL_PREFIX
**Description:**
The tool prefix, which gets prepended to the tools like $(TOOL_PREFIX)-gcc, $(TOOL_PREFIX)-g++, etc.
The following tools will be prefixed with '$(TOOL_PREFIX)-':
* gcc
* g++
* as
* objcopy
* objdump
* ar
* size
* nm
Defaults to `avr`
**Example:**
```Makefile
TOOL_PREFIX = arm-none-eabi
TOOL_PREFIX = pic32
```
**Requirement:** *Optional*
----
### CXX_NAME ### CXX_NAME
**Description:** **Description:**
@ -1146,14 +1177,27 @@ CPPFLAGS += -DMY_DEFINE_FOR_ALL_SOURCE_TYPES
**Description:** **Description:**
Override the default build tools. Override the default build tool paths and names.
If set to `1`, each tool (`CC`, `CXX`, `AS`, `OBJCOPY`, `OBJDUMP`, `AR`, `SIZE`, `NM`) must have its path explicitly defined. See `chipKIT.mk`. If OVERRIDE_EXECUTABLES is defined, all tools (`CC`, `CXX`, `AS`,
`OBJCOPY`, `OBJDUMP`, `AR`, `SIZE`, `NM`) must have their paths
explicitly defined. This may be used in the rare case where
overriding a path and/or executable name is required.
The "?=" assignment cannot be used because the executable tags
are already implicitly defined by Make (e.g. $(CC) == cc).
**Example:** **Example:**
```Makefile ```Makefile
OVERRIDE_EXECUTABLES = 1 OVERRIDE_EXECUTABLES = 1
CC = /usr/bin/avr-gcc
CXX = /usr/bin/avr-g++
AS = /usr/bin/avr-as
OBJCOPY = /usr/bin/avr-objcopy
OBJDUMP = /usr/bin/avr-objdump
AR = /usr/bin/avr-ar
SIZE = /some_path/alternative_avr-size
NM = /some_path/alternative_avr-nm
``` ```
**Requirement:** *Optional* **Requirement:** *Optional*

View file

@ -72,8 +72,7 @@ ifeq ($(CURRENT_OS),LINUX)
AVRDUDE_CONF = $(AVRDUDE_DIR)/avrdude.conf AVRDUDE_CONF = $(AVRDUDE_DIR)/avrdude.conf
endif endif
PIC32_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools
PIC32_TOOLS_PATH = $(PIC32_TOOLS_DIR)/bin
ALTERNATE_CORE = pic32 ALTERNATE_CORE = pic32
ALTERNATE_CORE_PATH = $(MPIDE_DIR)/hardware/pic32 ALTERNATE_CORE_PATH = $(MPIDE_DIR)/hardware/pic32
@ -89,23 +88,7 @@ CORE_AS_SRCS = $(ARDUINO_CORE_PATH)/vector_table.S \
ARDUINO_VERSION = 23 ARDUINO_VERSION = 23
CC_NAME = pic32-gcc TOOL_PREFIX = pic32
CXX_NAME = pic32-g++
AR_NAME = pic32-ar
OBJDUMP_NAME = pic32-objdump
OBJCOPY_NAME = pic32-objcopy
SIZE_NAME = pic32-size
NM_NAME = pic32-nm
OVERRIDE_EXECUTABLES = 1
CC = $(PIC32_TOOLS_PATH)/$(CC_NAME)
CXX = $(PIC32_TOOLS_PATH)/$(CXX_NAME)
AS = $(PIC32_TOOLS_PATH)/$(AS_NAME)
OBJCOPY = $(PIC32_TOOLS_PATH)/$(OBJCOPY_NAME)
OBJDUMP = $(PIC32_TOOLS_PATH)/$(OBJDUMP_NAME)
AR = $(PIC32_TOOLS_PATH)/$(AR_NAME)
SIZE = $(PIC32_TOOLS_PATH)/$(SIZE_NAME)
NM = $(PIC32_TOOLS_PATH)/$(NM_NAME)
LDSCRIPT = $(call PARSE_BOARD,$(BOARD_TAG),ldscript) LDSCRIPT = $(call PARSE_BOARD,$(BOARD_TAG),ldscript)
LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT) LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT)