source: configure @ 952e264

Last change on this file since 952e264 was 08b0ed8, checked in by dx <dx@…>, at 2017-03-12T04:16:58Z

configure: respect autotools-like verbose flags for make

In other words, running $(make V=1) will force a verbose build while
$(make V=0) will force a silent build regardless of the verbose option
set by the configure script.

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