source: configure @ 82149f4

Last change on this file since 82149f4 was 82149f4, checked in by GitHub <noreply@…>, at 2023-03-04T19:59:09Z

Fixes related to external-json-parser (#165)

  • configure: append conditionally json-parser to pc file

json-parser needs to be appended to Requires section of pkg-config file
when bitlbee is configured to use external-json-parser. This change is
needed for external plugins like bitlbee-steam.

  • Makefile: do not install json.h when system json-parser is used

install-dev target should not install bundled json.h when bitlbee is
configured to use external-json-parser.

  • Use correct json.h header file with respect to external_json_parser value

The preprocessor must include correct json.h header file with respect to
external_json_parser value, otherwise function prototypes and other
definitions do not need to correspond with object used for linking.

The state before this commit is that local version lib/json.h is used
always for compilation and external_json_parser variable controls if
local lib/json.o or global libjsonparser.so will be linked.

In order to fix this problem, #include directives in lib/json_util.h and
lib/oauth2.c were changed from "json.h" to <json.h> and preprocessor -I
flags were moved after conditional json-parser flags, which is enough
for solving the issue. Additionally, USE_EXTERNAL_JSON_PARSER macro is
exported when external-json-parser is used and it is used in lib/json.h
to trigger an error message, which should prevent similar mistakes in
future.

  • Property mode set to 100755
File size: 26.1 KB
Line 
1#!/bin/sh
2
3##############################
4##  Configurer for BitlBee  ##
5##                          ##
6##  Copyright 2004 Lintux   ##
7##  Copyright 2002 Lucumo   ##
8##############################
9
10prefix="/usr/local/"
11bindir="$prefix/bin/"
12sbindir="$prefix/sbin/"
13etcdir="$prefix/etc/bitlbee/"
14mandir="$prefix/share/man/"
15datadir="$prefix/share/bitlbee/"
16config="/var/lib/bitlbee/"
17libdir="$prefix/lib/"
18plugindir="$prefix/lib/bitlbee/"
19includedir="$prefix/include/bitlbee/"
20systemdsystemunitdir=""
21sysusersdir=""
22libevent="/usr/"
23pidfile="/var/run/bitlbee.pid"
24ipcsocket=""
25pcdir="$prefix/lib/pkgconfig"
26systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib"
27sysroot=""
28
29configure_args="$*"
30
31# Set these to default-on to let it be overriden by either the user or purple
32#
33# If the user sets one of these to 1, purple won't disable them.
34# Otherwise, if it's still default-on, it gets included in normal builds,
35# but not purple ones.
36jabber="default-on"
37
38twitter=1
39purple=0
40
41verbose=0
42doc=1
43debug=0
44strip=0
45gcov=0
46asan=0
47plugins=1
48otr=0
49
50events=glib
51external_json_parser=auto
52ssl=auto
53
54pam=0
55ldap=0
56
57pie=1
58
59systemd=auto
60
61arch=$(uname -s)
62arch_rel=$(uname -r)
63
64GLIB_MIN_VERSION=2.32
65
66# Cygwin, Darwin and SunOS < 5.11 do not support PIC/PIE
67case "$arch" in
68        CYGWIN* )
69                pie=0;;
70        Darwin )
71                pie=0;;
72        SunOS )
73                if [ "$arch_rel" = "5.10" ]; then
74                        pie=0
75                fi
76                ;;
77esac
78
79get_version() {
80        REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' "$srcdir"/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/')
81
82        if [ -n "$BITLBEE_VERSION" ]; then
83                # environment variable already set to something to spoof it
84                # don't replace it with the git stuff
85                return
86        fi
87
88        BITLBEE_VERSION=$REAL_BITLBEE_VERSION
89
90        if [ -d "$srcdir"/.git ] && type git > /dev/null 2> /dev/null; then
91                timestamp=$(cd "$srcdir" || exit 1; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g')
92                branch=$(cd "$srcdir" || exit 1; git rev-parse --abbrev-ref HEAD)
93
94                search='\(.*\)-\([0-9]*\)-\(g[0-9a-f]*\)'
95                replace="\1+$timestamp+$branch+\2-\3-git"
96
97                if ! describe=$(cd "$srcdir" || exit 1; git describe --long --tags 2>/dev/null) ; then
98                        describe=${REAL_BITLBEE_VERSION}-0-g$(cd "$srcdir" || exit; git rev-parse --short HEAD)
99                fi
100
101                BITLBEE_VERSION=$(echo "$describe" | sed "s#$search#$replace#")
102
103                unset timestamp branch search replace describe
104        fi
105}
106
107if [ "$1" = "--dump-version" ]; then
108        srcdir=$(cd "$(dirname "$0")" || exit;pwd)
109        get_version
110        echo "$BITLBEE_VERSION"
111        exit
112fi
113
114echo BitlBee configure
115
116while [ -n "$1" ]; do
117        e="$(expr "X$1" : 'X--\(.*=.*\)')"
118        if [ -z "$e" ]; then
119                cat<<EOF
120
121Usage: $0 [OPTIONS]
122
123Option          Description                             Default
124
125--prefix=...    Directories to put files in             $prefix
126--bindir=...                                            $bindir
127--sbindir=...                                           $sbindir
128--etcdir=...                                            $etcdir
129--mandir=...                                            $mandir
130--datadir=...                                           $datadir
131--plugindir=...                                         $plugindir
132--systemdsystemunitdir=...                              $systemdsystemunitdir
133--sysusersdir                       $sysusersdir
134--pidfile=...                                           $pidfile
135--config=...                                            $config
136
137--verbose=0/1   Disable/enable verbose build            $verbose
138
139--jabber=0/1    Disable/enable Jabber part              $jabber
140--twitter=0/1   Disable/enable Twitter part             $twitter
141
142--purple=0/1    Disable/enable libpurple support        $purple
143                (automatically disables other protocol modules)
144
145--pam=0/1       Disable/enable PAM authentication       $pam
146--ldap=0/1      Disable/enable LDAP authentication      $ldap
147
148--doc=0/1       Disable/enable help.txt generation      $doc
149--debug=0/1     Disable/enable debugging                $debug
150--strip=0/1     Disable/enable binary stripping         $strip
151--pie=0/1       Build position independent executable   $pie
152--gcov=0/1      Disable/enable test coverage reporting  $gcov
153--asan=0/1      Disable/enable AddressSanitizer         $asan
154--plugins=0/1   Disable/enable plugins support          $plugins
155--otr=0/1/auto/plugin
156                Disable/enable OTR encryption support   $otr
157
158--events=...    Event handler (glib, libevent)          $events
159--ssl=...       SSL library to use (gnutls, nss, openssl, auto)
160                                                        $ssl
161--external_json_parser=0/1/auto Use External JSON parser $external_json_parser
162--systemd=0/1  Enable/disable systemd support $systemd
163
164
165--target=...    Cross compilation target                same as host
166--sysroot=...   Cross compilation sysroot               $sysroot
167EOF
168                exit;
169        fi
170        eval "$e"
171        shift;
172done
173
174# Expand $prefix and get rid of double slashes
175bindir=$(eval echo "$bindir/" | sed 's/\/\{1,\}/\//g')
176sbindir=$(eval echo "$sbindir/" | sed 's/\/\{1,\}/\//g')
177etcdir=$(eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g')
178mandir=$(eval echo "$mandir/" | sed 's/\/\{1,\}/\//g')
179datadir=$(eval echo "$datadir/" | sed 's/\/\{1,\}/\//g')
180config=$(eval echo "$config/" | sed 's/\/\{1,\}/\//g')
181libdir=$(eval echo "$libdir/" | sed 's/\/\{1,\}/\//g')
182plugindir=$(eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g')
183includedir=$(eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g')
184libevent=$(eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g')
185
186pidfile=$(eval echo "$pidfile" | sed 's/\/\{1,\}/\//g')
187ipcsocket=$(eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g')
188pcdir=$(eval echo "$pcdir" | sed 's/\/\{1,\}/\//g')
189
190protocols_mods=""
191
192cat <<EOF >Makefile.settings
193## BitlBee settings, generated by configure
194
195# ./configure $configure_args
196
197PREFIX=$prefix
198BINDIR=$bindir
199SBINDIR=$sbindir
200ETCDIR=$etcdir
201MANDIR=$mandir
202DATADIR=$datadir
203PLUGINDIR=$plugindir
204CONFIG=$config
205LIBDIR=$libdir
206INCLUDEDIR=$includedir
207PCDIR=$pcdir
208
209TARGET=$target
210
211INSTALL=install -p
212
213DESTDIR=
214LFLAGS=
215EFLAGS=-lm
216EOF
217
218srcdir=$(cd "$(dirname "$0")" || exit;pwd)
219currdir=$(pwd)
220if [ ! "$srcdir" = "$currdir" ]; then 
221        echo
222        echo "configure script run from a different directory. Will create some symlinks..."
223        if [ ! -e Makefile ] || [ -L Makefile ]; then
224                COPYDIRS="doc lib protocols tests utils"
225                mkdir -p $(cd "$srcdir" || exit 1; find $COPYDIRS -type d)
226                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
227                dst="$PWD"
228                cd "$srcdir" || exit 1
229                find . -type f -name Makefile -print | while read -r i ; do
230                        ln -s "$PWD${i#.}" "$dst/$i";
231                done
232                cd "$dst" || exit 1
233                rm -rf .bzr
234        fi
235       
236        echo "_SRCDIR_=$srcdir/" >> Makefile.settings
237        CFLAGS="$CFLAGS -I${dst}"
238else
239        srcdir=$PWD
240fi
241
242cat<<EOF >config.h
243/* BitlBee settings, generated by configure
244   
245   Do *NOT* use any of these defines in your code without thinking twice, most
246   of them can/will be overridden at run-time */
247
248#define BITLBEE_CONFIGURE_ARGS "$configure_args"
249
250#define CONFIG "$config"
251#define ETCDIR "$etcdir"
252#define VARDIR "$datadir"
253#define PLUGINDIR "$plugindir"
254#define DATADIR "$datadir"
255#define PIDFILE "$pidfile"
256#define IPCSOCKET "$ipcsocket"
257EOF
258
259
260
261if [ -n "$target" ]; then
262        # prepend sysroot to system lib dirs
263
264        systemlibdirs_cross=''
265        for i in $systemlibdirs; do
266                systemlibdirs_cross="$systemlibdirs_cross $sysroot$i"
267        done
268        systemlibdirs=$systemlibdirs_cross
269        unset systemlibdirs_cross
270
271        # backward compatibility
272
273        if [ -z "$PKG_CONFIG_LIBDIR" ]; then
274                PKG_CONFIG_LIBDIR=/usr/"$target"/lib/pkgconfig
275                export PKG_CONFIG_LIBDIR
276        fi
277
278        if [ -d /usr/"$target"/bin ]; then
279                PATH=/usr/"$target"/bin:$PATH
280        fi
281
282        if [ -d /usr/"$target"/lib ]; then
283                systemlibdirs="$systemlibdirs /usr/$target/lib"
284        fi
285
286        CC=$target-cc
287        LD=$target-ld
288        STRIP=$target-strip
289fi
290
291if [ "$asan" = "1" ]; then
292        CFLAGS="$CFLAGS -fsanitize=address"
293        LDFLAGS="$LDFLAGS -fsanitize=address"
294        debug=1
295fi
296
297if [ "$verbose" = "0" ]; then
298        echo 'VERBOSE=@' >> Makefile.settings
299else
300        echo 'VERBOSE=' >> Makefile.settings
301fi
302
303cat <<EOF >>Makefile.settings
304
305# Enable/disable output verbosity
306ifdef V
307ifeq (\$(V),1)
308        VERBOSE=
309else
310        VERBOSE=@
311endif
312endif
313
314EOF
315
316if [ "$debug" = "1" ]; then
317        echo 'DEBUG=1' >> Makefile.settings
318        CFLAGS="$CFLAGS -g3 -DDEBUG -O0"
319else
320        [ -z "$CFLAGS" ] && CFLAGS="-g -O2"
321fi
322
323if [ "$pie" = "1" ]; then
324        echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings
325        echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings
326fi
327
328# shellcheck disable=SC2129
329echo "LDFLAGS=$LDFLAGS" >> Makefile.settings
330
331echo "CFLAGS=$CFLAGS $CPPFLAGS" >> Makefile.settings
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 [ -n "$systemdsystemunitdir" ] || [ $systemd -eq 1 ]; then
754            echo "systemd requested but not found"
755            exit 1
756        else
757            systemd=0
758        fi
759    fi
760fi
761
762pkgconf_systemd_var() {
763    # First try deprecated variable, use newer variable if not found
764    if $PKG_CONFIG --print-variables systemd | grep -q "$1" ; then
765        $PKG_CONFIG --variable="$1" systemd
766    else
767        $PKG_CONFIG --variable="$2" systemd
768    fi
769}
770
771if [ "$systemd" = "1" ]; then
772        if [ -z "$systemdsystemunitdir" ]; then
773                systemdsystemunitdir=$(pkgconf_systemd_var systemdsystemunitdir systemd_system_unit_dir)
774        fi
775    if [ -z "$sysusersdir" ] ; then
776        sysusersdir=$(pkgconf_systemd_var sysusersdir sysusers_dir)
777    fi
778
779        echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
780    echo "SYSUSERSDIR=$sysusersdir" >> Makefile.settings
781fi
782
783if [ "$gcov" = "1" ]; then
784        echo "CFLAGS+=--coverage" >> Makefile.settings
785        echo "EFLAGS+=--coverage" >> Makefile.settings
786fi
787
788if [ "$plugins" = "0" ]; then
789        plugindir=""
790        echo '#undef WITH_PLUGINS' >> config.h
791else
792        echo '#define WITH_PLUGINS' >> config.h
793fi
794
795if [ "$otr" = "auto" ]; then
796        ! $PKG_CONFIG --exists libotr
797        otr=$?
798fi
799
800if [ "$otr" != "0" ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
801        exit 1
802fi
803
804if [ "$otr" = "1" ]; then
805        # BI == built-in
806        echo '#define OTR_BI' >> config.h
807        # shellcheck disable=SC2129
808        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
809        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
810        echo 'OTR_BI=otr.o' >> Makefile.settings
811elif [ "$otr" = "plugin" ]; then
812        # for some mysterious reason beyond the comprehension of my mortal mind,
813        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
814        echo '#define OTR_PI' >> config.h
815        # shellcheck disable=SC2129
816        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
817        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
818        echo 'OTR_PI=otr.so' >> Makefile.settings
819fi
820
821if [ -z "$PYTHON" ]; then
822        for pp in python python3 python2; do
823                if which $pp > /dev/null; then
824                        PYTHON=$pp
825                        break
826                fi
827        done
828fi
829
830if [ "$doc" = "1" ]; then
831        # check this here just in case someone tries to install it in python2.4...
832        if [ ! -e "$srcdir"/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
833                echo
834                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
835                echo "(Use the PYTHON environment variable if it's in a weird location)"
836                exit 1
837        fi
838        echo "DOC=1" >> Makefile.settings
839        echo "PYTHON=$PYTHON" >> Makefile.settings
840fi
841
842get_version
843
844if [ ! "$BITLBEE_VERSION" = "$REAL_BITLBEE_VERSION" ]; then
845        echo "Spoofing version number: $BITLBEE_VERSION"
846        echo "#undef BITLBEE_VERSION" >> config.h
847        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
848        echo
849fi
850
851if ! make helloworld > /dev/null 2>&1; then
852        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
853        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
854        echo "under the name 'gmake'."
855        echo
856        if gmake helloworld > /dev/null 2>&1; then
857                echo "gmake seems to be available on your machine, great."
858                echo
859        else
860                echo "gmake is not installed (or not working). Please try to install it."
861                echo
862        fi
863fi
864
865pkgconfiglibs=''
866case "$arch" in
867CYGWIN* )
868        pkgconfiglibs="-L${libdir} -lbitlbee -no-undefined"
869esac
870
871pkgconfigrequires='glib-2.0'
872if [ "$external_json_parser" = '1' ]; then
873        pkgconfigrequires="$pkgconfigrequires json-parser"
874fi
875
876cat <<EOF >bitlbee.pc
877prefix=$prefix
878includedir=$includedir
879plugindir=$plugindir
880libdir=$libdir
881datadir=$datadir
882
883Name: bitlbee
884Description: IRC to IM gateway
885Requires: $pkgconfigrequires
886Version: $BITLBEE_VERSION
887Libs: $pkgconfiglibs
888Cflags: -I\${includedir}
889
890EOF
891
892protocols=''
893protoobjs=''
894
895if [ "$purple" = "0" ]; then
896        echo '#undef WITH_PURPLE' >> config.h
897else
898        if ! $PKG_CONFIG purple; then
899                echo
900                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
901                exit 1
902        fi
903        echo '#define WITH_PURPLE' >> config.h
904        cat<<EOF >>Makefile.settings
905EFLAGS += $($PKG_CONFIG purple --libs)
906PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
907EOF
908        protocols=$protocols'purple '
909        protoobjs=$protoobjs'purple_mod.o '
910
911        # only disable these if the user didn't enable them explicitly
912        [ "$jabber" = "default-on" ] && jabber=0
913
914        echo '#undef PACKAGE' >> config.h
915        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
916       
917        if [ "$events" = "libevent" ]; then
918                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
919                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
920                echo 'libpurple + libevent is *not* recommended!'
921                echo
922        fi
923fi
924
925case "$CC" in
926*gcc* )
927        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
928        for i in . lib tests protocols protocols/*/; do
929                mkdir -p "$i"/.depend
930        done
931esac
932
933if [ "$jabber" = "0" ]; then
934        echo '#undef WITH_JABBER' >> config.h
935else
936        echo '#define WITH_JABBER' >> config.h
937        protocols=$protocols'jabber '
938        protoobjs=$protoobjs'jabber_mod.o '
939fi
940
941if [ "$twitter" = "0" ]; then
942        echo '#undef WITH_TWITTER' >> config.h
943else
944        echo '#define WITH_TWITTER' >> config.h
945        protocols=$protocols'twitter '
946        protoobjs=$protoobjs'twitter_mod.o '
947fi
948
949if [ "$protocols" = "PROTOCOLS = " ]; then
950        echo "Warning: You haven't selected any communication protocol to compile!"
951        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
952fi
953
954echo "PROTOCOLS = $protocols" >> Makefile.settings
955echo "PROTOOBJS = $protoobjs" >> Makefile.settings
956
957echo Architecture: "$arch"
958case "$arch" in
959Linux )
960;;
961GNU/* )
962;;
963*BSD )
964;;
965Darwin )
966        echo 'STRIP=\# skip strip' >> Makefile.settings
967;;
968IRIX )
969;;
970SunOS )
971        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
972        echo 'STRIP=\# skip strip' >> Makefile.settings
973        echo '#define NO_FD_PASSING' >> config.h
974        if [ "$arch_rel" = "5.10" ]; then
975                echo '#define NO_STRCASESTR' >> config.h
976        fi
977;;
978AIX )
979        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
980;;
981CYGWIN* )
982        echo 'EFLAGS+=-Wl,--export-all,--out-implib,libbitlbee.dll.a' >> Makefile.settings
983        echo 'IMPLIB=libbitlbee.dll.a' >> Makefile.settings
984;;
985Windows )
986        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
987;;
988* )
989        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
990        echo 'Please report any problems at http://bugs.bitlbee.org/.'
991;;
992esac
993
994if [ -n "$target" ]; then
995        echo "Cross-compiling for: $target"
996fi
997
998echo
999echo 'Configuration done:'
1000
1001if [ "$debug" = "1" ]; then
1002        echo '  Debugging enabled.'
1003else
1004        echo '  Debugging disabled.'
1005fi
1006
1007if [ "$asan" = "1" ]; then
1008        echo '  AddressSanitizer (ASAN) enabled.'
1009else
1010        echo '  AddressSanitizer (ASAN) disabled.'
1011fi
1012
1013if [ "$pie" = "1" ]; then
1014        echo '  Building PIE executable'
1015else
1016        echo '  Building non-PIE executable'
1017fi
1018
1019if [ "$strip" = "1" ]; then
1020        echo '  Binary stripping enabled.'
1021else
1022        echo '  Binary stripping disabled.'
1023fi
1024
1025if [ "$otr" = "1" ]; then
1026        echo '  Off-the-Record (OTR) Messaging enabled.'
1027elif [ "$otr" = "plugin" ]; then
1028        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
1029else
1030        echo '  Off-the-Record (OTR) Messaging disabled.'
1031fi
1032
1033if [ "$systemd" = "1" ]; then
1034        echo '  systemd enabled.'
1035else
1036        echo '  systemd disabled.'
1037fi
1038
1039echo '  Using python: '$PYTHON
1040
1041if [ "$external_json_parser" = "1" ]; then
1042    echo '  Using system JSON parser.'
1043else
1044    echo '  Using bundled JSON parser.'
1045fi
1046
1047echo '  Using event handler: '$events
1048echo '  Using SSL library: '$ssl
1049#echo '  Building with these storage backends: '$STORAGES
1050
1051if [ -n "$protocols" ]; then
1052        echo '  Building with these protocols:' "$protocols""$protocols_mods"
1053        case "$protocols" in
1054        *purple*)
1055                echo "    Note that BitlBee-libpurple is supported on a best-effort basis. It's"
1056                echo "    not *fully* compatible with normal BitlBee. Don't use it unless you"
1057                echo "    absolutely need it (i.e. support for a certain protocol or feature)."
1058        esac
1059else
1060        echo '  Building without IM-protocol support. We wish you a lot of fun...'
1061fi
Note: See TracBrowser for help on using the repository browser.