source: configure @ b38d399

Last change on this file since b38d399 was e2472dd, checked in by dequis <dx@…>, at 2014-11-24T05:16:05Z

configure: --asan=1 parameter for AddressSanitizer

Requires gcc >=4.8 or clang >=3.1

AddressSanitizer (ASan) is a fast memory error detector. See also:

https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer

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