source: configure @ 87872c7

Last change on this file since 87872c7 was a7baf40, checked in by dequis <dx@…>, at 2016-11-19T07:59:14Z

Remove yahoo (the old protocol). Use funyahoo++ instead.

RIP

The previous commit already handled the part of telling users.

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