source: configure @ e28c449

Last change on this file since e28c449 was e28c449, checked in by dequis <dx@…>, at 2015-05-31T04:53:01Z

configure: handle 'git describe' failures when no tags are reachable

Just make up some fake describe output based on the real version

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