1 dnl YAZ Toolkit, Index Data 1994-2003
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.112 2003-04-28 21:02:15 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 2.0.2)
8 AC_SUBST(READLINE_LIBS)
9 AC_SUBST(YAZ_CONF_CFLAGS)
10 dnl ------ Checking programs
13 AC_CHECK_PROGS(YACC, 'bison -y')
14 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
21 AC_ARG_WITH(dtd, [ --with-dtd[=DIR] use docbookx.dtd in DIR],
23 if test -f "$withval/docbookx.dtd"; then
27 AC_MSG_CHECKING(for docbookx.dtd)
28 for d in /usr/share/sgml/docbook/dtd/xml/4.1.2 \
29 /usr/share/sgml/docbook/xml-dtd-4.1.2* \
30 /usr/share/sgml/docbook/xml-dtd-4.1 \
31 /usr/share/sgml/docbook/dtd/xml/4.0 \
32 /usr/lib/sgml/dtd/docbook-xml
34 if test -f $d/docbookx.dtd; then
40 if test -z "$DTD_DIR"; then
41 AC_MSG_RESULT(Not found)
45 AC_ARG_WITH(dsssl,[ --with-dsssl[=DIR] use Docbook DSSSL in DIR/{html,print}/docbook.dsl],
47 if test -f "$withval/html/docbook.dsl"; then
51 AC_MSG_CHECKING(for docbook.dsl)
52 for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
53 /usr/share/sgml/docbook/dsssl-stylesheets-1.* \
54 /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh
56 if test -f $d/html/docbook.dsl; then
62 if test -z "$DSSSL_DIR"; then
63 AC_MSG_RESULT(Not found)
67 AC_ARG_WITH(xsl,[ --with-xsl[=DIR] use Docbook XSL in DIR/{htmlhelp,xhtml}],
69 if test -f "$withval/htmlhelp/htmlhelp.xsl"; then
73 AC_MSG_CHECKING(for htmlhelp.xsl)
74 for d in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh \
75 /usr/share/sgml/docbook/xsl-stylesheets-1.*
77 if test -f $d/htmlhelp/htmlhelp.xsl; then
83 if test -z "$XSL_DIR"; then
84 AC_MSG_RESULT(Not found)
90 AC_CHECK_FUNC(connect)
91 if test "$ac_cv_func_connect" = "no"; then
92 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
94 if test "$checkBoth" = "1"; then
96 LIBS="$LIBS -lsocket -lnsl"
97 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
99 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
103 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
111 if test "$openssl" != "no"; then
114 if test "$openssl" != "yes"; then
115 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
116 SSL_LIBS="-L$openssl/lib"
117 CFLAGS="$SSL_CFLAGS $CFLAGS"
118 LIBS="$SSL_LIBS $LIBS"
120 AC_CHECK_LIB(crypto, main,[SSL_LIBS="$SSL_LIBS -lcrypto"])
121 LIBS="$LIBS $SSL_LIBS"
122 AC_CHECK_LIB(ssl, SSL_new)
123 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
124 SSL_LIBS="$SSL_LIBS -lssl"
125 AC_CHECK_HEADER(openssl/ssl.h,[SSL_DEFS="-DHAVE_OPENSSL_SSL_H=1"; USE_SSL=1])
132 AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
134 dnl ------ GNU Readline
135 READLINE_SHARED_LIBADD=""
136 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
137 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
140 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
141 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
142 if test "$ac_cv_lib_readline_readline" = "yes"; then
143 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
145 LIBS="$LIBS $READLINE_LIBS"
148 #include <readline/readline.h>
152 rl_attempted_completion_over = 0;
154 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
157 #include <readline/readline.h>
161 rl_completion_matches (0, 0);
163 ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
167 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
168 if test "$with_iconv" != "no"; then
169 AC_MSG_CHECKING(for iconv)
171 oldCPPFLAGS="${CPPFLAGS}"
172 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
173 LIBS="$LIBS -L${with_iconv}/lib"
174 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
179 static void f() {iconv_t t = iconv_open("", ""); }
181 AC_DEFINE(HAVE_ICONV_H)
188 static void f() {iconv_t t = iconv_open("", ""); }
190 AC_DEFINE(HAVE_ICONV_H)
194 CPPFLAGS="$oldCPPFLAGS"
199 dnl ------ various functions
200 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
201 if test "$ac_cv_func_poll" = "yes"; then
202 AC_CHECK_HEADERS(sys/poll.h)
205 AC_MSG_CHECKING([for socklen_t])
206 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
208 #include <sys/types.h>
209 #include <sys/socket.h>
213 extern int accept(int, struct sockaddr *, socklen_t *);
217 ],,[ac_cv_check_socklen_t=socklen_t],[
219 #include <sys/types.h>
220 #include <sys/socket.h>
224 extern int accept(int, struct sockaddr *, size_t t *);
228 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
231 AC_MSG_RESULT($ac_cv_check_socklen_t)
232 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
235 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
236 if test "$enable_tcpd" != ""; then
238 oldCPPFLAGS=$CPPFLAGS
239 if test "$enable_tcpd" != "yes"; then
240 LIBS="$LIBS -L$enable_tcpd/lib"
241 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
243 AC_MSG_CHECKING(for working tcpd.h)
244 LIBS="$LIBS -lwrap -lnsl"
245 AC_TRY_LINK([#include <syslog.h>
247 int allow_severity = LOG_INFO;
248 int deny_severity = LOG_WARNING;],
249 [struct request_info request_info; int i;
250 i = hosts_access(&request_info);],
251 tcpd_ok=1, tcpd_ok=0)
252 if test "$tcpd_ok" = "0"; then
255 CPPFLAGS=$oldCPPFLAGS
258 AC_DEFINE(HAVE_TCPD_H)
263 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
265 if test "$ac_cv_header_stdc" = "no"; then
266 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
270 AC_SUBST(CFLAGSTHREADS)
275 dnl ------ GNU threads
276 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
278 if test "$enable_pth" = "yes"; then
280 AC_CHECK_LIB(pth,main)
281 if test "$ac_cv_lib_pth_main" = "yes"; then
282 AC_CHECK_HEADERS(pth.h)
283 if test "$ac_cv_header_pth_h" = "yes"; then
285 CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
292 dnl ------ POSIX Threads
293 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
294 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
297 AC_CHECK_LIB(pthread,main)
298 AC_MSG_CHECKING(for working POSIX Threads)
299 AC_TRY_LINK([#include <pthread.h>
300 void *func(void *p) { return 0; }
302 pthread_t pthread_id;
303 pthread_create (&pthread_id, 0, func, 0);],
304 thread_ok=yes,thread_ok=no)
305 if test "$thread_ok" = "yes"; then
307 LIBTHREAD="-lpthread"
308 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
312 AC_TRY_LINK([#include <pthread.h>
313 void *func(void *p) { return 0; }
315 pthread_t pthread_id;
316 pthread_create (&pthread_id, 0, func, 0);],
317 thread_ok=yes,thread_ok=no)
318 if test "$thread_ok" = "yes"; then
319 AC_MSG_RESULT([yes,BSD])
320 CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
325 if test "$thread_ok" = "no"; then
331 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
335 AC_SUBST(XML2_CFLAGS)
337 AC_ARG_WITH(xml2, [ --with-xml2[=PREFIX] use libxml2 in PREFIX],[xml2dir=$withval])
338 if test "$xml2dir" = "yes"; then
339 for d in /usr /usr/local; do
340 if test -x $d/bin/xml2-config; then
345 if test "$xml2dir" != "no"; then
346 AC_MSG_CHECKING(for libXML2)
347 if test -x $xml2dir/bin/xml2-config; then
348 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
349 LIBS="$XML2_LIBS $LIBS"
350 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
351 XML2_VER=`$xml2dir/bin/xml2-config --version`
352 AC_MSG_RESULT($XML2_VER)
355 AC_MSG_RESULT(Not found)
359 dnl ------ Memory debugging
360 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
361 if test "$enable_memdebug" = "yes"; then
362 AC_DEFINE(TRACE_XMALLOC,2)
363 elif test "$enable_memdebug" = "no"; then
364 AC_DEFINE(TRACE_XMALLOC,0)
367 dnl ------ Using this for "in-source" yaz-config
368 AC_SUBST(YAZ_SRC_ROOT)
369 AC_SUBST(YAZ_BUILD_ROOT)
370 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
402 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > lib/yaz-config && chmod +x yaz-config lib/yaz-config])