/make/arduino-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/arduino-mk

« back to all changes in this revision

Viewing changes to arduino.mk

  • Committer: edam
  • Date: 2012-01-14 00:21:26 UTC
  • Revision ID: edam@waxworlds.org-20120114002126-0m1ktlytlif4dyt6
added "monitor" goal; documented boards and monitor goals

Show diffs side-by-side

added added

removed removed

45
45
#
46
46
# This makefile can be used as a drop-in replacement for the Arduino
47
47
# IDE's build system.  Simply create a symlink to it under the name
48
 
# "Makefile" and run make as described below (remembering to specify a
49
 
# BOARD).  You would create the symlink like like so:
 
48
# "Makefile" and run make (remembering to specify an ARDUINODIR and
 
49
# BOARD, as described below).  You would create the symlink like like
 
50
# so:
50
51
#
51
52
#   $ ln -s ~/src/arduino.mk Makefile
52
53
#
70
71
#
71
72
# A complete list of all the settings you can use in your Makefile
72
73
# follows shortly.  It should be noted, however, that some variables
73
 
# are better specified in the environment or on the command line than
74
 
# in a Makefile.  Specifically, the BOARD and SERIALDEV (if it is not
75
 
# automatically detected).
76
 
#
77
 
# When running make, you might want to specify the board type:
78
 
#
79
 
#   $ BOARD=pro5v make
80
 
#
81
 
# Or in the environment:
82
 
#
 
74
# are better specified in the environment (or on the command line)
 
75
# than in your Makefile.  Specifically, the ARDUINODIR, BOARD and, if
 
76
# it is not automatically detected, SERIALDEV.
 
77
#
 
78
# When running make, you might want to specify the board and path to
 
79
# your installation of the arduino software, like this:
 
80
#
 
81
#   $ export ARDUINODIR=~/opt/arduino-1.0
83
82
#   $ export BOARD=pro5v
84
83
#   $ make
85
84
#
86
85
# For a list of available board types, run `make boards`.
87
86
88
 
# Here is a list of all configuration parameters:
 
87
# Here is a complete list of configuration parameters:
 
88
#
 
89
# ARDUINODIR   The path where you have installed/unpacked the arduino
 
90
#              software (from http://arduino.cc/)
89
91
#
90
92
# BOARD        Specify a target board type.
91
93
#
93
95
#              found.  If unspecified, an attempt is made to determine
94
96
#              the name of a connected arduino's serial device.
95
97
#
96
 
# The following configuration parameters can be determined automatically:
97
 
#
98
 
# TARGET       The name of the target file.  This need not be set if it
99
 
#              is not determined automatically.
 
98
# TARGET       The name of the target file.  This is set automatically
 
99
#              if a .ino or .pde is found, but it is not neccesary to
 
100
#              set it otherwise.
100
101
#
101
102
# SOURCES      A list of all source files of whatever language.  The
102
103
#              language type is determined by the file extension.
 
104
#              This is set automatically if a .ino or .pde is found.
103
105
#
104
 
# LIBRARIES    A list of arduino libraries to build and include.
 
106
# LIBRARIES    A list of arduino libraries to build and include.  This
 
107
#              is set automatically if a .ino or .pde is found.
105
108
#
106
109
# This general-purpose makefile also defines the following goals for
107
110
# use on the command line when you run make:
119
122
#              target, from those that that would be built for the
120
123
#              project.
121
124
#
 
125
# boards       This is not a real goal.  It just displays a list of
 
126
#              available board names, so that you can set the BOARD
 
127
#              environment variable appropriately.
 
128
#
 
129
# monitor      This is not a real goal.  It starts screen on the serial
 
130
#              device.  It is ment to be an equivelant to the arduino
 
131
#              serial monitor.
122
132
#_______________________________________________________________________________
123
133
#
124
134
 
125
135
# The full path to the arduino software, from arduino.cc
 
136
ifndef ARDUINODIR
126
137
ARDUINODIR := $(wildcard ~/opt/arduino-1.0)
 
138
endif
127
139
 
128
140
# check arduino software
129
141
ifeq ($(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt), )
130
 
$(error ARDUINODIR is not set correctly at the top of arduino.mk)
 
142
$(error ARDUINODIR is not set correctly; arduino software not found)
131
143
endif
132
144
 
133
145
# auto mode?
203
215
CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) -DF_CPU=$(BOARD_BUILD_FCPU)
204
216
CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOSRCDIR)
205
217
CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/
206
 
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/,$(LIBRARIES))
 
218
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES))
 
219
CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES))
207
220
AVRDUDEFLAGS = -C $(ARDUINODIR)/hardware/tools/avrdude.conf -DV
208
221
AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV)
209
222
AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED)
215
228
#_______________________________________________________________________________
216
229
#                                                                          RULES
217
230
 
218
 
.PHONY: all target upload clean boards
 
231
.PHONY: all target upload clean boards monitor
219
232
 
220
233
all: target upload
221
234
 
235
248
        @sed -ne '/^#/d;s/^\(.*\).name=\(.*\)/\1            \2/;T' \
236
249
                -e 's/\(.\{12\}\) *\(.*\)/\1 \2/;p' $(BOARDS_FILE)
237
250
 
 
251
monitor:
 
252
        screen $(SERIALDEV)
 
253
 
238
254
# building the target
239
255
 
240
256
$(TARGET).hex: $(TARGET).elf