Added a way to get around the old log warning
[yaz-moved-to-github.git] / configure.in
1 dnl YAZ Toolkit, Index Data 1994-2004
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.161 2004-11-10 09:26:43 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 2.0.29)
6 AM_MAINTAINER_MODE
7 dnl
8 AC_SUBST(READLINE_LIBS)
9 AC_SUBST(YAZ_CONF_CFLAGS)
10 dnl ------ Checking programs
11 AC_PROG_CC
12 AC_PROG_CPP
13 AC_CHECK_PROGS(YACC, 'bison -y')
14 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
15 AC_PROG_INSTALL
16 AM_DISABLE_SHARED
17 AM_PROG_LIBTOOL
18 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
19 dnl
20 YAZ_DOC
21 dnl 
22 dnl ----- Sockets
23 checkBoth=0
24 AC_CHECK_FUNC(connect)
25 if test "$ac_cv_func_connect" = "no"; then
26         AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
27 fi
28 if test "$checkBoth" = "1"; then
29         oldLibs=$LIBS
30         LIBS="$LIBS -lsocket -lnsl"
31         AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
32 fi
33 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
34 dnl
35 dnl ------ OpenSSL
36 AC_SUBST(SSL_CFLAGS)
37 openssl=no
38 AC_ARG_WITH(openssl, [  --with-openssl[=PREFIX]   OpenSSL library in PREFIX], [openssl=$withval])
39 SSL_CFLAGS=""
40 SSL_LIBPATH=""
41 if test "$openssl" != "no"; then
42         sslver=no
43         if test "$openssl" != "yes"; then
44                 if test -x $openssl/bin/pkg-config; then
45                         if $openssl/bin/pkg-config --exists openssl; then
46                                 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
47                                 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
48                                 sslver=`$openssl/bin/pkg-config --modversion openssl`
49                         fi
50                 fi
51                 if test "$sslver" = "no"; then
52                         SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
53                         SSL_LIBPATH="-L$openssl/lib"
54                 fi
55         else
56                 if test "$pkgconfigpath" != "NONE"; then
57                         if $pkgconfigpath --exists openssl; then
58                                 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
59                                 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
60                                 sslver=`$pkgconfigpath --modversion openssl`
61                         fi
62                 fi
63                 if test "$sslver" = "no"; then
64                         SSL_CFLAGS="-I/usr/include/openssl"
65                 fi
66         fi
67         if test "$sslver" = "no"; then
68                 xLIBS="$LIBS";
69                 xCPPFLAGS="$CPPFLAGS";
70                 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
71                 AC_CHECK_LIB(crypto, main)
72                 AC_CHECK_LIB(ssl, SSL_new)
73                 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
74                         AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
75                         LIBS="$SSL_LIBPATH $LIBS"
76                 fi
77                 if test "$sslver" != "yes"; then
78                         LIBS="$xLIBS"
79                 fi
80                 CPPFLAGS="$xCPPFLAGS"
81         fi
82         AC_MSG_CHECKING([for SSL])
83         if test "$sslver" != "no"; then
84                 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
85                 AC_MSG_RESULT([$sslver])
86         else
87                 SSL_CFLAGS=""
88                 AC_MSG_RESULT([None])
89                 AC_MSG_ERROR([OpenSSL development libraries missing])
90         fi
91 fi
92 dnl
93 dnl ------ GNU Readline
94 READLINE_SHARED_LIBADD=""
95 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
96         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
97 )
98 READLINE_LIBS=""
99 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
100 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
101 if test "$ac_cv_lib_readline_readline" = "yes"; then
102         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
103         xLIBS=$LIBS
104         LIBS="$LIBS $READLINE_LIBS"
105         AC_TRY_LINK([
106         #include <stdio.h>
107         #include <readline/readline.h>
108         ],[
109                 rl_attempted_completion_over = 0;
110         ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
111         AC_TRY_LINK([
112         #include <stdio.h>
113         #include <readline/readline.h>
114         ],[
115                 rl_completion_matches (0, 0);
116         ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
117         LIBS=$xLIBS
118 fi
119 dnl ------ iconv
120 AC_ARG_WITH(iconv, [  --with-iconv[=PREFIX]     iconv library in PREFIX])
121 if test "$with_iconv" != "no"; then
122         AC_MSG_CHECKING(for iconv)
123         oldLIBS="$LIBS"
124         oldCPPFLAGS="${CPPFLAGS}"
125         if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
126                 LIBS="$LIBS -L${with_iconv}/lib"
127                 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
128         fi
129         AC_TRY_LINK([
130                 #include <iconv.h>
131         ],[
132                 iconv_t t = iconv_open("", "");
133         ],[
134                 AC_DEFINE(HAVE_ICONV_H)
135                 AC_MSG_RESULT(yes)
136         ],[
137                 LIBS="$LIBS -liconv"
138                 AC_TRY_LINK([
139                         #include <iconv.h>
140                 ],[
141                         iconv_t t = iconv_open("", "");
142                 ],[
143                         AC_DEFINE(HAVE_ICONV_H)
144                         AC_MSG_RESULT(yes)
145                 ],[
146                         LIBS="$oldLIBS"
147                         CPPFLAGS="$oldCPPFLAGS"
148                         AC_MSG_RESULT(no)
149                 ])
150         ])
151 fi
152 dnl ------ various functions
153 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
154 if test "$ac_cv_func_poll" = "yes"; then
155         AC_CHECK_HEADERS(sys/poll.h)
156 fi
157 dnl ------ socklen_t
158 dnl We check for socklen_t by making prototypes with the
159 dnl various types. First socklen_t, then size_t, finally int.
160 dnl If the prototype succeeds, we're probably safe.
161 dnl That works if accept is not preprocessor defined (such sa AIX)
162 AC_MSG_CHECKING([for socklen_t])
163 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
164         AC_TRY_COMPILE([
165 #include <sys/types.h>
166 #include <sys/socket.h>
167 #ifdef __cplusplus
168 extern "C" {
169 #endif
170 #define try 1
171 #ifdef AIX
172 #if AIX >= 51
173 #define try 0
174 #endif
175 #endif
176 #if try
177 extern int accept(int, struct sockaddr *, socklen_t *);
178 #endif
179 #ifdef __cplusplus
180 }
181 #endif
182         ],,[ac_cv_check_socklen_t=socklen_t],[
183                 AC_TRY_COMPILE([
184 #include <sys/types.h>
185 #include <sys/socket.h>
186 #ifdef __cplusplus
187 extern "C" {
188 #endif
189 #define try 1
190 #ifdef AIX
191 #if AIX >= 42
192 #define try 0
193 #endif
194 #endif
195 #if try
196 extern int accept(int, struct sockaddr *, size_t t *);
197 #endif
198 #ifdef __cplusplus
199 }
200 #endif
201                 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
202         ])
203 ])
204 AC_MSG_RESULT($ac_cv_check_socklen_t)
205 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
206 dnl
207 dnl ------ tcpd
208 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])
209 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
210         oldLibs=$LIBS
211         oldCPPFLAGS=$CPPFLAGS
212         if test "$enable_tcpd" != "yes"; then
213                 LIBS="$LIBS -L$enable_tcpd/lib"
214                 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
215         fi
216         AC_MSG_CHECKING(for working tcpd.h)
217         LIBS="$LIBS -lwrap -lnsl"
218         AC_TRY_LINK([#include <syslog.h>
219 #include <tcpd.h>
220         int allow_severity = LOG_INFO;
221         int deny_severity = LOG_WARNING;],
222         [struct request_info request_info; int i;
223         i = hosts_access(&request_info);],
224         tcpd_ok=1, tcpd_ok=0)
225         if test "$tcpd_ok" = "0"; then
226                 AC_MSG_RESULT(no)
227                 AC_MSG_ERROR([tcpd development libraries missing])
228                 LIBS=$oldLibs
229                 CPPFLAGS=$oldCPPFLAGS
230         else
231                 AC_MSG_RESULT(yes)
232                 AC_DEFINE(HAVE_TCPD_H)
233         fi
234 fi
235 dnl
236 dnl ------ Headers
237 AC_CHECK_HEADERS(fnmatch.h wchar.h locale.h langinfo.h)
238 AC_STDC_HEADERS
239 if test "$ac_cv_header_stdc" = "no"; then
240         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
241 fi
242 dnl
243 AC_SUBST(LIBTHREAD)
244 AC_SUBST(CFLAGSTHREADS)
245 HAVETHREADS=0
246 CFLAGSTHREADS=""
247 LIBTHREAD=""
248 dnl
249 dnl ------ GNU threads
250 AC_ARG_ENABLE(pth, [  --enable-pth            enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
251 AC_SUBST(LIBPTH)
252 if test "$enable_pth" = "yes"; then
253         OLIBS=$LIBS
254         AC_CHECK_LIB(pth,main)
255         if test "$ac_cv_lib_pth_main" = "yes"; then
256                 AC_CHECK_HEADERS(pth.h)
257                 if test "$ac_cv_header_pth_h" = "yes"; then
258                         LIBTHREAD="-lpth"
259                         CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
260                         HAVETHREADS=1
261                 fi
262         fi      
263         LIBS=$OLIBS
264 fi
265 dnl
266 dnl ------ POSIX Threads
267 AC_ARG_ENABLE(threads, [  --disable-threads       disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
268 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
269         OLIBS=$LIBS
270         OCC=$CC
271         AC_CHECK_LIB(pthread,main)
272         AC_MSG_CHECKING(for working POSIX Threads)
273         AC_TRY_LINK([#include <pthread.h>
274         void *func(void *p) { return 0; }
275         ],[
276         pthread_t pthread_id;
277         pthread_create (&pthread_id, 0, func, 0);],
278                 thread_ok=yes,thread_ok=no)
279         if test "$thread_ok" = "yes"; then
280                 AC_MSG_RESULT(yes)
281                 LIBTHREAD="-lpthread"
282                 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
283                 HAVETHREADS=1
284         else
285                 CC="$CC -pthread"
286                 AC_TRY_LINK([#include <pthread.h>
287                         void *func(void *p) { return 0; }
288                         ],[
289                         pthread_t pthread_id;
290                         pthread_create (&pthread_id, 0, func, 0);],
291                         thread_ok=yes,thread_ok=no)
292                 if test "$thread_ok" = "yes"; then
293                         AC_MSG_RESULT([yes,BSD])
294                         CFLAGSTHREADS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
295                         LIBTHREAD="-pthread"
296                         HAVETHREADS=1
297                 fi
298         fi
299         if test "$thread_ok" = "no"; then
300                 AC_MSG_RESULT(no)
301         fi
302         CC=$OCC
303         LIBS=$OLIBS
304 fi
305 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
306 dnl
307 dnl ----- libXML2
308 AC_SUBST(XML2_LIBS)
309 AC_SUBST(XML2_CFLAGS)
310 xml2dir=default
311 AC_ARG_WITH(xml2, [  --with-xml2[=PREFIX]      use libxml2 in PREFIX],[xml2dir=$withval])
312 if test "$xml2dir" = "yes" -o "$xml2dir" = "default"; then
313         for d in /usr /usr/local; do
314                 if test -x $d/bin/xml2-config; then
315                         xml2dir=$d
316                 fi
317         done
318 fi
319 if test "$xml2dir" != "no"; then
320         AC_MSG_CHECKING(for libXML2)
321         if test -x $xml2dir/bin/xml2-config; then
322                 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
323                 LIBS="$XML2_LIBS $LIBS"
324                 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
325                 XML2_VER=`$xml2dir/bin/xml2-config --version`
326                 AC_MSG_RESULT($XML2_VER)
327                 AC_DEFINE(HAVE_XML2)
328         else
329                 AC_MSG_RESULT([Not found])
330                 if test "$xml2dir" != "default"; then
331                         AC_MSG_ERROR([libXML2 development libraries missing])
332                 fi
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 src/Makefile
356 test/Makefile
357 util/Makefile
358 include/Makefile
359 include/yaz/Makefile
360 client/Makefile
361 ztest/Makefile
362 zoom/Makefile
363 doc/Makefile
364 doc/yaz.xml
365 doc/yazhtml.dsl
366 doc/yazphp.dsl
367 doc/yazprint.dsl
368 doc/tkl.xsl
369 doc/yazhtml.xsl
370 etc/Makefile
371 yaz-config
372 Doxyfile
373 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])