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