source: configure @ 8ca172f

Last change on this file since 8ca172f was 8ca172f, checked in by GitHub <noreply@…>, at 2022-12-04T17:09:00Z

Systemd Enhancements: Create user and directory automatically (#163)

  • configure: Simplify check for systemd, allow to request systemd support

Signed-off-by: Björn Bidar <bjorn.bidar@…>

  • configure: Add helper to be compatible with old and new systemd pc vars

Re:
https://github.com/systemd/systemd/commit/4908de44b0a0409f84a7cdc5641b114d6ce8ba03

Signed-off-by: Björn Bidar <bjorn.bidar@…>

  • systemd: Support systemd-sysusers.d

Signed-off-by: Björn Bidar <bjorn.bidar@…>

  • systemd: Define StateDirectory, create biltbee directory automatically

Signed-off-by: Björn Bidar <bjorn.bidar@…>

  • systemd: Also listen to /run/bitlbee/socket

Signed-off-by: Björn Bidar <bjorn.bidar@…>

  • systemd: Create RuntimeDirectory automatically

Signed-off-by: Björn Bidar <bjorn.bidar@…>

  • systemd: Also run regular systemd service as user

Signed-off-by: Björn Bidar <bjorn.bidar@…>

Signed-off-by: Björn Bidar <bjorn.bidar@…>

  • Property mode set to 100755
File size: 25.9 KB
Line 
1#!/bin/sh
2
3##############################
4##  Configurer for BitlBee  ##
5##                          ##
6##  Copyright 2004 Lintux   ##
7##  Copyright 2002 Lucumo   ##
8##############################
9
10prefix='/usr/local/'
11bindir='$prefix/bin/'
12sbindir='$prefix/sbin/'
13etcdir='$prefix/etc/bitlbee/'
14mandir='$prefix/share/man/'
15datadir='$prefix/share/bitlbee/'
16config='/var/lib/bitlbee/'
17libdir='$prefix/lib/'
18plugindir='$prefix/lib/bitlbee/'
19includedir='$prefix/include/bitlbee/'
20systemdsystemunitdir=''
21sysusersdir=''
22libevent='/usr/'
23pidfile='/var/run/bitlbee.pid'
24ipcsocket=''
25pcdir='$prefix/lib/pkgconfig'
26systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib"
27sysroot=''
28
29configure_args="$@"
30
31# Set these to default-on to let it be overriden by either the user or purple
32#
33# If the user sets one of these to 1, purple won't disable them.
34# Otherwise, if it's still default-on, it gets included in normal builds,
35# but not purple ones.
36jabber="default-on"
37
38twitter=1
39purple=0
40
41verbose=0
42doc=1
43debug=0
44strip=0
45gcov=0
46asan=0
47plugins=1
48otr=0
49
50events=glib
51external_json_parser=auto
52ssl=auto
53
54pam=0
55ldap=0
56
57pie=1
58
59systemd=auto
60
61arch=$(uname -s)
62arch_rel=$(uname -r)
63
64GLIB_MIN_VERSION=2.32
65
66# Cygwin, Darwin and SunOS < 5.11 do not support PIC/PIE
67case "$arch" in
68        CYGWIN* )
69                pie=0;;
70        Darwin )
71                pie=0;;
72        SunOS )
73                if [ "$arch_rel" = "5.10" ]; then
74                        pie=0
75                fi
76                ;;
77esac
78
79get_version() {
80        REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/')
81
82        if [ -n "$BITLBEE_VERSION" ]; then
83                # environment variable already set to something to spoof it
84                # don't replace it with the git stuff
85                return
86        fi
87
88        BITLBEE_VERSION=$REAL_BITLBEE_VERSION
89
90        if [ -d $srcdir/.git ] && type git > /dev/null 2> /dev/null; then
91                timestamp=$(cd $srcdir; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g')
92                branch=$(cd $srcdir; 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                describe=$(cd $srcdir; git describe --long --tags 2>/dev/null)
98                if [ $? -ne 0 ]; 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 support $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 -o -L Makefile ]; then
225                COPYDIRS="doc lib protocols tests utils"
226                mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d)
227                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
228                dst="$PWD"
229                cd "$srcdir"
230                for i in $(find . -name Makefile -type f); do
231                        ln -s "$PWD${i#.}" "$dst/$i";
232                done
233                cd "$dst"
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
329echo LDFLAGS=$LDFLAGS >> Makefile.settings
330
331echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings
332echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
333
334echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
335
336if [ -n "$CC" ]; then
337        CC=$CC
338elif type gcc > /dev/null 2> /dev/null; then
339        CC=gcc
340elif type cc > /dev/null 2> /dev/null; then
341        CC=cc
342else
343        echo 'Cannot find a C compiler, aborting.'
344        exit 1;
345fi
346
347echo "CC=$CC" >> Makefile.settings;
348if echo $CC | grep -qw 'gcc\|clang'; then
349        # Apparently -Wall is gcc-specific?
350        echo CFLAGS+=-Wall -Wformat -Werror=format-security >> Makefile.settings
351fi
352
353if [ -z "$LD" ]; then
354        if type ld > /dev/null 2> /dev/null; then
355                LD=ld
356        else
357                echo 'Cannot find ld, aborting.'
358                exit 1;
359        fi
360fi
361
362echo "LD=$LD" >> Makefile.settings
363
364if [ -z "$PKG_CONFIG" ]; then
365        PKG_CONFIG=pkg-config
366fi
367
368if ! $PKG_CONFIG --version > /dev/null 2>/dev/null; then
369        echo
370        echo 'Cannot find pkg-config, aborting.'
371        exit 1
372fi
373
374if $PKG_CONFIG glib-2.0; then
375        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
376                cat<<EOF >>Makefile.settings
377EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0)
378CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0)
379EOF
380        else
381                echo
382                echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.'
383                exit 1
384        fi
385else
386        echo
387        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
388        exit 1
389fi
390
391if [ "$events" = "libevent" ]; then
392        if ! [ -f "${libevent}include/event.h" ]; then
393                echo
394                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
395                echo 'its location using the --libevent= argument. (Example: If event.h is in'
396                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
397        fi
398       
399        echo '#define EVENTS_LIBEVENT' >> config.h
400        cat <<EOF >>Makefile.settings
401EFLAGS+=-levent -L${libevent}lib
402CFLAGS+=-I${libevent}include
403EOF
404elif [ "$events" = "glib" ]; then
405        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
406        echo '#define EVENTS_GLIB' >> config.h
407else
408        echo
409        echo 'ERROR: Unknown event handler specified.'
410        exit 1
411fi
412echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
413
414if [ "$external_json_parser" = "auto" ]; then
415        if pkg-config --exists json-parser; then
416                external_json_parser=1
417        else
418                external_json_parser=0
419        fi
420fi
421echo "EXTERNAL_JSON_PARSER=$external_json_parser" >> Makefile.settings
422if [ "$external_json_parser" = "1" ]; then
423    echo "CFLAGS+=$(pkg-config --cflags 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
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        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
541        if [ "$?" = "0" ]; 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                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
557                        if [ "$?" = "0" ]; then
558                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
559                                ret=0
560                        fi
561                fi
562        done
563
564        rm -f $TMPFILE
565        return $ret
566}
567
568detect_resolv_ns_dynamic()
569{
570        case "$arch" in
571        FreeBSD )
572                # In FreeBSD ns_ routines are present in libc.so
573                LIBRESOLV=;;
574        * )
575                LIBRESOLV=-lresolv;;
576        esac
577        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
578        ret=1
579        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
580        if [ "$?" = "0" ]; then
581                ret=0
582        fi
583
584        rm -f $TMPFILE
585        return $ret
586}
587
588detect_resolv_ns_static()
589{
590        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
591        ret=1
592        for i in $systemlibdirs; do
593                if [ -f $i/libresolv.a ]; then
594                        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
595                        if [ "$?" = "0" ]; then
596                                ret=0
597                        fi
598                fi
599        done
600
601        rm -f $TMPFILE
602        return $ret
603}
604
605detect_nameser_has_ns_types()
606{
607        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
608        ret=1
609        # since we aren't actually linking with ns_* routines
610        # we can just compile the test code
611        echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
612        if [ "$?" = "0" ]; then
613                ret=0
614        fi
615
616        rm -f $TMPFILE
617        return $ret
618}
619
620detect_backtrace()
621{
622        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
623        ret=1
624        echo "$BACKTRACE_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
625        if [ "$?" = "0" ]; then
626                ret=0
627        fi
628
629        rm -f $TMPFILE
630        return $ret
631}
632
633if [ "$ssl" = "auto" ]; then
634        detect_gnutls
635        if [ "$ret" = "0" ]; then
636                # Disable NSS for now as it's known to not work very well ATM.
637                #detect_nss
638                :
639        fi
640elif [ "$ssl" = "gnutls" ]; then
641        detect_gnutls
642elif [ "$ssl" = "nss" ]; then
643        detect_nss
644elif [ "$ssl" = "openssl" ]; then
645        echo
646        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
647        echo 'installation of OpenSSL (including devel/header files) before reporting'
648        echo 'compilation problems.'
649        echo
650        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
651        echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported'
652        echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the'
653        echo 'operating system, which makes it GPL-compatible.'
654        echo
655        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
656        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
657        echo
658        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
659        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
660        echo 'package, you really should use GnuTLS instead.'
661        echo
662        echo 'Also, the OpenSSL license requires us to say this:'
663        echo ' *    "This product includes software developed by the OpenSSL Project'
664        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
665       
666        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
667       
668        ret=1
669else
670        echo
671        echo 'ERROR: Unknown SSL library specified.'
672        exit 1
673fi
674
675if [ "$ret" = "0" ]; then
676        echo
677        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
678        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
679        echo '       so if you want to use that, you have to select it by hand.'
680       
681        exit 1
682fi;
683
684echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
685
686if detect_nameser_has_ns_types; then
687        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
688fi
689if detect_resolv_dynamic || detect_resolv_static; then
690        echo '#define HAVE_RESOLV_A' >> config.h
691        if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
692                echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
693        fi
694else
695        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
696fi
697
698if detect_backtrace; then
699        echo '#define HAVE_BACKTRACE' >> config.h
700        echo '#define CRASHFILE "'$config'crash.log"' >> config.h
701fi
702
703STORAGES="xml"
704
705for i in $STORAGES; do
706        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
707done
708echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
709
710authobjs=
711authlibs=
712if [ "$pam" = 0 ]; then
713        echo '#undef WITH_PAM' >> config.h
714else
715        if ! echo '#include <security/pam_appl.h>' | $CC -E - >/dev/null 2>/dev/null; then
716                echo 'Cannot find libpam development libraries, aborting. (Install libpam0g-dev?)'
717                exit 1
718        fi
719        echo '#define WITH_PAM' >> config.h
720        authobjs=$authobjs'auth_pam.o '
721        authlibs=$authlibs'-lpam '
722fi
723if [ "$ldap" = 0 ]; then
724        echo '#undef WITH_LDAP' >> config.h
725else
726        if ! echo '#include <ldap.h>' | $CC -E - >/dev/null 2>/dev/null; then
727                echo 'Cannot find libldap development libraries, aborting. (Install libldap2-dev?)'
728                exit 1
729        fi
730        echo '#define WITH_LDAP' >> config.h
731        authobjs=$authobjs'auth_ldap.o '
732        authlibs=$authlibs'-lldap '
733fi
734echo AUTH_OBJS=$authobjs >> Makefile.settings
735echo EFLAGS+=$authlibs >> Makefile.settings
736
737if [ "$strip" = 0 ]; then
738        echo "STRIP=\# skip strip" >> Makefile.settings;
739else
740        if [ "$debug" = 1 ]; then
741                echo
742                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
743                echo 'STRIP=\# skip strip' >> Makefile.settings
744                strip=0;
745        elif [ -n "$STRIP" ]; then
746                echo "STRIP=$STRIP" >> Makefile.settings;
747        elif type strip > /dev/null 2> /dev/null; then
748                echo "STRIP=strip" >> Makefile.settings;
749        else
750                echo
751                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
752                echo 'STRIP=\# skip strip' >> Makefile.settings
753                strip=0;
754        fi;
755fi
756
757if [ ! "$systemd" = 0 ]; then
758    if ! $PKG_CONFIG --exists systemd ; then
759        if [ -n "$systemdsystemunitdir" ] || [ "$systemd" -eq 1 ]; then
760            echo "systemd requested but not found"
761            exit 1
762        else
763            systemd=0
764        fi
765    fi
766fi
767
768pkgconf_systemd_var() {
769    # First try deprecated variable, use newer variable if not found
770    if $PKG_CONFIG --print-variables systemd | grep -q $1 ; then
771        $PKG_CONFIG --variable=$1 systemd
772    else
773        $PKG_CONFIG --variable=$2 systemd
774    fi
775}
776
777if [ "$systemd" -eq 1 ]; then
778        if [ -z "$systemdsystemunitdir" ]; then
779                systemdsystemunitdir=$(pkgconf_systemd_var systemdsystemunitdir systemd_system_unit_dir)
780        fi
781    if [ -z "$tmpfiles_dir" ] ; then
782        tmpfilesdir=$(pkgconf_systemd_var tmpfilesdir tmpfiles_dir)
783    fi
784    if [ -z "$sysusersdir" ] ; then
785        sysusersdir=$(pkgconf_systemd_var sysusersdir sysusers_dir)
786    fi
787
788        echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
789    echo "SYSUSERSDIR=$sysusersdir" >> Makefile.settings
790fi
791
792if [ "$gcov" = "1" ]; then
793        echo "CFLAGS+=--coverage" >> Makefile.settings
794        echo "EFLAGS+=--coverage" >> Makefile.settings
795fi
796
797if [ "$plugins" = 0 ]; then
798        plugindir=""
799        echo '#undef WITH_PLUGINS' >> config.h
800else
801        echo '#define WITH_PLUGINS' >> config.h
802fi
803
804otrprefix=""
805if [ "$otr" = "auto" ]; then
806        ! $PKG_CONFIG --exists libotr
807        otr=$?
808fi
809
810if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
811        exit 1
812fi
813
814if [ "$otr" = 1 ]; then
815        # BI == built-in
816        echo '#define OTR_BI' >> config.h
817        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
818        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
819        echo 'OTR_BI=otr.o' >> Makefile.settings
820elif [ "$otr" = "plugin" ]; then
821        # for some mysterious reason beyond the comprehension of my mortal mind,
822        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
823        echo '#define OTR_PI' >> config.h
824        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
825        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
826        echo 'OTR_PI=otr.so' >> Makefile.settings
827fi
828
829if [ -z "$PYTHON" ]; then
830        for pp in python python3 python2; do
831                if which $pp > /dev/null; then
832                        PYTHON=$pp
833                        break
834                fi
835        done
836fi
837
838if [ "$doc" = "1" ]; then
839        # check this here just in case someone tries to install it in python2.4...
840        if [ ! -e $srcdir/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
841                echo
842                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
843                echo "(Use the PYTHON environment variable if it's in a weird location)"
844                exit 1
845        fi
846        echo "DOC=1" >> Makefile.settings
847        echo "PYTHON=$PYTHON" >> Makefile.settings
848fi
849
850get_version
851
852if [ "$BITLBEE_VERSION" != "$REAL_BITLBEE_VERSION" ]; then
853        echo 'Spoofing version number: '$BITLBEE_VERSION
854        echo '#undef BITLBEE_VERSION' >> config.h
855        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
856        echo
857fi
858
859if ! make helloworld > /dev/null 2>&1; then
860        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
861        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
862        echo "under the name 'gmake'."
863        echo
864        if gmake helloworld > /dev/null 2>&1; then
865                echo "gmake seems to be available on your machine, great."
866                echo
867        else
868                echo "gmake is not installed (or not working). Please try to install it."
869                echo
870        fi
871fi
872
873pkgconfiglibs=''
874case "$arch" in
875CYGWIN* )
876        pkgconfiglibs='-L${libdir} -lbitlbee -no-undefined'
877esac
878
879cat <<EOF >bitlbee.pc
880prefix=$prefix
881includedir=$includedir
882plugindir=$plugindir
883libdir=$libdir
884datadir=$datadir
885
886Name: bitlbee
887Description: IRC to IM gateway
888Requires: glib-2.0
889Version: $BITLBEE_VERSION
890Libs: $pkgconfiglibs
891Cflags: -I\${includedir}
892
893EOF
894
895protocols=''
896protoobjs=''
897
898if [ "$purple" = 0 ]; then
899        echo '#undef WITH_PURPLE' >> config.h
900else
901        if ! $PKG_CONFIG purple; then
902                echo
903                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
904                exit 1
905        fi
906        echo '#define WITH_PURPLE' >> config.h
907        cat<<EOF >>Makefile.settings
908EFLAGS += $($PKG_CONFIG purple --libs)
909PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
910EOF
911        protocols=$protocols'purple '
912        protoobjs=$protoobjs'purple_mod.o '
913
914        # only disable these if the user didn't enable them explicitly
915        [ "$jabber" = "default-on" ] && jabber=0
916
917        echo '#undef PACKAGE' >> config.h
918        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
919       
920        if [ "$events" = "libevent" ]; then
921                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
922                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
923                echo 'libpurple + libevent is *not* recommended!'
924                echo
925        fi
926fi
927
928case "$CC" in
929*gcc* )
930        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
931        for i in . lib tests protocols protocols/*/; do
932                mkdir -p $i/.depend
933        done
934esac
935
936if [ "$jabber" = 0 ]; then
937        echo '#undef WITH_JABBER' >> config.h
938else
939        echo '#define WITH_JABBER' >> config.h
940        protocols=$protocols'jabber '
941        protoobjs=$protoobjs'jabber_mod.o '
942fi
943
944if [ "$twitter" = 0 ]; then
945        echo '#undef WITH_TWITTER' >> config.h
946else
947        echo '#define WITH_TWITTER' >> config.h
948        protocols=$protocols'twitter '
949        protoobjs=$protoobjs'twitter_mod.o '
950fi
951
952if [ "$protocols" = "PROTOCOLS = " ]; then
953        echo "Warning: You haven't selected any communication protocol to compile!"
954        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
955fi
956
957echo "PROTOCOLS = $protocols" >> Makefile.settings
958echo "PROTOOBJS = $protoobjs" >> Makefile.settings
959
960echo Architecture: $arch
961case "$arch" in
962Linux )
963;;
964GNU/* )
965;;
966*BSD )
967;;
968Darwin )
969        echo 'STRIP=\# skip strip' >> Makefile.settings
970;;
971IRIX )
972;;
973SunOS )
974        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
975        echo 'STRIP=\# skip strip' >> Makefile.settings
976        echo '#define NO_FD_PASSING' >> config.h
977        if [ "$arch_rel" = "5.10" ]; then
978                echo '#define NO_STRCASESTR' >> config.h
979        fi
980;;
981AIX )
982        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
983;;
984CYGWIN* )
985        echo 'EFLAGS+=-Wl,--export-all,--out-implib,libbitlbee.dll.a' >> Makefile.settings
986        echo 'IMPLIB=libbitlbee.dll.a' >> Makefile.settings
987;;
988Windows )
989        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
990;;
991* )
992        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
993        echo 'Please report any problems at http://bugs.bitlbee.org/.'
994;;
995esac
996
997if [ -n "$target" ]; then
998        echo "Cross-compiling for: $target"
999fi
1000
1001echo
1002echo 'Configuration done:'
1003
1004if [ "$debug" = "1" ]; then
1005        echo '  Debugging enabled.'
1006else
1007        echo '  Debugging disabled.'
1008fi
1009
1010if [ "$asan" = "1" ]; then
1011        echo '  AddressSanitizer (ASAN) enabled.'
1012else
1013        echo '  AddressSanitizer (ASAN) disabled.'
1014fi
1015
1016if [ "$pie" = "1" ]; then
1017        echo '  Building PIE executable'
1018else
1019        echo '  Building non-PIE executable'
1020fi
1021
1022if [ "$strip" = "1" ]; then
1023        echo '  Binary stripping enabled.'
1024else
1025        echo '  Binary stripping disabled.'
1026fi
1027
1028if [ "$otr" = "1" ]; then
1029        echo '  Off-the-Record (OTR) Messaging enabled.'
1030elif [ "$otr" = "plugin" ]; then
1031        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
1032else
1033        echo '  Off-the-Record (OTR) Messaging disabled.'
1034fi
1035
1036if [ "$systemd" -eq 1 ]; then
1037        echo '  systemd enabled.'
1038else
1039        echo '  systemd disabled.'
1040fi
1041
1042echo '  Using python: '$PYTHON
1043
1044if [ "$external_json_parser" = "1" ]; then
1045    echo '  Using system JSON parser.'
1046else
1047    echo '  Using bundled JSON parser.'
1048fi
1049
1050echo '  Using event handler: '$events
1051echo '  Using SSL library: '$ssl
1052#echo '  Building with these storage backends: '$STORAGES
1053
1054if [ -n "$protocols" ]; then
1055        echo '  Building with these protocols:' $protocols$protocols_mods
1056        case "$protocols" in
1057        *purple*)
1058                echo "    Note that BitlBee-libpurple is supported on a best-effort basis. It's"
1059                echo "    not *fully* compatible with normal BitlBee. Don't use it unless you"
1060                echo "    absolutely need it (i.e. support for a certain protocol or feature)."
1061        esac
1062else
1063        echo '  Building without IM-protocol support. We wish you a lot of fun...'
1064fi
Note: See TracBrowser for help on using the repository browser.