source: configure @ 85d7b85

Last change on this file since 85d7b85 was 85d7b85, checked in by Jelmer Vernooij <jelmer@…>, at 2008-04-02T14:22:57Z

Merge trunk.

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