1 dnl YAZ Toolkit, Index Data 1994-2002
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.98 2002-11-29 15:41:00 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 1.9.2)
7 AC_SUBST(READLINE_LIBS)
8 AC_SUBST(YAZ_CONF_CFLAGS)
9 dnl ------ Checking programs
18 AC_ARG_WITH(dtd, [ --with-dtd[=DIR] Use docbookx.dtd in DIR],
20 if test -f "$withval/docbookx.dtd"; then
24 AC_MSG_CHECKING(for docbookx.dtd)
25 for d in /usr/share/sgml/docbook/dtd/xml/4.1.2 \
26 /usr/share/sgml/docbook/xml-dtd-4.1.2* \
27 /usr/share/sgml/docbook/xml-dtd-4.1 \
28 /usr/share/sgml/docbook/dtd/xml/4.0 \
29 /usr/lib/sgml/dtd/docbook-xml
31 if test -f $d/docbookx.dtd; then
37 if test -z "$DTD_DIR"; then
38 AC_MSG_RESULT(Not found)
42 AC_ARG_WITH(dsssl,[ --with-dsssl[=DIR] Use DSSSL in DIR/{html,print}/docbook.dsl],
44 if test -f "$withval/html/docbook.dsl"; then
48 AC_MSG_CHECKING(for docbook.dsl)
49 for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
50 /usr/share/sgml/docbook/dsssl-stylesheets-1.* \
51 /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh
53 if test -f $d/html/docbook.dsl; then
59 if test -z "$DSSSL_DIR"; then
60 AC_MSG_RESULT(Not found)
66 AC_CHECK_FUNC(connect)
67 if test "$ac_cv_func_connect" = "no"; then
68 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
70 if test "$checkBoth" = "1"; then
72 LIBS="$LIBS -lsocket -lnsl"
73 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
75 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
79 AC_ARG_WITH(openssl, [ --with-openssl[=DIR] OpenSSL library in DIR], [openssl=$withval])
87 if test "$openssl" != "no"; then
90 if test "$openssl" != "yes"; then
91 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
92 SSL_LIBS="-L$openssl/lib"
93 CFLAGS="$SSL_CFLAGS $CFLAGS"
94 LIBS="$SSL_LIBS $LIBS"
96 AC_CHECK_LIB(crypto, main,[SSL_LIBS="$SSL_LIBS -lcrypto"])
97 LIBS="$LIBS $SSL_LIBS"
98 AC_CHECK_LIB(ssl, SSL_new)
99 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
100 SSL_LIBS="$SSL_LIBS -lssl"
101 AC_CHECK_HEADER(openssl/ssl.h,[SSL_DEFS="-DHAVE_OPENSSL_SSL_H=1"; USE_SSL=1])
108 AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
110 dnl ------ GNU Readline
111 READLINE_SHARED_LIBADD=""
112 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
113 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
116 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
117 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
118 if test "$ac_cv_lib_readline_readline" = "yes"; then
119 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
121 LIBS="$LIBS $READLINE_LIBS"
124 #include <readline/readline.h>
128 rl_attempted_completion_over = 0;
130 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
133 #include <readline/readline.h>
137 rl_completion_matches (0, 0);
139 ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
143 AC_ARG_WITH(iconv, [ --with-iconv[=DIR] iconv library in DIR])
144 if test "$with_iconv" != "no"; then
145 AC_MSG_CHECKING(for iconv)
147 oldCPPFLAGS="${CPPFLAGS}"
148 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
149 LIBS="$LIBS -L${with_iconv}/lib"
150 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
155 static void f() {iconv_t t = iconv_open("", ""); }
157 AC_DEFINE(HAVE_ICONV_H)
164 static void f() {iconv_t t = iconv_open("", ""); }
166 AC_DEFINE(HAVE_ICONV_H)
170 CPPFLAGS="$oldCPPFLAGS"
175 dnl ------ various functions
176 AC_CHECK_FUNCS(vsnprintf gettimeofday poll)
177 if test "$ac_cv_func_poll" = "yes"; then
178 AC_CHECK_HEADERS(sys/poll.h)
181 AC_MSG_CHECKING([for socklen_t])
182 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
184 #include <sys/types.h>
185 #include <sys/socket.h>
189 extern int accept(int, struct sockaddr *, socklen_t *);
193 ],,[ac_cv_check_socklen_t=socklen_t],[
195 #include <sys/types.h>
196 #include <sys/socket.h>
200 extern int accept(int, struct sockaddr *, size_t t *);
204 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
207 AC_MSG_RESULT($ac_cv_check_socklen_t)
208 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
211 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
212 if test "$enable_tcpd" != ""; then
214 oldCPPFLAGS=$CPPFLAGS
215 if test "$enable_tcpd" != "yes"; then
216 LIBS="$LIBS -L$enable_tcpd/lib"
217 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
219 AC_MSG_CHECKING(for working tcpd.h)
220 LIBS="$LIBS -lwrap -lnsl"
221 AC_TRY_LINK([#include <syslog.h>
223 int allow_severity = LOG_INFO;
224 int deny_severity = LOG_WARNING;],
225 [struct request_info request_info; int i;
226 i = hosts_access(&request_info);],
227 tcpd_ok=1, tcpd_ok=0)
228 if test "$tcpd_ok" = "0"; then
231 CPPFLAGS=$oldCPPFLAGS
234 AC_DEFINE(HAVE_TCPD_H)
239 AC_CHECK_HEADERS(fnmatch.h)
241 if test "$ac_cv_header_stdc" = "no"; then
242 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
246 AC_SUBST(CFLAGSTHREADS)
251 dnl ------ GNU threads
252 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
254 if test "$enable_pth" = "yes"; then
256 AC_CHECK_LIB(pth,main)
257 if test "$ac_cv_lib_pth_main" = "yes"; then
258 AC_CHECK_HEADERS(pth.h)
259 if test "$ac_cv_header_pth_h" = "yes"; then
261 CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
268 dnl ------ POSIX Threads
269 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
270 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
273 AC_CHECK_LIB(pthread,main)
274 AC_MSG_CHECKING(for working POSIX Threads)
275 AC_TRY_LINK([#include <pthread.h>
276 void *func(void *p) { return 0; }
278 pthread_t pthread_id;
279 pthread_create (&pthread_id, 0, func, 0);],
280 thread_ok=yes,thread_ok=no)
281 if test "$thread_ok" = "yes"; then
283 LIBTHREAD="-lpthread"
284 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
288 AC_TRY_LINK([#include <pthread.h>
289 void *func(void *p) { return 0; }
291 pthread_t pthread_id;
292 pthread_create (&pthread_id, 0, func, 0);],
293 thread_ok=yes,thread_ok=no)
294 if test "$thread_ok" = "yes"; then
295 AC_MSG_RESULT([yes,BSD])
296 CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
301 if test "$thread_ok" = "no"; then
307 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
309 dnl ------ Memory debugging
310 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
311 if test "$enable_memdebug" = "yes"; then
312 AC_DEFINE(TRACE_XMALLOC,2)
313 elif test "$enable_memdebug" = "no"; then
314 AC_DEFINE(TRACE_XMALLOC,0)
317 dnl ------ Using this for "in-source" yaz-config
318 AC_SUBST(YAZ_SRC_ROOT)
319 AC_SUBST(YAZ_BUILD_ROOT)
320 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
349 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > lib/yaz-config && chmod +x yaz-config lib/yaz-config])