source: configure @ 65d0dfd

Last change on this file since 65d0dfd was 65d0dfd, checked in by dx <dx@…>, at 2017-03-12T04:16:58Z

Add --verbose configure option to control verbose build output

Defaults to disabled to maintain the status quo.

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