1 dnl YAZ Toolkit, Index Data 1994-2006
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.ac,v 1.20 2006-06-02 10:50:28 adam Exp $
5 AC_INIT([yaz],[2.1.19],[adam@indexdata.dk])
6 AC_CONFIG_SRCDIR(configure.ac)
7 AC_CONFIG_AUX_DIR([config])
8 AM_INIT_AUTOMAKE([1.8])
10 AC_SUBST(READLINE_LIBS)
11 AC_SUBST(YAZ_CONF_CFLAGS)
12 dnl ------ Checking programs
15 AC_CHECK_PROGS(YACC, 'bison -y')
16 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
17 AC_CHECK_PROGS(TCLSH, tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2, tclsh)
21 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
27 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)
29 if test "$ac_cv_header_stdc" = "no"; then
30 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
33 AC_CHECK_TYPES([long long])
37 AC_CHECK_FUNC(connect)
38 if test "$ac_cv_func_connect" = "no"; then
39 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
41 if test "$checkBoth" = "1"; then
43 LIBS="$LIBS -lsocket -lnsl"
44 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
46 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
51 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
54 if test "$openssl" != "no"; then
56 if test "$openssl" != "yes"; then
57 if test -x $openssl/bin/pkg-config; then
58 if $openssl/bin/pkg-config --exists openssl; then
59 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
60 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
61 sslver=`$openssl/bin/pkg-config --modversion openssl`
64 if test "$sslver" = "no"; then
65 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
66 SSL_LIBPATH="-L$openssl/lib"
69 if test "$pkgconfigpath" != "NONE"; then
70 if $pkgconfigpath --exists openssl; then
71 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
72 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
73 sslver=`$pkgconfigpath --modversion openssl`
76 if test "$sslver" = "no"; then
77 SSL_CFLAGS="-I/usr/include/openssl"
80 if test "$sslver" = "no"; then
82 xCPPFLAGS="$CPPFLAGS";
83 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
84 AC_CHECK_LIB(crypto, main)
85 AC_CHECK_LIB(ssl, SSL_new)
86 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
87 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
88 LIBS="$SSL_LIBPATH $LIBS"
90 if test "$sslver" != "yes"; then
95 AC_MSG_CHECKING([for SSL])
96 if test "$sslver" != "no"; then
97 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
98 AC_MSG_RESULT([$sslver])
101 AC_MSG_RESULT([None])
102 AC_MSG_ERROR([OpenSSL development libraries missing])
106 dnl ------ GNU Readline
107 READLINE_SHARED_LIBADD=""
108 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
109 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
112 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
113 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
114 if test "$ac_cv_lib_readline_readline" = "yes"; then
115 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
117 LIBS="$LIBS $READLINE_LIBS"
120 #include <readline/readline.h>
122 rl_attempted_completion_over = 0;
123 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
126 #include <readline/readline.h>
128 rl_completion_matches (0, 0);
129 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
133 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
134 if test "$with_iconv" != "no"; then
135 AC_MSG_CHECKING(for iconv)
137 oldCPPFLAGS="${CPPFLAGS}"
138 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
139 LIBS="$LIBS -L${with_iconv}/lib"
140 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
145 iconv_t t = iconv_open("", "");
147 AC_DEFINE(HAVE_ICONV_H)
154 iconv_t t = iconv_open("", "");
156 AC_DEFINE(HAVE_ICONV_H)
160 CPPFLAGS="$oldCPPFLAGS"
165 dnl ------ various functions
166 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
176 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
177 AC_CHECK_HEADERS(sys/poll.h)
180 dnl We check for socklen_t by making prototypes with the
181 dnl various types. First socklen_t, then size_t, finally int.
182 dnl If the prototype succeeds, we're probably safe.
183 dnl That works if accept is not preprocessor defined (such sa AIX)
184 AC_MSG_CHECKING([for socklen_t])
185 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
187 #include <sys/types.h>
188 #include <sys/socket.h>
199 extern int accept(int, struct sockaddr *, socklen_t *);
204 ],,[ac_cv_check_socklen_t=socklen_t],[
206 #include <sys/types.h>
207 #include <sys/socket.h>
218 extern int accept(int, struct sockaddr *, size_t t *);
223 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
226 AC_MSG_RESULT($ac_cv_check_socklen_t)
227 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
228 AC_DEFINE(YAZ_USE_NEW_LOG)
231 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
232 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
234 oldCPPFLAGS=$CPPFLAGS
235 if test "$enable_tcpd" != "yes"; then
236 LIBS="$LIBS -L$enable_tcpd/lib"
237 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
239 AC_MSG_CHECKING(for working tcpd.h)
240 LIBS="$LIBS -lwrap -lnsl"
241 AC_TRY_LINK([#include <syslog.h>
243 int allow_severity = LOG_INFO;
244 int deny_severity = LOG_WARNING;],
245 [struct request_info request_info; int i;
246 i = hosts_access(&request_info);],
247 tcpd_ok=1, tcpd_ok=0)
248 if test "$tcpd_ok" = "0"; then
250 AC_MSG_ERROR([tcpd development libraries missing])
252 CPPFLAGS=$oldCPPFLAGS
255 AC_DEFINE(HAVE_TCPD_H)
259 AC_SUBST(THREAD_CFLAGS)
264 dnl ------ GNU threads
265 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
267 if test "$enable_pth" = "yes"; then
269 AC_CHECK_LIB(pth,main)
270 if test "$ac_cv_lib_pth_main" = "yes"; then
271 AC_CHECK_HEADERS(pth.h)
272 if test "$ac_cv_header_pth_h" = "yes"; then
274 THREAD_CFLAGS="-DYAZ_GNU_THREADS=1"
278 LIBS="$OLIBS $LIBTHREAD"
281 dnl ------ POSIX Threads
282 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
283 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
286 AC_CHECK_LIB(pthread,main)
287 AC_MSG_CHECKING(for working POSIX Threads)
288 AC_TRY_LINK([#include <pthread.h>
289 void *func(void *p) { return 0; }
291 pthread_t pthread_id;
292 pthread_create (&pthread_id, 0, func, 0);],
293 thread_ok=yes,thread_ok=no)
294 if test "$thread_ok" = "yes"; then
296 LIBTHREAD="-lpthread"
297 THREAD_CFLAGS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
301 AC_TRY_LINK([#include <pthread.h>
302 void *func(void *p) { return 0; }
304 pthread_t pthread_id;
305 pthread_create (&pthread_id, 0, func, 0);],
306 thread_ok=yes,thread_ok=no)
307 if test "$thread_ok" = "yes"; then
308 AC_MSG_RESULT([yes,BSD])
309 THREAD_CFLAGS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
314 if test "$thread_ok" = "no"; then
318 LIBS="$OLIBS $LIBTHREAD"
321 dnl ----- libXSLT/libEXLT/libXML2
322 AC_SUBST(XML2_CFLAGS)
328 if test "$XML2_LIBS"; then
329 LIBS="$XML2_LIBS $LIBS"
333 dnl ------ Memory debugging
334 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
335 if test "$enable_memdebug" = "yes"; then
336 AC_DEFINE(TRACE_XMALLOC,2)
337 elif test "$enable_memdebug" = "no"; then
338 AC_DEFINE(TRACE_XMALLOC,0)
341 dnl ------ Using this for "in-source" yaz-config
342 AC_SUBST(YAZ_SRC_ROOT)
343 AC_SUBST(YAZ_BUILD_ROOT)
344 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
367 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])
371 Build and install binaries with the usual
376 Build distribution tarball with
379 Verify distribution tarball with
384 "------------------------------------------------------------------------
387 YAZ Package: ${PACKAGE}
388 YAZ Version: ${VERSION}
389 Bugreport: ${PACKAGE_BUGREPORT}
390 Source code location: ${srcdir}
391 C Preprocessor: ${CPP}
392 C Preprocessor flags: ${CPPFLAGS}
394 C Compiler flags: ${CFLAGS}
395 Linker flags: ${LDFLAGS}
397 Host System Type: ${host}
398 Install path: ${prefix}
399 Automake: ${AUTOMAKE}
403 ------------------------------------------------------------------------"