source: configure @ 537d9b9

Last change on this file since 537d9b9 was 537d9b9, checked in by dequis <dx@…>, at 2016-11-20T08:40:36Z

Merge master up to commit '9f03c47' into parson

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