source: configure @ e2472dd

Last change on this file since e2472dd 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
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"
[b7d3cc34]25
[04e2a05]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
[1b221e0]36twitter=1
[04dc563]37purple=0
[b7d3cc34]38
39debug=0
40strip=1
[66b9e86e]41gcov=0
[e2472dd]42asan=0
[2abfbc5]43plugins=1
[04f0c10]44otr=0
[370899f]45skype=0
[85cf37f]46
47events=glib
[b7d3cc34]48ssl=auto
49
[7281ad1]50pie=1
51
[b7d3cc34]52arch=`uname -s`
53cpu=`uname -m`
54
[74c5718]55GLIB_MIN_VERSION=2.14
[670204f]56
[b7d3cc34]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
[57da960]70--sbindir=...                                           $sbindir
[b7d3cc34]71--etcdir=...                                            $etcdir
72--mandir=...                                            $mandir
73--datadir=...                                           $datadir
[7b23afd]74--plugindir=...                                         $plugindir
[417002e]75--systemdsystemunitdir=...                              $systemdsystemunitdir
[34b17d9]76--pidfile=...                                           $pidfile
[b7d3cc34]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
[4aa0f6b]83--twitter=0/1   Disable/enable Twitter part             $twitter
[b7d3cc34]84
[796da03]85--purple=0/1    Disable/enable libpurple support        $purple
[04f0c10]86                (automatically disables other protocol modules)
[b7d3cc34]87
88--debug=0/1     Disable/enable debugging                $debug
89--strip=0/1     Disable/enable binary stripping         $strip
[7281ad1]90--pie=0/1       Build position independent executable   $pie
[66b9e86e]91--gcov=0/1      Disable/enable test coverage reporting  $gcov
[e2472dd]92--asan=0/1      Disable/enable AddressSanitizer         $asan
[2abfbc5]93--plugins=0/1   Disable/enable plugins support          $plugins
[04f0c10]94--otr=0/1/auto/plugin
95                Disable/enable OTR encryption support   $otr
[17f6079]96--skype=0/1/plugin
[370899f]97                Disable/enable Skype support            $skype
[b7d3cc34]98
[85cf37f]99--events=...    Event handler (glib, libevent)          $events
[e1d3f98]100--ssl=...       SSL library to use (gnutls, nss, openssl, auto)
[b7d3cc34]101                                                        $ssl
[aec56b0]102
[7281ad1]103
[f1e7407]104--target=...    Cross compilation target                same as host
[b7d3cc34]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'`
[57da960]114sbindir=`eval echo "$sbindir/" | sed 's/\/\{1,\}/\//g'`
[b7d3cc34]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'`
[7b23afd]119plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
[85cf37f]120includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'`
121libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'`
122
[6dff9d4]123pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
124ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
[e506d6c]125pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
[b7d3cc34]126
[17f6079]127protocols_mods=""
128
[b95b0c8]129cat <<EOF >Makefile.settings
[b7d3cc34]130## BitlBee settings, generated by configure
131PREFIX=$prefix
132BINDIR=$bindir
[57da960]133SBINDIR=$sbindir
[b7d3cc34]134ETCDIR=$etcdir
135MANDIR=$mandir
136DATADIR=$datadir
[7b23afd]137PLUGINDIR=$plugindir
[b7d3cc34]138CONFIG=$config
[e506d6c]139INCLUDEDIR=$includedir
140PCDIR=$pcdir
[b7d3cc34]141
[1bf9492]142TARGET=$target
[b7d3cc34]143ARCH=$arch
144CPU=$cpu
145
[25b80e9c]146INSTALL=install -p
147
[b7d3cc34]148DESTDIR=
149LFLAGS=
[7a80925]150EFLAGS=-lm
[b7d3cc34]151EOF
152
[1074806]153srcdir=$(cd $(dirname $0);pwd)
154currdir=$(pwd)
155if [ "$srcdir" != "$currdir" ]; then 
[f60079b]156        echo
157        echo "configure script run from a different directory. Will create some symlinks..."
158        if [ ! -e Makefile -o -L Makefile ]; then
[04dc563]159                COPYDIRS="doc lib protocols tests utils"
160                mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d)
[f60079b]161                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
162                dst="$PWD"
163                cd "$srcdir"
[04dc563]164                for i in $(find . -name Makefile -type f); do
[f60079b]165                        ln -s "$PWD${i#.}" "$dst/$i";
166                done
167                cd "$dst"
168                rm -rf .bzr
169        fi
170       
[7fa5c19]171        echo "_SRCDIR_=$srcdir/" >> Makefile.settings
[f60079b]172        CFLAGS="$CFLAGS -I${dst}"
173else
174        srcdir=$PWD
175fi
176
[b95b0c8]177cat<<EOF >config.h
[b7d3cc34]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"
[7b23afd]186#define PLUGINDIR "$plugindir"
[34b17d9]187#define PIDFILE "$pidfile"
[6dff9d4]188#define IPCSOCKET "$ipcsocket"
[b7d3cc34]189#define ARCH "$arch"
190#define CPU "$cpu"
191EOF
192
[1bf9492]193
194
[f1e7407]195if [ -n "$target" ]; then
[1bf9492]196        PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
197        export PKG_CONFIG_LIBDIR
[f1e7407]198        PATH=/usr/$target/bin:$PATH
199        CC=$target-cc
200        LD=$target-ld
[1bf9492]201        systemlibdirs="/usr/$target/lib"
[f1e7407]202fi
203
[e2472dd]204if [ "$asan" = "1" ]; then
205        CFLAGS="$CFLAGS -fsanitize=address"
206        LDFLAGS="$LDFLAGS -fsanitize=address"
207        debug=1
208fi
[1bf9492]209
[b7d3cc34]210if [ "$debug" = "1" ]; then
211        echo 'DEBUG=1' >> Makefile.settings
[e2472dd]212        CFLAGS="$CFLAGS -g3 -DDEBUG -O0"
[b7d3cc34]213else
[56f260a]214        [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing"
[b7d3cc34]215fi
216
[7281ad1]217if [ "$pie" = "1" ]; then
218        echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings
219        echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings
220fi
221
[d203495]222echo LDFLAGS=$LDFLAGS >> Makefile.settings
223
[daae10f]224echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings
[f60079b]225echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
[b7d3cc34]226
[41a94dd]227echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
[f712188]228
[b7d3cc34]229if [ -n "$CC" ]; then
[5973412]230        CC=$CC
[b7d3cc34]231elif type gcc > /dev/null 2> /dev/null; then
[5973412]232        CC=gcc
[b7d3cc34]233elif type cc > /dev/null 2> /dev/null; then
[5973412]234        CC=cc
[b7d3cc34]235else
236        echo 'Cannot find a C compiler, aborting.'
237        exit 1;
238fi
239
[5973412]240echo "CC=$CC" >> Makefile.settings;
[daae10f]241if echo $CC | grep -qw gcc; then
242        # Apparently -Wall is gcc-specific?
243        echo CFLAGS+=-Wall >> Makefile.settings
244fi
[5973412]245
[f1e7407]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
[b7d3cc34]253fi
254
[f1e7407]255echo "LD=$LD" >> Makefile.settings
256
[32c632f]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
[670204f]262        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
[b95b0c8]263                cat<<EOF >>Makefile.settings
[32c632f]264EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
265CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
[b7d3cc34]266EOF
[670204f]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
[b7d3cc34]272else
[670204f]273        echo
[574af7e]274        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
[670204f]275        exit 1
[b7d3cc34]276fi
277
[85cf37f]278if [ "$events" = "libevent" ]; then
[003553b]279        if ! [ -f "${libevent}include/event.h" ]; then
[85cf37f]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
[b95b0c8]287        cat <<EOF >>Makefile.settings
[85cf37f]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
[b7d3cc34]294else
295        echo
[85cf37f]296        echo 'ERROR: Unknown event handler specified.'
297        exit 1
[b7d3cc34]298fi
[85cf37f]299echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
[b7d3cc34]300
301detect_gnutls()
302{
[4af7b4f]303        if $PKG_CONFIG --exists gnutls; then
[b95b0c8]304                cat <<EOF >>Makefile.settings
[83e47ec]305EFLAGS+=`$PKG_CONFIG --libs gnutls` `libgcrypt-config --libs`
306CFLAGS+=`$PKG_CONFIG --cflags gnutls` `libgcrypt-config --cflags`
[4af7b4f]307EOF
308                ssl=gnutls
[5513f3e]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
[4af7b4f]313                ret=1
314        elif libgnutls-config --version > /dev/null 2> /dev/null; then
[b95b0c8]315                cat <<EOF >>Makefile.settings
[83e47ec]316EFLAGS+=`libgnutls-config --libs` `libgcrypt-config --libs`
317CFLAGS+=`libgnutls-config --cflags` `libgcrypt-config --cflags`
[b7d3cc34]318EOF
319               
320                ssl=gnutls
321                ret=1;
322        else
323                ret=0;
324        fi;
325}
326
327detect_nss()
328{
[ef043d3]329        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then
[b95b0c8]330                cat<<EOF >>Makefile.settings
[ef043d3]331EFLAGS+=`$PKG_CONFIG --libs nss`
332CFLAGS+=`$PKG_CONFIG --cflags nss`
[b7d3cc34]333EOF
334               
335                ssl=nss
336                ret=1;
337        else
338                ret=0;
339        fi;
340}
341
[36cf9fd]342RESOLV_TESTCODE='
[aee8c19]343#include <sys/types.h>
344#include <netinet/in.h>
[36cf9fd]345#include <arpa/nameser.h>
346#include <resolv.h>
347
[632627e]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
[36cf9fd]362int main()
363{
364        ns_initparse( NULL, 0, NULL );
365        ns_parserr( NULL, ns_s_an, 0, NULL );
366}
367'
[632627e]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
[fb87924]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));
[632627e]382}
383'
[36cf9fd]384
385detect_resolv_dynamic()
386{
[aee8c19]387        case "$arch" in
[632627e]388        OpenBSD )
389                # In FreeBSD res_*/dn_* routines are present in libc.so
390                LIBRESOLV=;;
[aee8c19]391        FreeBSD )
[632627e]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
[aee8c19]396                LIBRESOLV=;;
397        * )
398                LIBRESOLV=-lresolv;;
399        esac
[4fca1db]400        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]401        ret=1
[aee8c19]402        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
[36cf9fd]403        if [ "$?" = "0" ]; then
[aee8c19]404                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
[8462239]405                ret=0
[36cf9fd]406        fi
407
[8462239]408        rm -f $TMPFILE
409        return $ret
[36cf9fd]410}
411
412detect_resolv_static()
413{
[4fca1db]414        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]415        ret=1
[36cf9fd]416        for i in $systemlibdirs; do
417                if [ -f $i/libresolv.a ]; then
[8462239]418                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
[36cf9fd]419                        if [ "$?" = "0" ]; then
420                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
[8462239]421                                ret=0
[36cf9fd]422                        fi
423                fi
424        done
425
[8462239]426        rm -f $TMPFILE
427        return $ret
[36cf9fd]428}
429
[632627e]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{
[fb87924]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
[632627e]476    fi
477
[fb87924]478    rm -f $TMPFILE
479    return $ret
[632627e]480}
481
[b3c467b]482if [ "$ssl" = "auto" ]; then
483        detect_gnutls
[b7d3cc34]484        if [ "$ret" = "0" ]; then
[c5920df]485                # Disable NSS for now as it's known to not work very well ATM.
486                #detect_nss
[191cfb1]487                :
[b7d3cc34]488        fi
[b3c467b]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'
[b3eee9b]496        echo 'installation of OpenSSL (including devel/header files) before reporting'
[b3c467b]497        echo 'compilation problems.'
498        echo
499        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
[b3eee9b]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.'
[b3c467b]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'
[b3eee9b]509        echo 'package, you really should use GnuTLS instead.'
[b3c467b]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/)"'
[b7d3cc34]514       
[b3c467b]515        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
516       
517        ret=1
518else
519        echo
520        echo 'ERROR: Unknown SSL library specified.'
521        exit 1
[b7d3cc34]522fi
523
[b3c467b]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,'
[e1d3f98]528        echo '       so if you want to use that, you have to select it by hand.'
[b7d3cc34]529       
[b3c467b]530        exit 1
531fi;
532
533echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
534
[632627e]535if detect_nameser_has_ns_types; then
536        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
537fi
[36cf9fd]538if detect_resolv_dynamic || detect_resolv_static; then
539        echo '#define HAVE_RESOLV_A' >> config.h
[632627e]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'
[36cf9fd]545fi
[36e9f62]546
[632627e]547
[ba7d16f]548STORAGES="xml"
[b3c467b]549
550for i in $STORAGES; do
551        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
552done
553echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
554
[b7d3cc34]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
[417002e]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
[66b9e86e]586if [ "$gcov" = "1" ]; then
[31fc3970]587        echo "CFLAGS+=--coverage" >> Makefile.settings
588        echo "EFLAGS+=--coverage" >> Makefile.settings
[66b9e86e]589fi
590
[2abfbc5]591if [ "$plugins" = 0 ]; then
[489847f]592        plugindir=""
[2abfbc5]593        echo '#undef WITH_PLUGINS' >> config.h
594else
595        echo '#define WITH_PLUGINS' >> config.h
596fi
597
[6738a67]598otrprefix=""
599for i in / /usr /usr/local; do
600        if [ -f ${i}/lib/libotr.a ]; then
601                otrprefix=${i}
602                break
603        fi
604done
[764c7d1]605if [ "$otr" = "auto" ]; then
[6738a67]606        if [ -n "$otrprefix" ]; then
607                otr=1
608        else
609                otr=0
610        fi
[764c7d1]611fi
[6738a67]612if [ "$otr" = 1 ]; then
[858ea01]613        # BI == built-in
614        echo '#define OTR_BI' >> config.h
[d348377]615        echo "EFLAGS+=-L${otrprefix}/lib -lotr -lgcrypt" >> Makefile.settings
[6738a67]616        echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings
[858ea01]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
[764c7d1]623fi
[a8aa823]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
[764c7d1]630
[17f6079]631if [ "$skype" = "1" -o "$skype" = "plugin" ]; then
[b2b7f52]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
[370899f]637        echo 'SKYPE_PI=skype.so' >> Makefile.settings
[17f6079]638        protocols_mods="$protocol_mods skype(plugin)"
[370899f]639fi
640
[ceebeb1]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
[f287f04]647REAL_BITLBEE_VERSION=`grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/'`
[ffea9b9]648echo
[a014331]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
[ffea9b9]656        rev=`bzr revno`
657        echo 'Using bzr revision #'$rev' as version number'
[f287f04]658        BITLBEE_VERSION=$REAL_BITLBEE_VERSION-bzr$nick-$rev
[b7d3cc34]659fi
660
661if [ -n "$BITLBEE_VERSION" ]; then
662        echo 'Spoofing version number: '$BITLBEE_VERSION
663        echo '#undef BITLBEE_VERSION' >> config.h
[f287f04]664        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
[ffea9b9]665        echo
[f287f04]666else
667        # for pkg-config
668        BITLBEE_VERSION=$REAL_BITLBEE_VERSION
[b7d3cc34]669fi
670
[4fca1db]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
[b95b0c8]685cat <<EOF >bitlbee.pc
[e506d6c]686prefix=$prefix
687includedir=$includedir
[489847f]688plugindir=$plugindir
[e506d6c]689
690Name: bitlbee
691Description: IRC to IM gateway
692Requires: glib-2.0
693Version: $BITLBEE_VERSION
694Libs:
695Cflags: -I\${includedir}
696
697EOF
698
[b7d3cc34]699protocols=''
700protoobjs=''
701
[e248c7f]702if [ "$purple" = 0 ]; then
703        echo '#undef WITH_PURPLE' >> config.h
704else
[e08e53c]705        if ! $PKG_CONFIG purple; then
706                echo
707                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
708                exit 1
709        fi
[e248c7f]710        echo '#define WITH_PURPLE' >> config.h
[b95b0c8]711        cat<<EOF >>Makefile.settings
[e08e53c]712EFLAGS += $($PKG_CONFIG purple --libs)
713PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
714EOF
[e248c7f]715        protocols=$protocols'purple '
716        protoobjs=$protoobjs'purple_mod.o '
717
[04e2a05]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
[18e1f3b]723
724        echo '#undef PACKAGE' >> config.h
725        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
[bda2975]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!'
[c775a58]731                echo
[bda2975]732        fi
[e248c7f]733fi
734
[b0a89cc]735case "$CC" in
736*gcc* )
[e371011]737        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
[fe92921]738        for i in . lib tests protocols protocols/*/; do
[b0a89cc]739                mkdir -p $i/.depend
740        done
741esac
742
[b7d3cc34]743if [ "$msn" = 0 ]; then
744        echo '#undef WITH_MSN' >> config.h
745else
746        echo '#define WITH_MSN' >> config.h
747        protocols=$protocols'msn '
[b5a22e3]748        protoobjs=$protoobjs'msn_mod.o '
[b7d3cc34]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 '
[b5a22e3]756        protoobjs=$protoobjs'jabber_mod.o '
[b7d3cc34]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 '
[b5a22e3]764        protoobjs=$protoobjs'oscar_mod.o '
[b7d3cc34]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 '
[b5a22e3]772        protoobjs=$protoobjs'yahoo_mod.o '
[b7d3cc34]773fi
774
[1b221e0]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
[b7d3cc34]783if [ "$protocols" = "PROTOCOLS = " ]; then
[43462708]784        echo "Warning: You haven't selected any communication protocol to compile!"
[b3c467b]785        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
[b7d3cc34]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 )
[caceb06]800        echo 'STRIP=\# skip strip' >> Makefile.settings
[b7d3cc34]801;;
802IRIX )
803;;
804SunOS )
805        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
806        echo 'STRIP=\# skip strip' >> Makefile.settings
[70d7795]807        echo '#define NO_FD_PASSING' >> config.h
[b7d3cc34]808;;
[8de63c3]809AIX )
810        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
[b7d3cc34]811;;
812CYGWIN* )
813;;
[aec56b0]814Windows )
[e252d8c]815        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
[aec56b0]816;;
[b7d3cc34]817* )
[8d6c4b1]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/.'
[b7d3cc34]820;;
821esac
822
[f1e7407]823if [ -n "$target" ]; then
824        echo "Cross-compiling for: $target"
825fi
826
[b7d3cc34]827echo
828echo 'Configuration done:'
829
830if [ "$debug" = "1" ]; then
[b3c467b]831        echo '  Debugging enabled.'
[b7d3cc34]832else
[b3c467b]833        echo '  Debugging disabled.'
[b7d3cc34]834fi
835
[e2472dd]836if [ "$asan" = "1" ]; then
837        echo '  AddressSanitizer (ASAN) enabled.'
838else
839        echo '  AddressSanitizer (ASAN) disabled.'
840fi
841
[7281ad1]842if [ "$pie" = "1" ]; then
843        echo '  Building PIE executable'
844else
845        echo '  Building non-PIE executable'
846fi
847
[b7d3cc34]848if [ "$strip" = "1" ]; then
[b3c467b]849        echo '  Binary stripping enabled.'
[b7d3cc34]850else
[b3c467b]851        echo '  Binary stripping disabled.'
[b7d3cc34]852fi
853
[764c7d1]854if [ "$otr" = "1" ]; then
855        echo '  Off-the-Record (OTR) Messaging enabled.'
[858ea01]856elif [ "$otr" = "plugin" ]; then
857        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
[764c7d1]858else
859        echo '  Off-the-Record (OTR) Messaging disabled.'
860fi
861
[417002e]862if [ -n "$systemdsystemunitdir" ]; then
863        echo '  systemd enabled.'
864else
865        echo '  systemd disabled.'
866fi
867
[b3c467b]868echo '  Using event handler: '$events
869echo '  Using SSL library: '$ssl
[4e3df8a]870#echo '  Building with these storage backends: '$STORAGES
[b7d3cc34]871
872if [ -n "$protocols" ]; then
[17f6079]873        echo '  Building with these protocols:' $protocols$protocols_mods
[4e3df8a]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
[b7d3cc34]880else
[b3c467b]881        echo '  Building without IM-protocol support. We wish you a lot of fun...'
[b7d3cc34]882fi
Note: See TracBrowser for help on using the repository browser.