From 2442dafb4fa8a7f0c5212a0d0f6e3fbafb986b29 Mon Sep 17 00:00:00 2001 From: Pieter du Preez Date: Thu, 13 Sep 2018 23:44:12 +0200 Subject: Moved the PARSE_BOARD macro from Arduino.mk to Common.mk. There seems to be 3 different macros to parse the boards.txt file. This patch moves the PARSE_BOARD macro from Arduino.mk to Common.mk. The PARSE_OPENCM and PARSE_TEENSY macros in Teensy.mk and OpenCM.mk were removed and the common PARSE_BOARD is now being called from everywhere. Advantages of this fix are: 1. Less code, i.e. no redundant parse macros. 2. A single standardized algorithm to parse the boards.txt file. --- Arduino.mk | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Arduino.mk') diff --git a/Arduino.mk b/Arduino.mk index fa82b0e..553c5a3 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -585,11 +585,6 @@ else $(call show_config_variable,BOARD_TAG,[USER]) 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 # But the user might have to define MCU, F_CPU etc ifeq ($(strip $(NO_CORE)),) -- cgit v1.2.3 From e44540043edb15c0ab7eab2a8d0cb3241933ce8e Mon Sep 17 00:00:00 2001 From: Pieter du Preez Date: Fri, 14 Sep 2018 16:14:14 +0200 Subject: Added the TOOL_PREFIX variable for setting up the executable tools. Currently three different tool chains seem to be used: * avr-* * pic32-* * arm-none-eabi-* These all get set up independently. This patch centralizes the definitions of the executable tools and does it generically, by means of the newly introduced TOOL_PREFIX variable. Setting up a tool chain is now simply a matter of defining the TOOL_PREFIX variable. For the currently supported tool chains it gets set to avr, pic32 or arm-none-eabi. Arbitrary tool chains can now easily be set up, by the TOOL_PREFIX variable. Although the use of the OVERRIDE_EXECUTABLES variable is now almost not justifiable, it was left as-is, in order to assure backwards compatibility. --- Arduino.mk | 110 ++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 83 insertions(+), 27 deletions(-) (limited to 'Arduino.mk') 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\ -- cgit v1.2.3 From 62d23d66a2f9326235022bfd8711c62e015c0bc8 Mon Sep 17 00:00:00 2001 From: Pieter du Preez Date: Sat, 15 Sep 2018 14:31:39 +0200 Subject: Moved the BOARDS_TXT section and stop if BOARDS_TXT is not a file. The section of Arduino.mk that calculates BOARDS_TXT was moved to just before the point where it gets used for the first time (a call to PARSE_BOARD). An error gets generated if BOARDS_TXT is not pointing to a valid file, directly after the BOARDS_TXT calculation. In addition, the PARSE_BOARD macro will now be bypassed if the BOARDS_TXT variable points to a non-existing file. If a user makefile uses PARSE_BOARD before including Arduino.mk, and the BOARDS_TXT is wrong, the error will only be caught in the Arduino.mk file, which is probably acceptable. --- Arduino.mk | 94 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 49 insertions(+), 45 deletions(-) (limited to 'Arduino.mk') diff --git a/Arduino.mk b/Arduino.mk index f47af3e..4122729 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -388,6 +388,55 @@ endif ######################################################################## # 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 @@ -557,51 +606,6 @@ else $(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER]) 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 -- cgit v1.2.3 From 0692c13e98a43a230a4bb94b1b9a1e75e17ea2d0 Mon Sep 17 00:00:00 2001 From: John Whittington Date: Fri, 28 Sep 2018 18:25:56 +0100 Subject: Pass OpenOCD options to debug_init target --- Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Arduino.mk') diff --git a/Arduino.mk b/Arduino.mk index fa82b0e..e23a7bc 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -1691,7 +1691,7 @@ else endif debug_init: - $(OPENOCD) + $(OPENOCD) $(OPENOCD_OPTS) debug: $(GDB) $(GDB_OPTS) -- cgit v1.2.3