forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard_native.mk
150 lines (115 loc) · 4.45 KB
/
board_native.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
TOOLCHAIN = NATIVE
include $(MK_DIR)/find_tools.mk
UAVCAN_DIRECTORY ?= $(SKETCHBOOK)/modules/uavcan
UAVCAN_DIR=$(shell cd $(UAVCAN_DIRECTORY) && pwd)/
# Hardcoded libraries/AP_Common/missing/cmath defines in "make" to retain the current behavior
EXTRAFLAGS += -DHAVE_CMATH_ISFINITE -DNEED_CMATH_ISFINITE_STD_NAMESPACE
EXTRAFLAGS += -DHAVE_ENDIAN_H -DHAVE_BYTESWAP_H
# 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
#
# Tool options
#
DEFINES = -DF_CPU=$(F_CPU)
DEFINES += -DSKETCH=\"$(SKETCH)\" -DSKETCHNAME="\"$(SKETCH)\"" -DSKETCHBOOK="\"$(SKETCHBOOK)\"" -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
DEFINES += $(EXTRAFLAGS)
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 -Wno-unknown-pragmas -Wno-trigraphs
WARNFLAGSCXX = \
-Wno-missing-field-initializers \
-Wno-reorder \
-Werror=format-security \
-Werror=array-bounds \
-Werror=unused-but-set-variable \
-Werror=uninitialized \
-Werror=init-self \
-Wfatal-errors \
-Wundef \
-Wno-unknown-warning-option \
-Wno-trigraphs
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
# features: TODO detect dependecy and make them optional
HAVE_LTTNG_UST=
ifeq ($(HAVE_LTTNG_UST),1)
DEFINES += -DHAVE_LTTNG_UST=1
LIBS += -llttng-ust -ldl
endif
# disable as this breaks distcc
#ifneq ($(SYSTYPE),Darwin)
#LISTOPTS = -adhlns=$(@:.o=.lst)
#endif
CPUFLAGS = -D_GNU_SOURCE
CPULDFLAGS = -g
OPTFLAGS ?= -O3 -g
CXXFLAGS = -g $(CPUFLAGS) $(DEFINES) $(OPTFLAGS)
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)
ifneq ($(SYSTYPE),Darwin)
LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP)
endif
LIBS ?= -lm -pthread
ifneq ($(SYSTYPE),Darwin)
LIBS += -lrt
endif
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)
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)"
endif
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
include $(MK_DIR)/build_rules.mk