source: configure @ b9c10a1

Last change on this file since b9c10a1 was b9c10a1, checked in by dequis <dx@…>, at 2017-05-29T05:04:36Z

cygwin: add -no-undefined on our side to fix issues with mac OS

So cygwin requires -no-undefined and it was supposed to be harmless on
platforms other than windows, but mac OS doesn't like it.

Instead of adding platform checks to every plugin, i'm going to revert
the changes that added -no-undefined to them, and just do what I should
have done since the beginning: use the cygwin-specific parts of the
pkg-config file to add -no-undefined right next to -lbitlbee

  • Property mode set to 100755
File size: 24.4 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.
35msn="default-on"
36jabber="default-on"
37oscar="default-on"
38
[1b221e0]39twitter=1
[04dc563]40purple=0
[b7d3cc34]41
[65d0dfd]42verbose=0
[a85a8ab]43doc=1
[b7d3cc34]44debug=0
[2a1c27f]45strip=0
[66b9e86e]46gcov=0
[e2472dd]47asan=0
[2abfbc5]48plugins=1
[04f0c10]49otr=0
[370899f]50skype=0
[85cf37f]51
52events=glib
[b7d3cc34]53ssl=auto
54
[a6005da]55pam=0
[50bb490]56ldap=0
[a6005da]57
[7281ad1]58pie=1
59
[21f450c]60arch=$(uname -s)
61
[34afea7]62GLIB_MIN_VERSION=2.16
[670204f]63
[25c4c78]64# Cygwin and Darwin don't support PIC/PIE
65case "$arch" in
[a85a8ab]66        CYGWIN* )
67                pie=0;;
68        Darwin )
69                pie=0;;
[25c4c78]70esac
71
[70ec7ab]72get_version() {
73        REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/')
[041777e]74
75        if [ -n "$BITLBEE_VERSION" ]; then
76                # environment variable already set to something to spoof it
77                # don't replace it with the git stuff
78                return
79        fi
80
[70ec7ab]81        BITLBEE_VERSION=$REAL_BITLBEE_VERSION
82
83        if [ -d $srcdir/.git ] && type git > /dev/null 2> /dev/null; then
84                timestamp=$(cd $srcdir; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g')
85                branch=$(cd $srcdir; git rev-parse --abbrev-ref HEAD)
86
[1d8cbc9]87                search='\(.*\)-\([0-9]*\)-\(g[0-9a-f]*\)'
[70ec7ab]88                replace="\1+$timestamp+$branch+\2-\3-git"
89
[e28c449]90                describe=$(cd $srcdir; git describe --long --tags 2>/dev/null)
91                if [ $? -ne 0 ]; then
92                        describe=${REAL_BITLBEE_VERSION}-0-g$(cd $srcdir; git rev-parse --short HEAD)
93                fi
[70ec7ab]94
[c984ee3]95                BITLBEE_VERSION=$(echo $describe | sed "s#$search#$replace#")
[e28c449]96
97                unset timestamp branch search replace describe
[70ec7ab]98        fi
99}
100
101if [ "$1" = "--dump-version" ]; then
102        srcdir=$(cd $(dirname $0);pwd)
103        get_version
104        echo $BITLBEE_VERSION
105        exit
106fi
107
108echo BitlBee configure
109
[b7d3cc34]110while [ -n "$1" ]; do
[4966712a]111        e="$(expr "X$1" : 'X--\(.*=.*\)')"
[b7d3cc34]112        if [ -z "$e" ]; then
113                cat<<EOF
114
115Usage: $0 [OPTIONS]
116
117Option          Description                             Default
118
119--prefix=...    Directories to put files in             $prefix
120--bindir=...                                            $bindir
[57da960]121--sbindir=...                                           $sbindir
[b7d3cc34]122--etcdir=...                                            $etcdir
123--mandir=...                                            $mandir
124--datadir=...                                           $datadir
[7b23afd]125--plugindir=...                                         $plugindir
[417002e]126--systemdsystemunitdir=...                              $systemdsystemunitdir
[34b17d9]127--pidfile=...                                           $pidfile
[b7d3cc34]128--config=...                                            $config
129
[65d0dfd]130--verbose=0/1   Disable/enable verbose build            $verbose
131
[b7d3cc34]132--msn=0/1       Disable/enable MSN part                 $msn
133--jabber=0/1    Disable/enable Jabber part              $jabber
134--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
[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
[17f6079]152--skype=0/1/plugin
[370899f]153                Disable/enable Skype support            $skype
[b7d3cc34]154
[85cf37f]155--events=...    Event handler (glib, libevent)          $events
[e1d3f98]156--ssl=...       SSL library to use (gnutls, nss, openssl, auto)
[b7d3cc34]157                                                        $ssl
[aec56b0]158
[7281ad1]159
[f1e7407]160--target=...    Cross compilation target                same as host
[f5bbaba]161--sysroot=...   Cross compilation sysroot               $sysroot
[b7d3cc34]162EOF
163                exit;
164        fi
165        eval "$e"
166        shift;
167done
168
169# Expand $prefix and get rid of double slashes
[4966712a]170bindir=$(eval echo "$bindir/" | sed 's/\/\{1,\}/\//g')
171sbindir=$(eval echo "$sbindir/" | sed 's/\/\{1,\}/\//g')
172etcdir=$(eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g')
173mandir=$(eval echo "$mandir/" | sed 's/\/\{1,\}/\//g')
174datadir=$(eval echo "$datadir/" | sed 's/\/\{1,\}/\//g')
175config=$(eval echo "$config/" | sed 's/\/\{1,\}/\//g')
[54b2a36]176libdir=$(eval echo "$libdir/" | sed 's/\/\{1,\}/\//g')
[4966712a]177plugindir=$(eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g')
178includedir=$(eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g')
179libevent=$(eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g')
180
181pidfile=$(eval echo "$pidfile" | sed 's/\/\{1,\}/\//g')
182ipcsocket=$(eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g')
183pcdir=$(eval echo "$pcdir" | sed 's/\/\{1,\}/\//g')
[b7d3cc34]184
[17f6079]185protocols_mods=""
186
[b95b0c8]187cat <<EOF >Makefile.settings
[b7d3cc34]188## BitlBee settings, generated by configure
[2f8e3ca]189
190# ./configure $configure_args
191
[b7d3cc34]192PREFIX=$prefix
193BINDIR=$bindir
[57da960]194SBINDIR=$sbindir
[b7d3cc34]195ETCDIR=$etcdir
196MANDIR=$mandir
197DATADIR=$datadir
[7b23afd]198PLUGINDIR=$plugindir
[b7d3cc34]199CONFIG=$config
[54b2a36]200LIBDIR=$libdir
[e506d6c]201INCLUDEDIR=$includedir
202PCDIR=$pcdir
[b7d3cc34]203
[1bf9492]204TARGET=$target
[b7d3cc34]205
[25b80e9c]206INSTALL=install -p
207
[b7d3cc34]208DESTDIR=
209LFLAGS=
[7a80925]210EFLAGS=-lm
[b7d3cc34]211EOF
212
[1074806]213srcdir=$(cd $(dirname $0);pwd)
214currdir=$(pwd)
215if [ "$srcdir" != "$currdir" ]; then 
[f60079b]216        echo
217        echo "configure script run from a different directory. Will create some symlinks..."
218        if [ ! -e Makefile -o -L Makefile ]; then
[04dc563]219                COPYDIRS="doc lib protocols tests utils"
220                mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d)
[f60079b]221                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
222                dst="$PWD"
223                cd "$srcdir"
[04dc563]224                for i in $(find . -name Makefile -type f); do
[f60079b]225                        ln -s "$PWD${i#.}" "$dst/$i";
226                done
227                cd "$dst"
228                rm -rf .bzr
229        fi
230       
[7fa5c19]231        echo "_SRCDIR_=$srcdir/" >> Makefile.settings
[f60079b]232        CFLAGS="$CFLAGS -I${dst}"
233else
234        srcdir=$PWD
235fi
236
[b95b0c8]237cat<<EOF >config.h
[b7d3cc34]238/* BitlBee settings, generated by configure
239   
240   Do *NOT* use any of these defines in your code without thinking twice, most
241   of them can/will be overridden at run-time */
242
[2f8e3ca]243#define BITLBEE_CONFIGURE_ARGS "$configure_args"
244
[b7d3cc34]245#define CONFIG "$config"
246#define ETCDIR "$etcdir"
247#define VARDIR "$datadir"
[7b23afd]248#define PLUGINDIR "$plugindir"
[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;
[daae10f]341if echo $CC | grep -qw gcc; then
342        # Apparently -Wall is gcc-specific?
343        echo CFLAGS+=-Wall >> Makefile.settings
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
491detect_resolv_dynamic()
492{
[aee8c19]493        case "$arch" in
[632627e]494        OpenBSD )
495                # In FreeBSD res_*/dn_* routines are present in libc.so
496                LIBRESOLV=;;
[aee8c19]497        FreeBSD )
[632627e]498                # In FreeBSD res_*/dn_* routines are present in libc.so
499                LIBRESOLV=;;
500        CYGWIN* )
501                # In Cygwin res_*/dn_* routines are present in libc.so
[aee8c19]502                LIBRESOLV=;;
503        * )
504                LIBRESOLV=-lresolv;;
505        esac
[4fca1db]506        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]507        ret=1
[aee8c19]508        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
[36cf9fd]509        if [ "$?" = "0" ]; then
[aee8c19]510                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
[8462239]511                ret=0
[36cf9fd]512        fi
513
[8462239]514        rm -f $TMPFILE
515        return $ret
[36cf9fd]516}
517
518detect_resolv_static()
519{
[4fca1db]520        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
[8462239]521        ret=1
[36cf9fd]522        for i in $systemlibdirs; do
523                if [ -f $i/libresolv.a ]; then
[8462239]524                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
[36cf9fd]525                        if [ "$?" = "0" ]; then
526                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
[8462239]527                                ret=0
[36cf9fd]528                        fi
529                fi
530        done
531
[8462239]532        rm -f $TMPFILE
533        return $ret
[36cf9fd]534}
535
[632627e]536detect_resolv_ns_dynamic()
537{
538        case "$arch" in
539        FreeBSD )
540                # In FreeBSD ns_ routines are present in libc.so
541                LIBRESOLV=;;
542        * )
543                LIBRESOLV=-lresolv;;
544        esac
545        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
546        ret=1
547        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
[a67e781]548        if [ "$?" = "0" ]; then
549                ret=0
550        fi
[632627e]551
552        rm -f $TMPFILE
553        return $ret
554}
555
556detect_resolv_ns_static()
557{
558        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
559        ret=1
560        for i in $systemlibdirs; do
561                if [ -f $i/libresolv.a ]; then
562                        echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
[a67e781]563                        if [ "$?" = "0" ]; then
564                                ret=0
565                        fi
[632627e]566                fi
567        done
568
569        rm -f $TMPFILE
570        return $ret
571}
572
573detect_nameser_has_ns_types()
574{
[a67e781]575        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
576        ret=1
577        # since we aren't actually linking with ns_* routines
578        # we can just compile the test code
579        echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
580        if [ "$?" = "0" ]; then
581                ret=0
582        fi
583
584        rm -f $TMPFILE
585        return $ret
[632627e]586}
587
[b3c467b]588if [ "$ssl" = "auto" ]; then
589        detect_gnutls
[b7d3cc34]590        if [ "$ret" = "0" ]; then
[c5920df]591                # Disable NSS for now as it's known to not work very well ATM.
592                #detect_nss
[191cfb1]593                :
[b7d3cc34]594        fi
[b3c467b]595elif [ "$ssl" = "gnutls" ]; then
596        detect_gnutls
597elif [ "$ssl" = "nss" ]; then
598        detect_nss
599elif [ "$ssl" = "openssl" ]; then
600        echo
601        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
[b3eee9b]602        echo 'installation of OpenSSL (including devel/header files) before reporting'
[b3c467b]603        echo 'compilation problems.'
604        echo
605        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
[b3eee9b]606        echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported'
607        echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the'
608        echo 'operating system, which makes it GPL-compatible.'
[b3c467b]609        echo
610        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
611        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
612        echo
613        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
614        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
[b3eee9b]615        echo 'package, you really should use GnuTLS instead.'
[b3c467b]616        echo
617        echo 'Also, the OpenSSL license requires us to say this:'
618        echo ' *    "This product includes software developed by the OpenSSL Project'
619        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
[b7d3cc34]620       
[b3c467b]621        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
622       
623        ret=1
624else
625        echo
626        echo 'ERROR: Unknown SSL library specified.'
627        exit 1
[b7d3cc34]628fi
629
[b3c467b]630if [ "$ret" = "0" ]; then
631        echo
632        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
633        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
[e1d3f98]634        echo '       so if you want to use that, you have to select it by hand.'
[b7d3cc34]635       
[b3c467b]636        exit 1
637fi;
638
639echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
640
[632627e]641if detect_nameser_has_ns_types; then
642        echo '#define NAMESER_HAS_NS_TYPES' >> config.h
643fi
[36cf9fd]644if detect_resolv_dynamic || detect_resolv_static; then
645        echo '#define HAVE_RESOLV_A' >> config.h
[a67e781]646        if detect_resolv_ns_dynamic || detect_resolv_ns_static; then
647                echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h
648        fi
[632627e]649else
[a67e781]650        echo 'Insufficient resolv routines. Jabber server must be set explicitly'
[36cf9fd]651fi
[36e9f62]652
[632627e]653
[ba7d16f]654STORAGES="xml"
[b3c467b]655
656for i in $STORAGES; do
657        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
658done
659echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
660
[8e6ecfe]661authobjs=
662authlibs=
[a6005da]663if [ "$pam" = 0 ]; then
664        echo '#undef WITH_PAM' >> config.h
665else
666        if ! echo '#include <security/pam_appl.h>' | $CC -E - >/dev/null 2>/dev/null; then
667                echo 'Cannot find libpam development libraries, aborting. (Install libpam0g-dev?)'
668                exit 1
669        fi
670        echo '#define WITH_PAM' >> config.h
671        authobjs=$authobjs'auth_pam.o '
672        authlibs=$authlibs'-lpam '
673fi
[50bb490]674if [ "$ldap" = 0 ]; then
675        echo '#undef WITH_LDAP' >> config.h
676else
677        if ! echo '#include <ldap.h>' | $CC -E - >/dev/null 2>/dev/null; then
678                echo 'Cannot find libldap development libraries, aborting. (Install libldap2-dev?)'
679                exit 1
680        fi
681        echo '#define WITH_LDAP' >> config.h
682        authobjs=$authobjs'auth_ldap.o '
683        authlibs=$authlibs'-lldap '
684fi
[8e6ecfe]685echo AUTH_OBJS=$authobjs >> Makefile.settings
686echo EFLAGS+=$authlibs >> Makefile.settings
687
[b7d3cc34]688if [ "$strip" = 0 ]; then
689        echo "STRIP=\# skip strip" >> Makefile.settings;
690else
691        if [ "$debug" = 1 ]; then
692                echo
693                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
694                echo 'STRIP=\# skip strip' >> Makefile.settings
695                strip=0;
696        elif [ -n "$STRIP" ]; then
697                echo "STRIP=$STRIP" >> Makefile.settings;
698        elif type strip > /dev/null 2> /dev/null; then
699                echo "STRIP=strip" >> Makefile.settings;
700        else
701                echo
702                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
703                echo 'STRIP=\# skip strip' >> Makefile.settings
704                strip=0;
705        fi;
706fi
707
[417002e]708if [ -z "$systemdsystemunitdir" ]; then
709        if $PKG_CONFIG --exists systemd; then
[4966712a]710                systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
[417002e]711        fi
712fi
713if [ -n "$systemdsystemunitdir" ]; then
714        if [ "$systemdsystemunitdir" != "no" ]; then
715                echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
716        fi
717fi
718
[66b9e86e]719if [ "$gcov" = "1" ]; then
[31fc3970]720        echo "CFLAGS+=--coverage" >> Makefile.settings
721        echo "EFLAGS+=--coverage" >> Makefile.settings
[66b9e86e]722fi
723
[2abfbc5]724if [ "$plugins" = 0 ]; then
[489847f]725        plugindir=""
[2abfbc5]726        echo '#undef WITH_PLUGINS' >> config.h
727else
728        echo '#define WITH_PLUGINS' >> config.h
729fi
730
[6738a67]731otrprefix=""
[764c7d1]732if [ "$otr" = "auto" ]; then
[a59bd11]733        ! $PKG_CONFIG --exists libotr
734        otr=$?
735fi
736
737if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
738        exit 1
[764c7d1]739fi
[a59bd11]740
[6738a67]741if [ "$otr" = 1 ]; then
[858ea01]742        # BI == built-in
743        echo '#define OTR_BI' >> config.h
[872e017]744        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
745        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
[858ea01]746        echo 'OTR_BI=otr.o' >> Makefile.settings
747elif [ "$otr" = "plugin" ]; then
[a59bd11]748        # for some mysterious reason beyond the comprehension of my mortal mind,
749        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
[858ea01]750        echo '#define OTR_PI' >> config.h
[872e017]751        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
752        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
[858ea01]753        echo 'OTR_PI=otr.so' >> Makefile.settings
[764c7d1]754fi
755
[17f6079]756if [ "$skype" = "1" -o "$skype" = "plugin" ]; then
[b2b7f52]757        if [ "$arch" = "Darwin" ]; then
758                echo "SKYPEFLAGS=-dynamiclib -undefined dynamic_lookup" >> Makefile.settings
759        else
760                echo "SKYPEFLAGS=-fPIC -shared" >> Makefile.settings
761        fi
[370899f]762        echo 'SKYPE_PI=skype.so' >> Makefile.settings
[17f6079]763        protocols_mods="$protocol_mods skype(plugin)"
[370899f]764fi
765
[1cef55f]766if [ -z "$PYTHON" ]; then
767        PYTHON=python
768fi
769
[a85a8ab]770if [ "$doc" = "1" ]; then
[beb0f54]771        # check this here just in case someone tries to install it in python2.4...
[1cef55f]772        if ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
[a85a8ab]773                echo
[beb0f54]774                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
[1cef55f]775                echo "(Use the PYTHON environment variable if it's in a weird location)"
[beb0f54]776                exit 1
[a85a8ab]777        fi
[beb0f54]778        echo "DOC=1" >> Makefile.settings
[1cef55f]779        echo "PYTHON=$PYTHON" >> Makefile.settings
[ceebeb1]780fi
781
[70ec7ab]782get_version
[e26aa72]783
[70ec7ab]784if [ "$BITLBEE_VERSION" != "$REAL_BITLBEE_VERSION" ]; then
[b7d3cc34]785        echo 'Spoofing version number: '$BITLBEE_VERSION
786        echo '#undef BITLBEE_VERSION' >> config.h
[f287f04]787        echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
[ffea9b9]788        echo
[b7d3cc34]789fi
790
[4fca1db]791if ! make helloworld > /dev/null 2>&1; then
792        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
793        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
794        echo "under the name 'gmake'."
795        echo
796        if gmake helloworld > /dev/null 2>&1; then
797                echo "gmake seems to be available on your machine, great."
798                echo
799        else
800                echo "gmake is not installed (or not working). Please try to install it."
801                echo
802        fi
803fi
804
[54b2a36]805pkgconfiglibs=''
806case "$arch" in
807CYGWIN* )
[b9c10a1]808        pkgconfiglibs='-L${libdir} -lbitlbee -no-undefined'
[54b2a36]809esac
810
[b95b0c8]811cat <<EOF >bitlbee.pc
[e506d6c]812prefix=$prefix
813includedir=$includedir
[489847f]814plugindir=$plugindir
[54b2a36]815libdir=$libdir
[e506d6c]816
817Name: bitlbee
818Description: IRC to IM gateway
819Requires: glib-2.0
820Version: $BITLBEE_VERSION
[54b2a36]821Libs: $pkgconfiglibs
[e506d6c]822Cflags: -I\${includedir}
823
824EOF
825
[b7d3cc34]826protocols=''
827protoobjs=''
828
[e248c7f]829if [ "$purple" = 0 ]; then
830        echo '#undef WITH_PURPLE' >> config.h
831else
[e08e53c]832        if ! $PKG_CONFIG purple; then
833                echo
834                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
835                exit 1
836        fi
[e248c7f]837        echo '#define WITH_PURPLE' >> config.h
[b95b0c8]838        cat<<EOF >>Makefile.settings
[e08e53c]839EFLAGS += $($PKG_CONFIG purple --libs)
840PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
841EOF
[e248c7f]842        protocols=$protocols'purple '
843        protoobjs=$protoobjs'purple_mod.o '
844
[04e2a05]845        # only disable these if the user didn't enable them explicitly
846        [ "$msn" = "default-on" ] && msn=0
847        [ "$jabber" = "default-on" ] && jabber=0
848        [ "$oscar" = "default-on" ] && oscar=0
[18e1f3b]849
850        echo '#undef PACKAGE' >> config.h
851        echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h
[bda2975]852       
853        if [ "$events" = "libevent" ]; then
854                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
855                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
856                echo 'libpurple + libevent is *not* recommended!'
[c775a58]857                echo
[bda2975]858        fi
[e248c7f]859fi
860
[b0a89cc]861case "$CC" in
862*gcc* )
[e371011]863        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
[fe92921]864        for i in . lib tests protocols protocols/*/; do
[b0a89cc]865                mkdir -p $i/.depend
866        done
867esac
868
[b7d3cc34]869if [ "$msn" = 0 ]; then
870        echo '#undef WITH_MSN' >> config.h
871else
872        echo '#define WITH_MSN' >> config.h
873        protocols=$protocols'msn '
[b5a22e3]874        protoobjs=$protoobjs'msn_mod.o '
[b7d3cc34]875fi
876
877if [ "$jabber" = 0 ]; then
878        echo '#undef WITH_JABBER' >> config.h
879else
880        echo '#define WITH_JABBER' >> config.h
881        protocols=$protocols'jabber '
[b5a22e3]882        protoobjs=$protoobjs'jabber_mod.o '
[b7d3cc34]883fi
884
885if [ "$oscar" = 0 ]; then
886        echo '#undef WITH_OSCAR' >> config.h
887else
888        echo '#define WITH_OSCAR' >> config.h
889        protocols=$protocols'oscar '
[b5a22e3]890        protoobjs=$protoobjs'oscar_mod.o '
[b7d3cc34]891fi
892
[1b221e0]893if [ "$twitter" = 0 ]; then
894        echo '#undef WITH_TWITTER' >> config.h
895else
896        echo '#define WITH_TWITTER' >> config.h
897        protocols=$protocols'twitter '
898        protoobjs=$protoobjs'twitter_mod.o '
899fi
900
[b7d3cc34]901if [ "$protocols" = "PROTOCOLS = " ]; then
[43462708]902        echo "Warning: You haven't selected any communication protocol to compile!"
[b3c467b]903        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
[b7d3cc34]904fi
905
906echo "PROTOCOLS = $protocols" >> Makefile.settings
907echo "PROTOOBJS = $protoobjs" >> Makefile.settings
908
909echo Architecture: $arch
910case "$arch" in
911Linux )
912;;
913GNU/* )
914;;
915*BSD )
916;;
917Darwin )
[caceb06]918        echo 'STRIP=\# skip strip' >> Makefile.settings
[b7d3cc34]919;;
920IRIX )
921;;
922SunOS )
923        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
924        echo 'STRIP=\# skip strip' >> Makefile.settings
[70d7795]925        echo '#define NO_FD_PASSING' >> config.h
[b7d3cc34]926;;
[8de63c3]927AIX )
928        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
[b7d3cc34]929;;
930CYGWIN* )
[54b2a36]931        echo 'EFLAGS+=-Wl,--export-all,--out-implib,libbitlbee.dll.a' >> Makefile.settings
932        echo 'IMPLIB=libbitlbee.dll.a' >> Makefile.settings
[b7d3cc34]933;;
[aec56b0]934Windows )
[e252d8c]935        echo 'Native windows compilation is not supported anymore, use cygwin instead.'
[aec56b0]936;;
[b7d3cc34]937* )
[8d6c4b1]938        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
939        echo 'Please report any problems at http://bugs.bitlbee.org/.'
[b7d3cc34]940;;
941esac
942
[f1e7407]943if [ -n "$target" ]; then
944        echo "Cross-compiling for: $target"
945fi
946
[b7d3cc34]947echo
948echo 'Configuration done:'
949
950if [ "$debug" = "1" ]; then
[b3c467b]951        echo '  Debugging enabled.'
[b7d3cc34]952else
[b3c467b]953        echo '  Debugging disabled.'
[b7d3cc34]954fi
955
[e2472dd]956if [ "$asan" = "1" ]; then
957        echo '  AddressSanitizer (ASAN) enabled.'
958else
959        echo '  AddressSanitizer (ASAN) disabled.'
960fi
961
[7281ad1]962if [ "$pie" = "1" ]; then
963        echo '  Building PIE executable'
964else
965        echo '  Building non-PIE executable'
966fi
967
[b7d3cc34]968if [ "$strip" = "1" ]; then
[b3c467b]969        echo '  Binary stripping enabled.'
[b7d3cc34]970else
[b3c467b]971        echo '  Binary stripping disabled.'
[b7d3cc34]972fi
973
[764c7d1]974if [ "$otr" = "1" ]; then
975        echo '  Off-the-Record (OTR) Messaging enabled.'
[858ea01]976elif [ "$otr" = "plugin" ]; then
977        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
[764c7d1]978else
979        echo '  Off-the-Record (OTR) Messaging disabled.'
980fi
981
[417002e]982if [ -n "$systemdsystemunitdir" ]; then
983        echo '  systemd enabled.'
984else
985        echo '  systemd disabled.'
986fi
987
[b3c467b]988echo '  Using event handler: '$events
989echo '  Using SSL library: '$ssl
[4e3df8a]990#echo '  Building with these storage backends: '$STORAGES
[b7d3cc34]991
992if [ -n "$protocols" ]; then
[17f6079]993        echo '  Building with these protocols:' $protocols$protocols_mods
[4e3df8a]994        case "$protocols" in
995        *purple*)
996                echo "    Note that BitlBee-libpurple is supported on a best-effort basis. It's"
997                echo "    not *fully* compatible with normal BitlBee. Don't use it unless you"
998                echo "    absolutely need it (i.e. support for a certain protocol or feature)."
999        esac
[b7d3cc34]1000else
[b3c467b]1001        echo '  Building without IM-protocol support. We wish you a lot of fun...'
[b7d3cc34]1002fi
Note: See TracBrowser for help on using the repository browser.