# Template makefile for arduino-ua toolchain
# Version 2.0 - 2012-11-07

# Remember to `make clean` before `make upload to a different board type 
# Actually, when you resume development its a good idea to start with a
# make clean.

# This is needed only if you have a main .ino file from a use of the IDE.
# Normally you will only have .cpp files.
TARGET = 

# Two common board types, mega2560 and uno.
# Either set your board type here or supply it on the make command as in
#		`make upload BOARD_TAG=uno`
BOARD_TAG = mega2560 

# Identify and of the extra libraries that are not in the core collection
# here.  If you don't have any, leave it undefined.
# For example:
#	ARDUINO_LIBS = SPI Adafruit_GFX Adafruit_ST7735 \
#	   Adafruit_SD Adafruit_SD/utility SD/utility UAUtils
ARDUINO_LIBS = UAUtils

# if there is a ARDUINO_UA_ROOT environment variable, it defines the
# root of the arduino_ua install.  If not, we assume it is $(HOME)
ifndef ARDUINO_UA_ROOT
  ARDUINO_UA_ROOT=$(HOME)
endif

# now set up all the toolchain defaults for the arduino-us install
include $(ARDUINO_UA_ROOT)/arduino-ua/mkfiles/ArduinoUA.mk

# This is magic to define the names MEGA or UNO in C/C++ files. on the 
# basis of the board type.
BOARD_DEFINE := $(shell echo $(BOARD_TAG) | tr 'a-z' 'A-Z' | tr -d [0-9])

# You can also add extra symbols to be defined, like DEBUG 
DEFINITIONS = $(BOARD_DEFINE) 

# this puts the -D arguments into the format rquired by the compiler.
DEFINES := ${DEFINITIONS:%=-D%}

# Define your compiler flags. Remember to `+=` the rule.
#CFLAGS += -Wall -Werror -std=c99
#CXXFLAGS += -Wall -Werror
CPPFLAGS += $(DEFINES) 

# Override the default optimization levels here
# For example, set to optimize level 0 to get the mimimum amount
# CPP_OPTIMIZE = -O0
# C_OPTIMIZE = -O0
# LD_OPTIMIZE = -O0

# Sometimes it is a good idea to see what code is being generated by the 
# compiler.  Set GENERATE_ASM to 1 to do this, and you will get .s files
# in the build-cli directory.  To do this only on demand, you can say
#    make GENERATE_ASM=1
# So for example if you only want to look at the assembly for the main 
# program, compile everything, touch the code, and do a make with the 
# GENERATE_ADM set in the command.
# GENERATE_ASM = 1