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([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"])])
65 AC_SUBST([SSL_CFLAGS])
69 AC_ARG_WITH([openssl], [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
72 if test "$openssl" != "no"; then
73 if test "$openssl" != "yes" -a "$openssl" != "default"; then
74 if test -x $openssl/bin/pkg-config; then
75 if $openssl/bin/pkg-config --exists openssl; then
76 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
77 SSL_LIBS="`$openssl/bin/pkg-config --libs openssl`"
78 sslver=`$openssl/bin/pkg-config --modversion openssl`
81 if test "$sslver" = "no"; then
82 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
83 SSL_LIBPATH="-L$openssl/lib"
86 if test "$pkgconfigpath" != "NONE"; then
87 if $pkgconfigpath --exists openssl; then
88 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
89 SSL_LIBS="`$pkgconfigpath --libs openssl`"
90 sslver=`$pkgconfigpath --modversion openssl`
93 if test "$sslver" = "no"; then
94 SSL_CFLAGS="-I/usr/include/openssl"
97 if test "$sslver" = "no"; then
99 xCPPFLAGS="$CPPFLAGS";
100 CPPFLAGS="$CPPFLAGS ${SSL_CFLAGS} ${SSL_LIBPATH}"
101 SSL_LIBS="${SSL_LIBPATH}"
102 AC_CHECK_LIB([crypto],[main])
103 if test "$ac_cv_lib_crypto_main" = "yes"; then
104 SSL_LIBS="${SSL_LIBS} -lcrypto"
106 AC_CHECK_LIB([ssl],[SSL_new])
107 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
108 AC_CHECK_HEADER([openssl/ssl.h],[sslver=yes])
109 SSL_LIBS="${SSL_LIBS} -lssl"
111 if test "$sslver" != "yes"; then
115 CPPFLAGS="$xCPPFLAGS"
117 AC_MSG_CHECKING([for SSL])
118 if test "$sslver" != "no"; then
119 AC_DEFINE([HAVE_OPENSSL_SSL_H],[1],[Define to 1 if OpenSSL is present])
120 AC_MSG_RESULT([$sslver])
123 AC_MSG_RESULT([None])
124 if test "$openssl" != "default"; then
125 AC_MSG_ERROR([OpenSSL development libraries missing])
131 AC_ARG_WITH([gnutls], [ --with-gnutls[=PREFIX] GNU TLS library in PREFIX], [gnutls=$withval])
132 if test "$gnutls" != "no" -a "$sslver" = "no"; then
134 if test "$gnutls" != "yes" -a "$gnutls" != "default"; then
135 if test -x $gnutls/bin/pkg-config; then
136 if $gnutls/bin/pkg-config --exists gnutls; then
137 SSL_CFLAGS=`$gnutls/bin/pkg-config --cflags gnutls`
138 SSL_LIBS="`$gnutls/bin/pkg-config --libs gnutls`"
139 gnutlsver=`$gnutls/bin/pkg-config --modversion gnutls`
143 if test "$pkgconfigpath" != "NONE"; then
144 if $pkgconfigpath --exists gnutls; then
145 SSL_CFLAGS=`$pkgconfigpath --cflags gnutls`
146 SSL_LIBS="`$pkgconfigpath --libs gnutls`"
147 gnutlsver=`$pkgconfigpath --modversion gnutls`
151 AC_MSG_CHECKING([for GNU TLS])
152 if test "$gnutlsver" != "no"; then
153 AC_DEFINE([HAVE_GNUTLS_H],[1],[Define to 1 if GNUTLS is present])
154 AC_MSG_RESULT([$gnutlsver])
157 AC_MSG_RESULT([None])
158 if test "$gnutls" != "default"; then
159 AC_MSG_ERROR([GNU TLS development libraries missing])
164 dnl ------ GNU Readline
165 READLINE_SHARED_LIBADD=""
166 AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
167 AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
170 AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
171 AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
172 if test "$ac_cv_lib_readline_readline" = "yes"; then
173 AC_CHECK_HEADERS([readline/readline.h readline/history.h])
175 LIBS="$LIBS $READLINE_LIBS"
178 #include <readline/readline.h>
180 rl_attempted_completion_over = 0;
181 ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER],1,[Define to 1 if rl_attempted_completion_over is defined]))
184 #include <readline/readline.h>
186 rl_completion_matches (0, 0);
187 ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES],1,[Define to 1 if rl_completion_matches is defined])])
191 AC_ARG_WITH([iconv],[ --with-iconv[=PREFIX] iconv library in PREFIX])
192 if test "$with_iconv" != "no"; then
193 AC_MSG_CHECKING([for iconv])
195 oldCPPFLAGS="${CPPFLAGS}"
196 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
197 LIBS="$LIBS -L${with_iconv}/lib"
198 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
203 iconv_t t = iconv_open("", "");
205 AC_DEFINE([HAVE_ICONV_H],1,[Define to 1 if iconv.h is present])
212 iconv_t t = iconv_open("", "");
214 AC_DEFINE([HAVE_ICONV_H],1)
218 CPPFLAGS="$oldCPPFLAGS"
223 dnl ------ various functions
224 AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
234 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
235 AC_CHECK_HEADERS([sys/poll.h])
238 dnl We check for socklen_t by making prototypes with the
239 dnl various types. First socklen_t, then size_t, finally int.
240 dnl If the prototype succeeds, we are probably safe.
241 dnl That works if accept is not preprocessor defined (such sa AIX)
242 AC_MSG_CHECKING([for socklen_t])
243 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
245 #include <sys/types.h>
246 #include <sys/socket.h>
257 extern int accept(int, struct sockaddr *, socklen_t *);
262 ],,[ac_cv_check_socklen_t=socklen_t],[
264 #include <sys/types.h>
265 #include <sys/socket.h>
276 extern int accept(int, struct sockaddr *, size_t t *);
281 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
284 AC_MSG_RESULT([$ac_cv_check_socklen_t])
285 AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t],[socklen_t type])
288 AC_ARG_ENABLE([tcpd],[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
289 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
291 oldCPPFLAGS=$CPPFLAGS
292 if test "$enable_tcpd" != "yes"; then
293 LIBS="$LIBS -L$enable_tcpd/lib"
294 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
296 AC_MSG_CHECKING([for working tcpd.h])
298 AC_TRY_LINK([#include <syslog.h>
300 int allow_severity = LOG_INFO;
301 int deny_severity = LOG_WARNING;],
302 [struct request_info request_info; int i;
303 i = hosts_access(&request_info);],
304 tcpd_ok=1, tcpd_ok=0)
306 if test "$tcpd_ok" = "0"; then
308 AC_MSG_ERROR([tcpd development libraries missing])
309 CPPFLAGS=$oldCPPFLAGS
313 AC_DEFINE([HAVE_TCPD_H],1,[Define to 1 if tcp wrap library is present])
316 AC_SUBST([TCPD_LIBS])
318 AC_SUBST([YAZ_CONFIG_CFLAGS])
320 dnl ------ POSIX Threads
322 AC_ARG_ENABLE([threads],[ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
323 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
326 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
327 dnl unfortunately empty thread lib spec is problematic because
328 dnl 'yaz-config --cflags' is not always passed to linker in
329 dnl applications using YAZ (such as Zebra).
330 if test "x$PTHREAD_LIBS" = "x"; then
332 for lib in -lpthread -lpthreads -lc_r; do
334 AC_TRY_LINK([ #include <pthread.h> ],
335 [ pthread_t id; pthread_join(id, 0); ],
336 [ PTHREAD_LIBS=$lib; break ]
341 LIBS="$LIBS $PTHREAD_LIBS"
342 AC_DEFINE(YAZ_POSIX_THREADS,1,[Define to 1 if POSIX threads is present])
343 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_POSIX_THREADS=1"
347 dnl ----- libXSLT/libEXLT/libXML2
348 AC_SUBST([XML2_CFLAGS])
352 AC_DEFINE(YAZ_HAVE_XML2,1,[Define to 1 if Libxml2 is present])
353 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
357 if test "$xml_enabled" = "true"; then
359 AC_DEFINE(YAZ_HAVE_XSLT,1,[Define to 1 if Libxslt is present])
360 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
363 AC_DEFINE(YAZ_HAVE_EXSLT,1,[Define to 1 if EXSLT is present])
364 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
368 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
370 if test "$XML2_LIBS"; then
371 LIBS="$XML2_LIBS $LIBS"
377 if test "$xml_enabled" = "true"; then
378 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
381 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
384 dnl ------ versioning
386 WIN_FILEVERSION=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { m = $4; printf("%d,%d,%d,%d", $1, $2, $3 == "" ? "0" : $3, $4 == "" ? "1" : $4);}'`
387 AC_SUBST([WIN_FILEVERSION])
388 VERSION_HEX=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { printf("%x", ($1 * 256 + $2) * 256 + $3);}'`
389 AC_SUBST([VERSION_HEX])
390 if test -d ${srcdir}/.git; then
391 VERSION_SHA1=`git show --pretty=format:%H|head -1`
393 VERSION_SHA1=`head -1 ${srcdir}/ChangeLog|awk '{print $2}'`
395 AC_SUBST([VERSION_SHA1])
418 include/yaz/yaz-version.h
420 sed s%echo_source=yes%echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
421 diff doc/local.ent doc/local0.ent >/dev/null 2>/dev/null \
422 || cp doc/local0.ent doc/local.ent
428 "------------------------------------------------------------------------
431 YAZ Package: ${PACKAGE}
432 YAZ Version: ${VERSION}
433 Bugreport: ${PACKAGE_BUGREPORT}
434 Source code location: ${srcdir}
435 C Preprocessor: ${CPP}
436 C Preprocessor flags: ${CPPFLAGS}
438 C Compiler flags: ${CFLAGS}
439 Linker flags: ${LDFLAGS}
441 Host System Type: ${host}
442 Install path: ${prefix}
443 Automake: ${AUTOMAKE}
447 ------------------------------------------------------------------------"
449 dnl mode:shell-script
450 dnl sh-indentation: 2
451 dnl sh-basic-offset: 4