Use libxml2 instead of libxslt(and libxml2)
[yaz-moved-to-github.git] / configure.in
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)
6 dnl
7 AC_SUBST(READLINE_LIBS)
8 AC_SUBST(YAZ_CONF_CFLAGS)
9 dnl ------ Checking programs
10 AC_PROG_CC
11 AC_PROG_CPP
12 AC_CHECK_PROGS(YACC, 'bison -y')
13 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
14 AC_PROG_INSTALL
15 AM_DISABLE_SHARED
16 AM_PROG_LIBTOOL
17 dnl
18 dnl ----- DOCBOOK DTD
19 AC_SUBST(DTD_DIR)
20 AC_ARG_WITH(dtd, [  --with-dtd[=DIR]        Use docbookx.dtd in DIR],
21 [
22    if test -f "$withval/docbookx.dtd"; then
23       DTD_DIR=$withval
24    fi
25 ],[
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 
32    do
33      if test -f $d/docbookx.dtd; then
34        AC_MSG_RESULT($d)
35        DTD_DIR=$d
36        break
37      fi
38    done
39    if test -z "$DTD_DIR"; then
40       AC_MSG_RESULT(Not found)
41    fi
42 ])
43 AC_SUBST(DSSSL_DIR)
44 AC_ARG_WITH(dsssl,[  --with-dsssl[=DIR]      Use DSSSL in DIR/{html,print}/docbook.dsl],
45 [
46    if test -f "$withval/html/docbook.dsl"; then
47       DSSSL_DIR=$withval
48    fi
49 ],[
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 
54    do
55      if test -f $d/html/docbook.dsl; then
56        AC_MSG_RESULT($d)
57        DSSSL_DIR=$d
58        break
59      fi
60    done
61    if test -z "$DSSSL_DIR"; then
62       AC_MSG_RESULT(Not found)
63    fi
64 ])
65 AC_SUBST(XSL_DIR)
66 AC_ARG_WITH(xsl,[  --with-xsl[=DIR]        Use XSL in DIR/{htmlhelp,xhtml}],
67 [
68    if test -f "$withval/htmlhelp/htmlhelp.xsl"; then
69       XSL_DIR=$withval
70    fi
71 ],[
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.* 
75    do
76      if test -f $d/htmlhelp/htmlhelp.xsl; then
77        AC_MSG_RESULT($d)
78        XSL_DIR=$d
79        break
80      fi
81    done
82    if test -z "$XSL_DIR"; then
83       AC_MSG_RESULT(Not found)
84    fi
85 ])
86 dnl 
87 dnl ----- Sockets
88 checkBoth=0
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)
92 fi
93 if test "$checkBoth" = "1"; then
94         oldLibs=$LIBS
95         LIBS="$LIBS -lsocket -lnsl"
96         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
97 fi
98 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
99 dnl
100 dnl ------ Open SSL
101 openssl=no
102 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    OpenSSL library in DIR], [openssl=$withval])
103 AC_SUBST(SSL_CFLAGS)
104 AC_SUBST(SSL_LIBS)
105 AC_SUBST(SSL_DEFS)
106 USE_SSL=0
107 SSL_CFLAGS=""
108 SSL_LIBS=""
109 SSL_DEFS=""
110 if test "$openssl" != "no"; then
111         xLIBS="$LIBS";
112         xCFLAGS="$CFLAGS";
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"
118         fi
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])
125         else
126                 SSL_LIBS=""
127         fi
128         LIBS="$xLIBS"
129         CFLAGS="$xCFLAGS"
130 fi
131 AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
132 dnl
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"])
137 )
138 READLINE_LIBS=""
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)
143         xLIBS=$LIBS
144         LIBS="$LIBS $READLINE_LIBS"
145         AC_TRY_LINK([
146         #include <stdio.h>
147         #include <readline/readline.h>
148         ],[
149         static void f()
150         {
151                 rl_attempted_completion_over = 0;
152         }
153         ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
154         AC_TRY_LINK([
155         #include <stdio.h>
156         #include <readline/readline.h>
157         ],[
158         static void f()
159         {
160                 rl_completion_matches (0, 0);
161         }
162         ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
163         LIBS=$xLIBS
164 fi
165 dnl ------ iconv
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)
169         oldLIBS="$LIBS"
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"
174         fi
175         AC_TRY_LINK([
176                 #include <iconv.h>
177         ],[
178                 static void f() {iconv_t t = iconv_open("", ""); }
179         ],[
180                 AC_DEFINE(HAVE_ICONV_H)
181                 AC_MSG_RESULT(yes)
182         ],[
183                 LIBS="$LIBS -liconv"
184                 AC_TRY_LINK([
185                         #include <iconv.h>
186                 ],[
187                         static void f() {iconv_t t = iconv_open("", ""); }
188                 ],[
189                         AC_DEFINE(HAVE_ICONV_H)
190                         AC_MSG_RESULT(yes)
191                 ],[
192                         LIBS="$oldLIBS"
193                         CPPFLAGS="$oldCPPFLAGS"
194                         AC_MSG_RESULT(no)
195                 ])
196         ])
197 fi
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)
202 fi
203 dnl ------ socklen_t
204 AC_MSG_CHECKING([for socklen_t])
205 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
206         AC_TRY_COMPILE([
207         #include <sys/types.h>
208         #include <sys/socket.h>
209         #ifdef __cplusplus
210         extern "C" {
211         #endif
212         extern int accept(int, struct sockaddr *, socklen_t *);
213         #ifdef __cplusplus
214         }
215         #endif
216         ],,[ac_cv_check_socklen_t=socklen_t],[
217                 AC_TRY_COMPILE([
218                 #include <sys/types.h>
219                 #include <sys/socket.h>
220                 #ifdef __cplusplus
221                 extern "C" {
222                 #endif
223                 extern int accept(int, struct sockaddr *, size_t t *);
224                 #ifdef __cplusplus
225                 }
226                 #endif
227                 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
228         ])
229 ])
230 AC_MSG_RESULT($ac_cv_check_socklen_t)
231 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
232 dnl
233 dnl ------ tcpd
234 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
235 if test "$enable_tcpd" != ""; then
236         oldLibs=$LIBS
237         oldCPPFLAGS=$CPPFLAGS
238         if test "$enable_tcpd" != "yes"; then
239                 LIBS="$LIBS -L$enable_tcpd/lib"
240                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
241         fi
242         AC_MSG_CHECKING(for working tcpd.h)
243         LIBS="$LIBS -lwrap -lnsl"
244         AC_TRY_LINK([#include <syslog.h>
245 #include <tcpd.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
252                 AC_MSG_RESULT(no)
253                 LIBS=$oldLibs
254                 CPPFLAGS=$oldCPPFLAGS
255         else
256                 AC_MSG_RESULT(yes)
257                 AC_DEFINE(HAVE_TCPD_H)
258         fi
259 fi
260 dnl
261 dnl ------ Headers
262 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
263 AC_STDC_HEADERS
264 if test "$ac_cv_header_stdc" = "no"; then
265         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
266 fi
267 dnl
268 AC_SUBST(LIBTHREAD)
269 AC_SUBST(CFLAGSTHREADS)
270 HAVETHREADS=0
271 CFLAGSTHREADS=""
272 LIBTHREAD=""
273 dnl
274 dnl ------ GNU threads
275 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
276 AC_SUBST(LIBPTH)
277 if test "$enable_pth" = "yes"; then
278         OLIBS=$LIBS
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
283                         LIBTHREAD="-lpth"
284                         CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
285                         HAVETHREADS=1
286                 fi
287         fi      
288         LIBS=$OLIBS
289 fi
290 dnl
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
294         OLIBS=$LIBS
295         OCC=$CC
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; }
300         ],[
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
305                 AC_MSG_RESULT(yes)
306                 LIBTHREAD="-lpthread"
307                 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
308                 HAVETHREADS=1
309         else
310                 CC="$CC -pthread"
311                 AC_TRY_LINK([#include <pthread.h>
312                         void *func(void *p) { return 0; }
313                         ],[
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"
320                         LIBTHREAD="-pthread"
321                         HAVETHREADS=1
322                 fi
323         fi
324         if test "$thread_ok" = "no"; then
325                 AC_MSG_RESULT(no)
326         fi
327         CC=$OCC
328         LIBS=$OLIBS
329 fi
330 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
331 dnl
332 dnl ----- libXSLT
333 AC_SUBST(XSLT_LIB)
334 AC_SUBST(XSLT_CFLAGS)
335 xsltdir=no
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
340                         xsltdir=$d
341                 fi
342         done
343 fi
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)
351                 AC_DEFINE(HAVE_XSLT)
352         else
353                 AC_MSG_RESULT(Not found)
354         fi
355 fi
356 dnl
357 dnl ----- libXML2
358 AC_SUBST(XML2_LIBS)
359 AC_SUBST(XML2_CFLAGS)
360 xml2dir=no
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
365                         xml2dir=$d
366                 fi
367         done
368 fi
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)
376                 AC_DEFINE(HAVE_XML2)
377         else
378                 AC_MSG_RESULT(Not found)
379         fi
380 fi
381 dnl
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)
388 fi
389 dnl
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`
394 YAZ_BUILD_ROOT=`pwd`
395 dnl
396 dnl ------ Makefiles
397 dnl
398 AC_OUTPUT([
399 Makefile
400 yaz.spec
401 util/Makefile
402 odr/Makefile
403 z39.50/Makefile
404 ill/Makefile
405 zutil/Makefile
406 comstack/Makefile
407 ccl/Makefile
408 cql/Makefile
409 server/Makefile
410 include/Makefile
411 include/yaz/Makefile
412 lib/Makefile
413 client/Makefile
414 ztest/Makefile
415 zoom/Makefile
416 doc/Makefile
417 doc/yaz.xml
418 doc/yazhtml.dsl
419 doc/yazphp.dsl
420 doc/yazprint.dsl
421 doc/tkl.xsl
422 doc/yazhtml.xsl
423 etc/Makefile
424 yaz-config
425 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > lib/yaz-config && chmod +x yaz-config lib/yaz-config])