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