/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), )
179
 
SERIALDEV := $(firstword $(wildcard /dev/ttyACM? /dev/ttyUSB?))
 
173
SERIALDEVGUESS := 0
 
174
ifeq "$(SERIALDEV)" ""
 
175
SERIALDEV := $(firstword $(wildcard \
 
176
        /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbmodem*))
 
177
SERIALDEVGUESS := 1
180
178
endif
181
179
 
182
180
# software
201
199
        $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
202
200
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/, *.c *.cpp)) \
203
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
204
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
205
218
 
206
219
# obtain board parameters from the arduino boards.txt file
207
220
BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt
216
229
BOARD_UPLOAD_PROTOCOL := \
217
230
        $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE))
218
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
 
219
241
# flags
220
242
CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections
221
243
CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
250
272
        @test -n "$(SERIALDEV)" || { \
251
273
                echo "error: SERIALDEV could not be determined automatically." >&2; \
252
274
                exit 1; }
 
275
        @test 0 -eq $(SERIALDEVGUESS) || { \
 
276
                echo "*GUESSING* at serial device:" $(SERIALDEV); \
 
277
                echo; }
253
278
        stty $(STTYFARG) $(SERIALDEV) hupcl
254
279
        $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i
255
280
 
270
295
        @test -n `which screen` || { \
271
296
                echo "error: can't find GNU screen, you might need to install it." >&2 \
272
297
                ecit 1; }
 
298
        @test 0 -eq $(SERIALDEVGUESS) || { \
 
299
                echo "*GUESSING* at serial device:" $(SERIALDEV); \
 
300
                echo; }
273
301
        screen $(SERIALDEV)
274
302
 
275
303
# building the target