1 dnl YAZ Toolkit, Index Data 1994-2005
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.in,v 1.172 2005-02-21 14:37:16 adam Exp $
4 AC_INIT(include/yaz/yaz-version.h)
5 AM_INIT_AUTOMAKE(yaz, 2.0.35)
8 AC_SUBST(READLINE_LIBS)
9 AC_SUBST(YAZ_CONF_CFLAGS)
10 dnl ------ Checking programs
13 AC_CHECK_PROGS(YACC, 'bison -y')
14 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
18 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
24 AC_CHECK_HEADERS(dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h sys/poll.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/un.h sys/wait.h unistd.h)
26 if test "$ac_cv_header_stdc" = "no"; then
27 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
30 AC_CHECK_TYPES([long long])
34 AC_CHECK_FUNC(connect)
35 if test "$ac_cv_func_connect" = "no"; then
36 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
38 if test "$checkBoth" = "1"; then
40 LIBS="$LIBS -lsocket -lnsl"
41 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
43 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
48 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
51 if test "$openssl" != "no"; then
53 if test "$openssl" != "yes"; then
54 if test -x $openssl/bin/pkg-config; then
55 if $openssl/bin/pkg-config --exists openssl; then
56 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
57 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
58 sslver=`$openssl/bin/pkg-config --modversion openssl`
61 if test "$sslver" = "no"; then
62 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
63 SSL_LIBPATH="-L$openssl/lib"
66 if test "$pkgconfigpath" != "NONE"; then
67 if $pkgconfigpath --exists openssl; then
68 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
69 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
70 sslver=`$pkgconfigpath --modversion openssl`
73 if test "$sslver" = "no"; then
74 SSL_CFLAGS="-I/usr/include/openssl"
77 if test "$sslver" = "no"; then
79 xCPPFLAGS="$CPPFLAGS";
80 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
81 AC_CHECK_LIB(crypto, main)
82 AC_CHECK_LIB(ssl, SSL_new)
83 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
84 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
85 LIBS="$SSL_LIBPATH $LIBS"
87 if test "$sslver" != "yes"; then
92 AC_MSG_CHECKING([for SSL])
93 if test "$sslver" != "no"; then
94 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
95 AC_MSG_RESULT([$sslver])
99 AC_MSG_ERROR([OpenSSL development libraries missing])
103 dnl ------ GNU Readline
104 READLINE_SHARED_LIBADD=""
105 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
106 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
109 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
110 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
111 if test "$ac_cv_lib_readline_readline" = "yes"; then
112 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
114 LIBS="$LIBS $READLINE_LIBS"
117 #include <readline/readline.h>
119 rl_attempted_completion_over = 0;
120 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
123 #include <readline/readline.h>
125 rl_completion_matches (0, 0);
126 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
130 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
131 if test "$with_iconv" != "no"; then
132 AC_MSG_CHECKING(for iconv)
134 oldCPPFLAGS="${CPPFLAGS}"
135 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
136 LIBS="$LIBS -L${with_iconv}/lib"
137 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
142 iconv_t t = iconv_open("", "");
144 AC_DEFINE(HAVE_ICONV_H)
151 iconv_t t = iconv_open("", "");
153 AC_DEFINE(HAVE_ICONV_H)
157 CPPFLAGS="$oldCPPFLAGS"
162 dnl ------ various functions
163 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r usleep)
164 if test "$ac_cv_func_poll" = "yes"; then
165 AC_CHECK_HEADERS(sys/poll.h)
168 dnl We check for socklen_t by making prototypes with the
169 dnl various types. First socklen_t, then size_t, finally int.
170 dnl If the prototype succeeds, we're probably safe.
171 dnl That works if accept is not preprocessor defined (such sa AIX)
172 AC_MSG_CHECKING([for socklen_t])
173 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
175 #include <sys/types.h>
176 #include <sys/socket.h>
187 extern int accept(int, struct sockaddr *, socklen_t *);
192 ],,[ac_cv_check_socklen_t=socklen_t],[
194 #include <sys/types.h>
195 #include <sys/socket.h>
206 extern int accept(int, struct sockaddr *, size_t t *);
211 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
214 AC_MSG_RESULT($ac_cv_check_socklen_t)
215 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
216 AC_DEFINE(YAZ_USE_NEW_LOG)
219 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
220 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
222 oldCPPFLAGS=$CPPFLAGS
223 if test "$enable_tcpd" != "yes"; then
224 LIBS="$LIBS -L$enable_tcpd/lib"
225 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
227 AC_MSG_CHECKING(for working tcpd.h)
228 LIBS="$LIBS -lwrap -lnsl"
229 AC_TRY_LINK([#include <syslog.h>
231 int allow_severity = LOG_INFO;
232 int deny_severity = LOG_WARNING;],
233 [struct request_info request_info; int i;
234 i = hosts_access(&request_info);],
235 tcpd_ok=1, tcpd_ok=0)
236 if test "$tcpd_ok" = "0"; then
238 AC_MSG_ERROR([tcpd development libraries missing])
240 CPPFLAGS=$oldCPPFLAGS
243 AC_DEFINE(HAVE_TCPD_H)
248 AC_SUBST(CFLAGSTHREADS)
253 dnl ------ GNU threads
254 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
256 if test "$enable_pth" = "yes"; then
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
263 CFLAGSTHREADS="-DYAZ_GNU_THREADS=1"
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
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; }
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
285 LIBTHREAD="-lpthread"
286 CFLAGSTHREADS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
290 AC_TRY_LINK([#include <pthread.h>
291 void *func(void *p) { return 0; }
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"
303 if test "$thread_ok" = "no"; then
309 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
313 AC_SUBST(XML2_CFLAGS)
315 AC_ARG_WITH(xml2, [ --with-xml2[=PREFIX] use libxml2 in PREFIX],[xml2dir=$withval])
316 if test "$xml2dir" = "yes" -o "$xml2dir" = "default"; then
317 for d in /usr /usr/local; do
318 if test -x $d/bin/xml2-config; then
323 if test "$xml2dir" != "no"; then
324 AC_MSG_CHECKING(for libXML2)
325 if test -x $xml2dir/bin/xml2-config; then
326 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
327 LIBS="$XML2_LIBS $LIBS"
328 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
329 XML2_VER=`$xml2dir/bin/xml2-config --version`
330 AC_MSG_RESULT($XML2_VER)
333 AC_MSG_RESULT([Not found])
334 if test "$xml2dir" != "default"; then
335 AC_MSG_ERROR([libXML2 development libraries missing])
340 dnl ------ Memory debugging
341 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
342 if test "$enable_memdebug" = "yes"; then
343 AC_DEFINE(TRACE_XMALLOC,2)
344 elif test "$enable_memdebug" = "no"; then
345 AC_DEFINE(TRACE_XMALLOC,0)
348 dnl ------ Using this for "in-source" yaz-config
349 AC_SUBST(YAZ_SRC_ROOT)
350 AC_SUBST(YAZ_BUILD_ROOT)
351 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
377 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])