diff --git a/Arduino.mk b/Arduino.mk index f47af3e3..41227295 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 diff --git a/Common.mk b/Common.mk index 6209b039..c5f2bc25 100644 --- a/Common.mk +++ b/Common.mk @@ -7,7 +7,13 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) 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) +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.