source: configure @ 5ca1416

Last change on this file since 5ca1416 was 70ec7ab, checked in by dequis <dx@…>, at 2015-05-03T22:43:33Z

configure: change version number format, add --dump-version

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