source: configure @ ba52ac5

Last change on this file since ba52ac5 was 3fbce97, checked in by Wilmer van der Gaast <wilmer@…>, at 2016-09-24T20:14:34Z

Merge branch 'master' into parson

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