source: configure @ fdba6bc

Last change on this file since fdba6bc was fb020ac, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-03-07T18:43:23Z

Merging in mainline, including improved away/status stuff.

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