source: configure @ 69aaf14

Last change on this file since 69aaf14 was 69aaf14, checked in by Jelmer Vernooij <jelmer@…>, at 2008-04-02T15:40:33Z

Merge several portability improvements.

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