source: configure @ 46b5ed1

Last change on this file since 46b5ed1 was 0d2cd10, checked in by dequis <dx@…>, at 2018-03-26T16:48:32Z

Write backtrace to /var/lib/bitlbee/crash.log on SIGSEGV

Async-signal-safe code is very restricted (nothing that may call malloc
indirectly), so this code tries its best to show meaningful stuff, but
the output is still fairly raw. The contents of the log file are:

  • BITLBEE_VERSION, BITLBEE_CONFIGURE_ARGS
  • Backtrace as generated by backtrace()/backtrace_symbols_fd()
  • A small help text explaining how to get more useful symbol names
  • Memory maps (/proc/self/maps), which also mentions loaded plugins

The backtrace() function is a GNU extension, /proc/ is a linux thing.
Non-glibc platforms (such as musl) won't show anything, non-linux
platforms will skip the memory maps when /proc/self/maps fails to open.

I'd like to include timestamps, but I can't find a safe way to format
them. Even turning raw unix timestamps to strings is hard. Fun stuff.

I used the config directory because it's the only place we can be sure
we can write to. The filename is hardcoded for the same reason there are
no timestamps.

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