source: configure @ 31169ee

Last change on this file since 31169ee was 70ec7ab, checked in by dequis <dx@…>, at 2015-05-03T22:43:33Z

configure: change version number format, add --dump-version

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