source: configure @ f9dbc99

Last change on this file since f9dbc99 was f9dbc99, checked in by Jelmer Vernooij <jelmer@…>, at 2008-04-02T14:37:13Z

Merge gnutls detection fix.

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