source: configure @ 5f8ab6a9

Last change on this file since 5f8ab6a9 was 5f8ab6a9, checked in by Sven Moritz Hallberg <pesco@…>, at 2010-06-03T10:41:03Z

merge in bitlbee 1.2.5

  • Property mode set to 100755
File size: 14.2 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'
22systemlibdirs="/lib /usr/lib /usr/local/lib"
23
24msn=1
25jabber=1
26oscar=1
27yahoo=1
28
29debug=0
30strip=1
31gcov=0
32plugins=1
33otr=auto
34
35events=glib
36ldap=0
37ssl=auto
38
39arch=`uname -s`
40cpu=`uname -m`
41
42GLIB_MIN_VERSION=2.4
43
44echo BitlBee configure
45
46while [ -n "$1" ]; do
47        e="`expr "X$1" : 'X--\(.*=.*\)'`"
48        if [ -z "$e" ]; then
49                cat<<EOF
50
51Usage: $0 [OPTIONS]
52
53Option          Description                             Default
54
55--prefix=...    Directories to put files in             $prefix
56--bindir=...                                            $bindir
57--etcdir=...                                            $etcdir
58--mandir=...                                            $mandir
59--datadir=...                                           $datadir
60--plugindir=...                                         $plugindir
61--pidfile=...                                           $pidfile
62--config=...                                            $config
63--ipcsocket=...                                         $ipcsocket
64
65--msn=0/1       Disable/enable MSN part                 $msn
66--jabber=0/1    Disable/enable Jabber part              $jabber
67--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
68--yahoo=0/1     Disable/enable Yahoo part               $yahoo
69
70--debug=0/1     Disable/enable debugging                $debug
71--strip=0/1     Disable/enable binary stripping         $strip
72--gcov=0/1      Disable/enable test coverage reporting  $gcov
73--plugins=0/1   Disable/enable plugins support          $plugins
74--otr=0/1       Disable/enable OTR encryption support   $otr
75
76--events=...    Event handler (glib, libevent)          $events
77--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
78                                                        $ssl
79
80--target=...    Cross compilation target                same as host
81EOF
82                exit;
83        fi
84        eval "$e"
85        shift;
86done
87
88# Expand $prefix and get rid of double slashes
89bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'`
90etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'`
91mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'`
92datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
93config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
94plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
95includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'`
96libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'`
97
98pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
99ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
100pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
101
102cat<<EOF>Makefile.settings
103## BitlBee settings, generated by configure
104PREFIX=$prefix
105BINDIR=$bindir
106ETCDIR=$etcdir
107MANDIR=$mandir
108DATADIR=$datadir
109PLUGINDIR=$plugindir
110CONFIG=$config
111INCLUDEDIR=$includedir
112PCDIR=$pcdir
113
114TARGET=$target
115ARCH=$arch
116CPU=$cpu
117
118DESTDIR=
119LFLAGS=
120EFLAGS=
121EOF
122
123cat<<EOF>config.h
124/* BitlBee settings, generated by configure
125   
126   Do *NOT* use any of these defines in your code without thinking twice, most
127   of them can/will be overridden at run-time */
128
129#define CONFIG "$config"
130#define ETCDIR "$etcdir"
131#define VARDIR "$datadir"
132#define PLUGINDIR "$plugindir"
133#define PIDFILE "$pidfile"
134#define IPCSOCKET "$ipcsocket"
135#define ARCH "$arch"
136#define CPU "$cpu"
137EOF
138
139
140
141if [ -n "$target" ]; then
142        PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
143        export PKG_CONFIG_LIBDIR
144        PATH=/usr/$target/bin:$PATH
145        CC=$target-cc
146        LD=$target-ld
147        systemlibdirs="/usr/$target/lib"
148fi
149
150
151if [ "$debug" = "1" ]; then
152        [ -z "$CFLAGS" ] && CFLAGS=-g
153        echo 'DEBUG=1' >> Makefile.settings
154        CFLAGS="$CFLAGS -DDEBUG"
155else
156        [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing"
157fi
158
159echo CFLAGS=$CFLAGS >> Makefile.settings
160echo CFLAGS+=-I`pwd` -iquote`pwd`/lib -iquote`pwd`/protocols -I. >> Makefile.settings
161
162echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
163
164if [ -n "$CC" ]; then
165        CC=$CC
166elif type gcc > /dev/null 2> /dev/null; then
167        CC=gcc
168elif type cc > /dev/null 2> /dev/null; then
169        CC=cc
170else
171        echo 'Cannot find a C compiler, aborting.'
172        exit 1;
173fi
174
175echo "CC=$CC" >> Makefile.settings;
176
177if [ -z "$LD" ]; then
178        if type ld > /dev/null 2> /dev/null; then
179                LD=ld
180        else
181                echo 'Cannot find ld, aborting.'
182                exit 1;
183        fi
184fi
185
186echo "LD=$LD" >> Makefile.settings
187
188if [ -z "$PKG_CONFIG" ]; then
189        PKG_CONFIG=pkg-config
190fi
191
192if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
193        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
194                cat<<EOF>>Makefile.settings
195EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
196CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
197EOF
198        else
199                echo
200                echo 'Found glib2 '`$PKG_CONFIG glib-2.0 --modversion`', but version '$GLIB_MIN_VERSION' or newer is required.'
201                exit 1
202        fi
203else
204        echo
205        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
206        exit 1
207fi
208
209if [ "$events" = "libevent" ]; then
210        if ! [ -f "${libevent}include/event.h" ]; then
211                echo
212                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
213                echo 'its location using the --libevent= argument. (Example: If event.h is in'
214                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
215        fi
216       
217        echo '#define EVENTS_LIBEVENT' >> config.h
218        cat <<EOF>>Makefile.settings
219EFLAGS+=-levent -L${libevent}lib
220CFLAGS+=-I${libevent}include
221EOF
222elif [ "$events" = "glib" ]; then
223        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
224        echo '#define EVENTS_GLIB' >> config.h
225else
226        echo
227        echo 'ERROR: Unknown event handler specified.'
228        exit 1
229fi
230echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
231
232detect_gnutls()
233{
234        if $PKG_CONFIG --exists gnutls; then
235                cat <<EOF>>Makefile.settings
236EFLAGS+=`$PKG_CONFIG --libs gnutls`
237CFLAGS+=`$PKG_CONFIG --cflags gnutls`
238EOF
239                ssl=gnutls
240                ret=1
241        elif libgnutls-config --version > /dev/null 2> /dev/null; then
242                cat <<EOF>>Makefile.settings
243EFLAGS+=`libgnutls-config --libs`
244CFLAGS+=`libgnutls-config --cflags`
245EOF
246               
247                ssl=gnutls
248                ret=1;
249        else
250                ret=0;
251        fi;
252}
253
254detect_nss()
255{
256        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG mozilla-nss; then
257                cat<<EOF>>Makefile.settings
258EFLAGS+=`$PKG_CONFIG --libs mozilla-nss`
259CFLAGS+=`$PKG_CONFIG --cflags mozilla-nss`
260EOF
261               
262                ssl=nss
263                ret=1;
264        else
265                ret=0;
266        fi;
267}
268
269detect_ldap()
270{
271        TMPFILE=$(mktemp)
272        if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then
273                cat<<EOF>>Makefile.settings
274EFLAGS+=-lldap
275CFLAGS+=
276EOF
277                ldap=1
278                rm -f $TMPFILE
279                ret=1
280        else
281                ldap=0
282                ret=0
283        fi
284}
285
286RESOLV_TESTCODE='
287#include <arpa/nameser.h>
288#include <resolv.h>
289
290int main()
291{
292        ns_initparse( NULL, 0, NULL );
293        ns_parserr( NULL, ns_s_an, 0, NULL );
294}
295'
296
297detect_resolv_dynamic()
298{
299        echo "$RESOLV_TESTCODE" | $CC -o /dev/null -x c - -lresolv >/dev/null 2>/dev/null
300        if [ "$?" = "0" ]; then
301                echo 'EFLAGS+=-lresolv' >> Makefile.settings
302                return 0
303        fi
304
305        return 1
306}
307
308detect_resolv_static()
309{
310        for i in $systemlibdirs; do
311                if [ -f $i/libresolv.a ]; then
312                        echo "$RESOLV_TESTCODE" | $CC -o /dev/null -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
313                        if [ "$?" = "0" ]; then
314                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
315                                return 0
316                        fi
317                fi
318        done
319
320        return 1
321}
322
323if [ "$ssl" = "auto" ]; then
324        detect_gnutls
325        if [ "$ret" = "0" ]; then
326                detect_nss
327        fi
328elif [ "$ssl" = "gnutls" ]; then
329        detect_gnutls
330elif [ "$ssl" = "nss" ]; then
331        detect_nss
332elif [ "$ssl" = "sspi" ]; then
333        echo
334elif [ "$ssl" = "openssl" ]; then
335        echo
336        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
337        echo 'install of OpenSSL (including devel/header files) before reporting'
338        echo 'compilation problems.'
339        echo
340        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
341        echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better'
342        echo 'supported by us. However, on many BSD machines, OpenSSL can be considered'
343        echo 'part of the operating system, which makes it GPL-compatible.'
344        echo
345        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
346        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
347        echo
348        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
349        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
350        echo 'package, you really should use GnuTLS or NSS instead.'
351        echo
352        echo 'Also, the OpenSSL license requires us to say this:'
353        echo ' *    "This product includes software developed by the OpenSSL Project'
354        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
355       
356        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
357       
358        ret=1
359elif [ "$ssl" = "bogus" ]; then
360        echo
361        echo 'Using bogus SSL code. This means some features will not work properly.'
362       
363        ## Yes, you, at the console! How can you authenticate if you don't have any SSL!?
364        if [ "$msn" = "1" -o "$yahoo" = "1" ]; then
365                echo
366                echo 'WARNING: The MSN and Yahoo! modules will not work without SSL. Disabling.'
367                msn=0
368                yahoo=0
369        fi
370       
371        ret=1
372else
373        echo
374        echo 'ERROR: Unknown SSL library specified.'
375        exit 1
376fi
377
378if [ "$ret" = "0" ]; then
379        echo
380        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
381        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
382        echo '       so if you want to use that, you have to select it by hand. If you don'\''t'
383        echo '       need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)'
384       
385        exit 1
386fi;
387
388echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
389
390if detect_resolv_dynamic || detect_resolv_static; then
391        echo '#define HAVE_RESOLV_A' >> config.h
392fi
393
394STORAGES="text xml"
395
396if [ "$ldap" = "auto" ]; then
397        detect_ldap
398fi
399
400if [ "$ldap" = 0 ]; then
401        echo "#undef WITH_LDAP" >> config.h
402elif [ "$ldap" = 1 ]; then
403        echo
404        echo 'LDAP support is a work in progress and does NOT work AT ALL right now.'
405        echo
406        exit 1
407       
408        echo "#define WITH_LDAP 1" >> config.h
409        STORAGES="$STORAGES ldap"
410fi
411
412for i in $STORAGES; do
413        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
414done
415echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
416
417if [ "$strip" = 0 ]; then
418        echo "STRIP=\# skip strip" >> Makefile.settings;
419else
420        if [ "$debug" = 1 ]; then
421                echo
422                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
423                echo 'STRIP=\# skip strip' >> Makefile.settings
424                strip=0;
425        elif [ -n "$STRIP" ]; then
426                echo "STRIP=$STRIP" >> Makefile.settings;
427        elif type strip > /dev/null 2> /dev/null; then
428                echo "STRIP=strip" >> Makefile.settings;
429        else
430                echo
431                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
432                echo 'STRIP=\# skip strip' >> Makefile.settings
433                strip=0;
434        fi;
435fi
436
437if [ "$gcov" = "1" ]; then
438        echo "CFLAGS+=--coverage" >> Makefile.settings
439        echo "EFLAGS+=--coverage" >> Makefile.settings
440fi
441
442if [ "$plugins" = 0 ]; then
443        echo '#undef WITH_PLUGINS' >> config.h
444else
445        echo '#define WITH_PLUGINS' >> config.h
446fi
447
448otrprefix=""
449for i in / /usr /usr/local; do
450        if [ -f ${i}/lib/libotr.a ]; then
451                otrprefix=${i}
452                break
453        fi
454done
455if [ "$otr" = "auto" ]; then
456        if [ -n "$otrprefix" ]; then
457                otr=1
458        else
459                otr=0
460        fi
461fi
462if [ "$otr" = 1 ]; then
463        echo '#define WITH_OTR' >> config.h
464        echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings
465        echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings
466else
467        echo '#undef WITH_OTR' >> config.h
468fi
469
470if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then
471        echo
472        echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.'
473        echo 'Install xmlto if you want online help to work.'
474fi
475
476echo
477if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
478        nick=`bzr nick`
479        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
480                nick="-$nick"
481        else
482                nick=""
483        fi
484        rev=`bzr revno`
485        echo 'Using bzr revision #'$rev' as version number'
486        BITLBEE_VERSION=\"bzr$nick-$rev\"
487fi
488
489if [ -n "$BITLBEE_VERSION" ]; then
490        echo 'Spoofing version number: '$BITLBEE_VERSION
491        echo '#undef BITLBEE_VERSION' >> config.h
492        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
493        echo
494fi
495
496cat <<EOF>bitlbee.pc
497prefix=$prefix
498includedir=$includedir
499
500Name: bitlbee
501Description: IRC to IM gateway
502Requires: glib-2.0
503Version: $BITLBEE_VERSION
504Libs:
505Cflags: -I\${includedir}
506
507EOF
508
509protocols=''
510protoobjs=''
511
512if [ "$msn" = 0 ]; then
513        echo '#undef WITH_MSN' >> config.h
514else
515        echo '#define WITH_MSN' >> config.h
516        protocols=$protocols'msn '
517        protoobjs=$protoobjs'msn_mod.o '
518fi
519
520if [ "$jabber" = 0 ]; then
521        echo '#undef WITH_JABBER' >> config.h
522else
523        echo '#define WITH_JABBER' >> config.h
524        protocols=$protocols'jabber '
525        protoobjs=$protoobjs'jabber_mod.o '
526fi
527
528if [ "$oscar" = 0 ]; then
529        echo '#undef WITH_OSCAR' >> config.h
530else
531        echo '#define WITH_OSCAR' >> config.h
532        protocols=$protocols'oscar '
533        protoobjs=$protoobjs'oscar_mod.o '
534fi
535
536if [ "$yahoo" = 0 ]; then
537        echo '#undef WITH_YAHOO' >> config.h
538else
539        echo '#define WITH_YAHOO' >> config.h
540        protocols=$protocols'yahoo '
541        protoobjs=$protoobjs'yahoo_mod.o '
542fi
543
544if [ "$protocols" = "PROTOCOLS = " ]; then
545        echo "Warning: You haven't selected any communication protocol to compile!"
546        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
547fi
548
549echo "PROTOCOLS = $protocols" >> Makefile.settings
550echo "PROTOOBJS = $protoobjs" >> Makefile.settings
551
552echo Architecture: $arch
553case "$arch" in
554Linux )
555;;
556GNU/* )
557;;
558*BSD )
559;;
560Darwin )
561        echo 'STRIP=\# skip strip' >> Makefile.settings
562;;
563IRIX )
564;;
565SunOS )
566        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
567        echo 'STRIP=\# skip strip' >> Makefile.settings
568;;
569AIX )
570        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
571;;
572CYGWIN* )
573        echo 'Cygwin is not officially supported.'
574;;
575Windows )
576;;
577* )
578        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
579        echo 'Please report any problems at http://bugs.bitlbee.org/.'
580;;
581esac
582
583if [ -n "$target" ]; then
584        echo "Cross-compiling for: $target"
585fi
586
587echo
588echo 'Configuration done:'
589
590if [ "$debug" = "1" ]; then
591        echo '  Debugging enabled.'
592else
593        echo '  Debugging disabled.'
594fi
595
596if [ "$strip" = "1" ]; then
597        echo '  Binary stripping enabled.'
598else
599        echo '  Binary stripping disabled.'
600fi
601
602if [ "$otr" = "1" ]; then
603        echo '  Off-the-Record (OTR) Messaging enabled.'
604else
605        echo '  Off-the-Record (OTR) Messaging disabled.'
606fi
607
608echo '  Using event handler: '$events
609echo '  Using SSL library: '$ssl
610echo '  Building with these storage backends: '$STORAGES
611
612if [ -n "$protocols" ]; then
613        echo '  Building with these protocols:' $protocols
614else
615        echo '  Building without IM-protocol support. We wish you a lot of fun...'
616fi
Note: See TracBrowser for help on using the repository browser.