source: configure @ 9efcfee

Last change on this file since 9efcfee was e5d2c56, checked in by dequis <dx@…>, at 2019-02-03T15:18:54Z

Remove OSCAR since both ICQ and AIM are dead

RIP.

  • Property mode set to 100755
File size: 24.0 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"
36
37twitter=1
38purple=0
39
40verbose=0
41doc=1
42debug=0
43strip=0
44gcov=0
45asan=0
46plugins=1
47otr=0
48
49events=glib
50ssl=auto
51
52pam=0
53ldap=0
54
55pie=1
56
57arch=$(uname -s)
58
59GLIB_MIN_VERSION=2.16
60
61# Cygwin and Darwin don't support PIC/PIE
62case "$arch" in
63        CYGWIN* )
64                pie=0;;
65        Darwin )
66                pie=0;;
67esac
68
69get_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
98if [ "$1" = "--dump-version" ]; then
99        srcdir=$(cd $(dirname $0);pwd)
100        get_version
101        echo $BITLBEE_VERSION
102        exit
103fi
104
105echo BitlBee configure
106
107while [ -n "$1" ]; do
108        e="$(expr "X$1" : 'X--\(.*=.*\)')"
109        if [ -z "$e" ]; then
110                cat<<EOF
111
112Usage: $0 [OPTIONS]
113
114Option          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
155EOF
156                exit;
157        fi
158        eval "$e"
159        shift;
160done
161
162# Expand $prefix and get rid of double slashes
163bindir=$(eval echo "$bindir/" | sed 's/\/\{1,\}/\//g')
164sbindir=$(eval echo "$sbindir/" | sed 's/\/\{1,\}/\//g')
165etcdir=$(eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g')
166mandir=$(eval echo "$mandir/" | sed 's/\/\{1,\}/\//g')
167datadir=$(eval echo "$datadir/" | sed 's/\/\{1,\}/\//g')
168config=$(eval echo "$config/" | sed 's/\/\{1,\}/\//g')
169libdir=$(eval echo "$libdir/" | sed 's/\/\{1,\}/\//g')
170plugindir=$(eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g')
171includedir=$(eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g')
172libevent=$(eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g')
173
174pidfile=$(eval echo "$pidfile" | sed 's/\/\{1,\}/\//g')
175ipcsocket=$(eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g')
176pcdir=$(eval echo "$pcdir" | sed 's/\/\{1,\}/\//g')
177
178protocols_mods=""
179
180cat <<EOF >Makefile.settings
181## BitlBee settings, generated by configure
182
183# ./configure $configure_args
184
185PREFIX=$prefix
186BINDIR=$bindir
187SBINDIR=$sbindir
188ETCDIR=$etcdir
189MANDIR=$mandir
190DATADIR=$datadir
191PLUGINDIR=$plugindir
192CONFIG=$config
193LIBDIR=$libdir
194INCLUDEDIR=$includedir
195PCDIR=$pcdir
196
197TARGET=$target
198
199INSTALL=install -p
200
201DESTDIR=
202LFLAGS=
203EFLAGS=-lm
204EOF
205
206srcdir=$(cd $(dirname $0);pwd)
207currdir=$(pwd)
208if [ "$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}"
226else
227        srcdir=$PWD
228fi
229
230cat<<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"
245EOF
246
247
248
249if [ -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
277fi
278
279if [ "$asan" = "1" ]; then
280        CFLAGS="$CFLAGS -fsanitize=address"
281        LDFLAGS="$LDFLAGS -fsanitize=address"
282        debug=1
283fi
284
285if [ "$verbose" = "0" ]; then
286        echo 'VERBOSE=@' >> Makefile.settings
287else
288        echo 'VERBOSE=' >> Makefile.settings
289fi
290
291cat <<EOF >>Makefile.settings
292
293# Enable/disable output verbosity
294ifdef V
295ifeq (\$(V),1)
296        VERBOSE=
297else
298        VERBOSE=@
299endif
300endif
301
302EOF
303
304if [ "$debug" = "1" ]; then
305        echo 'DEBUG=1' >> Makefile.settings
306        CFLAGS="$CFLAGS -g3 -DDEBUG -O0"
307else
308        [ -z "$CFLAGS" ] && CFLAGS="-g -O2 -fno-strict-aliasing"
309fi
310
311if [ "$pie" = "1" ]; then
312        echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings
313        echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings
314fi
315
316echo LDFLAGS=$LDFLAGS >> Makefile.settings
317
318echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings
319echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
320
321echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
322
323if [ -n "$CC" ]; then
324        CC=$CC
325elif type gcc > /dev/null 2> /dev/null; then
326        CC=gcc
327elif type cc > /dev/null 2> /dev/null; then
328        CC=cc
329else
330        echo 'Cannot find a C compiler, aborting.'
331        exit 1;
332fi
333
334echo "CC=$CC" >> Makefile.settings;
335if echo $CC | grep -qw 'gcc\|clang'; then
336        # Apparently -Wall is gcc-specific?
337        echo CFLAGS+=-Wall -Wformat -Werror=format-security >> Makefile.settings
338fi
339
340if [ -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
347fi
348
349echo "LD=$LD" >> Makefile.settings
350
351if [ -z "$PKG_CONFIG" ]; then
352        PKG_CONFIG=pkg-config
353fi
354
355if ! $PKG_CONFIG --version > /dev/null 2>/dev/null; then
356        echo
357        echo 'Cannot find pkg-config, aborting.'
358        exit 1
359fi
360
361if $PKG_CONFIG glib-2.0; then
362        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
363                cat<<EOF >>Makefile.settings
364EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0)
365CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0)
366EOF
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
372else
373        echo
374        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
375        exit 1
376fi
377
378if [ "$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
388EFLAGS+=-levent -L${libevent}lib
389CFLAGS+=-I${libevent}include
390EOF
391elif [ "$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
394else
395        echo
396        echo 'ERROR: Unknown event handler specified.'
397        exit 1
398fi
399echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
400
401detect_gnutls()
402{
403        if $PKG_CONFIG --exists gnutls; then
404                cat <<EOF >>Makefile.settings
405EFLAGS+=$($PKG_CONFIG --libs gnutls) $(libgcrypt-config --libs)
406CFLAGS+=$($PKG_CONFIG --cflags gnutls) $(libgcrypt-config --cflags)
407EOF
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
416EFLAGS+=$(libgnutls-config --libs) $(libgcrypt-config --libs)
417CFLAGS+=$(libgnutls-config --cflags) $(libgcrypt-config --cflags)
418EOF
419               
420                ssl=gnutls
421                ret=1;
422        else
423                ret=0;
424        fi;
425}
426
427detect_nss()
428{
429        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then
430                cat<<EOF >>Makefile.settings
431EFLAGS+=$($PKG_CONFIG --libs nss)
432CFLAGS+=$($PKG_CONFIG --cflags nss)
433EOF
434               
435                ssl=nss
436                ret=1;
437        else
438                ret=0;
439        fi;
440}
441
442RESOLV_TESTCODE='
443#include <sys/types.h>
444#include <netinet/in.h>
445#include <arpa/nameser.h>
446#include <resolv.h>
447
448int 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'
456RESOLV_NS_TESTCODE='
457#include <sys/types.h>
458#include <netinet/in.h>
459#include <arpa/nameser.h>
460#include <resolv.h>
461
462int main()
463{
464        ns_initparse( NULL, 0, NULL );
465        ns_parserr( NULL, ns_s_an, 0, NULL );
466}
467'
468RESOLV_NS_TYPES_TESTCODE='
469#include <sys/types.h>
470#include <netinet/in.h>
471#include <arpa/nameser.h>
472
473int 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
485BACKTRACE_TESTCODE='
486#include <execinfo.h>
487
488int main()
489{
490        void *trace[16];
491        return backtrace(trace, 16);
492}
493'
494
495detect_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
522detect_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
540detect_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
560detect_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
577detect_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
592detect_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
605if [ "$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
612elif [ "$ssl" = "gnutls" ]; then
613        detect_gnutls
614elif [ "$ssl" = "nss" ]; then
615        detect_nss
616elif [ "$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
641else
642        echo
643        echo 'ERROR: Unknown SSL library specified.'
644        exit 1
645fi
646
647if [ "$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
654fi;
655
656echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
657
658if detect_nameser_has_ns_types; then
659        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
660fi
661if 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
666else
667        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
668fi
669
670if detect_backtrace; then
671        echo '#define HAVE_BACKTRACE' >> config.h
672        echo '#define CRASHFILE "'$config'crash.log"' >> config.h
673fi
674
675STORAGES="xml"
676
677for i in $STORAGES; do
678        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
679done
680echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
681
682authobjs=
683authlibs=
684if [ "$pam" = 0 ]; then
685        echo '#undef WITH_PAM' >> config.h
686else
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 '
694fi
695if [ "$ldap" = 0 ]; then
696        echo '#undef WITH_LDAP' >> config.h
697else
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 '
705fi
706echo AUTH_OBJS=$authobjs >> Makefile.settings
707echo EFLAGS+=$authlibs >> Makefile.settings
708
709if [ "$strip" = 0 ]; then
710        echo "STRIP=\# skip strip" >> Makefile.settings;
711else
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;
727fi
728
729if [ -z "$systemdsystemunitdir" ]; then
730        if $PKG_CONFIG --exists systemd; then
731                systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
732        fi
733fi
734if [ -n "$systemdsystemunitdir" ]; then
735        if [ "$systemdsystemunitdir" != "no" ]; then
736                echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
737        fi
738fi
739
740if [ "$gcov" = "1" ]; then
741        echo "CFLAGS+=--coverage" >> Makefile.settings
742        echo "EFLAGS+=--coverage" >> Makefile.settings
743fi
744
745if [ "$plugins" = 0 ]; then
746        plugindir=""
747        echo '#undef WITH_PLUGINS' >> config.h
748else
749        echo '#define WITH_PLUGINS' >> config.h
750fi
751
752otrprefix=""
753if [ "$otr" = "auto" ]; then
754        ! $PKG_CONFIG --exists libotr
755        otr=$?
756fi
757
758if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
759        exit 1
760fi
761
762if [ "$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
768elif [ "$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
775fi
776
777if [ -z "$PYTHON" ]; then
778        PYTHON=python
779fi
780
781if [ "$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
791fi
792
793get_version
794
795if [ "$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
800fi
801
802if ! 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
814fi
815
816pkgconfiglibs=''
817case "$arch" in
818CYGWIN* )
819        pkgconfiglibs='-L${libdir} -lbitlbee -no-undefined'
820esac
821
822cat <<EOF >bitlbee.pc
823prefix=$prefix
824includedir=$includedir
825plugindir=$plugindir
826libdir=$libdir
827datadir=$datadir
828
829Name: bitlbee
830Description: IRC to IM gateway
831Requires: glib-2.0
832Version: $BITLBEE_VERSION
833Libs: $pkgconfiglibs
834Cflags: -I\${includedir}
835
836EOF
837
838protocols=''
839protoobjs=''
840
841if [ "$purple" = 0 ]; then
842        echo '#undef WITH_PURPLE' >> config.h
843else
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
851EFLAGS += $($PKG_CONFIG purple --libs)
852PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
853EOF
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
869fi
870
871case "$CC" in
872*gcc* )
873        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
874        for i in . lib tests protocols protocols/*/; do
875                mkdir -p $i/.depend
876        done
877esac
878
879if [ "$jabber" = 0 ]; then
880        echo '#undef WITH_JABBER' >> config.h
881else
882        echo '#define WITH_JABBER' >> config.h
883        protocols=$protocols'jabber '
884        protoobjs=$protoobjs'jabber_mod.o '
885fi
886
887if [ "$twitter" = 0 ]; then
888        echo '#undef WITH_TWITTER' >> config.h
889else
890        echo '#define WITH_TWITTER' >> config.h
891        protocols=$protocols'twitter '
892        protoobjs=$protoobjs'twitter_mod.o '
893fi
894
895if [ "$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!"
898fi
899
900echo "PROTOCOLS = $protocols" >> Makefile.settings
901echo "PROTOOBJS = $protoobjs" >> Makefile.settings
902
903echo Architecture: $arch
904case "$arch" in
905Linux )
906;;
907GNU/* )
908;;
909*BSD )
910;;
911Darwin )
912        echo 'STRIP=\# skip strip' >> Makefile.settings
913;;
914IRIX )
915;;
916SunOS )
917        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
918        echo 'STRIP=\# skip strip' >> Makefile.settings
919        echo '#define NO_FD_PASSING' >> config.h
920;;
921AIX )
922        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
923;;
924CYGWIN* )
925        echo 'EFLAGS+=-Wl,--export-all,--out-implib,libbitlbee.dll.a' >> Makefile.settings
926        echo 'IMPLIB=libbitlbee.dll.a' >> Makefile.settings
927;;
928Windows )
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;;
935esac
936
937if [ -n "$target" ]; then
938        echo "Cross-compiling for: $target"
939fi
940
941echo
942echo 'Configuration done:'
943
944if [ "$debug" = "1" ]; then
945        echo '  Debugging enabled.'
946else
947        echo '  Debugging disabled.'
948fi
949
950if [ "$asan" = "1" ]; then
951        echo '  AddressSanitizer (ASAN) enabled.'
952else
953        echo '  AddressSanitizer (ASAN) disabled.'
954fi
955
956if [ "$pie" = "1" ]; then
957        echo '  Building PIE executable'
958else
959        echo '  Building non-PIE executable'
960fi
961
962if [ "$strip" = "1" ]; then
963        echo '  Binary stripping enabled.'
964else
965        echo '  Binary stripping disabled.'
966fi
967
968if [ "$otr" = "1" ]; then
969        echo '  Off-the-Record (OTR) Messaging enabled.'
970elif [ "$otr" = "plugin" ]; then
971        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
972else
973        echo '  Off-the-Record (OTR) Messaging disabled.'
974fi
975
976if [ -n "$systemdsystemunitdir" ]; then
977        echo '  systemd enabled.'
978else
979        echo '  systemd disabled.'
980fi
981
982echo '  Using event handler: '$events
983echo '  Using SSL library: '$ssl
984#echo '  Building with these storage backends: '$STORAGES
985
986if [ -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
994else
995        echo '  Building without IM-protocol support. We wish you a lot of fun...'
996fi
Note: See TracBrowser for help on using the repository browser.