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