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