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