source: configure @ bc49ec2

Last change on this file since bc49ec2 was 04dc563, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-06-05T10:32:02Z

A few more configure script tweaks: Don't enable libpurple by default
anymore (in preparation for a merge), and limit the directory replication
stuff.

  • Property mode set to 100755
File size: 16.0 KB
Line 
1#!/bin/sh
2
3##############################
4##  Configurer for BitlBee  ##
5##                          ##
6##  Copyright 2004 Lintux   ##
7##  Copyright 2002 Lucumo   ##
8##############################
9
10prefix='/usr/local/'
11bindir='$prefix/sbin/'
12etcdir='$prefix/etc/bitlbee/'
13mandir='$prefix/share/man/'
14datadir='$prefix/share/bitlbee/'
15config='/var/lib/bitlbee/'
16plugindir='$prefix/lib/bitlbee/'
17includedir='$prefix/include/bitlbee/'
18libevent='/usr/'
19pidfile='/var/run/bitlbee.pid'
20ipcsocket='/var/run/bitlbee.sock'
21pcdir='$prefix/lib/pkgconfig'
22systemlibdirs="/lib /lib64 /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64"
23
24msn=1
25jabber=1
26oscar=1
27yahoo=1
28twitter=1
29purple=0
30
31debug=0
32strip=1
33gcov=0
34plugins=1
35
36events=glib
37ldap=0
38ssl=auto
39
40arch=`uname -s`
41cpu=`uname -m`
42
43GLIB_MIN_VERSION=2.4
44
45echo BitlBee configure
46
47while [ -n "$1" ]; do
48        e="`expr "X$1" : 'X--\(.*=.*\)'`"
49        if [ -z "$e" ]; then
50                cat<<EOF
51
52Usage: $0 [OPTIONS]
53
54Option          Description                             Default
55
56--prefix=...    Directories to put files in             $prefix
57--bindir=...                                            $bindir
58--etcdir=...                                            $etcdir
59--mandir=...                                            $mandir
60--datadir=...                                           $datadir
61--plugindir=...                                         $plugindir
62--pidfile=...                                           $pidfile
63--config=...                                            $config
64--ipcsocket=...                                         $ipcsocket
65
66--msn=0/1       Disable/enable MSN part                 $msn
67--jabber=0/1    Disable/enable Jabber part              $jabber
68--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
69--yahoo=0/1     Disable/enable Yahoo part               $yahoo
70--twitter=0/1 Disable/enable Twitter part               $twitter
71
72--purple=0/1    Disable/enable libpurple support        $purple
73
74--debug=0/1     Disable/enable debugging                $debug
75--strip=0/1     Disable/enable binary stripping         $strip
76--gcov=0/1      Disable/enable test coverage reporting  $gcov
77--plugins=0/1   Disable/enable plugins support          $plugins
78
79--events=...    Event handler (glib, libevent)          $events
80--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
81                                                        $ssl
82
83--target=...    Cross compilation target                same as host
84EOF
85                exit;
86        fi
87        eval "$e"
88        shift;
89done
90
91# Expand $prefix and get rid of double slashes
92bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'`
93etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'`
94mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'`
95datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
96config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
97plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
98includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'`
99libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'`
100
101pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
102ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
103pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
104
105cat<<EOF>Makefile.settings
106## BitlBee settings, generated by configure
107PREFIX=$prefix
108BINDIR=$bindir
109ETCDIR=$etcdir
110MANDIR=$mandir
111DATADIR=$datadir
112PLUGINDIR=$plugindir
113CONFIG=$config
114INCLUDEDIR=$includedir
115PCDIR=$pcdir
116
117TARGET=$target
118ARCH=$arch
119CPU=$cpu
120
121DESTDIR=
122LFLAGS=
123EFLAGS=
124EOF
125
126srcdir="$(dirname $0)"
127if [ "$srcdir" != "." ]; then
128        echo
129        echo "configure script run from a different directory. Will create some symlinks..."
130        if [ ! -e Makefile -o -L Makefile ]; then
131                COPYDIRS="doc lib protocols tests utils"
132                mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d)
133                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
134                dst="$PWD"
135                cd "$srcdir"
136                for i in $(find . -name Makefile -type f); do
137                        ln -s "$PWD${i#.}" "$dst/$i";
138                done
139                cd "$dst"
140                rm -rf .bzr
141        fi
142       
143        echo "SRCDIR=$srcdir/" >> Makefile.settings
144        CFLAGS="$CFLAGS -I${dst}"
145else
146        srcdir=$PWD
147fi
148
149cat<<EOF>config.h
150/* BitlBee settings, generated by configure
151   
152   Do *NOT* use any of these defines in your code without thinking twice, most
153   of them can/will be overridden at run-time */
154
155#define CONFIG "$config"
156#define ETCDIR "$etcdir"
157#define VARDIR "$datadir"
158#define PLUGINDIR "$plugindir"
159#define PIDFILE "$pidfile"
160#define IPCSOCKET "$ipcsocket"
161#define ARCH "$arch"
162#define CPU "$cpu"
163EOF
164
165
166
167if [ -n "$target" ]; then
168        PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
169        export PKG_CONFIG_LIBDIR
170        PATH=/usr/$target/bin:$PATH
171        CC=$target-cc
172        LD=$target-ld
173        systemlibdirs="/usr/$target/lib"
174fi
175
176
177if [ "$debug" = "1" ]; then
178        [ -z "$CFLAGS" ] && CFLAGS=-g
179        echo 'DEBUG=1' >> Makefile.settings
180        CFLAGS="$CFLAGS -DDEBUG"
181else
182        [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing"
183fi
184
185echo CFLAGS=$CFLAGS >> Makefile.settings
186echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
187
188echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
189
190if [ -n "$CC" ]; then
191        CC=$CC
192elif type gcc > /dev/null 2> /dev/null; then
193        CC=gcc
194elif type cc > /dev/null 2> /dev/null; then
195        CC=cc
196else
197        echo 'Cannot find a C compiler, aborting.'
198        exit 1;
199fi
200
201echo "CC=$CC" >> Makefile.settings;
202
203if [ -z "$LD" ]; then
204        if type ld > /dev/null 2> /dev/null; then
205                LD=ld
206        else
207                echo 'Cannot find ld, aborting.'
208                exit 1;
209        fi
210fi
211
212echo "LD=$LD" >> Makefile.settings
213
214if [ -z "$PKG_CONFIG" ]; then
215        PKG_CONFIG=pkg-config
216fi
217
218if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
219        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
220                cat<<EOF>>Makefile.settings
221EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
222CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
223EOF
224        else
225                echo
226                echo 'Found glib2 '`$PKG_CONFIG glib-2.0 --modversion`', but version '$GLIB_MIN_VERSION' or newer is required.'
227                exit 1
228        fi
229else
230        echo
231        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
232        exit 1
233fi
234
235if [ "$events" = "libevent" ]; then
236        if ! [ -f "${libevent}include/event.h" ]; then
237                echo
238                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
239                echo 'its location using the --libevent= argument. (Example: If event.h is in'
240                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
241        fi
242       
243        echo '#define EVENTS_LIBEVENT' >> config.h
244        cat <<EOF>>Makefile.settings
245EFLAGS+=-levent -L${libevent}lib
246CFLAGS+=-I${libevent}include
247EOF
248elif [ "$events" = "glib" ]; then
249        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
250        echo '#define EVENTS_GLIB' >> config.h
251else
252        echo
253        echo 'ERROR: Unknown event handler specified.'
254        exit 1
255fi
256echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
257
258detect_gnutls()
259{
260        if $PKG_CONFIG --exists gnutls; then
261                cat <<EOF>>Makefile.settings
262EFLAGS+=`$PKG_CONFIG --libs gnutls`
263CFLAGS+=`$PKG_CONFIG --cflags gnutls`
264EOF
265                ssl=gnutls
266                ret=1
267        elif libgnutls-config --version > /dev/null 2> /dev/null; then
268                cat <<EOF>>Makefile.settings
269EFLAGS+=`libgnutls-config --libs`
270CFLAGS+=`libgnutls-config --cflags`
271EOF
272               
273                ssl=gnutls
274                ret=1;
275        else
276                ret=0;
277        fi;
278}
279
280detect_nss()
281{
282        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG mozilla-nss; then
283                cat<<EOF>>Makefile.settings
284EFLAGS+=`$PKG_CONFIG --libs mozilla-nss`
285CFLAGS+=`$PKG_CONFIG --cflags mozilla-nss`
286EOF
287               
288                ssl=nss
289                ret=1;
290        else
291                ret=0;
292        fi;
293}
294
295detect_ldap()
296{
297        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
298        if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then
299                cat<<EOF>>Makefile.settings
300EFLAGS+=-lldap
301CFLAGS+=
302EOF
303                ldap=1
304                rm -f $TMPFILE
305                ret=1
306        else
307                ldap=0
308                ret=0
309        fi
310}
311
312RESOLV_TESTCODE='
313#include <arpa/nameser.h>
314#include <resolv.h>
315
316int main()
317{
318        ns_initparse( NULL, 0, NULL );
319        ns_parserr( NULL, ns_s_an, 0, NULL );
320}
321'
322
323detect_resolv_dynamic()
324{
325        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
326        ret=1
327        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -lresolv >/dev/null 2>/dev/null
328        if [ "$?" = "0" ]; then
329                echo 'EFLAGS+=-lresolv' >> Makefile.settings
330                ret=0
331        fi
332
333        rm -f $TMPFILE
334        return $ret
335}
336
337detect_resolv_static()
338{
339        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
340        ret=1
341        for i in $systemlibdirs; do
342                if [ -f $i/libresolv.a ]; then
343                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
344                        if [ "$?" = "0" ]; then
345                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
346                                ret=0
347                        fi
348                fi
349        done
350
351        rm -f $TMPFILE
352        return $ret
353}
354
355if [ "$ssl" = "auto" ]; then
356        detect_gnutls
357        if [ "$ret" = "0" ]; then
358                detect_nss
359        fi
360elif [ "$ssl" = "gnutls" ]; then
361        detect_gnutls
362elif [ "$ssl" = "nss" ]; then
363        detect_nss
364elif [ "$ssl" = "sspi" ]; then
365        echo
366elif [ "$ssl" = "openssl" ]; then
367        echo
368        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
369        echo 'install of OpenSSL (including devel/header files) before reporting'
370        echo 'compilation problems.'
371        echo
372        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
373        echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better'
374        echo 'supported by us. However, on many BSD machines, OpenSSL can be considered'
375        echo 'part of the operating system, which makes it GPL-compatible.'
376        echo
377        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
378        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
379        echo
380        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
381        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
382        echo 'package, you really should use GnuTLS or NSS instead.'
383        echo
384        echo 'Also, the OpenSSL license requires us to say this:'
385        echo ' *    "This product includes software developed by the OpenSSL Project'
386        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
387       
388        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
389       
390        ret=1
391elif [ "$ssl" = "bogus" ]; then
392        echo
393        echo 'Using bogus SSL code. This means some features will not work properly.'
394       
395        ## Yes, you, at the console! How can you authenticate if you don't have any SSL!?
396        if [ "$msn" = "1" -o "$yahoo" = "1" ]; then
397                echo
398                echo 'WARNING: The MSN and Yahoo! modules will not work without SSL. Disabling.'
399                msn=0
400                yahoo=0
401        fi
402       
403        ret=1
404else
405        echo
406        echo 'ERROR: Unknown SSL library specified.'
407        exit 1
408fi
409
410if [ "$ret" = "0" ]; then
411        echo
412        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
413        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
414        echo '       so if you want to use that, you have to select it by hand. If you don'\''t'
415        echo '       need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)'
416       
417        exit 1
418fi;
419
420echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
421
422if detect_resolv_dynamic || detect_resolv_static; then
423        echo '#define HAVE_RESOLV_A' >> config.h
424fi
425
426STORAGES="xml"
427
428if [ "$ldap" = "auto" ]; then
429        detect_ldap
430fi
431
432if [ "$ldap" = 0 ]; then
433        echo "#undef WITH_LDAP" >> config.h
434elif [ "$ldap" = 1 ]; then
435        echo
436        echo 'LDAP support is a work in progress and does NOT work AT ALL right now.'
437        echo
438        exit 1
439       
440        echo "#define WITH_LDAP 1" >> config.h
441        STORAGES="$STORAGES ldap"
442fi
443
444for i in $STORAGES; do
445        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
446done
447echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
448
449if [ "$strip" = 0 ]; then
450        echo "STRIP=\# skip strip" >> Makefile.settings;
451else
452        if [ "$debug" = 1 ]; then
453                echo
454                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
455                echo 'STRIP=\# skip strip' >> Makefile.settings
456                strip=0;
457        elif [ -n "$STRIP" ]; then
458                echo "STRIP=$STRIP" >> Makefile.settings;
459        elif type strip > /dev/null 2> /dev/null; then
460                echo "STRIP=strip" >> Makefile.settings;
461        else
462                echo
463                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
464                echo 'STRIP=\# skip strip' >> Makefile.settings
465                strip=0;
466        fi;
467fi
468
469if [ "$gcov" = "1" ]; then
470        echo "CFLAGS+=--coverage" >> Makefile.settings
471        echo "EFLAGS+=--coverage" >> Makefile.settings
472fi
473
474if [ "$plugins" = 0 ]; then
475        echo '#undef WITH_PLUGINS' >> config.h
476else
477        echo '#define WITH_PLUGINS' >> config.h
478fi
479
480if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then
481        echo
482        echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.'
483        echo 'Install xmlto if you want online help to work.'
484fi
485
486echo
487if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
488        nick=`bzr nick`
489        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
490                nick="-$nick"
491        else
492                nick=""
493        fi
494        rev=`bzr revno`
495        echo 'Using bzr revision #'$rev' as version number'
496        BITLBEE_VERSION=\"bzr$nick-$rev\"
497fi
498
499if [ -n "$BITLBEE_VERSION" ]; then
500        echo 'Spoofing version number: '$BITLBEE_VERSION
501        echo '#undef BITLBEE_VERSION' >> config.h
502        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
503        echo
504fi
505
506if ! make helloworld > /dev/null 2>&1; then
507        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
508        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
509        echo "under the name 'gmake'."
510        echo
511        if gmake helloworld > /dev/null 2>&1; then
512                echo "gmake seems to be available on your machine, great."
513                echo
514        else
515                echo "gmake is not installed (or not working). Please try to install it."
516                echo
517        fi
518fi
519
520cat <<EOF>bitlbee.pc
521prefix=$prefix
522includedir=$includedir
523
524Name: bitlbee
525Description: IRC to IM gateway
526Requires: glib-2.0
527Version: $BITLBEE_VERSION
528Libs:
529Cflags: -I\${includedir}
530
531EOF
532
533protocols=''
534protoobjs=''
535
536if [ "$purple" = 0 ]; then
537        echo '#undef WITH_PURPLE' >> config.h
538else
539        if ! $PKG_CONFIG purple; then
540                echo
541                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
542                exit 1
543        fi
544        echo '#define WITH_PURPLE' >> config.h
545        cat<<EOF>>Makefile.settings
546EFLAGS += $($PKG_CONFIG purple --libs)
547PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
548EOF
549        protocols=$protocols'purple '
550        protoobjs=$protoobjs'purple_mod.o '
551
552        # Having both libpurple and native IM modules in one binary may
553        # do strange things. Let's not do that.
554        msn=0
555        jabber=0
556        oscar=0
557        yahoo=0
558        twitter=0
559       
560        if [ "$events" = "libevent" ]; then
561                echo
562                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
563                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
564                echo 'libpurple + libevent is *not* recommended!'
565        fi
566fi
567
568if [ "$msn" = 0 ]; then
569        echo '#undef WITH_MSN' >> config.h
570else
571        echo '#define WITH_MSN' >> config.h
572        protocols=$protocols'msn '
573        protoobjs=$protoobjs'msn_mod.o '
574fi
575
576if [ "$jabber" = 0 ]; then
577        echo '#undef WITH_JABBER' >> config.h
578else
579        echo '#define WITH_JABBER' >> config.h
580        protocols=$protocols'jabber '
581        protoobjs=$protoobjs'jabber_mod.o '
582fi
583
584if [ "$oscar" = 0 ]; then
585        echo '#undef WITH_OSCAR' >> config.h
586else
587        echo '#define WITH_OSCAR' >> config.h
588        protocols=$protocols'oscar '
589        protoobjs=$protoobjs'oscar_mod.o '
590fi
591
592if [ "$yahoo" = 0 ]; then
593        echo '#undef WITH_YAHOO' >> config.h
594else
595        echo '#define WITH_YAHOO' >> config.h
596        protocols=$protocols'yahoo '
597        protoobjs=$protoobjs'yahoo_mod.o '
598fi
599
600if [ "$twitter" = 0 ]; then
601        echo '#undef WITH_TWITTER' >> config.h
602else
603        echo '#define WITH_TWITTER' >> config.h
604        protocols=$protocols'twitter '
605        protoobjs=$protoobjs'twitter_mod.o '
606fi
607
608if [ "$protocols" = "PROTOCOLS = " ]; then
609        echo "Warning: You haven't selected any communication protocol to compile!"
610        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
611fi
612
613echo "PROTOCOLS = $protocols" >> Makefile.settings
614echo "PROTOOBJS = $protoobjs" >> Makefile.settings
615
616echo Architecture: $arch
617case "$arch" in
618Linux )
619;;
620GNU/* )
621;;
622*BSD )
623;;
624Darwin )
625        echo 'STRIP=\# skip strip' >> Makefile.settings
626;;
627IRIX )
628;;
629SunOS )
630        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
631        echo 'STRIP=\# skip strip' >> Makefile.settings
632;;
633AIX )
634        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
635;;
636CYGWIN* )
637        echo 'Cygwin is not officially supported.'
638;;
639Windows )
640;;
641* )
642        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
643        echo 'Please report any problems at http://bugs.bitlbee.org/.'
644;;
645esac
646
647if [ -n "$target" ]; then
648        echo "Cross-compiling for: $target"
649fi
650
651echo
652echo 'Configuration done:'
653
654if [ "$debug" = "1" ]; then
655        echo '  Debugging enabled.'
656else
657        echo '  Debugging disabled.'
658fi
659
660if [ "$strip" = "1" ]; then
661        echo '  Binary stripping enabled.'
662else
663        echo '  Binary stripping disabled.'
664fi
665
666echo '  Using event handler: '$events
667echo '  Using SSL library: '$ssl
668echo '  Building with these storage backends: '$STORAGES
669
670if [ -n "$protocols" ]; then
671        echo '  Building with these protocols:' $protocols
672else
673        echo '  Building without IM-protocol support. We wish you a lot of fun...'
674fi
Note: See TracBrowser for help on using the repository browser.