source: configure @ a244877

Last change on this file since a244877 was 50bb490, checked in by Dennis Kaarsemaker <dennis@…>, at 2016-03-25T18:07:53Z

ldap authentication backend

We only support the openldap scheme for now, with users that are
posixAccounts. Moreover, as the plugin cannot be configured directly,
you must configure libldap correctly in /etc/openldap/ldap.conf

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