source: configure @ 2e99039

Last change on this file since 2e99039 was 872e017, checked in by dequis <dx@…>, at 2015-10-08T05:09:12Z

Add missing space in configure

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