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