source: configure @ a4fc3a0

Last change on this file since a4fc3a0 was a4fc3a0, checked in by Wilmer van der Gaast <wilmer@…>, at 2016-06-12T21:16:39Z

configure: add 'arch' variable again, needed for portability

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