source: configure @ a4fc3a0

Last change on this file since a4fc3a0 was a4fc3a0, checked in by Wilmer van der Gaast <wilmer@…>, at 2016-06-12T21:16:39Z

configure: add 'arch' variable again, needed for portability

It was removed by 2e78f75, but it only needed to remove the variable
that was written to config.h, not the one that was used internally by
configure.

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