source: configure @ 8e6ecfe

Last change on this file since 8e6ecfe was 8e6ecfe, checked in by Dennis Kaarsemaker <dennis@…>, at 2016-03-25T18:07:53Z

Authentication: scaffolding for multiple authentication backends

Instead of always putting users passwords in XML files, allow site
admins to configure a different authentication method to integrate
authentication with other systems.

This doesn't add any authentication backends yet, merely the
scaffolding. Notably:

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