source: configure @ 21a328ab

Last change on this file since 21a328ab was f18209a, checked in by Jelmer Vernooij <jelmer@…>, at 2020-08-30T18:11:01Z

Use python3 if 'python' is not available.

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