1 dnl YAZ Toolkit, Index Data 1994-2004
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.137 2004-04-28 22:44:58 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 2.0.19)
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])
18 AC_PATH_PROG(pkgconfig, pkg-config, NONE)
22 AC_ARG_WITH(dtd, [ --with-dtd[=DIR] use docbookx.dtd in DIR],
24 if test -f "$withval/docbookx.dtd"; then
28 AC_MSG_CHECKING(for docbookx.dtd)
29 for d in /usr/share/sgml/docbook/dtd/xml/4.1.2 \
30 /usr/share/sgml/docbook/xml-dtd-4.1.2* \
31 /usr/share/sgml/docbook/xml-dtd-4.1 \
32 /usr/share/sgml/docbook/dtd/xml/4.0 \
33 /usr/lib/sgml/dtd/docbook-xml
35 if test -f $d/docbookx.dtd; then
41 if test -z "$DTD_DIR"; then
42 AC_MSG_RESULT(Not found)
46 AC_ARG_WITH(dsssl,[ --with-dsssl[=DIR] use Docbook DSSSL in DIR/{html,print}/docbook.dsl],
48 if test -f "$withval/html/docbook.dsl"; then
52 AC_MSG_CHECKING(for docbook.dsl)
53 for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
54 /usr/share/sgml/docbook/dsssl-stylesheets-1.* \
55 /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh
57 if test -f $d/html/docbook.dsl; then
63 if test -z "$DSSSL_DIR"; then
64 AC_MSG_RESULT(Not found)
68 AC_ARG_WITH(xsl,[ --with-xsl[=DIR] use Docbook XSL in DIR/{htmlhelp,xhtml}],
70 if test -f "$withval/htmlhelp/htmlhelp.xsl"; then
74 AC_MSG_CHECKING(for htmlhelp.xsl)
75 for d in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh \
76 /usr/share/sgml/docbook/xsl-stylesheets-1.*
78 if test -f $d/htmlhelp/htmlhelp.xsl; then
84 if test -z "$XSL_DIR"; then
85 AC_MSG_RESULT(Not found)
91 AC_CHECK_FUNC(connect)
92 if test "$ac_cv_func_connect" = "no"; then
93 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
95 if test "$checkBoth" = "1"; then
97 LIBS="$LIBS -lsocket -lnsl"
98 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
100 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
104 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
112 if test "$openssl" != "no"; then
116 if test "$openssl" != "yes"; then
117 if $openssl/bin/pkg-config --exists openssl; then
118 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
119 SSL_LIBS=`$openssl/bin/pkg-config --libs openssl`
120 sslver=`$openssl/bin/pkg-config --modversion openssl`
122 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
123 SSL_LIBS="-L$openssl/lib"
124 CFLAGS="$SSL_CFLAGS $CFLAGS"
125 LIBS="$SSL_LIBS $LIBS"
128 if $pkgconfig --exists openssl; then
129 SSL_CFLAGS=`$pkgconfig --cflags openssl`
130 SSL_LIBS=`$pkgconfig --libs openssl`
131 sslver=`$pkgconfig --modversion openssl`
134 if test "$sslver" = "no"; then
135 AC_CHECK_LIB(crypto, main,[SSL_LIBS="$SSL_LIBS -lcrypto"])
136 LIBS="$LIBS $SSL_LIBS"
137 AC_CHECK_LIB(ssl, SSL_new)
138 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
139 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
141 if test "$sslver" = "yes"; then
142 SSL_LIBS="-lssl $SSL_LIBS"
145 if test "$sslver" != "no"; then
146 SSL_DEFS="-DHAVE_OPENSSL_SSL_H=1"
149 AC_MSG_CHECKING([for SSL])
150 AC_MSG_RESULT($sslver)
155 dnl ------ GNU Readline
156 READLINE_SHARED_LIBADD=""
157 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
158 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
161 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
162 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
163 if test "$ac_cv_lib_readline_readline" = "yes"; then
164 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
166 LIBS="$LIBS $READLINE_LIBS"
169 #include <readline/readline.h>
173 rl_attempted_completion_over = 0;
175 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
178 #include <readline/readline.h>
182 rl_completion_matches (0, 0);
184 ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
188 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
189 if test "$with_iconv" != "no"; then
190 AC_MSG_CHECKING(for iconv)
192 oldCPPFLAGS="${CPPFLAGS}"
193 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
194 LIBS="$LIBS -L${with_iconv}/lib"
195 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
200 static void f() {iconv_t t = iconv_open("", ""); }
202 AC_DEFINE(HAVE_ICONV_H)
209 static void f() {iconv_t t = iconv_open("", ""); }
211 AC_DEFINE(HAVE_ICONV_H)
215 CPPFLAGS="$oldCPPFLAGS"
220 dnl ------ various functions
221 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
222 if test "$ac_cv_func_poll" = "yes"; then
223 AC_CHECK_HEADERS(sys/poll.h)
226 dnl We check for socklen_t by making prototypes with the
227 dnl various types. First socklen_t, then size_t, finally int.
228 dnl If the prototype succeeds, we're probably safe.
229 dnl That works if accept is not preprocessor defined (such sa AIX)
230 AC_MSG_CHECKING([for socklen_t])
231 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
233 #include <sys/types.h>
234 #include <sys/socket.h>
245 extern int accept(int, struct sockaddr *, socklen_t *);
250 ],,[ac_cv_check_socklen_t=socklen_t],[
252 #include <sys/types.h>
253 #include <sys/socket.h>
264 extern int accept(int, struct sockaddr *, size_t t *);
269 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
272 AC_MSG_RESULT($ac_cv_check_socklen_t)
273 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
276 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
277 if test "$enable_tcpd" != "" && test "$enable_tcpd" != "no"; then
279 oldCPPFLAGS=$CPPFLAGS
280 if test "$enable_tcpd" != "yes"; then
281 LIBS="$LIBS -L$enable_tcpd/lib"
282 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
284 AC_MSG_CHECKING(for working tcpd.h)
285 LIBS="$LIBS -lwrap -lnsl"
286 AC_TRY_LINK([#include <syslog.h>
288 int allow_severity = LOG_INFO;
289 int deny_severity = LOG_WARNING;],
290 [struct request_info request_info; int i;
291 i = hosts_access(&request_info);],
292 tcpd_ok=1, tcpd_ok=0)
293 if test "$tcpd_ok" = "0"; then
296 CPPFLAGS=$oldCPPFLAGS
299 AC_DEFINE(HAVE_TCPD_H)
304 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
306 if test "$ac_cv_header_stdc" = "no"; then
307 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
311 AC_SUBST(CFLAGSTHREADS)
316 dnl ------ GNU threads
317 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
319 if test "$enable_pth" = "yes"; then
321 AC_CHECK_LIB(pth,main)
322 if test "$ac_cv_lib_pth_main" = "yes"; then
323 AC_CHECK_HEADERS(pth.h)
324 if test "$ac_cv_header_pth_h" = "yes"; then
326 CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
333 dnl ------ POSIX Threads
334 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
335 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
338 AC_CHECK_LIB(pthread,main)
339 AC_MSG_CHECKING(for working POSIX Threads)
340 AC_TRY_LINK([#include <pthread.h>
341 void *func(void *p) { return 0; }
343 pthread_t pthread_id;
344 pthread_create (&pthread_id, 0, func, 0);],
345 thread_ok=yes,thread_ok=no)
346 if test "$thread_ok" = "yes"; then
348 LIBTHREAD="-lpthread"
349 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
353 AC_TRY_LINK([#include <pthread.h>
354 void *func(void *p) { return 0; }
356 pthread_t pthread_id;
357 pthread_create (&pthread_id, 0, func, 0);],
358 thread_ok=yes,thread_ok=no)
359 if test "$thread_ok" = "yes"; then
360 AC_MSG_RESULT([yes,BSD])
361 CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
366 if test "$thread_ok" = "no"; then
372 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
376 AC_SUBST(XML2_CFLAGS)
378 AC_ARG_WITH(xml2, [ --with-xml2[=PREFIX] use libxml2 in PREFIX],[xml2dir=$withval])
379 if test "$xml2dir" = "yes"; then
380 for d in /usr /usr/local; do
381 if test -x $d/bin/xml2-config; then
386 if test "$xml2dir" != "no"; then
387 AC_MSG_CHECKING(for libXML2)
388 if test -x $xml2dir/bin/xml2-config; then
389 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
390 LIBS="$XML2_LIBS $LIBS"
391 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
392 XML2_VER=`$xml2dir/bin/xml2-config --version`
393 AC_MSG_RESULT($XML2_VER)
396 AC_MSG_RESULT(Not found)
400 dnl ------ Memory debugging
401 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
402 if test "$enable_memdebug" = "yes"; then
403 AC_DEFINE(TRACE_XMALLOC,2)
404 elif test "$enable_memdebug" = "no"; then
405 AC_DEFINE(TRACE_XMALLOC,0)
408 dnl ------ Using this for "in-source" yaz-config
409 AC_SUBST(YAZ_SRC_ROOT)
410 AC_SUBST(YAZ_BUILD_ROOT)
411 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
436 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])