source: configure @ 66b9e86e

Last change on this file since 66b9e86e was 66b9e86e, checked in by Jelmer Vernooij <jelmer@…>, at 2006-07-07T13:33:31Z

Add support for checking test suite coverage using gcov.

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