source: configure @ af6b7fa

Last change on this file since af6b7fa was 4d51c84, checked in by dequis <dx@…>, at 2017-07-09T03:10:53Z

configure: Don't require python if docs are already built

  • Property mode set to 100755
File size: 24.4 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 PIDFILE "$pidfile"
250#define IPCSOCKET "$ipcsocket"
251EOF
252
253
254
255if [ -n "$target" ]; then
256        # prepend sysroot to system lib dirs
257
258        systemlibdirs_cross=''
259        for i in $systemlibdirs; do
260                systemlibdirs_cross="$systemlibdirs_cross $sysroot$i"
261        done
262        systemlibdirs=$systemlibdirs_cross
263        unset systemlibdirs_cross
264
265        # backward compatibility
266
267        if [ -z "$PKG_CONFIG_LIBDIR" ]; then
268                PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
269                export PKG_CONFIG_LIBDIR
270        fi
271
272        if [ -d /usr/$target/bin ]; then
273                PATH=/usr/$target/bin:$PATH
274        fi
275
276        if [ -d /usr/$target/lib ]; then
277                systemlibdirs="$systemlibdirs /usr/$target/lib"
278        fi
279
280        CC=$target-cc
281        LD=$target-ld
282        STRIP=$target-strip
283fi
284
285if [ "$asan" = "1" ]; then
286        CFLAGS="$CFLAGS -fsanitize=address"
287        LDFLAGS="$LDFLAGS -fsanitize=address"
288        debug=1
289fi
290
291if [ "$verbose" = "0" ]; then
292        echo 'VERBOSE=@' >> Makefile.settings
293else
294        echo 'VERBOSE=' >> Makefile.settings
295fi
296
297cat <<EOF >>Makefile.settings
298
299# Enable/disable output verbosity
300ifdef V
301ifeq (\$(V),1)
302        VERBOSE=
303else
304        VERBOSE=@
305endif
306endif
307
308EOF
309
310if [ "$debug" = "1" ]; then
311        echo 'DEBUG=1' >> Makefile.settings
312        CFLAGS="$CFLAGS -g3 -DDEBUG -O0"
313else
314        [ -z "$CFLAGS" ] && CFLAGS="-g -O2 -fno-strict-aliasing"
315fi
316
317if [ "$pie" = "1" ]; then
318        echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings
319        echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings
320fi
321
322echo LDFLAGS=$LDFLAGS >> Makefile.settings
323
324echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings
325echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
326
327echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
328
329if [ -n "$CC" ]; then
330        CC=$CC
331elif type gcc > /dev/null 2> /dev/null; then
332        CC=gcc
333elif type cc > /dev/null 2> /dev/null; then
334        CC=cc
335else
336        echo 'Cannot find a C compiler, aborting.'
337        exit 1;
338fi
339
340echo "CC=$CC" >> Makefile.settings;
341if echo $CC | grep -qw gcc; then
342        # Apparently -Wall is gcc-specific?
343        echo CFLAGS+=-Wall >> Makefile.settings
344fi
345
346if [ -z "$LD" ]; then
347        if type ld > /dev/null 2> /dev/null; then
348                LD=ld
349        else
350                echo 'Cannot find ld, aborting.'
351                exit 1;
352        fi
353fi
354
355echo "LD=$LD" >> Makefile.settings
356
357if [ -z "$PKG_CONFIG" ]; then
358        PKG_CONFIG=pkg-config
359fi
360
361if ! $PKG_CONFIG --version > /dev/null 2>/dev/null; then
362        echo
363        echo 'Cannot find pkg-config, aborting.'
364        exit 1
365fi
366
367if $PKG_CONFIG glib-2.0; then
368        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
369                cat<<EOF >>Makefile.settings
370EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0)
371CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0)
372EOF
373        else
374                echo
375                echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.'
376                exit 1
377        fi
378else
379        echo
380        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
381        exit 1
382fi
383
384if [ "$events" = "libevent" ]; then
385        if ! [ -f "${libevent}include/event.h" ]; then
386                echo
387                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
388                echo 'its location using the --libevent= argument. (Example: If event.h is in'
389                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
390        fi
391       
392        echo '#define EVENTS_LIBEVENT' >> config.h
393        cat <<EOF >>Makefile.settings
394EFLAGS+=-levent -L${libevent}lib
395CFLAGS+=-I${libevent}include
396EOF
397elif [ "$events" = "glib" ]; then
398        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
399        echo '#define EVENTS_GLIB' >> config.h
400else
401        echo
402        echo 'ERROR: Unknown event handler specified.'
403        exit 1
404fi
405echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
406
407detect_gnutls()
408{
409        if $PKG_CONFIG --exists gnutls; then
410                cat <<EOF >>Makefile.settings
411EFLAGS+=$($PKG_CONFIG --libs gnutls) $(libgcrypt-config --libs)
412CFLAGS+=$($PKG_CONFIG --cflags gnutls) $(libgcrypt-config --cflags)
413EOF
414                ssl=gnutls
415                if ! $PKG_CONFIG gnutls --atleast-version=2.8; then
416                        echo
417                        echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.'
418                fi
419                ret=1
420        elif libgnutls-config --version > /dev/null 2> /dev/null; then
421                cat <<EOF >>Makefile.settings
422EFLAGS+=$(libgnutls-config --libs) $(libgcrypt-config --libs)
423CFLAGS+=$(libgnutls-config --cflags) $(libgcrypt-config --cflags)
424EOF
425               
426                ssl=gnutls
427                ret=1;
428        else
429                ret=0;
430        fi;
431}
432
433detect_nss()
434{
435        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then
436                cat<<EOF >>Makefile.settings
437EFLAGS+=$($PKG_CONFIG --libs nss)
438CFLAGS+=$($PKG_CONFIG --cflags nss)
439EOF
440               
441                ssl=nss
442                ret=1;
443        else
444                ret=0;
445        fi;
446}
447
448RESOLV_TESTCODE='
449#include <sys/types.h>
450#include <netinet/in.h>
451#include <arpa/nameser.h>
452#include <resolv.h>
453
454int main()
455{
456
457        res_query( NULL, 0, 0, NULL, 0);
458        dn_expand( NULL, NULL, NULL, NULL, 0);
459        dn_skipname( NULL, NULL);
460}
461'
462RESOLV_NS_TESTCODE='
463#include <sys/types.h>
464#include <netinet/in.h>
465#include <arpa/nameser.h>
466#include <resolv.h>
467
468int main()
469{
470        ns_initparse( NULL, 0, NULL );
471        ns_parserr( NULL, ns_s_an, 0, NULL );
472}
473'
474RESOLV_NS_TYPES_TESTCODE='
475#include <sys/types.h>
476#include <netinet/in.h>
477#include <arpa/nameser.h>
478
479int main()
480{
481        ns_msg nsh;
482        ns_rr rr;
483
484        /* Not all platforms we want to work on have
485         ns_* routines, so use this to make sure
486         the compiler uses it.*/
487        return (int)(sizeof(nsh) + sizeof(rr));
488}
489'
490
491detect_resolv_dynamic()
492{
493        case "$arch" in
494        OpenBSD )
495                # In FreeBSD res_*/dn_* routines are present in libc.so
496                LIBRESOLV=;;
497        FreeBSD )
498                # In FreeBSD res_*/dn_* routines are present in libc.so
499                LIBRESOLV=;;
500        CYGWIN* )
501                # In Cygwin res_*/dn_* routines are present in libc.so
502                LIBRESOLV=;;
503        * )
504                LIBRESOLV=-lresolv;;
505        esac
506        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
507        ret=1
508        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
509        if [ "$?" = "0" ]; then
510                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
511                ret=0
512        fi
513
514        rm -f $TMPFILE
515        return $ret
516}
517
518detect_resolv_static()
519{
520        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
521        ret=1
522        for i in $systemlibdirs; do
523                if [ -f $i/libresolv.a ]; then
524                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
525                        if [ "$?" = "0" ]; then
526                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
527                                ret=0
528                        fi
529                fi
530        done
531
532        rm -f $TMPFILE
533        return $ret
534}
535
536detect_resolv_ns_dynamic()
537{
538        case "$arch" in
539        FreeBSD )
540                # In FreeBSD ns_ routines are present in libc.so
541                LIBRESOLV=;;
542        * )
543                LIBRESOLV=-lresolv;;
544        esac
545        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
546        ret=1
547        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
548        if [ "$?" = "0" ]; then
549                ret=0
550        fi
551
552        rm -f $TMPFILE
553        return $ret
554}
555
556detect_resolv_ns_static()
557{
558        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
559        ret=1
560        for i in $systemlibdirs; do
561                if [ -f $i/libresolv.a ]; then
562                        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
563                        if [ "$?" = "0" ]; then
564                                ret=0
565                        fi
566                fi
567        done
568
569        rm -f $TMPFILE
570        return $ret
571}
572
573detect_nameser_has_ns_types()
574{
575        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
576        ret=1
577        # since we aren't actually linking with ns_* routines
578        # we can just compile the test code
579        echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
580        if [ "$?" = "0" ]; then
581                ret=0
582        fi
583
584        rm -f $TMPFILE
585        return $ret
586}
587
588if [ "$ssl" = "auto" ]; then
589        detect_gnutls
590        if [ "$ret" = "0" ]; then
591                # Disable NSS for now as it's known to not work very well ATM.
592                #detect_nss
593                :
594        fi
595elif [ "$ssl" = "gnutls" ]; then
596        detect_gnutls
597elif [ "$ssl" = "nss" ]; then
598        detect_nss
599elif [ "$ssl" = "openssl" ]; then
600        echo
601        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
602        echo 'installation of OpenSSL (including devel/header files) before reporting'
603        echo 'compilation problems.'
604        echo
605        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
606        echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported'
607        echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the'
608        echo 'operating system, which makes it GPL-compatible.'
609        echo
610        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
611        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
612        echo
613        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
614        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
615        echo 'package, you really should use GnuTLS instead.'
616        echo
617        echo 'Also, the OpenSSL license requires us to say this:'
618        echo ' *    "This product includes software developed by the OpenSSL Project'
619        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
620       
621        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
622       
623        ret=1
624else
625        echo
626        echo 'ERROR: Unknown SSL library specified.'
627        exit 1
628fi
629
630if [ "$ret" = "0" ]; then
631        echo
632        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
633        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
634        echo '       so if you want to use that, you have to select it by hand.'
635       
636        exit 1
637fi;
638
639echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
640
641if detect_nameser_has_ns_types; then
642        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
643fi
644if detect_resolv_dynamic || detect_resolv_static; then
645        echo '#define HAVE_RESOLV_A' >> config.h
646        if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
647                echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
648        fi
649else
650        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
651fi
652
653
654STORAGES="xml"
655
656for i in $STORAGES; do
657        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
658done
659echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
660
661authobjs=
662authlibs=
663if [ "$pam" = 0 ]; then
664        echo '#undef WITH_PAM' >> config.h
665else
666        if ! echo '#include <security/pam_appl.h>' | $CC -E - >/dev/null 2>/dev/null; then
667                echo 'Cannot find libpam development libraries, aborting. (Install libpam0g-dev?)'
668                exit 1
669        fi
670        echo '#define WITH_PAM' >> config.h
671        authobjs=$authobjs'auth_pam.o '
672        authlibs=$authlibs'-lpam '
673fi
674if [ "$ldap" = 0 ]; then
675        echo '#undef WITH_LDAP' >> config.h
676else
677        if ! echo '#include <ldap.h>' | $CC -E - >/dev/null 2>/dev/null; then
678                echo 'Cannot find libldap development libraries, aborting. (Install libldap2-dev?)'
679                exit 1
680        fi
681        echo '#define WITH_LDAP' >> config.h
682        authobjs=$authobjs'auth_ldap.o '
683        authlibs=$authlibs'-lldap '
684fi
685echo AUTH_OBJS=$authobjs >> Makefile.settings
686echo EFLAGS+=$authlibs >> Makefile.settings
687
688if [ "$strip" = 0 ]; then
689        echo "STRIP=\# skip strip" >> Makefile.settings;
690else
691        if [ "$debug" = 1 ]; then
692                echo
693                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
694                echo 'STRIP=\# skip strip' >> Makefile.settings
695                strip=0;
696        elif [ -n "$STRIP" ]; then
697                echo "STRIP=$STRIP" >> Makefile.settings;
698        elif type strip > /dev/null 2> /dev/null; then
699                echo "STRIP=strip" >> Makefile.settings;
700        else
701                echo
702                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
703                echo 'STRIP=\# skip strip' >> Makefile.settings
704                strip=0;
705        fi;
706fi
707
708if [ -z "$systemdsystemunitdir" ]; then
709        if $PKG_CONFIG --exists systemd; then
710                systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
711        fi
712fi
713if [ -n "$systemdsystemunitdir" ]; then
714        if [ "$systemdsystemunitdir" != "no" ]; then
715                echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
716        fi
717fi
718
719if [ "$gcov" = "1" ]; then
720        echo "CFLAGS+=--coverage" >> Makefile.settings
721        echo "EFLAGS+=--coverage" >> Makefile.settings
722fi
723
724if [ "$plugins" = 0 ]; then
725        plugindir=""
726        echo '#undef WITH_PLUGINS' >> config.h
727else
728        echo '#define WITH_PLUGINS' >> config.h
729fi
730
731otrprefix=""
732if [ "$otr" = "auto" ]; then
733        ! $PKG_CONFIG --exists libotr
734        otr=$?
735fi
736
737if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
738        exit 1
739fi
740
741if [ "$otr" = 1 ]; then
742        # BI == built-in
743        echo '#define OTR_BI' >> config.h
744        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
745        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
746        echo 'OTR_BI=otr.o' >> Makefile.settings
747elif [ "$otr" = "plugin" ]; then
748        # for some mysterious reason beyond the comprehension of my mortal mind,
749        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
750        echo '#define OTR_PI' >> config.h
751        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
752        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
753        echo 'OTR_PI=otr.so' >> Makefile.settings
754fi
755
756if [ "$skype" = "1" -o "$skype" = "plugin" ]; then
757        if [ "$arch" = "Darwin" ]; then
758                echo "SKYPEFLAGS=-dynamiclib -undefined dynamic_lookup" >> Makefile.settings
759        else
760                echo "SKYPEFLAGS=-fPIC -shared" >> Makefile.settings
761        fi
762        echo 'SKYPE_PI=skype.so' >> Makefile.settings
763        protocols_mods="$protocol_mods skype(plugin)"
764fi
765
766if [ -z "$PYTHON" ]; then
767        PYTHON=python
768fi
769
770if [ "$doc" = "1" ]; then
771        # check this here just in case someone tries to install it in python2.4...
772        if [ ! -e $srcdir/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
773                echo
774                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
775                echo "(Use the PYTHON environment variable if it's in a weird location)"
776                exit 1
777        fi
778        echo "DOC=1" >> Makefile.settings
779        echo "PYTHON=$PYTHON" >> Makefile.settings
780fi
781
782get_version
783
784if [ "$BITLBEE_VERSION" != "$REAL_BITLBEE_VERSION" ]; then
785        echo 'Spoofing version number: '$BITLBEE_VERSION
786        echo '#undef BITLBEE_VERSION' >> config.h
787        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
788        echo
789fi
790
791if ! make helloworld > /dev/null 2>&1; then
792        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
793        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
794        echo "under the name 'gmake'."
795        echo
796        if gmake helloworld > /dev/null 2>&1; then
797                echo "gmake seems to be available on your machine, great."
798                echo
799        else
800                echo "gmake is not installed (or not working). Please try to install it."
801                echo
802        fi
803fi
804
805pkgconfiglibs=''
806case "$arch" in
807CYGWIN* )
808        pkgconfiglibs='-L${libdir} -lbitlbee -no-undefined'
809esac
810
811cat <<EOF >bitlbee.pc
812prefix=$prefix
813includedir=$includedir
814plugindir=$plugindir
815libdir=$libdir
816
817Name: bitlbee
818Description: IRC to IM gateway
819Requires: glib-2.0
820Version: $BITLBEE_VERSION
821Libs: $pkgconfiglibs
822Cflags: -I\${includedir}
823
824EOF
825
826protocols=''
827protoobjs=''
828
829if [ "$purple" = 0 ]; then
830        echo '#undef WITH_PURPLE' >> config.h
831else
832        if ! $PKG_CONFIG purple; then
833                echo
834                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
835                exit 1
836        fi
837        echo '#define WITH_PURPLE' >> config.h
838        cat<<EOF >>Makefile.settings
839EFLAGS += $($PKG_CONFIG purple --libs)
840PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
841EOF
842        protocols=$protocols'purple '
843        protoobjs=$protoobjs'purple_mod.o '
844
845        # only disable these if the user didn't enable them explicitly
846        [ "$msn" = "default-on" ] && msn=0
847        [ "$jabber" = "default-on" ] && jabber=0
848        [ "$oscar" = "default-on" ] && oscar=0
849
850        echo '#undef PACKAGE' >> config.h
851        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
852       
853        if [ "$events" = "libevent" ]; then
854                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
855                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
856                echo 'libpurple + libevent is *not* recommended!'
857                echo
858        fi
859fi
860
861case "$CC" in
862*gcc* )
863        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
864        for i in . lib tests protocols protocols/*/; do
865                mkdir -p $i/.depend
866        done
867esac
868
869if [ "$msn" = 0 ]; then
870        echo '#undef WITH_MSN' >> config.h
871else
872        echo '#define WITH_MSN' >> config.h
873        protocols=$protocols'msn '
874        protoobjs=$protoobjs'msn_mod.o '
875fi
876
877if [ "$jabber" = 0 ]; then
878        echo '#undef WITH_JABBER' >> config.h
879else
880        echo '#define WITH_JABBER' >> config.h
881        protocols=$protocols'jabber '
882        protoobjs=$protoobjs'jabber_mod.o '
883fi
884
885if [ "$oscar" = 0 ]; then
886        echo '#undef WITH_OSCAR' >> config.h
887else
888        echo '#define WITH_OSCAR' >> config.h
889        protocols=$protocols'oscar '
890        protoobjs=$protoobjs'oscar_mod.o '
891fi
892
893if [ "$twitter" = 0 ]; then
894        echo '#undef WITH_TWITTER' >> config.h
895else
896        echo '#define WITH_TWITTER' >> config.h
897        protocols=$protocols'twitter '
898        protoobjs=$protoobjs'twitter_mod.o '
899fi
900
901if [ "$protocols" = "PROTOCOLS = " ]; then
902        echo "Warning: You haven't selected any communication protocol to compile!"
903        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
904fi
905
906echo "PROTOCOLS = $protocols" >> Makefile.settings
907echo "PROTOOBJS = $protoobjs" >> Makefile.settings
908
909echo Architecture: $arch
910case "$arch" in
911Linux )
912;;
913GNU/* )
914;;
915*BSD )
916;;
917Darwin )
918        echo 'STRIP=\# skip strip' >> Makefile.settings
919;;
920IRIX )
921;;
922SunOS )
923        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
924        echo 'STRIP=\# skip strip' >> Makefile.settings
925        echo '#define NO_FD_PASSING' >> config.h
926;;
927AIX )
928        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
929;;
930CYGWIN* )
931        echo 'EFLAGS+=-Wl,--export-all,--out-implib,libbitlbee.dll.a' >> Makefile.settings
932        echo 'IMPLIB=libbitlbee.dll.a' >> Makefile.settings
933;;
934Windows )
935        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
936;;
937* )
938        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
939        echo 'Please report any problems at http://bugs.bitlbee.org/.'
940;;
941esac
942
943if [ -n "$target" ]; then
944        echo "Cross-compiling for: $target"
945fi
946
947echo
948echo 'Configuration done:'
949
950if [ "$debug" = "1" ]; then
951        echo '  Debugging enabled.'
952else
953        echo '  Debugging disabled.'
954fi
955
956if [ "$asan" = "1" ]; then
957        echo '  AddressSanitizer (ASAN) enabled.'
958else
959        echo '  AddressSanitizer (ASAN) disabled.'
960fi
961
962if [ "$pie" = "1" ]; then
963        echo '  Building PIE executable'
964else
965        echo '  Building non-PIE executable'
966fi
967
968if [ "$strip" = "1" ]; then
969        echo '  Binary stripping enabled.'
970else
971        echo '  Binary stripping disabled.'
972fi
973
974if [ "$otr" = "1" ]; then
975        echo '  Off-the-Record (OTR) Messaging enabled.'
976elif [ "$otr" = "plugin" ]; then
977        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
978else
979        echo '  Off-the-Record (OTR) Messaging disabled.'
980fi
981
982if [ -n "$systemdsystemunitdir" ]; then
983        echo '  systemd enabled.'
984else
985        echo '  systemd disabled.'
986fi
987
988echo '  Using event handler: '$events
989echo '  Using SSL library: '$ssl
990#echo '  Building with these storage backends: '$STORAGES
991
992if [ -n "$protocols" ]; then
993        echo '  Building with these protocols:' $protocols$protocols_mods
994        case "$protocols" in
995        *purple*)
996                echo "    Note that BitlBee-libpurple is supported on a best-effort basis. It's"
997                echo "    not *fully* compatible with normal BitlBee. Don't use it unless you"
998                echo "    absolutely need it (i.e. support for a certain protocol or feature)."
999        esac
1000else
1001        echo '  Building without IM-protocol support. We wish you a lot of fun...'
1002fi
Note: See TracBrowser for help on using the repository browser.