source: configure @ acf26c3

Last change on this file since acf26c3 was 612b49d, checked in by GitHub <noreply@…>, at 2023-04-16T03:18:07Z

configure: address ShellCheck reports and add ShellCheck job (#189)

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