source: configure @ c227706

Last change on this file since c227706 was d8d63a2, checked in by Jelmer Vernooij <jelmer@…>, at 2006-12-05T20:40:17Z

[merge] wilmer

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