/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to arduino.mk

  • Committer: edam
  • Date: 2012-02-16 00:13:13 UTC
  • Revision ID: edam@waxworlds.org-20120216001313-5w52cnns4cqofb6e
updated arduino.mk

Show diffs side-by-side

added added

removed removed

2
2
#
3
3
#                         edam's arduino makefile
4
4
#_______________________________________________________________________________
5
 
#                                                                    version 0.2
 
5
#                                                                    version 0.1
6
6
#
7
7
# Copyright (c) 2011 Tim Marston <tim@ed.am>.
8
8
#
79
79
#              (from http://arduino.cc/)
80
80
#
81
81
# ARDUINOCONST The arduino software version, as an integer, used to define the
82
 
#              ARDUINO version constant. This defaults to 100 if undefined.
83
 
#
84
 
# AVRDUDECONF  The avrdude.conf to use. If undefined, this defaults to a guess
85
 
#              based on where the avrdude in use is. If empty, no avrdude.conf
86
 
#              is passed to avrdude (to the system default is used).
 
82
#              ARDUINO version constant. This defaults to 100 if unset.
87
83
#
88
84
# AVRTOOLSPATH A space-separated list of directories to search in order when
89
85
#              lookin for the avr build tools. This defaults to the system PATH
90
 
#              followed by subdirectories in ARDUINODIR if undefined.
 
86
#              followed by subdirectories in ARDUINODIR if unset.
91
87
#
92
88
# BOARD        Specify a target board type.  Run `make boards` to see available
93
89
#              board types.
134
130
ifndef ARDUINODIR
135
131
ARDUINODIR := $(wildcard ~/opt/arduino)
136
132
endif
137
 
ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" ""
 
133
ifeq ($(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt), )
138
134
$(error ARDUINODIR is not set correctly; arduino software not found)
139
135
endif
140
136
 
151
147
# auto mode?
152
148
INOFILE := $(wildcard *.ino *.pde)
153
149
ifdef INOFILE
154
 
ifneq "$(words $(INOFILE))" "1"
 
150
ifneq ($(words $(INOFILE)), 1)
155
151
$(error There is more than one .pde or .ino file in this directory!)
156
152
endif
157
153
 
169
165
 
170
166
endif
171
167
 
 
168
# no board? oh dear...
 
169
ifndef BOARD
 
170
ifneq "$(MAKECMDGOALS)" "boards"
 
171
ifneq "$(MAKECMDGOALS)" "clean"
 
172
$(error BOARD is unset.  Type 'make boards' to see possible values)
 
173
endif
 
174
endif
 
175
endif
 
176
 
172
177
# no serial device? make a poor attempt to detect an arduino
173
 
SERIALDEVGUESS := 0
174
 
ifeq "$(SERIALDEV)" ""
 
178
ifeq ($(SERIALDEV), )
175
179
SERIALDEV := $(firstword $(wildcard \
176
180
        /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbmodem*))
177
 
SERIALDEVGUESS := 1
178
181
endif
179
182
 
180
183
# software
199
202
        $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
200
203
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/, *.c *.cpp)) \
201
204
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/utility/, *.c *.cpp)) ))))
202
 
ifeq "$(AVRDUDECONF)" ""
203
 
ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude"
204
 
AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf
205
 
else
206
205
AVRDUDECONF := $(wildcard $(AVRDUDE).conf)
207
 
endif
208
 
endif
209
 
 
210
 
# no board?
211
 
ifndef BOARD
212
 
ifneq "$(MAKECMDGOALS)" "boards"
213
 
ifneq "$(MAKECMDGOALS)" "clean"
214
 
$(error BOARD is unset.  Type 'make boards' to see possible values)
215
 
endif
216
 
endif
217
 
endif
218
206
 
219
207
# obtain board parameters from the arduino boards.txt file
220
208
BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt
229
217
BOARD_UPLOAD_PROTOCOL := \
230
218
        $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE))
231
219
 
232
 
# invalid board?
233
 
ifeq "$(BOARD_BUILD_MCU)" ""
234
 
ifneq "$(MAKECMDGOALS)" "boards"
235
 
ifneq "$(MAKECMDGOALS)" "clean"
236
 
$(error BOARD is invalid.  Type 'make boards' to see possible values)
237
 
endif
238
 
endif
239
 
endif
240
 
 
241
220
# flags
242
221
CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections
243
222
CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
272
251
        @test -n "$(SERIALDEV)" || { \
273
252
                echo "error: SERIALDEV could not be determined automatically." >&2; \
274
253
                exit 1; }
275
 
        @test 0 -eq $(SERIALDEVGUESS) || { \
276
 
                echo "*GUESSING* at serial device:" $(SERIALDEV); \
277
 
                echo; }
278
254
        stty $(STTYFARG) $(SERIALDEV) hupcl
279
255
        $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i
280
256
 
295
271
        @test -n `which screen` || { \
296
272
                echo "error: can't find GNU screen, you might need to install it." >&2 \
297
273
                ecit 1; }
298
 
        @test 0 -eq $(SERIALDEVGUESS) || { \
299
 
                echo "*GUESSING* at serial device:" $(SERIALDEV); \
300
 
                echo; }
301
274
        screen $(SERIALDEV)
302
275
 
303
276
# building the target