ardupilot/mk/board_native.mk

132 lines
3.4 KiB
Makefile
Raw Normal View History

TOOLCHAIN = NATIVE
include $(MK_DIR)/find_tools.mk
#
# Tool options
#
DEFINES = -DF_CPU=$(F_CPU)
DEFINES += -DSKETCH=\"$(SKETCH)\" -DSKETCHNAME="\"$(SKETCH)\"" -DSKETCHBOOK="\"$(SKETCHBOOK)\"" -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
DEFINES += $(EXTRAFLAGS)
2014-07-06 23:04:54 -03:00
DEFINES += -DCONFIG_HAL_BOARD=$(HAL_BOARD) -DCONFIG_HAL_BOARD_SUBTYPE=$(HAL_BOARD_SUBTYPE)
WARNFLAGS = -Wall -Wextra -Wformat -Wshadow -Wpointer-arith -Wcast-align \
-Wlogical-op -Wwrite-strings -Wformat=2 -Wno-unused-parameter
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 \
-Wundef \
-Wno-unknown-warning-option
2016-01-20 20:55:03 -04:00
DEPFLAGS = -MD -MP -MT $@
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
# features: TODO detect dependecy and make them optional
HAVE_LTTNG=
ifeq ($(HAVE_LTTNG),1)
DEFINES += -DPERF_LTTNG=1
LIBS += -llttng-ust -ldl
endif
# disable as this breaks distcc
#ifneq ($(SYSTYPE),Darwin)
#LISTOPTS = -adhlns=$(@:.o=.lst)
#endif
2013-03-29 03:25:36 -03:00
CPUFLAGS = -D_GNU_SOURCE
CPULDFLAGS = -g
OPTFLAGS ?= -O3 -g
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)
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)
LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP)
2013-07-04 13:01:16 -03:00
endif
LIBS ?= -lm -pthread
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
LIBS += -lwinmm
endif
ifeq ($(VERBOSE),)
v = @
else
v =
endif
# Library object files
LIBOBJS := $(SKETCHLIBOBJS)
################################################################################
# Built products
#
# The ELF file
SKETCHELF = $(BUILDROOT)/$(SKETCH).elf
BUILDELF = $(notdir $(SKETCHELF))
# 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
# Link the final object
$(SKETCHELF): $(SKETCHOBJS) $(LIBOBJS)
@echo "Building $(SKETCHELF)"
$(RULEHDR)
$(v)$(LD) $(LDFLAGS) -o $@ $(SKETCHOBJS) $(LIBOBJS) $(LIBS)
$(v)cp $(SKETCHELF) .
@echo "Firmware is in $(BUILDELF)"
2015-12-13 23:18:37 -04:00
endif
2015-06-01 00:02:18 -03:00
SKETCH_INCLUDES = $(SKETCHLIBINCLUDES)
SLIB_INCLUDES = -I$(dir $<)/utility $(SKETCHLIBINCLUDES)
include $(MK_DIR)/build_rules.mk