source: configure @ 2309152

Last change on this file since 2309152 was ca0981a, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-05-13T23:05:07Z

As long as this is a separate branch, enabling purple by default's not a
bad idea.

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