-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-daemons-HOWTO.txt
409 lines (267 loc) · 13.9 KB
/
build-daemons-HOWTO.txt
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
This document contains a description to compile dessert daemons and to create daemon packages to
deployed in a daemon repository. Furthermore it tries to describe the used arguments and tools.
Supported systems are: Linux, Mac OS X and Cygwin
[Only Cygwin and Linux are tested while Cygwin had most mileage]
----------------------------------------------------------------------------------------------------
!!! DISCLAIMER !!!
Since each daemon project is fully under the care of the corresponding developer there is no
guarantee that a given dessert daemon project can be compiled at all. The descriptions here
where fully working at the time of writing but might be outdated at the time of reading.
----------------------------------------------------------------------------------------------------
Prerequisites:
- Android NDK Revision 4b or newer (http://developer.android.com/sdk/ndk/index.html)
- android-gcc wrapper perl script (part of the thesis; check <thesis-root>/Src/tools)
- android-strip wrapper perl script (part of the thesis; check <thesis-root>/Src/tools)
[actually this is optional]
- DES-SERT and dependencies libraries and their headers.
[this should come as a tarball and should correspond to the tarball used in building
the targeted version of the dessert manager application]
- (optional) dessert manager application sources
[they include XML schemas to be used in offline validation of XML files]
- (optional) Cygwin latest version; only needed if you want to compile on windows systems
All references to directories in this document are relative to a common build directory.
The directory of each daemon project is assumed to be in a subdirectory of the common build
directory unless otherwise noted in the preparations section.
The common include directory and the common libraries directory is assumed to be "tmp/include" and
"tmp/libs" (keep in mind this is relative to the common build directory). Feel free to change any
occurrence of "tmp" to your own liking.
Build artifacts are always placed in the source directory of the daemon project. No file should be
installed as it is not necessary.
----------------------------------------------------------------------------------------------------
Preparations:
---
Place the path of the android-gcc and android-strip wrapper scripts on the "PATH".
---
For the android-gcc and android-strip wrapper to function they must know the path of the NDK
installation. This is achieved by configuring the environment variable "ANDROID_NDK_HOME". The
wrappers are trying to guess the host system but in case of invalid identification please set
"ANDROID_NDK_PLATFORM" to either "linux-x86", "darwin-x86" or "windows". Furthermore the wrapper
assume a GCC 4.4.0 exists. This should be the case for NDK Revision 4b and NDK Revision 5 but in
case this is not true you can set "ANDROID_NDK_GCC_VERSION" to any version that exists in the
installed Android NDK.
To check if all is configured properly just run "android-gcc --version" and
"android-strip --version". The output should be
$ android-gcc --version
arm-eabi-gcc (GCC) 4.4.0
[...]
$ android-strip --version
GNU strip (GNU Binutils) 2.19
[...]
In case it doesn not work the paths that are checked for existance are: (in perl)
my $host_dir = "${ndk_home}/build/prebuilt/${ndk_host}";
my $toolchain_dir = "${host_dir}/arm-eabi-${ndk_gcc_version}";
my $gcc_exec = "${toolchain_dir}/bin/arm-eabi-gcc";
my $strip_exec = "${toolchain_dir}/bin/arm-eabi-strip";
my $platform_dir = "${ndk_home}/build/platforms/${ndk_platform}";
---
Untar the content of the dessert tarball into "tmp". Make sure that now there is a "tmp/include"
and "tmp/lib" directory.
----------------------------------------------------------------------------------------------------
Common build arguments:
There are a few recurring arguments to the build calls that can be used:
- CC="android-gcc"
Sets the compiler to use. In this case we want to use the android wrapper script.
- DESTDIR=".." and PREFIX="/tmp"
- DESTDIR="`pwd`/.." and PREFIX="/tmp"
- DESTDIR="/bin" PREFIX="`pwd`/../tmp/"
Or with any similiar values is used to force the build output to the "tmp" folder.
- CFLAGS="[...] -I`pwd`/../tmp/include [...]"
Must be set to find the additional includes (e.g. netinet/ipv6.h and uthash)
- LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert "
Adds an additional path to the search paths of the linker and includes the libdessert
library in the set of linked libraries.
Please note that the effect of some these arguments if not all of them can actually be achieved by
creating a proper Makefile that can handle Android.
----------------------------------------------------------------------------------------------------
Optional build step:
You can call "android-strip <binaryfile>" for each binary executable of the daemon builds to strip
them off any debug symbols. This safes about 10 to 20 percent of the file size.
----------------------------------------------------------------------------------------------------
Common problems and how to solve them:
* Some daemons still use the deprecated define "DESSERT_LOG_DEBUG" which is not part of the current
dessert header files.
Just remove any occurrences of it and you should be fine.
* Some daemons still use the deprecated define "DESSERT_MAXFRAMELEN" which is not part of the
dessert header files.
Just replace any use of it with "dessert_maxlen"
* Some daemons use an extension of the of printfs that is available from the GNU libc but that is
not supported by the bionic libc. This extension is used to print custom format types. Daemon
implementation use it to print mac addresses with "%M" and supplying a pointer to the 6 byte long
mac address type.
You can replace the occurences of "%M" in printf format strings with:
"%02x:%02x:%02x:%02x:%02x:%02x".
Replace the pointer to the address with (macro defined in dessert.h): (address variable is "host_addr")
EXPLODE_ARRAY6(host_addr)
A complete example would be:
printf("%02x:%02x:%02x:%02x:%02x:%02x", EXPLODE_ARRAY6(host_addr) );
Now remove from the main source file
- #include <printf.h>
- function print_macaddress_arginfo
- function print_macaddress
- the call to register_printf_function in main()
* Some daemons use a set compiler executable in their Makefiles instead of the variable CC.
You need to find the use of for example "gcc" and replace it with a proper call that utilizes
the variable CC. The actual line depends heavily on the Makefile that is causing the problem.
* Sometimes you run into problems with undefined symbols while linking especially when ones that are
related to time or ethernet.
Before doing any exhaustive problem finding just try and throw the following two lines at the
problem and see if it helps
#include <linux/if_ether.h>
#include <sys/time.h>
In case it does not help unfortunatly you have to figure out the problem yourself.
----------------------------------------------------------------------------------------------------
Example calls to build existing daemons as the time of writing:
(lines starting with !!! denote a problem that is described above)
[there are further important informations at the end of this file about the packaging
so please skip the build instructions if you are not interested in them]
---
des-example
!!! DESSERT_LOG_DEBUG
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-ara
!!! %M
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include -DTARGET_LINUX -DVERSION_MAJOR=1 -DVERSION_MINOR=9" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
Description:
- CFLAGS"[...] -DVERSION_MAJOR=1 -DVERSION_MINOR=3 [...]"
Make sure they match the version values in the Makefile. Somehow they do not get picked up.
---
des-gossiping
!!! DESSERT_LOG_DEBUG
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-gossiping-adv
!!! DESSERT_LOG_NODEBUG
!!! DESSERT_MAXFRAMELEN
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-aodv
!!! %M
!!! #include <linux/if_ether.h> and #include <sys/time.h>
!!! "gcc" in Makefile
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-aodv-mp
!!! #include <linux/if_ether.h> and #include <sys/time.h>
!!! "gcc" in Makefile
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-batman
!!! #include <linux/if_ether.h> and #include <sys/time.h>
!!! "gcc" in Makefile
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-dsr
!!! %M
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-lsr
checkout
!!! #include <linux/if_ether.h> and #include <sys/time.h>
!!! "gcc" in Makefile
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include -DTARGET_LINUX -DVERSION_MAJOR=1 -DVERSION_MINOR=3" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
Description:
- CFLAGS"[...] -DVERSION_MAJOR=1 -DVERSION_MINOR=3 [...]"
Make sure they match the version values in the Makefile. Somehow they do not get picked up.
---
des-olsr
!!! #include <linux/if_ether.h> and #include <sys/time.h>
!!! "gcc" in Makefile
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-satman
!!! #include <linux/if_ether.h> and #include <sys/time.h>
!!! "gcc" in Makefile
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
---
des-namtab
!!! #include <linux/if_ether.h> and #include <sys/time.h>
!!! "gcc" in Makefile
make CC="android-gcc" CFLAGS="-I`pwd`/../tmp/include" \
LDFLAGS="-L`pwd`/../tmp/lib -Wl,-rpath-link=`pwd`/../tmp/lib -ldessert " \
DESTDIR="/bin" PREFIX="`pwd`/../tmp/" clean all
----------------------------------------------------------------------------------------------------
Packaging of a daemon:
A daemon package is simple ZIP file containing the following six files in a flat (READ: NOT IN A
DIRECTORY) hierarchy:
- daemon
- icon.png
- daemon.properties
- launcher.xml
- config.template
- manager.xml
---
daemon:
The binary executable of the daemon as created above.
---
icon.png:
Icon file to be used in the installed tab. The size should be around 40x40 pixels. There is no
separate low/mid/high dpi support.
---
daemon.properties:
The description of the daemon. The keys are
- daemon.name : display name of the daemon {alphanumeric and '_' and '-' and '.'}
- daemon.version : arbitrary version string {alphanumeric and '_' and '-' and '.'}
[recommended is the actual version of the daemon e.g. 1.9]
- daemon.dessert.application.version : version mask that must match against the application
version for the daemon to be marked as compatible. mask is either x.y.z or a.b.c-x.y.z where
x,y,z,a,b and c are integer numbers or the wildcard symbol '*'. the latter mask type defines
a range from a.b.c inclusive to x.y.z inclusive. e.g. 1.0.* or 1.0.0-1.1.5
- daemon.dessert.library.version : API version of the dessert library that must be supported
by the packaged libraries for the daemon to be marked as compatible. comparision is according
to the libtool definition of .so versions.
---
launcher.xml:
DSL that describes the possible configurations that the user should be presented in the launch view.
For the structure of a launcher.xml check either the schema launcher.xsd that accompanies the
dessert manager sources or check out any existing daemon package.
---
config.template:
Template file for the startup configuration. The %<varname>% will be replaced with the values from
the launcher configuration where <varname> is the value of the attribe "name" of an element in the
launcher.xml.
---
manager.xml:
DSL that describes the possible commands and properties that the user should be presented in the
"Running" tab. For the structure of a manager.xml check either the schema manager.xsd that
accompanies the dessert manager sources or check out any existing daemon package.
----------------------------------------------------------------------------------------------------
Deployment to a repository:
Place the zipped daemon package relative to the index.xml file of the repository. The easiest is
to place it directly next to it but a directory hierarchy is allowed.
Next add an entry to the index.xml that describes the new daemon.
<Entry
name="###value###"
version="###value###"
applicationVersion="###value###"
libraryVersion="###value###"
path="###relative_path###"
/>
Each ###value### is a placeholder for the value from the "daemon.properties" file where the key
in the properties file is the same as the name of the corresponding attribute.
The ###relative_path### is a placeholder for the relative path from the index.xml to the zipped
daemon package.
The daemon is now deployed and after a refresh should show up in the "Manage" tab of the dessert
manager application.