source: configure @ 846cec61

Last change on this file since 846cec61 was b3c467b, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-06-28T09:59:33Z

Cleaned up Makefiles + configure: Cleaning up bitlbee.pc, removed the second
piece of libevent probing code that mysteriously appeared (?), better handling
of storage backends, an SSL module is now always included (so BitlBee can be
compiled again when building without MSN- and Jabber-support (http_client also
depends on SSL libs and can't be disabled)), oh, and fixed a compiler warning.

  • Property mode set to 100755
File size: 11.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/'
11bindir='$prefix/sbin/'
12etcdir='$prefix/etc/bitlbee/'
13mandir='$prefix/share/man/'
14datadir='$prefix/share/bitlbee/'
15config='/var/lib/bitlbee/'
[85cf37f]16plugindir='$prefix/lib/bitlbee/'
17includedir='$prefix/include/bitlbee/'
18libevent='/usr/'
[34b17d9]19pidfile='/var/run/bitlbee.pid'
[6dff9d4]20ipcsocket='/var/run/bitlbee'
[e506d6c]21pcdir='$prefix/lib/pkgconfig'
[b7d3cc34]22
23msn=1
24jabber=1
25oscar=1
26yahoo=1
27
28debug=0
29strip=1
30ipv6=1
[85cf37f]31
32events=glib
[f32d557]33ldap=auto
[b7d3cc34]34ssl=auto
35
36arch=`uname -s`
37cpu=`uname -m`
38
39echo BitlBee configure
40
41while [ -n "$1" ]; do
42        e="`expr "X$1" : 'X--\(.*=.*\)'`"
43        if [ -z "$e" ]; then
44                cat<<EOF
45
46Usage: $0 [OPTIONS]
47
48Option          Description                             Default
49
50--prefix=...    Directories to put files in             $prefix
51--bindir=...                                            $bindir
52--etcdir=...                                            $etcdir
53--mandir=...                                            $mandir
54--datadir=...                                           $datadir
[7b23afd]55--plugindir=...                                         $plugindir
[34b17d9]56--pidfile=...                                           $pidfile
[b7d3cc34]57--config=...                                            $config
[6dff9d4]58--ipcsocket=...                                         $ipcsocket
[b7d3cc34]59
60--msn=0/1       Disable/enable MSN part                 $msn
61--jabber=0/1    Disable/enable Jabber part              $jabber
62--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
63--yahoo=0/1     Disable/enable Yahoo part               $yahoo
64
65--debug=0/1     Disable/enable debugging                $debug
66--strip=0/1     Disable/enable binary stripping         $strip
67
68--ipv6=0/1      IPv6 socket support                     $ipv6
69
[f32d557]70--ldap=0/1/auto LDAP support                            $ldap
[f665dab]71
[85cf37f]72--events=...    Event handler (glib, libevent)          $events
[b7d3cc34]73--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
74                                                        $ssl
75EOF
76                exit;
77        fi
78        eval "$e"
79        shift;
80done
81
82# Expand $prefix and get rid of double slashes
83bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'`
84etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'`
85mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'`
86datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
87config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
[7b23afd]88plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
[85cf37f]89includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'`
90libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'`
91
[6dff9d4]92pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
93ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
[e506d6c]94pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
[b7d3cc34]95
96cat<<EOF>Makefile.settings
97## BitlBee settings, generated by configure
98PREFIX=$prefix
99BINDIR=$bindir
100ETCDIR=$etcdir
101MANDIR=$mandir
102DATADIR=$datadir
[7b23afd]103PLUGINDIR=$plugindir
[b7d3cc34]104CONFIG=$config
[6dff9d4]105IPCSOCKET=$ipcsocket
[e506d6c]106INCLUDEDIR=$includedir
107PCDIR=$pcdir
[b7d3cc34]108
109ARCH=$arch
110CPU=$cpu
111OUTFILE=bitlbee
112
113DESTDIR=
114LFLAGS=
115EFLAGS=
116EOF
117
118cat<<EOF>config.h
119/* BitlBee settings, generated by configure
120   
121   Do *NOT* use any of these defines in your code without thinking twice, most
122   of them can/will be overridden at run-time */
123
124#define CONFIG "$config"
125#define ETCDIR "$etcdir"
126#define VARDIR "$datadir"
[7b23afd]127#define PLUGINDIR "$plugindir"
[34b17d9]128#define PIDFILE "$pidfile"
[6dff9d4]129#define IPCSOCKET "$ipcsocket"
[b7d3cc34]130#define ARCH "$arch"
131#define CPU "$cpu"
132EOF
133
134if [ "$ipv6" = "1" ]; then
135        echo '#define IPV6' >> config.h
136fi
137
138if [ "$debug" = "1" ]; then
139        echo 'CFLAGS=-g' >> Makefile.settings
140        echo 'DEBUG=1' >> Makefile.settings
141        echo '#define DEBUG' >> config.h
142else
143        echo 'CFLAGS=-O3' >> Makefile.settings
144fi
145
[df1694b]146echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings
[b7d3cc34]147
[f712188]148echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
149
[b7d3cc34]150if [ -n "$CC" ]; then
[5973412]151        CC=$CC
[b7d3cc34]152elif type gcc > /dev/null 2> /dev/null; then
[5973412]153        CC=gcc
[b7d3cc34]154elif type cc > /dev/null 2> /dev/null; then
[5973412]155        CC=cc
[b7d3cc34]156else
157        echo 'Cannot find a C compiler, aborting.'
158        exit 1;
159fi
160
[5973412]161echo "CC=$CC" >> Makefile.settings;
162
[b7d3cc34]163if [ -n "$LD" ]; then
164        echo "LD=$LD" >> Makefile.settings;
165elif type ld > /dev/null 2> /dev/null; then
166        echo "LD=ld" >> Makefile.settings;
167else
168        echo 'Cannot find ld, aborting.'
169        exit 1;
170fi
171
[32c632f]172if [ -z "$PKG_CONFIG" ]; then
173        PKG_CONFIG=pkg-config
174fi
175
176if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
[b7d3cc34]177        cat<<EOF>>Makefile.settings
[32c632f]178EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
179CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
[b7d3cc34]180EOF
181else
[574af7e]182        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
[b7d3cc34]183        exit 1;
184fi
185
[85cf37f]186if [ "$events" = "libevent" ]; then
187        if ! [ -e "${libevent}include/event.h" ]; then
188                echo
189                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
190                echo 'its location using the --libevent= argument. (Example: If event.h is in'
191                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
192        fi
193       
194        echo '#define EVENTS_LIBEVENT' >> config.h
195        cat <<EOF>>Makefile.settings
196EFLAGS+=-levent -L${libevent}lib
197CFLAGS+=-I${libevent}include
198EOF
199elif [ "$events" = "glib" ]; then
200        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
201        echo '#define EVENTS_GLIB' >> config.h
202else
203        echo
204        echo 'ERROR: Unknown event handler specified.'
205        exit 1
[b7d3cc34]206fi
[85cf37f]207echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
[b7d3cc34]208
209detect_gnutls()
210{
211        if libgnutls-config --version > /dev/null 2> /dev/null; then
212                cat <<EOF>>Makefile.settings
213EFLAGS+=`libgnutls-config --libs`
214CFLAGS+=`libgnutls-config --cflags`
215EOF
216               
217                ssl=gnutls
218                ret=1;
219        else
220                ret=0;
221        fi;
222}
223
224detect_nss()
225{
[32c632f]226        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG mozilla-nss; then
[b7d3cc34]227                cat<<EOF>>Makefile.settings
[32c632f]228EFLAGS+=`$PKG_CONFIG --libs mozilla-nss`
229CFLAGS+=`$PKG_CONFIG --cflags mozilla-nss`
[b7d3cc34]230EOF
231               
232                ssl=nss
233                ret=1;
234        else
235                ret=0;
236        fi;
237}
238
[f32d557]239detect_ldap()
[f665dab]240{
[5973412]241        TMPFILE=`mktemp`
242        if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then
[f665dab]243                cat<<EOF>>Makefile.settings
[5973412]244EFLAGS+=-lldap
245CFLAGS+=
[f665dab]246EOF
[f32d557]247                ldap=1
[5973412]248                rm -f $TMPFILE
[f665dab]249                ret=1
250        else
[5973412]251                ldap=0
[f665dab]252                ret=0
253        fi
254}
255
[b3c467b]256if [ "$ssl" = "auto" ]; then
257        detect_gnutls
258        if [ "$ret" = "0" ]; then
259                detect_nss
[b7d3cc34]260        fi
[b3c467b]261elif [ "$ssl" = "gnutls" ]; then
262        detect_gnutls
263elif [ "$ssl" = "nss" ]; then
264        detect_nss
265elif [ "$ssl" = "openssl" ]; then
266        echo
267        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
268        echo 'install of OpenSSL (including devel/header files) before reporting'
269        echo 'compilation problems.'
270        echo
271        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
272        echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better'
273        echo 'supported by us. However, on many BSD machines, OpenSSL can be considered'
274        echo 'part of the operating system, which makes it GPL-compatible.'
275        echo
276        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
277        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
278        echo
279        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
280        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
281        echo 'package, you really should use GnuTLS or NSS instead.'
282        echo
283        echo 'Also, the OpenSSL license requires us to say this:'
284        echo ' *    "This product includes software developed by the OpenSSL Project'
285        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
[b7d3cc34]286       
[b3c467b]287        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
288       
289        ret=1
290elif [ "$ssl" = "bogus" ]; then
291        echo
292        echo 'Using bogus SSL code. This means some features have to be disabled.'
293       
294        ## Yes, you, at the console! How can you authenticate if you don't have any SSL!?
295        if [ "$msn" = "1" ]; then
[b7d3cc34]296                echo
[b3c467b]297                echo 'Real SSL support is necessary for MSN authentication, will build without'
298                echo 'MSN protocol support.'
299                msn=0
300        fi
[b7d3cc34]301       
[b3c467b]302        ret=1
303else
304        echo
305        echo 'ERROR: Unknown SSL library specified.'
306        exit 1
[b7d3cc34]307fi
308
[b3c467b]309if [ "$ret" = "0" ]; then
310        echo
311        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
312        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
313        echo '       so if you want to use that, you have to select it by hand. If you don'\''t'
314        echo '       need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)'
315       
316        exit 1
317fi;
318
319echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
320
321STORAGES="text xml"
322
[f32d557]323if [ "$ldap" = "auto" ]; then
324        detect_ldap
[f665dab]325fi
326
[f32d557]327if [ "$ldap" = 0 ]; then
[5973412]328        echo "#undef WITH_LDAP" >> config.h
[f32d557]329elif [ "$ldap" = 1 ]; then
[5973412]330        echo "#define WITH_LDAP 1" >> config.h
[b3c467b]331        STORAGES="$STORAGES ldap"
[f665dab]332fi
333
[b3c467b]334for i in $STORAGES; do
335        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
336done
337echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
338
[b7d3cc34]339if [ "$strip" = 0 ]; then
340        echo "STRIP=\# skip strip" >> Makefile.settings;
341else
342        if [ "$debug" = 1 ]; then
343                echo
344                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
345                echo 'STRIP=\# skip strip' >> Makefile.settings
346                strip=0;
347        elif [ -n "$STRIP" ]; then
348                echo "STRIP=$STRIP" >> Makefile.settings;
349        elif type strip > /dev/null 2> /dev/null; then
350                echo "STRIP=strip" >> Makefile.settings;
351        else
352                echo
353                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
354                echo 'STRIP=\# skip strip' >> Makefile.settings
355                strip=0;
356        fi;
357fi
358
[ffea9b9]359echo
[a014331]360if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
361        nick=`bzr nick`
362        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
363                nick="-$nick"
364        else
365                nick=""
366        fi
[ffea9b9]367        rev=`bzr revno`
368        echo 'Using bzr revision #'$rev' as version number'
[a014331]369        BITLBEE_VERSION=\"bzr$nick-$rev\"
[ffea9b9]370fi
371
[b7d3cc34]372if [ -n "$BITLBEE_VERSION" ]; then
373        echo 'Spoofing version number: '$BITLBEE_VERSION
374        echo '#undef BITLBEE_VERSION' >> config.h
[ffea9b9]375        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
376        echo
[b7d3cc34]377fi
378
[e506d6c]379cat <<EOF>bitlbee.pc
380prefix=$prefix
381includedir=$includedir
382
383Name: bitlbee
384Description: IRC to IM gateway
385Requires: glib-2.0
386Version: $BITLBEE_VERSION
387Libs:
388Cflags: -I\${includedir}
389
390EOF
391
[b7d3cc34]392protocols=''
393protoobjs=''
394
395if [ "$msn" = 0 ]; then
396        echo '#undef WITH_MSN' >> config.h
397else
398        echo '#define WITH_MSN' >> config.h
399        protocols=$protocols'msn '
[b5a22e3]400        protoobjs=$protoobjs'msn_mod.o '
[b7d3cc34]401fi
402
403if [ "$jabber" = 0 ]; then
404        echo '#undef WITH_JABBER' >> config.h
405else
406        echo '#define WITH_JABBER' >> config.h
407        protocols=$protocols'jabber '
[b5a22e3]408        protoobjs=$protoobjs'jabber_mod.o '
[b7d3cc34]409fi
410
411if [ "$oscar" = 0 ]; then
412        echo '#undef WITH_OSCAR' >> config.h
413else
414        echo '#define WITH_OSCAR' >> config.h
415        protocols=$protocols'oscar '
[b5a22e3]416        protoobjs=$protoobjs'oscar_mod.o '
[b7d3cc34]417fi
418
419if [ "$yahoo" = 0 ]; then
420        echo '#undef WITH_YAHOO' >> config.h
421else
422        echo '#define WITH_YAHOO' >> config.h
423        protocols=$protocols'yahoo '
[b5a22e3]424        protoobjs=$protoobjs'yahoo_mod.o '
[b7d3cc34]425fi
426
427if [ "$protocols" = "PROTOCOLS = " ]; then
428        echo "WARNING: You haven't selected any communication protocol to compile!"
[b3c467b]429        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
[b7d3cc34]430fi
431
432echo "PROTOCOLS = $protocols" >> Makefile.settings
433echo "PROTOOBJS = $protoobjs" >> Makefile.settings
434
435echo Architecture: $arch
436case "$arch" in
437Linux )
438;;
439GNU/* )
440;;
441*BSD )
442;;
443Darwin )
444;;
445IRIX )
446;;
[574af7e]447SunOS )
448        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
449        echo 'STRIP=\# skip strip' >> Makefile.settings
450;;
[b7d3cc34]451CYGWIN* )
452        echo 'Cygwin is not officially supported.'
453;;
454* )
[8d6c4b1]455        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
456        echo 'Please report any problems at http://bugs.bitlbee.org/.'
[b7d3cc34]457;;
458esac
459
460echo
461echo 'Configuration done:'
462
463if [ "$debug" = "1" ]; then
[b3c467b]464        echo '  Debugging enabled.'
[b7d3cc34]465else
[b3c467b]466        echo '  Debugging disabled.'
[b7d3cc34]467fi
468
469if [ "$strip" = "1" ]; then
[b3c467b]470        echo '  Binary stripping enabled.'
[b7d3cc34]471else
[b3c467b]472        echo '  Binary stripping disabled.'
[b7d3cc34]473fi
474
[b3c467b]475echo '  Using event handler: '$events
476echo '  Using SSL library: '$ssl
477echo '  Building with these storage backends: '$STORAGES
[b7d3cc34]478
479if [ -n "$protocols" ]; then
[b3c467b]480        echo '  Building with these protocols:' $protocols
[f665dab]481else
[b3c467b]482        echo '  Building without IM-protocol support. We wish you a lot of fun...'
[f665dab]483fi
Note: See TracBrowser for help on using the repository browser.