Debian Codegraph @

configure.ac

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 # jabberd2 configure script
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.61)
5 AC_INIT([jabberd2], [2.7.0], [[email protected]])
6 AC_CONFIG_SRCDIR([sx/sx.h])
7 AC_CONFIG_HEADER([config.h])
8 AC_CONFIG_MACRO_DIRS([m4])
9 AM_INIT_AUTOMAKE
10 AM_SILENT_RULES([yes])
11
12 # Checks for programs.
13 AC_PROG_CC
14 AC_PROG_CC_STDC
15 AM_PROG_CC_C_O
16 AC_PROG_CPP
17 AC_PROG_INSTALL
18 AC_PROG_LN_S
19 AC_PROG_MAKE_SET
20 # libtool for internal linking
21 AC_DISABLE_STATIC
22 AC_LIBTOOL_DLOPEN
23 AC_PROG_LIBTOOL
24
25 if test "x-$lt_cv_dlopen_libs" != "x-" ; then
26 LIBS="$LIBS $lt_cv_dlopen_libs"
27 fi
28
29 # extra paths
30 AC_ARG_WITH([extra_include_path], AC_HELP_STRING([--with-extra-include-path],
31 [use additional include paths]),
32 extra_include_path=$withval)
33 split_includes="`echo $extra_include_path | sed -e 's/:/ /g'`"
34 for incpath in $split_includes ; do
35 CPPFLAGS="-I$incpath $CPPFLAGS"
36 done
37
38 AC_ARG_WITH([extra_library_path], AC_HELP_STRING([--with-extra-library-path],
39 [use additional library paths (remember to update /etc/ld.so.conf too)]),
40 extra_library_path=$withval)
41 split_libs="`echo $extra_library_path | sed -e 's/:/ /g'`"
42 for libpath in $split_libs ; do
43 LDFLAGS="-L$libpath $LDFLAGS"
44 done
45
46 # set type of "char" to be "unsigned char"
47 CFLAGS="$CFLAGS -funsigned-char"
48
49 # developer flags
50 AC_ARG_ENABLE([developer], AC_HELP_STRING([--enable-developer], [Compile with warnings and debugging symbols]),
51 CFLAGS="-Wall -Wno-pointer-sign -g $CFLAGS")
52 # debugging
53 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable debug messages]),
54 want_debug=$enableval, want_debug=no)
55 if test "x-$want_debug" = "x-yes" ; then
56 AC_DEFINE(DEBUG,1,[Define to 1 if you want to get debug output with -D.])
57 AC_DEFINE(SX_DEBUG,1,[Define to 1 if you want to get SX debug output with -D.])
58 fi
59
60 AC_ARG_ENABLE(nad_debug, AC_HELP_STRING([--enable-nad-debug], [enable NAD pointer tracking]),
61 want_nad_debug=$enableval, want_nad_debug=no)
62 if test "x-$want_nad_debug" = "x-yes" ; then
63 AC_DEFINE(NAD_DEBUG,1,[Define to 1 if you want to enable NAD pointer tracking.])
64 fi
65
66 AC_ARG_ENABLE(pool_debug, AC_HELP_STRING([--enable-pool-debug], [enable memory pool statistics]),
67 want_pool_debug=$enableval, want_pool_debug=no)
68 if test "x-$want_pool_debug" = "x-yes" ; then
69 AC_DEFINE(POOL_DEBUG,1,[Define to 1 if you want to enable memory pool statistics.])
70 fi
71
72 AC_ARG_ENABLE(mio_debug, AC_HELP_STRING([--enable-mio-debug], [enable managed IO debug output]),
73 want_mio_debug=$enableval, want_mio_debug=no)
74 if test "x-$want_mio_debug" = "x-yes" ; then
75 AC_DEFINE(MIO_DEBUG,1,[Define to 1 if you want to enable managed IO debug output.])
76 fi
77
78 # Colorized build output
79 AX_CHECK_COMPILE_FLAG([-fdiagnostics-color], [CFLAGS="${CFLAGS} -fdiagnostics-color"],
80 [AX_CHECK_COMPILE_FLAG([-fcolor-diagnostics], [CFLAGS="${CFLAGS} -fcolor-diagnostics"])])
81
82 # Two-step header checking. First check for headers which don't
83 # require any other headers.
84 AC_HEADER_DIRENT
85 AC_HEADER_RESOLV
86 AC_HEADER_STDC
87 AC_HEADER_SYS_WAIT
88 AC_HEADER_TIME
89 AC_CHECK_HEADERS([arpa/inet.h \
90 arpa/nameser.h \
91 fcntl.h \
92 netinet/in.h \
93 signal.h \
94 stdarg.h \
95 stdint.h \
96 stdlib.h \
97 string.h \
98 sys/filio.h \
99 sys/ioctl.h \
100 sys/socket.h \
101 sys/time.h \
102 sys/timeb.h \
103 sys/types.h \
104 sys/stat.h \
105 sys/utsname.h \
106 syslog.h \
107 unistd.h \
108 windows.h \
109 winsock2.h \
110 ])
111
112 # Now check for those headers that do, including all the required
113 # headers.
114 AC_CHECK_HEADERS([resolv.h windns.h],,,
115 [#ifdef HAVE_SYS_TYPES_H
116 # include <sys/types.h>
117 #endif
118 #ifdef HAVE_WINSOCK2_H
119 # include <winsock2.h>
120 #endif
121 #ifdef HAVE_NETINET_IN_H
122 # include <netinet/in.h>
123 #endif])
124
125 # Checks for typedefs, structures, and compiler characteristics.
126 AC_C_CONST
127 AC_TYPE_MODE_T
128 AC_TYPE_OFF_T
129 AC_TYPE_PID_T
130 AC_TYPE_SIZE_T
131 AC_HEADER_TIME
132 AC_STRUCT_TM
133 AC_STRUCT_TIMEZONE
134 AC_TYPE_UINT16_T
135 AC_TYPE_UINT32_T
136 AC_TYPE_UINT8_T
137
138 # generic system types
139 AC_CREATE_STDINT_H(ac-stdint.h)
140
141 # Checks for library functions.
142 AC_FUNC_CLOSEDIR_VOID
143 AC_REPLACE_FNMATCH
144 AC_FUNC_FORK
145 AC_FUNC_MEMCMP
146 AC_FUNC_MKTIME
147 AC_FUNC_SELECT_ARGTYPES
148 AC_TYPE_SIGNAL
149 AC_FUNC_STAT
150 AC_FUNC_VPRINTF
151 AC_FUNC_SELECT_ARGTYPES
152 AC_CHECK_FUNCS([close \
153 dup2 \
154 fcntl \
155 _findfirst \
156 gethostname \
157 getopt \
158 getpagesize \
159 getpid \
160 gettimeofday \
161 inet_aton \
162 inet_ntoa \
163 ioctl \
164 isascii \
165 memchr \
166 memmove \
167 memset \
168 mkdir \
169 _mkdir \
170 modf \
171 select \
172 setenv \
173 sleep \
174 Sleep \
175 socket \
176 strcasecmp \
177 strchr \
178 strdup \
179 strerror \
180 stricmp \
181 strncasecmp \
182 strndup \
183 strnicmp \
184 strstr \
185 tzset \
186 uname \
187 ])
188
189 AC_CHECK_FUNC([crypt], ,[AC_CHECK_LIB([crypt], [crypt])])
190 if test "x$ac_cv_lib_crypt_crypt" = "xyes"; then
191 AC_DEFINE(HAVE_CRYPT, 1, [Define to 1 if you have the crypt() function])
192 fi
193 AM_CONDITIONAL(HAVE_CRYPT, [test "x$ac_cv_lib_crypt_crypt" = "xyes"])
194 AC_CHECK_FUNC([connect], ,[AC_CHECK_LIB([socket], [connect])])
195 AC_CHECK_LIB([ws2_32], [_head_libws2_32_a])
196
197 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB([resolv], [gethostbyname])])
198 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB([nsl], [gethostbyname])])
199 if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
200 AC_CHECK_FUNC([gethostbyname], , [AC_CHECK_LIB([socket], [gethostbyname])])
201 fi
202 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
203 AC_MSG_CHECKING([if we can include libnsl + libsocket])
204 LIBS="-lnsl -lsocket $LIBS"
205 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
206 if test "$my_ac_link_result" = "no" ; then
207 AC_MSG_RESULT([failure])
208 AC_MSG_ERROR([unable to use gethostbyname()])
209 else
210 AC_MSG_RESULT([success])
211 fi
212 fi
213
214 AC_SEARCH_LIBS(inet_ntop, nsl,[
215 AC_DEFINE(HAVE_INET_NTOP, 1,
216 [Define to 1 if you have the `inet_ntop' function.])])
217
218 dnl ** Check for inet_ntop
219 AC_SEARCH_LIBS(inet_pton, nsl,[
220 AC_DEFINE(HAVE_INET_PTON, 1,
221 [Define to 1 if you have the `inet_pton' function.])])
222
223 # windows has different names for a few basic things
224 if test "x-$ac_cv_func_getpid" != "x-yes" -a "x-$ac_cv_func__getpid" = "x-yes" ; then
225 AC_DEFINE(getpid,_getpid,[Define to a function than can provide getpid(2) functionality.])
226 fi
227
228 if test "x-$ac_cv_func_sleep" != "x-yes" -a "x-$ac_cv_func_Sleep" = "x-yes" ; then
229 AC_DEFINE(sleep,Sleep,[Define to a function than can provide sleep(2) functionality.])
230 fi
231
232 if test "x-$ac_cv_func_strcasecmp" != "x-yes" -a "x-$ac_cv_func_stricmp" = "x-yes" ; then
233 AC_DEFINE(strcasecmp,stricmp,[Define to a function than can provide strcasecmp(3) functionality.])
234 fi
235
236 if test "x-$ac_cv_func_strncasecmp" != "x-yes" -a "x-$ac_cv_func_strnicmp" = "x-yes" ; then
237 AC_DEFINE(strncasecmp,strnicmp,[Define to a function than can provide strncasecmp(3) functionality.])
238 fi
239
240 # winsock substitutions
241 if test "x-$ac_cv_func_close" != "x-yes" ; then
242 AC_MSG_CHECKING(for closesocket)
243 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]],
244 [[closesocket(0)]])],
245 [AC_MSG_RESULT(yes)
246 AC_DEFINE(close,closesocket,[Define to a function than can provide close(2) functionality.])],
247 AC_DEFINE(HAVE_CLOSE,1,[Define to 1 if you have the 'close' function.])
248 AC_MSG_RESULT(no))
249 fi
250
251 if test "x-$ac_cv_func_ioctl" != "x-yes" ; then
252 AC_MSG_CHECKING(for ioctlsocket)
253 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]],
254 [[ioctlsocket(0,0,0)]])],
255 [AC_MSG_RESULT(yes)
256 AC_DEFINE(ioctl,ioctlsocket,[Define to a function than can provide ioctl(2) functionality.])],
257 AC_DEFINE(HAVE_IOCTL,1,[Define to 1 if you have the 'ioctl' function.])
258 AC_MSG_RESULT(no))
259 fi
260
261 # res_query has been seen in libc, libbind and libresolv
262 if test "x-$ac_cv_header_resolv_h" = "x-yes" ; then
263 AC_CHECK_FUNCS(res_query)
264 if test "x-$ac_cv_func_res_query" = "x-yes" ; then
265 have_res_query=yes
266 else
267 AC_CHECK_LIB(resolv, res_query)
268 if test "x-$ac_cv_lib_resolv_res_query" = "x-yes" ; then
269 have_res_query=yes
270 else
271 AC_CHECK_LIB(bind, res_query)
272 if test "x-$ac_cv_lib_bind_res_query" = "x-yes" ; then
273 have_res_query=yes
274 else
275 dnl some glibcs have res_query as a macro, so work around it
276 AC_MSG_CHECKING([for res_query in -lresolv (alternate version)])
277 save_libs="$LIBS"
278 LIBS="-lresolv $LIBS"
279 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <resolv.h>]],
280 [[res_query(0,0,0,0,0)]])],
281 [AC_MSG_RESULT(yes)
282 have_res_query=yes],
283 [AC_MSG_RESULT(no)
284 LIBS="$save_libs"])
285 fi
286 fi
287 fi
288 fi
289 # windows calls it DnsQuery
290 if test "x-$ac_cv_header_windns_h" = "x-yes" ; then
291 AC_MSG_CHECKING([for DnsQuery in -ldnsapi])
292 save_libs="$LIBS"
293 LIBS="-ldnsapi $LIBS"
294 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <windows.h>
295 #include <windns.h>]],
296 [[DnsQuery(0,0,0,0,0,0)]])],
297 [AC_MSG_RESULT(yes)
298 have_dnsquery=yes],
299 [AC_MSG_RESULT(no)
300 LIBS="$save_libs"])
301 fi
302 if test "x-$have_res_query" = "x-yes" ; then
303 AC_DEFINE(HAVE_RES_QUERY,1,[Define to 1 if you have the 'res_query' function.])
304 elif test "x-$have_dnsquery" = "x-yes" ; then
305 AC_DEFINE(HAVE_DNSQUERY,1,[Define to 1 if you have the 'DnsQuery' function.])
306 else
307 AC_MSG_ERROR([no DNS resolver interface (res_query or DnsQuery) found])
308 fi
309
310 # syslog
311 if test "x-$ac_cv_header_syslog_h" = "x-yes" ; then
312 AC_CHECK_FUNCS(syslog vsyslog)
313 fi
314
315 if test "x-$ac_cv_header_windows_h" = "x-yes" ; then
316 AC_MSG_CHECKING(for ReportEvent)
317 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <windows.h>]],
318 [[ReportEvent(0,0,0,0,0,0,0,0,0)]])],
319 [AC_MSG_RESULT(yes)
320 AC_DEFINE(HAVE_REPORTEVENT,1,[Define to 1 if you have the 'ReportEvent' function.])],
321 AC_MSG_RESULT(no))
322 fi
323
324 # snprintf/vsnprintf don't exist everywhere. additionally, we require
325 # them to gracefully accept NULLs, which is non-standard
326 AC_CHECK_FUNCS(snprintf vsnprintf)
327 if test "x-$ac_cv_func_snprintf" = "x-yes" ; then
328 AC_MSG_CHECKING([if snprintf can handle NULL arguments])
329 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
330 #include <signal.h>
331 segv() { exit(1); }
332 main() { char b[10]; signal(SIGSEGV,segv); snprintf(b,10,"%s",NULL); exit(0); }]])],
333 AC_MSG_RESULT(yes),
334 [AC_MSG_RESULT(no)
335 AC_DEFINE(HAVE_BROKEN_SNPRINTF,1,[Define to 1 if 'snprintf' cannot handle NULL arguments.])])
336 fi
337 if test "x-$ac_cv_func_vsnprintf" = "x-yes" ; then
338 AC_MSG_CHECKING([if vsnprintf can handle NULL arguments])
339 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
340 #include <signal.h>
341 #include <stdarg.h>
342 segv() { exit(1); }
343 expand(char *f,...) { va_list ap; char b[10]; va_start(ap,f); vsnprintf(b,10,f,ap); va_end(ap); }
344 main() { char b[10]; signal(SIGSEGV,segv); expand("%s", NULL); exit(0); }]])],
345 AC_MSG_RESULT(yes),
346 [AC_MSG_RESULT(no)
347 AC_DEFINE(HAVE_BROKEN_VSNPRINTF,1,[Define to 1 if 'vsnprintf' cannot handle NULL arguments.])])
348 fi
349 TYPE_SOCKLEN_T
350 #
351 # Checks for libraries.
352
353 # Expat
354 AC_CHECK_LIB([expat], [XML_ParserCreate])
355 if test "x-$ac_cv_lib_expat_XML_ParserCreate" != "x-yes" ; then
356 AC_MSG_ERROR([Expat not found])
357 fi
358
359 # libidn >= 0.3.0
360 AC_CHECK_LIB(idn, stringprep_check_version)
361 if test "x-$ac_cv_lib_idn_stringprep_check_version" = "x-yes" ; then
362 AC_MSG_CHECKING(for Libidn version >= 0.3.0)
363 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stringprep.h>]],
364 [[return !(stringprep_check_version("0.3.0"))]])],
365 [AC_MSG_RESULT(yes)
366 have_idn=yes],
367 AC_MSG_RESULT(no))
368 fi
369 if test "x-$have_idn" != "x-yes" ; then
370 AC_MSG_ERROR([Libidn >= 0.3.0 not found])
371 fi
372
373 # udns
374 AC_CHECK_LIB(udns, dns_init)
375 if test "x-$ac_cv_lib_udns_dns_init" != "x-yes" ; then
376 AC_MSG_ERROR([UDNS library not found])
377 fi
378
379 # GnuSASL
380 AC_CHECK_HEADERS(gsasl.h)
381 if test "x-$ac_cv_header_gsasl_h" = "x-yes" ; then
382 AC_CHECK_LIB(gsasl, gsasl_check_version)
383 fi
384 if test "x-$ac_cv_lib_gsasl_gsasl_check_version" = "x-yes" ; then
385 AC_MSG_CHECKING(for GnuSASL version >= 1.4.0)
386 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <gsasl.h>]],
387 [[return !(gsasl_check_version("1.4.0"))]])],
388 [AC_MSG_RESULT(yes)
389 have_gsasl=yes],
390 AC_MSG_RESULT(no))
391 fi
392
393 if test "x-$have_gsasl" != "x-yes" ; then
394 AC_MSG_ERROR([GnuSASL >= 1.4.0 not found])
395 fi
396
397 #
398 # optional libs
399
400 # OpenSSL >= 1.0.2
401 AC_ARG_ENABLE(ssl, AC_HELP_STRING([--enable-ssl], [enable SSL/TLS support (yes)]), want_ssl=$enableval, want_ssl=yes)
402 AS_IF([test "x$want_ssl" = "xyes"], [
403 PKG_CHECK_MODULES(SSL, openssl >= 1.0.2,
404 have_ssl="yes"
405 AC_DEFINE(HAVE_SSL,1,[Define to 1 if OpenSSL is available.])
406 )
407 ])
408 AM_CONDITIONAL(HAVE_SSL, [test "x$have_ssl" = "xyes"])
409
410 dnl Check for & handle argument to --with-zlib.
411 _cppflags=$CPPFLAGS
412 _ldflags=$LDFLAGS
413 AC_ARG_WITH(zlib,
414 AC_HELP_STRING([--with-zlib=DIR],[search for zlib in DIR])
415 AC_HELP_STRING([--without-zlib],[disable use of zlib]),
416 [OPT_ZLIB="$withval"])
417
418 if test "$OPT_ZLIB" = "no" ; then
419 AC_MSG_WARN([zlib disabled])
420 else
421 if test "$OPT_ZLIB" = "yes" ; then
422 OPT_ZLIB=""
423 fi
424
425 if test -z "$OPT_ZLIB" ; then
426 dnl check for the lib first without setting any new path, since many
427 dnl people have it in the default path
428
429 AC_CHECK_LIB(z, inflateEnd,
430 dnl libz found, set the variable
431 [HAVE_LIBZ="1"],
432 dnl if no lib found, try /usr/local
433 [OPT_ZLIB="/usr/local"])
434
435 fi
436
437 dnl Add a nonempty path to the compiler flags
438 if test -n "$OPT_ZLIB"; then
439 CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
440 LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
441 fi
442
443 AC_CHECK_HEADER(zlib.h,
444 [
445 dnl zlib.h was found
446 HAVE_ZLIB_H="1"
447 dnl if the lib wasn't found already, try again with the new paths
448 if test "$HAVE_LIBZ" != "1"; then
449 AC_CHECK_LIB(z, gzread,
450 [
451 dnl the lib was found!
452 HAVE_LIBZ="1"
453 ],
454 [ CPPFLAGS=$_cppflags
455 LDFLAGS=$_ldflags])
456 fi
457 ],
458 [
459 dnl zlib.h was not found, restore the flags
460 CPPFLAGS=$_cppflags
461 LDFLAGS=$_ldflags]
462 )
463
464 if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
465 then
466 AC_MSG_WARN([configure found only the libz lib, not the header file!])
467 elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
468 then
469 AC_MSG_WARN([configure found only the libz header file, not the lib!])
470 elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
471 then
472 dnl both header and lib were found!
473 AC_SUBST(HAVE_LIBZ)
474 AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
475 AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
476 LIBS="$LIBS -lz"
477 fi
478 fi
479 AM_CONDITIONAL(HAVE_LIBZ, [test "$HAVE_LIBZ" = "1"])
480
481 # MySQL
482 AC_ARG_ENABLE([mysql],
483 AC_HELP_STRING([--enable-mysql[=DIR]], [enable MySQL auth/reg/storage support (no)]),
484 [ enable_mysql="$enableval" have_mysql=no MYSQL_PREFIX="$enableval" ],
485 [ enable_mysql=no have_mysql=no ])
486
487 if test "x-$enable_mysql" != "x-no" ; then
488 if test "$MYSQL_PREFIX" = "yes" ; then
489 MYSQL_PREFIX=/usr
490 fi
491
492 AC_PATH_PROG(mysqlconfig,mysql_config,,[$MYSQL_PREFIX/bin:$PATH])
493 if test [ -z "$mysqlconfig" ]
494 then
495 AC_MSG_ERROR([mysql_config executable not found: MySQL 5.0 or greater is required.])
496 else
497 AC_MSG_CHECKING(MySQL libraries)
498 MYSQL_LIBS=`${mysqlconfig} --libs`
499 AC_MSG_RESULT("$MYSQL_LIBS")
500
501 AC_MSG_CHECKING(mysql includes)
502 MYSQL_CFLAGS=`${mysqlconfig} --cflags`
503 AC_MSG_RESULT("$MYSQL_CFLAGS")
504
505 MYSQL_VERSION=`${mysqlconfig} --version`
506 MYSQL_VERSION_MAJOR=${MYSQL_VERSION%%.*}
507 if test $MYSQL_VERSION_MAJOR -lt 5 ; then
508 AC_MSG_ERROR([MySQL version 5.0 or greater required.])
509 fi
510
511 have_mysql=yes
512 AC_DEFINE(STORAGE_MYSQL, 1, [Define to 1 if you want to use MySQL for storage.])
513 fi
514 fi
515 AC_SUBST(MYSQL_CFLAGS)
516 AC_SUBST(MYSQL_LIBS)
517 AM_CONDITIONAL(STORAGE_MYSQL, [test "x-$have_mysql" = "x-yes"])
518
519 # PostgreSQL
520 AC_ARG_ENABLE([pgsql],
521 AC_HELP_STRING([--enable-pgsql[=DIR]], [enable PostgreSQL auth/reg/storage support (no)]),
522 [ enable_pgsql="$enableval" have_pgsql=no PGSQL_PREFIX="$enableval"],
523 [ enable_pgsql=no have_pgsql=no ])
524 if test "x-$enable_pgsql" != "x-no" ; then
525 if test "$PGSQL_PREFIX" = "yes" ; then
526 PGSQL_PREFIX=/usr
527 fi
528
529 AC_PATH_PROG(pgconfig,pg_config,,[$PGSQL_PREFIX/bin:$PATH])
530 if test [ -z "$pgconfig" ]
531 then
532 AC_MSG_ERROR([pg_config executable not found: PostgreSQL 8.0 or greater is required.])
533 else
534 AC_MSG_CHECKING(PostgresSQL libraries)
535 PGSQL_LIBDIR=`$pgconfig --libdir`
536 PGSQL_LIBS="-L$PGSQL_LIBDIR -lpq"
537 AC_MSG_RESULT("$PGSQL_LIBS")
538
539 AC_MSG_CHECKING(pgsql includes)
540 PGSQL_INCLUDE=`$pgconfig --includedir`
541 PGSQL_CFLAGS="-I$PGSQL_INCLUDE"
542 AC_MSG_RESULT("$PGSQL_CFLAGS")
543
544 have_pgsql=yes
545 AC_DEFINE([STORAGE_POSTGRES],[1],[Define to 1 if you want to use PostgreSQL for storage.])
546 fi
547 fi
548 AC_SUBST(PGSQL_CFLAGS)
549 AC_SUBST(PGSQL_LIBS)
550 AM_CONDITIONAL(STORAGE_PGSQL, [test "x-$have_pgsql" = "x-yes"])
551
552 # SQLite 3
553 AC_ARG_ENABLE([sqlite],
554 AS_HELP_STRING([--enable-sqlite], [enable SQLite3 auth/reg/storage support (no)]),
555 [enable_sqlite=$enableval have_sqlite=no],
556 [enable_sqlite=no have_sqlite=no])
557 if test "x-$enable_sqlite" = "x-yes" ; then
558 AC_CHECK_HEADERS([sqlite3.h], [
559 AC_CHECK_LIB([sqlite3], [sqlite3_open], [
560 have_sqlite=yes
561 SQLITE_LIBS="-lsqlite3"
562 AC_DEFINE(STORAGE_SQLITE, 1, [Define to 1 if you want to use SQLite 3 for storage.])
563 ])
564 ])
565 if test "x-$have_sqlite" != "x-yes" ; then
566 AC_MSG_ERROR([SQLite3 support requested, but headers/libraries not found.])
567 fi
568 fi
569 AC_SUBST(SQLITE_LIBS)
570 AM_CONDITIONAL(STORAGE_SQLITE, [test "x-$have_sqlite" = "x-yes"])
571
572 # Berkeley DB
573 _save_libs="$LIBS"
574 AC_ARG_ENABLE(db, AC_HELP_STRING([--enable-db], [enable Berkeley DB auth/reg/storage support (no)]),
575 want_db=$enableval, want_db=no)
576 if test "x-$want_db" = "x-yes" ; then
577 AC_CHECK_HEADERS(db.h)
578 if test "x-$ac_cv_header_db_h" = "x-yes" ; then
579 for lib in db43 db42 db-4.3 db-4.2 db-4.1 db-4 db4 db41 db ; do
580 if test "xxx$have_db_version" != "xxxyes" ; then
581 AC_MSG_CHECKING([for db_create in -l$lib])
582 save_libs="$LIBS"
583 LIBS="-l$lib $LIBS"
584 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <db.h>]],
585 [[db_create(0,0,0)]])],
586 [AC_MSG_RESULT(yes)
587 AC_MSG_CHECKING(for Berkeley DB version >= 4.1.25)
588 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <db.h>]],
589 [[do {
590 int major, minor, patch;
591 db_version(&major, &minor, &patch);
592 if(major < 4 ||
593 (major == 4 && minor < 1) ||
594 (major == 4 && minor == 1 && patch < 24) ||
595 (int)DB_VERSION_MAJOR != major ||
596 (int)DB_VERSION_MINOR != minor)
597 return 1;
598 } while(0)]])],
599 [AC_MSG_RESULT(yes)
600 have_db_version=yes
601 DB_LIBS="-l$lib"],
602 AC_MSG_RESULT(no))],
603 AC_MSG_RESULT(no))
604 LIBS="$save_libs"
605 fi
606 done
607 fi
608 if test "x-$have_db_version" != "x-yes" ; then
609 AC_MSG_ERROR([Berkeley DB >= 4.1.24 not found])
610 else
611 AC_DEFINE(STORAGE_DB,1,[Define to 1 if you want to use Berkeley DB for auth/reg/storage.])
612 fi
613 fi
614 AC_SUBST(DB_LIBS)
615 AM_CONDITIONAL(STORAGE_DB, [test "x-$have_db_version" = "x-yes"])
616 LIBS="$_save_libs"
617
618 # Oracle
619 AC_ARG_WITH(oracle-home,
620 AC_HELP_STRING([--with-oracle-home=DIR], [the Oracle home directory, for includes and libs]),
621 [ ac_oracle_home="$withval" ])
622
623 AC_ARG_ENABLE(oracle, AC_HELP_STRING([--enable-oracle], [enable Oracle auth/reg/storage support (no)]),
624 want_oracle=$enableval, want_oracle=no)
625 if test "x-$want_oracle" = "x-yes" ; then
626 AC_CHECK_HEADERS(oci.h)
627 if test "x-$ac_cv_header_oci_h" != "x-yes" ; then
628 if test -n $ac_oracle_home ; then
629 AC_MSG_CHECKING([for oci.h in $ac_oracle_home])
630 save_cppflags="$CPPFLAGS"
631 CPPFLAGS="-I$ac_oracle_home/rdbms/demo -I$ac_oracle_home/rdbms/public $CPPFLAGS"
632 save_libs="$LIBS"
633 LIBS="-L$ac_oracle_home/lib $LIBS"
634 save_ldflags="$LDFLAGS"
635 LDFLAGS="-Wl,-rpath,$ac_oracle_home/lib $LDFLAGS"
636 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <oci.h>]])],
637 [AC_MSG_RESULT(yes)
638 AC_DEFINE(HAVE_OCI_H,,[Define if you have oci.h])
639 ac_cv_header_oci_h=yes],
640 AC_MSG_RESULT(no))
641 if test "x-$ac_cv_header_oci_h" != "x-yes" ; then
642 CPPFLAGS="$save_cppflags"
643 LIBS="$save_libs"
644 LDFLAGS="$save_ldflags"
645 fi
646 fi
647 fi
648 if test "x-$ac_cv_header_oci_h" = "x-yes" ; then
649 AC_CHECK_LIB(clntsh, OCIInitialize)
650 fi
651 if test "x-$ac_cv_lib_clntsh_OCIInitialize" != "x-yes" ; then
652 AC_MSG_ERROR([Oracle client libraries not found])
653 else
654 have_oracle="yes"
655 ORACLE_CPPFLAGS="-I$ac_oracle_home/rdbms/demo -I$ac_oracle_home/rdbms/public"
656 ORACLE_LIBS="-L$ac_oracle_home/lib"
657 ORACLE_LDFLAGS="-Wl,-rpath,$ac_oracle_home/lib"
658 AC_DEFINE(STORAGE_ORACLE,1,[Define to 1 if you want to use Oracle for auth/reg/storage.])
659 fi
660 fi
661 AC_SUBST(ORACLE_CPPFLAGS)
662 AC_SUBST(ORACLE_LIBS)
663 AC_SUBST(ORACLE_LDFLAGS)
664 AM_CONDITIONAL(STORAGE_ORACLE, [test "x-$have_oracle" = "x-yes"])
665
666 # OpenLDAP
667 AC_ARG_ENABLE(ldap, AC_HELP_STRING([--enable-ldap], [enable OpenLDAP auth/reg support (no)]),
668 want_ldap=$enableval, want_ldap=no)
669 if test "x-$want_ldap" = "x-yes" ; then
670 AC_CHECK_HEADERS(lber.h ldap.h)
671 save_libs="$LIBS"
672 if test "x-$ac_cv_header_ldap_h" = "x-yes" -a "x-$ac_cv_header_lber_h" = "x-yes" ; then
673 AC_CHECK_LIB(lber, ber_alloc)
674 AC_CHECK_LIB(ldap, ldap_init)
675 fi
676 if test "x-$ac_cv_lib_lber_ber_alloc" = "x-yes" -a "x-$ac_cv_lib_ldap_ldap_init" = "x-yes" ; then
677 AC_MSG_CHECKING(for OpenLDAP version >= 2.1.0)
678 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <lber.h>
679 #include <ldap.h>]],
680 [[do {
681 LDAPAPIInfo info;
682 info.ldapai_info_version = LDAP_API_INFO_VERSION;
683 ldap_get_option(0, LDAP_OPT_API_INFO, &info);
684 if(info.ldapai_vendor_version != LDAP_VENDOR_VERSION || LDAP_VENDOR_VERSION < 2004)
685 return 1;
686 } while(0)]])],
687 [AC_MSG_RESULT(yes)
688 have_ldap_version=yes],
689 AC_MSG_RESULT(no))
690 fi
691 LIBS="$save_libs"
692 if test "x-$have_ldap_version" != "x-yes" ; then
693 AC_MSG_ERROR([OpenLDAP client libraries >= 2.1.0 not found])
694 else
695 LDAP_LIBS="-llber -lldap"
696 AC_DEFINE(STORAGE_LDAP,1,[Define to 1 if you want to use OpenLDAP for auth/reg.])
697 fi
698 fi
699 AC_SUBST(LDAP_LIBS)
700 AM_CONDITIONAL(STORAGE_LDAP, [test "x-$have_ldap_version" = "x-yes"])
701
702 # Plugabble Authentication Modules (PAM)
703 AC_ARG_ENABLE(pam, AC_HELP_STRING([--enable-pam], [enable PAM auth/reg support (no)]),
704 want_pam=$enableval, want_pam=no)
705 if test "x-$want_pam" = "x-yes" ; then
706 AC_CHECK_HEADERS(security/pam_appl.h)
707 if test "x-$ac_cv_header_security_pam_appl_h" = "x-yes" ; then
708 AC_CHECK_LIB(pam, pam_start, [
709 have_pam="yes"
710 PAM_LIBS="-lpam"
711 AC_DEFINE(STORAGE_PAM,1,[Define to 1 if you want to use PAM for auth/reg.])
712 ], [AC_MSG_ERROR([PAM application libraries not found])])
713 fi
714 fi
715 AC_SUBST(PAM_LIBS)
716 AM_CONDITIONAL(STORAGE_PAM, [test "x-$have_pam" = "x-yes"])
717
718 # pipe (not really an external package, but does need some checks)
719 AC_ARG_ENABLE(pipe, AC_HELP_STRING([--enable-pipe], [enable pipe auth/reg support (no)]),
720 want_pipe=$enableval, want_pipe=no)
721 if test "x-$want_pipe" = "x-yes" ; then
722 AC_CHECK_HEADERS(sys/wait.h)
723 AC_FUNC_FORK
724 AC_CHECK_FUNCS(pipe wait)
725 if test "x-$ac_cv_header_sys_wait_h" != "x-yes" -o \
726 "x-$ac_cv_func_fork" != "x-yes" -o \
727 "x-$ac_cv_func_pipe" != "x-yes" -o \
728 "x-$ac_cv_func_wait" != "x-yes" ; then
729 AC_MSG_ERROR([Pipe auth/reg requirements (sys/wait.h, fork(), pipe(), wait()) not found])
730 else
731 have_pipe="yes"
732 AC_DEFINE(STORAGE_PIPE,1,[Define to 1 if you want to use pipes for auth/reg.])
733 fi
734 fi
735 AM_CONDITIONAL(STORAGE_PIPE, [test "x-$have_pipe" = "x-yes"])
736
737 # Anonymous
738 AC_ARG_ENABLE(anon, AC_HELP_STRING([--enable-anon], [enable anonymous auth/reg support (no)]),
739 want_anon=$enableval, want_anon=no)
740 if test "x-$want_anon" = "x-yes" ; then
741 AC_DEFINE(STORAGE_ANON,1,[Define to 1 if you want anonymous auth.])
742 fi
743 AM_CONDITIONAL(STORAGE_ANON, [test "x-$want_anon" = "x-yes"])
744
745
746 # Filesystem storage
747 AC_ARG_ENABLE(fs, AC_HELP_STRING([--enable-fs], [enable filesystem storage support (no)]),
748 want_fs=$enableval, want_fs=no)
749 if test "x-$want_fs" = "x-yes" ; then
750 AC_DEFINE(STORAGE_FS,1,[Define to 1 if you want to use the filesystem for storage.])
751 fi
752 AM_CONDITIONAL(STORAGE_FS, [test "x-$want_fs" = "x-yes"])
753
754 # WebSocket support
755 AC_ARG_ENABLE(websocket, AC_HELP_STRING([--enable-websocket], [enable WebSocket support on C2S port (no)]),
756 want_websocket=$enableval, want_websocket=no)
757 if test "x-$want_websocket" = "x-yes" ; then
758 AC_CHECK_LIB([http_parser], [http_parser_init])
759 if test "x-$ac_cv_lib_http_parser_http_parser_init" != "x-yes" ; then
760 AC_MSG_ERROR([http_parser not found])
761 else
762 AC_DEFINE(USE_WEBSOCKET,1,[Define to 1 if you want to have WebSocket support in C2S.])
763 fi
764 fi
765 AM_CONDITIONAL(USE_WEBSOCKET, [test "x-$want_websocket" = "x-yes"])
766
767 #
768 # IPv6 checks
769 AC_DEFUN([_IP6_INCLUDES],[[
770 #include "ac-stdint.h"
771 #ifdef HAVE_SYS_TYPES_H
772 # include <sys/types.h>
773 #endif
774 #ifdef HAVE_SYS_SOCKET_H
775 # include <sys/socket.h>
776 #endif
777 #ifdef HAVE_NETINET_IN_H
778 # include <netinet/in.h>
779 #endif
780 #ifdef HAVE_ARPA_INET_H
781 # include <arpa/inet.h>
782 #endif
783 ]])
784
785 # these types are sometimes missing
786 AC_CHECK_TYPES([in_port_t, sa_family_t, struct sockaddr_storage, struct sockaddr_in6, struct in6_addr],,, _IP6_INCLUDES)
787
788 # some glibcs have broken sockaddr_storage members
789 if test "x-$ac_cv_type_struct_sockaddr_storage" = "x-yes" ; then
790 AC_MSG_CHECKING(for broken __ss_family member in struct sockaddr_storage)
791 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(_IP6_INCLUDES,
792 [[do {
793 struct sockaddr_storage s;
794 s.__ss_family = 0;
795 } while(0)]])],
796 [AC_MSG_RESULT(yes)
797 AC_DEFINE(ss_family, __ss_family,
798 [Define to '__ss_family' if 'struct sockaddr_storage' defines '__ss_family' instead of 'ss_family'.])],
799 AC_MSG_RESULT(no))
800
801 AC_MSG_CHECKING(for broken __ss_len member in struct sockaddr_storage)
802 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(_IP6_INCLUDES,
803 [[do {
804 struct sockaddr_storage s;
805 s.__ss_len = 0;
806 } while(0)]])],
807 [AC_MSG_RESULT(yes)
808 AC_DEFINE(ss_len, __ss_len,
809 [Define to '__ss_len' if 'struct sockaddr_storage' defines '__ss_len' instead of 'ss_len'.])],
810 AC_MSG_RESULT(no))
811 fi
812
813
814 #
815 # mio backend selection
816
817 AC_ARG_ENABLE(mio, AC_HELP_STRING([--enable-mio=BACKENDS], [use one of BACKENDS to drive MIO (select poll epoll kqueue)]),
818 mio_check=$enableval, mio_check='select poll epoll kqueue')
819
820 mio_backend=''
821 for backend in $mio_check ; do
822 case x-$backend in
823
824 x-kqueue)
825 AC_CHECK_HEADERS(sys/event.h)
826 if test "x-$ac_cv_header_sys_event_h" = "x-yes" ; then
827 AC_CHECK_FUNCS(kqueue,[
828 mio_backend='kqueue'
829 AC_DEFINE(MIO_KQUEUE,1,[Define to 1 if you want to use 'kqueue' for non-blocking I/O.])])
830 fi
831 ;;
832
833 x-epoll)
834 AC_CHECK_HEADERS(sys/epoll.h)
835 if test "x-$ac_cv_header_sys_epoll_h" = "x-yes" ; then
836 AC_CHECK_FUNCS(epoll_create,[
837 mio_backend='epoll'
838 AC_DEFINE(MIO_EPOLL,1,[Define to 1 if you want to use 'epoll' for non-blocking I/O.])])
839 fi
840 ;;
841
842 x-poll)
843 AC_CHECK_HEADERS(poll.h)
844 if test "x-$ac_cv_header_poll_h" = "x-yes" ; then
845 AC_CHECK_FUNCS(poll,[
846 mio_backend='poll'
847 AC_DEFINE(MIO_POLL,1,[Define to 1 if you want to use 'poll' for non-blocking I/O.])])
848 fi
849 ;;
850
851 x-select)
852 AC_CHECK_HEADERS(sys/select.h)
853 if test "x-$ac_cv_header_sys_select_h" = "x-yes" ; then
854 AC_CHECK_FUNCS(select, have_select=yes)
855 fi
856
857 if test "x-$have_select" != "x-yes" -a "x-$ac_cv_header_winsock2_h" = "x-yes" ; then
858 AC_MSG_CHECKING([for select in ws2_32])
859 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]],
860 [[select(0,0,0,0,0)]])],
861 [AC_MSG_RESULT(yes)
862 have_select=yes],
863 AC_MSG_RESULT(no))
864 fi
865
866 if test "x-$have_select" = "x-yes" ; then
867 mio_backend='select'
868 AC_DEFINE(MIO_SELECT,1,[Define to 1 if you want to use 'select' for non-blocking I/O.])
869 fi
870 ;;
871 esac
872 done
873
874 if test "x-$mio_backend" = "x-" ; then
875 AC_MSG_ERROR([no MIO backend available out of: $mio_check])
876 else
877 AC_MSG_NOTICE([using MIO backend: $mio_backend])
878 fi
879
880 # use libc function substitution library?
881 AC_ARG_WITH(subst,
882 AC_HELP_STRING([--without-subst],[disable use of substitution library]),
883 [OPT_LIBSUBST="$withval"])
884 AC_SUBST(USE_LIBSUBST)
885 AM_CONDITIONAL(USE_LIBSUBST, [test "$OPT_LIBSUBST" != "no"])
886
887 # conditional features
888 AC_ARG_ENABLE(superseded, AC_HELP_STRING([--enable-superseded], [enable superseded XEP support (yes)]),
889 want_superseded=$enableval, want_superseded=no)
890 if test "x-$want_superseded" = "x-yes" ; then
891 AC_DEFINE(ENABLE_SUPERSEDED,1,[Define to 1 if you want to compile-in superseded XEP handlers.])
892 fi
893
894 AC_ARG_ENABLE(experimental, AC_HELP_STRING([--enable-experimental], [enable experimental features (yes)]),
895 want_experimental=$enableval, want_experimental=no)
896 if test "x-$want_experimental" = "x-yes" ; then
897 AC_DEFINE(ENABLE_EXPERIMENTAL,1,[Define to 1 if you want to compile-in experimental features.])
898 fi
899 AM_CONDITIONAL(ENABLE_EXPERIMENTAL, [test "x-$want_experimental" = "x-yes"])
900
901 AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [enable tests (yes)]),
902 want_tests=$enableval, want_tests=yes)
903 if test "x-$want_tests" = "x-yes" ; then
904 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [want_tests=yes], [want_tests=no])
905 fi
906 AM_CONDITIONAL(ENABLE_TESTS, [test "x-$want_tests" = "x-yes"])
907
908 AC_ARG_ENABLE([werror], AC_HELP_STRING([--enable-werror], [Treat all warnings as error]),
909 CFLAGS="-Wall -Werror $CFLAGS")
910
911 # Generate Makefiles
912 AC_CONFIG_FILES([Doxyfile
913 Makefile
914 etc/Makefile
915 etc/templates/Makefile
916 man/Makefile
917 subst/Makefile
918 util/Makefile
919 mio/Makefile
920 sx/Makefile
921 storage/Makefile
922 c2s/Makefile
923 router/Makefile
924 s2s/Makefile
925 sm/Makefile
926 tools/Makefile
927 tests/Makefile])
928 AC_OUTPUT