Arduino-Makefile/Teensy.mk

138 lines
4.8 KiB
Makefile
Raw Normal View History

2014-10-14 02:48:07 +02:00
########################################################################
#
# Support for Teensy 3.x boards
2014-10-14 02:48:07 +02:00
#
# https://www.pjrc.com/teensy/
2014-10-14 02:48:07 +02:00
#
# You must install teensyduino for this Makefile to work:
#
# http://www.pjrc.com/teensy/teensyduino.html
#
# Copyright (C) 2014 Jeremy Shaw <jeremy@n-heptane.com> based on
# work that is copyright Sudar, Nicholas Zambetti, David A. Mellis
# & Hernando Barragan.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# Adapted from Arduino 0011 Makefile by M J Oldfield
#
# Original Arduino adaptation by mellis, eighthave, oli.keller
#
# Refer to HISTORY.md file for complete history of changes
#
########################################################################
2014-10-14 02:48:07 +02:00
ifndef ARDMK_DIR
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
endif
# include Common.mk now we know where it is
include $(ARDMK_DIR)/Common.mk
ARDMK_VENDOR = teensy
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt
2014-10-14 02:48:07 +02:00
ifndef F_CPU
ifndef BOARD_SUB
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.
F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed.
#$(info "speeds is " $(SPEEDS)) # Good for debugging
else
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
endif
endif
# if boards.txt gets modified, look there, else hard code it
ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
2016-11-05 20:19:15 +01:00
ifeq ($(strip $(ARCHITECTURE)),)
ARCHITECTURE = arm
endif
2014-10-14 02:48:07 +02:00
AVR_TOOLS_DIR = $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/$(ARCHITECTURE))
2016-11-04 19:28:18 +01:00
# define plaform lib dir ignoring teensy's oversight on putting it all in avr
ifndef ARDUINO_PLATFORM_LIB_PATH
ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/libraries
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_DIR))
endif
2014-10-14 02:48:07 +02:00
########################################################################
# command names
TOOL_PREFIX = arm-none-eabi
2014-10-14 02:48:07 +02:00
# processor stuff
ifndef MCU
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
2014-10-14 02:48:07 +02:00
endif
ifndef MCU_FLAG_NAME
MCU_FLAG_NAME=mcpu
endif
2014-10-14 02:48:07 +02:00
########################################################################
# FLAGS
ifndef USB_TYPE
USB_TYPE = USB_SERIAL
endif
CPPFLAGS += -DLAYOUT_US_ENGLISH -D$(USB_TYPE)
2014-10-14 02:48:07 +02:00
CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
2014-10-14 02:48:07 +02:00
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
2014-10-14 02:48:07 +02:00
CXXFLAGS_STD += -std=gnu++0x
endif
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
2014-10-14 02:48:07 +02:00
CXXFLAGS += -felide-constructors
endif
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpp)
2014-10-14 02:48:07 +02:00
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.S)
LDFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
LDFLAGS += -Wl,--gc-sections,--relax
2019-07-02 19:02:57 +02:00
LINKER_SCRIPTS ?= -T${ARDUINO_CORE_PATH}/${AMCU}.ld
OTHER_LIBS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.libs)
2014-10-14 02:48:07 +02:00
CPUFLAGS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
2016-11-04 19:37:10 +01:00
# 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')
########################################################################
# some fairly odd settings so that 'make upload' works
#
# may require additional patches for Windows support
do_upload: override get_monitor_port=""
AVRDUDE=@true
RESET_CMD = nohup $(ARDUINO_DIR)/hardware/tools/teensy_post_compile -board=$(BOARD_TAG) -tools=$(abspath $(ARDUINO_DIR)/hardware/tools) -path=$(abspath $(OBJDIR)) -file=$(TARGET) > /dev/null ; $(ARDUINO_DIR)/hardware/tools/teensy_reboot
2014-10-14 02:48:07 +02:00
########################################################################
# automatially include Arduino.mk for the user
2014-10-14 02:48:07 +02:00
include $(ARDMK_DIR)/Arduino.mk