/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 src/Makefile

  • Committer: edam
  • Date: 2012-01-04 19:16:50 UTC
  • Revision ID: edam@waxworlds.org-20120104191650-eij5qp0hapachu2g
updated arduino makefile

Show diffs side-by-side

added added

removed removed

122
122
#              target, from those that that would be built for the
123
123
#              project.
124
124
#
125
 
# boards       This is not a real goal.  It just displays a list of
126
 
#              available board names, so that you can set the BOARD
127
 
#              environment variable appropriately.
128
 
#
129
 
# monitor      This is not a real goal.  It starts screen on the serial
130
 
#              device.  It is ment to be an equivelant to the arduino
131
 
#              serial monitor.
132
125
#_______________________________________________________________________________
133
126
#
134
127
 
160
153
endif
161
154
 
162
155
# no target? use default
163
 
ifeq ($(TARGET), )
 
156
ifndef TARGET
164
157
TARGET := a.out
165
158
endif
166
159
 
167
160
# no serial device? attempt to detect an arduino
168
 
ifeq ($(SERIALDEV), )
 
161
ifndef SERIALDEV
169
162
SERIALDEV := $(firstword $(wildcard /dev/ttyACM? /dev/ttyUSB?))
170
163
endif
171
164
 
181
174
# files
182
175
OBJECTS := $(addsuffix .o, $(basename $(SOURCES)))
183
176
ARDUINOSRCDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino
184
 
ARDUINOLIBSDIR := $(ARDUINODIR)/libraries
185
177
ARDUINOLIB := _arduino.a
186
178
ARDUINOLIBTMP := _arduino.a.tmp
187
179
ARDUINOLIBOBJS := $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
188
180
        $(wildcard $(addprefix $(ARDUINOSRCDIR)/, *.c *.cpp)))))
189
181
ARDUINOLIBOBJS += $(foreach lib, $(LIBRARIES), \
190
182
        $(patsubst %, $(ARDUINOLIBTMP)/%.o, $(basename $(notdir \
191
 
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/, *.c *.cpp)) \
192
 
        $(wildcard $(addprefix $(ARDUINOLIBSDIR)/$(lib)/utility/, *.c *.cpp)) ))))
 
183
        $(wildcard $(addprefix $(ARDUINODIR)/libraries/$(lib)/, *.c *.cpp))))))
193
184
 
194
185
# obtain board parameters from the arduino boards.txt file
195
186
BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt
217
208
CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) -DF_CPU=$(BOARD_BUILD_FCPU)
218
209
CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOSRCDIR)
219
210
CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/
220
 
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES))
221
 
CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES))
 
211
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/,$(LIBRARIES))
222
212
AVRDUDEFLAGS = -C $(ARDUINODIR)/hardware/tools/avrdude.conf -DV
223
213
AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV)
224
214
AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED)
230
220
#_______________________________________________________________________________
231
221
#                                                                          RULES
232
222
 
233
 
.PHONY: all target upload clean boards monitor
 
223
.PHONY: all target upload clean boards
234
224
 
235
225
all: target upload
236
226
 
237
227
target: $(TARGET).hex
238
228
 
239
229
upload:
240
 
        @test -n "$(SERIALDEV)" || { echo "SERIALDEV is unset." >&2; exit 1; }
241
230
        stty -F $(SERIALDEV) hupcl
242
231
        $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i
243
232
 
251
240
        @sed -ne '/^#/d;s/^\(.*\).name=\(.*\)/\1            \2/;T' \
252
241
                -e 's/\(.\{12\}\) *\(.*\)/\1 \2/;p' $(BOARDS_FILE)
253
242
 
254
 
monitor:
255
 
        @test -n "$(SERIALDEV)" || { echo "SERIALDEV is unset." >&2; exit 1; }
256
 
        screen $(SERIALDEV)
257
 
 
258
243
# building the target
259
244
 
260
245
$(TARGET).hex: $(TARGET).elf
294
279
$(ARDUINOLIBTMP)/%.o: $(ARDUINODIR)/libraries/*/%.cpp
295
280
        @test -d $(ARDUINOLIBTMP) || mkdir $(ARDUINOLIBTMP)
296
281
        $(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 $@ $<