/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: 2014-01-11 21:59:40 UTC
  • Revision ID: tim@ed.am-20140111215940-6o0v14fqk7rxdhu8
make usage of sed more portable (and tested on OS X); switch 1.5 support to
using new boards.txt layout from 1.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
# obtain board parameters from the arduino boards.txt file(s)
195
195
BOARDSFILES := $(foreach dir, $(ARDUINOBACKENDS), \
196
196
        $(ARDUINODIR)/hardware/arduino$(dir)/boards.txt)
197
 
ifeq "$(ARDUINOBACKENDS)" "/"
198
 
readboardsparam = $(shell sed -ne "s/^$(BOARD)\\.$(1)=\(.*\)/\1/p" \
199
 
        $(BOARDSFILES))
200
 
else
201
197
readboardsparam = $(firstword \
202
 
        $(call readboardsmenuparam,$(1),$(basename $(BOARD)),$(suffix $(BOARD))) \
 
198
        $(shell sed -ne "s/^menu\\.cpu\\.$(BOARD)\\.$(1)=\(.*\)/\1/p" \
 
199
                $(BOARDSFILES)) \
203
200
        $(shell sed -ne "s/^$(basename $(BOARD))\\.$(1)=\(.*\)/\1/p" \
204
201
                $(BOARDSFILES)))
205
 
ifneq "$(wildcard /usr/bin/perl)" ""
206
 
readboardsmenuparam = $(shell perl -ne \
207
 
        '/^$(2)\.menu\.cpu/ && s/.*$(3)\.$(1)=(.*)/\1/i && print' $(BOARDSFILES))
208
 
else
209
 
readboardsmenuparam = $(shell sed -ne '/^$(2)\.menu\.cpu/ {' \
210
 
        -e 's/.*$(3)\.$(1)=\(.*\)/\1/p' -e '}' $(BOARDSFILES))
211
 
endif
212
 
endif
213
202
BOARD_BUILD_MCU := $(call readboardsparam,build.mcu)
214
203
BOARD_BUILD_FCPU := $(call readboardsparam,build.f_cpu)
215
204
BOARD_BUILD_VARIANT := $(call readboardsparam,build.variant)
216
205
BOARD_BUILD_CORE := $(call readboardsparam,build.core)
217
 
BOARD_BUILD_BOARD := $(call readboardsparam,build.board)
218
206
BOARD_UPLOAD_SPEED := $(call readboardsparam,upload.speed)
219
207
BOARD_UPLOAD_PROTOCOL := $(call readboardsparam,upload.protocol)
220
208
BOARD_USB_VID := $(call readboardsparam,build.vid)
249
237
        $(if $(shell grep ^$(basename $(BOARD))\\.name \
250
238
                $(ARDUINODIR)/hardware/arduino$(dir)/boards.txt), \
251
239
        $(ARDUINODIR)/hardware/arduino$(dir))))
252
 
ARDUINOBACKENDARCH=AVR
253
240
ARDUINOCOREDIR := $(ARDUINOBACKENDDIR)/cores/$(BOARD_BUILD_CORE)
254
241
 
255
242
# default library path (places to look for libraries)
276
263
# they're in LIBRARYPATH, and then to the alphabetically-greater named library
277
264
# (this is a really stupid way of doing it, but it's how the IDE works -- if
278
265
# it's causing problems, you can override it by setting LIBRARIES manually)
279
 
INCLUDEDHEADERS := $(shell sed -ne '/^[ \t]*\#[ \t]*include[ \t<"]/ {' \
280
 
         -e 's/^.*[<"]\(.*\)[>"].*/\1/p' -e '}' $(SOURCES))
 
266
INCLUDEDHEADERS := $(shell sed -ne "/^[ \t]*\#[ \t]*include[ \t<\"]/ {" \
 
267
         -e "s/^.*[<\"]\(.*\)[>\"].*/\1/" -e "p" -e "}" $(SOURCES))
281
268
reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) \
282
269
        $(firstword $(1))
283
270
LIBRARYHEADERS := $(foreach dir, $(LIBRARYPATH), \
293
280
LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \
294
281
        $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH)))))
295
282
endif
296
 
LIBRARYDIRS := $(LIBRARYDIRS) \
297
 
        $(addsuffix /utility, $(LIBRARYDIRS)) \
298
 
        $(addsuffix /src, $(LIBRARYDIRS))
 
283
LIBRARYDIRS := $(LIBRARYDIRS) $(addsuffix /utility, $(LIBRARYDIRS))
299
284
 
300
285
# files
301
286
TARGET := $(if $(TARGET),$(TARGET),a.out)
345
330
# flags
346
331
CPPFLAGS += -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections
347
332
CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
348
 
CPPFLAGS += -fpermissive -mmcu=$(BOARD_BUILD_MCU)
 
333
CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU)
349
334
CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST)
350
 
CPPFLAGS += -DARDUINO_$(BOARD_BUILD_BOARD) -DARDUINO_ARCH_$(ARDUINOBACKENDARCH)
351
335
CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID)
352
336
CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR)
353
337
CPPFLAGS += -I $(ARDUINOBACKENDDIR)/variants/$(BOARD_BUILD_VARIANT)/