source: configure @ 4a9c6b0

Last change on this file since 4a9c6b0 was ad66dcd, checked in by Artem Savkov <artem.savkov@…>, at 2017-08-31T20:13:34Z

Add datadir to pkgconfig file and config.h

Export datadir through pkgconfig and config.h for later use by plugins.

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