source: configure @ da75c3d

Last change on this file since da75c3d was f18209a, checked in by Jelmer Vernooij <jelmer@…>, at 2020-08-30T18:11:01Z

Use python3 if 'python' is not available.

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