2012-01-23 20:18:54 -06:00
|
|
|
# Sprinter Arduino Project Makefile
|
2013-06-06 17:49:25 -05:00
|
|
|
#
|
2012-01-23 20:18:54 -06:00
|
|
|
# Makefile Based on:
|
|
|
|
# Arduino 0011 Makefile
|
|
|
|
# Arduino adaptation by mellis, eighthave, oli.keller
|
2012-11-11 04:05:52 -06:00
|
|
|
# Marlin adaption by Daid
|
2012-01-23 20:18:54 -06:00
|
|
|
#
|
|
|
|
# This has been tested with Arduino 0022.
|
2013-06-06 17:49:25 -05:00
|
|
|
#
|
2012-01-23 20:18:54 -06:00
|
|
|
# This makefile allows you to build sketches from the command line
|
|
|
|
# without the Arduino environment (or Java).
|
|
|
|
#
|
|
|
|
# Detailed instructions for using the makefile:
|
|
|
|
#
|
2012-11-11 04:05:52 -06:00
|
|
|
# 1. Modify the line containg "ARDUINO_INSTALL_DIR" to point to the directory that
|
2012-01-23 20:18:54 -06:00
|
|
|
# contains the Arduino installation (for example, under Mac OS X, this
|
2014-01-16 09:58:35 -06:00
|
|
|
# might be /Applications/Arduino.app/Contents/Resources/Java).
|
2012-01-23 20:18:54 -06:00
|
|
|
#
|
2012-11-11 04:05:52 -06:00
|
|
|
# 2. Modify the line containing "UPLOAD_PORT" to refer to the filename
|
2012-01-23 20:18:54 -06:00
|
|
|
# representing the USB or serial connection to your Arduino board
|
2012-11-11 04:05:52 -06:00
|
|
|
# (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file
|
|
|
|
# changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*).
|
2012-01-23 20:18:54 -06:00
|
|
|
#
|
2013-06-06 17:49:25 -05:00
|
|
|
# 3. Set the line containing "MCU" to match your board's processor.
|
2012-01-23 20:18:54 -06:00
|
|
|
# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
|
|
|
|
# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
|
2012-03-07 17:05:10 -06:00
|
|
|
# change F_CPU to 8000000. If you are using Gen7 electronics, you
|
|
|
|
# probably need to use 20000000. Either way, you must regenerate
|
|
|
|
# the speed lookup table with create_speed_lookuptable.py.
|
2012-01-23 20:18:54 -06:00
|
|
|
#
|
|
|
|
# 4. Type "make" and press enter to compile/verify your program.
|
|
|
|
#
|
|
|
|
# 5. Type "make upload", reset your Arduino board, and press enter to
|
|
|
|
# upload your program to the Arduino board.
|
|
|
|
#
|
2012-11-11 04:05:52 -06:00
|
|
|
# Note that all settings are set with ?=, this means you can override them
|
|
|
|
# from the commandline with "make HARDWARE_MOTHERBOARD=71" for example
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2015-01-12 23:01:43 -06:00
|
|
|
# This defined the board you are compiling for (see boards.h for the options)
|
2012-11-11 04:05:52 -06:00
|
|
|
HARDWARE_MOTHERBOARD ?= 11
|
2012-01-25 03:46:27 -06:00
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
# Arduino source install directory, and version number
|
2015-01-12 23:01:43 -06:00
|
|
|
# On most linuxes this will be /usr/share/arduino
|
|
|
|
ARDUINO_INSTALL_DIR ?= /usr/share/arduino
|
2014-01-16 09:58:35 -06:00
|
|
|
ARDUINO_VERSION ?= 105
|
2012-03-22 08:48:10 -05:00
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
# You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
|
2013-06-06 17:49:25 -05:00
|
|
|
AVR_TOOLS_PATH ?=
|
2012-11-11 04:05:52 -06:00
|
|
|
|
|
|
|
#Programmer configuration
|
|
|
|
UPLOAD_RATE ?= 115200
|
2015-01-18 11:18:43 -06:00
|
|
|
AVRDUDE_PROGRAMMER ?= wiring
|
2015-01-12 23:01:43 -06:00
|
|
|
# on most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
|
2012-11-11 04:05:52 -06:00
|
|
|
UPLOAD_PORT ?= /dev/arduino
|
|
|
|
|
2015-01-12 23:01:43 -06:00
|
|
|
#Directory used to build files in, contains all the build files, from object files to the final hex file
|
|
|
|
#on linux it is best to put an absolute path like /home/username/tmp .
|
2012-11-11 04:05:52 -06:00
|
|
|
BUILD_DIR ?= applet
|
|
|
|
|
2013-07-24 05:09:53 -05:00
|
|
|
# This defines whether Liquid_TWI2 support will be built
|
2014-02-05 03:47:12 -06:00
|
|
|
LIQUID_TWI2 ?= 0
|
|
|
|
|
|
|
|
# this defines if Wire is needed
|
|
|
|
WIRE ?= 0
|
2013-07-24 05:09:53 -05:00
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
############################################################################
|
|
|
|
# Below here nothing should be changed...
|
|
|
|
|
|
|
|
# Here the Arduino variant is selected by the board type
|
|
|
|
# HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
|
|
|
|
# MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...
|
|
|
|
|
|
|
|
#Gen7
|
|
|
|
ifeq ($(HARDWARE_MOTHERBOARD),10)
|
|
|
|
HARDWARE_VARIANT ?= Gen7
|
2012-12-09 12:19:57 -06:00
|
|
|
MCU ?= atmega644
|
2012-11-11 04:05:52 -06:00
|
|
|
F_CPU ?= 20000000
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),11)
|
|
|
|
HARDWARE_VARIANT ?= Gen7
|
|
|
|
MCU ?= atmega644p
|
|
|
|
F_CPU ?= 20000000
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),12)
|
|
|
|
HARDWARE_VARIANT ?= Gen7
|
|
|
|
MCU ?= atmega644p
|
|
|
|
F_CPU ?= 20000000
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),13)
|
|
|
|
HARDWARE_VARIANT ?= Gen7
|
|
|
|
MCU ?= atmega1284p
|
|
|
|
F_CPU ?= 20000000
|
|
|
|
|
|
|
|
#RAMPS
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),3)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),33)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),34)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
|
|
|
|
#Gen6
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),5)
|
|
|
|
HARDWARE_VARIANT ?= Gen6
|
2012-12-09 16:02:03 -06:00
|
|
|
MCU ?= atmega644p
|
2012-11-11 04:05:52 -06:00
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),51)
|
|
|
|
HARDWARE_VARIANT ?= Gen6
|
2012-12-09 16:02:03 -06:00
|
|
|
MCU ?= atmega644p
|
2012-11-11 04:05:52 -06:00
|
|
|
|
|
|
|
#Sanguinololu
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),6)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
2012-12-09 16:02:03 -06:00
|
|
|
MCU ?= atmega644p
|
2012-11-11 04:05:52 -06:00
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),62)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
2012-12-09 16:02:03 -06:00
|
|
|
MCU ?= atmega644p
|
2012-11-11 04:05:52 -06:00
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),63)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
2012-12-09 16:02:03 -06:00
|
|
|
MCU ?= atmega644p
|
2013-07-14 03:17:55 -05:00
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),65)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
|
|
|
MCU ?= atmega1284p
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),66)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
|
|
|
MCU ?= atmega1284p
|
2012-11-11 04:05:52 -06:00
|
|
|
|
|
|
|
#Ultimaker
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),7)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),71)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega1280
|
|
|
|
|
|
|
|
#Teensylu
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),8)
|
2012-12-13 04:41:27 -06:00
|
|
|
HARDWARE_VARIANT ?= Teensy
|
2012-11-11 04:05:52 -06:00
|
|
|
MCU ?= at90usb1286
|
2012-12-09 16:30:55 -06:00
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),81)
|
2012-12-13 04:41:27 -06:00
|
|
|
HARDWARE_VARIANT ?= Teensy
|
2012-12-09 16:30:55 -06:00
|
|
|
MCU ?= at90usb1286
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),82)
|
2012-12-13 04:41:27 -06:00
|
|
|
HARDWARE_VARIANT ?= Teensy
|
2012-12-09 16:30:55 -06:00
|
|
|
MCU ?= at90usb646
|
2014-01-16 09:58:35 -06:00
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),83)
|
|
|
|
HARDWARE_VARIANT ?= Teensy
|
|
|
|
MCU ?= at90usb1286
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),84)
|
|
|
|
HARDWARE_VARIANT ?= Teensy
|
|
|
|
MCU ?= at90usb1286
|
2012-11-11 04:05:52 -06:00
|
|
|
|
|
|
|
#Gen3+
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),9)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
|
|
|
MCU ?= atmega644p
|
|
|
|
|
2014-05-06 19:24:20 -05:00
|
|
|
#Gen3 Monolithic Electronics
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),22)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
|
|
|
MCU ?= atmega644p
|
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
#Megatronics
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),70)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
|
|
|
|
#Alpha OMCA board
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),90)
|
|
|
|
HARDWARE_VARIANT ?= SanguinoA
|
|
|
|
MCU ?= atmega644
|
|
|
|
|
2012-12-13 05:19:12 -06:00
|
|
|
#Final OMCA board
|
2012-11-11 04:05:52 -06:00
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),91)
|
|
|
|
HARDWARE_VARIANT ?= Sanguino
|
|
|
|
MCU ?= atmega644p
|
|
|
|
|
2012-11-24 04:46:31 -06:00
|
|
|
#Rambo
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),301)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
|
2014-02-05 03:47:12 -06:00
|
|
|
# Azteeg
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),67)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
else ifeq ($(HARDWARE_MOTHERBOARD),68)
|
|
|
|
HARDWARE_VARIANT ?= arduino
|
|
|
|
MCU ?= atmega2560
|
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
|
|
|
|
# if you are setting this to something other than 16MHz
|
|
|
|
# Set to 16Mhz if not yet set.
|
|
|
|
F_CPU ?= 16000000
|
2012-03-22 08:48:10 -05:00
|
|
|
|
|
|
|
# Arduino containd the main source code for the Arduino
|
|
|
|
# Libraries, the "hardware variant" are for boards
|
|
|
|
# that derives from that, and their source are present in
|
|
|
|
# the main Marlin source directory
|
2012-11-24 04:46:31 -06:00
|
|
|
ifeq ($(HARDWARE_VARIANT), arduino)
|
2013-01-07 10:26:50 -06:00
|
|
|
HARDWARE_DIR = $(ARDUINO_INSTALL_DIR)/hardware
|
2012-03-22 08:48:10 -05:00
|
|
|
else
|
2012-12-10 05:06:30 -06:00
|
|
|
ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
|
2013-01-07 10:26:50 -06:00
|
|
|
HARDWARE_DIR = ../ArduinoAddons/Arduino_1.x.x
|
2012-12-10 05:06:30 -06:00
|
|
|
else
|
2013-01-07 10:26:50 -06:00
|
|
|
HARDWARE_DIR = ../ArduinoAddons/Arduino_0.xx
|
2012-12-10 05:06:30 -06:00
|
|
|
endif
|
2012-03-22 08:48:10 -05:00
|
|
|
endif
|
2013-01-07 10:26:50 -06:00
|
|
|
HARDWARE_SRC = $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/cores/arduino
|
2012-12-13 04:41:27 -06:00
|
|
|
|
2012-01-25 03:46:27 -06:00
|
|
|
TARGET = $(notdir $(CURDIR))
|
|
|
|
|
2012-03-22 08:48:10 -05:00
|
|
|
# VPATH tells make to look into these directory for source files,
|
|
|
|
# there is no need to specify explicit pathnames as long as the
|
|
|
|
# directory is added here
|
|
|
|
|
|
|
|
VPATH = .
|
2012-11-11 04:05:52 -06:00
|
|
|
VPATH += $(BUILD_DIR)
|
2012-03-22 08:48:10 -05:00
|
|
|
VPATH += $(HARDWARE_SRC)
|
2015-01-13 12:59:50 -06:00
|
|
|
ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy))
|
2013-01-08 05:54:31 -06:00
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/SPI
|
2013-07-24 05:09:53 -05:00
|
|
|
ifeq ($(LIQUID_TWI2), 1)
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
|
|
|
|
endif
|
2014-02-05 03:47:12 -06:00
|
|
|
ifeq ($(WIRE), 1)
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
|
|
|
|
endif
|
2013-01-08 05:54:31 -06:00
|
|
|
else
|
2013-01-07 10:26:50 -06:00
|
|
|
VPATH += $(HARDWARE_DIR)/libraries/LiquidCrystal
|
|
|
|
VPATH += $(HARDWARE_DIR)/libraries/SPI
|
2013-07-24 05:09:53 -05:00
|
|
|
ifeq ($(LIQUID_TWI2), 1)
|
|
|
|
VPATH += $(HARDWARE_DIR)/libraries/Wire
|
|
|
|
VPATH += $(HARDWARE_DIR)/libraries/Wire/utility
|
|
|
|
VPATH += $(HARDWARE_DIR)/libraries/LiquidTWI2
|
|
|
|
endif
|
2014-02-17 01:21:53 -06:00
|
|
|
ifeq ($(WIRE), 1)
|
2014-02-05 03:47:12 -06:00
|
|
|
VPATH += $(HARDWARE_DIR)/libraries/Wire
|
|
|
|
VPATH += $(HARDWARE_DIR)/libraries/Wire/utility
|
|
|
|
endif
|
2013-01-08 05:54:31 -06:00
|
|
|
endif
|
2012-11-24 04:46:31 -06:00
|
|
|
ifeq ($(HARDWARE_VARIANT), arduino)
|
2012-12-09 12:19:57 -06:00
|
|
|
HARDWARE_SUB_VARIANT ?= mega
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/variants/$(HARDWARE_SUB_VARIANT)
|
2013-01-07 10:26:50 -06:00
|
|
|
else
|
|
|
|
HARDWARE_SUB_VARIANT ?= standard
|
|
|
|
VPATH += $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
|
2012-11-24 04:46:31 -06:00
|
|
|
endif
|
|
|
|
SRC = wiring.c \
|
2012-03-22 08:48:10 -05:00
|
|
|
wiring_analog.c wiring_digital.c \
|
|
|
|
wiring_pulse.c \
|
|
|
|
wiring_shift.c WInterrupts.c
|
2014-01-16 09:58:35 -06:00
|
|
|
ifeq ($(HARDWARE_VARIANT), Teensy)
|
|
|
|
SRC = wiring.c
|
|
|
|
VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
|
|
|
|
endif
|
2012-11-11 04:05:52 -06:00
|
|
|
CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
|
2012-11-06 19:18:26 -06:00
|
|
|
MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \
|
2015-05-13 20:52:41 -05:00
|
|
|
SdFile.cpp SdVolume.cpp planner.cpp stepper.cpp \
|
|
|
|
temperature.cpp cardreader.cpp configuration_store.cpp \
|
2015-04-25 23:04:54 -05:00
|
|
|
watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \
|
2014-02-17 01:19:08 -06:00
|
|
|
vector_3.cpp qr_solve.cpp
|
2013-07-24 05:09:53 -05:00
|
|
|
ifeq ($(LIQUID_TWI2), 0)
|
|
|
|
CXXSRC += LiquidCrystal.cpp
|
|
|
|
else
|
|
|
|
SRC += twi.c
|
|
|
|
CXXSRC += Wire.cpp LiquidTWI2.cpp
|
|
|
|
endif
|
2012-11-24 04:46:31 -06:00
|
|
|
|
2014-02-05 03:47:12 -06:00
|
|
|
ifeq ($(WIRE), 1)
|
|
|
|
SRC += twi.c
|
|
|
|
CXXSRC += Wire.cpp
|
|
|
|
endif
|
|
|
|
|
2012-11-24 04:46:31 -06:00
|
|
|
#Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version
|
|
|
|
ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
|
|
|
|
CXXSRC += main.cpp
|
|
|
|
else
|
|
|
|
SRC += pins_arduino.c main.c
|
|
|
|
endif
|
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
FORMAT = ihex
|
|
|
|
|
|
|
|
# Name of this Makefile (used for "make depend").
|
|
|
|
MAKEFILE = Makefile
|
|
|
|
|
|
|
|
# Debugging format.
|
|
|
|
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
|
|
|
|
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
|
|
|
|
DEBUG = stabs
|
|
|
|
|
2012-01-23 20:18:54 -06:00
|
|
|
OPT = s
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-12-08 04:49:53 -06:00
|
|
|
DEFINES ?=
|
|
|
|
|
2012-12-12 22:18:31 -06:00
|
|
|
# Program settings
|
|
|
|
CC = $(AVR_TOOLS_PATH)avr-gcc
|
|
|
|
CXX = $(AVR_TOOLS_PATH)avr-g++
|
|
|
|
OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
|
|
|
|
OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
|
|
|
|
AR = $(AVR_TOOLS_PATH)avr-ar
|
|
|
|
SIZE = $(AVR_TOOLS_PATH)avr-size
|
|
|
|
NM = $(AVR_TOOLS_PATH)avr-nm
|
|
|
|
AVRDUDE = avrdude
|
|
|
|
REMOVE = rm -f
|
|
|
|
MV = mv -f
|
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
# Place -D or -U options here
|
2012-12-13 04:41:27 -06:00
|
|
|
CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
|
|
|
|
CXXDEFS = $(CDEFS)
|
|
|
|
|
|
|
|
ifeq ($(HARDWARE_VARIANT), Teensy)
|
|
|
|
CDEFS += -DUSB_SERIAL
|
|
|
|
SRC += usb.c pins_teensy.c
|
|
|
|
CXXSRC += usb_api.cpp
|
|
|
|
endif
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-03-22 08:48:10 -05:00
|
|
|
# Add all the source directories as include directories too
|
2012-04-10 20:37:55 -05:00
|
|
|
CINCS = ${addprefix -I ,${VPATH}}
|
|
|
|
CXXINCS = ${addprefix -I ,${VPATH}}
|
2011-11-05 08:13:20 -05:00
|
|
|
|
|
|
|
# Compiler flag to set the C Standard level.
|
2012-01-23 20:18:54 -06:00
|
|
|
# c89 - "ANSI" C
|
2011-11-05 08:13:20 -05:00
|
|
|
# gnu89 - c89 plus GCC extensions
|
2012-01-23 20:18:54 -06:00
|
|
|
# c99 - ISO C99 standard (not yet fully implemented)
|
2011-11-05 08:13:20 -05:00
|
|
|
# gnu99 - c99 plus GCC extensions
|
2012-01-23 20:18:54 -06:00
|
|
|
#CSTANDARD = -std=gnu99
|
2011-11-05 08:13:20 -05:00
|
|
|
CDEBUG = -g$(DEBUG)
|
2012-01-23 20:18:54 -06:00
|
|
|
CWARN = -Wall -Wstrict-prototypes
|
2012-03-22 08:48:10 -05:00
|
|
|
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
|
|
|
|
-fshort-enums -w -ffunction-sections -fdata-sections \
|
2012-11-11 04:05:52 -06:00
|
|
|
-DARDUINO=$(ARDUINO_VERSION)
|
|
|
|
ifneq ($(HARDWARE_MOTHERBOARD),)
|
2012-03-22 08:48:10 -05:00
|
|
|
CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
|
|
|
|
endif
|
2011-11-05 08:13:20 -05:00
|
|
|
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
2013-07-24 04:19:38 -05:00
|
|
|
CEXTRA = -fno-use-cxa-atexit
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-12-13 05:19:12 -06:00
|
|
|
CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
|
|
|
|
CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
|
|
|
|
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
|
|
|
LDFLAGS = -lm
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
# Programming support using avrdude. Settings and variables.
|
2012-11-11 04:05:52 -06:00
|
|
|
AVRDUDE_PORT = $(UPLOAD_PORT)
|
2015-01-12 23:01:43 -06:00
|
|
|
AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
|
2013-08-01 12:20:27 -05:00
|
|
|
ifeq ($(shell uname -s), Linux)
|
2015-07-20 06:37:39 -05:00
|
|
|
AVRDUDE_CONF = /etc/avrdude/avrdude.conf
|
2013-08-01 12:20:27 -05:00
|
|
|
else
|
|
|
|
AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
|
|
|
|
endif
|
2015-07-20 06:38:52 -05:00
|
|
|
AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
|
2015-01-18 11:18:43 -06:00
|
|
|
-p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
|
2015-01-12 23:01:43 -06:00
|
|
|
-b$(UPLOAD_RATE)
|
2011-11-05 08:13:20 -05:00
|
|
|
|
|
|
|
# Define all object files.
|
2012-11-11 04:05:52 -06:00
|
|
|
OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
|
|
|
|
OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
|
|
|
|
OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}}
|
2011-11-05 08:13:20 -05:00
|
|
|
|
|
|
|
# Define all listing files.
|
|
|
|
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
|
|
|
|
|
|
|
|
# Combine all necessary flags and optional flags.
|
|
|
|
# Add target processor to flags.
|
2012-01-23 20:18:54 -06:00
|
|
|
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
|
2012-03-22 08:48:10 -05:00
|
|
|
ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
|
|
|
|
ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2012-08-01 15:31:38 -05:00
|
|
|
# set V=1 (eg, "make V=1") to print the full commands etc.
|
|
|
|
ifneq ($V,1)
|
|
|
|
Pecho=@echo
|
|
|
|
P=@
|
|
|
|
else
|
|
|
|
Pecho=@:
|
|
|
|
P=
|
|
|
|
endif
|
2011-11-05 08:13:20 -05:00
|
|
|
|
|
|
|
# Default target.
|
2012-03-22 08:48:10 -05:00
|
|
|
all: sizeafter
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2013-06-06 17:49:25 -05:00
|
|
|
build: $(BUILD_DIR) elf hex
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-03-22 08:48:10 -05:00
|
|
|
# Creates the object directory
|
2013-06-06 17:49:25 -05:00
|
|
|
$(BUILD_DIR):
|
2012-11-11 04:05:52 -06:00
|
|
|
$P mkdir -p $(BUILD_DIR)
|
|
|
|
|
|
|
|
elf: $(BUILD_DIR)/$(TARGET).elf
|
|
|
|
hex: $(BUILD_DIR)/$(TARGET).hex
|
|
|
|
eep: $(BUILD_DIR)/$(TARGET).eep
|
2013-06-06 17:49:25 -05:00
|
|
|
lss: $(BUILD_DIR)/$(TARGET).lss
|
2012-11-11 04:05:52 -06:00
|
|
|
sym: $(BUILD_DIR)/$(TARGET).sym
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2013-06-06 17:49:25 -05:00
|
|
|
# Program the device.
|
2012-03-22 08:48:10 -05:00
|
|
|
# Do not try to reset an arduino if it's not one
|
2012-11-11 04:05:52 -06:00
|
|
|
upload: $(BUILD_DIR)/$(TARGET).hex
|
2012-03-22 08:48:10 -05:00
|
|
|
ifeq (${AVRDUDE_PROGRAMMER}, arduino)
|
2012-11-11 04:05:52 -06:00
|
|
|
stty hup < $(UPLOAD_PORT); true
|
2012-03-22 08:48:10 -05:00
|
|
|
endif
|
2011-11-05 08:13:20 -05:00
|
|
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
|
2012-03-22 08:48:10 -05:00
|
|
|
ifeq (${AVRDUDE_PROGRAMMER}, arduino)
|
2012-11-11 04:05:52 -06:00
|
|
|
stty -hup < $(UPLOAD_PORT); true
|
2012-03-22 08:48:10 -05:00
|
|
|
endif
|
2012-01-23 20:18:54 -06:00
|
|
|
|
|
|
|
# Display size of file.
|
2012-11-11 04:05:52 -06:00
|
|
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
|
|
|
|
ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
|
|
|
|
$(SIZE) $(BUILD_DIR)/$(TARGET).elf
|
2011-11-05 08:13:20 -05:00
|
|
|
sizebefore:
|
2012-11-11 04:05:52 -06:00
|
|
|
$P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-03-22 08:48:10 -05:00
|
|
|
sizeafter: build
|
2012-11-11 04:05:52 -06:00
|
|
|
$P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
|
|
|
COFFCONVERT=$(OBJCOPY) --debugging \
|
2012-01-25 03:46:27 -06:00
|
|
|
--change-section-address .data-0x800000 \
|
|
|
|
--change-section-address .bss-0x800000 \
|
|
|
|
--change-section-address .noinit-0x800000 \
|
2013-06-06 17:49:25 -05:00
|
|
|
--change-section-address .eeprom-0x810000
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
coff: $(BUILD_DIR)/$(TARGET).elf
|
|
|
|
$(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
extcoff: $(TARGET).elf
|
2012-11-11 04:05:52 -06:00
|
|
|
$(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
|
2011-11-05 08:13:20 -05:00
|
|
|
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
.SUFFIXES: .elf .hex .eep .lss .sym
|
2012-01-25 03:46:27 -06:00
|
|
|
.PRECIOUS: .o
|
2011-11-04 12:02:56 -05:00
|
|
|
|
|
|
|
.elf.hex:
|
2012-08-01 15:31:38 -05:00
|
|
|
$(Pecho) " COPY $@"
|
|
|
|
$P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
2011-11-05 08:13:20 -05:00
|
|
|
|
|
|
|
.elf.eep:
|
2012-01-23 20:18:54 -06:00
|
|
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
2012-01-25 03:46:27 -06:00
|
|
|
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
2011-11-05 08:13:20 -05:00
|
|
|
|
|
|
|
# Create extended listing file from ELF output file.
|
|
|
|
.elf.lss:
|
|
|
|
$(OBJDUMP) -h -S $< > $@
|
|
|
|
|
|
|
|
# Create a symbol table from ELF output file.
|
|
|
|
.elf.sym:
|
|
|
|
$(NM) -n $< > $@
|
|
|
|
|
2012-01-23 20:18:54 -06:00
|
|
|
# Link: create ELF output file from library.
|
2012-12-13 05:19:12 -06:00
|
|
|
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
|
2012-08-01 15:31:38 -05:00
|
|
|
$(Pecho) " CXX $@"
|
2012-12-13 05:19:12 -06:00
|
|
|
$P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS)
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
$(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
|
2012-12-09 12:19:57 -06:00
|
|
|
$(Pecho) " CC $<"
|
2012-08-01 15:31:38 -05:00
|
|
|
$P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
|
2012-03-22 08:48:10 -05:00
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
|
2012-12-09 12:19:57 -06:00
|
|
|
$(Pecho) " CXX $<"
|
2012-10-15 20:16:25 -05:00
|
|
|
$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
|
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
$(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
|
2012-12-09 12:19:57 -06:00
|
|
|
$(Pecho) " CXX $<"
|
2012-08-01 15:31:38 -05:00
|
|
|
$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
|
2012-03-22 08:48:10 -05:00
|
|
|
|
2011-11-05 08:13:20 -05:00
|
|
|
|
|
|
|
# Target: clean project.
|
2011-08-12 15:28:35 -05:00
|
|
|
clean:
|
2012-11-11 04:05:52 -06:00
|
|
|
$(Pecho) " RM $(BUILD_DIR)/*"
|
|
|
|
$P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \
|
|
|
|
$(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \
|
2012-01-25 03:46:27 -06:00
|
|
|
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
2012-11-11 04:05:52 -06:00
|
|
|
$(Pecho) " RMDIR $(BUILD_DIR)/"
|
|
|
|
$P rm -rf $(BUILD_DIR)
|
2012-03-22 08:48:10 -05:00
|
|
|
|
2012-01-23 20:18:54 -06:00
|
|
|
|
2012-11-11 04:05:52 -06:00
|
|
|
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
|
2012-03-22 08:48:10 -05:00
|
|
|
|
|
|
|
# Automaticaly include the dependency files created by gcc
|
2012-11-11 04:05:52 -06:00
|
|
|
-include ${wildcard $(BUILD_DIR)/*.d}
|