source: configure @ 814aa52

Last change on this file since 814aa52 was 814aa52, checked in by Sven Moritz Hallberg <pesco@…>, at 2010-06-03T11:00:45Z

merge in bitlbee 1.2.6

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