source: configure @ 7a9d968

Last change on this file since 7a9d968 was 7a9d968, checked in by Wilmer van der Gaast <wilmer@…>, at 2018-03-10T11:30:39Z

Merge branch 'master' into HEAD

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