source: configure @ 2a1c27f

Last change on this file since 2a1c27f was 2a1c27f, checked in by dequis <dx@…>, at 2016-11-28T18:20:34Z

Include debug symbols in non-debug builds, disable stripping by default

With this commit, the difference between debug and non-debug builds is
mainly the optimization level and -DDEBUG (which isn't used much)

In other words:

--debug=0 == CFLAGS="-g -O2 -fno-strict-aliasing"
--debug=1 == CFLAGS="-g3 -DDEBUG -O0"

And --strip=1 can be used to get rid of the debug symbols.

This is closer to the default behavior of autotools.

Should have done this forever ago, like back when bitlbee had bugs (lol)

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