1 dnl YAZ Toolkit, Index Data 1995-2007
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.ac,v 1.86 2007-06-29 08:03:02 adam Exp $
5 AC_INIT([yaz],[3.0.9],[yaz-help@indexdata.dk])
6 AC_CONFIG_SRCDIR(configure.ac)
7 AC_CONFIG_AUX_DIR([config])
8 AM_INIT_AUTOMAKE([1.8])
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, tclsh8.5 tclsh8.4 tclsh8.3 tclsh8.2, tclsh)
20 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
26 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])
27 AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[
29 #include <sys/types.h>
32 #include <sys/socket.h>
38 #include <netinet/in.h>
42 if test "$ac_cv_header_stdc" = "no"; then
43 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
46 AC_CHECK_TYPES([long long])
50 AC_CHECK_FUNC(connect)
51 if test "$ac_cv_func_connect" = "no"; then
52 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
54 if test "$checkBoth" = "1"; then
56 LIBS="$LIBS -lsocket -lnsl"
57 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
59 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
64 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
67 if test "$openssl" != "no"; then
69 if test "$openssl" != "yes" -a "$openssl" != "default"; then
70 if test -x $openssl/bin/pkg-config; then
71 if $openssl/bin/pkg-config --exists openssl; then
72 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
73 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
74 sslver=`$openssl/bin/pkg-config --modversion openssl`
77 if test "$sslver" = "no"; then
78 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
79 SSL_LIBPATH="-L$openssl/lib"
82 if test "$pkgconfigpath" != "NONE"; then
83 if $pkgconfigpath --exists openssl; then
84 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
85 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
86 sslver=`$pkgconfigpath --modversion openssl`
89 if test "$sslver" = "no"; then
90 SSL_CFLAGS="-I/usr/include/openssl"
93 if test "$sslver" = "no"; then
95 xCPPFLAGS="$CPPFLAGS";
96 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
97 AC_CHECK_LIB(crypto, main)
98 AC_CHECK_LIB(ssl, SSL_new)
99 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
100 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
101 LIBS="$SSL_LIBPATH $LIBS"
103 if test "$sslver" != "yes"; then
106 CPPFLAGS="$xCPPFLAGS"
108 AC_MSG_CHECKING([for SSL])
109 if test "$sslver" != "no"; then
110 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
111 AC_MSG_RESULT([$sslver])
114 AC_MSG_RESULT([None])
115 if test "$openssl" != "default"; then
116 AC_MSG_ERROR([OpenSSL development libraries missing])
121 dnl ------ GNU Readline
122 READLINE_SHARED_LIBADD=""
123 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
124 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
127 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
128 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
129 if test "$ac_cv_lib_readline_readline" = "yes"; then
130 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
132 LIBS="$LIBS $READLINE_LIBS"
135 #include <readline/readline.h>
137 rl_attempted_completion_over = 0;
138 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
141 #include <readline/readline.h>
143 rl_completion_matches (0, 0);
144 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
148 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
149 if test "$with_iconv" != "no"; then
150 AC_MSG_CHECKING(for iconv)
152 oldCPPFLAGS="${CPPFLAGS}"
153 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
154 LIBS="$LIBS -L${with_iconv}/lib"
155 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
160 iconv_t t = iconv_open("", "");
162 AC_DEFINE(HAVE_ICONV_H)
169 iconv_t t = iconv_open("", "");
171 AC_DEFINE(HAVE_ICONV_H)
175 CPPFLAGS="$oldCPPFLAGS"
180 dnl ------ libpcap / ziffy
184 AC_SUBST(PCAP_CFLAGS)
186 AC_ARG_WITH(pcap, [ --with-pcap[=DIR] libpcap root dir located in (dir)], [PCAP_DIR="$withval"],[PCAP_DIR=default])
188 AC_MSG_CHECKING([for libpcap (required for ziffy)])
189 if test "${PCAP_DIR}" != "no"; then
190 if test "${ac_cv_header_netinet_if_ether_h}" = "no"; then
192 elif test "${PCAP_DIR}" != "yes" && test "${PCAP_DIR}" != "default"; then
193 if test -r $PCAP_DIR/libpcap.a && test -r $PCAP_DIR/pcap.h; then
195 PCAP_LIBS="${LIBS} -L$PCAP_DIR -lpcap"
196 PCAP_CFLAGS="${INCS} -I$PCAP_DIR"
199 elif test -d /usr/local &&
200 test -r /usr/local/lib/libpcap.a &&
201 test -r /usr/local/include/pcap.h; then
202 PCAP_DIR="/usr/local"
203 PCAP_LIBS="${LIBS} -L$PCAP_DIR/lib -lpcap"
204 PCAP_CFLAGS="${INCS} -I$PCAP_DIR/include"
207 test -r /usr/lib/libpcap.a &&
208 test -r /usr/include/pcap.h; then
210 PCAP_LIBS="${LIBS} -lpcap"
214 if test -z "$ZIFFY_PROG"; then
215 AC_MSG_RESULT([not found. ziffy disabled])
216 if test "${PCAP_DIR}" != "default" && test "${PCAP_DIR}" != "no"; then
217 AC_MSG_ERROR([libpcap missing])
220 AC_MSG_RESULT([found in $PCAP_DIR])
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)
286 AC_DEFINE(YAZ_USE_NEW_LOG)
289 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
290 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
292 oldCPPFLAGS=$CPPFLAGS
293 if test "$enable_tcpd" != "yes"; then
294 LIBS="$LIBS -L$enable_tcpd/lib"
295 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
297 AC_MSG_CHECKING(for working tcpd.h)
299 AC_TRY_LINK([#include <syslog.h>
301 int allow_severity = LOG_INFO;
302 int deny_severity = LOG_WARNING;],
303 [struct request_info request_info; int i;
304 i = hosts_access(&request_info);],
305 tcpd_ok=1, tcpd_ok=0)
306 if test "$tcpd_ok" = "0"; then
308 AC_MSG_ERROR([tcpd development libraries missing])
310 CPPFLAGS=$oldCPPFLAGS
313 AC_DEFINE(HAVE_TCPD_H)
317 AC_SUBST(YAZ_CONFIG_CFLAGS)
321 dnl ------ GNU threads
322 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
324 if test "$enable_pth" = "yes"; then
327 AC_CHECK_LIB(pth,main)
328 if test "$ac_cv_lib_pth_main" = "yes"; then
329 AC_CHECK_HEADERS(pth.h)
330 if test "$ac_cv_header_pth_h" = "yes"; then
332 CFLAGS="$CFLAGS -DYAZ_GNU_THREADS=1"
336 LIBS="$OLIBS $PTH_LIBS"
339 dnl ------ POSIX Threads
340 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
341 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
344 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
345 dnl unfortunately empty thread lib spec is problematic because
346 dnl 'yaz-config --cflags' is not always passed to linker in
347 dnl applications using YAZ (such as Zebra).
348 if test "x$PTHREAD_LIBS" = "x"; then
350 for lib in -lpthread -lpthreads -lc_r; do
352 AC_TRY_LINK([ #include <pthread.h> ],
353 [ pthread_t id; pthread_join(id, 0); ],
354 [ PTHREAD_LIBS=$lib; break ]
360 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DYAZ_POSIX_THREADS=1"
364 dnl ----- libXSLT/libEXLT/libXML2
365 AC_SUBST(XML2_CFLAGS)
369 AC_DEFINE(YAZ_HAVE_XML2)
370 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
376 AC_DEFINE(YAZ_HAVE_XSLT)
377 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
382 AC_DEFINE(YAZ_HAVE_EXSLT)
383 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
387 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
389 if test "$XML2_LIBS"; then
390 LIBS="$XML2_LIBS $LIBS"
394 dnl ------ Memory debugging
395 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
396 if test "$enable_memdebug" = "yes"; then
397 AC_DEFINE(TRACE_XMALLOC,2)
398 elif test "$enable_memdebug" = "no"; then
399 AC_DEFINE(TRACE_XMALLOC,0)
402 dnl ------ Using this for "in-source" yaz-config
403 AC_SUBST(YAZ_SRC_ROOT)
404 AC_SUBST(YAZ_BUILD_ROOT)
405 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
430 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])
434 "------------------------------------------------------------------------
437 YAZ Package: ${PACKAGE}
438 YAZ Version: ${VERSION}
439 Bugreport: ${PACKAGE_BUGREPORT}
440 Source code location: ${srcdir}
441 C Preprocessor: ${CPP}
442 C Preprocessor flags: ${CPPFLAGS}
444 C Compiler flags: ${CFLAGS}
445 Linker flags: ${LDFLAGS}
447 Host System Type: ${host}
448 Install path: ${prefix}
449 Automake: ${AUTOMAKE}
453 ------------------------------------------------------------------------"
455 dnl mode:shell-script
456 dnl sh-indentation: 2
457 dnl sh-basic-offset: 4