source: configure @ 537d9b9

Last change on this file since 537d9b9 was 537d9b9, checked in by dequis <dx@…>, at 2016-11-20T08:40:36Z

Merge master up to commit '9f03c47' into parson

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