1 dnl YAZ Toolkit, Index Data 1995-2007
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.ac,v 1.66 2007-03-07 08:05:25 adam Exp $
5 AC_INIT([yaz],[2.1.52],[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 netinet/in.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h])
27 AC_CHECK_HEADERS([netinet/if_ether.h],[],[],[
29 #include <sys/types.h>
32 #include <sys/socket.h>
35 #include <netinet/in.h>
39 if test "$ac_cv_header_stdc" = "no"; then
40 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
43 AC_CHECK_TYPES([long long])
47 AC_CHECK_FUNC(connect)
48 if test "$ac_cv_func_connect" = "no"; then
49 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
51 if test "$checkBoth" = "1"; then
53 LIBS="$LIBS -lsocket -lnsl"
54 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
56 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
61 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
64 if test "$openssl" != "no"; then
66 if test "$openssl" != "yes" -a "$openssl" != "default"; then
67 if test -x $openssl/bin/pkg-config; then
68 if $openssl/bin/pkg-config --exists openssl; then
69 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
70 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
71 sslver=`$openssl/bin/pkg-config --modversion openssl`
74 if test "$sslver" = "no"; then
75 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
76 SSL_LIBPATH="-L$openssl/lib"
79 if test "$pkgconfigpath" != "NONE"; then
80 if $pkgconfigpath --exists openssl; then
81 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
82 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
83 sslver=`$pkgconfigpath --modversion openssl`
86 if test "$sslver" = "no"; then
87 SSL_CFLAGS="-I/usr/include/openssl"
90 if test "$sslver" = "no"; then
92 xCPPFLAGS="$CPPFLAGS";
93 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
94 AC_CHECK_LIB(crypto, main)
95 AC_CHECK_LIB(ssl, SSL_new)
96 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
97 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
98 LIBS="$SSL_LIBPATH $LIBS"
100 if test "$sslver" != "yes"; then
103 CPPFLAGS="$xCPPFLAGS"
105 AC_MSG_CHECKING([for SSL])
106 if test "$sslver" != "no"; then
107 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
108 AC_MSG_RESULT([$sslver])
111 AC_MSG_RESULT([None])
112 if test "$openssl" != "default"; then
113 AC_MSG_ERROR([OpenSSL development libraries missing])
118 dnl ------ GNU Readline
119 READLINE_SHARED_LIBADD=""
120 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
121 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
124 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
125 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
126 if test "$ac_cv_lib_readline_readline" = "yes"; then
127 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
129 LIBS="$LIBS $READLINE_LIBS"
132 #include <readline/readline.h>
134 rl_attempted_completion_over = 0;
135 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
138 #include <readline/readline.h>
140 rl_completion_matches (0, 0);
141 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
145 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
146 if test "$with_iconv" != "no"; then
147 AC_MSG_CHECKING(for iconv)
149 oldCPPFLAGS="${CPPFLAGS}"
150 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
151 LIBS="$LIBS -L${with_iconv}/lib"
152 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
157 iconv_t t = iconv_open("", "");
159 AC_DEFINE(HAVE_ICONV_H)
166 iconv_t t = iconv_open("", "");
168 AC_DEFINE(HAVE_ICONV_H)
172 CPPFLAGS="$oldCPPFLAGS"
177 dnl ------ libpcap / ziffy
181 AC_SUBST(PCAP_CFLAGS)
183 AC_ARG_WITH(pcap, [ --with-pcap[=DIR] libpcap root dir located in (dir)], [PCAP_DIR="$withval"],[PCAP_DIR=default])
185 AC_MSG_CHECKING([for libpcap (required for ziffy)])
186 if test "${PCAP_DIR}" != "no"; then
187 if test "${PCAP_DIR}" != "yes" && test "${PCAP_DIR}" != "default"; then
188 if test -r $PCAP_DIR/libpcap.a && test -r $PCAP_DIR/pcap.h; then
190 PCAP_LIBS="${LIBS} -L$PCAP_DIR -lpcap"
191 PCAP_CFLAGS="${INCS} -I$PCAP_DIR"
195 if test -d /usr/local &&
196 test -r /usr/local/lib/libpcap.a &&
197 test -r /usr/local/include/pcap.h; then
198 PCAP_DIR="/usr/local"
199 PCAP_LIBS="${LIBS} -L$PCAP_DIR/lib -lpcap"
200 PCAP_CFLAGS="${INCS} -I$PCAP_DIR/include"
203 test -r /usr/lib/libpcap.a &&
204 test -r /usr/include/pcap.h; then
206 PCAP_LIBS="${LIBS} -lpcap"
211 if test -z "$ZIFFY_PROG"; then
212 AC_MSG_RESULT([not found. ziffy disabled])
213 if test "${PCAP_DIR}" != "default" && test "${PCAP_DIR}" != "no"; then
214 AC_MSG_ERROR([libpcap missing])
217 AC_MSG_RESULT([found in $PCAP_DIR])
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)
283 AC_DEFINE(YAZ_USE_NEW_LOG)
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)
295 LIBS="$LIBS -lwrap -lnsl"
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)
303 if test "$tcpd_ok" = "0"; then
305 AC_MSG_ERROR([tcpd development libraries missing])
307 CPPFLAGS=$oldCPPFLAGS
310 AC_DEFINE(HAVE_TCPD_H)
314 AC_SUBST(YAZ_CONFIG_CFLAGS)
318 dnl ------ GNU threads
319 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
321 if test "$enable_pth" = "yes"; then
324 AC_CHECK_LIB(pth,main)
325 if test "$ac_cv_lib_pth_main" = "yes"; then
326 AC_CHECK_HEADERS(pth.h)
327 if test "$ac_cv_header_pth_h" = "yes"; then
329 CFLAGS="$CFLAGS -DYAZ_GNU_THREADS=1"
333 LIBS="$OLIBS $PTH_LIBS"
336 dnl ------ POSIX Threads
337 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
338 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
340 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
341 AC_DEFINE(YAZ_POSIX_THREADS)
342 dnl unfortunately empty thread lib spec is problematic because
343 dnl 'yaz-config --cflags' is not always passed to linker in
344 dnl applications using YAZ (such as Zebra).
345 if test "x$PTHREAD_LIBS" = "x"; then
347 for lib in -lpthread -lpthreads -lc_r; do
349 AC_TRY_LINK([ #include <pthread.h> ],
350 [ pthread_t id; pthread_join(id, 0); ],
351 [ PTHREAD_LIBS=$lib; break ]
356 LIBS="$PTHREAD_LIBS $LIBS"
357 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $PTHREAD_CFLAGS -DYAZ_POSIX_THREADS=1"
361 dnl ----- libXSLT/libEXLT/libXML2
362 AC_SUBST(XML2_CFLAGS)
366 AC_DEFINE(YAZ_HAVE_XML2)
367 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
373 AC_DEFINE(YAZ_HAVE_XSLT)
374 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
379 AC_DEFINE(YAZ_HAVE_EXSLT)
380 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
384 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
386 if test "$XML2_LIBS"; then
387 LIBS="$XML2_LIBS $LIBS"
391 dnl ------ Memory debugging
392 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
393 if test "$enable_memdebug" = "yes"; then
394 AC_DEFINE(TRACE_XMALLOC,2)
395 elif test "$enable_memdebug" = "no"; then
396 AC_DEFINE(TRACE_XMALLOC,0)
399 dnl ------ Using this for "in-source" yaz-config
400 AC_SUBST(YAZ_SRC_ROOT)
401 AC_SUBST(YAZ_BUILD_ROOT)
402 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
427 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])
431 "------------------------------------------------------------------------
434 YAZ Package: ${PACKAGE}
435 YAZ Version: ${VERSION}
436 Bugreport: ${PACKAGE_BUGREPORT}
437 Source code location: ${srcdir}
438 C Preprocessor: ${CPP}
439 C Preprocessor flags: ${CPPFLAGS}
441 C Compiler flags: ${CFLAGS}
442 Linker flags: ${LDFLAGS}
444 Host System Type: ${host}
445 Install path: ${prefix}
446 Automake: ${AUTOMAKE}
450 ------------------------------------------------------------------------"
452 dnl mode:shell-script
453 dnl sh-indentation: 2
454 dnl sh-basic-offset: 4