SOAP, SRW codecs and HTTP transport for YAZ using 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.103 2003-02-12 15:06:42 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 dnl 
66 dnl ----- Sockets
67 checkBoth=0
68 AC_CHECK_FUNC(connect)
69 if test "$ac_cv_func_connect" = "no"; then
70         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
71 fi
72 if test "$checkBoth" = "1"; then
73         oldLibs=$LIBS
74         LIBS="$LIBS -lsocket -lnsl"
75         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
76 fi
77 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
78 dnl
79 dnl ------ Open SSL
80 openssl=no
81 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    OpenSSL library in DIR], [openssl=$withval])
82 AC_SUBST(SSL_CFLAGS)
83 AC_SUBST(SSL_LIBS)
84 AC_SUBST(SSL_DEFS)
85 USE_SSL=0
86 SSL_CFLAGS=""
87 SSL_LIBS=""
88 SSL_DEFS=""
89 if test "$openssl" != "no"; then
90         xLIBS="$LIBS";
91         xCFLAGS="$CFLAGS";
92         if test "$openssl" != "yes"; then
93                 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
94                 SSL_LIBS="-L$openssl/lib"
95                 CFLAGS="$SSL_CFLAGS $CFLAGS"
96                 LIBS="$SSL_LIBS $LIBS"
97         fi
98         AC_CHECK_LIB(crypto, main,[SSL_LIBS="$SSL_LIBS -lcrypto"])
99         LIBS="$LIBS $SSL_LIBS"
100         AC_CHECK_LIB(ssl, SSL_new)
101         if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
102                 SSL_LIBS="$SSL_LIBS -lssl"
103                 AC_CHECK_HEADER(openssl/ssl.h,[SSL_DEFS="-DHAVE_OPENSSL_SSL_H=1"; USE_SSL=1])
104         else
105                 SSL_LIBS=""
106         fi
107         LIBS="$xLIBS"
108         CFLAGS="$xCFLAGS"
109 fi
110 AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
111 dnl
112 dnl ------ GNU Readline
113 READLINE_SHARED_LIBADD=""
114 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
115         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
116 )
117 READLINE_LIBS=""
118 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
119 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
120 if test "$ac_cv_lib_readline_readline" = "yes"; then
121         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
122         xLIBS=$LIBS
123         LIBS="$LIBS $READLINE_LIBS"
124         AC_TRY_LINK([
125         #include <stdio.h>
126         #include <readline/readline.h>
127         ],[
128         static void f()
129         {
130                 rl_attempted_completion_over = 0;
131         }
132         ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
133         AC_TRY_LINK([
134         #include <stdio.h>
135         #include <readline/readline.h>
136         ],[
137         static void f()
138         {
139                 rl_completion_matches (0, 0);
140         }
141         ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
142         LIBS=$xLIBS
143 fi
144 dnl ------ iconv
145 AC_ARG_WITH(iconv, [  --with-iconv[=DIR]      iconv library in DIR])
146 if test "$with_iconv" != "no"; then
147         AC_MSG_CHECKING(for iconv)
148         oldLIBS="$LIBS"
149         oldCPPFLAGS="${CPPFLAGS}"
150         if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
151                 LIBS="$LIBS -L${with_iconv}/lib"
152                 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
153         fi
154         AC_TRY_LINK([
155                 #include <iconv.h>
156         ],[
157                 static void f() {iconv_t t = iconv_open("", ""); }
158         ],[
159                 AC_DEFINE(HAVE_ICONV_H)
160                 AC_MSG_RESULT(yes)
161         ],[
162                 LIBS="$LIBS -liconv"
163                 AC_TRY_LINK([
164                         #include <iconv.h>
165                 ],[
166                         static void f() {iconv_t t = iconv_open("", ""); }
167                 ],[
168                         AC_DEFINE(HAVE_ICONV_H)
169                         AC_MSG_RESULT(yes)
170                 ],[
171                         LIBS="$oldLIBS"
172                         CPPFLAGS="$oldCPPFLAGS"
173                         AC_MSG_RESULT(no)
174                 ])
175         ])
176 fi
177 dnl ------ various functions
178 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
179 if test "$ac_cv_func_poll" = "yes"; then
180         AC_CHECK_HEADERS(sys/poll.h)
181 fi
182 dnl ------ socklen_t
183 AC_MSG_CHECKING([for socklen_t])
184 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
185         AC_TRY_COMPILE([
186         #include <sys/types.h>
187         #include <sys/socket.h>
188         #ifdef __cplusplus
189         extern "C" {
190         #endif
191         extern int accept(int, struct sockaddr *, socklen_t *);
192         #ifdef __cplusplus
193         }
194         #endif
195         ],,[ac_cv_check_socklen_t=socklen_t],[
196                 AC_TRY_COMPILE([
197                 #include <sys/types.h>
198                 #include <sys/socket.h>
199                 #ifdef __cplusplus
200                 extern "C" {
201                 #endif
202                 extern int accept(int, struct sockaddr *, size_t t *);
203                 #ifdef __cplusplus
204                 }
205                 #endif
206                 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
207         ])
208 ])
209 AC_MSG_RESULT($ac_cv_check_socklen_t)
210 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
211 dnl
212 dnl ------ tcpd
213 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
214 if test "$enable_tcpd" != ""; then
215         oldLibs=$LIBS
216         oldCPPFLAGS=$CPPFLAGS
217         if test "$enable_tcpd" != "yes"; then
218                 LIBS="$LIBS -L$enable_tcpd/lib"
219                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
220         fi
221         AC_MSG_CHECKING(for working tcpd.h)
222         LIBS="$LIBS -lwrap -lnsl"
223         AC_TRY_LINK([#include <syslog.h>
224 #include <tcpd.h>
225         int allow_severity = LOG_INFO;
226         int deny_severity = LOG_WARNING;],
227         [struct request_info request_info; int i;
228         i = hosts_access(&request_info);],
229         tcpd_ok=1, tcpd_ok=0)
230         if test "$tcpd_ok" = "0"; then
231                 AC_MSG_RESULT(no)
232                 LIBS=$oldLibs
233                 CPPFLAGS=$oldCPPFLAGS
234         else
235                 AC_MSG_RESULT(yes)
236                 AC_DEFINE(HAVE_TCPD_H)
237         fi
238 fi
239 dnl
240 dnl ------ Headers
241 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
242 AC_STDC_HEADERS
243 if test "$ac_cv_header_stdc" = "no"; then
244         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
245 fi
246 dnl
247 AC_SUBST(LIBTHREAD)
248 AC_SUBST(CFLAGSTHREADS)
249 HAVETHREADS=0
250 CFLAGSTHREADS=""
251 LIBTHREAD=""
252 dnl
253 dnl ------ GNU threads
254 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
255 AC_SUBST(LIBPTH)
256 if test "$enable_pth" = "yes"; then
257         OLIBS=$LIBS
258         AC_CHECK_LIB(pth,main)
259         if test "$ac_cv_lib_pth_main" = "yes"; then
260                 AC_CHECK_HEADERS(pth.h)
261                 if test "$ac_cv_header_pth_h" = "yes"; then
262                         LIBTHREAD="-lpth"
263                         CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
264                         HAVETHREADS=1
265                 fi
266         fi      
267         LIBS=$OLIBS
268 fi
269 dnl
270 dnl ------ POSIX Threads
271 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
272 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
273         OLIBS=$LIBS
274         OCC=$CC
275         AC_CHECK_LIB(pthread,main)
276         AC_MSG_CHECKING(for working POSIX Threads)
277         AC_TRY_LINK([#include <pthread.h>
278         void *func(void *p) { return 0; }
279         ],[
280         pthread_t pthread_id;
281         pthread_create (&pthread_id, 0, func, 0);],
282                 thread_ok=yes,thread_ok=no)
283         if test "$thread_ok" = "yes"; then
284                 AC_MSG_RESULT(yes)
285                 LIBTHREAD="-lpthread"
286                 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
287                 HAVETHREADS=1
288         else
289                 CC="$CC -pthread"
290                 AC_TRY_LINK([#include <pthread.h>
291                         void *func(void *p) { return 0; }
292                         ],[
293                         pthread_t pthread_id;
294                         pthread_create (&pthread_id, 0, func, 0);],
295                         thread_ok=yes,thread_ok=no)
296                 if test "$thread_ok" = "yes"; then
297                         AC_MSG_RESULT([yes,BSD])
298                         CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
299                         LIBTHREAD="-pthread"
300                         HAVETHREADS=1
301                 fi
302         fi
303         if test "$thread_ok" = "no"; then
304                 AC_MSG_RESULT(no)
305         fi
306         CC=$OCC
307         LIBS=$OLIBS
308 fi
309 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
310 dnl
311 dnl ----- XML/XSLT
312 AC_SUBST(XSLT_LIB)
313 AC_SUBST(XSLT_CFLAGS)
314 xsltdir=NONE
315 AC_ARG_WITH(xslt, [  --with-xslt[=PREFIX]    Use libxslt in PREFIX/{lib,include}],[xsltdir=$withval])
316 if test "x$xsltdir" = "xNONE"; then
317         for d in /usr /usr/local; do
318                 if test -x $d/bin/xslt-config; then
319                         xsltdir=$d
320                 fi
321         done
322 fi
323 if true; then
324         AC_MSG_CHECKING(for XSLT)
325         if test -x $xsltdir/bin/xslt-config; then
326                 XSLT_LIB=`$xsltdir/bin/xslt-config --libs`
327                 XSLT_CFLAGS=`$xsltdir/bin/xslt-config --cflags`
328                 XSLT_VER=`$xsltdir/bin/xslt-config --version`
329                 AC_MSG_RESULT($XSLT_VER)
330                 AC_DEFINE(HAVE_XSLT)
331         else
332                 AC_MSG_RESULT(Not found)
333         fi
334 fi
335 dnl
336 dnl ------ Memory debugging
337 AC_ARG_ENABLE(memdebug, [  --enable-memdebug       enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
338 if test "$enable_memdebug" = "yes"; then
339         AC_DEFINE(TRACE_XMALLOC,2)
340 elif test "$enable_memdebug" = "no"; then
341         AC_DEFINE(TRACE_XMALLOC,0)
342 fi
343 dnl
344 dnl ------ Using this for "in-source" yaz-config
345 AC_SUBST(YAZ_SRC_ROOT)
346 AC_SUBST(YAZ_BUILD_ROOT)
347 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
348 YAZ_BUILD_ROOT=`pwd`
349 dnl
350 dnl ------ Makefiles
351 dnl
352 AC_OUTPUT([
353 Makefile
354 yaz.spec
355 util/Makefile
356 odr/Makefile
357 z39.50/Makefile
358 ill/Makefile
359 zutil/Makefile
360 comstack/Makefile
361 ccl/Makefile
362 cql/Makefile
363 server/Makefile
364 include/Makefile
365 include/yaz/Makefile
366 lib/Makefile
367 client/Makefile
368 ztest/Makefile
369 zoom/Makefile
370 doc/Makefile
371 doc/yaz.xml
372 doc/yazhtml.dsl
373 doc/yazphp.dsl
374 doc/yazprint.dsl
375 doc/tkl.xsl
376 etc/Makefile
377 yaz-config
378 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > lib/yaz-config && chmod +x yaz-config lib/yaz-config])