forked from paparazzi/paparazzi
-
Notifications
You must be signed in to change notification settings - Fork 108
/
Makefile
352 lines (278 loc) · 10.9 KB
/
Makefile
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2004 Pascal Brisset Antoine Drouin
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# The default is to produce a quiet echo of compilation commands
# Launch with "make Q=''" to get full echo
Q=@
ifeq ($(Q),@)
MAKEFLAGS += --no-print-directory
endif
PAPARAZZI_SRC ?= $(shell pwd)
empty=
space=$(empty) $(empty)
ifneq ($(findstring $(space),$(PAPARAZZI_SRC)),)
$(error No spaces allowed in the current directory name)
endif
ifeq ($(PAPARAZZI_HOME),)
PAPARAZZI_HOME=$(PAPARAZZI_SRC)
endif
# export the PAPARAZZI environment to sub-make
export PAPARAZZI_SRC
export PAPARAZZI_HOME
OCAML=$(shell which ocaml)
OCAMLRUN=$(shell which ocamlrun)
BUILD_DATETIME:=$(shell date +%Y%m%d-%H%M%S)
# default mktemp in OS X doesn't work, use gmktemp with macports coreutils
UNAME = $(shell uname -s)
ifeq ("$(UNAME)","Darwin")
MKTEMP = gmktemp
else
MKTEMP = mktemp
endif
#
# define some paths
#
LIB=sw/lib
STATICINCLUDE=$(PAPARAZZI_HOME)/var/include
CONF=$(PAPARAZZI_SRC)/conf
AIRBORNE=sw/airborne
SIMULATOR=sw/simulator
COCKPIT=sw/ground_segment/cockpit
TMTC=sw/ground_segment/tmtc
GENERATORS=$(PAPARAZZI_SRC)/sw/tools/generators
JOYSTICK=sw/ground_segment/joystick
EXT=sw/ext
TOOLS=sw/tools
#
# build some stuff in subdirs
# nothing should depend on these...
#
PPRZCENTER=sw/supervision
MISC=sw/ground_segment/misc
LOGALIZER=sw/logalizer
SUBDIRS = $(PPRZCENTER) $(LOGALIZER) sw/tools
SUBDIRS_EXTRA = $(MISC)
#
# Communication protocol version
#
PPRZLINK_LIB_VERSION ?= 2.0
#
# xml files used as input for header generation
#
CUSTOM_MESSAGES_XML = $(CONF)/messages.xml
ABI_XML = $(CONF)/abi.xml
UBX_XML = $(CONF)/ubx.xml
MTK_XML = $(CONF)/mtk.xml
XSENS_XML = $(CONF)/xsens_MTi-G.xml
#
# generated header files
#
PPRZLINK_DIR=sw/ext/pprzlink
PPRZLINK_INSTALL=$(PAPARAZZI_HOME)/var/lib
MESSAGES_INSTALL=$(PAPARAZZI_HOME)/var
UBX_PROTOCOL_H=$(STATICINCLUDE)/ubx_protocol.h
MTK_PROTOCOL_H=$(STATICINCLUDE)/mtk_protocol.h
XSENS_PROTOCOL_H=$(STATICINCLUDE)/xsens_protocol.h
ABI_MESSAGES_H=$(STATICINCLUDE)/abi_messages.h
MAVLINK_DIR=$(STATICINCLUDE)/mavlink/
MAVLINK_PROTOCOL_H=$(MAVLINK_DIR)protocol.h
GEN_HEADERS = $(UBX_PROTOCOL_H) $(MTK_PROTOCOL_H) $(XSENS_PROTOCOL_H) $(ABI_MESSAGES_H)
core: ground_segment ext subdirs_extra
all: ground_segment ext subdirs_extra $(MAVLINK_PROTOCOL_H)
_print_building:
@echo "------------------------------------------------------------"
@echo "Building Paparazzi version" $(shell ./paparazzi_version)
@echo "------------------------------------------------------------"
print_build_version:
@echo "------------------------------------------------------------"
@echo "Last build Paparazzi version" $(shell cat $(PAPARAZZI_HOME)/var/build_version.txt 2> /dev/null || echo UNKNOWN)
@echo "------------------------------------------------------------"
_save_build_version:
$(Q)test -d $(PAPARAZZI_HOME)/var || mkdir -p $(PAPARAZZI_HOME)/var
$(Q)./paparazzi_version > $(PAPARAZZI_HOME)/var/build_version.txt
init:
@[ -d $(PAPARAZZI_HOME) ] || (echo "Copying config example in your $(PAPARAZZI_HOME) directory"; mkdir -p $(PAPARAZZI_HOME); cp -a conf $(PAPARAZZI_HOME); cp -a data $(PAPARAZZI_HOME); mkdir -p $(PAPARAZZI_HOME)/var/maps; mkdir -p $(PAPARAZZI_HOME)/var/include)
conf: conf/conf.xml conf/control_panel.xml conf/tools/blacklisted
conf/%.xml :conf/%_example.xml
[ -L $@ ] || [ -f $@ ] || cp $< $@
conf/tools/blacklisted: conf/tools/blacklisted_example
cp conf/tools/blacklisted_example conf/tools/blacklisted
ground_segment: _print_building conf libpprz subdirs static
ground_segment.opt: ground_segment cockpit.opt tmtc.opt
static: cockpit tmtc generators sim_static joystick static_h
libpprzlink.update:
$(MAKE) -C $(EXT) pprzlink.update
libpprzlink.install:
$(Q)Q=$(Q) MAKEFLAGS=-j1 DESTDIR=$(PPRZLINK_INSTALL) PPRZLINK_LIB_VERSION=${PPRZLINK_LIB_VERSION} $(MAKE) -C $(PPRZLINK_DIR) libpprzlink-install
libpprz: libpprzlink.update libpprzlink.install _save_build_version
$(MAKE) -C $(LIB)/ocaml
cockpit: libpprz
$(MAKE) -C $(COCKPIT)
cockpit.opt: libpprz
$(MAKE) -C $(COCKPIT) opt
tmtc: libpprz
$(MAKE) -C $(TMTC)
tmtc.opt: libpprz
$(MAKE) -C $(TMTC) opt
generators: libpprz
$(MAKE) -C $(GENERATORS)
joystick: libpprz
$(MAKE) -C $(JOYSTICK)
sim_static: libpprz
$(MAKE) -C $(SIMULATOR)
ext:
$(MAKE) -C $(EXT)
$(MAKE) -C $(TOOLS)/bluegiga_usb_dongle
opencv_bebop:
$(MAKE) -C $(EXT) opencv_bebop
#
# make misc subdirs
#
subdirs: $(SUBDIRS)
subdirs_extra: $(SUBDIRS_EXTRA)
$(MISC): ext
$(SUBDIRS): libpprz
$(MAKE) -C $@
$(SUBDIRS_EXTRA): libpprz
$(MAKE) -C $@
$(PPRZCENTER): libpprz
$(LOGALIZER): libpprz
static_h: pprzlink_protocol $(GEN_HEADERS)
pprzlink_protocol : libpprz
$(Q)test -d $(STATICINCLUDE) || mkdir -p $(STATICINCLUDE)
$(Q)test -d $(STATICLIB) || mkdir -p $(STATICLIB)
ifeq ("$(wildcard $(CUSTOM_MESSAGES_XML))","")
@echo GENERATE $@ with default messages
$(Q)Q=$(Q) MESSAGES_INSTALL=$(MESSAGES_INSTALL) VALIDATE_XML=FALSE PPRZLINK_LIB_VERSION=${PPRZLINK_LIB_VERSION} $(MAKE) -C $(PPRZLINK_DIR) pymessages
else
@echo GENERATE $@ with custome messages from $(CUSTOM_MESSAGES_XML)
$(Q)Q=$(Q) MESSAGES_XML=$(CUSTOM_MESSAGES_XML) MESSAGES_INSTALL=$(MESSAGES_INSTALL) PPRZLINK_LIB_VERSION=${PPRZLINK_LIB_VERSION} $(MAKE) -C $(PPRZLINK_DIR) pymessages
endif
$(UBX_PROTOCOL_H) : $(UBX_XML) generators
@echo GENERATE $@
$(eval $@_TMP := $(shell $(MKTEMP)))
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(GENERATORS)/gen_ubx.out $< > $($@_TMP)
$(Q)mv $($@_TMP) $@
$(Q)chmod a+r $@
$(MTK_PROTOCOL_H) : $(MTK_XML) generators
@echo GENERATE $@
$(eval $@_TMP := $(shell $(MKTEMP)))
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(GENERATORS)/gen_mtk.out $< > $($@_TMP)
$(Q)mv $($@_TMP) $@
$(Q)chmod a+r $@
$(XSENS_PROTOCOL_H) : $(XSENS_XML) generators
@echo GENERATE $@
$(eval $@_TMP := $(shell $(MKTEMP)))
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(GENERATORS)/gen_xsens.out $< > $($@_TMP)
$(Q)mv $($@_TMP) $@
$(Q)chmod a+r $@
$(ABI_MESSAGES_H) : $(ABI_XML) generators
@echo GENERATE $@
$(eval $@_TMP := $(shell $(MKTEMP)))
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(GENERATORS)/gen_abi.out $< airborne > $($@_TMP)
$(Q)mv $($@_TMP) $@
$(Q)chmod a+r $@
$(MAVLINK_PROTOCOL_H) :
$(Q)make -C $(PAPARAZZI_HOME)/sw/ext mavlink
#
# code generation for aircrafts from xml files
#
include Makefile.ac
ac_h ac fbw ap: static conf generators ext
sim: sim_static
#
# doxygen html documentation
#
dox:
$(Q)PAPARAZZI_HOME=$(PAPARAZZI_HOME) sw/tools/doxygen_gen/gen_modules_doc.py -pv
$(Q)PAPARAZZI_HOME=$(PAPARAZZI_HOME) sw/tools/doxygen_gen/gen_messages_doc.py -pv
@echo "Generationg doxygen html documentation in doc/generated/html"
$(Q)( cat Doxyfile ; echo "PROJECT_NUMBER=$(./paparazzi_version)"; echo "QUIET=YES") | doxygen -
@echo "Done. Open doc/generated/html/index.html in your browser to view it."
#
# Cleaning
#
clean:
$(Q)rm -fr dox build-stamp configure-stamp conf/%gconf.xml
$(Q)rm -f $(GEN_HEADERS)
$(Q)MESSAGES_INSTALL=$(MESSAGES_INSTALL) $(MAKE) -C $(PPRZLINK_DIR) uninstall
$(Q)rm -fr $(MAVLINK_DIR)
$(Q)find . -mindepth 2 -name Makefile -a ! -path "./sw/ext/*" -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \;
$(Q)$(MAKE) -C $(EXT) clean
$(Q)find . -name '*~' -exec rm -f {} \;
$(Q)find . -name '*.pyc' -exec rm -f {} \;
$(Q)find . -name 'Cargo.lock' -exec rm -f {} \;
cleanspaces:
find sw -path sw/ext -prune -o -type f -name '*.[ch]' -exec sed -i {} -e 's/[ \t]*$$//' \;
find sw -path sw/ext -prune -o -type f -name '*.py' -exec sed -i {} -e 's/[ \t]*$$//' \;
find conf -name '*.makefile' -exec sed -i {} -e 's/[ \t]*$$//' ';'
find . -path ./sw/ext -prune -o -name Makefile -exec sed -i {} -e 's/[ \t]*$$//' ';'
find sw -name '*.ml' -o -name '*.mli' -exec sed -i {} -e 's/[ \t]*$$//' ';'
find conf -name '*.xml' -exec sed -i {} -e 's/[ \t]*$$//' ';'
distclean : dist_clean
dist_clean :
@echo "Warning: This removes all non-repository files. This means you will loose your aircraft list, your maps, your logfiles, ... if you want this, then run: make dist_clean_irreversible"
dist_clean_irreversible: clean
rm -rf conf/conf.xml conf/controlpanel.xml
rm -rf var
ab_clean:
find sw/airborne -name '*~' -exec rm -f {} \;
#
# Tests
#
test: test_math test_examples test_modules
# subset of airframes for coverity test to pass the limited build time on travis
test_coverity: all
CONF_XML=conf/conf_tests_coverity.xml prove tests/aircrafts/
# test AggieAir conf
test_aggieair: all
CONF_XML=conf/airframes/AGGIEAIR/aggieair_conf.xml prove tests/aircrafts/
# test MAVLab users conf
test_mavlab: all
CONF_XML=conf/userconf/OPENUAS/openuas_conf.xml prove tests/aircrafts/
CONF_XML=conf/airframes/CDW/cdw_conf.xml prove tests/aircrafts/
CONF_XML=conf/airframes/BR/conf.xml prove tests/aircrafts/
# test TU Delft conf
test_tudelft: all
CONF_XML=conf/userconf/tudelft/conf.xml prove tests/aircrafts/
CONF_XML=conf/userconf/tudelft/delfly_conf.xml prove tests/aircrafts/
CONF_XML=conf/userconf/tudelft/course_conf.xml prove tests/aircrafts/
CONF_XML=conf/userconf/tudelft/guido_conf.xml prove tests/aircrafts/
# test GVF conf
test_gvf: all
CONF_XML=conf/userconf/GVF/gvf_conf.xml prove tests/aircrafts/
# compiles all aircrafts in conf_tests.xml
test_examples: all
CONF_XML=conf/conf_tests.xml prove tests/aircrafts/
# test compilation of modules
test_modules: all
prove -v tests/modules/test_modules.py
test_all_confs: all opencv_bebop
$(Q)$(eval $CONFS:=$(shell ./find_confs.py))
@echo "************\nFound $(words $($CONFS)) config files: $($CONFS)"
$(Q)$(foreach conf,$($CONFS),echo "\n************\nTesting all aircrafts in conf: $(conf)\n************" && (CONF_XML=$(conf) prove tests/aircrafts/ || echo "failed $(conf)" >> TEST_ALL_CONFS_FAILED);) test -f TEST_ALL_CONFS_FAILED && cat TEST_ALL_CONFS_FAILED && rm -f TEST_ALL_CONFS_FAILED && exit 1; exit 0
# run some math tests that don't need whole paparazzi to be built
test_math:
make -C tests/math
.PHONY: all print_build_version _print_building _save_build_version init dox ground_segment ground_segment.opt \
subdirs $(SUBDIRS) conf ext libpprz libpprzlink.update libpprzlink.install cockpit cockpit.opt tmtc tmtc.opt generators\
static sim_static opencv_bebop\
clean cleanspaces ab_clean dist_clean distclean dist_clean_irreversible \
test test_examples test_math test_all_confs