1 dnl YAZ Toolkit, Index Data 1994-2003
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.106 2003-02-17 22:35:47 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 1.9.3)
7 AC_SUBST(READLINE_LIBS)
8 AC_SUBST(YAZ_CONF_CFLAGS)
9 dnl ------ Checking programs
12 AC_CHECK_PROGS(YACC, 'bison -y')
13 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
20 AC_ARG_WITH(dtd, [ --with-dtd[=DIR] Use docbookx.dtd in DIR],
22 if test -f "$withval/docbookx.dtd"; then
26 AC_MSG_CHECKING(for docbookx.dtd)
27 for d in /usr/share/sgml/docbook/dtd/xml/4.1.2 \
28 /usr/share/sgml/docbook/xml-dtd-4.1.2* \
29 /usr/share/sgml/docbook/xml-dtd-4.1 \
30 /usr/share/sgml/docbook/dtd/xml/4.0 \
31 /usr/lib/sgml/dtd/docbook-xml
33 if test -f $d/docbookx.dtd; then
39 if test -z "$DTD_DIR"; then
40 AC_MSG_RESULT(Not found)
44 AC_ARG_WITH(dsssl,[ --with-dsssl[=DIR] Use DSSSL in DIR/{html,print}/docbook.dsl],
46 if test -f "$withval/html/docbook.dsl"; then
50 AC_MSG_CHECKING(for docbook.dsl)
51 for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
52 /usr/share/sgml/docbook/dsssl-stylesheets-1.* \
53 /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh
55 if test -f $d/html/docbook.dsl; then
61 if test -z "$DSSSL_DIR"; then
62 AC_MSG_RESULT(Not found)
66 AC_ARG_WITH(xsl,[ --with-xsl[=DIR] Use XSL in DIR/{htmlhelp,xhtml}],
68 if test -f "$withval/htmlhelp/htmlhelp.xsl"; then
72 AC_MSG_CHECKING(for htmlhelp.xsl)
73 for d in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh \
74 /usr/share/sgml/docbook/xsl-stylesheets-1.*
76 if test -f $d/htmlhelp/htmlhelp.xsl; then
82 if test -z "$XSL_DIR"; then
83 AC_MSG_RESULT(Not found)
89 AC_CHECK_FUNC(connect)
90 if test "$ac_cv_func_connect" = "no"; then
91 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
93 if test "$checkBoth" = "1"; then
95 LIBS="$LIBS -lsocket -lnsl"
96 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
98 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
102 AC_ARG_WITH(openssl, [ --with-openssl[=DIR] OpenSSL library in DIR], [openssl=$withval])
110 if test "$openssl" != "no"; then
113 if test "$openssl" != "yes"; then
114 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
115 SSL_LIBS="-L$openssl/lib"
116 CFLAGS="$SSL_CFLAGS $CFLAGS"
117 LIBS="$SSL_LIBS $LIBS"
119 AC_CHECK_LIB(crypto, main,[SSL_LIBS="$SSL_LIBS -lcrypto"])
120 LIBS="$LIBS $SSL_LIBS"
121 AC_CHECK_LIB(ssl, SSL_new)
122 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
123 SSL_LIBS="$SSL_LIBS -lssl"
124 AC_CHECK_HEADER(openssl/ssl.h,[SSL_DEFS="-DHAVE_OPENSSL_SSL_H=1"; USE_SSL=1])
131 AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
133 dnl ------ GNU Readline
134 READLINE_SHARED_LIBADD=""
135 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
136 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
139 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
140 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
141 if test "$ac_cv_lib_readline_readline" = "yes"; then
142 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
144 LIBS="$LIBS $READLINE_LIBS"
147 #include <readline/readline.h>
151 rl_attempted_completion_over = 0;
153 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
156 #include <readline/readline.h>
160 rl_completion_matches (0, 0);
162 ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
166 AC_ARG_WITH(iconv, [ --with-iconv[=DIR] iconv library in DIR])
167 if test "$with_iconv" != "no"; then
168 AC_MSG_CHECKING(for iconv)
170 oldCPPFLAGS="${CPPFLAGS}"
171 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
172 LIBS="$LIBS -L${with_iconv}/lib"
173 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
178 static void f() {iconv_t t = iconv_open("", ""); }
180 AC_DEFINE(HAVE_ICONV_H)
187 static void f() {iconv_t t = iconv_open("", ""); }
189 AC_DEFINE(HAVE_ICONV_H)
193 CPPFLAGS="$oldCPPFLAGS"
198 dnl ------ various functions
199 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
200 if test "$ac_cv_func_poll" = "yes"; then
201 AC_CHECK_HEADERS(sys/poll.h)
204 AC_MSG_CHECKING([for socklen_t])
205 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
207 #include <sys/types.h>
208 #include <sys/socket.h>
212 extern int accept(int, struct sockaddr *, socklen_t *);
216 ],,[ac_cv_check_socklen_t=socklen_t],[
218 #include <sys/types.h>
219 #include <sys/socket.h>
223 extern int accept(int, struct sockaddr *, size_t t *);
227 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
230 AC_MSG_RESULT($ac_cv_check_socklen_t)
231 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
234 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
235 if test "$enable_tcpd" != ""; then
237 oldCPPFLAGS=$CPPFLAGS
238 if test "$enable_tcpd" != "yes"; then
239 LIBS="$LIBS -L$enable_tcpd/lib"
240 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
242 AC_MSG_CHECKING(for working tcpd.h)
243 LIBS="$LIBS -lwrap -lnsl"
244 AC_TRY_LINK([#include <syslog.h>
246 int allow_severity = LOG_INFO;
247 int deny_severity = LOG_WARNING;],
248 [struct request_info request_info; int i;
249 i = hosts_access(&request_info);],
250 tcpd_ok=1, tcpd_ok=0)
251 if test "$tcpd_ok" = "0"; then
254 CPPFLAGS=$oldCPPFLAGS
257 AC_DEFINE(HAVE_TCPD_H)
262 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
264 if test "$ac_cv_header_stdc" = "no"; then
265 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
269 AC_SUBST(CFLAGSTHREADS)
274 dnl ------ GNU threads
275 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
277 if test "$enable_pth" = "yes"; then
279 AC_CHECK_LIB(pth,main)
280 if test "$ac_cv_lib_pth_main" = "yes"; then
281 AC_CHECK_HEADERS(pth.h)
282 if test "$ac_cv_header_pth_h" = "yes"; then
284 CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
291 dnl ------ POSIX Threads
292 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
293 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
296 AC_CHECK_LIB(pthread,main)
297 AC_MSG_CHECKING(for working POSIX Threads)
298 AC_TRY_LINK([#include <pthread.h>
299 void *func(void *p) { return 0; }
301 pthread_t pthread_id;
302 pthread_create (&pthread_id, 0, func, 0);],
303 thread_ok=yes,thread_ok=no)
304 if test "$thread_ok" = "yes"; then
306 LIBTHREAD="-lpthread"
307 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
311 AC_TRY_LINK([#include <pthread.h>
312 void *func(void *p) { return 0; }
314 pthread_t pthread_id;
315 pthread_create (&pthread_id, 0, func, 0);],
316 thread_ok=yes,thread_ok=no)
317 if test "$thread_ok" = "yes"; then
318 AC_MSG_RESULT([yes,BSD])
319 CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
324 if test "$thread_ok" = "no"; then
330 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
334 AC_SUBST(XSLT_CFLAGS)
336 AC_ARG_WITH(xslt, [ --with-xslt[=PREFIX] Use libxslt in PREFIX/{lib,include}],[xsltdir=$withval])
337 if test "$xsltdir" = "yes"; then
338 for d in /usr /usr/local; do
339 if test -x $d/bin/xslt-config; then
344 if test "$xsltdir" != "no"; then
345 AC_MSG_CHECKING(for XSLT)
346 if test -x $xsltdir/bin/xslt-config; then
347 XSLT_LIB=`$xsltdir/bin/xslt-config --libs`
348 XSLT_CFLAGS=`$xsltdir/bin/xslt-config --cflags`
349 XSLT_VER=`$xsltdir/bin/xslt-config --version`
350 AC_MSG_RESULT($XSLT_VER)
353 AC_MSG_RESULT(Not found)
359 AC_SUBST(XML2_CFLAGS)
361 AC_ARG_WITH(xml2, [ --with-xml2[=PREFIX] Use libxml2 in PREFIX/{lib,include}],[xml2dir=$withval])
362 if test "$xml2dir" = "yes"; then
363 for d in /usr /usr/local; do
364 if test -x $d/bin/xml2-config; then
369 if test "$xml2dir" != "no"; then
370 AC_MSG_CHECKING(for libXML2)
371 if test -x $xml2dir/bin/xml2-config; then
372 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
373 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
374 XML2_VER=`$xml2dir/bin/xml2-config --version`
375 AC_MSG_RESULT($XML2_VER)
378 AC_MSG_RESULT(Not found)
382 dnl ------ Memory debugging
383 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
384 if test "$enable_memdebug" = "yes"; then
385 AC_DEFINE(TRACE_XMALLOC,2)
386 elif test "$enable_memdebug" = "no"; then
387 AC_DEFINE(TRACE_XMALLOC,0)
390 dnl ------ Using this for "in-source" yaz-config
391 AC_SUBST(YAZ_SRC_ROOT)
392 AC_SUBST(YAZ_BUILD_ROOT)
393 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
425 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > lib/yaz-config && chmod +x yaz-config lib/yaz-config])