1 | #!/bin/sh |
---|
2 | |
---|
3 | ############################## |
---|
4 | ## Configurer for BitlBee ## |
---|
5 | ## ## |
---|
6 | ## Copyright 2004 Lintux ## |
---|
7 | ## Copyright 2002 Lucumo ## |
---|
8 | ############################## |
---|
9 | |
---|
10 | prefix='/usr/local/' |
---|
11 | bindir='$prefix/bin/' |
---|
12 | sbindir='$prefix/sbin/' |
---|
13 | etcdir='$prefix/etc/bitlbee/' |
---|
14 | mandir='$prefix/share/man/' |
---|
15 | datadir='$prefix/share/bitlbee/' |
---|
16 | config='/var/lib/bitlbee/' |
---|
17 | plugindir='$prefix/lib/bitlbee/' |
---|
18 | rpcplugindir='$plugindir/rpc/' |
---|
19 | includedir='$prefix/include/bitlbee/' |
---|
20 | systemdsystemunitdir='' |
---|
21 | libevent='/usr/' |
---|
22 | pidfile='/var/run/bitlbee.pid' |
---|
23 | ipcsocket='' |
---|
24 | pcdir='$prefix/lib/pkgconfig' |
---|
25 | systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib" |
---|
26 | sysroot='' |
---|
27 | |
---|
28 | configure_args="$@" |
---|
29 | |
---|
30 | # Set these to default-on to let it be overriden by either the user or purple |
---|
31 | # |
---|
32 | # If the user sets one of these to 1, purple won't disable them. |
---|
33 | # Otherwise, if it's still default-on, it gets included in normal builds, |
---|
34 | # but not purple ones. |
---|
35 | msn="default-on" |
---|
36 | jabber="default-on" |
---|
37 | oscar="default-on" |
---|
38 | yahoo="default-on" |
---|
39 | |
---|
40 | twitter=1 |
---|
41 | purple=0 |
---|
42 | rpc=1 |
---|
43 | |
---|
44 | doc=1 |
---|
45 | debug=0 |
---|
46 | strip=1 |
---|
47 | gcov=0 |
---|
48 | asan=0 |
---|
49 | plugins=1 |
---|
50 | otr=0 |
---|
51 | skype=0 |
---|
52 | |
---|
53 | events=glib |
---|
54 | ssl=auto |
---|
55 | |
---|
56 | pie=1 |
---|
57 | |
---|
58 | arch=$(uname -s) |
---|
59 | cpu=$(uname -m) |
---|
60 | |
---|
61 | GLIB_MIN_VERSION=2.16 |
---|
62 | |
---|
63 | # Cygwin and Darwin don't support PIC/PIE |
---|
64 | case "$arch" in |
---|
65 | CYGWIN* ) |
---|
66 | pie=0;; |
---|
67 | Darwin ) |
---|
68 | pie=0;; |
---|
69 | esac |
---|
70 | |
---|
71 | get_version() { |
---|
72 | REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/') |
---|
73 | |
---|
74 | if [ -n "$BITLBEE_VERSION" ]; then |
---|
75 | # environment variable already set to something to spoof it |
---|
76 | # don't replace it with the git stuff |
---|
77 | return |
---|
78 | fi |
---|
79 | |
---|
80 | BITLBEE_VERSION=$REAL_BITLBEE_VERSION |
---|
81 | |
---|
82 | if [ -d $srcdir/.git ] && type git > /dev/null 2> /dev/null; then |
---|
83 | timestamp=$(cd $srcdir; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g') |
---|
84 | branch=$(cd $srcdir; git rev-parse --abbrev-ref HEAD) |
---|
85 | |
---|
86 | search='\(.*\)-\([0-9]*\)-\(g[0-9a-f]*\)' |
---|
87 | replace="\1+$timestamp+$branch+\2-\3-git" |
---|
88 | |
---|
89 | describe=$(cd $srcdir; git describe --long --tags 2>/dev/null) |
---|
90 | if [ $? -ne 0 ]; then |
---|
91 | describe=${REAL_BITLBEE_VERSION}-0-g$(cd $srcdir; git rev-parse --short HEAD) |
---|
92 | fi |
---|
93 | |
---|
94 | BITLBEE_VERSION=$(echo $describe | sed "s#$search#$replace#") |
---|
95 | |
---|
96 | unset timestamp branch search replace describe |
---|
97 | fi |
---|
98 | } |
---|
99 | |
---|
100 | if [ "$1" = "--dump-version" ]; then |
---|
101 | srcdir=$(cd $(dirname $0);pwd) |
---|
102 | get_version |
---|
103 | echo $BITLBEE_VERSION |
---|
104 | exit |
---|
105 | fi |
---|
106 | |
---|
107 | echo BitlBee configure |
---|
108 | |
---|
109 | while [ -n "$1" ]; do |
---|
110 | e="$(expr "X$1" : 'X--\(.*=.*\)')" |
---|
111 | if [ -z "$e" ]; then |
---|
112 | cat<<EOF |
---|
113 | |
---|
114 | Usage: $0 [OPTIONS] |
---|
115 | |
---|
116 | Option Description Default |
---|
117 | |
---|
118 | --prefix=... Directories to put files in $prefix |
---|
119 | --bindir=... $bindir |
---|
120 | --sbindir=... $sbindir |
---|
121 | --etcdir=... $etcdir |
---|
122 | --mandir=... $mandir |
---|
123 | --datadir=... $datadir |
---|
124 | --plugindir=... $plugindir |
---|
125 | --rpcplugindir=... $rpcplugindir |
---|
126 | --systemdsystemunitdir=... $systemdsystemunitdir |
---|
127 | --pidfile=... $pidfile |
---|
128 | --config=... $config |
---|
129 | |
---|
130 | --msn=0/1 Disable/enable MSN part $msn |
---|
131 | --jabber=0/1 Disable/enable Jabber part $jabber |
---|
132 | --oscar=0/1 Disable/enable Oscar part (ICQ, AIM) $oscar |
---|
133 | --yahoo=0/1 Disable/enable Yahoo part $yahoo |
---|
134 | --twitter=0/1 Disable/enable Twitter part $twitter |
---|
135 | |
---|
136 | --purple=0/1 Disable/enable libpurple support $purple |
---|
137 | (automatically disables other protocol modules) |
---|
138 | --rpc=0/1 Disable/enable RPC plugin interface $rpc |
---|
139 | |
---|
140 | --doc=0/1 Disable/enable help.txt generation $doc |
---|
141 | --debug=0/1 Disable/enable debugging $debug |
---|
142 | --strip=0/1 Disable/enable binary stripping $strip |
---|
143 | --pie=0/1 Build position independent executable $pie |
---|
144 | --gcov=0/1 Disable/enable test coverage reporting $gcov |
---|
145 | --asan=0/1 Disable/enable AddressSanitizer $asan |
---|
146 | --plugins=0/1 Disable/enable plugins support $plugins |
---|
147 | --otr=0/1/auto/plugin |
---|
148 | Disable/enable OTR encryption support $otr |
---|
149 | --skype=0/1/plugin |
---|
150 | Disable/enable Skype support $skype |
---|
151 | |
---|
152 | --events=... Event handler (glib, libevent) $events |
---|
153 | --ssl=... SSL library to use (gnutls, nss, openssl, auto) |
---|
154 | $ssl |
---|
155 | |
---|
156 | |
---|
157 | --target=... Cross compilation target same as host |
---|
158 | --sysroot=... Cross compilation sysroot $sysroot |
---|
159 | EOF |
---|
160 | exit; |
---|
161 | fi |
---|
162 | eval "$e" |
---|
163 | shift; |
---|
164 | done |
---|
165 | |
---|
166 | # Expand $prefix and get rid of double slashes |
---|
167 | bindir=$(eval echo "$bindir/" | sed 's/\/\{1,\}/\//g') |
---|
168 | sbindir=$(eval echo "$sbindir/" | sed 's/\/\{1,\}/\//g') |
---|
169 | etcdir=$(eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g') |
---|
170 | mandir=$(eval echo "$mandir/" | sed 's/\/\{1,\}/\//g') |
---|
171 | datadir=$(eval echo "$datadir/" | sed 's/\/\{1,\}/\//g') |
---|
172 | config=$(eval echo "$config/" | sed 's/\/\{1,\}/\//g') |
---|
173 | plugindir=$(eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g') |
---|
174 | rpcplugindir=$(eval echo "$rpcplugindir/" | sed 's/\/\{1,\}/\//g') |
---|
175 | includedir=$(eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g') |
---|
176 | libevent=$(eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g') |
---|
177 | |
---|
178 | pidfile=$(eval echo "$pidfile" | sed 's/\/\{1,\}/\//g') |
---|
179 | ipcsocket=$(eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g') |
---|
180 | pcdir=$(eval echo "$pcdir" | sed 's/\/\{1,\}/\//g') |
---|
181 | |
---|
182 | protocols_mods="" |
---|
183 | |
---|
184 | cat <<EOF >Makefile.settings |
---|
185 | ## BitlBee settings, generated by configure |
---|
186 | |
---|
187 | # ./configure $configure_args |
---|
188 | |
---|
189 | PREFIX=$prefix |
---|
190 | BINDIR=$bindir |
---|
191 | SBINDIR=$sbindir |
---|
192 | ETCDIR=$etcdir |
---|
193 | MANDIR=$mandir |
---|
194 | DATADIR=$datadir |
---|
195 | PLUGINDIR=$plugindir |
---|
196 | RPCPLUGINDIR=$rpcplugindir |
---|
197 | CONFIG=$config |
---|
198 | INCLUDEDIR=$includedir |
---|
199 | PCDIR=$pcdir |
---|
200 | |
---|
201 | TARGET=$target |
---|
202 | ARCH=$arch |
---|
203 | CPU=$cpu |
---|
204 | |
---|
205 | INSTALL=install -p |
---|
206 | |
---|
207 | DESTDIR= |
---|
208 | LFLAGS= |
---|
209 | EFLAGS=-lm |
---|
210 | EOF |
---|
211 | |
---|
212 | srcdir=$(cd $(dirname $0);pwd) |
---|
213 | currdir=$(pwd) |
---|
214 | if [ "$srcdir" != "$currdir" ]; then |
---|
215 | echo |
---|
216 | echo "configure script run from a different directory. Will create some symlinks..." |
---|
217 | if [ ! -e Makefile -o -L Makefile ]; then |
---|
218 | COPYDIRS="doc lib protocols tests utils" |
---|
219 | mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d) |
---|
220 | find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null |
---|
221 | dst="$PWD" |
---|
222 | cd "$srcdir" |
---|
223 | for i in $(find . -name Makefile -type f); do |
---|
224 | ln -s "$PWD${i#.}" "$dst/$i"; |
---|
225 | done |
---|
226 | cd "$dst" |
---|
227 | rm -rf .bzr |
---|
228 | fi |
---|
229 | |
---|
230 | echo "_SRCDIR_=$srcdir/" >> Makefile.settings |
---|
231 | CFLAGS="$CFLAGS -I${dst}" |
---|
232 | else |
---|
233 | srcdir=$PWD |
---|
234 | fi |
---|
235 | |
---|
236 | cat<<EOF >config.h |
---|
237 | /* BitlBee settings, generated by configure |
---|
238 | |
---|
239 | Do *NOT* use any of these defines in your code without thinking twice, most |
---|
240 | of them can/will be overridden at run-time */ |
---|
241 | |
---|
242 | #define BITLBEE_CONFIGURE_ARGS "$configure_args" |
---|
243 | |
---|
244 | #define CONFIG "$config" |
---|
245 | #define ETCDIR "$etcdir" |
---|
246 | #define VARDIR "$datadir" |
---|
247 | #define PLUGINDIR "$plugindir" |
---|
248 | #define RPCPLUGINDIR "$rpcplugindir" |
---|
249 | #define PIDFILE "$pidfile" |
---|
250 | #define IPCSOCKET "$ipcsocket" |
---|
251 | #define ARCH "$arch" |
---|
252 | #define CPU "$cpu" |
---|
253 | EOF |
---|
254 | |
---|
255 | |
---|
256 | |
---|
257 | if [ -n "$target" ]; then |
---|
258 | # prepend sysroot to system lib dirs |
---|
259 | |
---|
260 | systemlibdirs_cross='' |
---|
261 | for i in $systemlibdirs; do |
---|
262 | systemlibdirs_cross="$systemlibdirs_cross $sysroot$i" |
---|
263 | done |
---|
264 | systemlibdirs=$systemlibdirs_cross |
---|
265 | unset systemlibdirs_cross |
---|
266 | |
---|
267 | # backward compatibility |
---|
268 | |
---|
269 | if [ -z "$PKG_CONFIG_LIBDIR" ]; then |
---|
270 | PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig |
---|
271 | export PKG_CONFIG_LIBDIR |
---|
272 | fi |
---|
273 | |
---|
274 | if [ -d /usr/$target/bin ]; then |
---|
275 | PATH=/usr/$target/bin:$PATH |
---|
276 | fi |
---|
277 | |
---|
278 | if [ -d /usr/$target/lib ]; then |
---|
279 | systemlibdirs="$systemlibdirs /usr/$target/lib" |
---|
280 | fi |
---|
281 | |
---|
282 | CC=$target-cc |
---|
283 | LD=$target-ld |
---|
284 | STRIP=$target-strip |
---|
285 | fi |
---|
286 | |
---|
287 | if [ "$asan" = "1" ]; then |
---|
288 | CFLAGS="$CFLAGS -fsanitize=address" |
---|
289 | LDFLAGS="$LDFLAGS -fsanitize=address" |
---|
290 | debug=1 |
---|
291 | fi |
---|
292 | |
---|
293 | if [ "$tsan" = "1" ]; then |
---|
294 | echo |
---|
295 | echo "Threaded BitlBee? Have a nice tall glass of http://imgur.com/gallery/tX4qxzS" |
---|
296 | echo "No need to sanitise threads in a single-threaded process!" |
---|
297 | fi |
---|
298 | |
---|
299 | if [ "$debug" = "1" ]; then |
---|
300 | echo 'DEBUG=1' >> Makefile.settings |
---|
301 | CFLAGS="$CFLAGS -g3 -DDEBUG -O0" |
---|
302 | else |
---|
303 | [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing" |
---|
304 | fi |
---|
305 | |
---|
306 | if [ "$pie" = "1" ]; then |
---|
307 | echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings |
---|
308 | echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings |
---|
309 | fi |
---|
310 | |
---|
311 | echo LDFLAGS=$LDFLAGS >> Makefile.settings |
---|
312 | |
---|
313 | echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings |
---|
314 | echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings |
---|
315 | |
---|
316 | echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings |
---|
317 | |
---|
318 | if [ -n "$CC" ]; then |
---|
319 | CC=$CC |
---|
320 | elif type gcc > /dev/null 2> /dev/null; then |
---|
321 | CC=gcc |
---|
322 | elif type cc > /dev/null 2> /dev/null; then |
---|
323 | CC=cc |
---|
324 | else |
---|
325 | echo 'Cannot find a C compiler, aborting.' |
---|
326 | exit 1; |
---|
327 | fi |
---|
328 | |
---|
329 | echo "CC=$CC" >> Makefile.settings; |
---|
330 | if echo $CC | grep -qw gcc; then |
---|
331 | # Apparently -Wall is gcc-specific? |
---|
332 | echo CFLAGS+=-Wall >> Makefile.settings |
---|
333 | fi |
---|
334 | |
---|
335 | if [ -z "$LD" ]; then |
---|
336 | if type ld > /dev/null 2> /dev/null; then |
---|
337 | LD=ld |
---|
338 | else |
---|
339 | echo 'Cannot find ld, aborting.' |
---|
340 | exit 1; |
---|
341 | fi |
---|
342 | fi |
---|
343 | |
---|
344 | echo "LD=$LD" >> Makefile.settings |
---|
345 | |
---|
346 | if [ -z "$PKG_CONFIG" ]; then |
---|
347 | PKG_CONFIG=pkg-config |
---|
348 | fi |
---|
349 | |
---|
350 | if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then |
---|
351 | if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then |
---|
352 | cat<<EOF >>Makefile.settings |
---|
353 | EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0) |
---|
354 | CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0) |
---|
355 | EOF |
---|
356 | else |
---|
357 | echo |
---|
358 | echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.' |
---|
359 | exit 1 |
---|
360 | fi |
---|
361 | else |
---|
362 | echo |
---|
363 | echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)' |
---|
364 | exit 1 |
---|
365 | fi |
---|
366 | |
---|
367 | if [ "$events" = "libevent" ]; then |
---|
368 | if ! [ -f "${libevent}include/event.h" ]; then |
---|
369 | echo |
---|
370 | echo 'Warning: Could not find event.h, you might have to install it and/or specify' |
---|
371 | echo 'its location using the --libevent= argument. (Example: If event.h is in' |
---|
372 | echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)' |
---|
373 | fi |
---|
374 | |
---|
375 | echo '#define EVENTS_LIBEVENT' >> config.h |
---|
376 | cat <<EOF >>Makefile.settings |
---|
377 | EFLAGS+=-levent -L${libevent}lib |
---|
378 | CFLAGS+=-I${libevent}include |
---|
379 | EOF |
---|
380 | elif [ "$events" = "glib" ]; then |
---|
381 | ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...): |
---|
382 | echo '#define EVENTS_GLIB' >> config.h |
---|
383 | else |
---|
384 | echo |
---|
385 | echo 'ERROR: Unknown event handler specified.' |
---|
386 | exit 1 |
---|
387 | fi |
---|
388 | echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings |
---|
389 | |
---|
390 | detect_gnutls() |
---|
391 | { |
---|
392 | if $PKG_CONFIG --exists gnutls; then |
---|
393 | cat <<EOF >>Makefile.settings |
---|
394 | EFLAGS+=$($PKG_CONFIG --libs gnutls) $(libgcrypt-config --libs) |
---|
395 | CFLAGS+=$($PKG_CONFIG --cflags gnutls) $(libgcrypt-config --cflags) |
---|
396 | EOF |
---|
397 | ssl=gnutls |
---|
398 | if ! $PKG_CONFIG gnutls --atleast-version=2.8; then |
---|
399 | echo |
---|
400 | echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.' |
---|
401 | fi |
---|
402 | ret=1 |
---|
403 | elif libgnutls-config --version > /dev/null 2> /dev/null; then |
---|
404 | cat <<EOF >>Makefile.settings |
---|
405 | EFLAGS+=$(libgnutls-config --libs) $(libgcrypt-config --libs) |
---|
406 | CFLAGS+=$(libgnutls-config --cflags) $(libgcrypt-config --cflags) |
---|
407 | EOF |
---|
408 | |
---|
409 | ssl=gnutls |
---|
410 | ret=1; |
---|
411 | else |
---|
412 | ret=0; |
---|
413 | fi; |
---|
414 | } |
---|
415 | |
---|
416 | detect_nss() |
---|
417 | { |
---|
418 | if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then |
---|
419 | cat<<EOF >>Makefile.settings |
---|
420 | EFLAGS+=$($PKG_CONFIG --libs nss) |
---|
421 | CFLAGS+=$($PKG_CONFIG --cflags nss) |
---|
422 | EOF |
---|
423 | |
---|
424 | ssl=nss |
---|
425 | ret=1; |
---|
426 | else |
---|
427 | ret=0; |
---|
428 | fi; |
---|
429 | } |
---|
430 | |
---|
431 | RESOLV_TESTCODE=' |
---|
432 | #include <sys/types.h> |
---|
433 | #include <netinet/in.h> |
---|
434 | #include <arpa/nameser.h> |
---|
435 | #include <resolv.h> |
---|
436 | |
---|
437 | int main() |
---|
438 | { |
---|
439 | |
---|
440 | res_query( NULL, 0, 0, NULL, 0); |
---|
441 | dn_expand( NULL, NULL, NULL, NULL, 0); |
---|
442 | dn_skipname( NULL, NULL); |
---|
443 | } |
---|
444 | ' |
---|
445 | RESOLV_NS_TESTCODE=' |
---|
446 | #include <sys/types.h> |
---|
447 | #include <netinet/in.h> |
---|
448 | #include <arpa/nameser.h> |
---|
449 | #include <resolv.h> |
---|
450 | |
---|
451 | int main() |
---|
452 | { |
---|
453 | ns_initparse( NULL, 0, NULL ); |
---|
454 | ns_parserr( NULL, ns_s_an, 0, NULL ); |
---|
455 | } |
---|
456 | ' |
---|
457 | RESOLV_NS_TYPES_TESTCODE=' |
---|
458 | #include <sys/types.h> |
---|
459 | #include <netinet/in.h> |
---|
460 | #include <arpa/nameser.h> |
---|
461 | |
---|
462 | int main() |
---|
463 | { |
---|
464 | ns_msg nsh; |
---|
465 | ns_rr rr; |
---|
466 | |
---|
467 | /* Not all platforms we want to work on have |
---|
468 | ns_* routines, so use this to make sure |
---|
469 | the compiler uses it.*/ |
---|
470 | return (int)(sizeof(nsh) + sizeof(rr)); |
---|
471 | } |
---|
472 | ' |
---|
473 | |
---|
474 | detect_resolv_dynamic() |
---|
475 | { |
---|
476 | case "$arch" in |
---|
477 | OpenBSD ) |
---|
478 | # In FreeBSD res_*/dn_* routines are present in libc.so |
---|
479 | LIBRESOLV=;; |
---|
480 | FreeBSD ) |
---|
481 | # In FreeBSD res_*/dn_* routines are present in libc.so |
---|
482 | LIBRESOLV=;; |
---|
483 | CYGWIN* ) |
---|
484 | # In Cygwin res_*/dn_* routines are present in libc.so |
---|
485 | LIBRESOLV=;; |
---|
486 | * ) |
---|
487 | LIBRESOLV=-lresolv;; |
---|
488 | esac |
---|
489 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
490 | ret=1 |
---|
491 | echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null |
---|
492 | if [ "$?" = "0" ]; then |
---|
493 | echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings |
---|
494 | ret=0 |
---|
495 | fi |
---|
496 | |
---|
497 | rm -f $TMPFILE |
---|
498 | return $ret |
---|
499 | } |
---|
500 | |
---|
501 | detect_resolv_static() |
---|
502 | { |
---|
503 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
504 | ret=1 |
---|
505 | for i in $systemlibdirs; do |
---|
506 | if [ -f $i/libresolv.a ]; then |
---|
507 | echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null |
---|
508 | if [ "$?" = "0" ]; then |
---|
509 | echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings |
---|
510 | ret=0 |
---|
511 | fi |
---|
512 | fi |
---|
513 | done |
---|
514 | |
---|
515 | rm -f $TMPFILE |
---|
516 | return $ret |
---|
517 | } |
---|
518 | |
---|
519 | detect_resolv_ns_dynamic() |
---|
520 | { |
---|
521 | case "$arch" in |
---|
522 | FreeBSD ) |
---|
523 | # In FreeBSD ns_ routines are present in libc.so |
---|
524 | LIBRESOLV=;; |
---|
525 | * ) |
---|
526 | LIBRESOLV=-lresolv;; |
---|
527 | esac |
---|
528 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
529 | ret=1 |
---|
530 | echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null |
---|
531 | if [ "$?" = "0" ]; then |
---|
532 | ret=0 |
---|
533 | fi |
---|
534 | |
---|
535 | rm -f $TMPFILE |
---|
536 | return $ret |
---|
537 | } |
---|
538 | |
---|
539 | detect_resolv_ns_static() |
---|
540 | { |
---|
541 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
542 | ret=1 |
---|
543 | for i in $systemlibdirs; do |
---|
544 | if [ -f $i/libresolv.a ]; then |
---|
545 | echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null |
---|
546 | if [ "$?" = "0" ]; then |
---|
547 | ret=0 |
---|
548 | fi |
---|
549 | fi |
---|
550 | done |
---|
551 | |
---|
552 | rm -f $TMPFILE |
---|
553 | return $ret |
---|
554 | } |
---|
555 | |
---|
556 | detect_nameser_has_ns_types() |
---|
557 | { |
---|
558 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
559 | ret=1 |
---|
560 | # since we aren't actually linking with ns_* routines |
---|
561 | # we can just compile the test code |
---|
562 | echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null |
---|
563 | if [ "$?" = "0" ]; then |
---|
564 | ret=0 |
---|
565 | fi |
---|
566 | |
---|
567 | rm -f $TMPFILE |
---|
568 | return $ret |
---|
569 | } |
---|
570 | |
---|
571 | if [ "$ssl" = "auto" ]; then |
---|
572 | detect_gnutls |
---|
573 | if [ "$ret" = "0" ]; then |
---|
574 | # Disable NSS for now as it's known to not work very well ATM. |
---|
575 | #detect_nss |
---|
576 | : |
---|
577 | fi |
---|
578 | elif [ "$ssl" = "gnutls" ]; then |
---|
579 | detect_gnutls |
---|
580 | elif [ "$ssl" = "nss" ]; then |
---|
581 | detect_nss |
---|
582 | elif [ "$ssl" = "openssl" ]; then |
---|
583 | echo |
---|
584 | echo 'No detection code exists for OpenSSL. Make sure that you have a complete' |
---|
585 | echo 'installation of OpenSSL (including devel/header files) before reporting' |
---|
586 | echo 'compilation problems.' |
---|
587 | echo |
---|
588 | echo 'Also, keep in mind that the OpenSSL is, according to some people, not' |
---|
589 | echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported' |
---|
590 | echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the' |
---|
591 | echo 'operating system, which makes it GPL-compatible.' |
---|
592 | echo |
---|
593 | echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' |
---|
594 | echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' |
---|
595 | echo |
---|
596 | echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' |
---|
597 | echo 'probably illegal. If you want to create and distribute a binary BitlBee' |
---|
598 | echo 'package, you really should use GnuTLS instead.' |
---|
599 | echo |
---|
600 | echo 'Also, the OpenSSL license requires us to say this:' |
---|
601 | echo ' * "This product includes software developed by the OpenSSL Project' |
---|
602 | echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' |
---|
603 | |
---|
604 | echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings |
---|
605 | |
---|
606 | ret=1 |
---|
607 | else |
---|
608 | echo |
---|
609 | echo 'ERROR: Unknown SSL library specified.' |
---|
610 | exit 1 |
---|
611 | fi |
---|
612 | |
---|
613 | if [ "$ret" = "0" ]; then |
---|
614 | echo |
---|
615 | echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' |
---|
616 | echo ' Please note that this script doesn'\''t have detection code for OpenSSL,' |
---|
617 | echo ' so if you want to use that, you have to select it by hand.' |
---|
618 | |
---|
619 | exit 1 |
---|
620 | fi; |
---|
621 | |
---|
622 | echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings |
---|
623 | |
---|
624 | if detect_nameser_has_ns_types; then |
---|
625 | echo '#define NAMESER_HAS_NS_TYPES' >> config.h |
---|
626 | fi |
---|
627 | if detect_resolv_dynamic || detect_resolv_static; then |
---|
628 | echo '#define HAVE_RESOLV_A' >> config.h |
---|
629 | if detect_resolv_ns_dynamic || detect_resolv_ns_static; then |
---|
630 | echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h |
---|
631 | fi |
---|
632 | else |
---|
633 | echo 'Insufficient resolv routines. Jabber server must be set explicitly' |
---|
634 | fi |
---|
635 | |
---|
636 | |
---|
637 | STORAGES="xml" |
---|
638 | |
---|
639 | for i in $STORAGES; do |
---|
640 | STORAGE_OBJS="$STORAGE_OBJS storage_$i.o" |
---|
641 | done |
---|
642 | echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings |
---|
643 | |
---|
644 | if [ "$strip" = 0 ]; then |
---|
645 | echo "STRIP=\# skip strip" >> Makefile.settings; |
---|
646 | else |
---|
647 | if [ "$debug" = 1 ]; then |
---|
648 | echo |
---|
649 | echo 'Stripping binaries does not make sense when debugging. Stripping disabled.' |
---|
650 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
651 | strip=0; |
---|
652 | elif [ -n "$STRIP" ]; then |
---|
653 | echo "STRIP=$STRIP" >> Makefile.settings; |
---|
654 | elif type strip > /dev/null 2> /dev/null; then |
---|
655 | echo "STRIP=strip" >> Makefile.settings; |
---|
656 | else |
---|
657 | echo |
---|
658 | echo 'No strip utility found, cannot remove unnecessary parts from executable.' |
---|
659 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
660 | strip=0; |
---|
661 | fi; |
---|
662 | fi |
---|
663 | |
---|
664 | if [ -z "$systemdsystemunitdir" ]; then |
---|
665 | if $PKG_CONFIG --exists systemd; then |
---|
666 | systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
---|
667 | fi |
---|
668 | fi |
---|
669 | if [ -n "$systemdsystemunitdir" ]; then |
---|
670 | if [ "$systemdsystemunitdir" != "no" ]; then |
---|
671 | echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings |
---|
672 | fi |
---|
673 | fi |
---|
674 | |
---|
675 | if [ "$gcov" = "1" ]; then |
---|
676 | echo "CFLAGS+=--coverage" >> Makefile.settings |
---|
677 | echo "EFLAGS+=--coverage" >> Makefile.settings |
---|
678 | fi |
---|
679 | |
---|
680 | if [ "$plugins" = 0 ]; then |
---|
681 | plugindir="" |
---|
682 | echo '#undef WITH_PLUGINS' >> config.h |
---|
683 | else |
---|
684 | echo '#define WITH_PLUGINS' >> config.h |
---|
685 | fi |
---|
686 | |
---|
687 | if [ "$rpc" = 0 ]; then |
---|
688 | # Somewhat pointless at this stage already but at least this keeps it |
---|
689 | # out of bitlbee.pc which is probably a good thing. |
---|
690 | rpcplugindir="" |
---|
691 | fi |
---|
692 | |
---|
693 | otrprefix="" |
---|
694 | if [ "$otr" = "auto" ]; then |
---|
695 | ! $PKG_CONFIG --exists libotr |
---|
696 | otr=$? |
---|
697 | fi |
---|
698 | |
---|
699 | if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then |
---|
700 | exit 1 |
---|
701 | fi |
---|
702 | |
---|
703 | if [ "$otr" = 1 ]; then |
---|
704 | # BI == built-in |
---|
705 | echo '#define OTR_BI' >> config.h |
---|
706 | echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings |
---|
707 | echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings |
---|
708 | echo 'OTR_BI=otr.o' >> Makefile.settings |
---|
709 | elif [ "$otr" = "plugin" ]; then |
---|
710 | # for some mysterious reason beyond the comprehension of my mortal mind, |
---|
711 | # the libgcrypt flags aren't needed when building as plugin. add them anyway. |
---|
712 | echo '#define OTR_PI' >> config.h |
---|
713 | echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings |
---|
714 | echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings |
---|
715 | echo 'OTR_PI=otr.so' >> Makefile.settings |
---|
716 | fi |
---|
717 | |
---|
718 | if [ "$skype" = "1" -o "$skype" = "plugin" ]; then |
---|
719 | if [ "$arch" = "Darwin" ]; then |
---|
720 | echo "SKYPEFLAGS=-dynamiclib -undefined dynamic_lookup" >> Makefile.settings |
---|
721 | else |
---|
722 | echo "SKYPEFLAGS=-fPIC -shared" >> Makefile.settings |
---|
723 | fi |
---|
724 | echo 'SKYPE_PI=skype.so' >> Makefile.settings |
---|
725 | protocols_mods="$protocol_mods skype(plugin)" |
---|
726 | fi |
---|
727 | |
---|
728 | if [ -z "$PYTHON" ]; then |
---|
729 | PYTHON=python |
---|
730 | fi |
---|
731 | |
---|
732 | if [ "$doc" = "1" ]; then |
---|
733 | # check this here just in case someone tries to install it in python2.4... |
---|
734 | if ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then |
---|
735 | echo |
---|
736 | echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs' |
---|
737 | echo "(Use the PYTHON environment variable if it's in a weird location)" |
---|
738 | exit 1 |
---|
739 | fi |
---|
740 | echo "DOC=1" >> Makefile.settings |
---|
741 | echo "PYTHON=$PYTHON" >> Makefile.settings |
---|
742 | fi |
---|
743 | |
---|
744 | get_version |
---|
745 | |
---|
746 | if [ "$BITLBEE_VERSION" != "$REAL_BITLBEE_VERSION" ]; then |
---|
747 | echo 'Spoofing version number: '$BITLBEE_VERSION |
---|
748 | echo '#undef BITLBEE_VERSION' >> config.h |
---|
749 | echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h |
---|
750 | echo |
---|
751 | fi |
---|
752 | |
---|
753 | if ! make helloworld > /dev/null 2>&1; then |
---|
754 | echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles." |
---|
755 | echo "BitlBee needs GNU make to build properly. On most systems GNU make is available" |
---|
756 | echo "under the name 'gmake'." |
---|
757 | echo |
---|
758 | if gmake helloworld > /dev/null 2>&1; then |
---|
759 | echo "gmake seems to be available on your machine, great." |
---|
760 | echo |
---|
761 | else |
---|
762 | echo "gmake is not installed (or not working). Please try to install it." |
---|
763 | echo |
---|
764 | fi |
---|
765 | fi |
---|
766 | |
---|
767 | cat <<EOF >bitlbee.pc |
---|
768 | prefix=$prefix |
---|
769 | includedir=$includedir |
---|
770 | plugindir=$plugindir |
---|
771 | rpcplugindir=$rpcplugindir |
---|
772 | |
---|
773 | Name: bitlbee |
---|
774 | Description: IRC to IM gateway |
---|
775 | Requires: glib-2.0 |
---|
776 | Version: $BITLBEE_VERSION |
---|
777 | Libs: |
---|
778 | Cflags: -I\${includedir} |
---|
779 | |
---|
780 | EOF |
---|
781 | |
---|
782 | protocols='' |
---|
783 | protoobjs='' |
---|
784 | |
---|
785 | if [ "$purple" = 0 ]; then |
---|
786 | echo '#undef WITH_PURPLE' >> config.h |
---|
787 | else |
---|
788 | if ! $PKG_CONFIG purple; then |
---|
789 | echo |
---|
790 | echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)' |
---|
791 | exit 1 |
---|
792 | fi |
---|
793 | echo '#define WITH_PURPLE' >> config.h |
---|
794 | cat<<EOF >>Makefile.settings |
---|
795 | EFLAGS += $($PKG_CONFIG purple --libs) |
---|
796 | PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags) |
---|
797 | EOF |
---|
798 | protocols=$protocols'purple ' |
---|
799 | protoobjs=$protoobjs'purple_mod.o ' |
---|
800 | |
---|
801 | # only disable these if the user didn't enable them explicitly |
---|
802 | [ "$msn" = "default-on" ] && msn=0 |
---|
803 | [ "$jabber" = "default-on" ] && jabber=0 |
---|
804 | [ "$oscar" = "default-on" ] && oscar=0 |
---|
805 | [ "$yahoo" = "default-on" ] && yahoo=0 |
---|
806 | |
---|
807 | echo '#undef PACKAGE' >> config.h |
---|
808 | echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h |
---|
809 | |
---|
810 | if [ "$events" = "libevent" ]; then |
---|
811 | echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling' |
---|
812 | echo 'outside libpurple, talking to GLib directly. At least for now the combination' |
---|
813 | echo 'libpurple + libevent is *not* recommended!' |
---|
814 | echo |
---|
815 | fi |
---|
816 | fi |
---|
817 | |
---|
818 | case "$CC" in |
---|
819 | *gcc* ) |
---|
820 | echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings |
---|
821 | for i in . lib tests protocols protocols/*/; do |
---|
822 | mkdir -p $i/.depend |
---|
823 | done |
---|
824 | esac |
---|
825 | |
---|
826 | if [ "$msn" = 0 ]; then |
---|
827 | echo '#undef WITH_MSN' >> config.h |
---|
828 | else |
---|
829 | echo '#define WITH_MSN' >> config.h |
---|
830 | protocols=$protocols'msn ' |
---|
831 | protoobjs=$protoobjs'msn_mod.o ' |
---|
832 | fi |
---|
833 | |
---|
834 | if [ "$jabber" = 0 ]; then |
---|
835 | echo '#undef WITH_JABBER' >> config.h |
---|
836 | else |
---|
837 | echo '#define WITH_JABBER' >> config.h |
---|
838 | protocols=$protocols'jabber ' |
---|
839 | protoobjs=$protoobjs'jabber_mod.o ' |
---|
840 | fi |
---|
841 | |
---|
842 | if [ "$oscar" = 0 ]; then |
---|
843 | echo '#undef WITH_OSCAR' >> config.h |
---|
844 | else |
---|
845 | echo '#define WITH_OSCAR' >> config.h |
---|
846 | protocols=$protocols'oscar ' |
---|
847 | protoobjs=$protoobjs'oscar_mod.o ' |
---|
848 | fi |
---|
849 | |
---|
850 | if [ "$yahoo" = 0 ]; then |
---|
851 | echo '#undef WITH_YAHOO' >> config.h |
---|
852 | else |
---|
853 | echo '#define WITH_YAHOO' >> config.h |
---|
854 | protocols=$protocols'yahoo ' |
---|
855 | protoobjs=$protoobjs'yahoo_mod.o ' |
---|
856 | fi |
---|
857 | |
---|
858 | if [ "$twitter" = 0 ]; then |
---|
859 | echo '#undef WITH_TWITTER' >> config.h |
---|
860 | else |
---|
861 | echo '#define WITH_TWITTER' >> config.h |
---|
862 | protocols=$protocols'twitter ' |
---|
863 | protoobjs=$protoobjs'twitter_mod.o ' |
---|
864 | fi |
---|
865 | |
---|
866 | if [ "$rpc" = 0 ]; then |
---|
867 | echo '#undef WITH_RPC' >> config.h |
---|
868 | else |
---|
869 | echo '#define WITH_RPC' >> config.h |
---|
870 | protocols=$protocols'rpc ' |
---|
871 | protoobjs=$protoobjs'rpc_mod.o ' |
---|
872 | fi |
---|
873 | |
---|
874 | if [ "$protocols" = "PROTOCOLS = " ]; then |
---|
875 | echo "Warning: You haven't selected any communication protocol to compile!" |
---|
876 | echo " BitlBee will run, but you will be unable to connect to IM servers!" |
---|
877 | fi |
---|
878 | |
---|
879 | echo "PROTOCOLS = $protocols" >> Makefile.settings |
---|
880 | echo "PROTOOBJS = $protoobjs" >> Makefile.settings |
---|
881 | |
---|
882 | echo Architecture: $arch |
---|
883 | case "$arch" in |
---|
884 | Linux ) |
---|
885 | ;; |
---|
886 | GNU/* ) |
---|
887 | ;; |
---|
888 | *BSD ) |
---|
889 | ;; |
---|
890 | Darwin ) |
---|
891 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
892 | ;; |
---|
893 | IRIX ) |
---|
894 | ;; |
---|
895 | SunOS ) |
---|
896 | echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings |
---|
897 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
898 | echo '#define NO_FD_PASSING' >> config.h |
---|
899 | ;; |
---|
900 | AIX ) |
---|
901 | echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings |
---|
902 | ;; |
---|
903 | CYGWIN* ) |
---|
904 | ;; |
---|
905 | Windows ) |
---|
906 | echo 'Native windows compilation is not supported anymore, use cygwin instead.' |
---|
907 | ;; |
---|
908 | * ) |
---|
909 | echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.' |
---|
910 | echo 'Please report any problems at http://bugs.bitlbee.org/.' |
---|
911 | ;; |
---|
912 | esac |
---|
913 | |
---|
914 | if [ -n "$target" ]; then |
---|
915 | echo "Cross-compiling for: $target" |
---|
916 | fi |
---|
917 | |
---|
918 | echo |
---|
919 | echo 'Configuration done:' |
---|
920 | |
---|
921 | if [ "$debug" = "1" ]; then |
---|
922 | echo ' Debugging enabled.' |
---|
923 | else |
---|
924 | echo ' Debugging disabled.' |
---|
925 | fi |
---|
926 | |
---|
927 | if [ "$asan" = "1" ]; then |
---|
928 | echo ' AddressSanitizer (ASAN) enabled.' |
---|
929 | else |
---|
930 | echo ' AddressSanitizer (ASAN) disabled.' |
---|
931 | fi |
---|
932 | |
---|
933 | if [ "$pie" = "1" ]; then |
---|
934 | echo ' Building PIE executable' |
---|
935 | else |
---|
936 | echo ' Building non-PIE executable' |
---|
937 | fi |
---|
938 | |
---|
939 | if [ "$strip" = "1" ]; then |
---|
940 | echo ' Binary stripping enabled.' |
---|
941 | else |
---|
942 | echo ' Binary stripping disabled.' |
---|
943 | fi |
---|
944 | |
---|
945 | if [ "$otr" = "1" ]; then |
---|
946 | echo ' Off-the-Record (OTR) Messaging enabled.' |
---|
947 | elif [ "$otr" = "plugin" ]; then |
---|
948 | echo ' Off-the-Record (OTR) Messaging enabled (as a plugin).' |
---|
949 | else |
---|
950 | echo ' Off-the-Record (OTR) Messaging disabled.' |
---|
951 | fi |
---|
952 | |
---|
953 | if [ -n "$systemdsystemunitdir" ]; then |
---|
954 | echo ' systemd enabled.' |
---|
955 | else |
---|
956 | echo ' systemd disabled.' |
---|
957 | fi |
---|
958 | |
---|
959 | echo ' Using event handler: '$events |
---|
960 | echo ' Using SSL library: '$ssl |
---|
961 | |
---|
962 | if [ -n "$protocols" ]; then |
---|
963 | echo ' Building with these protocols:' $protocols$protocols_mods |
---|
964 | case "$protocols" in |
---|
965 | *purple*) |
---|
966 | echo " Note that BitlBee-libpurple is supported on a best-effort basis. It's" |
---|
967 | echo " not *fully* compatible with normal BitlBee. Don't use it unless you" |
---|
968 | echo " absolutely need it (i.e. support for a certain protocol or feature)." |
---|
969 | esac |
---|
970 | else |
---|
971 | echo ' Building without IM-protocol support. We wish you a lot of fun...' |
---|
972 | fi |
---|