source: configure @ d2394be

Last change on this file since d2394be was b6df23d, checked in by GitHub <noreply@…>, at 2023-02-02T12:05:10Z

configure: fix single quotes in a C string when spoofing BITLBEE_VERSION (#170)

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