source: configure @ f618a4a

Last change on this file since f618a4a was 285b55d, checked in by Wilmer van der Gaast <wilmer@…>, at 2007-10-10T22:45:19Z

configure script now allows one to override CFLAGS. (Bug #171)

  • Property mode set to 100755
File size: 12.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'
[b7d3cc34]22
23msn=1
24jabber=1
25oscar=1
26yahoo=1
27
28debug=0
29strip=1
[66b9e86e]30gcov=0
[2abfbc5]31plugins=1
[b7d3cc34]32ipv6=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
74--ipv6=0/1      IPv6 socket support                     $ipv6
75
[85cf37f]76--events=...    Event handler (glib, libevent)          $events
[b7d3cc34]77--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
78                                                        $ssl
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
112ARCH=$arch
113CPU=$cpu
114OUTFILE=bitlbee
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
137if [ "$ipv6" = "1" ]; then
138        echo '#define IPV6' >> config.h
139fi
140
141if [ "$debug" = "1" ]; then
[285b55d]142        [ -z "$CFLAGS" ] && CFLAGS=-g
[b7d3cc34]143        echo 'DEBUG=1' >> Makefile.settings
144        echo '#define DEBUG' >> config.h
145else
[285b55d]146        [ -z "$CFLAGS" ] && CFLAGS=-O3
[b7d3cc34]147fi
148
[285b55d]149echo CFLAGS=$CFLAGS >> Makefile.settings
[df1694b]150echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings
[b7d3cc34]151
[f712188]152echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
153
[b7d3cc34]154if [ -n "$CC" ]; then
[5973412]155        CC=$CC
[b7d3cc34]156elif type gcc > /dev/null 2> /dev/null; then
[5973412]157        CC=gcc
[b7d3cc34]158elif type cc > /dev/null 2> /dev/null; then
[5973412]159        CC=cc
[b7d3cc34]160else
161        echo 'Cannot find a C compiler, aborting.'
162        exit 1;
163fi
164
[5973412]165echo "CC=$CC" >> Makefile.settings;
166
[b7d3cc34]167if [ -n "$LD" ]; then
168        echo "LD=$LD" >> Makefile.settings;
169elif type ld > /dev/null 2> /dev/null; then
170        echo "LD=ld" >> Makefile.settings;
171else
172        echo 'Cannot find ld, aborting.'
173        exit 1;
174fi
175
[32c632f]176if [ -z "$PKG_CONFIG" ]; then
177        PKG_CONFIG=pkg-config
178fi
179
180if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
[670204f]181        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
182                cat<<EOF>>Makefile.settings
[32c632f]183EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
184CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
[b7d3cc34]185EOF
[670204f]186        else
187                echo
188                echo 'Found glib2 '`$PKG_CONFIG glib-2.0 --modversion`', but version '$GLIB_MIN_VERSION' or newer is required.'
189                exit 1
190        fi
[b7d3cc34]191else
[670204f]192        echo
[574af7e]193        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
[670204f]194        exit 1
[b7d3cc34]195fi
196
[85cf37f]197if [ "$events" = "libevent" ]; then
198        if ! [ -e "${libevent}include/event.h" ]; then
199                echo
200                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
201                echo 'its location using the --libevent= argument. (Example: If event.h is in'
202                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
203        fi
204       
205        echo '#define EVENTS_LIBEVENT' >> config.h
206        cat <<EOF>>Makefile.settings
207EFLAGS+=-levent -L${libevent}lib
208CFLAGS+=-I${libevent}include
209EOF
210elif [ "$events" = "glib" ]; then
211        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
212        echo '#define EVENTS_GLIB' >> config.h
213else
214        echo
215        echo 'ERROR: Unknown event handler specified.'
216        exit 1
[b7d3cc34]217fi
[85cf37f]218echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
[b7d3cc34]219
220detect_gnutls()
221{
222        if libgnutls-config --version > /dev/null 2> /dev/null; then
223                cat <<EOF>>Makefile.settings
224EFLAGS+=`libgnutls-config --libs`
225CFLAGS+=`libgnutls-config --cflags`
226EOF
227               
228                ssl=gnutls
229                ret=1;
230        else
231                ret=0;
232        fi;
233}
234
235detect_nss()
236{
[32c632f]237        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG mozilla-nss; then
[b7d3cc34]238                cat<<EOF>>Makefile.settings
[32c632f]239EFLAGS+=`$PKG_CONFIG --libs mozilla-nss`
240CFLAGS+=`$PKG_CONFIG --cflags mozilla-nss`
[b7d3cc34]241EOF
242               
243                ssl=nss
244                ret=1;
245        else
246                ret=0;
247        fi;
248}
249
[f32d557]250detect_ldap()
[f665dab]251{
[5973412]252        TMPFILE=`mktemp`
253        if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then
[f665dab]254                cat<<EOF>>Makefile.settings
[5973412]255EFLAGS+=-lldap
256CFLAGS+=
[f665dab]257EOF
[f32d557]258                ldap=1
[5973412]259                rm -f $TMPFILE
[f665dab]260                ret=1
[b7d3cc34]261        else
[5973412]262                ldap=0
[f665dab]263                ret=0
[b7d3cc34]264        fi
[f665dab]265}
266
[b3c467b]267if [ "$ssl" = "auto" ]; then
268        detect_gnutls
[b7d3cc34]269        if [ "$ret" = "0" ]; then
[b3c467b]270                detect_nss
[b7d3cc34]271        fi
[b3c467b]272elif [ "$ssl" = "gnutls" ]; then
273        detect_gnutls
274elif [ "$ssl" = "nss" ]; then
275        detect_nss
276elif [ "$ssl" = "openssl" ]; then
277        echo
278        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
279        echo 'install of OpenSSL (including devel/header files) before reporting'
280        echo 'compilation problems.'
281        echo
282        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
283        echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better'
284        echo 'supported by us. However, on many BSD machines, OpenSSL can be considered'
285        echo 'part of the operating system, which makes it GPL-compatible.'
286        echo
287        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
288        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
289        echo
290        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
291        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
292        echo 'package, you really should use GnuTLS or NSS instead.'
293        echo
294        echo 'Also, the OpenSSL license requires us to say this:'
295        echo ' *    "This product includes software developed by the OpenSSL Project'
296        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
[b7d3cc34]297       
[b3c467b]298        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
299       
300        ret=1
301elif [ "$ssl" = "bogus" ]; then
302        echo
[670204f]303        echo 'Using bogus SSL code. This means some features will not work properly.'
[b3c467b]304       
305        ## Yes, you, at the console! How can you authenticate if you don't have any SSL!?
306        if [ "$msn" = "1" ]; then
[b7d3cc34]307                echo
[b3c467b]308                echo 'Real SSL support is necessary for MSN authentication, will build without'
309                echo 'MSN protocol support.'
310                msn=0
311        fi
[b7d3cc34]312       
[b3c467b]313        ret=1
314else
315        echo
316        echo 'ERROR: Unknown SSL library specified.'
317        exit 1
[b7d3cc34]318fi
319
[b3c467b]320if [ "$ret" = "0" ]; then
321        echo
322        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
323        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
324        echo '       so if you want to use that, you have to select it by hand. If you don'\''t'
325        echo '       need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)'
[b7d3cc34]326       
[b3c467b]327        exit 1
328fi;
329
330echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
331
[36e9f62]332for i in /lib /usr/lib /usr/local/lib; do
333        if [ -e $i/libresolv.a ]; then
334                echo '#define HAVE_RESOLV_A' >> config.h
335                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
336                break
337        fi
338done
339
[b3c467b]340STORAGES="text xml"
341
[f32d557]342if [ "$ldap" = "auto" ]; then
343        detect_ldap
[f665dab]344fi
345
[f32d557]346if [ "$ldap" = 0 ]; then
[5973412]347        echo "#undef WITH_LDAP" >> config.h
[f32d557]348elif [ "$ldap" = 1 ]; then
[5c5a586]349        echo
350        echo 'LDAP support is a work in progress and does NOT work AT ALL right now.'
351        echo
352        exit 1
353       
[5973412]354        echo "#define WITH_LDAP 1" >> config.h
[b3c467b]355        STORAGES="$STORAGES ldap"
[b7d3cc34]356fi
357
[b3c467b]358for i in $STORAGES; do
359        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
360done
361echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
362
[b7d3cc34]363if [ "$strip" = 0 ]; then
364        echo "STRIP=\# skip strip" >> Makefile.settings;
365else
366        if [ "$debug" = 1 ]; then
367                echo
368                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
369                echo 'STRIP=\# skip strip' >> Makefile.settings
370                strip=0;
371        elif [ -n "$STRIP" ]; then
372                echo "STRIP=$STRIP" >> Makefile.settings;
373        elif type strip > /dev/null 2> /dev/null; then
374                echo "STRIP=strip" >> Makefile.settings;
375        else
376                echo
377                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
378                echo 'STRIP=\# skip strip' >> Makefile.settings
379                strip=0;
380        fi;
381fi
382
[66b9e86e]383if [ "$gcov" = "1" ]; then
384        echo "CFLAGS+=-ftest-coverage -fprofile-arcs" >> Makefile.settings
385        echo "EFLAGS+=-lgcov" >> Makefile.settings
386fi
387
[2abfbc5]388if [ "$plugins" = 0 ]; then
389        echo '#undef WITH_PLUGINS' >> config.h
390else
391        echo '#define WITH_PLUGINS' >> config.h
392fi
393
[ffea9b9]394echo
[a014331]395if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
396        nick=`bzr nick`
397        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
398                nick="-$nick"
399        else
400                nick=""
401        fi
[ffea9b9]402        rev=`bzr revno`
403        echo 'Using bzr revision #'$rev' as version number'
[a014331]404        BITLBEE_VERSION=\"bzr$nick-$rev\"
[ffea9b9]405fi
406
[b7d3cc34]407if [ -n "$BITLBEE_VERSION" ]; then
408        echo 'Spoofing version number: '$BITLBEE_VERSION
409        echo '#undef BITLBEE_VERSION' >> config.h
[ffea9b9]410        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
411        echo
[b7d3cc34]412fi
413
[e506d6c]414cat <<EOF>bitlbee.pc
415prefix=$prefix
416includedir=$includedir
417
418Name: bitlbee
419Description: IRC to IM gateway
420Requires: glib-2.0
421Version: $BITLBEE_VERSION
422Libs:
423Cflags: -I\${includedir}
424
425EOF
426
[b7d3cc34]427protocols=''
428protoobjs=''
429
430if [ "$msn" = 0 ]; then
431        echo '#undef WITH_MSN' >> config.h
432else
433        echo '#define WITH_MSN' >> config.h
434        protocols=$protocols'msn '
[b5a22e3]435        protoobjs=$protoobjs'msn_mod.o '
[b7d3cc34]436fi
437
438if [ "$jabber" = 0 ]; then
439        echo '#undef WITH_JABBER' >> config.h
440else
441        echo '#define WITH_JABBER' >> config.h
442        protocols=$protocols'jabber '
[b5a22e3]443        protoobjs=$protoobjs'jabber_mod.o '
[b7d3cc34]444fi
445
446if [ "$oscar" = 0 ]; then
447        echo '#undef WITH_OSCAR' >> config.h
448else
449        echo '#define WITH_OSCAR' >> config.h
450        protocols=$protocols'oscar '
[b5a22e3]451        protoobjs=$protoobjs'oscar_mod.o '
[b7d3cc34]452fi
453
454if [ "$yahoo" = 0 ]; then
455        echo '#undef WITH_YAHOO' >> config.h
456else
457        echo '#define WITH_YAHOO' >> config.h
458        protocols=$protocols'yahoo '
[b5a22e3]459        protoobjs=$protoobjs'yahoo_mod.o '
[b7d3cc34]460fi
461
462if [ "$protocols" = "PROTOCOLS = " ]; then
463        echo "WARNING: You haven't selected any communication protocol to compile!"
[b3c467b]464        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
[b7d3cc34]465fi
466
467echo "PROTOCOLS = $protocols" >> Makefile.settings
468echo "PROTOOBJS = $protoobjs" >> Makefile.settings
469
470echo Architecture: $arch
471case "$arch" in
472Linux )
473;;
474GNU/* )
475;;
476*BSD )
477;;
478Darwin )
479;;
480IRIX )
481;;
[574af7e]482SunOS )
483        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
484        echo 'STRIP=\# skip strip' >> Makefile.settings
485;;
[8de63c3]486AIX )
487        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
488;;
[b7d3cc34]489CYGWIN* )
490        echo 'Cygwin is not officially supported.'
491;;
492* )
[8d6c4b1]493        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
494        echo 'Please report any problems at http://bugs.bitlbee.org/.'
[b7d3cc34]495;;
496esac
497
498echo
499echo 'Configuration done:'
500
501if [ "$debug" = "1" ]; then
[b3c467b]502        echo '  Debugging enabled.'
[b7d3cc34]503else
[b3c467b]504        echo '  Debugging disabled.'
[b7d3cc34]505fi
506
507if [ "$strip" = "1" ]; then
[b3c467b]508        echo '  Binary stripping enabled.'
[b7d3cc34]509else
[b3c467b]510        echo '  Binary stripping disabled.'
[b7d3cc34]511fi
512
[b3c467b]513echo '  Using event handler: '$events
514echo '  Using SSL library: '$ssl
515echo '  Building with these storage backends: '$STORAGES
[b7d3cc34]516
517if [ -n "$protocols" ]; then
[b3c467b]518        echo '  Building with these protocols:' $protocols
[b7d3cc34]519else
[b3c467b]520        echo '  Building without IM-protocol support. We wish you a lot of fun...'
[b7d3cc34]521fi
Note: See TracBrowser for help on using the repository browser.