source: configure @ 6738a67

Last change on this file since 6738a67 was 6738a67, checked in by Sven Moritz Hallberg <pesco@…>, at 2008-07-16T23:22:52Z

merge in latest trunk

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