source: configure @ ea3f90f

Last change on this file since ea3f90f was ea3f90f, checked in by Jelmer Vernooij <jelmer@…>, at 2022-02-17T22:23:06Z

Add strcasestr compatability function

Older platforms unfortunately does not have strcasestr nor does it exist
in the glib API, add fallback implementation.

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