source: configure @ 50d0a72

Last change on this file since 50d0a72 was 50d0a72, checked in by GitHub <noreply@…>, at 2023-03-07T21:21:34Z

Improve control over automatic properties of Systemd configuration (#174)

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