2013-02-21 00:43:25 -04:00
|
|
|
################################################################################
|
|
|
|
# Sketch
|
|
|
|
#
|
|
|
|
|
|
|
|
SRCSUFFIXES = *.cpp *.c *.S
|
|
|
|
|
2015-05-13 00:16:58 -03:00
|
|
|
MAKE_INC=$(wildcard $(SRCROOT)/make.inc)
|
2015-06-01 05:19:48 -03:00
|
|
|
ifeq (,$(MAKE_INC))
|
|
|
|
$(error You must have a make.inc file to list library dependencies)
|
|
|
|
endif
|
2015-05-13 00:16:58 -03:00
|
|
|
|
2013-02-21 00:43:25 -04:00
|
|
|
# Sketch source files
|
|
|
|
SKETCHSRCS := $(wildcard $(addprefix $(SRCROOT)/,$(SRCSUFFIXES)))
|
2015-06-01 05:19:48 -03:00
|
|
|
SKETCHCPP := $(SRCROOT)/$(SKETCH).cpp
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
# Sketch object files
|
2015-05-13 00:16:58 -03:00
|
|
|
SKETCHOBJS := $(subst $(SRCROOT),$(BUILDROOT),$(SKETCHSRCS))
|
2013-02-21 00:43:25 -04:00
|
|
|
SKETCHOBJS := $(addsuffix .o,$(basename $(SKETCHOBJS)))
|
|
|
|
|
2015-06-01 05:19:48 -03:00
|
|
|
# get list of libraries from make.inc
|
|
|
|
include $(MAKE_INC)
|
|
|
|
LIBTOKENS := $(LIBRARIES)
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Find sketchbook libraries referenced by the sketch.
|
|
|
|
#
|
|
|
|
# Include paths for sketch libraries
|
|
|
|
#
|
|
|
|
SKETCHLIBS := $(wildcard $(addprefix $(SKETCHBOOK)/libraries/,$(LIBTOKENS)))
|
|
|
|
SKETCHLIBNAMES := $(notdir $(SKETCHLIBS))
|
|
|
|
SKETCHLIBSRCDIRS := $(SKETCHLIBS) $(addsuffix /utility,$(SKETCHLIBS))
|
|
|
|
SKETCHLIBSRCS := $(wildcard $(foreach suffix,$(SRCSUFFIXES),$(addsuffix /$(suffix),$(SKETCHLIBSRCDIRS))))
|
|
|
|
SKETCHLIBOBJS := $(addsuffix .o,$(basename $(subst $(SKETCHBOOK),$(BUILDROOT),$(SKETCHLIBSRCS))))
|
2014-03-31 14:56:57 -03:00
|
|
|
SKETCHLIBINCLUDES := $(addprefix -I,$(SRCROOT))
|
|
|
|
SKETCHLIBINCLUDES += $(addprefix -I,$(SKETCHLIBS))
|
2013-08-12 22:23:50 -03:00
|
|
|
SKETCHLIBSRCSRELATIVE := $(subst $(SKETCHBOOK)/,,$(SKETCHLIBSRCS))
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2013-05-04 02:10:20 -03:00
|
|
|
ifeq ($(VERBOSE),)
|
|
|
|
v = @
|
|
|
|
else
|
|
|
|
v =
|
|
|
|
endif
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2015-05-31 21:09:43 -03:00
|
|
|
FORCE:
|
|
|
|
|
|
|
|
$(BUILDROOT)/make.flags: FORCE
|
2014-07-31 17:54:03 -03:00
|
|
|
@mkdir -p $(BUILDROOT)
|
2015-05-31 21:09:43 -03:00
|
|
|
@echo "// BUILDROOT=$(BUILDROOT) HAL_BOARD=$(HAL_BOARD) HAL_BOARD_SUBTYPE=$(HAL_BOARD_SUBTYPE) TOOLCHAIN=$(TOOLCHAIN) EXTRAFLAGS=$(EXTRAFLAGS)" > $(BUILDROOT)/make.flags.new
|
2015-05-31 21:19:31 -03:00
|
|
|
@cmp $(BUILDROOT)/make.flags $(BUILDROOT)/make.flags.new > /dev/null 2>&1 || rm -f $(SRCROOT)/*.o
|
2015-05-31 21:09:43 -03:00
|
|
|
@cmp $(BUILDROOT)/make.flags $(BUILDROOT)/make.flags.new > /dev/null 2>&1 || mv $(BUILDROOT)/make.flags.new $(BUILDROOT)/make.flags
|
|
|
|
@rm -f $(BUILDROOT)/make.flags.new
|
2014-07-31 17:54:03 -03:00
|
|
|
@cat $(BUILDROOT)/make.flags
|
2013-11-12 18:06:20 -04:00
|
|
|
|
2013-05-04 02:10:20 -03:00
|
|
|
# common header for rules, prints what is being built
|
|
|
|
define RULEHDR
|
|
|
|
@echo %% $(subst $(BUILDROOT)/,,$@)
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
endef
|