/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-10-29 22:48:06 UTC
  • Revision ID: tim@ed.am-20121029224806-3oyj7v3lxp19ae8m
updated .bzrignore

Show diffs side-by-side

added added

removed removed

2
2
#
3
3
#                         edam's Arduino makefile
4
4
#_______________________________________________________________________________
5
 
#                                                                    version 0.3
 
5
#                                                                 version 0.4dev
6
6
#
7
7
# Copyright (C) 2011, 1012 Tim Marston <tim@ed.am>.
8
8
#
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; /^[^.]\+\.name=/p' $(BOARDS_FILE) | \
302
 
                sed -e 's/\([^.]\+\)\.name=\(.*\)/\1            \2/' \
303
 
                        -e 's/\(.\{12\}\) *\(.*\)/\1 \2/'
 
307
        @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDS_FILE) | \
 
308
                sed -Ee 's/([^.]+)\.name=(.*)/\1            \2/' \
 
309
                        -e 's/(.{12}) *(.*)/\1 \2/'
304
310
 
305
311
monitor:
306
312
        @test -n "$(SERIALDEV)" || { \
325
331
.INTERMEDIATE: $(TARGET).elf
326
332
 
327
333
$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS)
328
 
        $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -o $@
 
334
        $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -lm -o $@
329
335
 
330
336
%.o: %.c
331
337
        mkdir -p .dep/$(dir $<)