2012-02-28 10:06:56 +01:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Arduino command line tools Makefile
|
|
|
|
# System part (i.e. project independent)
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010,2011,2012 Martin Oldfield <m@mjo.tc>, based on
|
|
|
|
# work that is copyright Nicholas Zambetti, David A. Mellis & Hernando
|
|
|
|
# Barragan.
|
2012-07-05 19:45:52 +02:00
|
|
|
#
|
2012-02-28 10:06:56 +01:00
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# Version 0.1 17.ii.2009 M J Oldfield
|
|
|
|
#
|
|
|
|
# 0.2 22.ii.2009 M J Oldfield
|
|
|
|
# - fixes so that the Makefile actually works!
|
|
|
|
# - support for uploading via ISP
|
|
|
|
# - orthogonal choices of using the Arduino for
|
|
|
|
# tools, libraries and uploading
|
|
|
|
#
|
|
|
|
# 0.3 21.v.2010 M J Oldfield
|
|
|
|
# - added proper license statement
|
|
|
|
# - added code from Philip Hands to reset
|
|
|
|
# Arduino prior to upload
|
|
|
|
#
|
|
|
|
# 0.4 25.v.2010 M J Oldfield
|
|
|
|
# - tweaked reset target on Philip Hands' advice
|
|
|
|
#
|
|
|
|
# 0.5 23.iii.2011 Stefan Tomanek
|
|
|
|
# - added ad-hoc library building
|
|
|
|
# 17.v.2011 M J Oldfield
|
|
|
|
# - grabbed said version from Ubuntu
|
|
|
|
#
|
|
|
|
# 0.6 22.vi.2011 M J Oldfield
|
|
|
|
# - added ard-parse-boards supports
|
2012-07-05 19:45:52 +02:00
|
|
|
# - added -lc to linker opts,
|
2012-02-28 10:06:56 +01:00
|
|
|
# on Fabien Le Lez's advice
|
|
|
|
#
|
|
|
|
# 0.7 12.vii.2011 M J Oldfield
|
|
|
|
# - moved -lm to the end of linker opts,
|
|
|
|
# to solve Frank Knopf's problem;
|
2012-07-05 19:45:52 +02:00
|
|
|
# - added -F to stty opts: Craig Hollabaugh
|
2012-02-28 10:06:56 +01:00
|
|
|
# reckons it's good for Ubuntu
|
|
|
|
#
|
|
|
|
# 0.8 12.ii.2012 M J Oldfield
|
|
|
|
# - Patches for Arduino 1.0 IDE:
|
|
|
|
# support .ino files;
|
|
|
|
# handle board 'variants';
|
|
|
|
# tweaked compile flags.
|
|
|
|
# - Build a library from all the system
|
|
|
|
# supplied code rather than linking the .o
|
|
|
|
# files directly.
|
|
|
|
# - Let TARGET default to current directory
|
|
|
|
# as per Daniele Vergini's patch.
|
|
|
|
# - Add support for .c files in system
|
|
|
|
# libraries: Dirk-Willem van Gulik and Evan
|
|
|
|
# Goldenberg both reported this and
|
|
|
|
# provided patches in the same spirit.
|
|
|
|
#
|
2012-04-27 00:11:25 +02:00
|
|
|
# 0.9 26.iv.2012 M J Oldfield
|
2012-04-29 13:06:41 +02:00
|
|
|
# - Allow the punter to specify boards.txt
|
|
|
|
# file and parser independently (after
|
|
|
|
# Peplin and Brotchie on github)
|
2012-04-27 00:16:23 +02:00
|
|
|
# - Support user libraries (Peplin's patch)
|
2012-04-27 13:48:36 +02:00
|
|
|
# - Remove main.cpp if NO_CORE_MAIN_CPP is
|
|
|
|
# defined (ex Peplin)
|
2012-04-29 13:06:41 +02:00
|
|
|
# - Added a monitor target which talks to the
|
|
|
|
# Arduino serial port (Peplin's suggestion)
|
2012-07-05 19:45:52 +02:00
|
|
|
# - Rejigged PATH calculations for general
|
2012-04-29 19:55:17 +02:00
|
|
|
# tidiness (ex Peplin)
|
|
|
|
# - Moved the reset target to Perl for
|
|
|
|
# clarity and better error handling (ex
|
|
|
|
# Daniele Vergini)
|
2012-07-05 19:45:52 +02:00
|
|
|
#
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# PATHS YOU NEED TO SET UP
|
|
|
|
#
|
|
|
|
# I've reworked the way paths to executables are constructed in this
|
|
|
|
# version (0.9) of the Makefile.
|
|
|
|
#
|
|
|
|
# We need to worry about three different sorts of file:
|
|
|
|
#
|
|
|
|
# 1. Things which are included in this distribution e.g. ard-parse-boards
|
|
|
|
# => ARDMK_DIR
|
|
|
|
#
|
2012-07-05 19:45:52 +02:00
|
|
|
# 2. Things which are always in the Arduino distribution e.g.
|
2012-04-29 19:55:17 +02:00
|
|
|
# boards.txt, libraries, &c.
|
|
|
|
# => ARDUINO_DIR
|
|
|
|
#
|
|
|
|
# 3. Things which might be bundled with the Arduino distribution, but
|
|
|
|
# might come from the system. Most of the toolchain is like this:
|
|
|
|
# on Linux it's supplied by the system.
|
|
|
|
# => AVR_TOOLS_DIR
|
|
|
|
#
|
|
|
|
# Having set these three variables, we can work out the rest assuming
|
|
|
|
# that things are canonically arranged beneath the directories defined
|
|
|
|
# above.
|
|
|
|
#
|
|
|
|
# On the Mac you might want to set:
|
|
|
|
#
|
|
|
|
# ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java
|
|
|
|
# ARDMK_DIR = /usr/local
|
|
|
|
#
|
|
|
|
# On Linux, you might prefer:
|
|
|
|
#
|
|
|
|
# ARDUINO_DIR = /usr/share/arduino
|
|
|
|
# ARDMK_DIR = /usr/local
|
|
|
|
# AVR_TOOLS_DIR = /usr
|
|
|
|
#
|
2012-07-05 19:45:52 +02:00
|
|
|
# You can either set these up in the Makefile, or put them in your
|
2012-04-29 19:55:17 +02:00
|
|
|
# environment e.g. in your .bashrc
|
|
|
|
#
|
2012-07-05 19:57:24 +02:00
|
|
|
# If you don't specify these, we can try to guess, but that might not work
|
|
|
|
# or work the way you want it to.
|
|
|
|
#
|
2012-04-29 19:55:17 +02:00
|
|
|
# If you don't install the ard-... binaries to /usr/local/bin, but
|
|
|
|
# instead copy them to e.g. /home/mjo/arduino.mk/bin then set
|
|
|
|
# ARDML_DIR = /home/mjo/arduino.mk
|
2012-07-05 19:45:52 +02:00
|
|
|
#
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# DEPENDENCIES
|
|
|
|
#
|
|
|
|
# The Perl programs need a couple of libraries:
|
|
|
|
# YAML
|
|
|
|
# Device::SerialPort
|
2012-04-27 00:11:25 +02:00
|
|
|
#
|
2012-02-28 10:06:56 +01:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# STANDARD ARDUINO WORKFLOW
|
|
|
|
#
|
|
|
|
# Given a normal sketch directory, all you need to do is to create
|
|
|
|
# a small Makefile which defines a few things, and then includes this one.
|
|
|
|
#
|
|
|
|
# For example:
|
|
|
|
#
|
|
|
|
# ARDUINO_LIBS = Ethernet Ethernet/utility SPI
|
|
|
|
# BOARD_TAG = uno
|
|
|
|
# ARDUINO_PORT = /dev/cu.usb*
|
|
|
|
#
|
|
|
|
# include /usr/local/share/Arduino.mk
|
|
|
|
#
|
|
|
|
# Hopefully these will be self-explanatory but in case they're not:
|
|
|
|
#
|
|
|
|
# ARDUINO_LIBS - A list of any libraries used by the sketch (we
|
2012-07-05 19:58:05 +02:00
|
|
|
# assume these are in $(ARDUINO_DIR)/hardware/libraries
|
|
|
|
# or your sketchbook's libraries directory)
|
2012-02-28 10:06:56 +01:00
|
|
|
#
|
|
|
|
# ARDUINO_PORT - The port where the Arduino can be found (only needed
|
2012-07-05 19:57:32 +02:00
|
|
|
# when uploading)
|
2012-02-28 10:06:56 +01:00
|
|
|
#
|
|
|
|
# BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega
|
|
|
|
# 'make show_boards' shows a list
|
|
|
|
#
|
2012-07-05 19:58:32 +02:00
|
|
|
# If you have your additional libraries relative to your source, rather
|
|
|
|
# than in your "sketchbook", also set USER_LIB_PATH, like this example:
|
|
|
|
#
|
|
|
|
# USER_LIB_PATH := $(realpath ../../libraries)
|
|
|
|
#
|
|
|
|
# If you've added the Arduino-Makefile repository to your git repo as a
|
|
|
|
# submodule (or other similar arrangement), you might have lines like this
|
|
|
|
# in your Makefile:
|
|
|
|
#
|
|
|
|
# ARDMK_DIR := $(realpath ../../tools/Arduino-Makefile)
|
|
|
|
# include $(ARDMK_DIR)/arduino-mk/Arduino.mk
|
|
|
|
#
|
|
|
|
# In any case, once this file has been created the typical workflow is just
|
2012-02-28 10:06:56 +01:00
|
|
|
#
|
|
|
|
# $ make upload
|
|
|
|
#
|
|
|
|
# All of the object files are created in the build-cli subdirectory
|
|
|
|
# All sources should be in the current directory and can include:
|
|
|
|
# - at most one .pde or .ino file which will be treated as C++ after
|
|
|
|
# the standard Arduino header and footer have been affixed.
|
|
|
|
# - any number of .c, .cpp, .s and .h files
|
|
|
|
#
|
|
|
|
# Included libraries are built in the build-cli/libs subdirectory.
|
|
|
|
#
|
|
|
|
# Besides make upload you can also
|
|
|
|
# make - no upload
|
|
|
|
# make clean - remove all our dependencies
|
|
|
|
# make depends - update dependencies
|
|
|
|
# make reset - reset the Arduino by tickling DTR on the serial port
|
|
|
|
# make raw_upload - upload without first resetting
|
|
|
|
# make show_boards - list all the boards defined in boards.txt
|
2012-04-29 13:06:41 +02:00
|
|
|
# make monitor - connect to the Arduino's serial port
|
2012-07-05 19:57:45 +02:00
|
|
|
# make size - show the size of the compiled output (relative to
|
|
|
|
# resources, if you have a patched avr-size)
|
|
|
|
# make disasm - generate a .lss file in build-cli that contains
|
|
|
|
# disassembly of the compiled file interspersed
|
|
|
|
# with your original source code.
|
2012-04-29 13:06:41 +02:00
|
|
|
#
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# SERIAL MONITOR
|
|
|
|
#
|
|
|
|
# The serial monitor just invokes the GNU screen program with suitable
|
2012-07-05 19:45:52 +02:00
|
|
|
# options. For more information see screen (1) and search for
|
2012-04-29 13:06:41 +02:00
|
|
|
# 'character special device'.
|
|
|
|
#
|
|
|
|
# The really useful thing to know is that ^A-k gets you out!
|
|
|
|
#
|
|
|
|
# The fairly useful thing to know is that you can bind another key to
|
|
|
|
# escape too, by creating $HOME{.screenrc} containing e.g.
|
|
|
|
#
|
|
|
|
# bindkey ^C kill
|
|
|
|
#
|
|
|
|
# If you want to change the baudrate, just set MONITOR_BAUDRATE. If you
|
|
|
|
# don't set it, it defaults to 9600 baud.
|
2012-02-28 10:06:56 +01:00
|
|
|
#
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# ARDUINO WITH ISP
|
|
|
|
#
|
|
|
|
# You need to specify some details of your ISP programmer and might
|
|
|
|
# also need to specify the fuse values:
|
|
|
|
#
|
|
|
|
# ISP_PROG = -c stk500v2
|
|
|
|
# ISP_PORT = /dev/ttyACM0
|
|
|
|
#
|
|
|
|
# You might also need to set the fuse bits, but typically they'll be
|
|
|
|
# read from boards.txt, based on the BOARD_TAG variable:
|
2012-07-05 19:45:52 +02:00
|
|
|
#
|
2012-02-28 10:06:56 +01:00
|
|
|
# ISP_LOCK_FUSE_PRE = 0x3f
|
|
|
|
# ISP_LOCK_FUSE_POST = 0xcf
|
|
|
|
# ISP_HIGH_FUSE = 0xdf
|
|
|
|
# ISP_LOW_FUSE = 0xff
|
|
|
|
# ISP_EXT_FUSE = 0x01
|
|
|
|
#
|
|
|
|
# I think the fuses here are fine for uploading to the ATmega168
|
|
|
|
# without bootloader.
|
2012-07-05 19:45:52 +02:00
|
|
|
#
|
2012-02-28 10:06:56 +01:00
|
|
|
# To actually do this upload use the ispload target:
|
|
|
|
#
|
|
|
|
# make ispload
|
|
|
|
#
|
|
|
|
#
|
|
|
|
########################################################################
|
|
|
|
|
2012-07-05 20:58:54 +02:00
|
|
|
# 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
|
2012-07-05 20:59:12 +02:00
|
|
|
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
|
2012-07-05 20:58:54 +02:00
|
|
|
|
|
|
|
# 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 --bytes=$(2))
|
|
|
|
|
|
|
|
# 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_info = $(info - $(call space_pad_to,$(2),20) $(1) = $($(1)) $(3))
|
|
|
|
|
|
|
|
# Just a nice simple visual separator
|
|
|
|
show_separator = $(info -------------------------)
|
|
|
|
|
|
|
|
|
|
|
|
$(call show_separator)
|
|
|
|
$(info Arduino.mk Configuration:)
|
2012-06-29 01:28:22 +02:00
|
|
|
|
|
|
|
ifndef ARDUINO_DIR
|
2012-07-05 21:39:32 +02:00
|
|
|
AUTO_ARDUINO_DIR := $(firstword \
|
|
|
|
$(call dir_if_exists,/usr/share/arduino) \
|
|
|
|
$(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) )
|
|
|
|
ifdef AUTO_ARDUINO_DIR
|
|
|
|
ARDUINO_DIR = $(AUTO_ARDUINO_DIR)
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,ARDUINO_DIR,[AUTODETECTED])
|
|
|
|
endif
|
2012-07-05 20:58:54 +02:00
|
|
|
|
|
|
|
else
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,ARDUINO_DIR)
|
2012-06-29 01:28:22 +02:00
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
########################################################################
|
2012-07-05 19:45:52 +02:00
|
|
|
#
|
2012-02-28 10:06:56 +01:00
|
|
|
# Default TARGET to cwd (ex Daniele Vergini)
|
|
|
|
ifndef TARGET
|
2012-07-05 21:04:35 +02:00
|
|
|
TARGET = $(notdir $(CURDIR))
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Arduino version number
|
|
|
|
ifndef ARDUINO_VERSION
|
2012-07-05 19:29:33 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
# Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes.
|
|
|
|
# Works for 1.0 and 1.0.1
|
|
|
|
AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3)
|
|
|
|
ifdef AUTO_ARDUINO_VERSION
|
|
|
|
ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION)
|
|
|
|
$(call show_config_info,ARDUINO_VERSION,[AUTODETECTED])
|
|
|
|
else
|
|
|
|
ARDUINO_VERSION = 100
|
|
|
|
$(call show_config_info,ARDUINO_VERSION,[DEFAULT])
|
|
|
|
endif
|
2012-07-05 19:29:33 +02:00
|
|
|
else
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,ARDUINO_VERSION)
|
2012-07-05 19:29:33 +02:00
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
# Arduino and system paths
|
2012-02-28 10:06:56 +01:00
|
|
|
#
|
2012-04-29 19:55:17 +02:00
|
|
|
ifdef ARDUINO_DIR
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
ifndef AVR_TOOLS_DIR
|
2012-06-29 01:32:23 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr)
|
|
|
|
ifdef BUNDLED_AVR_TOOLS_DIR
|
|
|
|
AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR)
|
|
|
|
# The avrdude bundled with Arduino can't find it's config
|
|
|
|
AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf
|
|
|
|
$(call show_config_info,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution))
|
2012-06-29 01:32:23 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
else
|
2012-06-29 01:32:23 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..))
|
|
|
|
ifdef SYSTEMPATH_AVR_TOOLS_DIR
|
|
|
|
AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
|
|
|
|
$(call show_config_info,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
|
|
|
|
endif # SYSTEMPATH_AVR_TOOLS_DIR
|
2012-06-29 01:32:23 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
endif # BUNDLED_AVR_TOOLS_DIR
|
2012-06-29 01:32:23 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
else
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,AVR_TOOLS_DIR)
|
|
|
|
endif #ndef AVR_TOOLS_DIR
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries
|
|
|
|
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
|
|
|
|
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants
|
2012-04-29 19:55:17 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
echo $(error "ARDUINO_DIR is not defined")
|
2012-04-29 19:55:17 +02:00
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
2012-07-05 20:58:54 +02:00
|
|
|
ifdef AVR_TOOLS_DIR
|
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
ifndef AVR_TOOLS_PATH
|
|
|
|
AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin
|
|
|
|
endif
|
2012-07-05 20:58:54 +02:00
|
|
|
|
|
|
|
endif
|
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
# Makefile distribution path
|
|
|
|
#
|
|
|
|
ifdef ARDMK_DIR
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,ARDMK_DIR)
|
2012-04-29 19:55:17 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
ifndef ARDMK_PATH
|
|
|
|
ARDMK_PATH = $(ARDMK_DIR)/bin
|
|
|
|
$(call show_config_info,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR))
|
2012-07-05 20:58:54 +02:00
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
else
|
|
|
|
$(call show_config_info,ARDMK_PATH)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
else
|
|
|
|
|
2012-07-05 21:04:35 +02:00
|
|
|
echo $(error "ARDMK_DIR is not defined")
|
2012-04-29 19:55:17 +02:00
|
|
|
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
# Miscellanea
|
|
|
|
#
|
2012-03-26 05:54:21 +02:00
|
|
|
ifndef ARDUINO_SKETCHBOOK
|
2012-07-05 21:04:35 +02:00
|
|
|
ARDUINO_SKETCHBOOK = $(HOME)/sketchbook
|
2012-03-26 05:54:21 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef USER_LIB_PATH
|
2012-07-05 21:04:35 +02:00
|
|
|
USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries
|
|
|
|
$(call show_config_info,USER_LIB_PATH,[DEFAULT],(in user sketchbook))
|
2012-07-05 20:58:54 +02:00
|
|
|
else
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,USER_LIB_PATH)
|
2012-03-26 05:54:21 +02:00
|
|
|
endif
|
|
|
|
|
2012-04-29 13:06:41 +02:00
|
|
|
########################################################################
|
|
|
|
# Serial monitor (just a screen wrapper)
|
|
|
|
#
|
|
|
|
# Quite how to construct the monitor command seems intimately tied
|
|
|
|
# to the command we're using (here screen). So, read the screen docs
|
|
|
|
# for more information (search for 'character special device').
|
|
|
|
#
|
|
|
|
ifndef MONITOR_BAUDRATE
|
2012-07-05 21:04:35 +02:00
|
|
|
MONITOR_BAUDRATE = 9600
|
2012-04-29 13:06:41 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef MONITOR_CMD
|
2012-07-05 21:04:35 +02:00
|
|
|
MONITOR_CMD = screen
|
2012-04-29 13:06:41 +02:00
|
|
|
endif
|
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
# Reset
|
|
|
|
ifndef RESET_CMD
|
2012-07-05 21:04:35 +02:00
|
|
|
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS)
|
2012-04-29 19:55:17 +02:00
|
|
|
endif
|
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
########################################################################
|
|
|
|
# boards.txt parsing
|
|
|
|
#
|
|
|
|
ifndef BOARD_TAG
|
2012-07-05 21:04:35 +02:00
|
|
|
BOARD_TAG = uno
|
|
|
|
$(call show_config_info,BOARD_TAG,[DEFAULT])
|
2012-07-05 20:58:54 +02:00
|
|
|
else
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,BOARD_TAG)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef BOARDS_TXT
|
2012-07-05 21:04:35 +02:00
|
|
|
BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef PARSE_BOARD
|
2012-07-05 21:04:35 +02:00
|
|
|
PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards
|
2012-04-27 00:11:25 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef PARSE_BOARD_OPTS
|
2012-07-05 21:04:35 +02:00
|
|
|
PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT)
|
2012-04-27 00:11:25 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef PARSE_BOARD_CMD
|
2012-07-05 21:04:35 +02:00
|
|
|
PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Which variant ? This affects the include path
|
|
|
|
ifndef VARIANT
|
2012-07-05 21:04:35 +02:00
|
|
|
VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# processor stuff
|
|
|
|
ifndef MCU
|
2012-07-05 21:04:35 +02:00
|
|
|
MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef F_CPU
|
2012-07-05 21:04:35 +02:00
|
|
|
F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# normal programming info
|
|
|
|
ifndef AVRDUDE_ARD_PROGRAMMER
|
2012-07-05 21:04:35 +02:00
|
|
|
AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef AVRDUDE_ARD_BAUDRATE
|
2012-07-05 21:04:35 +02:00
|
|
|
AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# fuses if you're using e.g. ISP
|
|
|
|
ifndef ISP_LOCK_FUSE_PRE
|
2012-07-05 21:04:35 +02:00
|
|
|
ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef ISP_LOCK_FUSE_POST
|
2012-07-05 21:04:35 +02:00
|
|
|
ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef ISP_HIGH_FUSE
|
2012-07-05 21:04:35 +02:00
|
|
|
ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef ISP_LOW_FUSE
|
2012-07-05 21:04:35 +02:00
|
|
|
ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef ISP_EXT_FUSE
|
2012-07-05 21:04:35 +02:00
|
|
|
ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Everything gets built in here
|
|
|
|
OBJDIR = build-cli
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Local sources
|
|
|
|
#
|
|
|
|
LOCAL_C_SRCS = $(wildcard *.c)
|
|
|
|
LOCAL_CPP_SRCS = $(wildcard *.cpp)
|
|
|
|
LOCAL_CC_SRCS = $(wildcard *.cc)
|
|
|
|
LOCAL_PDE_SRCS = $(wildcard *.pde)
|
|
|
|
LOCAL_INO_SRCS = $(wildcard *.ino)
|
|
|
|
LOCAL_AS_SRCS = $(wildcard *.S)
|
|
|
|
LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
|
|
|
|
$(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \
|
|
|
|
$(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o)
|
|
|
|
LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES))
|
|
|
|
|
|
|
|
# Dependency files
|
|
|
|
DEPS = $(LOCAL_OBJS:.o=.d)
|
|
|
|
|
|
|
|
# core sources
|
|
|
|
ifeq ($(strip $(NO_CORE)),)
|
2012-07-05 21:04:35 +02:00
|
|
|
ifdef ARDUINO_CORE_PATH
|
|
|
|
CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c)
|
|
|
|
CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
|
|
|
|
|
|
|
|
ifneq ($(strip $(NO_CORE_MAIN_CPP)),)
|
|
|
|
CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS))
|
|
|
|
$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE_MAIN_CPP))
|
|
|
|
endif
|
|
|
|
|
|
|
|
CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o)
|
|
|
|
CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \
|
|
|
|
$(OBJDIR)/%,$(CORE_OBJ_FILES))
|
|
|
|
endif
|
2012-07-05 20:58:54 +02:00
|
|
|
else
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE))
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Rules for making stuff
|
|
|
|
#
|
|
|
|
|
|
|
|
# The name of the main targets
|
|
|
|
TARGET_HEX = $(OBJDIR)/$(TARGET).hex
|
|
|
|
TARGET_ELF = $(OBJDIR)/$(TARGET).elf
|
|
|
|
TARGETS = $(OBJDIR)/$(TARGET).*
|
|
|
|
CORE_LIB = $(OBJDIR)/libcore.a
|
|
|
|
|
|
|
|
# A list of dependencies
|
|
|
|
DEP_FILE = $(OBJDIR)/depends.mk
|
|
|
|
|
|
|
|
# Names of executables
|
|
|
|
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
|
|
|
|
REMOVE = rm -f
|
|
|
|
MV = mv -f
|
|
|
|
CAT = cat
|
|
|
|
ECHO = echo
|
|
|
|
|
|
|
|
# General arguments
|
2012-07-05 21:39:50 +02:00
|
|
|
SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)))
|
|
|
|
USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)))
|
2012-02-28 10:06:56 +01:00
|
|
|
SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS))
|
2012-04-01 00:48:20 +02:00
|
|
|
USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS))
|
2012-02-28 10:06:56 +01:00
|
|
|
LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))
|
|
|
|
LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS)))
|
2012-04-01 00:48:20 +02:00
|
|
|
USER_LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(USER_LIBS)))
|
|
|
|
USER_LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(USER_LIBS)))
|
2012-02-28 10:06:56 +01:00
|
|
|
LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SRCS)) \
|
|
|
|
$(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS))
|
2012-04-01 00:48:20 +02:00
|
|
|
USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(USER_LIB_CPP_SRCS)) \
|
2012-03-26 05:54:21 +02:00
|
|
|
$(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(USER_LIB_C_SRCS))
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \
|
|
|
|
-I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
|
2012-04-01 00:48:20 +02:00
|
|
|
$(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \
|
2012-02-28 10:06:56 +01:00
|
|
|
-ffunction-sections -fdata-sections
|
|
|
|
CFLAGS = -std=gnu99
|
|
|
|
CXXFLAGS = -fno-exceptions
|
|
|
|
ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp
|
|
|
|
LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os
|
|
|
|
|
|
|
|
# Expand and pick the first port
|
|
|
|
ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT)))
|
|
|
|
|
2012-07-05 20:58:54 +02:00
|
|
|
ifndef SIZE_UTILITY_TYPE
|
2012-07-05 21:04:35 +02:00
|
|
|
# Command for avr_size: do $(call avr_size,elffile,hexfile)
|
|
|
|
ifneq (,$(findstring AVR,$(shell $(SIZE) --help)))
|
|
|
|
SIZE_UTILITY_TYPE = AVR_ENHANCED
|
|
|
|
else
|
|
|
|
SIZE_UTILITY_TYPE = BASIC
|
|
|
|
endif
|
|
|
|
$(call show_config_info,SIZE_UTILITY_TYPE,[AUTODETECTED])
|
2012-07-05 20:58:54 +02:00
|
|
|
|
2012-07-05 19:45:05 +02:00
|
|
|
else
|
2012-07-05 21:04:35 +02:00
|
|
|
$(call show_config_info,SIZE_UTILITY_TYPE,[MANUAL OVERRIDE],Warning - Manually overriding this is not recommended!)
|
2012-07-05 20:58:54 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(SIZE_UTILITY_TYPE),BASIC)
|
2012-07-05 21:04:35 +02:00
|
|
|
# We have a plain-old binutils version - just give it the hex.
|
|
|
|
avr_size = $(SIZE) $(2)
|
2012-07-05 19:45:05 +02:00
|
|
|
endif
|
|
|
|
|
2012-07-05 20:58:54 +02:00
|
|
|
ifeq ($(SIZE_UTILITY_TYPE),AVR_ENHANCED)
|
2012-07-05 21:04:35 +02:00
|
|
|
# We have a patched version of binutils that mentions AVR - pass the MCU
|
|
|
|
# and the elf to get nice output.
|
|
|
|
avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1)
|
2012-07-05 20:58:54 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef avr_size
|
2012-07-05 21:04:35 +02:00
|
|
|
$(error "We told you not to override SIZE_UTILITY_TYPE!")
|
2012-07-05 20:58:54 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# end of config output
|
|
|
|
$(call show_separator)
|
|
|
|
|
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
# Implicit rules for building everything (needed to get everything in
|
|
|
|
# the right directory)
|
|
|
|
#
|
|
|
|
# Rather than mess around with VPATH there are quasi-duplicate rules
|
|
|
|
# here for building e.g. a system C++ file and a local C++
|
|
|
|
# file. Besides making things simpler now, this would also make it
|
|
|
|
# easy to change the build options in future
|
|
|
|
|
|
|
|
# library sources
|
|
|
|
$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(CC) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
|
|
|
|
2012-03-26 05:54:21 +02:00
|
|
|
$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
# normal local sources
|
|
|
|
# .o rules are for objects, .d for dependency tracking
|
|
|
|
# there seems to be an awful lot of duplication here!!!
|
|
|
|
$(OBJDIR)/%.o: %.c
|
|
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.o: %.cc
|
|
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.o: %.cpp
|
|
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.o: %.S
|
|
|
|
$(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.o: %.s
|
|
|
|
$(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.d: %.c
|
|
|
|
$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
|
|
|
|
|
|
|
$(OBJDIR)/%.d: %.cc
|
|
|
|
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
|
|
|
|
|
|
|
$(OBJDIR)/%.d: %.cpp
|
|
|
|
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
|
|
|
|
|
|
|
$(OBJDIR)/%.d: %.S
|
|
|
|
$(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
|
|
|
|
|
|
|
$(OBJDIR)/%.d: %.s
|
|
|
|
$(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
|
|
|
|
|
|
|
# the pde -> cpp -> o file
|
|
|
|
$(OBJDIR)/%.cpp: %.pde
|
|
|
|
$(ECHO) '#include "WProgram.h"' > $@
|
|
|
|
$(CAT) $< >> $@
|
|
|
|
|
|
|
|
# the ino -> cpp -> o file
|
|
|
|
$(OBJDIR)/%.cpp: %.ino
|
|
|
|
$(ECHO) '#include <Arduino.h>' > $@
|
|
|
|
$(CAT) $< >> $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.o: $(OBJDIR)/%.cpp
|
|
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.d: $(OBJDIR)/%.cpp
|
|
|
|
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
|
|
|
|
|
|
|
# core files
|
|
|
|
$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c
|
|
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp
|
|
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
|
|
|
|
|
|
|
# various object conversions
|
|
|
|
$(OBJDIR)/%.hex: $(OBJDIR)/%.elf
|
|
|
|
$(OBJCOPY) -O ihex -R .eeprom $< $@
|
2012-07-05 20:58:54 +02:00
|
|
|
@echo
|
|
|
|
@echo
|
2012-07-05 19:45:19 +02:00
|
|
|
$(call avr_size,$<,$@)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
$(OBJDIR)/%.eep: $(OBJDIR)/%.elf
|
|
|
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
|
|
--change-section-lma .eeprom=0 -O ihex $< $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.lss: $(OBJDIR)/%.elf
|
|
|
|
$(OBJDUMP) -h -S $< > $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.sym: $(OBJDIR)/%.elf
|
|
|
|
$(NM) -n $< > $@
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Avrdude
|
|
|
|
#
|
|
|
|
ifndef AVRDUDE
|
2012-07-05 21:04:35 +02:00
|
|
|
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
AVRDUDE_COM_OPTS = -q -V -p $(MCU)
|
|
|
|
ifdef AVRDUDE_CONF
|
2012-07-05 21:04:35 +02:00
|
|
|
AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF)
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT)
|
|
|
|
|
|
|
|
ifndef ISP_PROG
|
2012-07-05 21:04:35 +02:00
|
|
|
ISP_PROG = -c stk500v2
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG)
|
|
|
|
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Explicit targets start here
|
|
|
|
#
|
|
|
|
|
|
|
|
all: $(OBJDIR) $(TARGET_HEX)
|
|
|
|
|
|
|
|
$(OBJDIR):
|
|
|
|
mkdir $(OBJDIR)
|
|
|
|
|
|
|
|
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm
|
|
|
|
|
2012-04-01 00:48:20 +02:00
|
|
|
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
|
|
|
|
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
$(DEP_FILE): $(OBJDIR) $(DEPS)
|
|
|
|
cat $(DEPS) > $(DEP_FILE)
|
|
|
|
|
|
|
|
upload: reset raw_upload
|
|
|
|
|
|
|
|
raw_upload: $(TARGET_HEX)
|
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
|
|
|
|
-U flash:w:$(TARGET_HEX):i
|
|
|
|
|
2012-07-05 19:45:52 +02:00
|
|
|
reset:
|
2012-04-29 19:55:17 +02:00
|
|
|
$(RESET_CMD) $(ARD_PORT)
|
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
# stty on MacOS likes -F, but on Debian it likes -f redirecting
|
|
|
|
# stdin/out appears to work but generates a spurious error on MacOS at
|
|
|
|
# least. Perhaps it would be better to just do it in perl ?
|
2012-07-05 19:45:52 +02:00
|
|
|
reset_stty:
|
2012-02-28 10:06:56 +01:00
|
|
|
for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \
|
|
|
|
do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \
|
|
|
|
done ;\
|
|
|
|
$$STTYF $(ARD_PORT) hupcl ;\
|
|
|
|
(sleep 0.1 || sleep 1) ;\
|
2012-07-05 19:45:52 +02:00
|
|
|
$$STTYF $(ARD_PORT) -hupcl
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
ispload: $(TARGET_HEX)
|
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \
|
|
|
|
-U lock:w:$(ISP_LOCK_FUSE_PRE):m \
|
|
|
|
-U hfuse:w:$(ISP_HIGH_FUSE):m \
|
|
|
|
-U lfuse:w:$(ISP_LOW_FUSE):m \
|
|
|
|
-U efuse:w:$(ISP_EXT_FUSE):m
|
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -D \
|
|
|
|
-U flash:w:$(TARGET_HEX):i
|
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \
|
|
|
|
-U lock:w:$(ISP_LOCK_FUSE_POST):m
|
|
|
|
|
|
|
|
clean:
|
2012-04-01 00:48:20 +02:00
|
|
|
$(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
depends: $(DEPS)
|
|
|
|
cat $(DEPS) > $(DEP_FILE)
|
|
|
|
|
|
|
|
size: $(OBJDIR) $(TARGET_HEX)
|
2012-07-05 19:45:05 +02:00
|
|
|
$(call avr_size,$(TARGET_ELF),$(TARGET_HEX))
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-07-05 19:45:52 +02:00
|
|
|
show_boards:
|
2012-04-27 15:52:10 +02:00
|
|
|
$(PARSE_BOARD_CMD) --boards
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-04-29 13:06:41 +02:00
|
|
|
monitor:
|
|
|
|
$(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE)
|
|
|
|
|
2012-07-03 19:36:00 +02:00
|
|
|
disasm: all $(OBJDIR)/$(TARGET).lss
|
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
include $(DEP_FILE)
|