source: configure @ 0515063

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

configure: respect autotools-like verbose flags for make

In other words, running $(make V=1) will force a verbose build while
$(make V=0) will force a silent build regardless of the verbose option
set by the configure script.

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