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