/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: Tim Marston
  • Date: 2013-02-20 21:23:08 UTC
  • Revision ID: tim@ed.am-20130220212308-l0e8dprou7nxaed0
fixed default ARDUINODIR and PREFERENCESFILE locations for Macs

Show diffs side-by-side

added added

removed removed

144
144
# monitor      Start `screen` on the serial device.  This is meant to be an
145
145
#              equivalent to the Arduino serial monitor.
146
146
#
147
 
# size         Displays size information about the bulit target.
 
147
# size         Displays size information about the built target.
148
148
#
149
149
# bootloader   Burns the bootloader for your board to it.
150
150
#
155
155
 
156
156
# default arduino software directory, check software exists
157
157
ifndef ARDUINODIR
158
 
ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino))
 
158
ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino \
 
159
        /Applications/Arduino.app/Contents/Resources/Java \
 
160
        $(HOME)/Applications/Arduino.app/Contents/Resources/Java))
159
161
endif
160
162
ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" ""
161
163
$(error ARDUINODIR is not set correctly; arduino software not found)
207
209
BOARD_BOOTLOADER_FILE := $(call readboardsparam,bootloader.file)
208
210
 
209
211
# obtain preferences from the IDE's preferences.txt
210
 
PREFERENCESFILE := $(wildcard $(HOME)/.arduino/preferences.txt)
 
212
PREFERENCESFILE := $(firstword $(wildcard \
 
213
        $(HOME)/.arduino/preferences.txt $(HOME)/Library/Arduino/preferences.txt))
211
214
ifneq "$(PREFERENCESFILE)" ""
212
215
readpreferencesparam = $(shell sed -ne "s/$(1)=\(.*\)/\1/p" $(PREFERENCESFILE))
213
216
SKETCHBOOKDIR := $(call readpreferencesparam,sketchbook.path)
257
260
LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \
258
261
        $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH)))))
259
262
LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS))
260
 
BOOTLOADERDIR := \
261
 
        $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)
262
263
 
263
264
# files
264
265
TARGET := $(if $(TARGET),$(TARGET),a.out)
267
268
ARDUINOLIB := .lib/arduino.a
268
269
ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \
269
270
        $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp))))
270
 
BOOTLOADERHEX := $(wildcard $(BOOTLOADERDIR)/$(BOARD_BOOTLOADER_FILE))
 
271
BOOTLOADERHEX := $(addprefix \
 
272
        $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)/, \
 
273
        $(BOARD_BOOTLOADER_FILE))
271
274
 
272
275
# avrdude confifuration
273
276
ifeq "$(AVRDUDECONF)" ""
358
361
 
359
362
bootloader:
360
363
        @echo "Burning bootloader to board..."
361
 
        @test -n "$(BOOTLOADERHEX)" || { \
362
 
                echo "error: bootloader file could not be determined." >&2; \
363
 
                exit 1; }
364
364
        @test -n "$(SERIALDEV)" || { \
365
365
                echo "error: SERIALDEV could not be determined automatically." >&2; \
366
366
                exit 1; }
369
369
                echo; }
370
370
        stty $(STTYFARG) $(SERIALDEV) hupcl
371
371
        $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_UNLOCK):m
372
 
        $(AVRDUDE) $(AVRDUDEFLAGS) -e -U lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m \
373
 
                -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m \
374
 
                $(patsubst %, -U efuse:w:%:m, $(BOARD_BOOTLOADER_EFUSES))
 
372
        $(AVRDUDE) $(AVRDUDEFLAGS) -eU lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m
 
373
        $(AVRDUDE) $(AVRDUDEFLAGS) -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m
 
374
ifneq "$(BOARD_BOOTLOADER_EFUSES)" ""
 
375
        $(AVRDUDE) $(AVRDUDEFLAGS) -U efuse:w:$(BOARD_BOOTLOADER_EFUSES):m
 
376
endif
 
377
ifneq "$(BOOTLOADERHEX)" ""
375
378
        $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(BOOTLOADERHEX):i
 
379
endif
376
380
        $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_LOCK):m
377
381
 
378
382
# building the target