source: configure @ 8e5751e

Last change on this file since 8e5751e was 8e5751e, checked in by Wilmer van der Gaast <wilmer@…>, at 2015-07-29T23:10:58Z

Add RPC plugin directory to configure script instead of defaulting to
/tmp/rpcplugins.

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