source: configure @ 701ab812

Last change on this file since 701ab812 was 9ae8f82, checked in by dequis <dx@…>, at 2016-07-25T23:42:31Z

configure: improve error message on missing pkg-config

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