source: configure @ 16b5f86

Last change on this file since 16b5f86 was e8a6211, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-10-22T17:00:15Z

Merge from main tree.

  • Property mode set to 100755
File size: 11.8 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
330for i in /lib /usr/lib /usr/local/lib; do
331        if [ -e $i/libresolv.a ]; then
332                echo '#define HAVE_RESOLV_A' >> config.h
333                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
334                break
335        fi
336done
337
338STORAGES="text xml"
339
340if [ "$ldap" = "auto" ]; then
341        detect_ldap
342fi
343
344if [ "$ldap" = 0 ]; then
345        echo "#undef WITH_LDAP" >> config.h
346elif [ "$ldap" = 1 ]; then
347        echo "#define WITH_LDAP 1" >> config.h
348        STORAGES="$STORAGES ldap"
349fi
350
351for i in $STORAGES; do
352        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
353done
354echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
355
356if [ "$strip" = 0 ]; then
357        echo "STRIP=\# skip strip" >> Makefile.settings;
358else
359        if [ "$debug" = 1 ]; then
360                echo
361                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
362                echo 'STRIP=\# skip strip' >> Makefile.settings
363                strip=0;
364        elif [ -n "$STRIP" ]; then
365                echo "STRIP=$STRIP" >> Makefile.settings;
366        elif type strip > /dev/null 2> /dev/null; then
367                echo "STRIP=strip" >> Makefile.settings;
368        else
369                echo
370                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
371                echo 'STRIP=\# skip strip' >> Makefile.settings
372                strip=0;
373        fi;
374fi
375
376echo
377if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
378        nick=`bzr nick`
379        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
380                nick="-$nick"
381        else
382                nick=""
383        fi
384        rev=`bzr revno`
385        echo 'Using bzr revision #'$rev' as version number'
386        BITLBEE_VERSION=\"bzr$nick-$rev\"
387fi
388
389if [ -n "$BITLBEE_VERSION" ]; then
390        echo 'Spoofing version number: '$BITLBEE_VERSION
391        echo '#undef BITLBEE_VERSION' >> config.h
392        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
393        echo
394fi
395
396cat <<EOF>bitlbee.pc
397prefix=$prefix
398includedir=$includedir
399
400Name: bitlbee
401Description: IRC to IM gateway
402Requires: glib-2.0
403Version: $BITLBEE_VERSION
404Libs:
405Cflags: -I\${includedir}
406
407EOF
408
409protocols=''
410protoobjs=''
411
412if [ "$msn" = 0 ]; then
413        echo '#undef WITH_MSN' >> config.h
414else
415        echo '#define WITH_MSN' >> config.h
416        protocols=$protocols'msn '
417        protoobjs=$protoobjs'msn_mod.o '
418fi
419
420if [ "$jabber" = 0 ]; then
421        echo '#undef WITH_JABBER' >> config.h
422else
423        echo '#define WITH_JABBER' >> config.h
424        protocols=$protocols'jabber '
425        protoobjs=$protoobjs'jabber_mod.o '
426fi
427
428if [ "$oscar" = 0 ]; then
429        echo '#undef WITH_OSCAR' >> config.h
430else
431        echo '#define WITH_OSCAR' >> config.h
432        protocols=$protocols'oscar '
433        protoobjs=$protoobjs'oscar_mod.o '
434fi
435
436if [ "$yahoo" = 0 ]; then
437        echo '#undef WITH_YAHOO' >> config.h
438else
439        echo '#define WITH_YAHOO' >> config.h
440        protocols=$protocols'yahoo '
441        protoobjs=$protoobjs'yahoo_mod.o '
442fi
443
444if [ "$protocols" = "PROTOCOLS = " ]; then
445        echo "WARNING: You haven't selected any communication protocol to compile!"
446        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
447fi
448
449echo "PROTOCOLS = $protocols" >> Makefile.settings
450echo "PROTOOBJS = $protoobjs" >> Makefile.settings
451
452echo Architecture: $arch
453case "$arch" in
454Linux )
455;;
456GNU/* )
457;;
458*BSD )
459;;
460Darwin )
461;;
462IRIX )
463;;
464SunOS )
465        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
466        echo 'STRIP=\# skip strip' >> Makefile.settings
467;;
468CYGWIN* )
469        echo 'Cygwin is not officially supported.'
470;;
471* )
472        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
473        echo 'Please report any problems at http://bugs.bitlbee.org/.'
474;;
475esac
476
477echo
478echo 'Configuration done:'
479
480if [ "$debug" = "1" ]; then
481        echo '  Debugging enabled.'
482else
483        echo '  Debugging disabled.'
484fi
485
486if [ "$strip" = "1" ]; then
487        echo '  Binary stripping enabled.'
488else
489        echo '  Binary stripping disabled.'
490fi
491
492echo '  Using event handler: '$events
493echo '  Using SSL library: '$ssl
494echo '  Building with these storage backends: '$STORAGES
495
496if [ -n "$protocols" ]; then
497        echo '  Building with these protocols:' $protocols
498else
499        echo '  Building without IM-protocol support. We wish you a lot of fun...'
500fi
Note: See TracBrowser for help on using the repository browser.