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"])])
61 AC_SUBST([SSL_CFLAGS])
65 AC_ARG_WITH([openssl], [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
68 if test "$openssl" != "no"; then
69 if test "$openssl" != "yes" -a "$openssl" != "default"; then
70 if test -x $openssl/bin/pkg-config; then
71 if $openssl/bin/pkg-config --exists openssl; then
72 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
73 SSL_LIBS="`$openssl/bin/pkg-config --libs openssl`"
74 sslver=`$openssl/bin/pkg-config --modversion openssl`
77 if test "$sslver" = "no"; then
78 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
79 SSL_LIBPATH="-L$openssl/lib"
82 if test "$pkgconfigpath" != "NONE"; then
83 if $pkgconfigpath --exists openssl; then
84 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
85 SSL_LIBS="`$pkgconfigpath --libs openssl`"
86 sslver=`$pkgconfigpath --modversion openssl`
89 if test "$sslver" = "no"; then
90 SSL_CFLAGS="-I/usr/include/openssl"
93 if test "$sslver" = "no"; then
95 xCPPFLAGS="$CPPFLAGS";
96 CPPFLAGS="$CPPFLAGS ${SSL_CFLAGS} ${SSL_LIBPATH}"
97 SSL_LIBS="${SSL_LIBPATH}"
98 AC_CHECK_LIB([crypto],[main])
99 if test "$ac_cv_lib_crypto_main" = "yes"; then
100 SSL_LIBS="${SSL_LIBS} -lcrypto"
102 AC_CHECK_LIB([ssl],[SSL_new])
103 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
104 AC_CHECK_HEADER([openssl/ssl.h],[sslver=yes])
105 SSL_LIBS="${SSL_LIBS} -lssl"
107 if test "$sslver" != "yes"; then
111 CPPFLAGS="$xCPPFLAGS"
113 AC_MSG_CHECKING([for SSL])
114 if test "$sslver" != "no"; then
115 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
116 AC_MSG_RESULT([$sslver])
119 AC_MSG_RESULT([None])
120 if test "$openssl" != "default"; then
121 AC_MSG_ERROR([OpenSSL development libraries missing])
127 AC_ARG_WITH([gnutls], [ --with-gnutls[=PREFIX] GNU TLS library in PREFIX], [gnutls=$withval])
128 if test "$gnutls" != "no" -a "$sslver" = "no"; then
130 if test "$gnutls" != "yes" -a "$gnutls" != "default"; then
131 if test -x $gnutls/bin/pkg-config; then
132 if $gnutls/bin/pkg-config --exists gnutls; then
133 SSL_CFLAGS=`$gnutls/bin/pkg-config --cflags gnutls`
134 SSL_LIBS="`$gnutls/bin/pkg-config --libs gnutls` -lgnutls-openssl"
135 gnutlsver=`$gnutls/bin/pkg-config --modversion gnutls`
139 if test "$pkgconfigpath" != "NONE"; then
140 if $pkgconfigpath --exists gnutls; then
141 SSL_CFLAGS=`$pkgconfigpath --cflags gnutls`
142 SSL_LIBS="`$pkgconfigpath --libs gnutls` -lgnutls-openssl"
143 gnutlsver=`$pkgconfigpath --modversion gnutls`
147 AC_MSG_CHECKING([for GNU TLS])
148 if test "$gnutlsver" != "no"; then
149 SSL_CFLAGS="-DHAVE_GNUTLS_H=1 $SSL_CFLAGS"
150 AC_MSG_RESULT([$gnutlsver])
153 AC_MSG_RESULT([None])
154 if test "$gnutls" != "default"; then
155 AC_MSG_ERROR([GNU TLS development libraries missing])
160 dnl ------ GNU Readline
161 READLINE_SHARED_LIBADD=""
162 AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
163 AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
166 AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
167 AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
168 if test "$ac_cv_lib_readline_readline" = "yes"; then
169 AC_CHECK_HEADERS([readline/readline.h readline/history.h])
171 LIBS="$LIBS $READLINE_LIBS"
174 #include <readline/readline.h>
176 rl_attempted_completion_over = 0;
177 ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER]))
180 #include <readline/readline.h>
182 rl_completion_matches (0, 0);
183 ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES])])
187 AC_ARG_WITH([iconv],[ --with-iconv[=PREFIX] iconv library in PREFIX])
188 if test "$with_iconv" != "no"; then
189 AC_MSG_CHECKING([for iconv])
191 oldCPPFLAGS="${CPPFLAGS}"
192 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
193 LIBS="$LIBS -L${with_iconv}/lib"
194 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
199 iconv_t t = iconv_open("", "");
201 AC_DEFINE([HAVE_ICONV_H])
208 iconv_t t = iconv_open("", "");
210 AC_DEFINE([HAVE_ICONV_H])
214 CPPFLAGS="$oldCPPFLAGS"
219 dnl ------ various functions
220 AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
230 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
231 AC_CHECK_HEADERS([sys/poll.h])
234 dnl We check for socklen_t by making prototypes with the
235 dnl various types. First socklen_t, then size_t, finally int.
236 dnl If the prototype succeeds, we are probably safe.
237 dnl That works if accept is not preprocessor defined (such sa AIX)
238 AC_MSG_CHECKING([for socklen_t])
239 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
241 #include <sys/types.h>
242 #include <sys/socket.h>
253 extern int accept(int, struct sockaddr *, socklen_t *);
258 ],,[ac_cv_check_socklen_t=socklen_t],[
260 #include <sys/types.h>
261 #include <sys/socket.h>
272 extern int accept(int, struct sockaddr *, size_t t *);
277 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
280 AC_MSG_RESULT([$ac_cv_check_socklen_t])
281 AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t])
282 AC_DEFINE([YAZ_USE_NEW_LOG])
285 AC_ARG_ENABLE([tcpd],[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
286 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
288 oldCPPFLAGS=$CPPFLAGS
289 if test "$enable_tcpd" != "yes"; then
290 LIBS="$LIBS -L$enable_tcpd/lib"
291 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
293 AC_MSG_CHECKING([for working tcpd.h])
295 AC_TRY_LINK([#include <syslog.h>
297 int allow_severity = LOG_INFO;
298 int deny_severity = LOG_WARNING;],
299 [struct request_info request_info; int i;
300 i = hosts_access(&request_info);],
301 tcpd_ok=1, tcpd_ok=0)
302 if test "$tcpd_ok" = "0"; then
304 AC_MSG_ERROR([tcpd development libraries missing])
306 CPPFLAGS=$oldCPPFLAGS
309 AC_DEFINE([HAVE_TCPD_H])
313 AC_SUBST([YAZ_CONFIG_CFLAGS])
315 dnl ------ POSIX Threads
317 AC_ARG_ENABLE([threads],[ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
318 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
321 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
322 dnl unfortunately empty thread lib spec is problematic because
323 dnl 'yaz-config --cflags' is not always passed to linker in
324 dnl applications using YAZ (such as Zebra).
325 if test "x$PTHREAD_LIBS" = "x"; then
327 for lib in -lpthread -lpthreads -lc_r; do
329 AC_TRY_LINK([ #include <pthread.h> ],
330 [ pthread_t id; pthread_join(id, 0); ],
331 [ PTHREAD_LIBS=$lib; break ]
337 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DYAZ_POSIX_THREADS=1"
341 dnl ----- libXSLT/libEXLT/libXML2
342 AC_SUBST([XML2_CFLAGS])
346 AC_DEFINE(YAZ_HAVE_XML2)
347 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
352 AC_DEFINE(YAZ_HAVE_XSLT)
353 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
356 AC_DEFINE(YAZ_HAVE_EXSLT)
357 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
360 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
362 if test "$XML2_LIBS"; then
363 LIBS="$XML2_LIBS $LIBS"
369 if test "$xml_enabled" = "true"; then
370 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
373 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
377 dnl ------ Memory debugging
378 AC_ARG_ENABLE([memdebug],[ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
379 if test "$enable_memdebug" = "yes"; then
380 AC_DEFINE([TRACE_XMALLOC],[2])
381 elif test "$enable_memdebug" = "no"; then
382 AC_DEFINE([TRACE_XMALLOC],[0])
385 dnl ------ Using this for "in-source" yaz-config
386 AC_SUBST([YAZ_SRC_ROOT])
387 AC_SUBST([YAZ_BUILD_ROOT])
388 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
391 dnl ------ windows version files
392 WIN_FILEVERSION=`echo $PACKAGE_VERSION|tr . ,`.1
416 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
422 "------------------------------------------------------------------------
425 YAZ Package: ${PACKAGE}
426 YAZ Version: ${VERSION}
427 Bugreport: ${PACKAGE_BUGREPORT}
428 Source code location: ${srcdir}
429 C Preprocessor: ${CPP}
430 C Preprocessor flags: ${CPPFLAGS}
432 C Compiler flags: ${CFLAGS}
433 Linker flags: ${LDFLAGS}
435 Host System Type: ${host}
436 Install path: ${prefix}
437 Automake: ${AUTOMAKE}
441 ------------------------------------------------------------------------"
443 dnl mode:shell-script
444 dnl sh-indentation: 2
445 dnl sh-basic-offset: 4