Keep white space for XML (do not pretty print)
[yaz-moved-to-github.git] / configure.in
1 dnl YAZ Toolkit, Index Data 1994-2001
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.77 2002-07-05 12:42:52 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 1.8.8dev)
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_PROG_INSTALL
13 AM_DISABLE_SHARED
14 AM_PROG_LIBTOOL
15 dnl
16 dnl ----- DOCBOOK DTD
17 AC_SUBST(DTD_DIR)
18 AC_ARG_WITH(dtd, [  --with-dtd[=DIR]        Use docbookx.dtd in DIR],
19 [
20    if test -f "$withval/docbookx.dtd"; then
21       DTD_DIR=$withval
22    fi
23 ],[
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/dtd/xml/4.0 \
28             /usr/lib/sgml/dtd/docbook-xml 
29    do
30      if test -f $d/docbookx.dtd; then
31        AC_MSG_RESULT($d)
32        DTD_DIR=$d
33        break
34      fi
35    done
36    if test -z "$DTD_DIR"; then
37       AC_MSG_RESULT(Not found)
38    fi
39 ])
40 AC_SUBST(DSSSL_DIR)
41 AC_ARG_WITH(dsssl,[  --with-dsssl[=DIR]      Use DSSSL in DIR/{html,print}/docbook.dsl],
42 [
43    if test -f "$withval/html/docbook.dsl"; then
44       DSSSL_DIR=$withval
45    fi
46 ],[
47    AC_MSG_CHECKING(for docbook.dsl)
48    for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
49             /usr/share/sgml/docbook/dsssl-stylesheets-1.64 \
50             /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh 
51    do
52      if test -f $d/html/docbook.dsl; then
53        AC_MSG_RESULT($d)
54        DSSSL_DIR=$d
55        break
56      fi
57    done
58    if test -z "$DSSSL_DIR"; then
59       AC_MSG_RESULT(Not found)
60    fi
61 ])
62 dnl 
63 dnl ----- Sockets
64 checkBoth=0
65 AC_CHECK_FUNC(connect)
66 if test "$ac_cv_func_connect" = "no"; then
67         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
68 fi
69 if test "$checkBoth" = "1"; then
70         oldLibs=$LIBS
71         LIBS="$LIBS -lsocket -lnsl"
72         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
73 fi
74 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
75 dnl
76 dnl
77 dnl ------ EXPAT
78 expat=yes
79 AC_ARG_WITH(expat,   [  --with-expat[=DIR]      EXPAT library in DIR],[expat=$withval])
80 if test "$expat" != "no"; then
81         xLIBS="$LIBS";
82         xCFLAGS="$CFLAGS";
83         if test "$expat" != "yes"; then
84                 EXPAT_CFLAGS="-I$expat/include"
85                 EXPAT_LIBS="-L$expat/lib"
86                 CFLAGS="$EXPAT_CFLAGS $CFLAGS"
87                 LIBS="$EXPAT_LIBS $LIBS"
88         fi
89         AC_CHECK_LIB(expat,XML_ParserCreate,[LIBS="$LIBS -lexpat"])
90         if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
91                 AC_CHECK_HEADERS(expat.h)
92                 if test "$ac_cv_header_expat_h" = "yes"; then
93                         YAZ_CONF_CFLAGS="$YAZ_CONF_CFLAGS -DYAZ_HAVE_EXPAT=1"
94                 fi
95         else
96                 LIBS="$xLIBS"
97                 CFLAGS="$xCFLAGS"
98         fi
99 fi
100 dnl
101 dnl ------ Open SSL
102 openssl=no
103 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    OpenSSL library in DIR], [openssl=$withval])
104 AC_SUBST(SSL_CFLAGS)
105 AC_SUBST(SSL_LIBS)
106 AC_SUBST(SSL_DEFS)
107 USE_SSL=0
108 SSL_CFLAGS=""
109 SSL_LIBS=""
110 SSL_DEFS=""
111 if test "$openssl" != "no"; then
112         xLIBS="$LIBS";
113         xCFLAGS="$CFLAGS";
114         if test "$openssl" != "yes"; then
115                 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
116                 SSL_LIBS="-L$openssl/lib"
117                 CFLAGS="$SSL_CFLAGS $CFLAGS"
118                 LIBS="$SSL_LIBS $LIBS"
119         fi
120         AC_CHECK_LIB(crypto, main,[SSL_LIBS="$SSL_LIBS -lcrypto"])
121         LIBS="$LIBS $SSL_LIBS"
122         AC_CHECK_LIB(ssl, SSL_new)
123         if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
124                 SSL_LIBS="$SSL_LIBS -lssl"
125                 AC_CHECK_HEADER(openssl/ssl.h,[SSL_DEFS="-DHAVE_OPENSSL_SSL_H=1"; USE_SSL=1])
126         else
127                 SSL_LIBS=""
128         fi
129         LIBS="$xLIBS"
130         CFLAGS="$xCFLAGS"
131 fi
132 AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
133 dnl
134 dnl ------ GNU Readline
135 READLINE_SHARED_LIBADD=""
136 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
137         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
138 )
139 READLINE_LIBS=""
140 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
141 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
142 if test "$ac_cv_lib_readline_readline" = "yes"; then
143         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
144         xLIBS=$LIBS
145         LIBS="$LIBS $READLINE_LIBS"
146         AC_TRY_LINK([
147         #include <stdio.h>
148         #include <readline/readline.h>
149         ],[
150         static void f()
151         {
152                 rl_attempted_completion_over = 0;
153         }
154         ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
155         AC_TRY_LINK([
156         #include <stdio.h>
157         #include <readline/readline.h>
158         ],[
159         static void f()
160         {
161                 rl_completion_matches (0, 0);
162         }
163         ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
164         LIBS=$xLIBS
165 fi
166 dnl ------ various functions
167 AC_CHECK_FUNCS(vsnprintf gettimeofday poll)
168 if test "$ac_cv_func_poll" = "yes"; then
169         AC_CHECK_HEADERS(sys/poll.h)
170 fi
171 dnl
172 dnl ------ tcpd
173 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
174 if test "$enable_tcpd" != ""; then
175         oldLibs=$LIBS
176         oldCPPFLAGS=$CPPFLAGS
177         if test "$enable_tcpd" != "yes"; then
178                 LIBS="$LIBS -L$enable_tcpd/lib"
179                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
180         fi
181         AC_MSG_CHECKING(for working tcpd.h)
182         LIBS="$LIBS -lwrap -lnsl"
183         AC_TRY_LINK([#include <syslog.h>
184 #include <tcpd.h>
185         int allow_severity = LOG_INFO;
186         int deny_severity = LOG_WARNING;],
187         [struct request_info request_info; int i;
188         i = hosts_access(&request_info);],
189         tcpd_ok=1, tcpd_ok=0)
190         if test "$tcpd_ok" = "0"; then
191                 AC_MSG_RESULT(no)
192                 LIBS=$oldLibs
193                 CPPFLAGS=$oldCPPFLAGS
194         else
195                 AC_MSG_RESULT(yes)
196                 AC_DEFINE(HAVE_TCPD_H)
197         fi
198 fi
199 dnl
200 dnl ------ Headers
201 AC_CHECK_HEADERS(fnmatch.h iconv.h)
202 AC_STDC_HEADERS
203 if test "$ac_cv_header_stdc" = "no"; then
204         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
205 fi
206 dnl
207 AC_SUBST(LIBTHREAD)
208 AC_SUBST(CFLAGSTHREADS)
209 HAVETHREADS=0
210 CFLAGSTHREADS=""
211 LIBTHREAD=""
212 dnl
213 dnl ------ GNU threads
214 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
215 AC_SUBST(LIBPTH)
216 if test "$enable_pth" = "yes"; then
217         OLIBS=$LIBS
218         AC_CHECK_LIB(pth,main)
219         if test "$ac_cv_lib_pth_main" = "yes"; then
220                 AC_CHECK_HEADERS(pth.h)
221                 if test "$ac_cv_header_pth_h" = "yes"; then
222                         LIBTHREAD="-lpth"
223                         CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
224                         HAVETHREADS=1
225                 fi
226         fi      
227         LIBS=$OLIBS
228 fi
229 dnl
230 dnl ------ POSIX Threads
231 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
232 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
233         OLIBS=$LIBS
234         OCC=$CC
235         AC_CHECK_LIB(pthread,main)
236         AC_MSG_CHECKING(for working POSIX Threads)
237         AC_TRY_LINK([#include <pthread.h>
238         void *func(void *p) { return 0; }
239         ],[
240         pthread_t pthread_id;
241         pthread_create (&pthread_id, 0, func, 0);],
242                 thread_ok=yes,thread_ok=no)
243         if test "$thread_ok" = "yes"; then
244                 AC_MSG_RESULT(yes)
245                 LIBTHREAD="-lpthread"
246                 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
247                 HAVETHREADS=1
248         else
249                 CC="$CC -pthread"
250                 AC_TRY_LINK([#include <pthread.h>
251                         void *func(void *p) { return 0; }
252                         ],[
253                         pthread_t pthread_id;
254                         pthread_create (&pthread_id, 0, func, 0);],
255                         thread_ok=yes,thread_ok=no)
256                 if test "$thread_ok" = "yes"; then
257                         AC_MSG_RESULT([yes,BSD])
258                         CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
259                         LIBTHREAD="-pthread"
260                         HAVETHREADS=1
261                 fi
262         fi
263         if test "$thread_ok" = "no"; then
264                 AC_MSG_RESULT(no)
265         fi
266         CC=$OCC
267         LIBS=$OLIBS
268 fi
269 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
270 dnl
271 dnl ------ Memory debugging
272 AC_ARG_ENABLE(memdebug, [  --enable-memdebug       enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
273 if test "$enable_memdebug" = "yes"; then
274         AC_DEFINE(TRACE_XMALLOC,2)
275 elif test "$enable_memdebug" = "no"; then
276         AC_DEFINE(TRACE_XMALLOC,0)
277 fi
278 dnl
279 dnl ------ Using this for "in-source" yaz-config
280 AC_SUBST(YAZ_SRC_ROOT)
281 AC_SUBST(YAZ_BUILD_ROOT)
282 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
283 YAZ_BUILD_ROOT=`pwd`
284 dnl
285 if test -f ${srcdir}/lib/yaz-config.in; then
286         rm ${srcdir}/lib/yaz-config.in
287 fi
288 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < ${srcdir}/yaz-config.in >${srcdir}/lib/yaz-config.in
289 dnl
290 dnl ------ Makefiles
291 dnl
292 AC_OUTPUT([
293 Makefile
294 yaz.spec
295 util/Makefile
296 odr/Makefile
297 z39.50/Makefile
298 ill/Makefile
299 zutil/Makefile
300 comstack/Makefile
301 ccl/Makefile
302 tab/Makefile
303 retrieval/Makefile
304 server/Makefile
305 include/Makefile
306 include/yaz/Makefile
307 lib/Makefile
308 zoom/Makefile
309 client/Makefile
310 ztest/Makefile
311 doc/Makefile
312 doc/yaz.xml
313 doc/yazhtml.dsl
314 doc/yazphp.dsl
315 doc/yazprint.dsl
316 yaz-config
317 lib/yaz-config
318 ],[chmod +x yaz-config lib/yaz-config])