forked from paparazzi/paparazzi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
277 lines (216 loc) · 8.55 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
# Hey Emacs, this is a -*- makefile -*-
#
# Paparazzi main $Id$
# 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 fucking spaces allowed in the current directory name)
endif
ifeq ($(PAPARAZZI_HOME),)
PAPARAZZI_HOME=$(PAPARAZZI_SRC)
endif
LIB=sw/lib
AIRBORNE=sw/airborne
COCKPIT=sw/ground_segment/cockpit
TMTC=sw/ground_segment/tmtc
MULTIMON=sw/ground_segment/multimon
MISC=sw/ground_segment/misc
LOGALIZER=sw/logalizer
SIMULATOR=sw/simulator
MAKE=make PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME)
CONF=$(PAPARAZZI_SRC)/conf
STATICINCLUDE =$(PAPARAZZI_HOME)/var/include
MESSAGES_H=$(STATICINCLUDE)/messages.h
MESSAGES2_H=$(STATICINCLUDE)/messages2.h
UBX_PROTOCOL_H=$(STATICINCLUDE)/ubx_protocol.h
MTK_PROTOCOL_H=$(STATICINCLUDE)/mtk_protocol.h
XSENS_PROTOCOL_H=$(STATICINCLUDE)/xsens_protocol.h
DL_PROTOCOL_H=$(STATICINCLUDE)/dl_protocol.h
DL_PROTOCOL2_H=$(STATICINCLUDE)/dl_protocol2.h
MESSAGES_XML = $(CONF)/messages.xml
UBX_XML = $(CONF)/ubx.xml
MTK_XML = $(CONF)/mtk.xml
XSENS_XML = $(CONF)/xsens_MTi-G.xml
TOOLS=$(PAPARAZZI_SRC)/sw/tools
OCAML=$(shell which ocaml)
OCAMLRUN=$(shell which ocamlrun)
# try to find the paparazzi multilib toolchain
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
#found the compiler from the paparazzi multilib package
ARMGCC=$(TOOLCHAIN_DIR)/bin/arm-none-eabi-gcc
else
#try picking up the arm-none-eabi compiler from the path, otherwise use arm-elf
HAVE_ARM_NONE_EABI_GCC := $(shell which arm-none-eabi-gcc)
ifeq ($(strip $(HAVE_ARM_NONE_EABI_GCC)),)
ARMGCC=$(shell which arm-elf-gcc)
else
ARMGCC=$(HAVE_ARM_NONE_EABI_GCC)
endif
endif
all: conf commands static
static : lib center tools cockpit multimon tmtc misc logalizer lpc21iap sim_static static_h usb_lib
conf: conf/conf.xml conf/control_panel.xml conf/maps.xml FORCE
conf/%.xml :conf/%.xml.example
[ -L $@ ] || [ -f $@ ] || cp $< $@
conf/maps.xml: conf/maps.xml.example FORCE
-cd data/maps; $(MAKE)
if test ! -e $@; then cp $< $@; fi
FORCE:
lib:
cd $(LIB)/ocaml; $(MAKE)
center: lib
cd sw/supervision; $(MAKE)
tools: lib
cd $(TOOLS); $(MAKE)
logalizer: lib
cd $(LOGALIZER); $(MAKE)
sim_static : lib
cd $(SIMULATOR); $(MAKE) PAPARAZZI_SRC=$(PAPARAZZI_SRC)
cockpit: lib
cd $(COCKPIT); $(MAKE) all
tmtc: lib cockpit
cd $(TMTC); $(MAKE) all
misc:
cd $(MISC); $(MAKE) all
multimon:
cd $(MULTIMON); $(MAKE)
static_h: $(MESSAGES_H) $(MESSAGES2_H) $(UBX_PROTOCOL_H) $(MTK_PROTOCOL_H) $(XSENS_PROTOCOL_H) $(DL_PROTOCOL_H) $(DL_PROTOCOL2_H)
usb_lib:
@[ -d sw/airborne/arch/lpc21/lpcusb ] && ((test -x "$(ARMGCC)" && (cd sw/airborne/arch/lpc21/lpcusb; $(MAKE))) || echo "Not building usb_lib: ARMGCC=$(ARMGCC) not found") || echo "Not building usb_lib: sw/airborne/arch/lpc21/lpcusb directory missing"
$(MESSAGES_H) : $(MESSAGES_XML) $(CONF_XML) tools
$(Q)test -d $(STATICINCLUDE) || mkdir -p $(STATICINCLUDE)
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_messages.out $< telemetry > /tmp/msg.h
$(Q)mv /tmp/msg.h $@
$(Q)chmod a+r $@
$(MESSAGES2_H) : $(MESSAGES_XML) $(CONF_XML) tools
$(Q)test -d $(STATICINCLUDE) || mkdir -p $(STATICINCLUDE)
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_messages2.out $< telemetry > /tmp/msg2.h
$(Q)mv /tmp/msg2.h $@
$(Q)chmod a+r $@
$(UBX_PROTOCOL_H) : $(UBX_XML) tools
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_ubx.out $< > /tmp/ubx.h
$(Q)mv /tmp/ubx.h $@
$(MTK_PROTOCOL_H) : $(MTK_XML) tools
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_mtk.out $< > /tmp/mtk.h
$(Q)mv /tmp/mtk.h $@
$(XSENS_PROTOCOL_H) : $(XSENS_XML) tools
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_xsens.out $< > /tmp/xsens.h
$(Q)mv /tmp/xsens.h $@
$(DL_PROTOCOL_H) : $(MESSAGES_XML) tools
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_messages.out $< datalink > /tmp/dl.h
$(Q)mv /tmp/dl.h $@
$(DL_PROTOCOL2_H) : $(MESSAGES_XML) tools
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_messages2.out $< datalink > /tmp/dl2.h
$(Q)mv /tmp/dl2.h $@
include Makefile.ac
sim : sim_static
ac_h ac1 ac2 ac3 ac fbw ap: static conf
##### preliminary hard wired arm7 bootloader rules
#
#
# call with : make bl PROC=[TINY|FBW|AP|GENERIC]
bl:
cd $(AIRBORNE)/arch/lpc21/test/bootloader; $(MAKE) clean; $(MAKE)
BOOTLOADER_DEV=/dev/ttyUSB0
upload_bl bl.upload: bl
lpc21isp -control $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex $(BOOTLOADER_DEV) 38400 12000
JTAG_INTERFACE = olimex-jtag-tiny.cfg
#JTAG_INTERFACE = olimex-arm-usb-ocd.cfg
upload_jtag: bl
openocd -f interface/$(JTAG_INTERFACE) -f board/olimex_lpc_h2148.cfg -c init -c halt -c "flash write_image erase $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex" -c reset -c shutdown
lpc21iap:
cd sw/ground_segment/lpc21iap; $(MAKE)
upgrade_bl bl.upgrade: bl lpc21iap
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/test/bootloader/bl_ram.elf
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/test/bootloader/bl.elf
ms:
cd $(AIRBORNE)/arch/lpc21/lpcusb; $(MAKE)
cd $(AIRBORNE)/arch/lpc21/lpcusb/examples; $(MAKE)
upload_ms ms.upload: ms
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/lpcusb/examples/msc.elf
#####
#####
doxygen:
mkdir -p dox
doxygen Doxyfile
run_sitl :
$(PAPARAZZI_HOME)/var/$(AIRCRAFT)/sim/simsitl
install :
$(MAKE) -f Makefile.install PREFIX=$(PREFIX)
uninstall :
$(MAKE) -f Makefile.install PREFIX=$(PREFIX) uninstall
DISTRO=lenny
deb :
chmod u+x debian/rules
cp debian/control.$(DISTRO) debian/control
cp debian/changelog.$(DISTRO) debian/changelog
dpkg-buildpackage $(DEBFLAGS) -Ivar -rfakeroot
fast_deb:
$(MAKE) deb OCAMLC=ocamlc.opt DEBFLAGS=-b
clean:
$(Q)rm -fr dox build-stamp configure-stamp conf/%gconf.xml debian/files debian/paparazzi-base debian/paparazzi-bin
$(Q)rm -f $(MESSAGES_H) $(MESSAGES2_H) $(UBX_PROTOCOL_H) $(MTK_PROTOCOL_H) $(DL_PROTOCOL_H)
$(Q)find . -mindepth 2 -name Makefile -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \;
$(Q)find . -name '*~' -exec rm -f {} \;
$(Q)rm -f paparazzi sw/simulator/launchsitl
cleanspaces:
find ./sw/airborne -name '*.[ch]' -exec sed -i {} -e 's/[ \t]*$$//' \;
find ./conf -name '*.makefile' -exec sed -i {} -e 's/[ \t]*$$//' ';'
find ./sw -name '*.ml' -exec sed -i {} -e 's/[ \t]*$$//' ';'
find ./sw -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/maps_data conf/maps.xml
rm -rf conf/conf.xml conf/controlpanel.xml
rm -rf var
ab_clean:
find sw/airborne -name '*~' -exec rm -f {} \;
replace_current_conf_xml:
test conf/conf.xml || mv conf/conf.xml conf/conf.xml.backup.`date +%Y%m%d-%H%M%s`
cp conf/conf.xml.example conf/conf.xml
commands: paparazzi sw/simulator/launchsitl
paparazzi:
cat src/paparazzi | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
chmod a+x $@
sw/simulator/launchsitl:
cat src/$(@F) | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
chmod a+x $@
test: all replace_current_conf_xml
cd tests; $(MAKE) test