2012-02-28 10:06:56 +01:00
|
|
|
########################################################################
|
|
|
|
#
|
2013-05-31 06:12:44 +02:00
|
|
|
# Makefile for compiling Arduino sketches from command line
|
2012-02-28 10:06:56 +01:00
|
|
|
# System part (i.e. project independent)
|
|
|
|
#
|
2012-07-06 08:42:43 +02:00
|
|
|
# Copyright (C) 2012 Sudar <http://sudarmuthu.com>, based on
|
|
|
|
# - M J Oldfield work: https://github.com/mjoldfield/Arduino-Makefile
|
|
|
|
#
|
2012-02-28 10:06:56 +01:00
|
|
|
# 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
|
|
|
|
#
|
2013-06-15 16:18:47 +02:00
|
|
|
# Current version: 0.11.0
|
2013-05-31 05:59:36 +02:00
|
|
|
#
|
|
|
|
# Refer to HISTORY.md file for complete history of changes
|
2012-11-17 22:18:56 +01:00
|
|
|
#
|
2012-07-14 08:51:54 +02:00
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# PATHS YOU NEED TO SET UP
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# 2. Things which are always in the Arduino distribution e.g.
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# You can either set these up in the Makefile, or put them in your
|
|
|
|
# environment e.g. in your .bashrc
|
|
|
|
#
|
|
|
|
# If you don't specify these, we can try to guess, but that might not work
|
|
|
|
# or work the way you want it to.
|
|
|
|
#
|
|
|
|
# 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-11-01 16:33:46 +01:00
|
|
|
# If you'd rather not see the configuration output, define ARDUINO_QUIET.
|
|
|
|
#
|
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
|
|
|
|
#
|
2013-06-12 09:17:34 +02:00
|
|
|
# All of the object files are created in the build-{BOARD_TAG} subdirectory
|
2012-02-28 10:06:56 +01:00
|
|
|
# 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
|
|
|
|
#
|
2013-06-12 09:17:34 +02:00
|
|
|
# Included libraries are built in the build-{BOARD_TAG}/libs subdirectory.
|
2012-02-28 10:06:56 +01:00
|
|
|
#
|
|
|
|
# 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-12-15 14:27:08 +01:00
|
|
|
# make verify_size - Verify that the size of the final file is less than
|
|
|
|
# the capacity of the micro controller.
|
2012-12-16 17:06:23 +01:00
|
|
|
# make eeprom - upload the eep file
|
|
|
|
# make raw_eeprom - upload the eep file without first resetting
|
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
|
2012-08-19 08:36:40 +02:00
|
|
|
# don't set it, it tries to read from the sketch. If it couldn't read
|
2012-07-15 09:55:45 +02:00
|
|
|
# from the sketch, then 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:
|
|
|
|
#
|
2013-06-12 09:17:34 +02:00
|
|
|
# ISP_PROG = stk500v2
|
2012-02-28 10:06:56 +01:00
|
|
|
# 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
|
|
|
|
#
|
2012-12-16 17:06:23 +01:00
|
|
|
# You can specify to also upload the EEPROM file:
|
|
|
|
# ISP_EEPROM = 1
|
|
|
|
#
|
2012-02-28 10:06:56 +01:00
|
|
|
# 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.
|
2012-07-13 19:26:48 +02:00
|
|
|
space_pad_to = $(shell echo $(1) " " | head -c$(2))
|
2012-07-05 20:58:54 +02:00
|
|
|
|
2013-05-30 16:09:05 +02:00
|
|
|
arduino_output =
|
|
|
|
# When output is not suppressed and we're in the top-level makefile,
|
|
|
|
# running for the first time (i.e., not after a restart after
|
|
|
|
# regenerating the dependency file), then output the configuration.
|
2012-11-01 16:33:46 +01:00
|
|
|
ifndef ARDUINO_QUIET
|
2013-05-30 16:09:05 +02:00
|
|
|
ifeq ($(MAKE_RESTARTS),)
|
|
|
|
ifeq ($(MAKELEVEL),0)
|
|
|
|
arduino_output = $(info $(1))
|
|
|
|
endif
|
|
|
|
endif
|
2012-11-01 16:33:46 +01:00
|
|
|
endif
|
|
|
|
|
2012-07-05 22:01:11 +02:00
|
|
|
# Call with some text, and a prefix tag if desired (like [AUTODETECTED]),
|
2012-11-01 16:33:46 +01:00
|
|
|
show_config_info = $(call arduino_output,- $(call space_pad_to,$(2),20) $(1))
|
2012-07-05 22:01:11 +02:00
|
|
|
|
2012-07-05 20:58:54 +02:00
|
|
|
# Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]),
|
|
|
|
# and an explanation if desired (like (found in $$PATH)
|
2012-07-05 22:01:11 +02:00
|
|
|
show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2))
|
2012-07-05 20:58:54 +02:00
|
|
|
|
|
|
|
# Just a nice simple visual separator
|
2012-11-01 16:33:46 +01:00
|
|
|
show_separator = $(call arduino_output,-------------------------)
|
2012-07-05 20:58:54 +02:00
|
|
|
|
|
|
|
$(call show_separator)
|
2012-11-01 16:33:46 +01:00
|
|
|
$(call arduino_output,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 22:01:11 +02:00
|
|
|
$(call show_config_variable,ARDUINO_DIR,[AUTODETECTED])
|
2012-07-05 21:04:35 +02:00
|
|
|
endif
|
2012-07-05 20:58:54 +02:00
|
|
|
|
|
|
|
else
|
2013-06-09 13:43:04 +02:00
|
|
|
$(call show_config_variable,ARDUINO_DIR,[USER])
|
2012-06-29 01:28:22 +02:00
|
|
|
endif
|
2012-07-14 08:51:54 +02:00
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
########################################################################
|
2012-07-05 19:45:52 +02:00
|
|
|
#
|
2013-06-06 04:26:08 +02:00
|
|
|
# Default TARGET to pwd (ex Daniele Vergini)
|
2012-02-28 10:06:56 +01:00
|
|
|
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 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
|
2013-05-30 16:23:32 +02:00
|
|
|
VERSION_FILE := $(ARDUINO_DIR)/lib/version.txt
|
2013-06-13 12:30:09 +02:00
|
|
|
AUTO_ARDUINO_VERSION := $(shell [ -e $(VERSION_FILE) ] && cat $(VERSION_FILE) | sed -e 's/^[0-9]://g' -e 's/[.]//g' -e 's/$$/0000/' | head -c3)
|
2012-07-05 21:04:35 +02:00
|
|
|
ifdef AUTO_ARDUINO_VERSION
|
|
|
|
ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION)
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,ARDUINO_VERSION,[AUTODETECTED])
|
2012-07-05 21:04:35 +02:00
|
|
|
else
|
|
|
|
ARDUINO_VERSION = 100
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,ARDUINO_VERSION,[DEFAULT])
|
2012-07-05 21:04:35 +02:00
|
|
|
endif
|
2012-07-05 19:29:33 +02:00
|
|
|
else
|
2013-06-09 13:43:04 +02:00
|
|
|
$(call show_config_variable,ARDUINO_VERSION,[USER])
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
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-02-28 10:06:56 +01: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
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,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)
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH))
|
2012-07-05 21:04:35 +02:00
|
|
|
endif # SYSTEMPATH_AVR_TOOLS_DIR
|
2012-02-28 10:06:56 +01: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
|
2013-06-09 13:43:04 +02:00
|
|
|
$(call show_config_variable,AVR_TOOLS_DIR,[USER])
|
2012-07-05 21:04:35 +02:00
|
|
|
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
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,ARDUINO_LIB_PATH,[COMPUTED],(from ARDUINO_DIR))
|
2012-07-05 21:04:35 +02:00
|
|
|
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
|
2012-04-29 19:55:17 +02:00
|
|
|
|
2013-06-02 18:03:42 +02:00
|
|
|
ifndef ARDUINO_VAR_PATH
|
|
|
|
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants
|
|
|
|
$(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR))
|
|
|
|
else
|
|
|
|
$(call show_config_variable,ARDUINO_VAR_PATH,[USER])
|
|
|
|
endif
|
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-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
# Makefile distribution path
|
|
|
|
#
|
2012-08-19 05:30:25 +02:00
|
|
|
ifndef ARDMK_DIR
|
|
|
|
# presume it's a level above the path to our own file
|
|
|
|
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/..)
|
|
|
|
$(call show_config_variable,ARDMK_DIR,[COMPUTED],(relative to $(notdir $(lastword $(MAKEFILE_LIST)))))
|
|
|
|
else
|
|
|
|
$(call show_config_variable,ARDMK_DIR,[USER])
|
|
|
|
endif
|
2012-04-29 19:55:17 +02:00
|
|
|
|
2012-08-19 05:30:25 +02:00
|
|
|
ifdef ARDMK_DIR
|
2012-07-05 21:04:35 +02:00
|
|
|
ifndef ARDMK_PATH
|
|
|
|
ARDMK_PATH = $(ARDMK_DIR)/bin
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR))
|
2012-07-05 21:04:35 +02:00
|
|
|
else
|
2013-06-09 13:43:04 +02:00
|
|
|
$(call show_config_variable,ARDMK_PATH,[USER])
|
2012-07-05 21:04:35 +02:00
|
|
|
endif
|
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-08-19 05:30:25 +02:00
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
2013-05-31 14:13:00 +02:00
|
|
|
# Miscellaneous
|
2012-04-29 19:55:17 +02:00
|
|
|
#
|
2012-03-26 05:54:21 +02:00
|
|
|
ifndef ARDUINO_SKETCHBOOK
|
2012-08-19 04:24:07 +02:00
|
|
|
ifneq ($(wildcard $(HOME)/.arduino/preferences.txt),)
|
2013-06-15 12:02:27 +02:00
|
|
|
ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \
|
2012-08-19 04:24:07 +02:00
|
|
|
$(HOME)/.arduino/preferences.txt | \
|
|
|
|
sed -e 's/sketchbook.path=//' )
|
|
|
|
endif
|
2012-12-23 11:12:30 +01:00
|
|
|
|
2013-06-15 12:02:27 +02:00
|
|
|
# on mac
|
2012-12-23 11:12:30 +01:00
|
|
|
ifneq ($(wildcard $(HOME)/Library/Arduino/preferences.txt),)
|
2013-06-15 12:02:27 +02:00
|
|
|
ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \
|
2012-12-23 11:12:30 +01:00
|
|
|
$(HOME)/Library/Arduino/preferences.txt | \
|
|
|
|
sed -e 's/sketchbook.path=//' )
|
|
|
|
endif
|
|
|
|
|
2012-08-19 04:24:07 +02:00
|
|
|
ifneq ($(ARDUINO_SKETCHBOOK),)
|
|
|
|
$(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(in arduino preferences file))
|
|
|
|
else
|
|
|
|
ARDUINO_SKETCHBOOK = $(HOME)/sketchbook
|
|
|
|
$(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT])
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
$(call show_config_variable,ARDUINO_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
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,USER_LIB_PATH,[DEFAULT],(in user sketchbook))
|
2012-07-05 20:58:54 +02:00
|
|
|
else
|
2013-06-09 13:43:04 +02:00
|
|
|
$(call show_config_variable,USER_LIB_PATH,[USER])
|
2012-03-26 05:54:21 +02:00
|
|
|
endif
|
|
|
|
|
2012-04-29 19:55:17 +02:00
|
|
|
########################################################################
|
|
|
|
# Reset
|
2013-05-31 14:13:00 +02:00
|
|
|
#
|
2012-04-29 19:55:17 +02:00
|
|
|
ifndef RESET_CMD
|
2013-06-08 13:56:24 +02:00
|
|
|
ifeq ($(BOARD_TAG),leonardo)
|
2013-06-14 12:39:38 +02:00
|
|
|
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino --leonardo \
|
2013-06-08 13:56:24 +02:00
|
|
|
$(ARD_RESET_OPTS) $(call get_arduino_port)
|
|
|
|
else
|
|
|
|
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino \
|
|
|
|
$(ARD_RESET_OPTS) $(call get_arduino_port)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef WAIT_CONNECTION_CMD
|
|
|
|
ifeq ($(BOARD_TAG),leonardo)
|
|
|
|
WAIT_CONNECTION_CMD = \
|
|
|
|
$(ARDMK_PATH)/wait-connection-leonardo $(call get_arduino_port)
|
|
|
|
else
|
2013-06-13 09:38:27 +02:00
|
|
|
WAIT_CONNECTION_CMD =
|
2013-06-08 13:56:24 +02:00
|
|
|
endif
|
2012-04-29 19:55:17 +02:00
|
|
|
endif
|
|
|
|
|
2013-06-08 13:56:24 +02:00
|
|
|
ifeq ($(BOARD_TAG),leonardo)
|
|
|
|
ERROR_ON_LEONARDO = $(error On leonardo, raw_xxx operation is not supported)
|
|
|
|
else
|
2013-06-13 09:38:27 +02:00
|
|
|
ERROR_ON_LEONARDO =
|
2013-06-08 13:56:24 +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
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_variable,BOARD_TAG,[DEFAULT])
|
2012-07-05 20:58:54 +02:00
|
|
|
else
|
2013-06-15 12:02:27 +02:00
|
|
|
# Strip the board tag of any extra whitespace, since it was causing the makefile to fail
|
|
|
|
# https://github.com/sudar/Arduino-Makefile/issues/57
|
|
|
|
BOARD_TAG := $(strip $(BOARD_TAG))
|
2013-06-09 13:43:04 +02:00
|
|
|
$(call show_config_variable,BOARD_TAG,[USER])
|
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
|
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
# If NO_CORE is set, then we don't have to parse boards.txt file
|
|
|
|
# But the user might have to define MCU, F_CPU etc
|
|
|
|
ifeq ($(strip $(NO_CORE)),)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifndef PARSE_BOARD_CMD
|
|
|
|
PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
# Which variant ? This affects the include path
|
|
|
|
ifndef VARIANT
|
|
|
|
VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
# processor stuff
|
|
|
|
ifndef MCU
|
|
|
|
MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifndef F_CPU
|
|
|
|
F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu)
|
2013-06-02 18:03:42 +02:00
|
|
|
endif
|
2012-09-17 18:06:48 +02:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifeq ($(VARIANT),leonardo)
|
|
|
|
# USB IDs for the Leonardo
|
|
|
|
ifndef USB_VID
|
|
|
|
USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef USB_PID
|
|
|
|
USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null)
|
|
|
|
endif
|
2013-06-02 18:03:42 +02:00
|
|
|
endif
|
2012-09-17 18:06:48 +02:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
# normal programming info
|
|
|
|
ifndef AVRDUDE_ARD_PROGRAMMER
|
|
|
|
AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifndef AVRDUDE_ARD_BAUDRATE
|
|
|
|
AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
# fuses if you're using e.g. ISP
|
|
|
|
ifndef ISP_LOCK_FUSE_PRE
|
|
|
|
ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifndef ISP_HIGH_FUSE
|
|
|
|
ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifndef ISP_LOW_FUSE
|
|
|
|
ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifndef ISP_EXT_FUSE
|
|
|
|
ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef ISP_LOCK_FUSE_POST
|
|
|
|
ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef HEX_MAXIMUM_SIZE
|
|
|
|
HEX_MAXIMUM_SIZE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.maximum_size)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
endif
|
|
|
|
|
2012-09-17 17:29:31 +02:00
|
|
|
# Everything gets built in here (include BOARD_TAG now)
|
2012-09-17 17:25:21 +02:00
|
|
|
ifndef OBJDIR
|
2013-06-15 16:00:39 +02:00
|
|
|
OBJDIR = build-$(BOARD_TAG)
|
2012-11-13 00:34:51 +01:00
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Local sources
|
|
|
|
#
|
2012-07-01 12:52:36 +02:00
|
|
|
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)
|
2012-08-19 03:16:44 +02:00
|
|
|
LOCAL_SRCS = $(LOCAL_C_SRCS) $(LOCAL_CPP_SRCS) \
|
|
|
|
$(LOCAL_CC_SRCS) $(LOCAL_PDE_SRCS) \
|
|
|
|
$(LOCAL_INO_SRCS) $(LOCAL_AS_SRCS)
|
2012-02-28 10:06:56 +01:00
|
|
|
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))
|
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
# If NO_CORE is not set, then we need exactly one .pde or .ino file
|
|
|
|
ifeq ($(strip $(NO_CORE)),)
|
|
|
|
|
|
|
|
ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 0)
|
|
|
|
ifeq ($(strip $(NO_CORE)),)
|
|
|
|
$(error No .pde or .ino files found. If you want to compile .c or .cpp files, then set NO_CORE)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Ideally, this should just check if there are more than one file
|
|
|
|
ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1)
|
|
|
|
#TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49
|
|
|
|
$(error Need exactly one .pde or .ino file)
|
|
|
|
endif
|
|
|
|
|
2013-05-30 13:14:20 +02:00
|
|
|
endif
|
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
# 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))
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_info,NO_CORE_MAIN_CPP set so core library will not include main.cpp,[MANUAL])
|
2012-07-05 21:04:35 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o)
|
|
|
|
CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \
|
2013-06-02 18:03:42 +02:00
|
|
|
$(OBJDIR)/%,$(CORE_OBJ_FILES))
|
2012-07-05 21:04:35 +02:00
|
|
|
endif
|
2012-07-05 20:58:54 +02:00
|
|
|
else
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_info,NO_CORE set so core library will not be built,[MANUAL])
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
2012-08-19 03:16:44 +02:00
|
|
|
########################################################################
|
|
|
|
# Determine ARDUINO_LIBS automatically
|
|
|
|
#
|
|
|
|
ifndef ARDUINO_LIBS
|
|
|
|
# automatically determine included libraries
|
|
|
|
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*)), \
|
|
|
|
$(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(LOCAL_SRCS)))
|
|
|
|
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_SKETCHBOOK)/libraries/*)), \
|
|
|
|
$(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(LOCAL_SRCS)))
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 12:55:10 +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').
|
|
|
|
#
|
2013-06-15 16:00:39 +02:00
|
|
|
ifeq ($(strip $(NO_CORE)),)
|
|
|
|
ifndef MONITOR_BAUDRATE
|
|
|
|
SPEED = $(shell egrep -h 'Serial.begin\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1)
|
|
|
|
MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200)
|
2013-06-02 18:03:42 +02:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifeq ($(MONITOR_BAUDRATE),)
|
|
|
|
MONITOR_BAUDRATE = 9600
|
|
|
|
$(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED])
|
|
|
|
else
|
|
|
|
$(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch))
|
|
|
|
endif
|
2013-06-02 18:03:42 +02:00
|
|
|
else
|
2013-06-15 16:00:39 +02:00
|
|
|
$(call show_config_variable,MONITOR_BAUDRATE, [USER])
|
2013-06-02 18:03:42 +02:00
|
|
|
endif
|
2013-05-30 12:55:10 +02:00
|
|
|
|
2013-06-15 16:00:39 +02:00
|
|
|
ifndef MONITOR_CMD
|
|
|
|
MONITOR_CMD = screen
|
|
|
|
endif
|
2013-05-30 12:55:10 +02:00
|
|
|
endif
|
|
|
|
|
2013-05-30 13:29:25 +02:00
|
|
|
########################################################################
|
|
|
|
# Include file to use for old .pde files
|
|
|
|
#
|
2013-05-31 14:13:00 +02:00
|
|
|
ifndef ARDUINO_HEADER
|
2013-06-02 18:03:42 +02:00
|
|
|
# We should check for Arduino version, if the file is .pde because a
|
|
|
|
# .pde file might be used in Arduino 1.0
|
|
|
|
ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1)
|
|
|
|
ARDUINO_HEADER=WProgram.h
|
|
|
|
else
|
|
|
|
ARDUINO_HEADER=Arduino.h
|
|
|
|
endif
|
2013-05-30 13:29:25 +02:00
|
|
|
endif
|
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
########################################################################
|
|
|
|
# Rules for making stuff
|
|
|
|
#
|
|
|
|
|
|
|
|
# The name of the main targets
|
|
|
|
TARGET_HEX = $(OBJDIR)/$(TARGET).hex
|
|
|
|
TARGET_ELF = $(OBJDIR)/$(TARGET).elf
|
2012-11-17 22:18:56 +01:00
|
|
|
TARGET_EEP = $(OBJDIR)/$(TARGET).eep
|
2012-02-28 10:06:56 +01:00
|
|
|
TARGETS = $(OBJDIR)/$(TARGET).*
|
|
|
|
CORE_LIB = $(OBJDIR)/libcore.a
|
|
|
|
|
|
|
|
# Names of executables
|
|
|
|
CC = $(AVR_TOOLS_PATH)/avr-gcc
|
|
|
|
CXX = $(AVR_TOOLS_PATH)/avr-g++
|
2012-09-20 18:28:42 +02:00
|
|
|
AS = $(AVR_TOOLS_PATH)/avr-as
|
2012-02-28 10:06:56 +01:00
|
|
|
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
|
2012-06-23 07:53:16 +02:00
|
|
|
REMOVE = rm -rf
|
2012-02-28 10:06:56 +01:00
|
|
|
MV = mv -f
|
|
|
|
CAT = cat
|
2012-07-02 10:17:28 +02:00
|
|
|
ECHO = echo
|
2013-06-15 11:59:49 +02:00
|
|
|
MKDIR = mkdir -p
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
# General arguments
|
2012-07-05 21:39:50 +02:00
|
|
|
USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)))
|
2012-07-05 22:02:24 +02:00
|
|
|
USER_LIB_NAMES= $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS))
|
|
|
|
|
|
|
|
# Let user libraries override system ones.
|
|
|
|
SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))
|
|
|
|
SYS_LIB_NAMES = $(patsubst $(ARDUINO_LIB_PATH)/%,%,$(SYS_LIBS))
|
|
|
|
|
|
|
|
# Error here if any are missing.
|
|
|
|
LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES),$(ARDUINO_LIBS))
|
|
|
|
ifneq (,$(strip $(LIBS_NOT_FOUND)))
|
|
|
|
$(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH): $(LIBS_NOT_FOUND))
|
|
|
|
endif
|
|
|
|
|
2012-08-19 08:00:39 +02:00
|
|
|
SYS_LIBS := $(wildcard $(SYS_LIBS) $(addsuffix /utility,$(SYS_LIBS)))
|
|
|
|
USER_LIBS := $(wildcard $(USER_LIBS) $(addsuffix /utility,$(USER_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)) \
|
2013-06-02 18:03:42 +02:00
|
|
|
$(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)) \
|
2013-06-02 18:03:42 +02:00
|
|
|
$(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(USER_LIB_C_SRCS))
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-02-20 17:30:44 +01:00
|
|
|
# Dependency files
|
|
|
|
DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d)
|
|
|
|
|
2012-06-09 07:29:02 +02:00
|
|
|
# Using += instead of =, so that CPPFLAGS can be set per sketch level
|
|
|
|
CPPFLAGS += -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \
|
2013-06-02 18:03:42 +02:00
|
|
|
-I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
|
|
|
|
$(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -Wall \
|
|
|
|
-ffunction-sections -fdata-sections
|
2013-05-31 13:35:47 +02:00
|
|
|
|
|
|
|
# USB IDs for the Leonardo
|
2013-06-13 09:38:27 +02:00
|
|
|
ifeq ($(VARIANT),leonardo)
|
2013-06-02 18:03:42 +02:00
|
|
|
CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID)
|
2013-05-31 13:35:47 +02:00
|
|
|
endif
|
|
|
|
|
2012-12-15 13:30:52 +01:00
|
|
|
CFLAGS += -std=gnu99 $(EXTRA_FLAGS) $(EXTRA_CFLAGS)
|
|
|
|
CXXFLAGS += -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS)
|
2012-08-27 22:08:48 +02:00
|
|
|
ASFLAGS += -mmcu=$(MCU) -I. -x assembler-with-cpp
|
2012-12-15 13:30:52 +01:00
|
|
|
LDFLAGS += -mmcu=$(MCU) -Wl,--gc-sections -Os $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS)
|
2012-07-01 13:04:39 +02:00
|
|
|
SIZEFLAGS ?= --mcu=$(MCU) -C
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-11-01 16:57:11 +01:00
|
|
|
# Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors.
|
|
|
|
get_arduino_port = $(if $(wildcard $(ARDUINO_PORT)),$(firstword $(wildcard $(ARDUINO_PORT))),$(error Arduino port $(ARDUINO_PORT) not found!))
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-09 13:48:12 +02:00
|
|
|
# Returns the ISP port (first wildcard expansion) if it exists, otherwise it errors.
|
|
|
|
get_isp_port = $(if $(wildcard $(ISP_PORT)),$(firstword $(wildcard $(ISP_PORT))),$(error ISP port $(ISP_PORT) not found!))
|
|
|
|
|
2012-07-05 22:01:11 +02:00
|
|
|
# Command for avr_size: do $(call avr_size,elffile,hexfile)
|
|
|
|
ifneq (,$(findstring AVR,$(shell $(SIZE) --help)))
|
|
|
|
# We have a patched version of binutils that mentions AVR - pass the MCU
|
|
|
|
# and the elf to get nice output.
|
2012-07-13 19:06:54 +02:00
|
|
|
avr_size = $(SIZE) $(SIZEFLAGS) --format=avr $(1)
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_info,Size utility: AVR-aware for enhanced output,[AUTODETECTED])
|
2012-07-05 19:45:05 +02:00
|
|
|
else
|
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 22:01:11 +02:00
|
|
|
$(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED])
|
2012-07-05 19:45:05 +02:00
|
|
|
endif
|
|
|
|
|
2012-07-05 22:01:11 +02:00
|
|
|
ifneq (,$(strip $(ARDUINO_LIBS)))
|
2012-11-01 16:33:46 +01:00
|
|
|
$(call arduino_output,-)
|
2012-07-05 22:01:11 +02:00
|
|
|
$(call show_config_info,ARDUINO_LIBS =)
|
|
|
|
endif
|
2013-05-31 14:13:00 +02:00
|
|
|
|
2012-07-05 22:01:11 +02:00
|
|
|
ifneq (,$(strip $(USER_LIB_NAMES)))
|
|
|
|
$(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER]))
|
2012-07-05 20:58:54 +02:00
|
|
|
endif
|
|
|
|
|
2012-07-05 22:01:11 +02:00
|
|
|
ifneq (,$(strip $(SYS_LIB_NAMES)))
|
|
|
|
$(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM]))
|
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
|
Fix directory creation for library source files
In commit 3bce1d88 (Allow adding extra common dependencies), the way
$(OBJDIR) was created changed. Instead of having some ad-hoc mkdir calls
around, all relevant rules were made to depend on the directory instead.
However, this change didn't take into account that the object files for
libraries live instead a subdirectory of $(OBJDIR), which was no longer
automatically created. This made compilation of all libraries fail, on a
clean build directory.
Fixing the rules to depend on $(dir $@) or $(dir %) doesn't work, since
those function calls are expanded by making upon reading the file, not
later when the rule is actually matched.
Therefore, this commit restores the previous explicit mkdir calls for
library object files. The non-library objects files, which do not live
in a subdirectory, still use the dependency approach as before.
Fixes: #58
2013-06-13 23:05:57 +02:00
|
|
|
$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c
|
2013-06-15 11:59:49 +02:00
|
|
|
$(MKDIR) $(dir $@)
|
2013-02-20 17:30:44 +01:00
|
|
|
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
Fix directory creation for library source files
In commit 3bce1d88 (Allow adding extra common dependencies), the way
$(OBJDIR) was created changed. Instead of having some ad-hoc mkdir calls
around, all relevant rules were made to depend on the directory instead.
However, this change didn't take into account that the object files for
libraries live instead a subdirectory of $(OBJDIR), which was no longer
automatically created. This made compilation of all libraries fail, on a
clean build directory.
Fixing the rules to depend on $(dir $@) or $(dir %) doesn't work, since
those function calls are expanded by making upon reading the file, not
later when the rule is actually matched.
Therefore, this commit restores the previous explicit mkdir calls for
library object files. The non-library objects files, which do not live
in a subdirectory, still use the dependency approach as before.
Fixes: #58
2013-06-13 23:05:57 +02:00
|
|
|
$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp
|
2013-06-15 11:59:49 +02:00
|
|
|
$(MKDIR) $(dir $@)
|
2013-02-20 17:30:44 +01:00
|
|
|
$(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
Fix directory creation for library source files
In commit 3bce1d88 (Allow adding extra common dependencies), the way
$(OBJDIR) was created changed. Instead of having some ad-hoc mkdir calls
around, all relevant rules were made to depend on the directory instead.
However, this change didn't take into account that the object files for
libraries live instead a subdirectory of $(OBJDIR), which was no longer
automatically created. This made compilation of all libraries fail, on a
clean build directory.
Fixing the rules to depend on $(dir $@) or $(dir %) doesn't work, since
those function calls are expanded by making upon reading the file, not
later when the rule is actually matched.
Therefore, this commit restores the previous explicit mkdir calls for
library object files. The non-library objects files, which do not live
in a subdirectory, still use the dependency approach as before.
Fixes: #58
2013-06-13 23:05:57 +02:00
|
|
|
$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp
|
2013-06-15 11:59:49 +02:00
|
|
|
$(MKDIR) $(dir $@)
|
2013-02-20 17:30:44 +01:00
|
|
|
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
2012-03-26 05:54:21 +02:00
|
|
|
|
Fix directory creation for library source files
In commit 3bce1d88 (Allow adding extra common dependencies), the way
$(OBJDIR) was created changed. Instead of having some ad-hoc mkdir calls
around, all relevant rules were made to depend on the directory instead.
However, this change didn't take into account that the object files for
libraries live instead a subdirectory of $(OBJDIR), which was no longer
automatically created. This made compilation of all libraries fail, on a
clean build directory.
Fixing the rules to depend on $(dir $@) or $(dir %) doesn't work, since
those function calls are expanded by making upon reading the file, not
later when the rule is actually matched.
Therefore, this commit restores the previous explicit mkdir calls for
library object files. The non-library objects files, which do not live
in a subdirectory, still use the dependency approach as before.
Fixes: #58
2013-06-13 23:05:57 +02:00
|
|
|
$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c
|
2013-06-15 11:59:49 +02:00
|
|
|
$(MKDIR) $(dir $@)
|
2013-02-20 17:30:44 +01:00
|
|
|
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
2012-03-26 05:54:21 +02:00
|
|
|
|
2013-01-31 22:14:07 +01:00
|
|
|
ifdef COMMON_DEPS
|
2013-06-14 12:45:14 +02:00
|
|
|
COMMON_DEPS := $(COMMON_DEPS) Makefile
|
2013-01-31 22:14:07 +01:00
|
|
|
else
|
2013-06-14 12:45:14 +02:00
|
|
|
COMMON_DEPS := Makefile
|
2013-01-31 22:14:07 +01:00
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
# normal local sources
|
2013-05-30 19:44:39 +02:00
|
|
|
$(OBJDIR)/%.o: %.c $(COMMON_DEPS) | $(OBJDIR)
|
2012-07-05 05:30:47 +02:00
|
|
|
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 19:44:39 +02:00
|
|
|
$(OBJDIR)/%.o: %.cc $(COMMON_DEPS) | $(OBJDIR)
|
2012-07-05 05:30:47 +02:00
|
|
|
$(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 19:44:39 +02:00
|
|
|
$(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) | $(OBJDIR)
|
2012-07-05 05:30:47 +02:00
|
|
|
$(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 19:44:39 +02:00
|
|
|
$(OBJDIR)/%.o: %.S $(COMMON_DEPS) | $(OBJDIR)
|
2012-07-05 05:30:47 +02:00
|
|
|
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 19:44:39 +02:00
|
|
|
$(OBJDIR)/%.o: %.s $(COMMON_DEPS) | $(OBJDIR)
|
2012-02-28 10:06:56 +01:00
|
|
|
$(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
|
|
|
|
2013-05-30 13:35:37 +02:00
|
|
|
# the pde -> o file
|
2013-06-19 23:36:21 +02:00
|
|
|
$(OBJDIR)/%.o: %.pde $(COMMON_DEPS) | $(OBJDIR)
|
2013-05-31 14:13:00 +02:00
|
|
|
$(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 13:35:37 +02:00
|
|
|
# the ino -> o file
|
2013-06-19 23:36:21 +02:00
|
|
|
$(OBJDIR)/%.o: %.ino $(COMMON_DEPS) | $(OBJDIR)
|
2012-07-05 05:30:47 +02:00
|
|
|
$(CXX) -x c++ -include Arduino.h -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-09-20 18:30:46 +02:00
|
|
|
# generated assembly
|
2013-06-19 23:41:01 +02:00
|
|
|
$(OBJDIR)/%.s: %.pde $(COMMON_DEPS) | $(OBJDIR)
|
|
|
|
$(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(OBJDIR)/%.s: %.ino $(COMMON_DEPS) | $(OBJDIR)
|
|
|
|
$(CXX) -x c++ -include Arduino.h -MMD -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
2012-09-20 18:30:46 +02:00
|
|
|
|
|
|
|
#$(OBJDIR)/%.lst: $(OBJDIR)/%.s
|
|
|
|
# $(AS) -mmcu=$(MCU) -alhnd $< > $@
|
|
|
|
|
2012-02-28 10:06:56 +01:00
|
|
|
# core files
|
2013-05-30 19:44:39 +02:00
|
|
|
$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR)
|
2013-02-20 17:30:44 +01:00
|
|
|
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 19:44:39 +02:00
|
|
|
$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR)
|
2013-02-20 17:30:44 +01:00
|
|
|
$(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
# various object conversions
|
2012-11-01 16:34:09 +01:00
|
|
|
$(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS)
|
2012-02-28 10:06:56 +01:00
|
|
|
$(OBJCOPY) -O ihex -R .eeprom $< $@
|
2012-09-20 18:29:15 +02:00
|
|
|
@$(ECHO)
|
|
|
|
@$(ECHO)
|
2012-07-05 19:45:19 +02:00
|
|
|
$(call avr_size,$<,$@)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-11-01 16:34:09 +01:00
|
|
|
$(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS)
|
2012-02-28 10:06:56 +01:00
|
|
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
|
|
--change-section-lma .eeprom=0 -O ihex $< $@
|
|
|
|
|
2012-11-01 16:34:09 +01:00
|
|
|
$(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(COMMON_DEPS)
|
2012-08-23 19:39:42 +02:00
|
|
|
$(OBJDUMP) -h --source --demangle --wide $< > $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-11-01 16:34:09 +01:00
|
|
|
$(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS)
|
2012-09-20 18:29:36 +02:00
|
|
|
$(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2012-06-11 00:06:08 +02:00
|
|
|
ifndef AVRDUDE_CONF
|
2013-06-02 18:03:42 +02:00
|
|
|
ifndef AVR_TOOLS_DIR
|
|
|
|
# The avrdude bundled with Arduino can't find its config
|
|
|
|
AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf
|
|
|
|
endif
|
|
|
|
# If avrdude is installed separately, it can find its own config file
|
2012-06-11 00:06:08 +02:00
|
|
|
endif
|
|
|
|
|
2013-06-15 15:47:13 +02:00
|
|
|
# Default avrdude options. -V Do not verify, -q - suppress progress output
|
|
|
|
ifndef AVRDUDE_OPTS
|
|
|
|
AVRDUDE_OPTS = -q -V
|
|
|
|
endif
|
|
|
|
|
|
|
|
AVRDUDE_COM_OPTS = $(AVRDUDE_OPTS) -p $(MCU)
|
2012-02-28 10:06:56 +01:00
|
|
|
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
|
|
|
|
|
2012-11-01 16:57:11 +01:00
|
|
|
AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(call get_arduino_port)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
ifndef ISP_PROG
|
2013-06-09 13:48:12 +02:00
|
|
|
ISP_PROG = stk500v1
|
2012-02-28 10:06:56 +01:00
|
|
|
endif
|
|
|
|
|
2013-06-09 13:48:12 +02:00
|
|
|
ifndef AVRDUDE_ISP_BAUDRATE
|
|
|
|
AVRDUDE_ISP_BAUDRATE = 19200
|
2012-11-17 22:18:56 +01:00
|
|
|
endif
|
|
|
|
|
2013-06-15 15:53:26 +02:00
|
|
|
# Pre fuse settings
|
|
|
|
ifndef AVRDUDE_ISP_FUSES_PRE
|
|
|
|
|
|
|
|
ifneq ($(strip $(ISP_LOCK_FUSE_PRE)),)
|
|
|
|
AVRDUDE_ISP_FUSES_PRE += -U lock:w:$(ISP_LOCK_FUSE_PRE):m
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(strip $(ISP_HIGH_FUSE)),)
|
|
|
|
AVRDUDE_ISP_FUSES_PRE += -U hfuse:w:$(ISP_HIGH_FUSE):m
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(strip $(ISP_LOW_FUSE)),)
|
|
|
|
AVRDUDE_ISP_FUSES_PRE += -U lfuse:w:$(ISP_LOW_FUSE):m
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(strip $(ISP_EXT_FUSE)),)
|
|
|
|
AVRDUDE_ISP_FUSES_PRE += -U efuse:w:$(ISP_EXT_FUSE):m
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Post fuse settings
|
|
|
|
ifndef AVRDUDE_ISP_FUSES_POST
|
|
|
|
ifneq ($(strip $(ISP_LOCK_FUSE_POST)),)
|
|
|
|
AVRDUDE_ISP_FUSES_POST += -U lock:w:$(ISP_LOCK_FUSE_POST):m
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-06-09 13:48:12 +02:00
|
|
|
AVRDUDE_ISP_OPTS = -c $(ISP_PROG) -b $(AVRDUDE_ISP_BAUDRATE) -P $(call get_isp_port)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-11-17 22:18:56 +01:00
|
|
|
ifndef ISP_EEPROM
|
2013-06-02 18:03:42 +02:00
|
|
|
ISP_EEPROM = 0
|
2012-11-17 22:18:56 +01:00
|
|
|
endif
|
|
|
|
|
2012-12-16 17:06:23 +01:00
|
|
|
AVRDUDE_UPLOAD_HEX = -U flash:w:$(TARGET_HEX):i
|
|
|
|
AVRDUDE_UPLOAD_EEP = -U eeprom:w:$(TARGET_EEP):i
|
|
|
|
AVRDUDE_ISPLOAD_OPTS = $(AVRDUDE_UPLOAD_HEX)
|
2013-06-02 18:03:42 +02:00
|
|
|
|
2012-11-17 22:18:56 +01:00
|
|
|
ifneq ($(ISP_EEPROM), 0)
|
2013-06-02 18:03:42 +02:00
|
|
|
AVRDUDE_ISPLOAD_OPTS += $(AVRDUDE_UPLOAD_EEP)
|
2012-11-17 22:18:56 +01:00
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
|
|
|
# Explicit targets start here
|
|
|
|
#
|
|
|
|
|
2013-05-30 19:44:39 +02:00
|
|
|
all: $(TARGET_EEP) $(TARGET_HEX) verify_size
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-06 04:26:08 +02:00
|
|
|
# Rule to create $(OBJDIR) automatically. All rules with recipes that
|
2013-05-30 19:44:39 +02:00
|
|
|
# create a file within it, but do not already depend on a file within it
|
|
|
|
# should depend on this rule. They should use a "order-only
|
2013-06-06 04:26:08 +02:00
|
|
|
# prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prerequisite
|
|
|
|
# list) to prevent remaking the target when any file in the directory
|
2013-05-30 19:44:39 +02:00
|
|
|
# changes.
|
2012-02-28 10:06:56 +01:00
|
|
|
$(OBJDIR):
|
2013-06-15 11:59:49 +02:00
|
|
|
$(MKDIR) $(OBJDIR)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
$(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
|
|
|
|
2013-06-08 13:56:24 +02:00
|
|
|
error_on_leonardo:
|
|
|
|
$(ERROR_ON_LEONARDO)
|
|
|
|
|
2013-06-08 13:02:43 +02:00
|
|
|
# Use submake so we can guarantee the reset happens
|
|
|
|
# before the upload, even with make -j
|
2013-05-30 15:01:07 +02:00
|
|
|
upload: $(TARGET_HEX) verify_size
|
|
|
|
$(MAKE) reset
|
|
|
|
$(MAKE) do_upload
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 15:01:07 +02:00
|
|
|
raw_upload: $(TARGET_HEX) verify_size
|
2013-06-08 13:56:24 +02:00
|
|
|
$(MAKE) error_on_leonardo
|
2013-05-30 15:01:07 +02:00
|
|
|
$(MAKE) do_upload
|
|
|
|
|
|
|
|
do_upload:
|
2012-02-28 10:06:56 +01:00
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
|
2012-12-16 17:06:23 +01:00
|
|
|
$(AVRDUDE_UPLOAD_HEX)
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-06-08 13:56:24 +02:00
|
|
|
do_eeprom: $(TARGET_EEP) $(TARGET_HEX)
|
2012-12-16 17:06:23 +01:00
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
|
|
|
|
$(AVRDUDE_UPLOAD_EEP)
|
2012-11-17 22:18:56 +01:00
|
|
|
|
2013-06-08 13:56:24 +02:00
|
|
|
eeprom: $(TARGET_HEX) verify_size
|
|
|
|
$(MAKE) reset
|
|
|
|
$(MAKE) do_eeprom
|
|
|
|
|
|
|
|
raw_eeprom: $(TARGET_HEX) verify_size
|
|
|
|
$(MAKE) error_on_leonardo
|
|
|
|
$(MAKE) do_eeprom
|
|
|
|
|
|
|
|
# the last part is for leonardo.
|
|
|
|
# wait until leonardo reboots and establish a new connection.
|
2012-07-05 19:45:52 +02:00
|
|
|
reset:
|
2013-06-08 13:56:24 +02:00
|
|
|
$(call arduino_output,Resetting Arduino...)
|
|
|
|
$(RESET_CMD)
|
|
|
|
$(WAIT_CONNECTION_CMD)
|
2012-04-29 19:55:17 +02:00
|
|
|
|
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 <' ; \
|
2013-06-13 09:38:27 +02:00
|
|
|
do $$STTYF /dev/tty >/dev/null 2>&1 && break ; \
|
|
|
|
done ; \
|
|
|
|
$$STTYF $(call get_arduino_port) hupcl ; \
|
|
|
|
(sleep 0.1 2>/dev/null || sleep 1) ; \
|
2012-11-01 16:57:11 +01:00
|
|
|
$$STTYF $(call get_arduino_port) -hupcl
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-12-16 17:06:23 +01:00
|
|
|
ispload: $(TARGET_EEP) $(TARGET_HEX) verify_size
|
2013-06-15 15:53:26 +02:00
|
|
|
ifdef AVRDUDE_ISP_FUSES_PRE
|
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \
|
2013-06-15 15:53:26 +02:00
|
|
|
$(AVRDUDE_ISPLOAD_OPTS)
|
|
|
|
ifdef AVRDUDE_ISP_FUSES_POST
|
|
|
|
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST)
|
|
|
|
endif
|
2012-02-28 10:06:56 +01:00
|
|
|
|
|
|
|
clean:
|
2012-07-05 05:30:47 +02:00
|
|
|
$(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR}
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2013-05-30 19:44:39 +02:00
|
|
|
size: $(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:
|
2012-11-01 16:57:11 +01:00
|
|
|
$(MONITOR_CMD) $(call get_arduino_port) $(MONITOR_BAUDRATE)
|
2012-04-29 13:06:41 +02:00
|
|
|
|
2012-09-20 18:29:26 +02:00
|
|
|
disasm: $(OBJDIR)/$(TARGET).lss
|
|
|
|
@$(ECHO) The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss
|
2012-07-03 19:36:00 +02:00
|
|
|
|
2012-09-20 18:30:46 +02:00
|
|
|
symbol_sizes: $(OBJDIR)/$(TARGET).sym
|
|
|
|
@$(ECHO) A symbol listing sorted by their size have been dumped to $(OBJDIR)/$(TARGET).sym
|
2012-04-29 13:06:41 +02:00
|
|
|
|
2012-11-13 01:13:03 +01:00
|
|
|
$(TARGET_HEX).sizeok: $(TARGET_HEX)
|
2013-06-15 12:04:10 +02:00
|
|
|
ifneq ($(strip $(HEX_MAXIMUM_SIZE)),)
|
|
|
|
$(ARDMK_PATH)/ard-verify-size $(TARGET_HEX) $(HEX_MAXIMUM_SIZE)
|
|
|
|
touch $@
|
|
|
|
else
|
|
|
|
@$(ECHO) Maximum Hex size is not specified. Make sure the hex file that you are going to upload is less than microcontrollers flash memory
|
|
|
|
endif
|
2012-11-13 00:34:51 +01:00
|
|
|
|
2012-11-13 01:13:03 +01:00
|
|
|
verify_size: $(TARGET_HEX) $(TARGET_HEX).sizeok
|
2012-04-29 13:06:41 +02:00
|
|
|
|
2012-09-20 18:30:46 +02:00
|
|
|
generated_assembly: $(OBJDIR)/$(TARGET).s
|
|
|
|
@$(ECHO) Compiler-generated assembly for the main input source has been dumped to $(OBJDIR)/$(TARGET).s
|
2012-07-03 19:36:00 +02:00
|
|
|
|
2013-06-08 13:56:24 +02:00
|
|
|
.PHONY: all upload raw_upload raw_eeprom error_on_leonardo reset reset_stty ispload clean depends size show_boards monitor disasm symbol_sizes generated_assembly verify_size
|
2012-02-28 10:06:56 +01:00
|
|
|
|
2012-05-05 12:33:40 +02:00
|
|
|
# added - in the beginning, so that we don't get an error if the file is not present
|
2012-07-05 05:30:47 +02:00
|
|
|
-include $(DEPS)
|