/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: Dan
  • Date: 2012-02-17 01:24:40 UTC
  • Revision ID: dan@waxworlds.org-20120217012440-y0kwpr4l2i3y1zuw
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.1
 
5
#                                                                    version 0.2
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 unset.
 
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).
83
87
#
84
88
# AVRTOOLSPATH A space-separated list of directories to search in order when
85
89
#              lookin for the avr build tools. This defaults to the system PATH
86
 
#              followed by subdirectories in ARDUINODIR if unset.
 
90
#              followed by subdirectories in ARDUINODIR if undefined.
87
91
#
88
92
# BOARD        Specify a target board type.  Run `make boards` to see available
89
93
#              board types.
130
134
ifndef ARDUINODIR
131
135
ARDUINODIR := $(wildcard ~/opt/arduino)
132
136
endif
133
 
ifeq ($(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt), )
 
137
ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" ""
134
138
$(error ARDUINODIR is not set correctly; arduino software not found)
135
139
endif
136
140
 
147
151
# auto mode?
148
152
INOFILE := $(wildcard *.ino *.pde)
149
153
ifdef INOFILE
150
 
ifneq ($(words $(INOFILE)), 1)
 
154
ifneq "$(words $(INOFILE))" "1"
151
155
$(error There is more than one .pde or .ino file in this directory!)
152
156
endif
153
157
 
165
169
 
166
170
endif
167
171
 
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
 
 
177
172
# no serial device? make a poor attempt to detect an arduino
178
 
ifeq ($(SERIALDEV), )
 
173
SERIALDEVGUESS := 0
 
174
ifeq "$(SERIALDEV)" ""
179
175
SERIALDEV := $(firstword $(wildcard \
180
176
        /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbmodem*))
 
177
SERIALDEVGUESS := 1
181
178
endif
182
179
 
183
180
# software
202
199
        $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
203
200
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/, *.c *.cpp)) \
204
201
        $(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
205
206
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
206
218
 
207
219
# obtain board parameters from the arduino boards.txt file
208
220
BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt
217
229
BOARD_UPLOAD_PROTOCOL := \
218
230
        $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE))
219
231
 
 
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
 
220
241
# flags
221
242
CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections
222
243
CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
251
272
        @test -n "$(SERIALDEV)" || { \
252
273
                echo "error: SERIALDEV could not be determined automatically." >&2; \
253
274
                exit 1; }
 
275
        @test 0 -eq $(SERIALDEVGUESS) || { \
 
276
                echo "*GUESSING* at serial device:" $(SERIALDEV); \
 
277
                echo; }
254
278
        stty $(STTYFARG) $(SERIALDEV) hupcl
255
279
        $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i
256
280
 
271
295
        @test -n `which screen` || { \
272
296
                echo "error: can't find GNU screen, you might need to install it." >&2 \
273
297
                ecit 1; }
 
298
        @test 0 -eq $(SERIALDEVGUESS) || { \
 
299
                echo "*GUESSING* at serial device:" $(SERIALDEV); \
 
300
                echo; }
274
301
        screen $(SERIALDEV)
275
302
 
276
303
# building the target