1 dnl YAZ Toolkit, Index Data 1994-2004
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.123 2004-01-06 13:38:56 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 2.0.9)
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/pkgconfig --cflags openssl`
119 SSL_LIBS=`$openssl/bin/pkgconfig --libs openssl`
120 sslver=`$openssl/bin/pkgconfig --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="$SSL_LIBS -lssl"
145 if test "$sslver" != "no"; then
146 SSL_DEFS="-DHAVE_OPENSSL_H=1"
149 AC_MSG_CHECKING([for SSL])
150 AC_MSG_RESULT($sslver)
154 AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
156 dnl ------ GNU Readline
157 READLINE_SHARED_LIBADD=""
158 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
159 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
162 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
163 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
164 if test "$ac_cv_lib_readline_readline" = "yes"; then
165 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
167 LIBS="$LIBS $READLINE_LIBS"
170 #include <readline/readline.h>
174 rl_attempted_completion_over = 0;
176 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
179 #include <readline/readline.h>
183 rl_completion_matches (0, 0);
185 ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
189 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
190 if test "$with_iconv" != "no"; then
191 AC_MSG_CHECKING(for iconv)
193 oldCPPFLAGS="${CPPFLAGS}"
194 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
195 LIBS="$LIBS -L${with_iconv}/lib"
196 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
201 static void f() {iconv_t t = iconv_open("", ""); }
203 AC_DEFINE(HAVE_ICONV_H)
210 static void f() {iconv_t t = iconv_open("", ""); }
212 AC_DEFINE(HAVE_ICONV_H)
216 CPPFLAGS="$oldCPPFLAGS"
221 dnl ------ various functions
222 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
223 if test "$ac_cv_func_poll" = "yes"; then
224 AC_CHECK_HEADERS(sys/poll.h)
227 dnl We check for socklen_t by making prototypes with the
228 dnl various types. First socklen_t, then size_t, finally int.
229 dnl If the prototype succeeds, we're probably safe.
230 dnl That works if accept is not preprocessor defined (such sa AIX)
231 AC_MSG_CHECKING([for socklen_t])
232 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
234 #include <sys/types.h>
235 #include <sys/socket.h>
246 extern int accept(int, struct sockaddr *, socklen_t *);
251 ],,[ac_cv_check_socklen_t=socklen_t],[
253 #include <sys/types.h>
254 #include <sys/socket.h>
265 extern int accept(int, struct sockaddr *, size_t t *);
270 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
273 AC_MSG_RESULT($ac_cv_check_socklen_t)
274 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
277 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
278 if test "$enable_tcpd" != ""; then
280 oldCPPFLAGS=$CPPFLAGS
281 if test "$enable_tcpd" != "yes"; then
282 LIBS="$LIBS -L$enable_tcpd/lib"
283 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
285 AC_MSG_CHECKING(for working tcpd.h)
286 LIBS="$LIBS -lwrap -lnsl"
287 AC_TRY_LINK([#include <syslog.h>
289 int allow_severity = LOG_INFO;
290 int deny_severity = LOG_WARNING;],
291 [struct request_info request_info; int i;
292 i = hosts_access(&request_info);],
293 tcpd_ok=1, tcpd_ok=0)
294 if test "$tcpd_ok" = "0"; then
297 CPPFLAGS=$oldCPPFLAGS
300 AC_DEFINE(HAVE_TCPD_H)
305 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
307 if test "$ac_cv_header_stdc" = "no"; then
308 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
312 AC_SUBST(CFLAGSTHREADS)
317 dnl ------ GNU threads
318 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
320 if test "$enable_pth" = "yes"; then
322 AC_CHECK_LIB(pth,main)
323 if test "$ac_cv_lib_pth_main" = "yes"; then
324 AC_CHECK_HEADERS(pth.h)
325 if test "$ac_cv_header_pth_h" = "yes"; then
327 CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
334 dnl ------ POSIX Threads
335 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
336 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
339 AC_CHECK_LIB(pthread,main)
340 AC_MSG_CHECKING(for working POSIX Threads)
341 AC_TRY_LINK([#include <pthread.h>
342 void *func(void *p) { return 0; }
344 pthread_t pthread_id;
345 pthread_create (&pthread_id, 0, func, 0);],
346 thread_ok=yes,thread_ok=no)
347 if test "$thread_ok" = "yes"; then
349 LIBTHREAD="-lpthread"
350 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
354 AC_TRY_LINK([#include <pthread.h>
355 void *func(void *p) { return 0; }
357 pthread_t pthread_id;
358 pthread_create (&pthread_id, 0, func, 0);],
359 thread_ok=yes,thread_ok=no)
360 if test "$thread_ok" = "yes"; then
361 AC_MSG_RESULT([yes,BSD])
362 CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
367 if test "$thread_ok" = "no"; then
373 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
377 AC_SUBST(XML2_CFLAGS)
379 AC_ARG_WITH(xml2, [ --with-xml2[=PREFIX] use libxml2 in PREFIX],[xml2dir=$withval])
380 if test "$xml2dir" = "yes"; then
381 for d in /usr /usr/local; do
382 if test -x $d/bin/xml2-config; then
387 if test "$xml2dir" != "no"; then
388 AC_MSG_CHECKING(for libXML2)
389 if test -x $xml2dir/bin/xml2-config; then
390 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
391 LIBS="$XML2_LIBS $LIBS"
392 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
393 XML2_VER=`$xml2dir/bin/xml2-config --version`
394 AC_MSG_RESULT($XML2_VER)
397 AC_MSG_RESULT(Not found)
401 dnl ------ Memory debugging
402 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
403 if test "$enable_memdebug" = "yes"; then
404 AC_DEFINE(TRACE_XMALLOC,2)
405 elif test "$enable_memdebug" = "no"; then
406 AC_DEFINE(TRACE_XMALLOC,0)
409 dnl ------ Using this for "in-source" yaz-config
410 AC_SUBST(YAZ_SRC_ROOT)
411 AC_SUBST(YAZ_BUILD_ROOT)
412 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
437 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])