source: configure @ b75671d

Last change on this file since b75671d was b75671d, checked in by Wilmer van der Gaast <wilmer@…>, at 2015-06-17T22:47:26Z

Merge remote-tracking branch 'origin/master' into parson

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