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