source: configure @ 098b430

Last change on this file since 098b430 was 872e017, checked in by dequis <dx@…>, at 2015-10-08T05:09:12Z

Add missing space in configure

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