/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-07-19 12:07:13 UTC
  • Revision ID: tim@ed.am-20130719120713-3mh7or8yld4y6zar
added support for assembly sources

Show diffs side-by-side

added added

removed removed

239
239
$(error There is more than one .pde or .ino file in this directory!)
240
240
endif
241
241
 
242
 
# automatically determine sources and target
 
242
# automatically determine sources and targeet
243
243
TARGET := $(basename $(INOFILE))
244
244
SOURCES := $(INOFILE) \
245
245
        $(wildcard *.c *.cc *.cpp *.C *.s *.S) \
246
246
        $(wildcard $(addprefix util/, *.c *.cc *.cpp *.C *.s *.S)) \
247
247
        $(wildcard $(addprefix utility/, *.c *.cc *.cpp *.C *.s *.S))
248
248
 
249
 
# automatically determine library directories (to pull library sources in from)
250
 
# by matching included headers in poject sources to headers that exist in the
251
 
# roots of any library directories, giving priority to libraries in the order
252
 
# they're in LIBRARYPATH, and then to the alphabetically-greater named library
253
 
# (this is a really stupid way of doing it, but it's how the IDE works -- if
254
 
# it's causing problems, you can override it by setting LIBRARIES manually)
255
 
INCLUDEDHEADERS := \
256
 
        $(shell sed -nre "s/^\s*\#\s*include\s*[<\"](\S+\.h)[>\"].*/\1/p" \
257
 
        $(SOURCES))
258
 
reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) \
259
 
        $(firstword $(1))
260
 
LIBRARYHEADERS := $(foreach dir, $(LIBRARYPATH), \
261
 
        $(call reverse, $(sort $(wildcard $(dir)/*))))
262
 
LIBRARYHEADERS := $(foreach dir, $(LIBRARYHEADERS), $(wildcard $(dir)/*.h))
263
 
LIBRARYDIRS := $(foreach hdr, $(INCLUDEDHEADERS), $(patsubst %/$(hdr), %, \
264
 
        $(firstword $(filter %/$(hdr), $(LIBRARYHEADERS)))))
265
 
 
266
 
endif
267
 
 
268
 
# if LIBRARIES is specified, use it
269
 
ifneq "$(LIBRARIES)" ""
270
 
LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \
271
 
        $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH)))))
 
249
# automatically determine included libraries
 
250
LIBRARIES := $(filter $(notdir $(wildcard $(addsuffix /*, $(LIBRARYPATH)))), \
 
251
        $(shell sed -nre "s/^\s*\#\s*include\s*[<\"](\S+)\.h[>\"].*/\1/p" \
 
252
        $(SOURCES)))
 
253
 
272
254
endif
273
255
 
274
256
# software
284
266
 
285
267
# directories
286
268
ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/$(BOARD_BUILD_CORE)
 
269
LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \
 
270
        $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH)))))
287
271
LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS))
288
272
 
289
273
# files