1 dnl This file is part of the YAZ toolkit.
2 dnl Copyright (C) 1995-2011 Index Data
4 AC_INIT([yaz],[4.2.14],[yaz-help@indexdata.dk])
5 AC_CONFIG_HEADERS(include/config.h)
6 AC_CONFIG_SRCDIR([configure.ac])
7 AC_CONFIG_AUX_DIR([config])
8 AM_INIT_AUTOMAKE([1.9])
10 AC_SUBST([READLINE_LIBS])
11 AC_SUBST([YAZ_CONF_CFLAGS])
12 dnl ------ Checking programs
15 AC_CHECK_PROGS([YACC], 'bison -y')
16 test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
17 AC_CHECK_PROGS([TCLSH], [tclsh tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2], [tclsh])
20 AC_PATH_PROG([pkgconfigpath],[pkg-config],[NONE])
25 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],[],[],[])
26 AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
28 #include <sys/types.h>
31 #include <sys/socket.h>
37 #include <netinet/in.h>
41 if test "$ac_cv_header_stdc" = "no"; then
42 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
45 AC_CHECK_TYPES([long long])
49 AC_CHECK_FUNC([connect])
50 if test "$ac_cv_func_connect" = "no"; then
51 AC_CHECK_LIB([socket],[main], LIBS="$LIBS -lsocket", checkBoth=1)
53 if test "$checkBoth" = "1"; then
55 LIBS="$LIBS -lsocket -lnsl"
56 AC_CHECK_FUNC([accept], , [LIBS=$oldLibs])
58 AC_CHECK_FUNC([gethostbyname], ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
62 AC_SUBST([SSL_CFLAGS])
66 AC_ARG_WITH([openssl], [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
69 if test "$openssl" != "no"; then
70 if test "$openssl" != "yes" -a "$openssl" != "default"; then
71 if test -x $openssl/bin/pkg-config; then
72 if $openssl/bin/pkg-config --exists openssl; then
73 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
74 SSL_LIBS="`$openssl/bin/pkg-config --libs openssl`"
75 sslver=`$openssl/bin/pkg-config --modversion openssl`
78 if test "$sslver" = "no"; then
79 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
80 SSL_LIBPATH="-L$openssl/lib"
83 if test "$pkgconfigpath" != "NONE"; then
84 if $pkgconfigpath --exists openssl; then
85 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
86 SSL_LIBS="`$pkgconfigpath --libs openssl`"
87 sslver=`$pkgconfigpath --modversion openssl`
90 if test "$sslver" = "no"; then
91 SSL_CFLAGS="-I/usr/include/openssl"
94 if test "$sslver" = "no"; then
96 xCPPFLAGS="$CPPFLAGS";
97 CPPFLAGS="$CPPFLAGS ${SSL_CFLAGS} ${SSL_LIBPATH}"
98 SSL_LIBS="${SSL_LIBPATH}"
99 AC_CHECK_LIB([crypto],[main])
100 if test "$ac_cv_lib_crypto_main" = "yes"; then
101 SSL_LIBS="${SSL_LIBS} -lcrypto"
103 AC_CHECK_LIB([ssl],[SSL_new])
104 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
105 AC_CHECK_HEADER([openssl/ssl.h],[sslver=yes])
106 SSL_LIBS="${SSL_LIBS} -lssl"
108 if test "$sslver" != "yes"; then
112 CPPFLAGS="$xCPPFLAGS"
114 AC_MSG_CHECKING([for SSL])
115 if test "$sslver" != "no"; then
116 AC_DEFINE([HAVE_OPENSSL_SSL_H],[1],[Define to 1 if OpenSSL is present])
117 AC_MSG_RESULT([$sslver])
120 AC_MSG_RESULT([None])
121 if test "$openssl" != "default"; then
122 AC_MSG_ERROR([OpenSSL development libraries missing])
128 AC_ARG_WITH([gnutls], [ --with-gnutls[=PREFIX] GNU TLS library in PREFIX], [gnutls=$withval])
129 if test "$gnutls" != "no" -a "$sslver" = "no"; then
131 if test "$gnutls" != "yes" -a "$gnutls" != "default"; then
132 if test -x $gnutls/bin/pkg-config; then
133 if $gnutls/bin/pkg-config --exists gnutls; then
134 SSL_CFLAGS=`$gnutls/bin/pkg-config --cflags gnutls`
135 SSL_LIBS="`$gnutls/bin/pkg-config --libs gnutls`"
136 gnutlsver=`$gnutls/bin/pkg-config --modversion gnutls`
140 if test "$pkgconfigpath" != "NONE"; then
141 if $pkgconfigpath --exists gnutls; then
142 SSL_CFLAGS=`$pkgconfigpath --cflags gnutls`
143 SSL_LIBS="`$pkgconfigpath --libs gnutls`"
144 gnutlsver=`$pkgconfigpath --modversion gnutls`
148 AC_MSG_CHECKING([for GNU TLS])
149 if test "$gnutlsver" != "no"; then
150 AC_DEFINE([HAVE_GNUTLS_H],[1],[Define to 1 if GNUTLS is present])
151 AC_MSG_RESULT([$gnutlsver])
154 AC_MSG_RESULT([None])
155 if test "$gnutls" != "default"; then
156 AC_MSG_ERROR([GNU TLS development libraries missing])
161 dnl ------ GNU Readline
162 READLINE_SHARED_LIBADD=""
163 AC_CHECK_LIB([ncurses],[tgetent],[READLINE_SHARED_LIBADD="-lncurses"],
164 AC_CHECK_LIB([termcap],[tgetent],[READLINE_SHARED_LIBADD="-ltermcap"])
167 AC_CHECK_LIB([readline],[readline],[READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
168 AC_CHECK_LIB([history],[add_history],[READLINE_LIBS="$READLINE_LIBS -lhistory"])
169 if test "$ac_cv_lib_readline_readline" = "yes"; then
170 AC_CHECK_HEADERS([readline/readline.h readline/history.h])
172 LIBS="$LIBS $READLINE_LIBS"
175 #include <readline/readline.h>
177 rl_attempted_completion_over = 0;
178 ],AC_DEFINE([HAVE_READLINE_COMPLETION_OVER],1,[Define to 1 if rl_attempted_completion_over is defined]))
181 #include <readline/readline.h>
183 rl_completion_matches (0, 0);
184 ],[AC_DEFINE([HAVE_READLINE_RL_COMPLETION_MATCHES],1,[Define to 1 if rl_completion_matches is defined])])
188 AC_ARG_WITH([iconv],[ --with-iconv[=PREFIX] iconv library in PREFIX])
189 if test "$with_iconv" != "no"; then
190 AC_MSG_CHECKING([for iconv])
192 oldCPPFLAGS="${CPPFLAGS}"
193 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
194 LIBS="$LIBS -L${with_iconv}/lib"
195 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
200 iconv_t t = iconv_open("", "");
202 AC_DEFINE([HAVE_ICONV_H],1,[Define to 1 if iconv.h is present])
209 iconv_t t = iconv_open("", "");
211 AC_DEFINE([HAVE_ICONV_H],1)
215 CPPFLAGS="$oldCPPFLAGS"
220 dnl ------ various functions
221 AC_CHECK_FUNCS([getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64])
231 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
232 AC_CHECK_HEADERS([sys/poll.h])
235 dnl We check for socklen_t by making prototypes with the
236 dnl various types. First socklen_t, then size_t, finally int.
237 dnl If the prototype succeeds, we are probably safe.
238 dnl That works if accept is not preprocessor defined (such sa AIX)
239 AC_MSG_CHECKING([for socklen_t])
240 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
242 #include <sys/types.h>
243 #include <sys/socket.h>
254 extern int accept(int, struct sockaddr *, socklen_t *);
259 ],,[ac_cv_check_socklen_t=socklen_t],[
261 #include <sys/types.h>
262 #include <sys/socket.h>
273 extern int accept(int, struct sockaddr *, size_t t *);
278 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
281 AC_MSG_RESULT([$ac_cv_check_socklen_t])
282 AC_DEFINE_UNQUOTED([YAZ_SOCKLEN_T],[$ac_cv_check_socklen_t],[socklen_t type])
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)
303 if test "$tcpd_ok" = "0"; then
305 AC_MSG_ERROR([tcpd development libraries missing])
306 CPPFLAGS=$oldCPPFLAGS
310 AC_DEFINE([HAVE_TCPD_H],1,[Define to 1 if tcp wrap library is present])
313 AC_SUBST([TCPD_LIBS])
315 AC_SUBST([YAZ_CONFIG_CFLAGS])
317 dnl ------ POSIX Threads
319 AC_ARG_ENABLE([threads],[ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
320 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
323 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
324 dnl unfortunately empty thread lib spec is problematic because
325 dnl 'yaz-config --cflags' is not always passed to linker in
326 dnl applications using YAZ (such as Zebra).
327 if test "x$PTHREAD_LIBS" = "x"; then
329 for lib in -lpthread -lpthreads -lc_r; do
331 AC_TRY_LINK([ #include <pthread.h> ],
332 [ pthread_t id; pthread_join(id, 0); ],
333 [ PTHREAD_LIBS=$lib; break ]
338 LIBS="$LIBS $PTHREAD_LIBS"
339 AC_DEFINE(YAZ_POSIX_THREADS,1,[Define to 1 if POSIX threads is present])
340 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_POSIX_THREADS=1"
344 dnl ----- libXSLT/libEXLT/libXML2
345 AC_SUBST([XML2_CFLAGS])
349 AC_DEFINE(YAZ_HAVE_XML2,1,[Define to 1 if Libxml2 is present])
350 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
354 if test "$xml_enabled" = "true"; then
356 AC_DEFINE(YAZ_HAVE_XSLT,1,[Define to 1 if Libxslt is present])
357 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
360 AC_DEFINE(YAZ_HAVE_EXSLT,1,[Define to 1 if EXSLT is present])
361 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
365 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
367 if test "$XML2_LIBS"; then
368 LIBS="$XML2_LIBS $LIBS"
374 if test "$xml_enabled" = "true"; then
375 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
378 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
381 dnl ------ versioning
383 WIN_FILEVERSION=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { m = $4; printf("%d,%d,%d,%d", $1, $2, $3 == "" ? "0" : $3, $4 == "" ? "1" : $4);}'`
384 AC_SUBST([WIN_FILEVERSION])
385 VERSION_HEX=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { printf("%x", ($1 * 256 + $2) * 256 + $3);}'`
386 AC_SUBST([VERSION_HEX])
387 if test -d ${srcdir}/.git; then
388 VERSION_SHA1=`git show --pretty=format:%H|head -1`
390 VERSION_SHA1=`head -1 ${srcdir}/ChangeLog|awk '{print $2}'`
392 AC_SUBST([VERSION_SHA1])
415 include/yaz/yaz-version.h
417 sed s%echo_source=yes%echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
423 "------------------------------------------------------------------------
426 YAZ Package: ${PACKAGE}
427 YAZ Version: ${VERSION}
428 Bugreport: ${PACKAGE_BUGREPORT}
429 Source code location: ${srcdir}
430 C Preprocessor: ${CPP}
431 C Preprocessor flags: ${CPPFLAGS}
433 C Compiler flags: ${CFLAGS}
434 Linker flags: ${LDFLAGS}
436 Host System Type: ${host}
437 Install path: ${prefix}
438 Automake: ${AUTOMAKE}
442 ------------------------------------------------------------------------"
444 dnl mode:shell-script
445 dnl sh-indentation: 2
446 dnl sh-basic-offset: 4