source: configure @ bea6db0

Last change on this file since bea6db0 was bea6db0, checked in by GitHub <noreply@…>, at 2023-03-07T21:43:36Z

Fix systemd autodetection (#175)

  • Property mode set to 100755
File size: 26.2 KB
Line 
1#!/bin/sh
2
3##############################
4##  Configurer for BitlBee  ##
5##                          ##
6##  Copyright 2004 Lintux   ##
7##  Copyright 2002 Lucumo   ##
8##############################
9
10prefix="/usr/local/"
11bindir="$prefix/bin/"
12sbindir="$prefix/sbin/"
13etcdir="$prefix/etc/bitlbee/"
14mandir="$prefix/share/man/"
15datadir="$prefix/share/bitlbee/"
16config="/var/lib/bitlbee/"
17libdir="$prefix/lib/"
18plugindir="$prefix/lib/bitlbee/"
19includedir="$prefix/include/bitlbee/"
20systemdsystemunitdir=""
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                  $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
332
333echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
334
335if type gcc > /dev/null 2> /dev/null; then
336        CC=gcc
337elif type cc > /dev/null 2> /dev/null; then
338        CC=cc
339else
340        echo 'Cannot find a C compiler, aborting.'
341        exit 1;
342fi
343
344echo "CC=$CC" >> Makefile.settings;
345if echo $CC | grep -qw 'gcc\|clang'; then
346        # Apparently -Wall is gcc-specific?
347        echo CFLAGS+=-Wall -Wformat -Werror=format-security >> Makefile.settings
348fi
349
350if [ -z "$LD" ]; then
351        if type ld > /dev/null 2> /dev/null; then
352                LD=ld
353        else
354                echo 'Cannot find ld, aborting.'
355                exit 1;
356        fi
357fi
358
359echo "LD=$LD" >> Makefile.settings
360
361if [ -z "$PKG_CONFIG" ]; then
362        PKG_CONFIG=pkg-config
363fi
364
365if ! $PKG_CONFIG --version > /dev/null 2>/dev/null; then
366        echo
367        echo 'Cannot find pkg-config, aborting.'
368        exit 1
369fi
370
371if $PKG_CONFIG glib-2.0; then
372        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
373                cat<<EOF >>Makefile.settings
374EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0)
375CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0)
376EOF
377        else
378                echo
379                echo "Found glib2 $($PKG_CONFIG glib-2.0 --modversion), but version $GLIB_MIN_VERSION or newer is required."
380                exit 1
381        fi
382else
383        echo
384        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
385        exit 1
386fi
387
388if [ "$events" = "libevent" ]; then
389        if ! [ -f "${libevent}include/event.h" ]; then
390                echo
391                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
392                echo 'its location using the --libevent= argument. (Example: If event.h is in'
393                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
394        fi
395       
396        echo '#define EVENTS_LIBEVENT' >> config.h
397        cat <<EOF >>Makefile.settings
398EFLAGS+=-levent -L${libevent}lib
399CFLAGS+=-I${libevent}include
400EOF
401elif [ "$events" = "glib" ]; then
402        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
403        echo '#define EVENTS_GLIB' >> config.h
404else
405        echo
406        echo 'ERROR: Unknown event handler specified.'
407        exit 1
408fi
409echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
410
411if [ "$external_json_parser" = "auto" ]; then
412        if pkg-config --exists json-parser; then
413                external_json_parser=1
414        else
415                external_json_parser=0
416        fi
417fi
418echo "EXTERNAL_JSON_PARSER=$external_json_parser" >> Makefile.settings
419if [ "$external_json_parser" = "1" ]; then
420    # shellcheck disable=SC2129
421    echo "CFLAGS+=$(pkg-config --cflags json-parser)" >> Makefile.settings
422    echo "CFLAGS+=-DUSE_EXTERNAL_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
427echo CFLAGS+=-I"${srcdir}" -I"${srcdir}"/lib -I"${srcdir}"/protocols -I. >> Makefile.settings
428
429detect_gnutls()
430{
431        if $PKG_CONFIG --exists gnutls; then
432                cat <<EOF >>Makefile.settings
433EFLAGS+=$($PKG_CONFIG --libs gnutls) $(libgcrypt-config --libs)
434CFLAGS+=$($PKG_CONFIG --cflags gnutls) $(libgcrypt-config --cflags)
435EOF
436                ssl=gnutls
437                if ! $PKG_CONFIG gnutls --atleast-version=2.8; then
438                        echo
439                        echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.'
440                fi
441                ret=1
442        elif libgnutls-config --version > /dev/null 2> /dev/null; then
443                cat <<EOF >>Makefile.settings
444EFLAGS+=$(libgnutls-config --libs) $(libgcrypt-config --libs)
445CFLAGS+=$(libgnutls-config --cflags) $(libgcrypt-config --cflags)
446EOF
447               
448                ssl=gnutls
449                ret=1;
450        else
451                ret=0;
452        fi;
453}
454
455detect_nss()
456{
457        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then
458                cat<<EOF >>Makefile.settings
459EFLAGS+=$($PKG_CONFIG --libs nss)
460CFLAGS+=$($PKG_CONFIG --cflags nss)
461EOF
462               
463                ssl=nss
464                ret=1;
465        else
466                ret=0;
467        fi;
468}
469
470RESOLV_TESTCODE='
471#include <sys/types.h>
472#include <netinet/in.h>
473#include <arpa/nameser.h>
474#include <resolv.h>
475
476int main()
477{
478
479        res_query( NULL, 0, 0, NULL, 0);
480        dn_expand( NULL, NULL, NULL, NULL, 0);
481        dn_skipname( NULL, NULL);
482}
483'
484RESOLV_NS_TESTCODE='
485#include <sys/types.h>
486#include <netinet/in.h>
487#include <arpa/nameser.h>
488#include <resolv.h>
489
490int main()
491{
492        ns_initparse( NULL, 0, NULL );
493        ns_parserr( NULL, ns_s_an, 0, NULL );
494}
495'
496RESOLV_NS_TYPES_TESTCODE='
497#include <sys/types.h>
498#include <netinet/in.h>
499#include <arpa/nameser.h>
500
501int main()
502{
503        ns_msg nsh;
504        ns_rr rr;
505
506        /* Not all platforms we want to work on have
507         ns_* routines, so use this to make sure
508         the compiler uses it.*/
509        return (int)(sizeof(nsh) + sizeof(rr));
510}
511'
512
513BACKTRACE_TESTCODE='
514#include <execinfo.h>
515
516int main()
517{
518        void *trace[16];
519        return backtrace(trace, 16);
520}
521'
522
523detect_resolv_dynamic()
524{
525        case "$arch" in
526        OpenBSD )
527                # In FreeBSD res_*/dn_* routines are present in libc.so
528                LIBRESOLV=;;
529        FreeBSD )
530                # In FreeBSD res_*/dn_* routines are present in libc.so
531                LIBRESOLV=;;
532        CYGWIN* )
533                # In Cygwin res_*/dn_* routines are present in libc.so
534                LIBRESOLV=;;
535        * )
536                LIBRESOLV=-lresolv;;
537        esac
538        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
539        ret=1
540        if echo "$RESOLV_TESTCODE" | $CC -o "$TMPFILE" -x c - $LIBRESOLV >/dev/null 2>/dev/null ; then
541                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
542                ret=0
543        fi
544
545        rm -f "$TMPFILE"
546        return $ret
547}
548
549detect_resolv_static()
550{
551        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
552        ret=1
553        for i in $systemlibdirs; do
554                if [ -f "$i"/libresolv.a ]; then
555                        if echo "$RESOLV_TESTCODE" | $CC -o "$TMPFILE" -x c - -Wl,"$i"/libresolv.a >/dev/null 2>/dev/null ; then
556                                echo "EFLAGS+=$i/libresolv.a" >> Makefile.settings
557                                ret=0
558                        fi
559                fi
560        done
561
562        rm -f "$TMPFILE"
563        return $ret
564}
565
566detect_resolv_ns_dynamic()
567{
568        case "$arch" in
569        FreeBSD )
570                # In FreeBSD ns_ routines are present in libc.so
571                LIBRESOLV=;;
572        * )
573                LIBRESOLV=-lresolv;;
574        esac
575        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
576        ret=1
577        if echo "$RESOLV_NS_TESTCODE" | $CC -o "$TMPFILE" -x c - $LIBRESOLV >/dev/null 2>/dev/null ; then
578                ret=0
579        fi
580
581        rm -f "$TMPFILE"
582        return $ret
583}
584
585detect_resolv_ns_static()
586{
587        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
588        ret=1
589        for i in $systemlibdirs; do
590                if [ -f "$i"/libresolv.a ]; then
591                        if echo "$RESOLV_NS_TESTCODE" | $CC -o "$TMPFILE" -x c - -Wl,"$i"/libresolv.a >/dev/null 2>/dev/null ; then
592                                ret=0
593                        fi
594                fi
595        done
596
597        rm -f "$TMPFILE"
598        return $ret
599}
600
601detect_nameser_has_ns_types()
602{
603        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
604        ret=1
605        # since we aren't actually linking with ns_* routines
606        # we can just compile the test code
607        if echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o "$TMPFILE" -x c -  >/dev/null 2>/dev/null ; then
608                ret=0
609        fi
610
611        rm -f "$TMPFILE"
612        return $ret
613}
614
615detect_backtrace()
616{
617        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
618        ret=1
619        if echo "$BACKTRACE_TESTCODE" | $CC -o "$TMPFILE" -x c -  >/dev/null 2>/dev/null ; then
620                ret=0
621        fi
622
623        rm -f "$TMPFILE"
624        return $ret
625}
626
627if [ "$ssl" = "auto" ]; then
628        detect_gnutls
629        if [ "$ret" = "0" ]; then
630                # Disable NSS for now as it's known to not work very well ATM.
631                #detect_nss
632                :
633        fi
634elif [ "$ssl" = "gnutls" ]; then
635        detect_gnutls
636elif [ "$ssl" = "nss" ]; then
637        detect_nss
638elif [ "$ssl" = "openssl" ]; then
639        echo
640        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
641        echo 'installation of OpenSSL (including devel/header files) before reporting'
642        echo 'compilation problems.'
643        echo
644        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
645        echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported'
646        echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the'
647        echo 'operating system, which makes it GPL-compatible.'
648        echo
649        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
650        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
651        echo
652        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
653        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
654        echo 'package, you really should use GnuTLS instead.'
655        echo
656        echo 'Also, the OpenSSL license requires us to say this:'
657        echo ' *    "This product includes software developed by the OpenSSL Project'
658        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
659       
660        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
661       
662        ret=1
663else
664        echo
665        echo 'ERROR: Unknown SSL library specified.'
666        exit 1
667fi
668
669if [ "$ret" = "0" ]; then
670        echo
671        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
672        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
673        echo '       so if you want to use that, you have to select it by hand.'
674       
675        exit 1
676fi;
677
678echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
679
680if detect_nameser_has_ns_types; then
681        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
682fi
683if detect_resolv_dynamic || detect_resolv_static; then
684        echo '#define HAVE_RESOLV_A' >> config.h
685        if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
686                echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
687        fi
688else
689        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
690fi
691
692if detect_backtrace; then
693        echo '#define HAVE_BACKTRACE' >> config.h
694        echo "#define CRASHFILE \"${config}crash.log\"" >> config.h
695fi
696
697STORAGES="xml"
698
699for i in $STORAGES; do
700        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
701done
702echo "STORAGE_OBJS=$STORAGE_OBJS" >> Makefile.settings
703
704authobjs=
705authlibs=
706if [ "$pam" = "0" ]; then
707        echo '#undef WITH_PAM' >> config.h
708else
709        if ! echo '#include <security/pam_appl.h>' | $CC -E - >/dev/null 2>/dev/null; then
710                echo 'Cannot find libpam development libraries, aborting. (Install libpam0g-dev?)'
711                exit 1
712        fi
713        echo '#define WITH_PAM' >> config.h
714        authobjs=$authobjs'auth_pam.o '
715        authlibs=$authlibs'-lpam '
716fi
717if [ "$ldap" = "0" ]; then
718        echo '#undef WITH_LDAP' >> config.h
719else
720        if ! echo '#include <ldap.h>' | $CC -E - >/dev/null 2>/dev/null; then
721                echo 'Cannot find libldap development libraries, aborting. (Install libldap2-dev?)'
722                exit 1
723        fi
724        echo '#define WITH_LDAP' >> config.h
725        authobjs=$authobjs'auth_ldap.o '
726        authlibs=$authlibs'-lldap '
727fi
728echo AUTH_OBJS="$authobjs" >> Makefile.settings
729echo EFLAGS+="$authlibs" >> Makefile.settings
730
731if [ "$strip" = "0" ]; then
732        echo "STRIP=\# skip strip" >> Makefile.settings;
733else
734        if [ "$debug" = "1" ]; then
735                echo
736                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
737                echo 'STRIP=\# skip strip' >> Makefile.settings
738                strip=0;
739        elif [ -n "$STRIP" ]; then
740                echo "STRIP=$STRIP" >> Makefile.settings;
741        elif type strip > /dev/null 2> /dev/null; then
742                echo "STRIP=strip" >> Makefile.settings;
743        else
744                echo
745                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
746                echo 'STRIP=\# skip strip' >> Makefile.settings
747                strip=0;
748        fi;
749fi
750
751if [ ! "$systemd" = "0" ]; then
752    if ! $PKG_CONFIG --exists systemd ; then
753        if [ $systemd -eq 1 ]; then
754            echo "systemd requested but not found"
755            exit 1
756        else
757            systemd=0
758        fi
759    elif [ $systemd = "auto" ]; then
760        systemd=1
761    fi
762fi
763
764pkgconf_systemd_var() {
765    # First try deprecated variable, use newer variable if not found
766    if $PKG_CONFIG --print-variables systemd | grep -q "$1" ; then
767        $PKG_CONFIG --variable="$1" systemd
768    else
769        $PKG_CONFIG --variable="$2" systemd
770    fi
771}
772
773if [ "$systemd" = "1" ]; then
774        if [ -z "$systemdsystemunitdir" ]; then
775                systemdsystemunitdir=$(pkgconf_systemd_var systemdsystemunitdir systemd_system_unit_dir)
776        fi
777        if [ -z "$sysusersdir" ] ; then
778                sysusersdir=$(pkgconf_systemd_var sysusersdir sysusers_dir)
779        fi
780fi
781
782if [ -n "$systemdsystemunitdir" ]; then
783        echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
784fi
785if [ -n "$sysusersdir" ]; then
786        echo "SYSUSERSDIR=$sysusersdir" >> Makefile.settings
787fi
788
789if [ "$gcov" = "1" ]; then
790        echo "CFLAGS+=--coverage" >> Makefile.settings
791        echo "EFLAGS+=--coverage" >> Makefile.settings
792fi
793
794if [ "$plugins" = "0" ]; then
795        plugindir=""
796        echo '#undef WITH_PLUGINS' >> config.h
797else
798        echo '#define WITH_PLUGINS' >> config.h
799fi
800
801if [ "$otr" = "auto" ]; then
802        ! $PKG_CONFIG --exists libotr
803        otr=$?
804fi
805
806if [ "$otr" != "0" ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
807        exit 1
808fi
809
810if [ "$otr" = "1" ]; then
811        # BI == built-in
812        echo '#define OTR_BI' >> config.h
813        # shellcheck disable=SC2129
814        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
815        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
816        echo 'OTR_BI=otr.o' >> Makefile.settings
817elif [ "$otr" = "plugin" ]; then
818        # for some mysterious reason beyond the comprehension of my mortal mind,
819        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
820        echo '#define OTR_PI' >> config.h
821        # shellcheck disable=SC2129
822        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
823        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
824        echo 'OTR_PI=otr.so' >> Makefile.settings
825fi
826
827if [ -z "$PYTHON" ]; then
828        for pp in python python3 python2; do
829                if which $pp > /dev/null; then
830                        PYTHON=$pp
831                        break
832                fi
833        done
834fi
835
836if [ "$doc" = "1" ]; then
837        # check this here just in case someone tries to install it in python2.4...
838        if [ ! -e "$srcdir"/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
839                echo
840                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
841                echo "(Use the PYTHON environment variable if it's in a weird location)"
842                exit 1
843        fi
844        echo "DOC=1" >> Makefile.settings
845        echo "PYTHON=$PYTHON" >> Makefile.settings
846fi
847
848get_version
849
850if [ ! "$BITLBEE_VERSION" = "$REAL_BITLBEE_VERSION" ]; then
851        echo "Spoofing version number: $BITLBEE_VERSION"
852        echo "#undef BITLBEE_VERSION" >> config.h
853        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
854        echo
855fi
856
857if ! make helloworld > /dev/null 2>&1; then
858        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
859        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
860        echo "under the name 'gmake'."
861        echo
862        if gmake helloworld > /dev/null 2>&1; then
863                echo "gmake seems to be available on your machine, great."
864                echo
865        else
866                echo "gmake is not installed (or not working). Please try to install it."
867                echo
868        fi
869fi
870
871pkgconfiglibs=''
872case "$arch" in
873CYGWIN* )
874        pkgconfiglibs="-L${libdir} -lbitlbee -no-undefined"
875esac
876
877pkgconfigrequires='glib-2.0'
878if [ "$external_json_parser" = '1' ]; then
879        pkgconfigrequires="$pkgconfigrequires json-parser"
880fi
881
882cat <<EOF >bitlbee.pc
883prefix=$prefix
884includedir=$includedir
885plugindir=$plugindir
886libdir=$libdir
887datadir=$datadir
888
889Name: bitlbee
890Description: IRC to IM gateway
891Requires: $pkgconfigrequires
892Version: $BITLBEE_VERSION
893Libs: $pkgconfiglibs
894Cflags: -I\${includedir}
895
896EOF
897
898protocols=''
899protoobjs=''
900
901if [ "$purple" = "0" ]; then
902        echo '#undef WITH_PURPLE' >> config.h
903else
904        if ! $PKG_CONFIG purple; then
905                echo
906                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
907                exit 1
908        fi
909        echo '#define WITH_PURPLE' >> config.h
910        cat<<EOF >>Makefile.settings
911EFLAGS += $($PKG_CONFIG purple --libs)
912PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
913EOF
914        protocols=$protocols'purple '
915        protoobjs=$protoobjs'purple_mod.o '
916
917        # only disable these if the user didn't enable them explicitly
918        [ "$jabber" = "default-on" ] && jabber=0
919
920        echo '#undef PACKAGE' >> config.h
921        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
922       
923        if [ "$events" = "libevent" ]; then
924                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
925                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
926                echo 'libpurple + libevent is *not* recommended!'
927                echo
928        fi
929fi
930
931case "$CC" in
932*gcc* )
933        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
934        for i in . lib tests protocols protocols/*/; do
935                mkdir -p "$i"/.depend
936        done
937esac
938
939if [ "$jabber" = "0" ]; then
940        echo '#undef WITH_JABBER' >> config.h
941else
942        echo '#define WITH_JABBER' >> config.h
943        protocols=$protocols'jabber '
944        protoobjs=$protoobjs'jabber_mod.o '
945fi
946
947if [ "$twitter" = "0" ]; then
948        echo '#undef WITH_TWITTER' >> config.h
949else
950        echo '#define WITH_TWITTER' >> config.h
951        protocols=$protocols'twitter '
952        protoobjs=$protoobjs'twitter_mod.o '
953fi
954
955if [ "$protocols" = "PROTOCOLS = " ]; then
956        echo "Warning: You haven't selected any communication protocol to compile!"
957        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
958fi
959
960echo "PROTOCOLS = $protocols" >> Makefile.settings
961echo "PROTOOBJS = $protoobjs" >> Makefile.settings
962
963echo Architecture: "$arch"
964case "$arch" in
965Linux )
966;;
967GNU/* )
968;;
969*BSD )
970;;
971Darwin )
972        echo 'STRIP=\# skip strip' >> Makefile.settings
973;;
974IRIX )
975;;
976SunOS )
977        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
978        echo 'STRIP=\# skip strip' >> Makefile.settings
979        echo '#define NO_FD_PASSING' >> config.h
980        if [ "$arch_rel" = "5.10" ]; then
981                echo '#define NO_STRCASESTR' >> config.h
982        fi
983;;
984AIX )
985        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
986;;
987CYGWIN* )
988        echo 'EFLAGS+=-Wl,--export-all,--out-implib,libbitlbee.dll.a' >> Makefile.settings
989        echo 'IMPLIB=libbitlbee.dll.a' >> Makefile.settings
990;;
991Windows )
992        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
993;;
994* )
995        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
996        echo 'Please report any problems at http://bugs.bitlbee.org/.'
997;;
998esac
999
1000if [ -n "$target" ]; then
1001        echo "Cross-compiling for: $target"
1002fi
1003
1004echo
1005echo 'Configuration done:'
1006
1007if [ "$debug" = "1" ]; then
1008        echo '  Debugging enabled.'
1009else
1010        echo '  Debugging disabled.'
1011fi
1012
1013if [ "$asan" = "1" ]; then
1014        echo '  AddressSanitizer (ASAN) enabled.'
1015else
1016        echo '  AddressSanitizer (ASAN) disabled.'
1017fi
1018
1019if [ "$pie" = "1" ]; then
1020        echo '  Building PIE executable'
1021else
1022        echo '  Building non-PIE executable'
1023fi
1024
1025if [ "$strip" = "1" ]; then
1026        echo '  Binary stripping enabled.'
1027else
1028        echo '  Binary stripping disabled.'
1029fi
1030
1031if [ "$otr" = "1" ]; then
1032        echo '  Off-the-Record (OTR) Messaging enabled.'
1033elif [ "$otr" = "plugin" ]; then
1034        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
1035else
1036        echo '  Off-the-Record (OTR) Messaging disabled.'
1037fi
1038
1039if [ "$systemd" = "1" ]; then
1040        echo '  systemd enabled.'
1041else
1042        echo '  systemd disabled.'
1043fi
1044
1045echo '  Using python: '$PYTHON
1046
1047if [ "$external_json_parser" = "1" ]; then
1048    echo '  Using system JSON parser.'
1049else
1050    echo '  Using bundled JSON parser.'
1051fi
1052
1053echo '  Using event handler: '$events
1054echo '  Using SSL library: '$ssl
1055#echo '  Building with these storage backends: '$STORAGES
1056
1057if [ -n "$protocols" ]; then
1058        echo '  Building with these protocols:' "$protocols""$protocols_mods"
1059        case "$protocols" in
1060        *purple*)
1061                echo "    Note that BitlBee-libpurple is supported on a best-effort basis. It's"
1062                echo "    not *fully* compatible with normal BitlBee. Don't use it unless you"
1063                echo "    absolutely need it (i.e. support for a certain protocol or feature)."
1064        esac
1065else
1066        echo '  Building without IM-protocol support. We wish you a lot of fun...'
1067fi
Note: See TracBrowser for help on using the repository browser.