source: configure @ 65d0dfd

Last change on this file since 65d0dfd was 65d0dfd, checked in by dx <dx@…>, at 2017-03-12T04:16:58Z

Add --verbose configure option to control verbose build output

Defaults to disabled to maintain the status quo.

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