source: configure @ cc0ad0a

Last change on this file since cc0ad0a was cc0ad0a, checked in by Jelmer Vernooij <jelmer@…>, at 2022-02-22T15:27:23Z

configure: Fix syntax

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