/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-10 21:25:33 UTC
  • Revision ID: edam@waxworlds.org-20120210212533-fwi9b0isyr8my2lu
updated arduino.mk

Show diffs side-by-side

added added

removed removed

147
147
endif
148
148
 
149
149
# no target? use default
150
 
ifndef TARGET
 
150
ifeq ($(TARGET), )
151
151
TARGET := a.out
152
152
endif
153
153
 
154
154
# no serial device? attempt to detect an arduino
155
 
ifndef SERIALDEV
 
155
ifeq ($(SERIALDEV), )
156
156
SERIALDEV := $(firstword $(wildcard /dev/ttyACM? /dev/ttyUSB?))
157
157
endif
158
158
 
168
168
# files
169
169
OBJECTS := $(addsuffix .o, $(basename $(SOURCES)))
170
170
ARDUINOSRCDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino
 
171
ARDUINOLIBSDIR := $(ARDUINODIR)/libraries
171
172
ARDUINOLIB := _arduino.a
172
 
ARDUINOLIBTMP := _arduino.a.tmp
 
173
ARDUINOLIBTMP := $(ARDUINOLIB).tmp
173
174
ARDUINOLIBOBJS := $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
174
175
        $(wildcard $(addprefix $(ARDUINOSRCDIR)/, *.c *.cpp)))))
175
176
ARDUINOLIBOBJS += $(foreach lib, $(LIBRARIES), \
176
177
        $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
177
 
        $(wildcard $(addprefix $(ARDUINODIR)/libraries/$(lib)/, *.c *.cpp))))))
 
178
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/, *.c *.cpp)) \
 
179
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/utility/, *.c *.cpp)) ))))
178
180
 
179
181
# obtain board parameters from the arduino boards.txt file
180
182
BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt
189
191
BOARD_UPLOAD_PROTOCOL := \
190
192
        $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE))
191
193
 
192
 
# software
193
 
CC := avr-gcc
194
 
CXX := avr-g++
195
 
LD := avr-ld
196
 
AR := avr-ar
197
 
OBJCOPY := avr-objcopy
198
 
AVRDUDE := avrdude
 
194
# prefer software that comes with arduino
 
195
TOOLSDIRPREFIX = $(wildcard $(ARDUINODIR)/hardware/tools/)
 
196
TOOLSAVRDIRPREFIX = $(wildcard $(ARDUINODIR)/hardware/tools/avr/)
 
197
 
 
198
# software (prioritise binaries that came with arduino software)
 
199
FIND_SOFTWARE = $(firstword $(wildcard \
 
200
        $(ARDUINODIR)/hardware/tools/$(1) \
 
201
        $(ARDUINODIR)/hardware/tools/avr/bin/$(1) \
 
202
        ) $(1) )
 
203
CC := $(call FIND_SOFTWARE,avr-gcc)
 
204
CXX := $(call FIND_SOFTWARE,avr-g++)
 
205
LD := $(call FIND_SOFTWARE,avr-ld)
 
206
AR := $(call FIND_SOFTWARE,avr-ar)
 
207
OBJCOPY := $(call FIND_SOFTWARE,avr-objcopy)
 
208
AVRDUDE := $(call FIND_SOFTWARE,avrdude)
199
209
 
200
210
# flags
201
211
CPPFLAGS = -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections
284
294
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/%.cpp
285
295
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
286
296
        $(COMPILE.cpp) -o $@ $<
 
297
 
 
298
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/utility/%.c
 
299
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
 
300
        $(COMPILE.c) -o $@ $<
 
301
 
 
302
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/utility/%.cpp
 
303
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
 
304
        $(COMPILE.cpp) -o $@ $<