2013-02-21 00:43:25 -04:00
|
|
|
# find key paths and system type
|
|
|
|
|
|
|
|
# Save the system type for later use.
|
|
|
|
#
|
|
|
|
SYSTYPE := $(shell uname)
|
|
|
|
|
2016-04-15 16:13:50 -03:00
|
|
|
GIT_VERSION ?= $(shell git rev-parse HEAD | cut -c1-8)
|
2013-11-08 07:26:52 -04:00
|
|
|
EXTRAFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
|
|
|
|
|
2016-04-01 14:53:38 -03:00
|
|
|
# Add missing parts from libc and libstdc++ for all boards
|
|
|
|
EXTRAFLAGS += -I$(SKETCHBOOK)/libraries/AP_Common/missing
|
|
|
|
|
2013-02-21 00:43:25 -04:00
|
|
|
# force LANG to C so awk works sanely on MacOS
|
|
|
|
export LANG=C
|
|
|
|
|
|
|
|
#
|
|
|
|
# Locate the sketch sources based on the initial Makefile's path
|
|
|
|
#
|
|
|
|
SRCROOT := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
|
2014-07-23 07:13:55 -03:00
|
|
|
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
|
2013-02-21 00:43:25 -04:00
|
|
|
# Workaround a $(realpath ) bug on cygwin
|
|
|
|
ifeq ($(SRCROOT),)
|
|
|
|
SRCROOT := $(shell cygpath -m ${CURDIR})
|
|
|
|
$(warning your realpath function is not working)
|
|
|
|
$(warning > setting SRCROOT to $(SRCROOT))
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# We need to know the location of the sketchbook. If it hasn't been overridden,
|
|
|
|
# try the parent of the current directory. If there is no libraries directory
|
|
|
|
# there, assume that we are in a library's examples directory and try backing up
|
|
|
|
# further.
|
|
|
|
#
|
|
|
|
ifeq ($(SKETCHBOOK),)
|
|
|
|
SKETCHBOOK := $(shell cd $(SRCROOT)/.. && pwd)
|
|
|
|
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
|
|
|
|
SKETCHBOOK := $(shell cd $(SRCROOT)/../.. && pwd)
|
|
|
|
endif
|
|
|
|
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
|
|
|
|
SKETCHBOOK := $(shell cd $(SRCROOT)/../../.. && pwd)
|
|
|
|
endif
|
|
|
|
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
|
|
|
|
SKETCHBOOK := $(shell cd $(SRCROOT)/../../../.. && pwd)
|
|
|
|
endif
|
|
|
|
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
|
|
|
|
$(error ERROR: cannot determine sketchbook location - please specify on the commandline with SKETCHBOOK=<path>)
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
|
|
|
|
$(warning WARNING: sketchbook directory $(SKETCHBOOK) contains no libraries)
|
|
|
|
endif
|
|
|
|
endif
|
2014-07-23 07:13:55 -03:00
|
|
|
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
|
2013-03-03 07:22:33 -04:00
|
|
|
# Convert cygwin path into a windows normal path
|
2013-03-27 23:23:30 -03:00
|
|
|
SKETCHBOOK := $(shell cygpath ${SKETCHBOOK})
|
2013-02-21 00:43:25 -04:00
|
|
|
endif
|
|
|
|
|
2015-05-25 01:51:12 -03:00
|
|
|
ifneq ($(wildcard $(SKETCHBOOK)/config.mk),)
|
2015-05-30 08:00:50 -03:00
|
|
|
$(info Reading $(SKETCHBOOK)/config.mk)
|
2015-05-25 01:51:12 -03:00
|
|
|
include $(SKETCHBOOK)/config.mk
|
|
|
|
endif
|
|
|
|
|
2015-06-19 04:57:13 -03:00
|
|
|
ifneq ($(wildcard $(SKETCHBOOK)/developer.mk),)
|
|
|
|
$(info Reading $(SKETCHBOOK)/developer.mk)
|
|
|
|
include $(SKETCHBOOK)/developer.mk
|
|
|
|
endif
|
|
|
|
|
2013-02-21 00:43:25 -04:00
|
|
|
#
|
|
|
|
# Work out the sketch name from the name of the source directory.
|
|
|
|
#
|
|
|
|
SKETCH := $(lastword $(subst /, ,$(SRCROOT)))
|
|
|
|
# Workaround a $(lastword ) bug on cygwin
|
|
|
|
ifeq ($(SKETCH),)
|
|
|
|
WORDLIST := $(subst /, ,$(SRCROOT))
|
|
|
|
SKETCH := $(word $(words $(WORDLIST)),$(WORDLIST))
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Work out where we are going to be building things
|
|
|
|
#
|
|
|
|
TMPDIR ?= /tmp
|
2013-08-26 10:03:39 -03:00
|
|
|
|
|
|
|
ifneq ($(findstring px4, $(MAKECMDGOALS)),)
|
|
|
|
# when building px4 we need all sources to be inside the sketchbook directory
|
|
|
|
# as the NuttX build system relies on it
|
2013-08-12 22:22:54 -03:00
|
|
|
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
|
2014-03-31 14:56:57 -03:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),)
|
|
|
|
# when building vrbrain we need all sources to be inside the sketchbook directory
|
|
|
|
# as the NuttX build system relies on it
|
|
|
|
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
|
|
|
|
endif
|
|
|
|
|
2014-05-30 17:58:34 -03:00
|
|
|
ifneq ($(findstring vrubrain, $(MAKECMDGOALS)),)
|
|
|
|
# when building vrbrain we need all sources to be inside the sketchbook directory
|
|
|
|
# as the NuttX build system relies on it
|
|
|
|
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
|
|
|
|
endif
|
|
|
|
|
2016-07-05 12:52:26 -03:00
|
|
|
ifneq ($(findstring vrcore, $(MAKECMDGOALS)),)
|
|
|
|
# when building vrcore we need all sources to be inside the sketchbook directory
|
2014-05-30 17:58:34 -03:00
|
|
|
# as the NuttX build system relies on it
|
|
|
|
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
|
|
|
|
endif
|
|
|
|
|
2014-03-31 14:56:57 -03:00
|
|
|
ifeq ($(BUILDROOT),)
|
2013-08-26 10:03:39 -03:00
|
|
|
BUILDROOT := $(abspath $(TMPDIR)/$(SKETCH).build)
|
|
|
|
endif
|
|
|
|
|
2013-02-21 00:43:25 -04:00
|
|
|
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
|
|
|
|
# Workaround a $(abspath ) bug on cygwin
|
|
|
|
ifeq ($(BUILDROOT),)
|
|
|
|
BUILDROOT := C:$(TMPDIR)/$(SKETCH).build
|
|
|
|
$(warning your abspath function is not working)
|
|
|
|
$(warning > setting BUILDROOT to $(BUILDROOT))
|
2013-03-03 07:22:33 -04:00
|
|
|
else
|
|
|
|
BUILDROOT := $(shell cygpath ${BUILDROOT})
|
2013-02-21 00:43:25 -04:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2016-04-05 01:10:04 -03:00
|
|
|
ifneq ($(findstring mavlink1, $(MAKECMDGOALS)),)
|
2016-02-24 01:56:33 -04:00
|
|
|
EXTRAFLAGS += -DMAVLINK_PROTOCOL_VERSION=1
|
2016-01-14 17:21:42 -04:00
|
|
|
MAVLINK_SUBDIR=v1.0
|
|
|
|
MAVLINK_WIRE_PROTOCOL=1.0
|
2016-04-05 01:10:04 -03:00
|
|
|
else
|
|
|
|
EXTRAFLAGS += -DMAVLINK_PROTOCOL_VERSION=2
|
|
|
|
MAVLINK_SUBDIR=v2.0
|
|
|
|
MAVLINK_WIRE_PROTOCOL=2.0
|
2016-01-14 17:21:42 -04:00
|
|
|
endif
|
|
|
|
|
2013-02-21 00:43:25 -04:00
|
|
|
ifneq ($(APPDIR),)
|
|
|
|
# this is a recusive PX4 build
|
|
|
|
HAL_BOARD = HAL_BOARD_PX4
|
|
|
|
endif
|
|
|
|
|
|
|
|
# handle target based overrides for board type
|
|
|
|
ifneq ($(findstring px4, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_PX4
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(findstring sitl, $(MAKECMDGOALS)),)
|
2015-05-04 03:18:15 -03:00
|
|
|
HAL_BOARD = HAL_BOARD_SITL
|
2014-08-13 01:41:59 -03:00
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
|
2013-02-21 00:43:25 -04:00
|
|
|
endif
|
|
|
|
|
2013-09-22 03:04:08 -03:00
|
|
|
ifneq ($(findstring linux, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
2014-07-06 23:04:54 -03:00
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NONE
|
2013-09-22 03:04:08 -03:00
|
|
|
endif
|
|
|
|
|
2015-09-06 18:43:01 -03:00
|
|
|
ifneq ($(findstring erleboard, $(MAKECMDGOALS)),)
|
2014-07-06 23:04:54 -03:00
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
2015-09-06 18:43:01 -03:00
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD
|
2014-07-13 19:52:43 -03:00
|
|
|
endif
|
|
|
|
|
2014-11-13 19:18:14 -04:00
|
|
|
ifneq ($(findstring zynq, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_ZYNQ
|
|
|
|
endif
|
|
|
|
|
2014-07-06 23:04:54 -03:00
|
|
|
ifneq ($(findstring pxf, $(MAKECMDGOALS)),)
|
2014-07-06 20:37:27 -03:00
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
2014-07-06 23:04:54 -03:00
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_PXF
|
2014-07-06 20:37:27 -03:00
|
|
|
endif
|
|
|
|
|
2015-07-09 21:23:12 -03:00
|
|
|
ifneq ($(findstring bebop, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_BEBOP
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2014-07-23 07:13:55 -03:00
|
|
|
ifneq ($(findstring navio, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NAVIO
|
|
|
|
endif
|
|
|
|
|
2015-08-17 23:25:02 -03:00
|
|
|
ifneq ($(findstring raspilot, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_RASPILOT
|
|
|
|
endif
|
|
|
|
|
2015-11-01 07:29:23 -04:00
|
|
|
ifneq ($(findstring erlebrain2, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2
|
|
|
|
endif
|
|
|
|
|
2015-01-10 19:21:52 -04:00
|
|
|
ifneq ($(findstring bbbmini, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_BBBMINI
|
|
|
|
endif
|
|
|
|
|
2015-08-11 18:45:42 -03:00
|
|
|
ifneq ($(findstring minlure, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_MINLURE
|
|
|
|
endif
|
|
|
|
|
2013-02-21 00:43:25 -04:00
|
|
|
ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_VRBRAIN
|
2014-08-13 01:41:59 -03:00
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
|
2013-02-21 00:43:25 -04:00
|
|
|
endif
|
|
|
|
|
2014-05-30 17:58:34 -03:00
|
|
|
ifneq ($(findstring vrubrain, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_VRBRAIN
|
2014-08-13 01:41:59 -03:00
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
|
2014-05-30 17:58:34 -03:00
|
|
|
endif
|
|
|
|
|
2016-07-05 12:52:26 -03:00
|
|
|
ifneq ($(findstring vrcore, $(MAKECMDGOALS)),)
|
2014-05-30 17:58:34 -03:00
|
|
|
HAL_BOARD = HAL_BOARD_VRBRAIN
|
2014-08-13 01:41:59 -03:00
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
|
2014-05-30 17:58:34 -03:00
|
|
|
endif
|
|
|
|
|
2015-11-28 05:17:26 -04:00
|
|
|
ifneq ($(findstring bhat, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_BH
|
|
|
|
endif
|
|
|
|
|
2015-12-13 23:18:37 -04:00
|
|
|
ifneq ($(findstring qflight, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_QFLIGHT
|
|
|
|
endif
|
|
|
|
|
2015-03-24 20:28:59 -03:00
|
|
|
ifneq ($(findstring qurt, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_QURT
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
|
|
|
|
endif
|
|
|
|
|
2016-01-05 06:36:41 -04:00
|
|
|
ifneq ($(findstring pxfmini, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_PXFMINI
|
|
|
|
endif
|
|
|
|
|
2015-05-20 21:11:20 -03:00
|
|
|
# default to SITL
|
2013-02-21 00:43:25 -04:00
|
|
|
ifeq ($(HAL_BOARD),)
|
2015-05-20 21:11:20 -03:00
|
|
|
HAL_BOARD = HAL_BOARD_SITL
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
|
2013-03-11 22:45:49 -03:00
|
|
|
endif
|
2016-01-20 08:30:00 -04:00
|
|
|
|
|
|
|
ifneq ($(findstring navio2, $(MAKECMDGOALS)),)
|
|
|
|
HAL_BOARD = HAL_BOARD_LINUX
|
|
|
|
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NAVIO2
|
|
|
|
endif
|