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