source: configure @ 1bf9492

Last change on this file since 1bf9492 was 1bf9492, checked in by Jelmer Vernooij <jelmer@…>, at 2008-06-09T02:18:34Z

Use system lib directories and pkg-config directory from target when specified.

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