source: configure @ ba52ac5

Last change on this file since ba52ac5 was 3fbce97, checked in by Wilmer van der Gaast <wilmer@…>, at 2016-09-24T20:14:34Z

Merge branch 'master' into parson

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