/make/arduino-mk

To get this branch, use:
bzr branch http://bzr.ed.am/make/arduino-mk

« back to all changes in this revision

Viewing changes to arduino.mk

  • Committer: edam
  • Date: 2012-11-23 17:19:57 UTC
  • Revision ID: tim@ed.am-20121123171957-hhvv5usliko07gge
added TODO

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
#                         edam's Arduino makefile
4
4
#_______________________________________________________________________________
5
 
#                                                                 version 0.3dev
 
5
#                                                                 version 0.4dev
6
6
#
7
7
# Copyright (C) 2011, 1012 Tim Marston <tim@ed.am>.
8
8
#
180
180
SERIALDEVGUESS := 0
181
181
ifeq "$(SERIALDEV)" ""
182
182
SERIALDEV := $(firstword $(wildcard \
183
 
        /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbmodem*))
 
183
        /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*))
184
184
SERIALDEVGUESS := 1
185
185
endif
186
186
 
234
234
        $(shell sed -ne "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_FILE))
235
235
BOARD_UPLOAD_PROTOCOL := \
236
236
        $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE))
 
237
BOARD_USB_VID := \
 
238
        $(shell sed -ne "s/$(BOARD).build.vid=\(.*\)/\1/p" $(BOARDS_FILE))
 
239
BOARD_USB_PID := \
 
240
        $(shell sed -ne "s/$(BOARD).build.pid=\(.*\)/\1/p" $(BOARDS_FILE))
237
241
 
238
242
# invalid board?
239
243
ifeq "$(BOARD_BUILD_MCU)" ""
249
253
CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
250
254
CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU)
251
255
CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST)
252
 
CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR)
253
 
CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/
254
 
CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES))
255
 
CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES))
 
256
CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID)
 
257
CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR)
 
258
CPPFLAGS += -I $(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/
 
259
CPPFLAGS += $(addprefix -I $(ARDUINODIR)/libraries/, $(LIBRARIES))
 
260
CPPFLAGS += $(patsubst %, -I $(ARDUINODIR)/libraries/%/utility, $(LIBRARIES))
256
261
CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep
257
262
CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h
258
263
AVRDUDEFLAGS := $(addprefix -C , $(AVRDUDECONF)) -DV
260
265
AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED)
261
266
LINKFLAGS := -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU)
262
267
 
263
 
# figure out which arg to use with stty
264
 
STTYFARG := $(shell stty --help > /dev/null 2>&1 && echo -F || echo -f)
 
268
# figure out which arg to use with stty (for OS X, GNU and busybox stty)
 
269
STTYFARG := $(shell stty --help 2>&1 | \
 
270
        grep -q 'illegal option' && echo -f || echo -F)
265
271
 
266
272
# include dependencies
267
273
ifneq "$(MAKECMDGOALS)" "clean"
280
286
 
281
287
target: $(TARGET).hex
282
288
 
283
 
upload:
 
289
upload: target
284
290
        @echo "\nUploading to board..."
285
291
        @test -n "$(SERIALDEV)" || { \
286
292
                echo "error: SERIALDEV could not be determined automatically." >&2; \
298
304
 
299
305
boards:
300
306
        @echo Available values for BOARD:
301
 
        @sed -ne '/^#/d;s/^\(.*\).name=\(.*\)/\1            \2/;T' \
302
 
                -e 's/\(.\{12\}\) *\(.*\)/\1 \2/;p' $(BOARDS_FILE)
 
307
        @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDS_FILE) | \
 
308
                sed -Ee 's/([^.]+)\.name=(.*)/\1            \2/' \
 
309
                        -e 's/(.{12}) *(.*)/\1 \2/'
303
310
 
304
311
monitor:
305
312
        @test -n "$(SERIALDEV)" || { \
324
331
.INTERMEDIATE: $(TARGET).elf
325
332
 
326
333
$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS)
327
 
        $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -o $@
 
334
        $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -lm -o $@
328
335
 
329
336
%.o: %.c
330
337
        mkdir -p .dep/$(dir $<)