source: configure @ 6a72a57

Last change on this file since 6a72a57 was 6a72a57, checked in by Jelmer Vernooij <jelmer@…>, at 2008-06-10T03:43:46Z

Move OUTFILE determination to Makefile rather than configure.

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