2013-02-21 00:43:25 -04:00
|
|
|
################################################################################
|
|
|
|
# Sketch
|
|
|
|
#
|
|
|
|
|
2015-03-24 20:28:59 -03:00
|
|
|
SRCSUFFIXES = *.cpp
|
2013-02-21 00:43:25 -04:00
|
|
|
|
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
|
|
|
|
2016-07-13 22:46:17 -03:00
|
|
|
GLOBAL_MAKE_INC=$(wildcard $(SKETCHBOOK)/mk/make.inc)
|
|
|
|
ifeq (,$(GLOBAL_MAKE_INC))
|
|
|
|
$(error You must have a make.inc in mk/ directory)
|
|
|
|
endif
|
|
|
|
|
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)
|
2016-07-13 22:46:17 -03:00
|
|
|
include $(GLOBAL_MAKE_INC)
|
2015-06-01 05:19:48 -03:00
|
|
|
LIBTOKENS := $(LIBRARIES)
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2015-10-15 19:09:54 -03:00
|
|
|
|
|
|
|
# HAL and board specific libraries are included here.
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL \
|
|
|
|
AP_HAL_Empty
|
|
|
|
|
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_APM1)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_APM
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_APM2)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_APM
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_SITL)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_SITL \
|
|
|
|
SITL
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_LINUX)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_Linux
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_PX4)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_PX4
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_VRBRAIN)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_VRBRAIN
|
|
|
|
endif
|
|
|
|
|
2015-03-24 20:28:59 -03:00
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_QURT)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_QURT
|
|
|
|
endif
|
|
|
|
|
2018-02-02 16:35:19 -04:00
|
|
|
ifeq ($(HAL_BOARD),HAL_BOARD_F4LIGHT)
|
|
|
|
LIBTOKENS += \
|
|
|
|
AP_HAL_F4Light
|
|
|
|
endif
|
|
|
|
|
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))))
|
2016-01-02 01:03:59 -04:00
|
|
|
SKETCHLIBINCLUDES := -I$(SKETCHBOOK)/libraries/ -I$(BUILDROOT)/libraries/ -I$(BUILDROOT)/libraries/GCS_MAVLink/
|
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
|