1 dnl This file is part of the YAZ toolkit.
2 dnl Copyright (C) Index Data
3 dnl See the file LICENSE for details.
6 m4_esyscmd([. ./IDMETA; echo $VERSION|tr -d '\n']),
7 [yaz-help@indexdata.dk])
8 AC_CONFIG_HEADERS(include/config.h)
9 AC_CONFIG_SRCDIR([configure.ac])
10 AC_CONFIG_AUX_DIR([config])
11 AM_INIT_AUTOMAKE([1.11.1 subdir-objects])
13 AC_SUBST([READLINE_LIBS])
14 AC_SUBST([YAZ_CONF_CFLAGS])
15 dnl ------ Checking programs
18 AC_CHECK_PROGS([YACC], 'bison -y')
19 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
20 AC_CHECK_PROGS([TCLSH], [tclsh tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2], [tclsh])
23 AC_PATH_PROG([pkgconfigpath],[pkg-config],[NONE])
28 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 sys/prctl.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h],[],[],[])
29 AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
31 #include <sys/types.h>
34 #include <sys/socket.h>
40 #include <netinet/in.h>
44 if test "$ac_cv_header_stdc" = "no"; then
45 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
48 AC_CHECK_TYPES([long long])
52 AC_CHECK_FUNC([connect])
53 if test "$ac_cv_func_connect" = "no"; then
54 AC_CHECK_LIB([socket],[main], LIBS="$LIBS -lsocket", checkBoth=1)
56 if test "$checkBoth" = "1"; then
58 LIBS="$LIBS -lsocket -lnsl"
59 AC_CHECK_FUNC([accept], , [LIBS=$oldLibs])
61 AC_CHECK_FUNC([gethostbyname], ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
63 AC_SUBST([GCRYPT_LIBS])
65 AC_ARG_WITH(libgcrypt, [ --with-libgcrypt=DIR use libgcrypt-config in DIR],[libgcryptpath=$withval])
66 if test "$libgcryptpath" != "no"; then
67 if test "$libgcryptpath" = "NONE"; then
68 AC_PATH_PROG([libgcrypt],[libgcrypt-config],[NONE])
69 elif test -x $libgcryptpath/libgcrypt-config; then
70 libgcrypt=$libgcryptpath/libgcrypt-config
72 libgcrypt=$libgcryptpath
74 AC_MSG_CHECKING([for libgcrypt])
75 if "$libgcrypt" --version >/dev/null 2>&1; then
76 libgcryptversion=`$libgcrypt --version`
77 libgcryptversion2=`echo "$libgcryptversion" | awk 'BEGIN { FS = "."; } { printf "%d", [$]1 * 1000 + [$]2;}'`
78 AC_MSG_RESULT([$libgcryptversion])
79 if test $libgcryptversion2 -ge 1002; then
80 GCRYPT_LIBS="`$libgcrypt --libs`"
81 CFLAGS="$CFLAGS `$libgcrypt --cflags`"
82 AC_DEFINE([HAVE_GCRYPT_H],[1],[Define to 1 if libgcrypt is present])
84 if test "$libgcryptpath" = "NONE"; then
85 AC_MSG_WARN([Only libgcrypt version 1.2 and later supported])
87 AC_MSG_ERROR([Only libgcrypt version 1.2 and later supported])
97 AC_SUBST([MEMCACHED_LIBS])
98 AC_ARG_WITH([memcached], [ --with-memcached Memcached library], [memcached=$withval])
99 if test "$memcached" != "no" -a -n "$libgcryptversion"; then
100 AC_CHECK_LIB([memcached],[memcached_get], [MEMCACHED_LIBS="-lmemcached"])
101 if test "$ac_cv_lib_memcached_memcached_get" = "yes"; then
102 AC_CHECK_HEADERS([libmemcached/memcached.h])
103 if test "$ac_cv_header_libmemcached_memcached_h" = "yes"; then
104 AC_CHECK_LIB([memcached],[memcached], [
105 AC_DEFINE([HAVE_MEMCACHED_FUNC],[1],[Define to 1 if memcached function is defined])])
108 #include <libmemcached/memcached.h>
110 memcached_return_t x;
111 ],[AC_DEFINE([HAVE_MEMCACHED_RETURN_T],[1],[Define to 1 if memcached_return_t is defined])]
117 AC_SUBST([SSL_CFLAGS])
120 AC_ARG_WITH([gnutls], [ --with-gnutls[=PREFIX] GNU TLS library in PREFIX], [gnutls=$withval])
121 if test "$gnutls" != "no"; then
123 if test "$gnutls" != "yes" -a "$gnutls" != "default"; then
124 if test -x $gnutls/bin/pkg-config; then
125 if $gnutls/bin/pkg-config --exists gnutls; then
126 SSL_CFLAGS=`$gnutls/bin/pkg-config --cflags gnutls`
127 SSL_LIBS="`$gnutls/bin/pkg-config --libs gnutls`"
128 gnutlsver=`$gnutls/bin/pkg-config --modversion gnutls`
132 if test "$pkgconfigpath" != "NONE"; then
133 if $pkgconfigpath --exists gnutls; then
134 SSL_CFLAGS=`$pkgconfigpath --cflags gnutls`
135 SSL_LIBS="`$pkgconfigpath --libs gnutls`"
136 gnutlsver=`$pkgconfigpath --modversion gnutls`
140 AC_MSG_CHECKING([for GNU TLS])
141 if test "$gnutlsver" != "no"; then
142 AC_DEFINE([HAVE_GNUTLS_H],[1],[Define to 1 if GNUTLS is present])
143 AC_MSG_RESULT([$gnutlsver])
146 AC_MSG_RESULT([None])
147 if test "$gnutls" != "default"; then
148 AC_MSG_ERROR([GNU TLS development libraries missing])
153 dnl ------ GNU Readline
154 READLINE_SHARED_LIBADD=""
155 AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
156 AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
159 AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
160 AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
161 if test "$ac_cv_lib_readline_readline" = "yes"; then
162 AC_CHECK_HEADERS([readline/readline.h readline/history.h])
164 LIBS="$LIBS $READLINE_LIBS"
167 #include <readline/readline.h>
169 rl_attempted_completion_over = 0;
170 ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER],1,[Define to 1 if rl_attempted_completion_over is defined]))
173 #include <readline/readline.h>
175 rl_completion_matches (0, 0);
176 ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES],1,[Define to 1 if rl_completion_matches is defined])])
180 AC_ARG_WITH([iconv],[ --with-iconv[=PREFIX] iconv library in PREFIX])
181 if test "$with_iconv" != "no"; then
182 AC_MSG_CHECKING([for iconv])
184 oldCPPFLAGS="${CPPFLAGS}"
185 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
186 LIBS="$LIBS -L${with_iconv}/lib"
187 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
192 iconv_t t = iconv_open("", "");
194 AC_DEFINE([HAVE_ICONV_H],1,[Define to 1 if iconv.h is present])
201 iconv_t t = iconv_open("", "");
203 AC_DEFINE([HAVE_ICONV_H],1)
207 CPPFLAGS="$oldCPPFLAGS"
212 dnl ------ various functions
213 AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
223 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
224 AC_CHECK_HEADERS([sys/poll.h])
227 dnl We check for socklen_t by making prototypes with the
228 dnl various types. First socklen_t, then size_t, finally int.
229 dnl If the prototype succeeds, we are probably safe.
230 dnl That works if accept is not preprocessor defined (such sa AIX)
231 AC_MSG_CHECKING([for socklen_t])
232 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
234 #include <sys/types.h>
235 #include <sys/socket.h>
246 extern int accept(int, struct sockaddr *, socklen_t *);
251 ],,[ac_cv_check_socklen_t=socklen_t],[
253 #include <sys/types.h>
254 #include <sys/socket.h>
265 extern int accept(int, struct sockaddr *, size_t t *);
270 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
273 AC_MSG_RESULT([$ac_cv_check_socklen_t])
274 AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t],[socklen_t type])
277 AC_ARG_ENABLE([tcpd],[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
278 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
280 oldCPPFLAGS=$CPPFLAGS
281 if test "$enable_tcpd" != "yes"; then
282 LIBS="$LIBS -L$enable_tcpd/lib"
283 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
285 AC_MSG_CHECKING([for working tcpd.h])
287 AC_TRY_LINK([#include <syslog.h>
289 int allow_severity = LOG_INFO;
290 int deny_severity = LOG_WARNING;],
291 [struct request_info request_info; int i;
292 i = hosts_access(&request_info);],
293 tcpd_ok=1, tcpd_ok=0)
295 if test "$tcpd_ok" = "0"; then
297 AC_MSG_ERROR([tcpd development libraries missing])
298 CPPFLAGS=$oldCPPFLAGS
302 AC_DEFINE([HAVE_TCPD_H],1,[Define to 1 if tcp wrap library is present])
305 AC_SUBST([TCPD_LIBS])
307 AC_SUBST([YAZ_CONFIG_CFLAGS])
309 dnl ------ POSIX Threads
311 AC_ARG_ENABLE([threads],[ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
312 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
315 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
316 dnl unfortunately empty thread lib spec is problematic because
317 dnl 'yaz-config --cflags' is not always passed to linker in
318 dnl applications using YAZ (such as Zebra).
319 if test "x$PTHREAD_LIBS" = "x"; then
321 for lib in -lpthread -lpthreads -lc_r; do
323 AC_TRY_LINK([ #include <pthread.h> ],
324 [ pthread_t id; pthread_join(id, 0); ],
325 [ PTHREAD_LIBS=$lib; break ]
330 LIBS="$LIBS $PTHREAD_LIBS"
331 AC_DEFINE(YAZ_POSIX_THREADS,1,[Define to 1 if POSIX threads is present])
332 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_POSIX_THREADS=1"
336 dnl ----- libXSLT/libEXLT/libXML2
337 AC_SUBST([XML2_CFLAGS])
341 AC_DEFINE(YAZ_HAVE_XML2,1,[Define to 1 if Libxml2 is present])
342 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
346 if test "$xml_enabled" = "true"; then
348 AC_DEFINE(YAZ_HAVE_XSLT,1,[Define to 1 if Libxslt is present])
349 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
352 AC_DEFINE(YAZ_HAVE_EXSLT,1,[Define to 1 if EXSLT is present])
353 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
357 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
359 if test "$XML2_LIBS"; then
360 LIBS="$XML2_LIBS $LIBS"
366 if test "$xml_enabled" = "true"; then
367 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
370 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
373 dnl ------ versioning
375 WIN_FILEVERSION=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { m = $4; printf("%d,%d,%d,%d", $1, $2, $3 == "" ? "0" : $3, $4 == "" ? "1" : $4);}'`
376 AC_SUBST([WIN_FILEVERSION])
377 VERSION_HEX=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { printf("%x", ($1 * 256 + $2) * 256 + $3);}'`
378 AC_SUBST([VERSION_HEX])
379 if test -d ${srcdir}/.git; then
380 VERSION_SHA1=`git show --pretty=format:%H|head -1`
382 VERSION_SHA1=`head -1 ${srcdir}/ChangeLog|awk '{print $2}'`
384 AC_SUBST([VERSION_SHA1])
407 include/yaz/yaz-version.h
409 sed s%echo_source=yes%echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
410 diff doc/local.ent doc/local0.ent >/dev/null 2>/dev/null \
411 || cp doc/local0.ent doc/local.ent
417 "------------------------------------------------------------------------
420 YAZ Package: ${PACKAGE}
421 YAZ Version: ${VERSION}
422 Bugreport: ${PACKAGE_BUGREPORT}
423 Source code location: ${srcdir}
424 C Preprocessor: ${CPP}
425 C Preprocessor flags: ${CPPFLAGS}
427 C Compiler flags: ${CFLAGS}
428 Linker flags: ${LDFLAGS}
430 Host System Type: ${host}
431 Install path: ${prefix}
432 Automake: ${AUTOMAKE}
436 ------------------------------------------------------------------------"
438 dnl mode:shell-script
439 dnl sh-indentation: 2
440 dnl sh-basic-offset: 4