source: configure @ cc0ad0a

Last change on this file since cc0ad0a was cc0ad0a, checked in by Jelmer Vernooij <jelmer@…>, at 2022-02-22T15:27:23Z

configure: Fix syntax

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