source: configure @ a1c92dd

Last change on this file since a1c92dd was ad66dcd, checked in by Artem Savkov <artem.savkov@…>, at 2017-08-31T20:13:34Z

Add datadir to pkgconfig file and config.h

Export datadir through pkgconfig and config.h for later use by plugins.

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