source: configure @ 3f44e43

Last change on this file since 3f44e43 was 3f44e43, checked in by dequis <dx@…>, at 2016-11-21T07:49:26Z

Merge branch 'master' into parson

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