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