source: configure @ 7051acb

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

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

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