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/bin/' |
---|
12 | sbindir='$prefix/sbin/' |
---|
13 | etcdir='$prefix/etc/bitlbee/' |
---|
14 | mandir='$prefix/share/man/' |
---|
15 | datadir='$prefix/share/bitlbee/' |
---|
16 | config='/var/lib/bitlbee/' |
---|
17 | plugindir='$prefix/lib/bitlbee/' |
---|
18 | includedir='$prefix/include/bitlbee/' |
---|
19 | systemdsystemunitdir='' |
---|
20 | libevent='/usr/' |
---|
21 | pidfile='/var/run/bitlbee.pid' |
---|
22 | ipcsocket='' |
---|
23 | pcdir='$prefix/lib/pkgconfig' |
---|
24 | systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib" |
---|
25 | |
---|
26 | # Set these to default-on to let it be overriden by either the user or purple |
---|
27 | # |
---|
28 | # If the user sets one of these to 1, purple won't disable them. |
---|
29 | # Otherwise, if it's still default-on, it gets included in normal builds, |
---|
30 | # but not purple ones. |
---|
31 | msn="default-on" |
---|
32 | jabber="default-on" |
---|
33 | oscar="default-on" |
---|
34 | yahoo="default-on" |
---|
35 | |
---|
36 | twitter=1 |
---|
37 | purple=0 |
---|
38 | |
---|
39 | debug=0 |
---|
40 | strip=1 |
---|
41 | gcov=0 |
---|
42 | asan=0 |
---|
43 | plugins=1 |
---|
44 | otr=0 |
---|
45 | skype=0 |
---|
46 | |
---|
47 | events=glib |
---|
48 | ssl=auto |
---|
49 | |
---|
50 | pie=1 |
---|
51 | |
---|
52 | arch=`uname -s` |
---|
53 | cpu=`uname -m` |
---|
54 | |
---|
55 | GLIB_MIN_VERSION=2.16 |
---|
56 | |
---|
57 | echo BitlBee configure |
---|
58 | |
---|
59 | # Cygwin and Darwin don't support PIC/PIE |
---|
60 | case "$arch" in |
---|
61 | CYGWIN* ) |
---|
62 | pie=0;; |
---|
63 | Darwin ) |
---|
64 | pie=0;; |
---|
65 | esac |
---|
66 | |
---|
67 | while [ -n "$1" ]; do |
---|
68 | e="`expr "X$1" : 'X--\(.*=.*\)'`" |
---|
69 | if [ -z "$e" ]; then |
---|
70 | cat<<EOF |
---|
71 | |
---|
72 | Usage: $0 [OPTIONS] |
---|
73 | |
---|
74 | Option Description Default |
---|
75 | |
---|
76 | --prefix=... Directories to put files in $prefix |
---|
77 | --bindir=... $bindir |
---|
78 | --sbindir=... $sbindir |
---|
79 | --etcdir=... $etcdir |
---|
80 | --mandir=... $mandir |
---|
81 | --datadir=... $datadir |
---|
82 | --plugindir=... $plugindir |
---|
83 | --systemdsystemunitdir=... $systemdsystemunitdir |
---|
84 | --pidfile=... $pidfile |
---|
85 | --config=... $config |
---|
86 | |
---|
87 | --msn=0/1 Disable/enable MSN part $msn |
---|
88 | --jabber=0/1 Disable/enable Jabber part $jabber |
---|
89 | --oscar=0/1 Disable/enable Oscar part (ICQ, AIM) $oscar |
---|
90 | --yahoo=0/1 Disable/enable Yahoo part $yahoo |
---|
91 | --twitter=0/1 Disable/enable Twitter part $twitter |
---|
92 | |
---|
93 | --purple=0/1 Disable/enable libpurple support $purple |
---|
94 | (automatically disables other protocol modules) |
---|
95 | |
---|
96 | --debug=0/1 Disable/enable debugging $debug |
---|
97 | --strip=0/1 Disable/enable binary stripping $strip |
---|
98 | --pie=0/1 Build position independent executable $pie |
---|
99 | --gcov=0/1 Disable/enable test coverage reporting $gcov |
---|
100 | --asan=0/1 Disable/enable AddressSanitizer $asan |
---|
101 | --plugins=0/1 Disable/enable plugins support $plugins |
---|
102 | --otr=0/1/auto/plugin |
---|
103 | Disable/enable OTR encryption support $otr |
---|
104 | --skype=0/1/plugin |
---|
105 | Disable/enable Skype support $skype |
---|
106 | |
---|
107 | --events=... Event handler (glib, libevent) $events |
---|
108 | --ssl=... SSL library to use (gnutls, nss, openssl, auto) |
---|
109 | $ssl |
---|
110 | |
---|
111 | |
---|
112 | --target=... Cross compilation target same as host |
---|
113 | EOF |
---|
114 | exit; |
---|
115 | fi |
---|
116 | eval "$e" |
---|
117 | shift; |
---|
118 | done |
---|
119 | |
---|
120 | # Expand $prefix and get rid of double slashes |
---|
121 | bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'` |
---|
122 | sbindir=`eval echo "$sbindir/" | sed 's/\/\{1,\}/\//g'` |
---|
123 | etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'` |
---|
124 | mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'` |
---|
125 | datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'` |
---|
126 | config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'` |
---|
127 | plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'` |
---|
128 | includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'` |
---|
129 | libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'` |
---|
130 | |
---|
131 | pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'` |
---|
132 | ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'` |
---|
133 | pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'` |
---|
134 | |
---|
135 | protocols_mods="" |
---|
136 | |
---|
137 | cat <<EOF >Makefile.settings |
---|
138 | ## BitlBee settings, generated by configure |
---|
139 | PREFIX=$prefix |
---|
140 | BINDIR=$bindir |
---|
141 | SBINDIR=$sbindir |
---|
142 | ETCDIR=$etcdir |
---|
143 | MANDIR=$mandir |
---|
144 | DATADIR=$datadir |
---|
145 | PLUGINDIR=$plugindir |
---|
146 | CONFIG=$config |
---|
147 | INCLUDEDIR=$includedir |
---|
148 | PCDIR=$pcdir |
---|
149 | |
---|
150 | TARGET=$target |
---|
151 | ARCH=$arch |
---|
152 | CPU=$cpu |
---|
153 | |
---|
154 | INSTALL=install -p |
---|
155 | |
---|
156 | DESTDIR= |
---|
157 | LFLAGS= |
---|
158 | EFLAGS=-lm |
---|
159 | EOF |
---|
160 | |
---|
161 | srcdir=$(cd $(dirname $0);pwd) |
---|
162 | currdir=$(pwd) |
---|
163 | if [ "$srcdir" != "$currdir" ]; then |
---|
164 | echo |
---|
165 | echo "configure script run from a different directory. Will create some symlinks..." |
---|
166 | if [ ! -e Makefile -o -L Makefile ]; then |
---|
167 | COPYDIRS="doc lib protocols tests utils" |
---|
168 | mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d) |
---|
169 | find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null |
---|
170 | dst="$PWD" |
---|
171 | cd "$srcdir" |
---|
172 | for i in $(find . -name Makefile -type f); do |
---|
173 | ln -s "$PWD${i#.}" "$dst/$i"; |
---|
174 | done |
---|
175 | cd "$dst" |
---|
176 | rm -rf .bzr |
---|
177 | fi |
---|
178 | |
---|
179 | echo "_SRCDIR_=$srcdir/" >> Makefile.settings |
---|
180 | CFLAGS="$CFLAGS -I${dst}" |
---|
181 | else |
---|
182 | srcdir=$PWD |
---|
183 | fi |
---|
184 | |
---|
185 | cat<<EOF >config.h |
---|
186 | /* BitlBee settings, generated by configure |
---|
187 | |
---|
188 | Do *NOT* use any of these defines in your code without thinking twice, most |
---|
189 | of them can/will be overridden at run-time */ |
---|
190 | |
---|
191 | #define CONFIG "$config" |
---|
192 | #define ETCDIR "$etcdir" |
---|
193 | #define VARDIR "$datadir" |
---|
194 | #define PLUGINDIR "$plugindir" |
---|
195 | #define PIDFILE "$pidfile" |
---|
196 | #define IPCSOCKET "$ipcsocket" |
---|
197 | #define ARCH "$arch" |
---|
198 | #define CPU "$cpu" |
---|
199 | EOF |
---|
200 | |
---|
201 | |
---|
202 | |
---|
203 | if [ -n "$target" ]; then |
---|
204 | PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig |
---|
205 | export PKG_CONFIG_LIBDIR |
---|
206 | PATH=/usr/$target/bin:$PATH |
---|
207 | CC=$target-cc |
---|
208 | LD=$target-ld |
---|
209 | systemlibdirs="/usr/$target/lib" |
---|
210 | fi |
---|
211 | |
---|
212 | if [ "$asan" = "1" ]; then |
---|
213 | CFLAGS="$CFLAGS -fsanitize=address" |
---|
214 | LDFLAGS="$LDFLAGS -fsanitize=address" |
---|
215 | debug=1 |
---|
216 | fi |
---|
217 | |
---|
218 | if [ "$debug" = "1" ]; then |
---|
219 | echo 'DEBUG=1' >> Makefile.settings |
---|
220 | CFLAGS="$CFLAGS -g3 -DDEBUG -O0" |
---|
221 | else |
---|
222 | [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing" |
---|
223 | fi |
---|
224 | |
---|
225 | if [ "$pie" = "1" ]; then |
---|
226 | echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings |
---|
227 | echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings |
---|
228 | fi |
---|
229 | |
---|
230 | echo LDFLAGS=$LDFLAGS >> Makefile.settings |
---|
231 | |
---|
232 | echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings |
---|
233 | echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings |
---|
234 | |
---|
235 | echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings |
---|
236 | |
---|
237 | if [ -n "$CC" ]; then |
---|
238 | CC=$CC |
---|
239 | elif type gcc > /dev/null 2> /dev/null; then |
---|
240 | CC=gcc |
---|
241 | elif type cc > /dev/null 2> /dev/null; then |
---|
242 | CC=cc |
---|
243 | else |
---|
244 | echo 'Cannot find a C compiler, aborting.' |
---|
245 | exit 1; |
---|
246 | fi |
---|
247 | |
---|
248 | echo "CC=$CC" >> Makefile.settings; |
---|
249 | if echo $CC | grep -qw gcc; then |
---|
250 | # Apparently -Wall is gcc-specific? |
---|
251 | echo CFLAGS+=-Wall >> Makefile.settings |
---|
252 | fi |
---|
253 | |
---|
254 | if [ -z "$LD" ]; then |
---|
255 | if type ld > /dev/null 2> /dev/null; then |
---|
256 | LD=ld |
---|
257 | else |
---|
258 | echo 'Cannot find ld, aborting.' |
---|
259 | exit 1; |
---|
260 | fi |
---|
261 | fi |
---|
262 | |
---|
263 | echo "LD=$LD" >> Makefile.settings |
---|
264 | |
---|
265 | if [ -z "$PKG_CONFIG" ]; then |
---|
266 | PKG_CONFIG=pkg-config |
---|
267 | fi |
---|
268 | |
---|
269 | if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then |
---|
270 | if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then |
---|
271 | cat<<EOF >>Makefile.settings |
---|
272 | EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0` |
---|
273 | CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0` |
---|
274 | EOF |
---|
275 | else |
---|
276 | echo |
---|
277 | echo 'Found glib2 '`$PKG_CONFIG glib-2.0 --modversion`', but version '$GLIB_MIN_VERSION' or newer is required.' |
---|
278 | exit 1 |
---|
279 | fi |
---|
280 | else |
---|
281 | echo |
---|
282 | echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)' |
---|
283 | exit 1 |
---|
284 | fi |
---|
285 | |
---|
286 | if [ "$events" = "libevent" ]; then |
---|
287 | if ! [ -f "${libevent}include/event.h" ]; then |
---|
288 | echo |
---|
289 | echo 'Warning: Could not find event.h, you might have to install it and/or specify' |
---|
290 | echo 'its location using the --libevent= argument. (Example: If event.h is in' |
---|
291 | echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)' |
---|
292 | fi |
---|
293 | |
---|
294 | echo '#define EVENTS_LIBEVENT' >> config.h |
---|
295 | cat <<EOF >>Makefile.settings |
---|
296 | EFLAGS+=-levent -L${libevent}lib |
---|
297 | CFLAGS+=-I${libevent}include |
---|
298 | EOF |
---|
299 | elif [ "$events" = "glib" ]; then |
---|
300 | ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...): |
---|
301 | echo '#define EVENTS_GLIB' >> config.h |
---|
302 | else |
---|
303 | echo |
---|
304 | echo 'ERROR: Unknown event handler specified.' |
---|
305 | exit 1 |
---|
306 | fi |
---|
307 | echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings |
---|
308 | |
---|
309 | detect_gnutls() |
---|
310 | { |
---|
311 | if $PKG_CONFIG --exists gnutls; then |
---|
312 | cat <<EOF >>Makefile.settings |
---|
313 | EFLAGS+=`$PKG_CONFIG --libs gnutls` `libgcrypt-config --libs` |
---|
314 | CFLAGS+=`$PKG_CONFIG --cflags gnutls` `libgcrypt-config --cflags` |
---|
315 | EOF |
---|
316 | ssl=gnutls |
---|
317 | if ! pkg-config gnutls --atleast-version=2.8; then |
---|
318 | echo |
---|
319 | echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.' |
---|
320 | fi |
---|
321 | ret=1 |
---|
322 | elif libgnutls-config --version > /dev/null 2> /dev/null; then |
---|
323 | cat <<EOF >>Makefile.settings |
---|
324 | EFLAGS+=`libgnutls-config --libs` `libgcrypt-config --libs` |
---|
325 | CFLAGS+=`libgnutls-config --cflags` `libgcrypt-config --cflags` |
---|
326 | EOF |
---|
327 | |
---|
328 | ssl=gnutls |
---|
329 | ret=1; |
---|
330 | else |
---|
331 | ret=0; |
---|
332 | fi; |
---|
333 | } |
---|
334 | |
---|
335 | detect_nss() |
---|
336 | { |
---|
337 | if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then |
---|
338 | cat<<EOF >>Makefile.settings |
---|
339 | EFLAGS+=`$PKG_CONFIG --libs nss` |
---|
340 | CFLAGS+=`$PKG_CONFIG --cflags nss` |
---|
341 | EOF |
---|
342 | |
---|
343 | ssl=nss |
---|
344 | ret=1; |
---|
345 | else |
---|
346 | ret=0; |
---|
347 | fi; |
---|
348 | } |
---|
349 | |
---|
350 | RESOLV_TESTCODE=' |
---|
351 | #include <sys/types.h> |
---|
352 | #include <netinet/in.h> |
---|
353 | #include <arpa/nameser.h> |
---|
354 | #include <resolv.h> |
---|
355 | |
---|
356 | int main() |
---|
357 | { |
---|
358 | |
---|
359 | res_query( NULL, 0, 0, NULL, 0); |
---|
360 | dn_expand( NULL, NULL, NULL, NULL, 0); |
---|
361 | dn_skipname( NULL, NULL); |
---|
362 | } |
---|
363 | ' |
---|
364 | RESOLV_NS_TESTCODE=' |
---|
365 | #include <sys/types.h> |
---|
366 | #include <netinet/in.h> |
---|
367 | #include <arpa/nameser.h> |
---|
368 | #include <resolv.h> |
---|
369 | |
---|
370 | int main() |
---|
371 | { |
---|
372 | ns_initparse( NULL, 0, NULL ); |
---|
373 | ns_parserr( NULL, ns_s_an, 0, NULL ); |
---|
374 | } |
---|
375 | ' |
---|
376 | RESOLV_NS_TYPES_TESTCODE=' |
---|
377 | #include <sys/types.h> |
---|
378 | #include <netinet/in.h> |
---|
379 | #include <arpa/nameser.h> |
---|
380 | |
---|
381 | int main() |
---|
382 | { |
---|
383 | ns_msg nsh; |
---|
384 | ns_rr rr; |
---|
385 | |
---|
386 | /* Not all platforms we want to work on have |
---|
387 | ns_* routines, so use this to make sure |
---|
388 | the compiler uses it.*/ |
---|
389 | return (int)(sizeof(nsh) + sizeof(rr)); |
---|
390 | } |
---|
391 | ' |
---|
392 | |
---|
393 | detect_resolv_dynamic() |
---|
394 | { |
---|
395 | case "$arch" in |
---|
396 | OpenBSD ) |
---|
397 | # In FreeBSD res_*/dn_* routines are present in libc.so |
---|
398 | LIBRESOLV=;; |
---|
399 | FreeBSD ) |
---|
400 | # In FreeBSD res_*/dn_* routines are present in libc.so |
---|
401 | LIBRESOLV=;; |
---|
402 | CYGWIN* ) |
---|
403 | # In Cygwin res_*/dn_* routines are present in libc.so |
---|
404 | LIBRESOLV=;; |
---|
405 | * ) |
---|
406 | LIBRESOLV=-lresolv;; |
---|
407 | esac |
---|
408 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
409 | ret=1 |
---|
410 | echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null |
---|
411 | if [ "$?" = "0" ]; then |
---|
412 | echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings |
---|
413 | ret=0 |
---|
414 | fi |
---|
415 | |
---|
416 | rm -f $TMPFILE |
---|
417 | return $ret |
---|
418 | } |
---|
419 | |
---|
420 | detect_resolv_static() |
---|
421 | { |
---|
422 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
423 | ret=1 |
---|
424 | for i in $systemlibdirs; do |
---|
425 | if [ -f $i/libresolv.a ]; then |
---|
426 | echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null |
---|
427 | if [ "$?" = "0" ]; then |
---|
428 | echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings |
---|
429 | ret=0 |
---|
430 | fi |
---|
431 | fi |
---|
432 | done |
---|
433 | |
---|
434 | rm -f $TMPFILE |
---|
435 | return $ret |
---|
436 | } |
---|
437 | |
---|
438 | detect_resolv_ns_dynamic() |
---|
439 | { |
---|
440 | case "$arch" in |
---|
441 | FreeBSD ) |
---|
442 | # In FreeBSD ns_ routines are present in libc.so |
---|
443 | LIBRESOLV=;; |
---|
444 | * ) |
---|
445 | LIBRESOLV=-lresolv;; |
---|
446 | esac |
---|
447 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
448 | ret=1 |
---|
449 | echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null |
---|
450 | if [ "$?" = "0" ]; then |
---|
451 | ret=0 |
---|
452 | fi |
---|
453 | |
---|
454 | rm -f $TMPFILE |
---|
455 | return $ret |
---|
456 | } |
---|
457 | |
---|
458 | detect_resolv_ns_static() |
---|
459 | { |
---|
460 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
461 | ret=1 |
---|
462 | for i in $systemlibdirs; do |
---|
463 | if [ -f $i/libresolv.a ]; then |
---|
464 | echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null |
---|
465 | if [ "$?" = "0" ]; then |
---|
466 | ret=0 |
---|
467 | fi |
---|
468 | fi |
---|
469 | done |
---|
470 | |
---|
471 | rm -f $TMPFILE |
---|
472 | return $ret |
---|
473 | } |
---|
474 | |
---|
475 | detect_nameser_has_ns_types() |
---|
476 | { |
---|
477 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
478 | ret=1 |
---|
479 | # since we aren't actually linking with ns_* routines |
---|
480 | # we can just compile the test code |
---|
481 | echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null |
---|
482 | if [ "$?" = "0" ]; then |
---|
483 | ret=0 |
---|
484 | fi |
---|
485 | |
---|
486 | rm -f $TMPFILE |
---|
487 | return $ret |
---|
488 | } |
---|
489 | |
---|
490 | if [ "$ssl" = "auto" ]; then |
---|
491 | detect_gnutls |
---|
492 | if [ "$ret" = "0" ]; then |
---|
493 | # Disable NSS for now as it's known to not work very well ATM. |
---|
494 | #detect_nss |
---|
495 | : |
---|
496 | fi |
---|
497 | elif [ "$ssl" = "gnutls" ]; then |
---|
498 | detect_gnutls |
---|
499 | elif [ "$ssl" = "nss" ]; then |
---|
500 | detect_nss |
---|
501 | elif [ "$ssl" = "openssl" ]; then |
---|
502 | echo |
---|
503 | echo 'No detection code exists for OpenSSL. Make sure that you have a complete' |
---|
504 | echo 'installation of OpenSSL (including devel/header files) before reporting' |
---|
505 | echo 'compilation problems.' |
---|
506 | echo |
---|
507 | echo 'Also, keep in mind that the OpenSSL is, according to some people, not' |
---|
508 | echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported' |
---|
509 | echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the' |
---|
510 | echo 'operating system, which makes it GPL-compatible.' |
---|
511 | echo |
---|
512 | echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' |
---|
513 | echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' |
---|
514 | echo |
---|
515 | echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' |
---|
516 | echo 'probably illegal. If you want to create and distribute a binary BitlBee' |
---|
517 | echo 'package, you really should use GnuTLS instead.' |
---|
518 | echo |
---|
519 | echo 'Also, the OpenSSL license requires us to say this:' |
---|
520 | echo ' * "This product includes software developed by the OpenSSL Project' |
---|
521 | echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' |
---|
522 | |
---|
523 | echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings |
---|
524 | |
---|
525 | ret=1 |
---|
526 | else |
---|
527 | echo |
---|
528 | echo 'ERROR: Unknown SSL library specified.' |
---|
529 | exit 1 |
---|
530 | fi |
---|
531 | |
---|
532 | if [ "$ret" = "0" ]; then |
---|
533 | echo |
---|
534 | echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' |
---|
535 | echo ' Please note that this script doesn'\''t have detection code for OpenSSL,' |
---|
536 | echo ' so if you want to use that, you have to select it by hand.' |
---|
537 | |
---|
538 | exit 1 |
---|
539 | fi; |
---|
540 | |
---|
541 | echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings |
---|
542 | |
---|
543 | if detect_nameser_has_ns_types; then |
---|
544 | echo '#define NAMESER_HAS_NS_TYPES' >> config.h |
---|
545 | fi |
---|
546 | if detect_resolv_dynamic || detect_resolv_static; then |
---|
547 | echo '#define HAVE_RESOLV_A' >> config.h |
---|
548 | if detect_resolv_ns_dynamic || detect_resolv_ns_static; then |
---|
549 | echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h |
---|
550 | fi |
---|
551 | else |
---|
552 | echo 'Insufficient resolv routines. Jabber server must be set explicitly' |
---|
553 | fi |
---|
554 | |
---|
555 | |
---|
556 | STORAGES="xml" |
---|
557 | |
---|
558 | for i in $STORAGES; do |
---|
559 | STORAGE_OBJS="$STORAGE_OBJS storage_$i.o" |
---|
560 | done |
---|
561 | echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings |
---|
562 | |
---|
563 | if [ "$strip" = 0 ]; then |
---|
564 | echo "STRIP=\# skip strip" >> Makefile.settings; |
---|
565 | else |
---|
566 | if [ "$debug" = 1 ]; then |
---|
567 | echo |
---|
568 | echo 'Stripping binaries does not make sense when debugging. Stripping disabled.' |
---|
569 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
570 | strip=0; |
---|
571 | elif [ -n "$STRIP" ]; then |
---|
572 | echo "STRIP=$STRIP" >> Makefile.settings; |
---|
573 | elif type strip > /dev/null 2> /dev/null; then |
---|
574 | echo "STRIP=strip" >> Makefile.settings; |
---|
575 | else |
---|
576 | echo |
---|
577 | echo 'No strip utility found, cannot remove unnecessary parts from executable.' |
---|
578 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
579 | strip=0; |
---|
580 | fi; |
---|
581 | fi |
---|
582 | |
---|
583 | if [ -z "$systemdsystemunitdir" ]; then |
---|
584 | if $PKG_CONFIG --exists systemd; then |
---|
585 | systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd` |
---|
586 | fi |
---|
587 | fi |
---|
588 | if [ -n "$systemdsystemunitdir" ]; then |
---|
589 | if [ "$systemdsystemunitdir" != "no" ]; then |
---|
590 | echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings |
---|
591 | fi |
---|
592 | fi |
---|
593 | |
---|
594 | if [ "$gcov" = "1" ]; then |
---|
595 | echo "CFLAGS+=--coverage" >> Makefile.settings |
---|
596 | echo "EFLAGS+=--coverage" >> Makefile.settings |
---|
597 | fi |
---|
598 | |
---|
599 | if [ "$plugins" = 0 ]; then |
---|
600 | plugindir="" |
---|
601 | echo '#undef WITH_PLUGINS' >> config.h |
---|
602 | else |
---|
603 | echo '#define WITH_PLUGINS' >> config.h |
---|
604 | fi |
---|
605 | |
---|
606 | otrprefix="" |
---|
607 | for i in / /usr /usr/local; do |
---|
608 | if [ -f ${i}/lib/libotr.a ]; then |
---|
609 | otrprefix=${i} |
---|
610 | break |
---|
611 | fi |
---|
612 | done |
---|
613 | if [ "$otr" = "auto" ]; then |
---|
614 | if [ -n "$otrprefix" ]; then |
---|
615 | otr=1 |
---|
616 | else |
---|
617 | otr=0 |
---|
618 | fi |
---|
619 | fi |
---|
620 | if [ "$otr" = 1 ]; then |
---|
621 | # BI == built-in |
---|
622 | echo '#define OTR_BI' >> config.h |
---|
623 | echo "EFLAGS+=-L${otrprefix}/lib -lotr -lgcrypt" >> Makefile.settings |
---|
624 | echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings |
---|
625 | echo 'OTR_BI=otr.o' >> Makefile.settings |
---|
626 | elif [ "$otr" = "plugin" ]; then |
---|
627 | echo '#define OTR_PI' >> config.h |
---|
628 | echo "OTRFLAGS=-L${otrprefix}/lib -lotr" >> Makefile.settings |
---|
629 | echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings |
---|
630 | echo 'OTR_PI=otr.so' >> Makefile.settings |
---|
631 | fi |
---|
632 | if [ "$otr" != 0 ] && ! pkg-config libotr --atleast-version=4.0; then |
---|
633 | echo |
---|
634 | echo 'WARNING: Your libotr seems to be old. BitlBee now needs at least libotr 4.0.' |
---|
635 | # Not hard-failing because the code above doesn't use pkg-config, so who knows |
---|
636 | # what's true at this point... |
---|
637 | fi |
---|
638 | |
---|
639 | if [ "$skype" = "1" -o "$skype" = "plugin" ]; then |
---|
640 | if [ "$arch" = "Darwin" ]; then |
---|
641 | echo "SKYPEFLAGS=-dynamiclib -undefined dynamic_lookup" >> Makefile.settings |
---|
642 | else |
---|
643 | echo "SKYPEFLAGS=-fPIC -shared" >> Makefile.settings |
---|
644 | fi |
---|
645 | echo 'SKYPE_PI=skype.so' >> Makefile.settings |
---|
646 | protocols_mods="$protocol_mods skype(plugin)" |
---|
647 | fi |
---|
648 | |
---|
649 | if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then |
---|
650 | echo |
---|
651 | echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.' |
---|
652 | echo 'Install xmlto if you want online help to work.' |
---|
653 | fi |
---|
654 | |
---|
655 | REAL_BITLBEE_VERSION=`grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/'` |
---|
656 | echo |
---|
657 | if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then |
---|
658 | nick=`bzr nick` |
---|
659 | if [ -n "$nick" -a "$nick" != "bitlbee" ]; then |
---|
660 | nick="-$nick" |
---|
661 | else |
---|
662 | nick="" |
---|
663 | fi |
---|
664 | rev=`bzr revno` |
---|
665 | echo 'Using bzr revision #'$rev' as version number' |
---|
666 | BITLBEE_VERSION=$REAL_BITLBEE_VERSION-bzr$nick-$rev |
---|
667 | fi |
---|
668 | |
---|
669 | if [ -z "$BITLBEE_VERSION" -a -d .git ] && type git > /dev/null 2> /dev/null; then |
---|
670 | rev=`git describe --long --tags`-`git rev-parse --abbrev-ref HEAD` |
---|
671 | echo 'Using '$rev' as git version number' |
---|
672 | BITLBEE_VERSION=$rev-git |
---|
673 | fi |
---|
674 | |
---|
675 | if [ -n "$BITLBEE_VERSION" ]; then |
---|
676 | echo 'Spoofing version number: '$BITLBEE_VERSION |
---|
677 | echo '#undef BITLBEE_VERSION' >> config.h |
---|
678 | echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h |
---|
679 | echo |
---|
680 | else |
---|
681 | # for pkg-config |
---|
682 | BITLBEE_VERSION=$REAL_BITLBEE_VERSION |
---|
683 | fi |
---|
684 | |
---|
685 | if ! make helloworld > /dev/null 2>&1; then |
---|
686 | echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles." |
---|
687 | echo "BitlBee needs GNU make to build properly. On most systems GNU make is available" |
---|
688 | echo "under the name 'gmake'." |
---|
689 | echo |
---|
690 | if gmake helloworld > /dev/null 2>&1; then |
---|
691 | echo "gmake seems to be available on your machine, great." |
---|
692 | echo |
---|
693 | else |
---|
694 | echo "gmake is not installed (or not working). Please try to install it." |
---|
695 | echo |
---|
696 | fi |
---|
697 | fi |
---|
698 | |
---|
699 | cat <<EOF >bitlbee.pc |
---|
700 | prefix=$prefix |
---|
701 | includedir=$includedir |
---|
702 | plugindir=$plugindir |
---|
703 | |
---|
704 | Name: bitlbee |
---|
705 | Description: IRC to IM gateway |
---|
706 | Requires: glib-2.0 |
---|
707 | Version: $BITLBEE_VERSION |
---|
708 | Libs: |
---|
709 | Cflags: -I\${includedir} |
---|
710 | |
---|
711 | EOF |
---|
712 | |
---|
713 | protocols='' |
---|
714 | protoobjs='' |
---|
715 | |
---|
716 | if [ "$purple" = 0 ]; then |
---|
717 | echo '#undef WITH_PURPLE' >> config.h |
---|
718 | else |
---|
719 | if ! $PKG_CONFIG purple; then |
---|
720 | echo |
---|
721 | echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)' |
---|
722 | exit 1 |
---|
723 | fi |
---|
724 | echo '#define WITH_PURPLE' >> config.h |
---|
725 | cat<<EOF >>Makefile.settings |
---|
726 | EFLAGS += $($PKG_CONFIG purple --libs) |
---|
727 | PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags) |
---|
728 | EOF |
---|
729 | protocols=$protocols'purple ' |
---|
730 | protoobjs=$protoobjs'purple_mod.o ' |
---|
731 | |
---|
732 | # only disable these if the user didn't enable them explicitly |
---|
733 | [ "$msn" = "default-on" ] && msn=0 |
---|
734 | [ "$jabber" = "default-on" ] && jabber=0 |
---|
735 | [ "$oscar" = "default-on" ] && oscar=0 |
---|
736 | [ "$yahoo" = "default-on" ] && yahoo=0 |
---|
737 | |
---|
738 | echo '#undef PACKAGE' >> config.h |
---|
739 | echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h |
---|
740 | |
---|
741 | if [ "$events" = "libevent" ]; then |
---|
742 | echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling' |
---|
743 | echo 'outside libpurple, talking to GLib directly. At least for now the combination' |
---|
744 | echo 'libpurple + libevent is *not* recommended!' |
---|
745 | echo |
---|
746 | fi |
---|
747 | fi |
---|
748 | |
---|
749 | case "$CC" in |
---|
750 | *gcc* ) |
---|
751 | echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings |
---|
752 | for i in . lib tests protocols protocols/*/; do |
---|
753 | mkdir -p $i/.depend |
---|
754 | done |
---|
755 | esac |
---|
756 | |
---|
757 | if [ "$msn" = 0 ]; then |
---|
758 | echo '#undef WITH_MSN' >> config.h |
---|
759 | else |
---|
760 | echo '#define WITH_MSN' >> config.h |
---|
761 | protocols=$protocols'msn ' |
---|
762 | protoobjs=$protoobjs'msn_mod.o ' |
---|
763 | fi |
---|
764 | |
---|
765 | if [ "$jabber" = 0 ]; then |
---|
766 | echo '#undef WITH_JABBER' >> config.h |
---|
767 | else |
---|
768 | echo '#define WITH_JABBER' >> config.h |
---|
769 | protocols=$protocols'jabber ' |
---|
770 | protoobjs=$protoobjs'jabber_mod.o ' |
---|
771 | fi |
---|
772 | |
---|
773 | if [ "$oscar" = 0 ]; then |
---|
774 | echo '#undef WITH_OSCAR' >> config.h |
---|
775 | else |
---|
776 | echo '#define WITH_OSCAR' >> config.h |
---|
777 | protocols=$protocols'oscar ' |
---|
778 | protoobjs=$protoobjs'oscar_mod.o ' |
---|
779 | fi |
---|
780 | |
---|
781 | if [ "$yahoo" = 0 ]; then |
---|
782 | echo '#undef WITH_YAHOO' >> config.h |
---|
783 | else |
---|
784 | echo '#define WITH_YAHOO' >> config.h |
---|
785 | protocols=$protocols'yahoo ' |
---|
786 | protoobjs=$protoobjs'yahoo_mod.o ' |
---|
787 | fi |
---|
788 | |
---|
789 | if [ "$twitter" = 0 ]; then |
---|
790 | echo '#undef WITH_TWITTER' >> config.h |
---|
791 | else |
---|
792 | echo '#define WITH_TWITTER' >> config.h |
---|
793 | protocols=$protocols'twitter ' |
---|
794 | protoobjs=$protoobjs'twitter_mod.o ' |
---|
795 | fi |
---|
796 | |
---|
797 | if [ "$protocols" = "PROTOCOLS = " ]; then |
---|
798 | echo "Warning: You haven't selected any communication protocol to compile!" |
---|
799 | echo " BitlBee will run, but you will be unable to connect to IM servers!" |
---|
800 | fi |
---|
801 | |
---|
802 | echo "PROTOCOLS = $protocols" >> Makefile.settings |
---|
803 | echo "PROTOOBJS = $protoobjs" >> Makefile.settings |
---|
804 | |
---|
805 | echo Architecture: $arch |
---|
806 | case "$arch" in |
---|
807 | Linux ) |
---|
808 | ;; |
---|
809 | GNU/* ) |
---|
810 | ;; |
---|
811 | *BSD ) |
---|
812 | ;; |
---|
813 | Darwin ) |
---|
814 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
815 | ;; |
---|
816 | IRIX ) |
---|
817 | ;; |
---|
818 | SunOS ) |
---|
819 | echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings |
---|
820 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
821 | echo '#define NO_FD_PASSING' >> config.h |
---|
822 | ;; |
---|
823 | AIX ) |
---|
824 | echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings |
---|
825 | ;; |
---|
826 | CYGWIN* ) |
---|
827 | ;; |
---|
828 | Windows ) |
---|
829 | echo 'Native windows compilation is not supported anymore, use cygwin instead.' |
---|
830 | ;; |
---|
831 | * ) |
---|
832 | echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.' |
---|
833 | echo 'Please report any problems at http://bugs.bitlbee.org/.' |
---|
834 | ;; |
---|
835 | esac |
---|
836 | |
---|
837 | if [ -n "$target" ]; then |
---|
838 | echo "Cross-compiling for: $target" |
---|
839 | fi |
---|
840 | |
---|
841 | echo |
---|
842 | echo 'Configuration done:' |
---|
843 | |
---|
844 | if [ "$debug" = "1" ]; then |
---|
845 | echo ' Debugging enabled.' |
---|
846 | else |
---|
847 | echo ' Debugging disabled.' |
---|
848 | fi |
---|
849 | |
---|
850 | if [ "$asan" = "1" ]; then |
---|
851 | echo ' AddressSanitizer (ASAN) enabled.' |
---|
852 | else |
---|
853 | echo ' AddressSanitizer (ASAN) disabled.' |
---|
854 | fi |
---|
855 | |
---|
856 | if [ "$pie" = "1" ]; then |
---|
857 | echo ' Building PIE executable' |
---|
858 | else |
---|
859 | echo ' Building non-PIE executable' |
---|
860 | fi |
---|
861 | |
---|
862 | if [ "$strip" = "1" ]; then |
---|
863 | echo ' Binary stripping enabled.' |
---|
864 | else |
---|
865 | echo ' Binary stripping disabled.' |
---|
866 | fi |
---|
867 | |
---|
868 | if [ "$otr" = "1" ]; then |
---|
869 | echo ' Off-the-Record (OTR) Messaging enabled.' |
---|
870 | elif [ "$otr" = "plugin" ]; then |
---|
871 | echo ' Off-the-Record (OTR) Messaging enabled (as a plugin).' |
---|
872 | else |
---|
873 | echo ' Off-the-Record (OTR) Messaging disabled.' |
---|
874 | fi |
---|
875 | |
---|
876 | if [ -n "$systemdsystemunitdir" ]; then |
---|
877 | echo ' systemd enabled.' |
---|
878 | else |
---|
879 | echo ' systemd disabled.' |
---|
880 | fi |
---|
881 | |
---|
882 | echo ' Using event handler: '$events |
---|
883 | echo ' Using SSL library: '$ssl |
---|
884 | #echo ' Building with these storage backends: '$STORAGES |
---|
885 | |
---|
886 | if [ -n "$protocols" ]; then |
---|
887 | echo ' Building with these protocols:' $protocols$protocols_mods |
---|
888 | case "$protocols" in |
---|
889 | *purple*) |
---|
890 | echo " Note that BitlBee-libpurple is supported on a best-effort basis. It's" |
---|
891 | echo " not *fully* compatible with normal BitlBee. Don't use it unless you" |
---|
892 | echo " absolutely need it (i.e. support for a certain protocol or feature)." |
---|
893 | esac |
---|
894 | else |
---|
895 | echo ' Building without IM-protocol support. We wish you a lot of fun...' |
---|
896 | fi |
---|