source: configure @ cdca30b

Last change on this file since cdca30b was 68b518d6, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-05-26T09:03:38Z

Merging from main development tree.

  • Property mode set to 100755
File size: 11.5 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'
21pcdir='$prefix/lib/pkgconfig'
22
23msn=1
24jabber=1
25oscar=1
26yahoo=1
27
28debug=0
29strip=1
30ipv6=1
31
32events=glib
33ssl=auto
34
35arch=`uname -s`
36cpu=`uname -m`
37
38echo BitlBee configure
39
40while [ -n "$1" ]; do
41        e="`expr "X$1" : 'X--\(.*=.*\)'`"
42        if [ -z "$e" ]; then
43                cat<<EOF
44
45Usage: $0 [OPTIONS]
46
47Option          Description                             Default
48
49--prefix=...    Directories to put files in             $prefix
50--bindir=...                                            $bindir
51--etcdir=...                                            $etcdir
52--mandir=...                                            $mandir
53--datadir=...                                           $datadir
54--plugindir=...                                         $plugindir
55--pidfile=...                                           $pidfile
56--config=...                                            $config
57--ipcsocket=...                                         $ipcsocket
58
59--msn=0/1       Disable/enable MSN part                 $msn
60--jabber=0/1    Disable/enable Jabber part              $jabber
61--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
62--yahoo=0/1     Disable/enable Yahoo part               $yahoo
63
64--debug=0/1     Disable/enable debugging                $debug
65--strip=0/1     Disable/enable binary stripping         $strip
66
67--ipv6=0/1      IPv6 socket support                     $ipv6
68
69--events=...    Event handler (glib, libevent)          $events
70--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
71                                                        $ssl
72EOF
73                exit;
74        fi
75        eval "$e"
76        shift;
77done
78
79# Expand $prefix and get rid of double slashes
80bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'`
81etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'`
82mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'`
83datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
84config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
85plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
86includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'`
87libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'`
88
89pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
90ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
91pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
92
93cat<<EOF>Makefile.settings
94## BitlBee settings, generated by configure
95PREFIX=$prefix
96BINDIR=$bindir
97ETCDIR=$etcdir
98MANDIR=$mandir
99DATADIR=$datadir
100PLUGINDIR=$plugindir
101CONFIG=$config
102IPCSOCKET=$ipcsocket
103INCLUDEDIR=$includedir
104PCDIR=$pcdir
105
106ARCH=$arch
107CPU=$cpu
108OUTFILE=bitlbee
109
110DESTDIR=
111LFLAGS=
112EFLAGS=
113EOF
114
115cat<<EOF>config.h
116/* BitlBee settings, generated by configure
117   
118   Do *NOT* use any of these defines in your code without thinking twice, most
119   of them can/will be overridden at run-time */
120
121#define CONFIG "$config"
122#define ETCDIR "$etcdir"
123#define VARDIR "$datadir"
124#define PLUGINDIR "$plugindir"
125#define PIDFILE "$pidfile"
126#define IPCSOCKET "$ipcsocket"
127#define ARCH "$arch"
128#define CPU "$cpu"
129EOF
130
131if [ "$ipv6" = "1" ]; then
132        echo '#define IPV6' >> config.h
133fi
134
135if [ "$debug" = "1" ]; then
136        echo 'CFLAGS=-g' >> Makefile.settings
137        echo 'DEBUG=1' >> Makefile.settings
138        echo '#define DEBUG' >> config.h
139else
140        echo 'CFLAGS=-O3' >> Makefile.settings
141fi
142
143echo CFLAGS+=-I`pwd` -I`pwd`/protocols -I. >> Makefile.settings
144
145echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
146
147if [ -n "$CC" ]; then
148        echo "CC=$CC" >> Makefile.settings;
149elif type gcc > /dev/null 2> /dev/null; then
150        echo "CC=gcc" >> Makefile.settings;
151elif type cc > /dev/null 2> /dev/null; then
152        echo "CC=cc" >> Makefile.settings;
153else
154        echo 'Cannot find a C compiler, aborting.'
155        exit 1;
156fi
157
158if [ -n "$LD" ]; then
159        echo "LD=$LD" >> Makefile.settings;
160elif type ld > /dev/null 2> /dev/null; then
161        echo "LD=ld" >> Makefile.settings;
162else
163        echo 'Cannot find ld, aborting.'
164        exit 1;
165fi
166
167if [ -z "$PKG_CONFIG" ]; then
168        PKG_CONFIG=pkg-config
169fi
170
171GLIB=0
172
173if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
174        cat<<EOF>>Makefile.settings
175EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
176CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
177EOF
178        echo '#define GLIB2' >> config.h
179        GLIB=2
180elif type glib-config > /dev/null 2> /dev/null; then
181        cat<<EOF>>Makefile.settings
182EFLAGS+=`glib-config --libs`
183CFLAGS+=`glib-config --cflags`
184EOF
185        echo '#define GLIB1' >> config.h
186        GLIB=1
187else
188        echo 'Cannot find glib development libraries, aborting. (Install libglib-dev?)'
189        exit 1;
190fi
191
192if [ GLIB = 1 -o -r /usr/include/iconv.h ]; then
193        :;
194elif [ -r /usr/local/include/iconv.h ]; then
195        echo CFLAGS+=-I/usr/local/include >> Makefile.settings
196else
197        echo
198        echo 'Warning: Could not find iconv.h, you might have to install it and/or modify'
199        echo 'Makefile.settings to tell where this file is.'
200fi
201
202
203if [ "$events" = "libevent" ]; then
204        if ! [ -e "${libevent}include/event.h" ]; then
205                echo
206                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
207                echo 'its location using the --libevent= argument. (Example: If event.h is in'
208                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
209        fi
210       
211        echo '#define EVENTS_LIBEVENT' >> config.h
212        cat <<EOF>>Makefile.settings
213EFLAGS+=-levent -L${libevent}lib
214CFLAGS+=-I${libevent}include
215EOF
216elif [ "$events" = "glib" ]; then
217        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
218        echo '#define EVENTS_GLIB' >> config.h
219else
220        echo
221        echo 'ERROR: Unknown event handler specified.'
222        exit 1
223fi
224echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
225
226
227detect_gnutls()
228{
229        if libgnutls-config --version > /dev/null 2> /dev/null; then
230                cat <<EOF>>Makefile.settings
231EFLAGS+=`libgnutls-config --libs`
232CFLAGS+=`libgnutls-config --cflags`
233EOF
234               
235                ssl=gnutls
236                ret=1;
237        else
238                ret=0;
239        fi;
240}
241
242detect_nss()
243{
244        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG mozilla-nss; then
245                cat<<EOF>>Makefile.settings
246EFLAGS+=`$PKG_CONFIG --libs mozilla-nss`
247CFLAGS+=`$PKG_CONFIG --cflags mozilla-nss`
248EOF
249               
250                ssl=nss
251                ret=1;
252        else
253                ret=0;
254        fi;
255}
256
257if [ "$msn" = 1 -o "$jabber" = 1 ]; then
258        if [ "$ssl" = "auto" ]; then
259                detect_gnutls
260                if [ "$ret" = "0" ]; then
261                        detect_nss
262                fi;
263        elif [ "$ssl" = "gnutls" ]; then
264                detect_gnutls;
265        elif [ "$ssl" = "nss" ]; then
266                detect_nss;
267        elif [ "$ssl" = "openssl" ]; then
268                echo
269                echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
270                echo 'install of OpenSSL (including devel/header files) before reporting'
271                echo 'compilation problems.'
272                echo
273                echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
274                echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better'
275                echo 'supported by us. However, on many BSD machines, OpenSSL can be considered'
276                echo 'part of the operating system, which makes it GPL-compatible.'
277                echo
278                echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
279                echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
280                echo
281                echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
282                echo 'probably illegal. If you want to create and distribute a binary BitlBee'
283                echo 'package, you really should use GnuTLS or NSS instead.'
284                echo
285                echo 'Also, the OpenSSL license requires us to say this:'
286                echo ' *    "This product includes software developed by the OpenSSL Project'
287                echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
288               
289                echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
290               
291                ret=1;
292        elif [ "$ssl" = "bogus" ]; then
293                echo
294                echo 'Using bogus SSL code. This will not make the MSN module work, but it will'
295                echo 'allow you to use the Jabber module - although without working SSL support.'
296               
297                ret=1;
298        else
299                echo
300                echo 'ERROR: Unknown SSL library specified.'
301                exit 1;
302        fi
303       
304        if [ "$ret" = "0" ]; then
305                echo
306                echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
307                echo '       This is necessary for MSN and full Jabber support. To continue,'
308                echo '       install a suitable SSL library or disable MSN support (--msn=0).'
309                echo '       If you want Jabber without SSL support you can try --ssl=bogus.'
310               
311                exit 1;
312        fi;
313       
314        echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
315fi
316
317if [ "$strip" = 0 ]; then
318        echo "STRIP=\# skip strip" >> Makefile.settings;
319else
320        if [ "$debug" = 1 ]; then
321                echo
322                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
323                echo 'STRIP=\# skip strip' >> Makefile.settings
324                strip=0;
325        elif [ -n "$STRIP" ]; then
326                echo "STRIP=$STRIP" >> Makefile.settings;
327        elif type strip > /dev/null 2> /dev/null; then
328                echo "STRIP=strip" >> Makefile.settings;
329        elif /bin/test -x /usr/ccs/bin/strip; then
330                echo "STRIP=/usr/ccs/bin/strip" >> Makefile.settings;
331        else
332                echo
333                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
334                echo 'STRIP=\# skip strip' >> Makefile.settings
335                strip=0;
336        fi;
337fi
338
339echo
340if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
341        nick=`bzr nick`
342        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
343                nick="-$nick"
344        else
345                nick=""
346        fi
347        rev=`bzr revno`
348        echo 'Using bzr revision #'$rev' as version number'
349        BITLBEE_VERSION=\"bzr$nick-$rev\"
350fi
351
352if [ -n "$BITLBEE_VERSION" ]; then
353        echo 'Spoofing version number: '$BITLBEE_VERSION
354        echo '#undef BITLBEE_VERSION' >> config.h
355        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
356        echo
357fi
358
359cat <<EOF>bitlbee.pc
360prefix=$prefix
361includedir=$includedir
362
363Name: bitlbee
364Description: IRC to IM gateway
365Requires: glib-2.0
366Version: $BITLBEE_VERSION
367Libs:
368Cflags: -I\${includedir}
369
370EOF
371
372protocols=''
373protoobjs=''
374
375if [ "$msn" = 0 ]; then
376        echo '#undef WITH_MSN' >> config.h
377else
378        echo '#define WITH_MSN' >> config.h
379        protocols=$protocols'msn '
380        protoobjs=$protoobjs'msn_mod.o '
381fi
382
383if [ "$jabber" = 0 ]; then
384        echo '#undef WITH_JABBER' >> config.h
385else
386        echo '#define WITH_JABBER' >> config.h
387        protocols=$protocols'jabber '
388        protoobjs=$protoobjs'jabber_mod.o '
389fi
390
391if [ "$oscar" = 0 ]; then
392        echo '#undef WITH_OSCAR' >> config.h
393else
394        echo '#define WITH_OSCAR' >> config.h
395        protocols=$protocols'oscar '
396        protoobjs=$protoobjs'oscar_mod.o '
397fi
398
399if [ "$yahoo" = 0 ]; then
400        echo '#undef WITH_YAHOO' >> config.h
401else
402        echo '#define WITH_YAHOO' >> config.h
403        protocols=$protocols'yahoo '
404        protoobjs=$protoobjs'yahoo_mod.o '
405fi
406
407if [ "$protocols" = "PROTOCOLS = " ]; then
408        echo "WARNING: You haven't selected any communication protocol to compile!"
409        echo "         Bitlbee will run, but you will be unable to connect to IM servers!"
410fi
411
412echo "PROTOCOLS = $protocols" >> Makefile.settings
413echo "PROTOOBJS = $protoobjs" >> Makefile.settings
414
415echo Architecture: $arch
416case "$arch" in
417Linux )
418;;
419GNU/* )
420;;
421*BSD )
422        echo 'EFLAGS+=-liconv' >> Makefile.settings;
423;;
424SunOS )
425        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
426        echo 'STRIP=\# skip strip' >> Makefile.settings
427        echo 'EFLAGS+=-liconv' >> Makefile.settings;
428;;
429Darwin )
430        echo 'EFLAGS+=-liconv' >> Makefile.settings;
431;;
432IRIX )
433;;
434CYGWIN* )
435        echo 'Cygwin is not officially supported.'
436;;
437* )
438        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
439        echo 'Please report any problems at http://bugs.bitlbee.org/.'
440;;
441esac
442
443echo
444echo 'Configuration done:'
445
446if [ "$debug" = "1" ]; then
447        echo '  Debugging enabled.';
448else
449        echo '  Debugging disabled.';
450fi
451
452if [ "$strip" = "1" ]; then
453        echo '  Binary stripping enabled.';
454else
455        echo '  Binary stripping disabled.';
456fi
457
458echo '  Using event handler: '$events;
459echo '  Using SSL library: '$ssl;
460
461#if [ "$flood" = "0" ]; then
462#       echo '  Flood protection disabled.';
463#else
464#       echo '  Flood protection enabled.';
465#fi
466
467if [ -n "$protocols" ]; then
468        echo '  Building with these protocols:' $protocols;
469else
470        echo '  Building without IM-protocol support. We wish you a lot of fun...';
471fi
Note: See TracBrowser for help on using the repository browser.