source: configure @ 60d6c03

Last change on this file since 60d6c03 was 21f450c, checked in by dequis <dx@…>, at 2016-05-26T00:15:15Z

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.9 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
338if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
[670204f]339        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
[b95b0c8]340                cat<<EOF >>Makefile.settings
[4966712a]341EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0)
342CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0)
[b7d3cc34]343EOF
[670204f]344        else
345                echo
[4966712a]346                echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.'
[670204f]347                exit 1
348        fi
[b7d3cc34]349else
[670204f]350        echo
[574af7e]351        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
[670204f]352        exit 1
[b7d3cc34]353fi
354
[85cf37f]355if [ "$events" = "libevent" ]; then
[003553b]356        if ! [ -f "${libevent}include/event.h" ]; then
[85cf37f]357                echo
358                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
359                echo 'its location using the --libevent= argument. (Example: If event.h is in'
360                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
361        fi
362       
363        echo '#define EVENTS_LIBEVENT' >> config.h
[b95b0c8]364        cat <<EOF >>Makefile.settings
[85cf37f]365EFLAGS+=-levent -L${libevent}lib
366CFLAGS+=-I${libevent}include
367EOF
368elif [ "$events" = "glib" ]; then
369        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
370        echo '#define EVENTS_GLIB' >> config.h
[b7d3cc34]371else
372        echo
[85cf37f]373        echo 'ERROR: Unknown event handler specified.'
374        exit 1
[b7d3cc34]375fi
[85cf37f]376echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
[b7d3cc34]377
378detect_gnutls()
379{
[4af7b4f]380        if $PKG_CONFIG --exists gnutls; then
[b95b0c8]381                cat <<EOF >>Makefile.settings
[4966712a]382EFLAGS+=$($PKG_CONFIG --libs gnutls) $(libgcrypt-config --libs)
383CFLAGS+=$($PKG_CONFIG --cflags gnutls) $(libgcrypt-config --cflags)
[4af7b4f]384EOF
385                ssl=gnutls
[a59bd11]386                if ! $PKG_CONFIG gnutls --atleast-version=2.8; then
[5513f3e]387                        echo
388                        echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.'
389                fi
[4af7b4f]390                ret=1
391        elif libgnutls-config --version > /dev/null 2> /dev/null; then
[b95b0c8]392                cat <<EOF >>Makefile.settings
[4966712a]393EFLAGS+=$(libgnutls-config --libs) $(libgcrypt-config --libs)
394CFLAGS+=$(libgnutls-config --cflags) $(libgcrypt-config --cflags)
[b7d3cc34]395EOF
396               
397                ssl=gnutls
398                ret=1;
399        else
400                ret=0;
401        fi;
402}
403
404detect_nss()
405{
[ef043d3]406        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then
[b95b0c8]407                cat<<EOF >>Makefile.settings
[4966712a]408EFLAGS+=$($PKG_CONFIG --libs nss)
409CFLAGS+=$($PKG_CONFIG --cflags nss)
[b7d3cc34]410EOF
411               
412                ssl=nss
413                ret=1;
414        else
415                ret=0;
416        fi;
417}
418
[36cf9fd]419RESOLV_TESTCODE='
[aee8c19]420#include <sys/types.h>
421#include <netinet/in.h>
[36cf9fd]422#include <arpa/nameser.h>
423#include <resolv.h>
424
[632627e]425int main()
426{
427
428        res_query( NULL, 0, 0, NULL, 0);
429        dn_expand( NULL, NULL, NULL, NULL, 0);
430        dn_skipname( NULL, NULL);
431}
432'
433RESOLV_NS_TESTCODE='
434#include <sys/types.h>
435#include <netinet/in.h>
436#include <arpa/nameser.h>
437#include <resolv.h>
438
[36cf9fd]439int main()
440{
441        ns_initparse( NULL, 0, NULL );
442        ns_parserr( NULL, ns_s_an, 0, NULL );
443}
444'
[632627e]445RESOLV_NS_TYPES_TESTCODE='
446#include <sys/types.h>
447#include <netinet/in.h>
448#include <arpa/nameser.h>
449
450int main()
451{
452        ns_msg nsh;
453        ns_rr rr;
454
[fb87924]455        /* Not all platforms we want to work on have
456         ns_* routines, so use this to make sure
457         the compiler uses it.*/
458        return (int)(sizeof(nsh) + sizeof(rr));
[632627e]459}
460'
[36cf9fd]461
462detect_resolv_dynamic()
463{
[aee8c19]464        case "$arch" in
[632627e]465        OpenBSD )
466                # In FreeBSD res_*/dn_* routines are present in libc.so
467                LIBRESOLV=;;
[aee8c19]468        FreeBSD )
[632627e]469                # In FreeBSD res_*/dn_* routines are present in libc.so
470                LIBRESOLV=;;
471        CYGWIN* )
472                # In Cygwin res_*/dn_* routines are present in libc.so
[aee8c19]473                LIBRESOLV=;;
474        * )
475                LIBRESOLV=-lresolv;;
476        esac
[4fca1db]477        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]478        ret=1
[aee8c19]479        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
[36cf9fd]480        if [ "$?" = "0" ]; then
[aee8c19]481                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
[8462239]482                ret=0
[36cf9fd]483        fi
484
[8462239]485        rm -f $TMPFILE
486        return $ret
[36cf9fd]487}
488
489detect_resolv_static()
490{
[4fca1db]491        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]492        ret=1
[36cf9fd]493        for i in $systemlibdirs; do
494                if [ -f $i/libresolv.a ]; then
[8462239]495                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
[36cf9fd]496                        if [ "$?" = "0" ]; then
497                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
[8462239]498                                ret=0
[36cf9fd]499                        fi
500                fi
501        done
502
[8462239]503        rm -f $TMPFILE
504        return $ret
[36cf9fd]505}
506
[632627e]507detect_resolv_ns_dynamic()
508{
509        case "$arch" in
510        FreeBSD )
511                # In FreeBSD ns_ routines are present in libc.so
512                LIBRESOLV=;;
513        * )
514                LIBRESOLV=-lresolv;;
515        esac
516        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
517        ret=1
518        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
[a67e781]519        if [ "$?" = "0" ]; then
520                ret=0
521        fi
[632627e]522
523        rm -f $TMPFILE
524        return $ret
525}
526
527detect_resolv_ns_static()
528{
529        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
530        ret=1
531        for i in $systemlibdirs; do
532                if [ -f $i/libresolv.a ]; then
533                        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
[a67e781]534                        if [ "$?" = "0" ]; then
535                                ret=0
536                        fi
[632627e]537                fi
538        done
539
540        rm -f $TMPFILE
541        return $ret
542}
543
544detect_nameser_has_ns_types()
545{
[a67e781]546        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
547        ret=1
548        # since we aren't actually linking with ns_* routines
549        # we can just compile the test code
550        echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
551        if [ "$?" = "0" ]; then
552                ret=0
553        fi
554
555        rm -f $TMPFILE
556        return $ret
[632627e]557}
558
[b3c467b]559if [ "$ssl" = "auto" ]; then
560        detect_gnutls
[b7d3cc34]561        if [ "$ret" = "0" ]; then
[c5920df]562                # Disable NSS for now as it's known to not work very well ATM.
563                #detect_nss
[191cfb1]564                :
[b7d3cc34]565        fi
[b3c467b]566elif [ "$ssl" = "gnutls" ]; then
567        detect_gnutls
568elif [ "$ssl" = "nss" ]; then
569        detect_nss
570elif [ "$ssl" = "openssl" ]; then
571        echo
572        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
[b3eee9b]573        echo 'installation of OpenSSL (including devel/header files) before reporting'
[b3c467b]574        echo 'compilation problems.'
575        echo
576        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
[b3eee9b]577        echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported'
578        echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the'
579        echo 'operating system, which makes it GPL-compatible.'
[b3c467b]580        echo
581        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
582        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
583        echo
584        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
585        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
[b3eee9b]586        echo 'package, you really should use GnuTLS instead.'
[b3c467b]587        echo
588        echo 'Also, the OpenSSL license requires us to say this:'
589        echo ' *    "This product includes software developed by the OpenSSL Project'
590        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
[b7d3cc34]591       
[b3c467b]592        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
593       
594        ret=1
595else
596        echo
597        echo 'ERROR: Unknown SSL library specified.'
598        exit 1
[b7d3cc34]599fi
600
[b3c467b]601if [ "$ret" = "0" ]; then
602        echo
603        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
604        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
[e1d3f98]605        echo '       so if you want to use that, you have to select it by hand.'
[b7d3cc34]606       
[b3c467b]607        exit 1
608fi;
609
610echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
611
[632627e]612if detect_nameser_has_ns_types; then
613        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
614fi
[36cf9fd]615if detect_resolv_dynamic || detect_resolv_static; then
616        echo '#define HAVE_RESOLV_A' >> config.h
[a67e781]617        if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
618                echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
619        fi
[632627e]620else
[a67e781]621        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
[36cf9fd]622fi
[36e9f62]623
[632627e]624
[ba7d16f]625STORAGES="xml"
[b3c467b]626
627for i in $STORAGES; do
628        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
629done
630echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
631
[8e6ecfe]632authobjs=
633authlibs=
[a6005da]634if [ "$pam" = 0 ]; then
635        echo '#undef WITH_PAM' >> config.h
636else
637        if ! echo '#include <security/pam_appl.h>' | $CC -E - >/dev/null 2>/dev/null; then
638                echo 'Cannot find libpam development libraries, aborting. (Install libpam0g-dev?)'
639                exit 1
640        fi
641        echo '#define WITH_PAM' >> config.h
642        authobjs=$authobjs'auth_pam.o '
643        authlibs=$authlibs'-lpam '
644fi
[50bb490]645if [ "$ldap" = 0 ]; then
646        echo '#undef WITH_LDAP' >> config.h
647else
648        if ! echo '#include <ldap.h>' | $CC -E - >/dev/null 2>/dev/null; then
649                echo 'Cannot find libldap development libraries, aborting. (Install libldap2-dev?)'
650                exit 1
651        fi
652        echo '#define WITH_LDAP' >> config.h
653        authobjs=$authobjs'auth_ldap.o '
654        authlibs=$authlibs'-lldap '
655fi
[8e6ecfe]656echo AUTH_OBJS=$authobjs >> Makefile.settings
657echo EFLAGS+=$authlibs >> Makefile.settings
658
[b7d3cc34]659if [ "$strip" = 0 ]; then
660        echo "STRIP=\# skip strip" >> Makefile.settings;
661else
662        if [ "$debug" = 1 ]; then
663                echo
664                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
665                echo 'STRIP=\# skip strip' >> Makefile.settings
666                strip=0;
667        elif [ -n "$STRIP" ]; then
668                echo "STRIP=$STRIP" >> Makefile.settings;
669        elif type strip > /dev/null 2> /dev/null; then
670                echo "STRIP=strip" >> Makefile.settings;
671        else
672                echo
673                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
674                echo 'STRIP=\# skip strip' >> Makefile.settings
675                strip=0;
676        fi;
677fi
678
[417002e]679if [ -z "$systemdsystemunitdir" ]; then
680        if $PKG_CONFIG --exists systemd; then
[4966712a]681                systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
[417002e]682        fi
683fi
684if [ -n "$systemdsystemunitdir" ]; then
685        if [ "$systemdsystemunitdir" != "no" ]; then
686                echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
687        fi
688fi
689
[66b9e86e]690if [ "$gcov" = "1" ]; then
[31fc3970]691        echo "CFLAGS+=--coverage" >> Makefile.settings
692        echo "EFLAGS+=--coverage" >> Makefile.settings
[66b9e86e]693fi
694
[2abfbc5]695if [ "$plugins" = 0 ]; then
[489847f]696        plugindir=""
[2abfbc5]697        echo '#undef WITH_PLUGINS' >> config.h
698else
699        echo '#define WITH_PLUGINS' >> config.h
700fi
701
[6738a67]702otrprefix=""
[764c7d1]703if [ "$otr" = "auto" ]; then
[a59bd11]704        ! $PKG_CONFIG --exists libotr
705        otr=$?
706fi
707
708if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
709        exit 1
[764c7d1]710fi
[a59bd11]711
[6738a67]712if [ "$otr" = 1 ]; then
[858ea01]713        # BI == built-in
714        echo '#define OTR_BI' >> config.h
[872e017]715        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
716        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
[858ea01]717        echo 'OTR_BI=otr.o' >> Makefile.settings
718elif [ "$otr" = "plugin" ]; then
[a59bd11]719        # for some mysterious reason beyond the comprehension of my mortal mind,
720        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
[858ea01]721        echo '#define OTR_PI' >> config.h
[872e017]722        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
723        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
[858ea01]724        echo 'OTR_PI=otr.so' >> Makefile.settings
[764c7d1]725fi
726
[17f6079]727if [ "$skype" = "1" -o "$skype" = "plugin" ]; then
[b2b7f52]728        if [ "$arch" = "Darwin" ]; then
729                echo "SKYPEFLAGS=-dynamiclib -undefined dynamic_lookup" >> Makefile.settings
730        else
731                echo "SKYPEFLAGS=-fPIC -shared" >> Makefile.settings
732        fi
[370899f]733        echo 'SKYPE_PI=skype.so' >> Makefile.settings
[17f6079]734        protocols_mods="$protocol_mods skype(plugin)"
[370899f]735fi
736
[1cef55f]737if [ -z "$PYTHON" ]; then
738        PYTHON=python
739fi
740
[a85a8ab]741if [ "$doc" = "1" ]; then
[beb0f54]742        # check this here just in case someone tries to install it in python2.4...
[1cef55f]743        if ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
[a85a8ab]744                echo
[beb0f54]745                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
[1cef55f]746                echo "(Use the PYTHON environment variable if it's in a weird location)"
[beb0f54]747                exit 1
[a85a8ab]748        fi
[beb0f54]749        echo "DOC=1" >> Makefile.settings
[1cef55f]750        echo "PYTHON=$PYTHON" >> Makefile.settings
[ceebeb1]751fi
752
[70ec7ab]753get_version
[e26aa72]754
[70ec7ab]755if [ "$BITLBEE_VERSION" != "$REAL_BITLBEE_VERSION" ]; then
[b7d3cc34]756        echo 'Spoofing version number: '$BITLBEE_VERSION
757        echo '#undef BITLBEE_VERSION' >> config.h
[f287f04]758        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
[ffea9b9]759        echo
[b7d3cc34]760fi
761
[4fca1db]762if ! make helloworld > /dev/null 2>&1; then
763        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
764        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
765        echo "under the name 'gmake'."
766        echo
767        if gmake helloworld > /dev/null 2>&1; then
768                echo "gmake seems to be available on your machine, great."
769                echo
770        else
771                echo "gmake is not installed (or not working). Please try to install it."
772                echo
773        fi
774fi
775
[b95b0c8]776cat <<EOF >bitlbee.pc
[e506d6c]777prefix=$prefix
778includedir=$includedir
[489847f]779plugindir=$plugindir
[e506d6c]780
781Name: bitlbee
782Description: IRC to IM gateway
783Requires: glib-2.0
784Version: $BITLBEE_VERSION
785Libs:
786Cflags: -I\${includedir}
787
788EOF
789
[b7d3cc34]790protocols=''
791protoobjs=''
792
[e248c7f]793if [ "$purple" = 0 ]; then
794        echo '#undef WITH_PURPLE' >> config.h
795else
[e08e53c]796        if ! $PKG_CONFIG purple; then
797                echo
798                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
799                exit 1
800        fi
[e248c7f]801        echo '#define WITH_PURPLE' >> config.h
[b95b0c8]802        cat<<EOF >>Makefile.settings
[e08e53c]803EFLAGS += $($PKG_CONFIG purple --libs)
804PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
805EOF
[e248c7f]806        protocols=$protocols'purple '
807        protoobjs=$protoobjs'purple_mod.o '
808
[04e2a05]809        # only disable these if the user didn't enable them explicitly
810        [ "$msn" = "default-on" ] && msn=0
811        [ "$jabber" = "default-on" ] && jabber=0
812        [ "$oscar" = "default-on" ] && oscar=0
813        [ "$yahoo" = "default-on" ] && yahoo=0
[18e1f3b]814
815        echo '#undef PACKAGE' >> config.h
816        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
[bda2975]817       
818        if [ "$events" = "libevent" ]; then
819                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
820                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
821                echo 'libpurple + libevent is *not* recommended!'
[c775a58]822                echo
[bda2975]823        fi
[e248c7f]824fi
825
[b0a89cc]826case "$CC" in
827*gcc* )
[e371011]828        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
[fe92921]829        for i in . lib tests protocols protocols/*/; do
[b0a89cc]830                mkdir -p $i/.depend
831        done
832esac
833
[b7d3cc34]834if [ "$msn" = 0 ]; then
835        echo '#undef WITH_MSN' >> config.h
836else
837        echo '#define WITH_MSN' >> config.h
838        protocols=$protocols'msn '
[b5a22e3]839        protoobjs=$protoobjs'msn_mod.o '
[b7d3cc34]840fi
841
842if [ "$jabber" = 0 ]; then
843        echo '#undef WITH_JABBER' >> config.h
844else
845        echo '#define WITH_JABBER' >> config.h
846        protocols=$protocols'jabber '
[b5a22e3]847        protoobjs=$protoobjs'jabber_mod.o '
[b7d3cc34]848fi
849
850if [ "$oscar" = 0 ]; then
851        echo '#undef WITH_OSCAR' >> config.h
852else
853        echo '#define WITH_OSCAR' >> config.h
854        protocols=$protocols'oscar '
[b5a22e3]855        protoobjs=$protoobjs'oscar_mod.o '
[b7d3cc34]856fi
857
858if [ "$yahoo" = 0 ]; then
859        echo '#undef WITH_YAHOO' >> config.h
860else
861        echo '#define WITH_YAHOO' >> config.h
862        protocols=$protocols'yahoo '
[b5a22e3]863        protoobjs=$protoobjs'yahoo_mod.o '
[b7d3cc34]864fi
865
[1b221e0]866if [ "$twitter" = 0 ]; then
867        echo '#undef WITH_TWITTER' >> config.h
868else
869        echo '#define WITH_TWITTER' >> config.h
870        protocols=$protocols'twitter '
871        protoobjs=$protoobjs'twitter_mod.o '
872fi
873
[b7d3cc34]874if [ "$protocols" = "PROTOCOLS = " ]; then
[43462708]875        echo "Warning: You haven't selected any communication protocol to compile!"
[b3c467b]876        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
[b7d3cc34]877fi
878
879echo "PROTOCOLS = $protocols" >> Makefile.settings
880echo "PROTOOBJS = $protoobjs" >> Makefile.settings
881
882echo Architecture: $arch
883case "$arch" in
884Linux )
885;;
886GNU/* )
887;;
888*BSD )
889;;
890Darwin )
[caceb06]891        echo 'STRIP=\# skip strip' >> Makefile.settings
[b7d3cc34]892;;
893IRIX )
894;;
895SunOS )
896        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
897        echo 'STRIP=\# skip strip' >> Makefile.settings
[70d7795]898        echo '#define NO_FD_PASSING' >> config.h
[b7d3cc34]899;;
[8de63c3]900AIX )
901        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
[b7d3cc34]902;;
903CYGWIN* )
904;;
[aec56b0]905Windows )
[e252d8c]906        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
[aec56b0]907;;
[b7d3cc34]908* )
[8d6c4b1]909        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
910        echo 'Please report any problems at http://bugs.bitlbee.org/.'
[b7d3cc34]911;;
912esac
913
[f1e7407]914if [ -n "$target" ]; then
915        echo "Cross-compiling for: $target"
916fi
917
[b7d3cc34]918echo
919echo 'Configuration done:'
920
921if [ "$debug" = "1" ]; then
[b3c467b]922        echo '  Debugging enabled.'
[b7d3cc34]923else
[b3c467b]924        echo '  Debugging disabled.'
[b7d3cc34]925fi
926
[e2472dd]927if [ "$asan" = "1" ]; then
928        echo '  AddressSanitizer (ASAN) enabled.'
929else
930        echo '  AddressSanitizer (ASAN) disabled.'
931fi
932
[7281ad1]933if [ "$pie" = "1" ]; then
934        echo '  Building PIE executable'
935else
936        echo '  Building non-PIE executable'
937fi
938
[b7d3cc34]939if [ "$strip" = "1" ]; then
[b3c467b]940        echo '  Binary stripping enabled.'
[b7d3cc34]941else
[b3c467b]942        echo '  Binary stripping disabled.'
[b7d3cc34]943fi
944
[764c7d1]945if [ "$otr" = "1" ]; then
946        echo '  Off-the-Record (OTR) Messaging enabled.'
[858ea01]947elif [ "$otr" = "plugin" ]; then
948        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
[764c7d1]949else
950        echo '  Off-the-Record (OTR) Messaging disabled.'
951fi
952
[417002e]953if [ -n "$systemdsystemunitdir" ]; then
954        echo '  systemd enabled.'
955else
956        echo '  systemd disabled.'
957fi
958
[b3c467b]959echo '  Using event handler: '$events
960echo '  Using SSL library: '$ssl
[4e3df8a]961#echo '  Building with these storage backends: '$STORAGES
[b7d3cc34]962
963if [ -n "$protocols" ]; then
[17f6079]964        echo '  Building with these protocols:' $protocols$protocols_mods
[4e3df8a]965        case "$protocols" in
966        *purple*)
967                echo "    Note that BitlBee-libpurple is supported on a best-effort basis. It's"
968                echo "    not *fully* compatible with normal BitlBee. Don't use it unless you"
969                echo "    absolutely need it (i.e. support for a certain protocol or feature)."
970        esac
[b7d3cc34]971else
[b3c467b]972        echo '  Building without IM-protocol support. We wish you a lot of fun...'
[b7d3cc34]973fi
Note: See TracBrowser for help on using the repository browser.