1 dnl This file is part of the YAZ toolkit.
2 dnl Copyright (C) 1995-2008 Index Data
4 AC_INIT([yaz],[3.0.28],[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)
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 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"])])
63 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
66 if test "$openssl" != "no"; then
68 if test "$openssl" != "yes" -a "$openssl" != "default"; then
69 if test -x $openssl/bin/pkg-config; then
70 if $openssl/bin/pkg-config --exists openssl; then
71 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
72 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
73 sslver=`$openssl/bin/pkg-config --modversion openssl`
76 if test "$sslver" = "no"; then
77 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
78 SSL_LIBPATH="-L$openssl/lib"
81 if test "$pkgconfigpath" != "NONE"; then
82 if $pkgconfigpath --exists openssl; then
83 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
84 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
85 sslver=`$pkgconfigpath --modversion openssl`
88 if test "$sslver" = "no"; then
89 SSL_CFLAGS="-I/usr/include/openssl"
92 if test "$sslver" = "no"; then
94 xCPPFLAGS="$CPPFLAGS";
95 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
96 AC_CHECK_LIB(crypto, main)
97 AC_CHECK_LIB(ssl, SSL_new)
98 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
99 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
100 LIBS="$SSL_LIBPATH $LIBS"
102 if test "$sslver" != "yes"; then
105 CPPFLAGS="$xCPPFLAGS"
107 AC_MSG_CHECKING([for SSL])
108 if test "$sslver" != "no"; then
109 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
110 AC_MSG_RESULT([$sslver])
113 AC_MSG_RESULT([None])
114 if test "$openssl" != "default"; then
115 AC_MSG_ERROR([OpenSSL development libraries missing])
120 dnl ------ GNU Readline
121 READLINE_SHARED_LIBADD=""
122 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
123 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
126 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
127 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
128 if test "$ac_cv_lib_readline_readline" = "yes"; then
129 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
131 LIBS="$LIBS $READLINE_LIBS"
134 #include <readline/readline.h>
136 rl_attempted_completion_over = 0;
137 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
140 #include <readline/readline.h>
142 rl_completion_matches (0, 0);
143 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
147 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
148 if test "$with_iconv" != "no"; then
149 AC_MSG_CHECKING(for iconv)
151 oldCPPFLAGS="${CPPFLAGS}"
152 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
153 LIBS="$LIBS -L${with_iconv}/lib"
154 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
159 iconv_t t = iconv_open("", "");
161 AC_DEFINE(HAVE_ICONV_H)
168 iconv_t t = iconv_open("", "");
170 AC_DEFINE(HAVE_ICONV_H)
174 CPPFLAGS="$oldCPPFLAGS"
179 dnl ------ various functions
180 AC_CHECK_FUNCS(getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
190 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
191 AC_CHECK_HEADERS(sys/poll.h)
194 dnl We check for socklen_t by making prototypes with the
195 dnl various types. First socklen_t, then size_t, finally int.
196 dnl If the prototype succeeds, we are probably safe.
197 dnl That works if accept is not preprocessor defined (such sa AIX)
198 AC_MSG_CHECKING([for socklen_t])
199 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
201 #include <sys/types.h>
202 #include <sys/socket.h>
213 extern int accept(int, struct sockaddr *, socklen_t *);
218 ],,[ac_cv_check_socklen_t=socklen_t],[
220 #include <sys/types.h>
221 #include <sys/socket.h>
232 extern int accept(int, struct sockaddr *, size_t t *);
237 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
240 AC_MSG_RESULT($ac_cv_check_socklen_t)
241 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
242 AC_DEFINE(YAZ_USE_NEW_LOG)
245 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
246 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
248 oldCPPFLAGS=$CPPFLAGS
249 if test "$enable_tcpd" != "yes"; then
250 LIBS="$LIBS -L$enable_tcpd/lib"
251 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
253 AC_MSG_CHECKING(for working tcpd.h)
255 AC_TRY_LINK([#include <syslog.h>
257 int allow_severity = LOG_INFO;
258 int deny_severity = LOG_WARNING;],
259 [struct request_info request_info; int i;
260 i = hosts_access(&request_info);],
261 tcpd_ok=1, tcpd_ok=0)
262 if test "$tcpd_ok" = "0"; then
264 AC_MSG_ERROR([tcpd development libraries missing])
266 CPPFLAGS=$oldCPPFLAGS
269 AC_DEFINE(HAVE_TCPD_H)
273 AC_SUBST(YAZ_CONFIG_CFLAGS)
274 dnl ------ GNU threads
276 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
278 if test "$enable_pth" = "yes"; then
281 AC_CHECK_LIB(pth,main)
282 if test "$ac_cv_lib_pth_main" = "yes"; then
283 AC_CHECK_HEADERS(pth.h)
284 if test "$ac_cv_header_pth_h" = "yes"; then
286 CFLAGS="$CFLAGS -DYAZ_GNU_THREADS=1"
290 LIBS="$OLIBS $PTH_LIBS"
293 dnl ------ POSIX Threads
294 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
295 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
298 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
299 dnl unfortunately empty thread lib spec is problematic because
300 dnl 'yaz-config --cflags' is not always passed to linker in
301 dnl applications using YAZ (such as Zebra).
302 if test "x$PTHREAD_LIBS" = "x"; then
304 for lib in -lpthread -lpthreads -lc_r; do
306 AC_TRY_LINK([ #include <pthread.h> ],
307 [ pthread_t id; pthread_join(id, 0); ],
308 [ PTHREAD_LIBS=$lib; break ]
314 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DYAZ_POSIX_THREADS=1"
318 dnl ----- libXSLT/libEXLT/libXML2
319 AC_SUBST(XML2_CFLAGS)
324 AC_DEFINE(YAZ_HAVE_XML2)
325 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
332 AC_DEFINE(YAZ_HAVE_XSLT)
333 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
338 AC_DEFINE(YAZ_HAVE_EXSLT)
339 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
343 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
345 if test "$XML2_LIBS"; then
346 LIBS="$XML2_LIBS $LIBS"
352 if test "$xml_enabled" = "true"; then
353 ICU_CPPFLAGS="$ICU_CPPFLAGS -D YAZ_HAVE_ICU=1"
356 AC_MSG_WARN([ICU support disabled because XML support is unavailable])
360 dnl ------ Memory debugging
361 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
362 if test "$enable_memdebug" = "yes"; then
363 AC_DEFINE(TRACE_XMALLOC,2)
364 elif test "$enable_memdebug" = "no"; then
365 AC_DEFINE(TRACE_XMALLOC,0)
368 dnl ------ Using this for "in-source" yaz-config
369 AC_SUBST(YAZ_SRC_ROOT)
370 AC_SUBST(YAZ_BUILD_ROOT)
371 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
374 dnl ------ windows version files
375 WIN_FILEVERSION=`echo $PACKAGE_VERSION|tr . ,`.1
399 sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config
405 "------------------------------------------------------------------------
408 YAZ Package: ${PACKAGE}
409 YAZ Version: ${VERSION}
410 Bugreport: ${PACKAGE_BUGREPORT}
411 Source code location: ${srcdir}
412 C Preprocessor: ${CPP}
413 C Preprocessor flags: ${CPPFLAGS}
415 C Compiler flags: ${CFLAGS}
416 Linker flags: ${LDFLAGS}
418 Host System Type: ${host}
419 Install path: ${prefix}
420 Automake: ${AUTOMAKE}
424 ------------------------------------------------------------------------"
426 dnl mode:shell-script
427 dnl sh-indentation: 2
428 dnl sh-basic-offset: 4