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.9 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" -a ! -f src/cql.c && AC_MSG_ERROR([GNU Bison not found])
20 test -z "$YACC" && AC_MSG_WARN([GNU Bison not found])
21 AC_CHECK_PROGS([TCLSH], [tclsh tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2], [tclsh])
25 AC_PATH_PROG([pkgconfigpath],[pkg-config],[NONE])
31 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 execinfo.h],[],[],[])
32 AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
34 #include <sys/types.h>
37 #include <sys/socket.h>
43 #include <netinet/in.h>
47 if test "$ac_cv_header_stdc" = "no"; then
48 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
51 AC_CHECK_TYPES([long long])
55 AC_CHECK_FUNC([connect])
56 if test "$ac_cv_func_connect" = "no"; then
57 AC_CHECK_LIB([socket],[main], LIBS="$LIBS -lsocket", checkBoth=1)
59 if test "$checkBoth" = "1"; then
61 LIBS="$LIBS -lsocket -lnsl"
62 AC_CHECK_FUNC([accept], , [LIBS=$oldLibs])
64 AC_CHECK_FUNC([gethostbyname], ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
68 AC_SUBST([HIREDIS_LIBS])
69 AC_ARG_WITH([redis], [ --with-redis hiredis library], [hiredis=$withval])
70 if test "$hiredis" != "no" -a "$pkgconfigpath" != "NONE"; then
71 AC_CHECK_LIB([hiredis],[redisCommandArgv],[HIREDIS_LIBS=-lhiredis])
72 AC_MSG_CHECKING([for redis])
73 if $pkgconfigpath --cflags hiredis >/dev/null 2>&1 ; then
74 if $pkgconfigpath --atleast-version 0.10 hiredis; then
76 CFLAGS="$CFLAGS `$pkgconfigpath --cflags hiredis`"
77 HIREDIS_LIBS="`$pkgconfigpath --libs hiredis`"
78 AC_DEFINE([HAVE_HIREDIS],[1],[Define to 1 if hiredis is enabled])
80 AC_MSG_RESULT([no. Version 0.10 required])
81 if test "$hiredis" != "default"; then
82 AC_MSG_ERROR([hiredis libraries missing])
86 if test "$ac_cv_lib_hiredis_redisCommandArgv" = "yes"; then
87 AC_DEFINE([HAVE_HIREDIS],[1])
91 if test "$hiredis" != "default"; then
92 AC_MSG_ERROR([hiredis libraries missing])
99 AC_SUBST([MEMCACHED_LIBS])
100 AC_ARG_WITH([memcached], [ --with-memcached Memcached library], [memcached=$withval])
101 if test "$memcached" != "no" -a "$pkgconfigpath" != "NONE"; then
102 AC_MSG_CHECKING([for libmemcached])
103 if $pkgconfigpath --cflags libmemcached >/dev/null 2>&1 ; then
104 if $pkgconfigpath --atleast-version 0.40 libmemcached; then
106 CFLAGS="$CFLAGS `$pkgconfigpath --cflags libmemcached`"
107 MEMCACHED_LIBS="`$pkgconfigpath --libs libmemcached`"
108 AC_DEFINE([HAVE_LIBMEMCACHED],[1],[Define to 1 if memcached is enabled])
110 AC_MSG_RESULT([no. Version 0.40 required])
111 if test "$memcached" != "default"; then
112 AC_MSG_ERROR([libmemcached libraries missing])
117 if test "$memcached" != "default"; then
118 AC_MSG_ERROR([libmemcached libraries missing])
126 AC_SUBST([SSL_CFLAGS])
129 AC_ARG_WITH([gnutls], [ --with-gnutls[=PREFIX] GNU TLS library in PREFIX], [gnutls=$withval])
130 if test "$gnutls" != "no"; then
132 if test "$gnutls" != "yes" -a "$gnutls" != "default"; then
133 if test -x $gnutls/bin/pkg-config; then
134 if $gnutls/bin/pkg-config --exists gnutls; then
135 SSL_CFLAGS=`$gnutls/bin/pkg-config --cflags gnutls`
136 SSL_LIBS="`$gnutls/bin/pkg-config --libs gnutls`"
137 gnutlsver=`$gnutls/bin/pkg-config --modversion gnutls`
141 if test "$pkgconfigpath" != "NONE"; then
142 if $pkgconfigpath --exists gnutls; then
143 SSL_CFLAGS=`$pkgconfigpath --cflags gnutls`
144 SSL_LIBS="`$pkgconfigpath --libs gnutls`"
145 gnutlsver=`$pkgconfigpath --modversion gnutls`
149 AC_MSG_CHECKING([for GNU TLS])
150 if test "$gnutlsver" != "no"; then
151 AC_DEFINE([HAVE_GNUTLS_H],[1],[Define to 1 if GNUTLS is present])
152 AC_MSG_RESULT([$gnutlsver])
155 AC_MSG_RESULT([None])
156 if test "$gnutls" != "default"; then
157 AC_MSG_ERROR([GNU TLS development libraries missing])
162 dnl ------ GNU Readline
163 READLINE_SHARED_LIBADD=""
164 AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
165 AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
168 AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
169 AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
170 if test "$ac_cv_lib_readline_readline" = "yes"; then
171 AC_CHECK_HEADERS([readline/readline.h readline/history.h])
173 LIBS="$LIBS $READLINE_LIBS"
176 #include <readline/readline.h>
178 rl_attempted_completion_over = 0;
179 ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER],1,[Define to 1 if rl_attempted_completion_over is defined]))
182 #include <readline/readline.h>
184 rl_completion_matches (0, 0);
185 ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES],1,[Define to 1 if rl_completion_matches is defined])])
189 AC_ARG_WITH([iconv],[ --with-iconv[=PREFIX] iconv library in PREFIX])
190 if test "$with_iconv" != "no"; then
191 AC_MSG_CHECKING([for iconv])
193 oldCPPFLAGS="${CPPFLAGS}"
194 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
195 LIBS="$LIBS -L${with_iconv}/lib"
196 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
201 iconv_t t = iconv_open("", "");
203 AC_DEFINE([HAVE_ICONV_H],1,[Define to 1 if iconv.h is present])
210 iconv_t t = iconv_open("", "");
212 AC_DEFINE([HAVE_ICONV_H],1)
216 CPPFLAGS="$oldCPPFLAGS"
221 dnl ------ various functions
222 AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
232 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
233 AC_CHECK_HEADERS([sys/poll.h])
236 dnl We check for socklen_t by making prototypes with the
237 dnl various types. First socklen_t, then size_t, finally int.
238 dnl If the prototype succeeds, we are probably safe.
239 dnl That works if accept is not preprocessor defined (such sa AIX)
240 AC_MSG_CHECKING([for socklen_t])
241 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
243 #include <sys/types.h>
244 #include <sys/socket.h>
255 extern int accept(int, struct sockaddr *, socklen_t *);
260 ],,[ac_cv_check_socklen_t=socklen_t],[
262 #include <sys/types.h>
263 #include <sys/socket.h>
274 extern int accept(int, struct sockaddr *, size_t t *);
279 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
282 AC_MSG_RESULT([$ac_cv_check_socklen_t])
283 AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t],[socklen_t type])
286 AC_ARG_ENABLE([tcpd],[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
287 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
289 oldCPPFLAGS=$CPPFLAGS
290 if test "$enable_tcpd" != "yes"; then
291 LIBS="$LIBS -L$enable_tcpd/lib"
292 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
294 AC_MSG_CHECKING([for working tcpd.h])
296 AC_TRY_LINK([#include <syslog.h>
298 int allow_severity = LOG_INFO;
299 int deny_severity = LOG_WARNING;],
300 [struct request_info request_info; int i;
301 i = hosts_access(&request_info);],
302 tcpd_ok=1, tcpd_ok=0)
304 if test "$tcpd_ok" = "0"; then
306 AC_MSG_ERROR([tcpd development libraries missing])
307 CPPFLAGS=$oldCPPFLAGS
311 AC_DEFINE([HAVE_TCPD_H],1,[Define to 1 if tcp wrap library is present])
314 AC_SUBST([TCPD_LIBS])
316 AC_SUBST([YAZ_CONFIG_CFLAGS])
318 dnl ------ POSIX Threads
320 AC_ARG_ENABLE([threads],[ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
321 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
324 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
325 dnl unfortunately empty thread lib spec is problematic because
326 dnl 'yaz-config --cflags' is not always passed to linker in
327 dnl applications using YAZ (such as Zebra).
328 if test "x$PTHREAD_LIBS" = "x"; then
330 for lib in -lpthread -lpthreads -lc_r; do
332 AC_TRY_LINK([ #include <pthread.h> ],
333 [ pthread_t id; pthread_join(id, 0); ],
334 [ PTHREAD_LIBS=$lib; break ]
339 LIBS="$LIBS $PTHREAD_LIBS"
340 AC_DEFINE(YAZ_POSIX_THREADS,1,[Define to 1 if POSIX threads is present])
341 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_POSIX_THREADS=1"
345 dnl ----- libXSLT/libEXLT/libXML2
346 AC_SUBST([XML2_CFLAGS])
350 AC_DEFINE(YAZ_HAVE_XML2,1,[Define to 1 if Libxml2 is present])
351 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
355 if test "$xml_enabled" = "true"; then
357 AC_DEFINE(YAZ_HAVE_XSLT,1,[Define to 1 if Libxslt is present])
358 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
361 AC_DEFINE(YAZ_HAVE_EXSLT,1,[Define to 1 if EXSLT is present])
362 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
366 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
368 if test "$XML2_LIBS"; then
369 LIBS="$XML2_LIBS $LIBS"
375 if test "$xml_enabled" = "true"; then
376 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
379 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
382 dnl ------ versioning
384 WIN_FILEVERSION=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { m = $4; printf("%d,%d,%d,%d", $1, $2, $3 == "" ? "0" : $3, $4 == "" ? "1" : $4);}'`
385 AC_SUBST([WIN_FILEVERSION])
386 VERSION_HEX=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { printf("%x", ($1 * 256 + $2) * 256 + $3);}'`
387 AC_SUBST([VERSION_HEX])
388 if test -d ${srcdir}/.git; then
389 VERSION_SHA1=`git show --pretty=format:%H|head -1`
391 VERSION_SHA1=`head -1 ${srcdir}/ChangeLog|awk '{print $2}'`
393 AC_SUBST([VERSION_SHA1])
416 include/yaz/yaz-version.h
418 sed s%echo_source=yes%echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
419 diff doc/local.ent doc/local0.ent >/dev/null 2>/dev/null \
420 || cp doc/local0.ent doc/local.ent
426 "------------------------------------------------------------------------
429 YAZ Package: ${PACKAGE}
430 YAZ Version: ${VERSION}
431 Bugreport: ${PACKAGE_BUGREPORT}
432 Source code location: ${srcdir}
433 C Preprocessor: ${CPP}
434 C Preprocessor flags: ${CPPFLAGS}
436 C Compiler flags: ${CFLAGS}
437 Linker flags: ${LDFLAGS}
439 Host System Type: ${host}
440 Install path: ${prefix}
441 Automake: ${AUTOMAKE}
445 ------------------------------------------------------------------------"
447 dnl mode:shell-script
448 dnl sh-indentation: 2
449 dnl sh-basic-offset: 4