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