Arduino-Makefile/Common.mk

92 lines
3.4 KiB
Makefile
Raw Normal View History

SAMD Cortex M0 device support (Zero, MKR1000, etc) Compilation improvements by adding variant as other obj but not working on device Arduino Zero devices with OpenOCD working Created ARM_TOOLS_DIR and define arm toolchain executables in Sam.mk Check avr-gcc on last AVR_TOOLS_DIR detect and indenting formatting GDB debugging and programming added Documentation updates and define ARDMK_VENDOR rather than include Sam.mk Expand all parse_boards when defined rather than when used Trim extra defines regex working on both macOS and Linux but need better fix Print USB ids and added debug usage to readme Add note on Arduino package dir and made board.txt work Do ARM ARDUINO_ARCH define in Arduino.mk] Add MZeroBlink to non-testable examples for now Remove \B from extra defines grep Add ARDUINO_PACKAGE_DIR for board support files Fix a typo in the README Fix typo in arduino-mk-vars.md Prevent re-including Arduino.mk from Sam.mk when make restarts for upload Add catrina to ARD_REST_OPTS if/else Remove realpath in Sam.mk for cygwin compatability SAMD bootloader support in ard-reset using --zero Enters bootloader using open/close of port at 1200 BAUD, then polls the attached devices for new port enumerating (bootloader). This is how the Arduino IDE operates Bossa support for Zero, MKR1000 etc Re-word Arm README section after Native USB development Reset for zero refactored like IDE Zero bootloader reset tested on macOS and comments added Re-word ARM bootloader and remove imports from testing Patch changes ARDMK_VENDOR->ARCHITECHTURE, show_config_vars, ignore CORE_VER if emtpy Common.mk header guard, openocd/bossac avoid separator, typos Documentation update for patch changes Move ARM tools to Sam.mk and auto-detect include Correct accidental commit of Blink Makefile change Lib fix with alternative core and documentation Append zero to ARD_RESET_OPTS rather than set Prioritise package ARM upload tools over path installed Add note in README on ARM tools versions Move openocd variant config script flag to OPTS
2018-01-02 18:35:47 +01:00
COMMON_INCLUDED = TRUE
# Useful functions
# Returns the first argument (typically a directory), if the file or directory
# named by concatenating the first and optionally second argument
# (directory and optional filename) exists
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
# Run a shell script if it exists. Stops make on error.
runscript_if_exists = \
$(if $(wildcard $(1)), \
$(if $(findstring 0, \
$(lastword $(shell $(abspath $(wildcard $(1))); echo $$?))), \
$(info Info: $(1) success), \
$(error ERROR: $(1) failed)))
# For message printing: pad the right side of the first argument with spaces to
# the number of bytes indicated by the second argument.
space_pad_to = $(shell echo "$(1) " | head -c$(2))
# Call with some text, and a prefix tag if desired (like [AUTODETECTED]),
show_config_info = $(call arduino_output,- $(call space_pad_to,$(2),20) $(1))
# Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]),
# and an explanation if desired (like (found in $$PATH)
show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2))
# Just a nice simple visual separator
show_separator = $(call arduino_output,-------------------------)
SAMD Cortex M0 device support (Zero, MKR1000, etc) Compilation improvements by adding variant as other obj but not working on device Arduino Zero devices with OpenOCD working Created ARM_TOOLS_DIR and define arm toolchain executables in Sam.mk Check avr-gcc on last AVR_TOOLS_DIR detect and indenting formatting GDB debugging and programming added Documentation updates and define ARDMK_VENDOR rather than include Sam.mk Expand all parse_boards when defined rather than when used Trim extra defines regex working on both macOS and Linux but need better fix Print USB ids and added debug usage to readme Add note on Arduino package dir and made board.txt work Do ARM ARDUINO_ARCH define in Arduino.mk] Add MZeroBlink to non-testable examples for now Remove \B from extra defines grep Add ARDUINO_PACKAGE_DIR for board support files Fix a typo in the README Fix typo in arduino-mk-vars.md Prevent re-including Arduino.mk from Sam.mk when make restarts for upload Add catrina to ARD_REST_OPTS if/else Remove realpath in Sam.mk for cygwin compatability SAMD bootloader support in ard-reset using --zero Enters bootloader using open/close of port at 1200 BAUD, then polls the attached devices for new port enumerating (bootloader). This is how the Arduino IDE operates Bossa support for Zero, MKR1000 etc Re-word Arm README section after Native USB development Reset for zero refactored like IDE Zero bootloader reset tested on macOS and comments added Re-word ARM bootloader and remove imports from testing Patch changes ARDMK_VENDOR->ARCHITECHTURE, show_config_vars, ignore CORE_VER if emtpy Common.mk header guard, openocd/bossac avoid separator, typos Documentation update for patch changes Move ARM tools to Sam.mk and auto-detect include Correct accidental commit of Blink Makefile change Lib fix with alternative core and documentation Append zero to ARD_RESET_OPTS rather than set Prioritise package ARM upload tools over path installed Add note in README on ARM tools versions Move openocd variant config script flag to OPTS
2018-01-02 18:35:47 +01:00
# Master Arduino Makefile include (after user Makefile)
ardmk_include = $(shell basename $(word 2,$(MAKEFILE_LIST)))
$(call show_separator)
SAMD Cortex M0 device support (Zero, MKR1000, etc) Compilation improvements by adding variant as other obj but not working on device Arduino Zero devices with OpenOCD working Created ARM_TOOLS_DIR and define arm toolchain executables in Sam.mk Check avr-gcc on last AVR_TOOLS_DIR detect and indenting formatting GDB debugging and programming added Documentation updates and define ARDMK_VENDOR rather than include Sam.mk Expand all parse_boards when defined rather than when used Trim extra defines regex working on both macOS and Linux but need better fix Print USB ids and added debug usage to readme Add note on Arduino package dir and made board.txt work Do ARM ARDUINO_ARCH define in Arduino.mk] Add MZeroBlink to non-testable examples for now Remove \B from extra defines grep Add ARDUINO_PACKAGE_DIR for board support files Fix a typo in the README Fix typo in arduino-mk-vars.md Prevent re-including Arduino.mk from Sam.mk when make restarts for upload Add catrina to ARD_REST_OPTS if/else Remove realpath in Sam.mk for cygwin compatability SAMD bootloader support in ard-reset using --zero Enters bootloader using open/close of port at 1200 BAUD, then polls the attached devices for new port enumerating (bootloader). This is how the Arduino IDE operates Bossa support for Zero, MKR1000 etc Re-word Arm README section after Native USB development Reset for zero refactored like IDE Zero bootloader reset tested on macOS and comments added Re-word ARM bootloader and remove imports from testing Patch changes ARDMK_VENDOR->ARCHITECHTURE, show_config_vars, ignore CORE_VER if emtpy Common.mk header guard, openocd/bossac avoid separator, typos Documentation update for patch changes Move ARM tools to Sam.mk and auto-detect include Correct accidental commit of Blink Makefile change Lib fix with alternative core and documentation Append zero to ARD_RESET_OPTS rather than set Prioritise package ARM upload tools over path installed Add note in README on ARM tools versions Move openocd variant config script flag to OPTS
2018-01-02 18:35:47 +01:00
$(call arduino_output,$(call ardmk_include) Configuration:)
########################################################################
#
# Detect OS
ifeq ($(OS),Windows_NT)
CURRENT_OS = WINDOWS
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CURRENT_OS = LINUX
endif
ifeq ($(UNAME_S),Darwin)
CURRENT_OS = MAC
endif
endif
$(call show_config_variable,CURRENT_OS,[AUTODETECTED])
########################################################################
#
# Travis-CI
ifneq ($(TEST),)
DEPENDENCIES_DIR = /var/tmp/Arduino-Makefile-testing-dependencies
DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_DIR)/mpide-0023-linux64-20130817-test
ifeq ($(MPIDE_DIR),)
MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR)
endif
DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/arduino-1.0.6
ifeq ($(ARDUINO_DIR),)
ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR)
endif
endif
########################################################################
# Arduino Directory
ifndef ARDUINO_DIR
AUTO_ARDUINO_DIR := $(firstword \
$(call dir_if_exists,/usr/share/arduino) \
$(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) \
$(call dir_if_exists,/Applications/Arduino.app/Contents/Java) )
ifdef AUTO_ARDUINO_DIR
ARDUINO_DIR = $(AUTO_ARDUINO_DIR)
$(call show_config_variable,ARDUINO_DIR,[AUTODETECTED])
else
echo $(error "ARDUINO_DIR is not defined")
endif
else
$(call show_config_variable,ARDUINO_DIR,[USER])
endif
ifeq ($(CURRENT_OS),WINDOWS)
ifneq ($(shell echo $(ARDUINO_DIR) | egrep '\\|[[:space:]]|cygdrive'),)
echo $(error On Windows, ARDUINO_DIR and other defines must use forward slash and not contain spaces, special characters or be cygdrive relative)
endif
endif