source: configure @ 670204f

Last change on this file since 670204f was 670204f, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-10-22T12:43:40Z

Copied 1.0.x changelogs, disabled LDAP support in configure (because the
code just doesn't work yet) and added GLib version detection. (GLib 2.4
and up *should* work.)

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