source: configure @ 4af7b4f

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

Use pkg-config file for gnutls if possible.

This allows building against a gnutls built for a an architecture other
than the host architecture.

  • 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
76EOF
77                exit;
78        fi
79        eval "$e"
80        shift;
81done
82
83# Expand $prefix and get rid of double slashes
84bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'`
85etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'`
86mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'`
87datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
88config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
89plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
90includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'`
91libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'`
92
93pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
94ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
95pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
96
97cat<<EOF>Makefile.settings
98## BitlBee settings, generated by configure
99PREFIX=$prefix
100BINDIR=$bindir
101ETCDIR=$etcdir
102MANDIR=$mandir
103DATADIR=$datadir
104PLUGINDIR=$plugindir
105CONFIG=$config
106INCLUDEDIR=$includedir
107PCDIR=$pcdir
108
109ARCH=$arch
110CPU=$cpu
111OUTFILE=bitlbee
112
113DESTDIR=
114LFLAGS=
115EFLAGS=
116EOF
117
118cat<<EOF>config.h
119/* BitlBee settings, generated by configure
120   
121   Do *NOT* use any of these defines in your code without thinking twice, most
122   of them can/will be overridden at run-time */
123
124#define CONFIG "$config"
125#define ETCDIR "$etcdir"
126#define VARDIR "$datadir"
127#define PLUGINDIR "$plugindir"
128#define PIDFILE "$pidfile"
129#define IPCSOCKET "$ipcsocket"
130#define ARCH "$arch"
131#define CPU "$cpu"
132EOF
133
134if [ "$debug" = "1" ]; then
135        [ -z "$CFLAGS" ] && CFLAGS=-g
136        echo 'DEBUG=1' >> Makefile.settings
137        CFLAGS="$CFLAGS -DDEBUG"
138else
139        [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing"
140fi
141
142echo CFLAGS=$CFLAGS >> Makefile.settings
143echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings
144
145echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
146
147if [ -n "$CC" ]; then
148        CC=$CC
149elif type gcc > /dev/null 2> /dev/null; then
150        CC=gcc
151elif type cc > /dev/null 2> /dev/null; then
152        CC=cc
153else
154        echo 'Cannot find a C compiler, aborting.'
155        exit 1;
156fi
157
158echo "CC=$CC" >> Makefile.settings;
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        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
175                cat<<EOF>>Makefile.settings
176EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
177CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
178EOF
179        else
180                echo
181                echo 'Found glib2 '`$PKG_CONFIG glib-2.0 --modversion`', but version '$GLIB_MIN_VERSION' or newer is required.'
182                exit 1
183        fi
184else
185        echo
186        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
187        exit 1
188fi
189
190if [ "$events" = "libevent" ]; then
191        if ! [ -f "${libevent}include/event.h" ]; then
192                echo
193                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
194                echo 'its location using the --libevent= argument. (Example: If event.h is in'
195                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
196        fi
197       
198        echo '#define EVENTS_LIBEVENT' >> config.h
199        cat <<EOF>>Makefile.settings
200EFLAGS+=-levent -L${libevent}lib
201CFLAGS+=-I${libevent}include
202EOF
203elif [ "$events" = "glib" ]; then
204        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
205        echo '#define EVENTS_GLIB' >> config.h
206else
207        echo
208        echo 'ERROR: Unknown event handler specified.'
209        exit 1
210fi
211echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
212
213detect_gnutls()
214{
215        if $PKG_CONFIG --exists gnutls; then
216                cat <<EOF>>Makefile.settings
217EFLAGS+=`$PKG_CONFIG --libs gnutls`
218CFLAGS+=`$PKG_CONFIG --cflags gnutls`
219EOF
220                ssl=gnutls
221                ret=1
222        elif 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
332for i in /lib /usr/lib /usr/local/lib; do
333        if [ -f $i/libresolv.a ]; then
334                echo '#define HAVE_RESOLV_A' >> config.h
335                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
336                break
337        fi
338done
339
340STORAGES="text xml"
341
342if [ "$ldap" = "auto" ]; then
343        detect_ldap
344fi
345
346if [ "$ldap" = 0 ]; then
347        echo "#undef WITH_LDAP" >> config.h
348elif [ "$ldap" = 1 ]; then
349        echo
350        echo 'LDAP support is a work in progress and does NOT work AT ALL right now.'
351        echo
352        exit 1
353       
354        echo "#define WITH_LDAP 1" >> config.h
355        STORAGES="$STORAGES ldap"
356fi
357
358for i in $STORAGES; do
359        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
360done
361echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
362
363if [ "$strip" = 0 ]; then
364        echo "STRIP=\# skip strip" >> Makefile.settings;
365else
366        if [ "$debug" = 1 ]; then
367                echo
368                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
369                echo 'STRIP=\# skip strip' >> Makefile.settings
370                strip=0;
371        elif [ -n "$STRIP" ]; then
372                echo "STRIP=$STRIP" >> Makefile.settings;
373        elif type strip > /dev/null 2> /dev/null; then
374                echo "STRIP=strip" >> Makefile.settings;
375        else
376                echo
377                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
378                echo 'STRIP=\# skip strip' >> Makefile.settings
379                strip=0;
380        fi;
381fi
382
383if [ "$gcov" = "1" ]; then
384        echo "CFLAGS+=-ftest-coverage -fprofile-arcs" >> Makefile.settings
385        echo "EFLAGS+=-lgcov" >> Makefile.settings
386fi
387
388if [ "$plugins" = 0 ]; then
389        echo '#undef WITH_PLUGINS' >> config.h
390else
391        echo '#define WITH_PLUGINS' >> config.h
392fi
393
394echo
395if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
396        nick=`bzr nick`
397        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
398                nick="-$nick"
399        else
400                nick=""
401        fi
402        rev=`bzr revno`
403        echo 'Using bzr revision #'$rev' as version number'
404        BITLBEE_VERSION=\"bzr$nick-$rev\"
405fi
406
407if [ -n "$BITLBEE_VERSION" ]; then
408        echo 'Spoofing version number: '$BITLBEE_VERSION
409        echo '#undef BITLBEE_VERSION' >> config.h
410        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
411        echo
412fi
413
414cat <<EOF>bitlbee.pc
415prefix=$prefix
416includedir=$includedir
417
418Name: bitlbee
419Description: IRC to IM gateway
420Requires: glib-2.0
421Version: $BITLBEE_VERSION
422Libs:
423Cflags: -I\${includedir}
424
425EOF
426
427protocols=''
428protoobjs=''
429
430if [ "$msn" = 0 ]; then
431        echo '#undef WITH_MSN' >> config.h
432else
433        echo '#define WITH_MSN' >> config.h
434        protocols=$protocols'msn '
435        protoobjs=$protoobjs'msn_mod.o '
436fi
437
438if [ "$jabber" = 0 ]; then
439        echo '#undef WITH_JABBER' >> config.h
440else
441        echo '#define WITH_JABBER' >> config.h
442        protocols=$protocols'jabber '
443        protoobjs=$protoobjs'jabber_mod.o '
444fi
445
446if [ "$oscar" = 0 ]; then
447        echo '#undef WITH_OSCAR' >> config.h
448else
449        echo '#define WITH_OSCAR' >> config.h
450        protocols=$protocols'oscar '
451        protoobjs=$protoobjs'oscar_mod.o '
452fi
453
454if [ "$yahoo" = 0 ]; then
455        echo '#undef WITH_YAHOO' >> config.h
456else
457        echo '#define WITH_YAHOO' >> config.h
458        protocols=$protocols'yahoo '
459        protoobjs=$protoobjs'yahoo_mod.o '
460fi
461
462if [ "$protocols" = "PROTOCOLS = " ]; then
463        echo "Warning: You haven't selected any communication protocol to compile!"
464        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
465fi
466
467echo "PROTOCOLS = $protocols" >> Makefile.settings
468echo "PROTOOBJS = $protoobjs" >> Makefile.settings
469
470echo Architecture: $arch
471case "$arch" in
472Linux )
473;;
474GNU/* )
475;;
476*BSD )
477;;
478Darwin )
479;;
480IRIX )
481;;
482SunOS )
483        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
484        echo 'STRIP=\# skip strip' >> Makefile.settings
485;;
486AIX )
487        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
488;;
489CYGWIN* )
490        echo 'Cygwin is not officially supported.'
491;;
492* )
493        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
494        echo 'Please report any problems at http://bugs.bitlbee.org/.'
495;;
496esac
497
498echo
499echo 'Configuration done:'
500
501if [ "$debug" = "1" ]; then
502        echo '  Debugging enabled.'
503else
504        echo '  Debugging disabled.'
505fi
506
507if [ "$strip" = "1" ]; then
508        echo '  Binary stripping enabled.'
509else
510        echo '  Binary stripping disabled.'
511fi
512
513echo '  Using event handler: '$events
514echo '  Using SSL library: '$ssl
515echo '  Building with these storage backends: '$STORAGES
516
517if [ -n "$protocols" ]; then
518        echo '  Building with these protocols:' $protocols
519else
520        echo '  Building without IM-protocol support. We wish you a lot of fun...'
521fi
Note: See TracBrowser for help on using the repository browser.