2013-02-21 00:43:25 -04:00
|
|
|
TOOLCHAIN = NATIVE
|
|
|
|
|
|
|
|
include $(MK_DIR)/find_tools.mk
|
|
|
|
|
2017-04-02 11:57:12 -03:00
|
|
|
UAVCAN_DIRECTORY ?= $(SKETCHBOOK)/modules/uavcan
|
|
|
|
UAVCAN_DIR=$(shell cd $(UAVCAN_DIRECTORY) && pwd)/
|
|
|
|
|
2016-04-04 19:41:27 -03:00
|
|
|
# Hardcoded libraries/AP_Common/missing/cmath defines in "make" to retain the current behavior
|
|
|
|
EXTRAFLAGS += -DHAVE_CMATH_ISFINITE -DNEED_CMATH_ISFINITE_STD_NAMESPACE
|
|
|
|
|
2016-07-08 10:49:47 -03:00
|
|
|
EXTRAFLAGS += -DHAVE_ENDIAN_H -DHAVE_BYTESWAP_H
|
2017-04-02 11:57:12 -03:00
|
|
|
|
|
|
|
# Since actual compiler mode is C++11, the library will default to UAVCAN_CPP11, but it will fail to compile
|
|
|
|
# because this platform lacks most of the standard library and STL. Hence we need to force C++03 mode.
|
|
|
|
EXTRAFLAGS += -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 -DUAVCAN_NO_ASSERTIONS -DUAVCAN_NULLPTR=nullptr
|
|
|
|
|
|
|
|
EXTRAFLAGS += -I$(UAVCAN_DIRECTORY)/libuavcan/include
|
|
|
|
EXTRAFLAGS += -I$(UAVCAN_DIRECTORY)/libuavcan/include/dsdlc_generated
|
|
|
|
|
2013-02-21 00:43:25 -04:00
|
|
|
#
|
|
|
|
# Tool options
|
|
|
|
#
|
|
|
|
DEFINES = -DF_CPU=$(F_CPU)
|
2015-05-10 08:01:30 -03:00
|
|
|
DEFINES += -DSKETCH=\"$(SKETCH)\" -DSKETCHNAME="\"$(SKETCH)\"" -DSKETCHBOOK="\"$(SKETCHBOOK)\"" -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
|
2015-05-20 21:11:20 -03:00
|
|
|
DEFINES += $(EXTRAFLAGS)
|
2014-07-06 23:04:54 -03:00
|
|
|
DEFINES += -DCONFIG_HAL_BOARD=$(HAL_BOARD) -DCONFIG_HAL_BOARD_SUBTYPE=$(HAL_BOARD_SUBTYPE)
|
2016-02-11 00:50:46 -04:00
|
|
|
WARNFLAGS = -Wall -Wextra -Wformat -Wshadow -Wpointer-arith -Wcast-align \
|
2015-11-30 02:26:04 -04:00
|
|
|
-Wlogical-op -Wwrite-strings -Wformat=2 -Wno-unused-parameter -Wno-unknown-pragmas -Wno-trigraphs
|
2016-02-11 00:50:46 -04:00
|
|
|
WARNFLAGSCXX = \
|
|
|
|
-Wno-missing-field-initializers \
|
|
|
|
-Wno-reorder \
|
|
|
|
-Werror=format-security \
|
|
|
|
-Werror=array-bounds \
|
|
|
|
-Werror=unused-but-set-variable \
|
|
|
|
-Werror=uninitialized \
|
|
|
|
-Werror=init-self \
|
2016-01-20 20:55:03 -04:00
|
|
|
-Wfatal-errors \
|
2016-03-05 09:51:11 -04:00
|
|
|
-Wundef \
|
2015-11-30 02:26:04 -04:00
|
|
|
-Wno-unknown-warning-option \
|
|
|
|
-Wno-trigraphs
|
2015-11-25 08:45:26 -04:00
|
|
|
DEPFLAGS = -MD -MP -MT $@
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
CXXOPTS = -ffunction-sections -fdata-sections -fno-exceptions -fsigned-char
|
|
|
|
COPTS = -ffunction-sections -fdata-sections -fsigned-char
|
|
|
|
|
|
|
|
ASOPTS = -x assembler-with-cpp
|
2013-07-04 13:01:16 -03:00
|
|
|
|
2016-01-13 13:40:35 -04:00
|
|
|
# features: TODO detect dependecy and make them optional
|
2016-05-21 11:47:52 -03:00
|
|
|
HAVE_LTTNG_UST=
|
2016-01-13 13:40:35 -04:00
|
|
|
|
2016-05-21 11:47:52 -03:00
|
|
|
ifeq ($(HAVE_LTTNG_UST),1)
|
|
|
|
DEFINES += -DHAVE_LTTNG_UST=1
|
2016-01-13 13:40:35 -04:00
|
|
|
LIBS += -llttng-ust -ldl
|
|
|
|
endif
|
|
|
|
|
2014-07-06 21:27:04 -03:00
|
|
|
# disable as this breaks distcc
|
|
|
|
#ifneq ($(SYSTYPE),Darwin)
|
|
|
|
#LISTOPTS = -adhlns=$(@:.o=.lst)
|
|
|
|
#endif
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2013-03-29 03:25:36 -03:00
|
|
|
CPUFLAGS = -D_GNU_SOURCE
|
|
|
|
CPULDFLAGS = -g
|
2015-05-03 19:10:54 -03:00
|
|
|
OPTFLAGS ?= -O3 -g
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2014-07-06 23:04:54 -03:00
|
|
|
CXXFLAGS = -g $(CPUFLAGS) $(DEFINES) $(OPTFLAGS)
|
2015-05-17 18:26:48 -03:00
|
|
|
CXXFLAGS += -std=gnu++11 $(WARNFLAGS) $(WARNFLAGSCXX) $(DEPFLAGS) $(CXXOPTS)
|
2013-02-21 00:43:25 -04:00
|
|
|
CFLAGS = -g $(CPUFLAGS) $(DEFINES) -Wa,$(LISTOPTS) $(OPTFLAGS)
|
|
|
|
CFLAGS += $(WARNFLAGS) $(DEPFLAGS) $(COPTS)
|
|
|
|
ASFLAGS = -g $(CPUFLAGS) $(DEFINES) -Wa,$(LISTOPTS) $(DEPFLAGS)
|
|
|
|
ASFLAGS += $(ASOPTS)
|
|
|
|
LDFLAGS = -g $(CPUFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
2013-07-04 13:01:16 -03:00
|
|
|
|
|
|
|
ifneq ($(SYSTYPE),Darwin)
|
2013-02-21 00:43:25 -04:00
|
|
|
LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP)
|
2013-07-04 13:01:16 -03:00
|
|
|
endif
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2016-06-21 07:51:01 -03:00
|
|
|
LIBS ?= -lm -pthread
|
|
|
|
|
2016-07-06 11:10:59 -03:00
|
|
|
ifneq ($(SYSTYPE),Darwin)
|
|
|
|
LIBS += -lrt
|
|
|
|
endif
|
2015-05-25 03:48:13 -03:00
|
|
|
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
|
|
|
|
LIBS += -lwinmm
|
|
|
|
endif
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
ifeq ($(VERBOSE),)
|
|
|
|
v = @
|
|
|
|
else
|
|
|
|
v =
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Library object files
|
|
|
|
LIBOBJS := $(SKETCHLIBOBJS)
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Built products
|
|
|
|
#
|
|
|
|
|
|
|
|
# The ELF file
|
|
|
|
SKETCHELF = $(BUILDROOT)/$(SKETCH).elf
|
2014-11-13 02:27:53 -04:00
|
|
|
BUILDELF = $(notdir $(SKETCHELF))
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
# HEX file
|
|
|
|
SKETCHHEX = $(BUILDROOT)/$(SKETCH).hex
|
|
|
|
|
|
|
|
# EEP file
|
|
|
|
SKETCHEEP = $(BUILDROOT)/$(SKETCH).eep
|
|
|
|
|
|
|
|
# Map file
|
|
|
|
SKETCHMAP = $(BUILDROOT)/$(SKETCH).map
|
|
|
|
|
|
|
|
# All of the objects that may be built
|
|
|
|
ALLOBJS = $(SKETCHOBJS) $(LIBOBJS)
|
|
|
|
|
|
|
|
# All of the dependency files that may be generated
|
|
|
|
ALLDEPS = $(ALLOBJS:%.o=%.d)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Targets
|
|
|
|
#
|
|
|
|
|
|
|
|
all: $(SKETCHELF)
|
|
|
|
|
|
|
|
print-%:
|
|
|
|
echo "$*=$($*)"
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Rules
|
|
|
|
#
|
|
|
|
|
|
|
|
# fetch dependency info from a previous build if any of it exists
|
|
|
|
-include $(ALLDEPS)
|
|
|
|
|
2015-12-13 23:18:37 -04:00
|
|
|
ifeq ($(HAL_BOARD_SUBTYPE),HAL_BOARD_SUBTYPE_LINUX_QFLIGHT)
|
|
|
|
include $(MK_DIR)/board_qflight.mk
|
|
|
|
else
|
2013-02-21 00:43:25 -04:00
|
|
|
# Link the final object
|
2015-05-31 21:09:43 -03:00
|
|
|
$(SKETCHELF): $(SKETCHOBJS) $(LIBOBJS)
|
2013-04-02 00:18:42 -03:00
|
|
|
@echo "Building $(SKETCHELF)"
|
2013-02-21 00:43:25 -04:00
|
|
|
$(RULEHDR)
|
2015-05-31 21:09:43 -03:00
|
|
|
$(v)$(LD) $(LDFLAGS) -o $@ $(SKETCHOBJS) $(LIBOBJS) $(LIBS)
|
2014-11-13 02:27:53 -04:00
|
|
|
$(v)cp $(SKETCHELF) .
|
|
|
|
@echo "Firmware is in $(BUILDELF)"
|
2015-12-13 23:18:37 -04:00
|
|
|
endif
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2017-04-02 11:57:12 -03:00
|
|
|
SKETCH_INCLUDES = $(SKETCHLIBINCLUDES) -I$(UAVCAN_DIRECTORY)/libuavcan/include -I$(UAVCAN_DIRECTORY)/libuavcan/include/dsdlc_generated
|
|
|
|
SLIB_INCLUDES = -I$(dir $<)/utility $(SKETCHLIBINCLUDES) -I$(UAVCAN_DIRECTORY)/libuavcan/include -I$(UAVCAN_DIRECTORY)/libuavcan/include/dsdlc_generated
|
2015-06-01 00:02:18 -03:00
|
|
|
|
2015-05-31 21:09:43 -03:00
|
|
|
include $(MK_DIR)/build_rules.mk
|