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