source: configure @ 2e78f75

Last change on this file since 2e78f75 was 2e78f75, checked in by Jelmer Vernooij <jelmer@…>, at 2016-05-15T17:16:38Z

Remove the ARCH / CPU defines.

These only reflect on what arch/cpu bitlbee was built, not on which
it is running. This makes the Debian package unreproducible.
See e.g.
https://tests.reproducible-builds.org/rb-pkg/testing/i386/bitlbee.html

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