1 dnl YAZ Toolkit, Index Data 1994-2003
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.114 2003-06-04 13:28:37 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 2.0.3)
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 dnl We check for socklen_t by making prototypes with the
206 dnl various types. First socklen_t, then size_t, finally int.
207 dnl If the prototype succeeds, we're probably safe.
208 dnl That works if accept is not preprocessor defined (such sa AIX)
209 AC_MSG_CHECKING([for socklen_t])
210 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
212 #include <sys/types.h>
213 #include <sys/socket.h>
224 extern int accept(int, struct sockaddr *, socklen_t *);
229 ],,[ac_cv_check_socklen_t=socklen_t],[
231 #include <sys/types.h>
232 #include <sys/socket.h>
243 extern int accept(int, struct sockaddr *, size_t t *);
248 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
251 AC_MSG_RESULT($ac_cv_check_socklen_t)
252 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
255 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
256 if test "$enable_tcpd" != ""; then
258 oldCPPFLAGS=$CPPFLAGS
259 if test "$enable_tcpd" != "yes"; then
260 LIBS="$LIBS -L$enable_tcpd/lib"
261 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
263 AC_MSG_CHECKING(for working tcpd.h)
264 LIBS="$LIBS -lwrap -lnsl"
265 AC_TRY_LINK([#include <syslog.h>
267 int allow_severity = LOG_INFO;
268 int deny_severity = LOG_WARNING;],
269 [struct request_info request_info; int i;
270 i = hosts_access(&request_info);],
271 tcpd_ok=1, tcpd_ok=0)
272 if test "$tcpd_ok" = "0"; then
275 CPPFLAGS=$oldCPPFLAGS
278 AC_DEFINE(HAVE_TCPD_H)
283 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
285 if test "$ac_cv_header_stdc" = "no"; then
286 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
290 AC_SUBST(CFLAGSTHREADS)
295 dnl ------ GNU threads
296 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
298 if test "$enable_pth" = "yes"; then
300 AC_CHECK_LIB(pth,main)
301 if test "$ac_cv_lib_pth_main" = "yes"; then
302 AC_CHECK_HEADERS(pth.h)
303 if test "$ac_cv_header_pth_h" = "yes"; then
305 CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
312 dnl ------ POSIX Threads
313 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
314 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
317 AC_CHECK_LIB(pthread,main)
318 AC_MSG_CHECKING(for working POSIX Threads)
319 AC_TRY_LINK([#include <pthread.h>
320 void *func(void *p) { return 0; }
322 pthread_t pthread_id;
323 pthread_create (&pthread_id, 0, func, 0);],
324 thread_ok=yes,thread_ok=no)
325 if test "$thread_ok" = "yes"; then
327 LIBTHREAD="-lpthread"
328 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
332 AC_TRY_LINK([#include <pthread.h>
333 void *func(void *p) { return 0; }
335 pthread_t pthread_id;
336 pthread_create (&pthread_id, 0, func, 0);],
337 thread_ok=yes,thread_ok=no)
338 if test "$thread_ok" = "yes"; then
339 AC_MSG_RESULT([yes,BSD])
340 CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
345 if test "$thread_ok" = "no"; then
351 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
355 AC_SUBST(XML2_CFLAGS)
357 AC_ARG_WITH(xml2, [ --with-xml2[=PREFIX] use libxml2 in PREFIX],[xml2dir=$withval])
358 if test "$xml2dir" = "yes"; then
359 for d in /usr /usr/local; do
360 if test -x $d/bin/xml2-config; then
365 if test "$xml2dir" != "no"; then
366 AC_MSG_CHECKING(for libXML2)
367 if test -x $xml2dir/bin/xml2-config; then
368 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
369 LIBS="$XML2_LIBS $LIBS"
370 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
371 XML2_VER=`$xml2dir/bin/xml2-config --version`
372 AC_MSG_RESULT($XML2_VER)
375 AC_MSG_RESULT(Not found)
379 dnl ------ Memory debugging
380 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
381 if test "$enable_memdebug" = "yes"; then
382 AC_DEFINE(TRACE_XMALLOC,2)
383 elif test "$enable_memdebug" = "no"; then
384 AC_DEFINE(TRACE_XMALLOC,0)
387 dnl ------ Using this for "in-source" yaz-config
388 AC_SUBST(YAZ_SRC_ROOT)
389 AC_SUBST(YAZ_BUILD_ROOT)
390 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
422 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > lib/yaz-config && chmod +x yaz-config lib/yaz-config])