source: configure @ e9eee04

Last change on this file since e9eee04 was e9eee04, checked in by Jelmer Vernooij <jelmer@…>, at 2022-08-22T14:48:16Z

configure: remove -fno-strict-aliasing

lib/json.c seems to be the last place where -fno-strict-aliasing was
needed. It is obsolete now and we can remove it.

Bug: https://bugs.gentoo.org/861371
Signed-off-by: Petr Vaněk <arkamar@…>

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