/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: Tim Marston
  • Date: 2012-05-17 19:17:05 UTC
  • Revision ID: tim@ed.am-20120517191705-3d28d50tw8w51v7g
removed 5V regulator from scematic and replaced the connection to the regulator
on the Arduino -- ecause that's what we should be using and out seperate
regulator is only working around a fault in out arduino

Show diffs side-by-side

added added

removed removed

2
2
#
3
3
#                         edam's Arduino makefile
4
4
#_______________________________________________________________________________
5
 
#                                                                 version 0.3dev
 
5
#                                                                    version 0.3
6
6
#
7
7
# Copyright (C) 2011, 1012 Tim Marston <tim@ed.am>.
8
8
#
117
117
# when you run make:
118
118
#
119
119
# all          This is the default if no goal is specified.  It builds the
120
 
#              target and uploads it.
 
120
#              target.
121
121
#
122
122
# target       Builds the target.
123
123
#
171
171
        $(wildcard $(addprefix utility/, *.c *.cc *.cpp))
172
172
 
173
173
# automatically determine included libraries
174
 
ARDUINOLIBSAVAIL := $(notdir $(wildcard $(ARDUINODIR)/libraries/*))
175
 
LIBRARIES := $(filter $(ARDUINOLIBSAVAIL), \
 
174
LIBRARIES := $(filter $(notdir $(wildcard $(ARDUINODIR)/libraries/*)), \
176
175
        $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES)))
177
176
 
178
177
endif
181
180
SERIALDEVGUESS := 0
182
181
ifeq "$(SERIALDEV)" ""
183
182
SERIALDEV := $(firstword $(wildcard \
184
 
        /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbmodem*))
 
183
        /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*))
185
184
SERIALDEVGUESS := 1
186
185
endif
187
186
 
198
197
# files
199
198
TARGET := $(if $(TARGET),$(TARGET),a.out)
200
199
OBJECTS := $(addsuffix .o, $(basename $(SOURCES)))
201
 
ARDUINOSRCDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino
202
 
ARDUINOLIBSDIR := $(ARDUINODIR)/libraries
203
 
ARDUINOLIB := _arduino.a
204
 
ARDUINOLIBTMP := $(ARDUINOLIB).tmp
205
 
ARDUINOLIBOBJS := $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
206
 
        $(wildcard $(addprefix $(ARDUINOSRCDIR)/, *.c *.cpp)))))
207
 
ARDUINOLIBOBJS += $(foreach lib, $(LIBRARIES), \
208
 
        $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
209
 
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/, *.c *.cpp)) \
210
 
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/utility/, *.c *.cpp)) ))))
 
200
DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES))
 
201
ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino
 
202
ARDUINOLIB := .lib/arduino.a
 
203
ARDUINOLIBLIBSDIR := $(ARDUINODIR)/libraries
 
204
ARDUINOLIBLIBSPATH := $(foreach lib, $(LIBRARIES), \
 
205
        $(ARDUINODIR)/libraries/$(lib)/ $(ARDUINODIR)/libraries/$(lib)/utility/ )
 
206
ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(ARDUINOLIBLIBSPATH), \
 
207
        $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp))))
211
208
ifeq "$(AVRDUDECONF)" ""
212
209
ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude"
213
210
AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf
252
249
CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
253
250
CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU)
254
251
CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST)
255
 
CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOSRCDIR)
 
252
CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR)
256
253
CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/
257
254
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES))
258
255
CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES))
 
256
CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep
 
257
CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h
259
258
AVRDUDEFLAGS := $(addprefix -C , $(AVRDUDECONF)) -DV
260
259
AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV)
261
260
AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED)
264
263
# figure out which arg to use with stty
265
264
STTYFARG := $(shell stty --help > /dev/null 2>&1 && echo -F || echo -f)
266
265
 
 
266
# include dependencies
 
267
ifneq "$(MAKECMDGOALS)" "clean"
 
268
-include $(DEPFILES)
 
269
endif
 
270
 
267
271
# default rule
268
272
.DEFAULT_GOAL := all
269
273
 
272
276
 
273
277
.PHONY: all target upload clean boards monitor size
274
278
 
275
 
all: target upload
 
279
all: target
276
280
 
277
281
target: $(TARGET).hex
278
282
 
290
294
clean:
291
295
        rm -f $(OBJECTS)
292
296
        rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~
293
 
        rm -rf $(ARDUINOLIBTMP)
 
297
        rm -rf .lib .dep
294
298
 
295
299
boards:
296
300
        @echo Available values for BOARD:
297
 
        @sed -ne '/^#/d;s/^\(.*\).name=\(.*\)/\1            \2/;T' \
298
 
                -e 's/\(.\{12\}\) *\(.*\)/\1 \2/;p' $(BOARDS_FILE)
 
301
        @sed -ne '/^#/d; /^[^.]\+\.name=/p' $(BOARDS_FILE) | \
 
302
                sed -e 's/\([^.]\+\)\.name=\(.*\)/\1            \2/' \
 
303
                        -e 's/\(.\{12\}\) *\(.*\)/\1 \2/'
299
304
 
300
305
monitor:
301
306
        @test -n "$(SERIALDEV)" || { \
322
327
$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS)
323
328
        $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -o $@
324
329
 
 
330
%.o: %.c
 
331
        mkdir -p .dep/$(dir $<)
 
332
        $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $<
 
333
 
 
334
%.o: %.cpp
 
335
        mkdir -p .dep/$(dir $<)
 
336
        $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $<
 
337
 
 
338
%.o: %.cc
 
339
        mkdir -p .dep/$(dir $<)
 
340
        $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $<
 
341
 
 
342
%.o: %.C
 
343
        mkdir -p .dep/$(dir $<)
 
344
        $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $<
 
345
 
325
346
%.o: %.ino
326
 
        $(COMPILE.cpp) -o $@ -x c++ -include $(ARDUINOSRCDIR)/Arduino.h $<
 
347
        mkdir -p .dep/$(dir $<)
 
348
        $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $<
327
349
 
328
350
%.o: %.pde
329
 
        $(COMPILE.cpp) -o $@ -x c++ -include $(ARDUINOSRCDIR)/Arduino.h $<
 
351
        mkdir -p .dep/$(dir $<)
 
352
        $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ -x c++ -include $(ARDUINOCOREDIR)/Arduino.h $<
330
353
 
331
354
# building the arduino library
332
355
 
333
356
$(ARDUINOLIB): $(ARDUINOLIBOBJS)
334
357
        $(AR) rcs $@ $?
335
 
        rm -rf $(ARDUINOLIBTMP)
336
 
 
337
 
.INTERMEDIATE: $(ARDUINOLIBOBJS)
338
 
 
339
 
$(ARDUINOLIBTMP)/%.o: $(ARDUINOSRCDIR)/%.c
340
 
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
341
 
        $(COMPILE.c) -o $@ $<
342
 
 
343
 
$(ARDUINOLIBTMP)/%.o: $(ARDUINOSRCDIR)/%.cpp
344
 
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
345
 
        $(COMPILE.cpp) -o $@ $<
346
 
 
347
 
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/%.c
348
 
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
349
 
        $(COMPILE.c) -o $@ $<
350
 
 
351
 
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/%.cpp
352
 
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
353
 
        $(COMPILE.cpp) -o $@ $<
354
 
 
355
 
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/utility/%.c
356
 
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
357
 
        $(COMPILE.c) -o $@ $<
358
 
 
359
 
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/utility/%.cpp
360
 
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
 
358
 
 
359
.lib/%.c.o: %.c
 
360
        mkdir -p $(dir $@)
 
361
        $(COMPILE.c) -o $@ $<
 
362
 
 
363
.lib/%.cpp.o: %.cpp
 
364
        mkdir -p $(dir $@)
 
365
        $(COMPILE.cpp) -o $@ $<
 
366
 
 
367
.lib/%.cc.o: %.cc
 
368
        mkdir -p $(dir $@)
 
369
        $(COMPILE.cpp) -o $@ $<
 
370
 
 
371
.lib/%.C.o: %.C
 
372
        mkdir -p $(dir $@)
361
373
        $(COMPILE.cpp) -o $@ $<