source: configure @ 21f450c

Last change on this file since 21f450c was 21f450c, checked in by dequis <dx@…>, at 2016-05-26T00:15:15Z

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

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

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