1 dnl YAZ Toolkit, Index Data 1994-2006
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.ac,v 1.1 2006-03-28 16:36:35 adam Exp $
5 AC_INIT(yaz,2.1.15,adam.indexdata.dk)
6 AC_CONFIG_SRCDIR(configure.ac)
9 AC_SUBST(READLINE_LIBS)
10 AC_SUBST(YAZ_CONF_CFLAGS)
11 dnl ------ Checking programs
14 AC_CHECK_PROGS(YACC, 'bison -y')
15 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
19 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
25 AC_CHECK_HEADERS(dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/un.h sys/wait.h unistd.h)
27 if test "$ac_cv_header_stdc" = "no"; then
28 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
31 AC_CHECK_TYPES([long long])
35 AC_CHECK_FUNC(connect)
36 if test "$ac_cv_func_connect" = "no"; then
37 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
39 if test "$checkBoth" = "1"; then
41 LIBS="$LIBS -lsocket -lnsl"
42 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
44 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
49 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
52 if test "$openssl" != "no"; then
54 if test "$openssl" != "yes"; then
55 if test -x $openssl/bin/pkg-config; then
56 if $openssl/bin/pkg-config --exists openssl; then
57 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
58 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
59 sslver=`$openssl/bin/pkg-config --modversion openssl`
62 if test "$sslver" = "no"; then
63 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
64 SSL_LIBPATH="-L$openssl/lib"
67 if test "$pkgconfigpath" != "NONE"; then
68 if $pkgconfigpath --exists openssl; then
69 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
70 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
71 sslver=`$pkgconfigpath --modversion openssl`
74 if test "$sslver" = "no"; then
75 SSL_CFLAGS="-I/usr/include/openssl"
78 if test "$sslver" = "no"; then
80 xCPPFLAGS="$CPPFLAGS";
81 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
82 AC_CHECK_LIB(crypto, main)
83 AC_CHECK_LIB(ssl, SSL_new)
84 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
85 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
86 LIBS="$SSL_LIBPATH $LIBS"
88 if test "$sslver" != "yes"; then
93 AC_MSG_CHECKING([for SSL])
94 if test "$sslver" != "no"; then
95 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
96 AC_MSG_RESULT([$sslver])
100 AC_MSG_ERROR([OpenSSL development libraries missing])
104 dnl ------ GNU Readline
105 READLINE_SHARED_LIBADD=""
106 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
107 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
110 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
111 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
112 if test "$ac_cv_lib_readline_readline" = "yes"; then
113 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
115 LIBS="$LIBS $READLINE_LIBS"
118 #include <readline/readline.h>
120 rl_attempted_completion_over = 0;
121 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
124 #include <readline/readline.h>
126 rl_completion_matches (0, 0);
127 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
131 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
132 if test "$with_iconv" != "no"; then
133 AC_MSG_CHECKING(for iconv)
135 oldCPPFLAGS="${CPPFLAGS}"
136 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
137 LIBS="$LIBS -L${with_iconv}/lib"
138 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
143 iconv_t t = iconv_open("", "");
145 AC_DEFINE(HAVE_ICONV_H)
152 iconv_t t = iconv_open("", "");
154 AC_DEFINE(HAVE_ICONV_H)
158 CPPFLAGS="$oldCPPFLAGS"
163 dnl ------ various functions
164 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
174 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
175 AC_CHECK_HEADERS(sys/poll.h)
178 dnl We check for socklen_t by making prototypes with the
179 dnl various types. First socklen_t, then size_t, finally int.
180 dnl If the prototype succeeds, we're probably safe.
181 dnl That works if accept is not preprocessor defined (such sa AIX)
182 AC_MSG_CHECKING([for socklen_t])
183 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
185 #include <sys/types.h>
186 #include <sys/socket.h>
197 extern int accept(int, struct sockaddr *, socklen_t *);
202 ],,[ac_cv_check_socklen_t=socklen_t],[
204 #include <sys/types.h>
205 #include <sys/socket.h>
216 extern int accept(int, struct sockaddr *, size_t t *);
221 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
224 AC_MSG_RESULT($ac_cv_check_socklen_t)
225 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
226 AC_DEFINE(YAZ_USE_NEW_LOG)
229 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
230 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
232 oldCPPFLAGS=$CPPFLAGS
233 if test "$enable_tcpd" != "yes"; then
234 LIBS="$LIBS -L$enable_tcpd/lib"
235 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
237 AC_MSG_CHECKING(for working tcpd.h)
238 LIBS="$LIBS -lwrap -lnsl"
239 AC_TRY_LINK([#include <syslog.h>
241 int allow_severity = LOG_INFO;
242 int deny_severity = LOG_WARNING;],
243 [struct request_info request_info; int i;
244 i = hosts_access(&request_info);],
245 tcpd_ok=1, tcpd_ok=0)
246 if test "$tcpd_ok" = "0"; then
248 AC_MSG_ERROR([tcpd development libraries missing])
250 CPPFLAGS=$oldCPPFLAGS
253 AC_DEFINE(HAVE_TCPD_H)
257 AC_SUBST(THREAD_CFLAGS)
262 dnl ------ GNU threads
263 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
265 if test "$enable_pth" = "yes"; then
267 AC_CHECK_LIB(pth,main)
268 if test "$ac_cv_lib_pth_main" = "yes"; then
269 AC_CHECK_HEADERS(pth.h)
270 if test "$ac_cv_header_pth_h" = "yes"; then
272 THREAD_CFLAGS="-DYAZ_GNU_THREADS=1"
276 LIBS="$OLIBS $LIBTHREAD"
279 dnl ------ POSIX Threads
280 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
281 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
284 AC_CHECK_LIB(pthread,main)
285 AC_MSG_CHECKING(for working POSIX Threads)
286 AC_TRY_LINK([#include <pthread.h>
287 void *func(void *p) { return 0; }
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
294 LIBTHREAD="-lpthread"
295 THREAD_CFLAGS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
299 AC_TRY_LINK([#include <pthread.h>
300 void *func(void *p) { return 0; }
302 pthread_t pthread_id;
303 pthread_create (&pthread_id, 0, func, 0);],
304 thread_ok=yes,thread_ok=no)
305 if test "$thread_ok" = "yes"; then
306 AC_MSG_RESULT([yes,BSD])
307 THREAD_CFLAGS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
312 if test "$thread_ok" = "no"; then
316 LIBS="$OLIBS $LIBTHREAD"
321 AC_SUBST(XML2_CFLAGS)
323 AC_ARG_WITH(xml2, [ --with-xml2[=PREFIX] use libxml2 in PREFIX],[xml2dir=$withval])
324 if test "$xml2dir" = "yes" -o "$xml2dir" = "default"; then
325 for d in /usr /usr/local; do
326 if test -x $d/bin/xml2-config; then
331 if test "$xml2dir" != "no"; then
332 AC_MSG_CHECKING(for libXML2)
333 if test -x $xml2dir/bin/xml2-config; then
334 XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
335 LIBS="$XML2_LIBS $LIBS"
336 XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
337 XML2_VER=`$xml2dir/bin/xml2-config --version`
338 AC_MSG_RESULT($XML2_VER)
341 AC_MSG_RESULT([Not found])
342 if test "$xml2dir" = "default"; then
343 AC_MSG_WARN([Libxml2 development libraries not found.])
344 AC_MSG_WARN([YAZ will NOT support SRW/SRU.])
346 AC_MSG_ERROR([libXML2 development libraries not found.])
351 dnl ------ Memory debugging
352 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
353 if test "$enable_memdebug" = "yes"; then
354 AC_DEFINE(TRACE_XMALLOC,2)
355 elif test "$enable_memdebug" = "no"; then
356 AC_DEFINE(TRACE_XMALLOC,0)
359 dnl ------ Using this for "in-source" yaz-config
360 AC_SUBST(YAZ_SRC_ROOT)
361 AC_SUBST(YAZ_BUILD_ROOT)
362 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
387 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])