1 dnl This file is part of the YAZ toolkit.
2 dnl Copyright (C) 1995-2008 Index Data
4 AC_INIT([yaz],[3.0.28],[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])
62 AC_ARG_WITH([openssl], [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
65 if test "$openssl" != "no"; then
67 if test "$openssl" != "yes" -a "$openssl" != "default"; then
68 if test -x $openssl/bin/pkg-config; then
69 if $openssl/bin/pkg-config --exists openssl; then
70 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
71 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
72 sslver=`$openssl/bin/pkg-config --modversion openssl`
75 if test "$sslver" = "no"; then
76 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
77 SSL_LIBPATH="-L$openssl/lib"
80 if test "$pkgconfigpath" != "NONE"; then
81 if $pkgconfigpath --exists openssl; then
82 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
83 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
84 sslver=`$pkgconfigpath --modversion openssl`
87 if test "$sslver" = "no"; then
88 SSL_CFLAGS="-I/usr/include/openssl"
91 if test "$sslver" = "no"; then
93 xCPPFLAGS="$CPPFLAGS";
94 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
95 AC_CHECK_LIB([crypto],[main])
96 AC_CHECK_LIB([ssl],[SSL_new])
97 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
98 AC_CHECK_HEADER([openssl/ssl.h],[sslver=yes])
99 LIBS="$SSL_LIBPATH $LIBS"
101 if test "$sslver" != "yes"; then
104 CPPFLAGS="$xCPPFLAGS"
106 AC_MSG_CHECKING([for SSL])
107 if test "$sslver" != "no"; then
108 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
109 AC_MSG_RESULT([$sslver])
112 AC_MSG_RESULT([None])
113 if test "$openssl" != "default"; then
114 AC_MSG_ERROR([OpenSSL development libraries missing])
119 dnl ------ GNU Readline
120 READLINE_SHARED_LIBADD=""
121 AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
122 AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
125 AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
126 AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
127 if test "$ac_cv_lib_readline_readline" = "yes"; then
128 AC_CHECK_HEADERS([readline/readline.h readline/history.h])
130 LIBS="$LIBS $READLINE_LIBS"
133 #include <readline/readline.h>
135 rl_attempted_completion_over = 0;
136 ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER]))
139 #include <readline/readline.h>
141 rl_completion_matches (0, 0);
142 ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES])])
146 AC_ARG_WITH([iconv],[ --with-iconv[=PREFIX] iconv library in PREFIX])
147 if test "$with_iconv" != "no"; then
148 AC_MSG_CHECKING([for iconv])
150 oldCPPFLAGS="${CPPFLAGS}"
151 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
152 LIBS="$LIBS -L${with_iconv}/lib"
153 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
158 iconv_t t = iconv_open("", "");
160 AC_DEFINE([HAVE_ICONV_H])
167 iconv_t t = iconv_open("", "");
169 AC_DEFINE([HAVE_ICONV_H])
173 CPPFLAGS="$oldCPPFLAGS"
178 dnl ------ various functions
179 AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
189 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
190 AC_CHECK_HEADERS([sys/poll.h])
193 dnl We check for socklen_t by making prototypes with the
194 dnl various types. First socklen_t, then size_t, finally int.
195 dnl If the prototype succeeds, we are probably safe.
196 dnl That works if accept is not preprocessor defined (such sa AIX)
197 AC_MSG_CHECKING([for socklen_t])
198 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
200 #include <sys/types.h>
201 #include <sys/socket.h>
212 extern int accept(int, struct sockaddr *, socklen_t *);
217 ],,[ac_cv_check_socklen_t=socklen_t],[
219 #include <sys/types.h>
220 #include <sys/socket.h>
231 extern int accept(int, struct sockaddr *, size_t t *);
236 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
239 AC_MSG_RESULT([$ac_cv_check_socklen_t])
240 AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t])
241 AC_DEFINE([YAZ_USE_NEW_LOG])
244 AC_ARG_ENABLE([tcpd],[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
245 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
247 oldCPPFLAGS=$CPPFLAGS
248 if test "$enable_tcpd" != "yes"; then
249 LIBS="$LIBS -L$enable_tcpd/lib"
250 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
252 AC_MSG_CHECKING([for working tcpd.h])
254 AC_TRY_LINK([#include <syslog.h>
256 int allow_severity = LOG_INFO;
257 int deny_severity = LOG_WARNING;],
258 [struct request_info request_info; int i;
259 i = hosts_access(&request_info);],
260 tcpd_ok=1, tcpd_ok=0)
261 if test "$tcpd_ok" = "0"; then
263 AC_MSG_ERROR([tcpd development libraries missing])
265 CPPFLAGS=$oldCPPFLAGS
268 AC_DEFINE([HAVE_TCPD_H])
272 AC_SUBST([YAZ_CONFIG_CFLAGS])
274 dnl ------ POSIX Threads
275 AC_ARG_ENABLE([threads],[ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
276 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
279 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
280 dnl unfortunately empty thread lib spec is problematic because
281 dnl 'yaz-config --cflags' is not always passed to linker in
282 dnl applications using YAZ (such as Zebra).
283 if test "x$PTHREAD_LIBS" = "x"; then
285 for lib in -lpthread -lpthreads -lc_r; do
287 AC_TRY_LINK([ #include <pthread.h> ],
288 [ pthread_t id; pthread_join(id, 0); ],
289 [ PTHREAD_LIBS=$lib; break ]
295 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DYAZ_POSIX_THREADS=1"
299 dnl ----- libXSLT/libEXLT/libXML2
300 AC_SUBST([XML2_CFLAGS])
304 AC_DEFINE(YAZ_HAVE_XML2)
305 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
310 AC_DEFINE(YAZ_HAVE_XSLT)
311 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
314 AC_DEFINE(YAZ_HAVE_EXSLT)
315 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
318 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
320 if test "$XML2_LIBS"; then
321 LIBS="$XML2_LIBS $LIBS"
327 if test "$xml_enabled" = "true"; then
328 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
331 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
335 dnl ------ Memory debugging
336 AC_ARG_ENABLE([memdebug],[ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
337 if test "$enable_memdebug" = "yes"; then
338 AC_DEFINE([TRACE_XMALLOC],[2])
339 elif test "$enable_memdebug" = "no"; then
340 AC_DEFINE([TRACE_XMALLOC],[0])
343 dnl ------ Using this for "in-source" yaz-config
344 AC_SUBST([YAZ_SRC_ROOT])
345 AC_SUBST([YAZ_BUILD_ROOT])
346 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
349 dnl ------ windows version files
350 WIN_FILEVERSION=`echo $PACKAGE_VERSION|tr . ,`.1
374 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
380 "------------------------------------------------------------------------
383 YAZ Package: ${PACKAGE}
384 YAZ Version: ${VERSION}
385 Bugreport: ${PACKAGE_BUGREPORT}
386 Source code location: ${srcdir}
387 C Preprocessor: ${CPP}
388 C Preprocessor flags: ${CPPFLAGS}
390 C Compiler flags: ${CFLAGS}
391 Linker flags: ${LDFLAGS}
393 Host System Type: ${host}
394 Install path: ${prefix}
395 Automake: ${AUTOMAKE}
399 ------------------------------------------------------------------------"
401 dnl mode:shell-script
402 dnl sh-indentation: 2
403 dnl sh-basic-offset: 4