source: configure @ 3f44e43

Last change on this file since 3f44e43 was 3f44e43, checked in by dequis <dx@…>, at 2016-11-21T07:49:26Z

Merge branch 'master' into parson

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