source: configure @ 0d753ff

Last change on this file since 0d753ff was 0d753ff, checked in by Jelmer Vernooij <jelmer@…>, at 2022-02-17T22:23:06Z

Disable pie on SunOS, not supported

Add SunOS to the list of operating systems not supporting pie

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