source: configure @ 7a9d968

Last change on this file since 7a9d968 was 7a9d968, checked in by Wilmer van der Gaast <wilmer@…>, at 2018-03-10T11:30:39Z

Merge branch 'master' into HEAD

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