1 dnl This file is part of the YAZ toolkit.
2 dnl Copyright (C) 1995-2008 Index Data
4 AC_INIT([yaz],[3.0.29],[yaz-help@indexdata.dk])
5 AC_CONFIG_SRCDIR([configure.ac])
6 AC_CONFIG_AUX_DIR([config])
7 AM_INIT_AUTOMAKE([1.9])
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])
16 AC_CHECK_PROGS([TCLSH], [tclsh tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2], [tclsh])
19 AC_PATH_PROG([pkgconfigpath],[pkg-config],[NONE])
24 AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h])
25 AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
27 #include <sys/types.h>
30 #include <sys/socket.h>
36 #include <netinet/in.h>
40 if test "$ac_cv_header_stdc" = "no"; then
41 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
44 AC_CHECK_TYPES([long long])
48 AC_CHECK_FUNC([connect])
49 if test "$ac_cv_func_connect" = "no"; then
50 AC_CHECK_LIB([socket],[main], LIBS="$LIBS -lsocket", checkBoth=1)
52 if test "$checkBoth" = "1"; then
54 LIBS="$LIBS -lsocket -lnsl"
55 AC_CHECK_FUNC([accept], , [LIBS=$oldLibs])
57 AC_CHECK_FUNC([gethostbyname], ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
60 AC_SUBST([SSL_CFLAGS])
63 AC_ARG_WITH([openssl], [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
66 if test "$openssl" != "no"; then
68 if test "$openssl" != "yes" -a "$openssl" != "default"; then
69 if test -x $openssl/bin/pkg-config; then
70 if $openssl/bin/pkg-config --exists openssl; then
71 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
72 SSL_LIBS="`$openssl/bin/pkg-config --libs openssl`"
73 sslver=`$openssl/bin/pkg-config --modversion openssl`
76 if test "$sslver" = "no"; then
77 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
78 SSL_LIBPATH="-L$openssl/lib"
81 if test "$pkgconfigpath" != "NONE"; then
82 if $pkgconfigpath --exists openssl; then
83 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
84 SSL_LIBS="`$pkgconfigpath --libs openssl`"
85 sslver=`$pkgconfigpath --modversion openssl`
88 if test "$sslver" = "no"; then
89 SSL_CFLAGS="-I/usr/include/openssl"
92 if test "$sslver" = "no"; then
94 xCPPFLAGS="$CPPFLAGS";
95 CPPFLAGS="$CPPFLAGS ${SSL_CFLAGS} ${SSL_LIBPATH}"
96 SSL_LIBS="${SSL_LIBPATH}"
97 AC_CHECK_LIB([crypto],[main])
98 if test "$ac_cv_lib_crypto_main" = "yes"; then
99 SSL_LIBS="${SSL_LIBS} -lcrypto"
101 AC_CHECK_LIB([ssl],[SSL_new])
102 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
103 AC_CHECK_HEADER([openssl/ssl.h],[sslver=yes])
104 SSL_LIBS="${SSL_LIBS} -lssl"
106 if test "$sslver" != "yes"; then
110 CPPFLAGS="$xCPPFLAGS"
112 AC_MSG_CHECKING([for SSL])
113 if test "$sslver" != "no"; then
114 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
115 AC_MSG_RESULT([$sslver])
118 AC_MSG_RESULT([None])
119 if test "$openssl" != "default"; then
120 AC_MSG_ERROR([OpenSSL development libraries missing])
125 dnl ------ GNU Readline
126 READLINE_SHARED_LIBADD=""
127 AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
128 AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
131 AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
132 AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
133 if test "$ac_cv_lib_readline_readline" = "yes"; then
134 AC_CHECK_HEADERS([readline/readline.h readline/history.h])
136 LIBS="$LIBS $READLINE_LIBS"
139 #include <readline/readline.h>
141 rl_attempted_completion_over = 0;
142 ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER]))
145 #include <readline/readline.h>
147 rl_completion_matches (0, 0);
148 ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES])])
152 AC_ARG_WITH([iconv],[ --with-iconv[=PREFIX] iconv library in PREFIX])
153 if test "$with_iconv" != "no"; then
154 AC_MSG_CHECKING([for iconv])
156 oldCPPFLAGS="${CPPFLAGS}"
157 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
158 LIBS="$LIBS -L${with_iconv}/lib"
159 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
164 iconv_t t = iconv_open("", "");
166 AC_DEFINE([HAVE_ICONV_H])
173 iconv_t t = iconv_open("", "");
175 AC_DEFINE([HAVE_ICONV_H])
179 CPPFLAGS="$oldCPPFLAGS"
184 dnl ------ various functions
185 AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
195 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
196 AC_CHECK_HEADERS([sys/poll.h])
199 dnl We check for socklen_t by making prototypes with the
200 dnl various types. First socklen_t, then size_t, finally int.
201 dnl If the prototype succeeds, we are probably safe.
202 dnl That works if accept is not preprocessor defined (such sa AIX)
203 AC_MSG_CHECKING([for socklen_t])
204 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
206 #include <sys/types.h>
207 #include <sys/socket.h>
218 extern int accept(int, struct sockaddr *, socklen_t *);
223 ],,[ac_cv_check_socklen_t=socklen_t],[
225 #include <sys/types.h>
226 #include <sys/socket.h>
237 extern int accept(int, struct sockaddr *, size_t t *);
242 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
245 AC_MSG_RESULT([$ac_cv_check_socklen_t])
246 AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t])
247 AC_DEFINE([YAZ_USE_NEW_LOG])
250 AC_ARG_ENABLE([tcpd],[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
251 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
253 oldCPPFLAGS=$CPPFLAGS
254 if test "$enable_tcpd" != "yes"; then
255 LIBS="$LIBS -L$enable_tcpd/lib"
256 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
258 AC_MSG_CHECKING([for working tcpd.h])
260 AC_TRY_LINK([#include <syslog.h>
262 int allow_severity = LOG_INFO;
263 int deny_severity = LOG_WARNING;],
264 [struct request_info request_info; int i;
265 i = hosts_access(&request_info);],
266 tcpd_ok=1, tcpd_ok=0)
267 if test "$tcpd_ok" = "0"; then
269 AC_MSG_ERROR([tcpd development libraries missing])
271 CPPFLAGS=$oldCPPFLAGS
274 AC_DEFINE([HAVE_TCPD_H])
278 AC_SUBST([YAZ_CONFIG_CFLAGS])
280 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 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
287 dnl unfortunately empty thread lib spec is problematic because
288 dnl 'yaz-config --cflags' is not always passed to linker in
289 dnl applications using YAZ (such as Zebra).
290 if test "x$PTHREAD_LIBS" = "x"; then
292 for lib in -lpthread -lpthreads -lc_r; do
294 AC_TRY_LINK([ #include <pthread.h> ],
295 [ pthread_t id; pthread_join(id, 0); ],
296 [ PTHREAD_LIBS=$lib; break ]
302 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DYAZ_POSIX_THREADS=1"
306 dnl ----- libXSLT/libEXLT/libXML2
307 AC_SUBST([XML2_CFLAGS])
311 AC_DEFINE(YAZ_HAVE_XML2)
312 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
317 AC_DEFINE(YAZ_HAVE_XSLT)
318 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
321 AC_DEFINE(YAZ_HAVE_EXSLT)
322 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
325 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
327 if test "$XML2_LIBS"; then
328 LIBS="$XML2_LIBS $LIBS"
334 if test "$xml_enabled" = "true"; then
335 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
338 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
342 dnl ------ Memory debugging
343 AC_ARG_ENABLE([memdebug],[ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
344 if test "$enable_memdebug" = "yes"; then
345 AC_DEFINE([TRACE_XMALLOC],[2])
346 elif test "$enable_memdebug" = "no"; then
347 AC_DEFINE([TRACE_XMALLOC],[0])
350 dnl ------ Using this for "in-source" yaz-config
351 AC_SUBST([YAZ_SRC_ROOT])
352 AC_SUBST([YAZ_BUILD_ROOT])
353 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
356 dnl ------ windows version files
357 WIN_FILEVERSION=`echo $PACKAGE_VERSION|tr . ,`.1
381 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
387 "------------------------------------------------------------------------
390 YAZ Package: ${PACKAGE}
391 YAZ Version: ${VERSION}
392 Bugreport: ${PACKAGE_BUGREPORT}
393 Source code location: ${srcdir}
394 C Preprocessor: ${CPP}
395 C Preprocessor flags: ${CPPFLAGS}
397 C Compiler flags: ${CFLAGS}
398 Linker flags: ${LDFLAGS}
400 Host System Type: ${host}
401 Install path: ${prefix}
402 Automake: ${AUTOMAKE}
406 ------------------------------------------------------------------------"
408 dnl mode:shell-script
409 dnl sh-indentation: 2
410 dnl sh-basic-offset: 4