Remove --enable-module option
[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.76 2002-06-02 21:34:45 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 ------ EXPAT
77 expat=no
78 AC_ARG_WITH(expat,   [  --with-expat[=DIR]      EXPAT library in DIR],[expat=$withval])
79 if test "$expat" != "no"; then
80         xLIBS="$LIBS";
81         xCFLAGS="$CFLAGS";
82         if test "$expat" != "yes"; then
83                 EXPAT_CFLAGS="-I$expat/include"
84                 EXPAT_LIBS="-L$expat/lib"
85                 CFLAGS="$EXPAT_CFLAGS $CFLAGS"
86                 LIBS="$EXPAT_LIBS $LIBS"
87         fi
88         AC_CHECK_LIB(expat,XML_ParserCreate,[LIBS="$LIBS -lexpat"])
89         if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
90                 AC_CHECK_HEADERS(expat.h)
91                 if test "$ac_cv_header_expat_h" = "yes"; then
92                         YAZ_CONF_CFLAGS="$YAZ_CONF_CFLAGS -DYAZ_HAVE_EXPAT=1"
93                 fi
94         else
95                 LIBS="$xLIBS"
96                 CFLAGS="$xCFLAGS"
97         fi
98 fi
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 ------ various functions
166 AC_CHECK_FUNCS(vsnprintf gettimeofday poll)
167 if test "$ac_cv_func_poll" = "yes"; then
168         AC_CHECK_HEADERS(sys/poll.h)
169 fi
170 dnl
171 dnl ------ tcpd
172 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
173 if test "$enable_tcpd" != ""; then
174         oldLibs=$LIBS
175         oldCPPFLAGS=$CPPFLAGS
176         if test "$enable_tcpd" != "yes"; then
177                 LIBS="$LIBS -L$enable_tcpd/lib"
178                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
179         fi
180         AC_MSG_CHECKING(for working tcpd.h)
181         LIBS="$LIBS -lwrap -lnsl"
182         AC_TRY_LINK([#include <syslog.h>
183 #include <tcpd.h>
184         int allow_severity = LOG_INFO;
185         int deny_severity = LOG_WARNING;],
186         [struct request_info request_info; int i;
187         i = hosts_access(&request_info);],
188         tcpd_ok=1, tcpd_ok=0)
189         if test "$tcpd_ok" = "0"; then
190                 AC_MSG_RESULT(no)
191                 LIBS=$oldLibs
192                 CPPFLAGS=$oldCPPFLAGS
193         else
194                 AC_MSG_RESULT(yes)
195                 AC_DEFINE(HAVE_TCPD_H)
196         fi
197 fi
198 dnl
199 dnl ------ Headers
200 AC_CHECK_HEADERS(fnmatch.h)
201 AC_STDC_HEADERS
202 if test "$ac_cv_header_stdc" = "no"; then
203         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
204 fi
205 dnl
206 AC_SUBST(LIBTHREAD)
207 AC_SUBST(CFLAGSTHREADS)
208 HAVETHREADS=0
209 CFLAGSTHREADS=""
210 LIBTHREAD=""
211 dnl
212 dnl ------ GNU threads
213 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
214 AC_SUBST(LIBPTH)
215 if test "$enable_pth" = "yes"; then
216         OLIBS=$LIBS
217         AC_CHECK_LIB(pth,main)
218         if test "$ac_cv_lib_pth_main" = "yes"; then
219                 AC_CHECK_HEADERS(pth.h)
220                 if test "$ac_cv_header_pth_h" = "yes"; then
221                         LIBTHREAD="-lpth"
222                         CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
223                         HAVETHREADS=1
224                 fi
225         fi      
226         LIBS=$OLIBS
227 fi
228 dnl
229 dnl ------ POSIX Threads
230 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
231 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
232         OLIBS=$LIBS
233         OCC=$CC
234         AC_CHECK_LIB(pthread,main)
235         AC_MSG_CHECKING(for working POSIX Threads)
236         AC_TRY_LINK([#include <pthread.h>
237         void *func(void *p) { return 0; }
238         ],[
239         pthread_t pthread_id;
240         pthread_create (&pthread_id, 0, func, 0);],
241                 thread_ok=yes,thread_ok=no)
242         if test "$thread_ok" = "yes"; then
243                 AC_MSG_RESULT(yes)
244                 LIBTHREAD="-lpthread"
245                 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
246                 HAVETHREADS=1
247         else
248                 CC="$CC -pthread"
249                 AC_TRY_LINK([#include <pthread.h>
250                         void *func(void *p) { return 0; }
251                         ],[
252                         pthread_t pthread_id;
253                         pthread_create (&pthread_id, 0, func, 0);],
254                         thread_ok=yes,thread_ok=no)
255                 if test "$thread_ok" = "yes"; then
256                         AC_MSG_RESULT([yes,BSD])
257                         CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
258                         LIBTHREAD="-pthread"
259                         HAVETHREADS=1
260                 fi
261         fi
262         if test "$thread_ok" = "no"; then
263                 AC_MSG_RESULT(no)
264         fi
265         CC=$OCC
266         LIBS=$OLIBS
267 fi
268 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
269 dnl
270 dnl ------ Memory debugging
271 AC_ARG_ENABLE(memdebug, [  --enable-memdebug       enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
272 if test "$enable_memdebug" = "yes"; then
273         AC_DEFINE(TRACE_XMALLOC,2)
274 elif test "$enable_memdebug" = "no"; then
275         AC_DEFINE(TRACE_XMALLOC,0)
276 fi
277 dnl
278 dnl ------ Using this for "in-source" yaz-config
279 AC_SUBST(YAZ_SRC_ROOT)
280 AC_SUBST(YAZ_BUILD_ROOT)
281 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
282 YAZ_BUILD_ROOT=`pwd`
283 dnl
284 if test -f ${srcdir}/lib/yaz-config.in; then
285         rm ${srcdir}/lib/yaz-config.in
286 fi
287 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < ${srcdir}/yaz-config.in >${srcdir}/lib/yaz-config.in
288 dnl
289 dnl ------ Makefiles
290 dnl
291 AC_OUTPUT([
292 Makefile
293 yaz.spec
294 util/Makefile
295 odr/Makefile
296 z39.50/Makefile
297 ill/Makefile
298 zutil/Makefile
299 comstack/Makefile
300 ccl/Makefile
301 tab/Makefile
302 retrieval/Makefile
303 server/Makefile
304 include/Makefile
305 include/yaz/Makefile
306 lib/Makefile
307 zoom/Makefile
308 client/Makefile
309 ztest/Makefile
310 doc/Makefile
311 doc/yaz.xml
312 doc/yazhtml.dsl
313 doc/yazphp.dsl
314 doc/yazprint.dsl
315 yaz-config
316 lib/yaz-config
317 ],[chmod +x yaz-config lib/yaz-config])