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