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