Debian Codegraph @

configure

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