source: configure @ 727a68b

Last change on this file since 727a68b 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
RevLine 
[b7d3cc34]1#!/bin/sh
2
3##############################
4##  Configurer for BitlBee  ##
5##                          ##
6##  Copyright 2004 Lintux   ##
7##  Copyright 2002 Lucumo   ##
8##############################
9
10prefix='/usr/local/'
[57da960]11bindir='$prefix/bin/'
12sbindir='$prefix/sbin/'
[b7d3cc34]13etcdir='$prefix/etc/bitlbee/'
14mandir='$prefix/share/man/'
15datadir='$prefix/share/bitlbee/'
16config='/var/lib/bitlbee/'
[85cf37f]17plugindir='$prefix/lib/bitlbee/'
18includedir='$prefix/include/bitlbee/'
[417002e]19systemdsystemunitdir=''
[85cf37f]20libevent='/usr/'
[34b17d9]21pidfile='/var/run/bitlbee.pid'
[4c225f0]22ipcsocket=''
[e506d6c]23pcdir='$prefix/lib/pkgconfig'
[25b80e9c]24systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib"
[f5bbaba]25sysroot=''
[b7d3cc34]26
[2f8e3ca]27configure_args="$@"
28
[04e2a05]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
[1b221e0]39twitter=1
[04dc563]40purple=0
[b7d3cc34]41
[a85a8ab]42doc=1
[b7d3cc34]43debug=0
44strip=1
[66b9e86e]45gcov=0
[e2472dd]46asan=0
[2abfbc5]47plugins=1
[04f0c10]48otr=0
[370899f]49skype=0
[85cf37f]50
51events=glib
[b7d3cc34]52ssl=auto
53
[a6005da]54pam=0
[50bb490]55ldap=0
[a6005da]56
[7281ad1]57pie=1
58
[21f450c]59arch=$(uname -s)
60
[34afea7]61GLIB_MIN_VERSION=2.16
[670204f]62
[25c4c78]63# Cygwin and Darwin don't support PIC/PIE
64case "$arch" in
[a85a8ab]65        CYGWIN* )
66                pie=0;;
67        Darwin )
68                pie=0;;
[25c4c78]69esac
70
[70ec7ab]71get_version() {
72        REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/')
[041777e]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
[70ec7ab]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
[1d8cbc9]86                search='\(.*\)-\([0-9]*\)-\(g[0-9a-f]*\)'
[70ec7ab]87                replace="\1+$timestamp+$branch+\2-\3-git"
88
[e28c449]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
[70ec7ab]93
[c984ee3]94                BITLBEE_VERSION=$(echo $describe | sed "s#$search#$replace#")
[e28c449]95
96                unset timestamp branch search replace describe
[70ec7ab]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
[b7d3cc34]109while [ -n "$1" ]; do
[4966712a]110        e="$(expr "X$1" : 'X--\(.*=.*\)')"
[b7d3cc34]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
[57da960]120--sbindir=...                                           $sbindir
[b7d3cc34]121--etcdir=...                                            $etcdir
122--mandir=...                                            $mandir
123--datadir=...                                           $datadir
[7b23afd]124--plugindir=...                                         $plugindir
[417002e]125--systemdsystemunitdir=...                              $systemdsystemunitdir
[34b17d9]126--pidfile=...                                           $pidfile
[b7d3cc34]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
[4aa0f6b]133--twitter=0/1   Disable/enable Twitter part             $twitter
[b7d3cc34]134
[796da03]135--purple=0/1    Disable/enable libpurple support        $purple
[04f0c10]136                (automatically disables other protocol modules)
[b7d3cc34]137
[a6005da]138--pam=0/1       Disable/enable PAM authentication       $pam
[50bb490]139--ldap=0/1      Disable/enable LDAP authentication      $ldap
[a6005da]140
[a85a8ab]141--doc=0/1       Disable/enable help.txt generation      $doc
[b7d3cc34]142--debug=0/1     Disable/enable debugging                $debug
143--strip=0/1     Disable/enable binary stripping         $strip
[7281ad1]144--pie=0/1       Build position independent executable   $pie
[66b9e86e]145--gcov=0/1      Disable/enable test coverage reporting  $gcov
[e2472dd]146--asan=0/1      Disable/enable AddressSanitizer         $asan
[2abfbc5]147--plugins=0/1   Disable/enable plugins support          $plugins
[04f0c10]148--otr=0/1/auto/plugin
149                Disable/enable OTR encryption support   $otr
[17f6079]150--skype=0/1/plugin
[370899f]151                Disable/enable Skype support            $skype
[b7d3cc34]152
[85cf37f]153--events=...    Event handler (glib, libevent)          $events
[e1d3f98]154--ssl=...       SSL library to use (gnutls, nss, openssl, auto)
[b7d3cc34]155                                                        $ssl
[aec56b0]156
[7281ad1]157
[f1e7407]158--target=...    Cross compilation target                same as host
[f5bbaba]159--sysroot=...   Cross compilation sysroot               $sysroot
[b7d3cc34]160EOF
161                exit;
162        fi
163        eval "$e"
164        shift;
165done
166
167# Expand $prefix and get rid of double slashes
[4966712a]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')
[b7d3cc34]181
[17f6079]182protocols_mods=""
183
[b95b0c8]184cat <<EOF >Makefile.settings
[b7d3cc34]185## BitlBee settings, generated by configure
[2f8e3ca]186
187# ./configure $configure_args
188
[b7d3cc34]189PREFIX=$prefix
190BINDIR=$bindir
[57da960]191SBINDIR=$sbindir
[b7d3cc34]192ETCDIR=$etcdir
193MANDIR=$mandir
194DATADIR=$datadir
[7b23afd]195PLUGINDIR=$plugindir
[b7d3cc34]196CONFIG=$config
[e506d6c]197INCLUDEDIR=$includedir
198PCDIR=$pcdir
[b7d3cc34]199
[1bf9492]200TARGET=$target
[b7d3cc34]201
[25b80e9c]202INSTALL=install -p
203
[b7d3cc34]204DESTDIR=
205LFLAGS=
[7a80925]206EFLAGS=-lm
[b7d3cc34]207EOF
208
[1074806]209srcdir=$(cd $(dirname $0);pwd)
210currdir=$(pwd)
211if [ "$srcdir" != "$currdir" ]; then 
[f60079b]212        echo
213        echo "configure script run from a different directory. Will create some symlinks..."
214        if [ ! -e Makefile -o -L Makefile ]; then
[04dc563]215                COPYDIRS="doc lib protocols tests utils"
216                mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d)
[f60079b]217                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
218                dst="$PWD"
219                cd "$srcdir"
[04dc563]220                for i in $(find . -name Makefile -type f); do
[f60079b]221                        ln -s "$PWD${i#.}" "$dst/$i";
222                done
223                cd "$dst"
224                rm -rf .bzr
225        fi
226       
[7fa5c19]227        echo "_SRCDIR_=$srcdir/" >> Makefile.settings
[f60079b]228        CFLAGS="$CFLAGS -I${dst}"
229else
230        srcdir=$PWD
231fi
232
[b95b0c8]233cat<<EOF >config.h
[b7d3cc34]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
[2f8e3ca]239#define BITLBEE_CONFIGURE_ARGS "$configure_args"
240
[b7d3cc34]241#define CONFIG "$config"
242#define ETCDIR "$etcdir"
243#define VARDIR "$datadir"
[7b23afd]244#define PLUGINDIR "$plugindir"
[34b17d9]245#define PIDFILE "$pidfile"
[6dff9d4]246#define IPCSOCKET "$ipcsocket"
[b7d3cc34]247EOF
248
[1bf9492]249
250
[f1e7407]251if [ -n "$target" ]; then
[f5bbaba]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
[f1e7407]276        CC=$target-cc
277        LD=$target-ld
[f5bbaba]278        STRIP=$target-strip
[f1e7407]279fi
280
[e2472dd]281if [ "$asan" = "1" ]; then
282        CFLAGS="$CFLAGS -fsanitize=address"
283        LDFLAGS="$LDFLAGS -fsanitize=address"
284        debug=1
285fi
[1bf9492]286
[b7d3cc34]287if [ "$debug" = "1" ]; then
288        echo 'DEBUG=1' >> Makefile.settings
[e2472dd]289        CFLAGS="$CFLAGS -g3 -DDEBUG -O0"
[b7d3cc34]290else
[56f260a]291        [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing"
[b7d3cc34]292fi
293
[7281ad1]294if [ "$pie" = "1" ]; then
295        echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings
296        echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings
297fi
298
[d203495]299echo LDFLAGS=$LDFLAGS >> Makefile.settings
300
[daae10f]301echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings
[f60079b]302echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
[b7d3cc34]303
[41a94dd]304echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
[f712188]305
[b7d3cc34]306if [ -n "$CC" ]; then
[5973412]307        CC=$CC
[b7d3cc34]308elif type gcc > /dev/null 2> /dev/null; then
[5973412]309        CC=gcc
[b7d3cc34]310elif type cc > /dev/null 2> /dev/null; then
[5973412]311        CC=cc
[b7d3cc34]312else
313        echo 'Cannot find a C compiler, aborting.'
314        exit 1;
315fi
316
[5973412]317echo "CC=$CC" >> Makefile.settings;
[daae10f]318if echo $CC | grep -qw gcc; then
319        # Apparently -Wall is gcc-specific?
320        echo CFLAGS+=-Wall >> Makefile.settings
321fi
[5973412]322
[f1e7407]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
[b7d3cc34]330fi
331
[f1e7407]332echo "LD=$LD" >> Makefile.settings
333
[32c632f]334if [ -z "$PKG_CONFIG" ]; then
335        PKG_CONFIG=pkg-config
336fi
337
[9ae8f82]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
[670204f]345        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
[b95b0c8]346                cat<<EOF >>Makefile.settings
[4966712a]347EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0)
348CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0)
[b7d3cc34]349EOF
[670204f]350        else
351                echo
[4966712a]352                echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.'
[670204f]353                exit 1
354        fi
[b7d3cc34]355else
[670204f]356        echo
[574af7e]357        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
[670204f]358        exit 1
[b7d3cc34]359fi
360
[85cf37f]361if [ "$events" = "libevent" ]; then
[003553b]362        if ! [ -f "${libevent}include/event.h" ]; then
[85cf37f]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
[b95b0c8]370        cat <<EOF >>Makefile.settings
[85cf37f]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
[b7d3cc34]377else
378        echo
[85cf37f]379        echo 'ERROR: Unknown event handler specified.'
380        exit 1
[b7d3cc34]381fi
[85cf37f]382echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
[b7d3cc34]383
384detect_gnutls()
385{
[4af7b4f]386        if $PKG_CONFIG --exists gnutls; then
[b95b0c8]387                cat <<EOF >>Makefile.settings
[4966712a]388EFLAGS+=$($PKG_CONFIG --libs gnutls) $(libgcrypt-config --libs)
389CFLAGS+=$($PKG_CONFIG --cflags gnutls) $(libgcrypt-config --cflags)
[4af7b4f]390EOF
391                ssl=gnutls
[a59bd11]392                if ! $PKG_CONFIG gnutls --atleast-version=2.8; then
[5513f3e]393                        echo
394                        echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.'
395                fi
[4af7b4f]396                ret=1
397        elif libgnutls-config --version > /dev/null 2> /dev/null; then
[b95b0c8]398                cat <<EOF >>Makefile.settings
[4966712a]399EFLAGS+=$(libgnutls-config --libs) $(libgcrypt-config --libs)
400CFLAGS+=$(libgnutls-config --cflags) $(libgcrypt-config --cflags)
[b7d3cc34]401EOF
402               
403                ssl=gnutls
404                ret=1;
405        else
406                ret=0;
407        fi;
408}
409
410detect_nss()
411{
[ef043d3]412        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then
[b95b0c8]413                cat<<EOF >>Makefile.settings
[4966712a]414EFLAGS+=$($PKG_CONFIG --libs nss)
415CFLAGS+=$($PKG_CONFIG --cflags nss)
[b7d3cc34]416EOF
417               
418                ssl=nss
419                ret=1;
420        else
421                ret=0;
422        fi;
423}
424
[36cf9fd]425RESOLV_TESTCODE='
[aee8c19]426#include <sys/types.h>
427#include <netinet/in.h>
[36cf9fd]428#include <arpa/nameser.h>
429#include <resolv.h>
430
[632627e]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
[36cf9fd]445int main()
446{
447        ns_initparse( NULL, 0, NULL );
448        ns_parserr( NULL, ns_s_an, 0, NULL );
449}
450'
[632627e]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
[fb87924]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));
[632627e]465}
466'
[36cf9fd]467
468detect_resolv_dynamic()
469{
[aee8c19]470        case "$arch" in
[632627e]471        OpenBSD )
472                # In FreeBSD res_*/dn_* routines are present in libc.so
473                LIBRESOLV=;;
[aee8c19]474        FreeBSD )
[632627e]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
[aee8c19]479                LIBRESOLV=;;
480        * )
481                LIBRESOLV=-lresolv;;
482        esac
[4fca1db]483        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]484        ret=1
[aee8c19]485        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
[36cf9fd]486        if [ "$?" = "0" ]; then
[aee8c19]487                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
[8462239]488                ret=0
[36cf9fd]489        fi
490
[8462239]491        rm -f $TMPFILE
492        return $ret
[36cf9fd]493}
494
495detect_resolv_static()
496{
[4fca1db]497        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]498        ret=1
[36cf9fd]499        for i in $systemlibdirs; do
500                if [ -f $i/libresolv.a ]; then
[8462239]501                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
[36cf9fd]502                        if [ "$?" = "0" ]; then
503                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
[8462239]504                                ret=0
[36cf9fd]505                        fi
506                fi
507        done
508
[8462239]509        rm -f $TMPFILE
510        return $ret
[36cf9fd]511}
512
[632627e]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
[a67e781]525        if [ "$?" = "0" ]; then
526                ret=0
527        fi
[632627e]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
[a67e781]540                        if [ "$?" = "0" ]; then
541                                ret=0
542                        fi
[632627e]543                fi
544        done
545
546        rm -f $TMPFILE
547        return $ret
548}
549
550detect_nameser_has_ns_types()
551{
[a67e781]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
[632627e]563}
564
[b3c467b]565if [ "$ssl" = "auto" ]; then
566        detect_gnutls
[b7d3cc34]567        if [ "$ret" = "0" ]; then
[c5920df]568                # Disable NSS for now as it's known to not work very well ATM.
569                #detect_nss
[191cfb1]570                :
[b7d3cc34]571        fi
[b3c467b]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'
[b3eee9b]579        echo 'installation of OpenSSL (including devel/header files) before reporting'
[b3c467b]580        echo 'compilation problems.'
581        echo
582        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
[b3eee9b]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.'
[b3c467b]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'
[b3eee9b]592        echo 'package, you really should use GnuTLS instead.'
[b3c467b]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/)"'
[b7d3cc34]597       
[b3c467b]598        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
599       
600        ret=1
601else
602        echo
603        echo 'ERROR: Unknown SSL library specified.'
604        exit 1
[b7d3cc34]605fi
606
[b3c467b]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,'
[e1d3f98]611        echo '       so if you want to use that, you have to select it by hand.'
[b7d3cc34]612       
[b3c467b]613        exit 1
614fi;
615
616echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
617
[632627e]618if detect_nameser_has_ns_types; then
619        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
620fi
[36cf9fd]621if detect_resolv_dynamic || detect_resolv_static; then
622        echo '#define HAVE_RESOLV_A' >> config.h
[a67e781]623        if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
624                echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
625        fi
[632627e]626else
[a67e781]627        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
[36cf9fd]628fi
[36e9f62]629
[632627e]630
[ba7d16f]631STORAGES="xml"
[b3c467b]632
633for i in $STORAGES; do
634        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
635done
636echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
637
[8e6ecfe]638authobjs=
639authlibs=
[a6005da]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
[50bb490]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
[8e6ecfe]662echo AUTH_OBJS=$authobjs >> Makefile.settings
663echo EFLAGS+=$authlibs >> Makefile.settings
664
[b7d3cc34]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
[417002e]685if [ -z "$systemdsystemunitdir" ]; then
686        if $PKG_CONFIG --exists systemd; then
[4966712a]687                systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
[417002e]688        fi
689fi
690if [ -n "$systemdsystemunitdir" ]; then
691        if [ "$systemdsystemunitdir" != "no" ]; then
692                echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
693        fi
694fi
695
[66b9e86e]696if [ "$gcov" = "1" ]; then
[31fc3970]697        echo "CFLAGS+=--coverage" >> Makefile.settings
698        echo "EFLAGS+=--coverage" >> Makefile.settings
[66b9e86e]699fi
700
[2abfbc5]701if [ "$plugins" = 0 ]; then
[489847f]702        plugindir=""
[2abfbc5]703        echo '#undef WITH_PLUGINS' >> config.h
704else
705        echo '#define WITH_PLUGINS' >> config.h
706fi
707
[6738a67]708otrprefix=""
[764c7d1]709if [ "$otr" = "auto" ]; then
[a59bd11]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
[764c7d1]716fi
[a59bd11]717
[6738a67]718if [ "$otr" = 1 ]; then
[858ea01]719        # BI == built-in
720        echo '#define OTR_BI' >> config.h
[872e017]721        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
722        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
[858ea01]723        echo 'OTR_BI=otr.o' >> Makefile.settings
724elif [ "$otr" = "plugin" ]; then
[a59bd11]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.
[858ea01]727        echo '#define OTR_PI' >> config.h
[872e017]728        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
729        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
[858ea01]730        echo 'OTR_PI=otr.so' >> Makefile.settings
[764c7d1]731fi
732
[17f6079]733if [ "$skype" = "1" -o "$skype" = "plugin" ]; then
[b2b7f52]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
[370899f]739        echo 'SKYPE_PI=skype.so' >> Makefile.settings
[17f6079]740        protocols_mods="$protocol_mods skype(plugin)"
[370899f]741fi
742
[1cef55f]743if [ -z "$PYTHON" ]; then
744        PYTHON=python
745fi
746
[a85a8ab]747if [ "$doc" = "1" ]; then
[beb0f54]748        # check this here just in case someone tries to install it in python2.4...
[1cef55f]749        if ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
[a85a8ab]750                echo
[beb0f54]751                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
[1cef55f]752                echo "(Use the PYTHON environment variable if it's in a weird location)"
[beb0f54]753                exit 1
[a85a8ab]754        fi
[beb0f54]755        echo "DOC=1" >> Makefile.settings
[1cef55f]756        echo "PYTHON=$PYTHON" >> Makefile.settings
[ceebeb1]757fi
758
[70ec7ab]759get_version
[e26aa72]760
[70ec7ab]761if [ "$BITLBEE_VERSION" != "$REAL_BITLBEE_VERSION" ]; then
[b7d3cc34]762        echo 'Spoofing version number: '$BITLBEE_VERSION
763        echo '#undef BITLBEE_VERSION' >> config.h
[f287f04]764        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
[ffea9b9]765        echo
[b7d3cc34]766fi
767
[4fca1db]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
[b95b0c8]782cat <<EOF >bitlbee.pc
[e506d6c]783prefix=$prefix
784includedir=$includedir
[489847f]785plugindir=$plugindir
[e506d6c]786
787Name: bitlbee
788Description: IRC to IM gateway
789Requires: glib-2.0
790Version: $BITLBEE_VERSION
791Libs:
792Cflags: -I\${includedir}
793
794EOF
795
[b7d3cc34]796protocols=''
797protoobjs=''
798
[e248c7f]799if [ "$purple" = 0 ]; then
800        echo '#undef WITH_PURPLE' >> config.h
801else
[e08e53c]802        if ! $PKG_CONFIG purple; then
803                echo
804                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
805                exit 1
806        fi
[e248c7f]807        echo '#define WITH_PURPLE' >> config.h
[b95b0c8]808        cat<<EOF >>Makefile.settings
[e08e53c]809EFLAGS += $($PKG_CONFIG purple --libs)
810PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
811EOF
[e248c7f]812        protocols=$protocols'purple '
813        protoobjs=$protoobjs'purple_mod.o '
814
[04e2a05]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
[18e1f3b]820
821        echo '#undef PACKAGE' >> config.h
822        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
[bda2975]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!'
[c775a58]828                echo
[bda2975]829        fi
[e248c7f]830fi
831
[b0a89cc]832case "$CC" in
833*gcc* )
[e371011]834        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
[fe92921]835        for i in . lib tests protocols protocols/*/; do
[b0a89cc]836                mkdir -p $i/.depend
837        done
838esac
839
[b7d3cc34]840if [ "$msn" = 0 ]; then
841        echo '#undef WITH_MSN' >> config.h
842else
843        echo '#define WITH_MSN' >> config.h
844        protocols=$protocols'msn '
[b5a22e3]845        protoobjs=$protoobjs'msn_mod.o '
[b7d3cc34]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 '
[b5a22e3]853        protoobjs=$protoobjs'jabber_mod.o '
[b7d3cc34]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 '
[b5a22e3]861        protoobjs=$protoobjs'oscar_mod.o '
[b7d3cc34]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 '
[b5a22e3]869        protoobjs=$protoobjs'yahoo_mod.o '
[b7d3cc34]870fi
871
[1b221e0]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
[b7d3cc34]880if [ "$protocols" = "PROTOCOLS = " ]; then
[43462708]881        echo "Warning: You haven't selected any communication protocol to compile!"
[b3c467b]882        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
[b7d3cc34]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 )
[caceb06]897        echo 'STRIP=\# skip strip' >> Makefile.settings
[b7d3cc34]898;;
899IRIX )
900;;
901SunOS )
902        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
903        echo 'STRIP=\# skip strip' >> Makefile.settings
[70d7795]904        echo '#define NO_FD_PASSING' >> config.h
[b7d3cc34]905;;
[8de63c3]906AIX )
907        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
[b7d3cc34]908;;
909CYGWIN* )
910;;
[aec56b0]911Windows )
[e252d8c]912        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
[aec56b0]913;;
[b7d3cc34]914* )
[8d6c4b1]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/.'
[b7d3cc34]917;;
918esac
919
[f1e7407]920if [ -n "$target" ]; then
921        echo "Cross-compiling for: $target"
922fi
923
[b7d3cc34]924echo
925echo 'Configuration done:'
926
927if [ "$debug" = "1" ]; then
[b3c467b]928        echo '  Debugging enabled.'
[b7d3cc34]929else
[b3c467b]930        echo '  Debugging disabled.'
[b7d3cc34]931fi
932
[e2472dd]933if [ "$asan" = "1" ]; then
934        echo '  AddressSanitizer (ASAN) enabled.'
935else
936        echo '  AddressSanitizer (ASAN) disabled.'
937fi
938
[7281ad1]939if [ "$pie" = "1" ]; then
940        echo '  Building PIE executable'
941else
942        echo '  Building non-PIE executable'
943fi
944
[b7d3cc34]945if [ "$strip" = "1" ]; then
[b3c467b]946        echo '  Binary stripping enabled.'
[b7d3cc34]947else
[b3c467b]948        echo '  Binary stripping disabled.'
[b7d3cc34]949fi
950
[764c7d1]951if [ "$otr" = "1" ]; then
952        echo '  Off-the-Record (OTR) Messaging enabled.'
[858ea01]953elif [ "$otr" = "plugin" ]; then
954        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
[764c7d1]955else
956        echo '  Off-the-Record (OTR) Messaging disabled.'
957fi
958
[417002e]959if [ -n "$systemdsystemunitdir" ]; then
960        echo '  systemd enabled.'
961else
962        echo '  systemd disabled.'
963fi
964
[b3c467b]965echo '  Using event handler: '$events
966echo '  Using SSL library: '$ssl
[4e3df8a]967#echo '  Building with these storage backends: '$STORAGES
[b7d3cc34]968
969if [ -n "$protocols" ]; then
[17f6079]970        echo '  Building with these protocols:' $protocols$protocols_mods
[4e3df8a]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
[b7d3cc34]977else
[b3c467b]978        echo '  Building without IM-protocol support. We wish you a lot of fun...'
[b7d3cc34]979fi
Note: See TracBrowser for help on using the repository browser.