diff --git a/Arduino.mk b/Arduino.mk index 553c5a3..f47af3e 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -388,28 +388,80 @@ endif ######################################################################## # Arduino and system paths +ifndef TOOL_PREFIX + TOOL_PREFIX = avr +endif + 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 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 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 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 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 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 ifndef AVR_TOOLS_DIR @@ -457,8 +509,8 @@ ifndef AVR_TOOLS_DIR AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) else - # One last attempt using avr-gcc in case using arm - SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $(avr-gcc)))/..)) + # One last attempt using $(TOOL_PREFIX)-gcc in case using arm + SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $($(TOOL_PREFIX)-gcc)))/..)) ifdef SYSTEMPATH_AVR_TOOLS_DIR AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) @@ -483,8 +535,8 @@ else endif #ndef AVR_TOOLS_DIR -ifndef AVR_TOOLS_PATH - AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin +ifndef TOOLS_PATH + TOOLS_PATH = $(AVR_TOOLS_DIR)/bin endif ifndef ARDUINO_LIB_PATH @@ -821,7 +873,7 @@ endif ifeq ($(strip $(NO_CORE)),) ifdef ARDUINO_CORE_PATH 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_AS_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.S) @@ -931,18 +983,22 @@ TARGET_EEP = $(OBJDIR)/$(TARGET).eep TARGET_BIN = $(OBJDIR)/$(TARGET).bin CORE_LIB = $(OBJDIR)/libcore.a -# Names of executables - chipKIT needs to override all to set paths to PIC32 -# tools, and we can't use "?=" assignment because these are already implicitly +# Names of executables +# 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). ifndef OVERRIDE_EXECUTABLES - CC = $(AVR_TOOLS_PATH)/$(CC_NAME) - CXX = $(AVR_TOOLS_PATH)/$(CXX_NAME) - AS = $(AVR_TOOLS_PATH)/$(AS_NAME) - OBJCOPY = $(AVR_TOOLS_PATH)/$(OBJCOPY_NAME) - OBJDUMP = $(AVR_TOOLS_PATH)/$(OBJDUMP_NAME) - AR = $(AVR_TOOLS_PATH)/$(AR_NAME) - SIZE = $(AVR_TOOLS_PATH)/$(SIZE_NAME) - NM = $(AVR_TOOLS_PATH)/$(NM_NAME) + CC = $(TOOLS_PATH)/$(CC_NAME) + CXX = $(TOOLS_PATH)/$(CXX_NAME) + AS = $(TOOLS_PATH)/$(AS_NAME) + OBJCOPY = $(TOOLS_PATH)/$(OBJCOPY_NAME) + OBJDUMP = $(TOOLS_PATH)/$(OBJDUMP_NAME) + AR = $(TOOLS_PATH)/$(AR_NAME) + SIZE = $(TOOLS_PATH)/$(SIZE_NAME) + NM = $(TOOLS_PATH)/$(NM_NAME) endif REMOVE = rm -rf @@ -1078,15 +1134,15 @@ ifneq ($(CATERINA),) CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) 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') # moved from above so we can find version-dependant ar -ifndef AR_NAME +ifeq ($(TOOL_PREFIX), avr) ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) - AR_NAME = avr-gcc-ar + AR_NAME := $(TOOL_PREFIX)-gcc-ar else - AR_NAME = avr-ar + AR_NAME := $(TOOL_PREFIX)-ar endif endif @@ -1404,7 +1460,7 @@ CTAGS_CMD = $(CTAGS_EXEC) $(CTAGS_OPTS) -auf # If avrdude is installed separately, it can find its own config file ifndef AVRDUDE - AVRDUDE = $(AVR_TOOLS_PATH)/avrdude + AVRDUDE = $(TOOLS_PATH)/avrdude endif # Default avrdude options @@ -1747,7 +1803,7 @@ help: make debug_init - start openocd gdb server\n\ make debug - connect to gdb target and begin debugging\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\ the capacity of the micro controller.\n\ make symbol_sizes - generate a .sym file containing symbols and their\n\ diff --git a/HISTORY.md b/HISTORY.md index b192c16..1743903 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -23,6 +23,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - 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: 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) - Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278) diff --git a/OpenCM.mk b/OpenCM.mk index fd73af5..b6d0534 100644 --- a/OpenCM.mk +++ b/OpenCM.mk @@ -69,77 +69,7 @@ endif ######################################################################## # command names -ifndef CC_NAME - 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-as - else - $(call show_config_variable,AS_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-nm - else - $(call show_config_variable,NM_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 +TOOL_PREFIX = arm-none-eabi # processor stuff ifndef MCU diff --git a/Sam.mk b/Sam.mk index bbea32c..2ec94ee 100644 --- a/Sam.mk +++ b/Sam.mk @@ -167,7 +167,7 @@ endif # Use arm-toolchain from Arduino install if exists and user has not defined global version 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)) else $(call show_config_variable,ARM_TOOLS_DIR,[USER]) @@ -182,82 +182,12 @@ endif ######################################################################## # command names -ifndef CC_NAME - 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 +TOOL_PREFIX = arm-none-eabi ifndef GDB_NAME GDB_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gdb) ifndef GDB_NAME - GDB_NAME := arm-none-eabi-gdb + GDB_NAME := $(TOOL_PREFIX)-gdb else $(call show_config_variable,GDB_NAME,[COMPUTED]) endif @@ -385,17 +315,8 @@ endif ######################################################################## # EXECUTABLES # 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 -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) +AVR_TOOLS_DIR := $(ARM_TOOLS_DIR) #GDB = $(ARM_TOOLS_PATH)/$(GDB_NAME) # Use system gdb for now as Arduino supplied has lib error? GDB = $(GDB_NAME) diff --git a/Teensy.mk b/Teensy.mk index 15769cb..d4f23bc 100644 --- a/Teensy.mk +++ b/Teensy.mk @@ -66,77 +66,7 @@ endif ######################################################################## # command names -ifndef CC_NAME - 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 +TOOL_PREFIX = arm-none-eabi # processor stuff ifndef MCU diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 2bc2205..b6b9b37 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -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 **Description:** @@ -1146,14 +1177,27 @@ CPPFLAGS += -DMY_DEFINE_FOR_ALL_SOURCE_TYPES **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:** ```Makefile 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* diff --git a/chipKIT.mk b/chipKIT.mk index 298ac96..e5e4386 100644 --- a/chipKIT.mk +++ b/chipKIT.mk @@ -72,8 +72,7 @@ ifeq ($(CURRENT_OS),LINUX) AVRDUDE_CONF = $(AVRDUDE_DIR)/avrdude.conf endif -PIC32_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools -PIC32_TOOLS_PATH = $(PIC32_TOOLS_DIR)/bin +AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools ALTERNATE_CORE = pic32 ALTERNATE_CORE_PATH = $(MPIDE_DIR)/hardware/pic32 @@ -89,23 +88,7 @@ CORE_AS_SRCS = $(ARDUINO_CORE_PATH)/vector_table.S \ ARDUINO_VERSION = 23 -CC_NAME = pic32-gcc -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) +TOOL_PREFIX = pic32 LDSCRIPT = $(call PARSE_BOARD,$(BOARD_TAG),ldscript) LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT)