source: configure @ 92a03a0

Last change on this file since 92a03a0 was 92a03a0, checked in by GitHub <noreply@…>, at 2023-04-03T19:10:41Z

HTTPSify BitlBee URLs (#180)

...and refer to GitHub instead of Bazaar.

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