1 dnl YAZ Toolkit, Index Data 1994-2006
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.ac,v 1.52 2006-12-18 08:48:30 adam Exp $
5 AC_INIT([yaz],[2.1.43],[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 sys/select.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/un.h sys/wait.h unistd.h netinet/if_ether.h netinet/in_systm.h)
28 if test "$ac_cv_header_stdc" = "no"; then
29 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
32 AC_CHECK_TYPES([long long])
36 AC_CHECK_FUNC(connect)
37 if test "$ac_cv_func_connect" = "no"; then
38 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
40 if test "$checkBoth" = "1"; then
42 LIBS="$LIBS -lsocket -lnsl"
43 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
45 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
50 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
53 if test "$openssl" != "no"; then
55 if test "$openssl" != "yes" -a "$openssl" != "default"; then
56 if test -x $openssl/bin/pkg-config; then
57 if $openssl/bin/pkg-config --exists openssl; then
58 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
59 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
60 sslver=`$openssl/bin/pkg-config --modversion openssl`
63 if test "$sslver" = "no"; then
64 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
65 SSL_LIBPATH="-L$openssl/lib"
68 if test "$pkgconfigpath" != "NONE"; then
69 if $pkgconfigpath --exists openssl; then
70 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
71 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
72 sslver=`$pkgconfigpath --modversion openssl`
75 if test "$sslver" = "no"; then
76 SSL_CFLAGS="-I/usr/include/openssl"
79 if test "$sslver" = "no"; then
81 xCPPFLAGS="$CPPFLAGS";
82 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
83 AC_CHECK_LIB(crypto, main)
84 AC_CHECK_LIB(ssl, SSL_new)
85 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
86 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
87 LIBS="$SSL_LIBPATH $LIBS"
89 if test "$sslver" != "yes"; then
94 AC_MSG_CHECKING([for SSL])
95 if test "$sslver" != "no"; then
96 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
97 AC_MSG_RESULT([$sslver])
100 AC_MSG_RESULT([None])
101 if test "$openssl" != "default"; then
102 AC_MSG_ERROR([OpenSSL development libraries missing])
107 dnl ------ GNU Readline
108 READLINE_SHARED_LIBADD=""
109 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
110 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
113 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
114 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
115 if test "$ac_cv_lib_readline_readline" = "yes"; then
116 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
118 LIBS="$LIBS $READLINE_LIBS"
121 #include <readline/readline.h>
123 rl_attempted_completion_over = 0;
124 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
127 #include <readline/readline.h>
129 rl_completion_matches (0, 0);
130 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
134 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
135 if test "$with_iconv" != "no"; then
136 AC_MSG_CHECKING(for iconv)
138 oldCPPFLAGS="${CPPFLAGS}"
139 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
140 LIBS="$LIBS -L${with_iconv}/lib"
141 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
146 iconv_t t = iconv_open("", "");
148 AC_DEFINE(HAVE_ICONV_H)
155 iconv_t t = iconv_open("", "");
157 AC_DEFINE(HAVE_ICONV_H)
161 CPPFLAGS="$oldCPPFLAGS"
166 dnl ------ libpcap / ziffy
170 AC_SUBST(PCAP_CFLAGS)
172 AC_ARG_WITH(pcap, [ --with-pcap[=DIR] libpcap root dir located in (dir)], [PCAP_DIR="$withval"],[PCAP_DIR=default])
174 AC_MSG_CHECKING([for libpcap (required for ziffy)])
175 if test "${PCAP_DIR}" != "no"; then
176 if test "${PCAP_DIR}" != "yes" && test "${PCAP_DIR}" != "default"; then
177 if test -r $PCAP_DIR/libpcap.a && test -r $PCAP_DIR/pcap.h; then
179 PCAP_LIBS="${LIBS} -L$PCAP_DIR -lpcap"
180 PCAP_CFLAGS="${INCS} -I$PCAP_DIR"
184 if test -d /usr/local &&
185 test -r /usr/local/lib/libpcap.a &&
186 test -r /usr/local/include/pcap.h; then
187 PCAP_DIR="/usr/local"
188 PCAP_LIBS="${LIBS} -L$PCAP_DIR/lib -lpcap"
189 PCAP_CFLAGS="${INCS} -I$PCAP_DIR/include"
192 test -r /usr/lib/libpcap.a &&
193 test -r /usr/include/pcap.h; then
195 PCAP_LIBS="${LIBS} -lpcap"
200 if test -z "$ZIFFY_PROG"; then
201 AC_MSG_RESULT([not found. ziffy disabled])
202 if test "${PCAP_DIR}" != "default" && test "${PCAP_DIR}" != "no"; then
203 AC_MSG_ERROR([libpcap missing])
206 AC_MSG_RESULT([found in $PCAP_DIR])
209 dnl ------ various functions
210 AC_CHECK_FUNCS(getaddrinfo vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
220 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
221 AC_CHECK_HEADERS(sys/poll.h)
224 dnl We check for socklen_t by making prototypes with the
225 dnl various types. First socklen_t, then size_t, finally int.
226 dnl If the prototype succeeds, we are probably safe.
227 dnl That works if accept is not preprocessor defined (such sa AIX)
228 AC_MSG_CHECKING([for socklen_t])
229 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
231 #include <sys/types.h>
232 #include <sys/socket.h>
243 extern int accept(int, struct sockaddr *, socklen_t *);
248 ],,[ac_cv_check_socklen_t=socklen_t],[
250 #include <sys/types.h>
251 #include <sys/socket.h>
262 extern int accept(int, struct sockaddr *, size_t t *);
267 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
270 AC_MSG_RESULT($ac_cv_check_socklen_t)
271 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
272 AC_DEFINE(YAZ_USE_NEW_LOG)
275 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
276 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
278 oldCPPFLAGS=$CPPFLAGS
279 if test "$enable_tcpd" != "yes"; then
280 LIBS="$LIBS -L$enable_tcpd/lib"
281 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
283 AC_MSG_CHECKING(for working tcpd.h)
284 LIBS="$LIBS -lwrap -lnsl"
285 AC_TRY_LINK([#include <syslog.h>
287 int allow_severity = LOG_INFO;
288 int deny_severity = LOG_WARNING;],
289 [struct request_info request_info; int i;
290 i = hosts_access(&request_info);],
291 tcpd_ok=1, tcpd_ok=0)
292 if test "$tcpd_ok" = "0"; then
294 AC_MSG_ERROR([tcpd development libraries missing])
296 CPPFLAGS=$oldCPPFLAGS
299 AC_DEFINE(HAVE_TCPD_H)
303 AC_SUBST(THREAD_CFLAGS)
308 dnl ------ GNU threads
309 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
311 if test "$enable_pth" = "yes"; then
313 AC_CHECK_LIB(pth,main)
314 if test "$ac_cv_lib_pth_main" = "yes"; then
315 AC_CHECK_HEADERS(pth.h)
316 if test "$ac_cv_header_pth_h" = "yes"; then
318 THREAD_CFLAGS="-DYAZ_GNU_THREADS=1"
322 LIBS="$OLIBS $LIBTHREAD"
325 dnl ------ POSIX Threads
326 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
327 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
330 AC_CHECK_LIB(pthread,main)
331 AC_MSG_CHECKING(for working POSIX Threads)
332 AC_TRY_LINK([#include <pthread.h>
333 void *func(void *p) { return 0; }
335 pthread_t pthread_id;
336 pthread_create (&pthread_id, 0, func, 0);],
337 thread_ok=yes,thread_ok=no)
338 if test "$thread_ok" = "yes"; then
340 LIBTHREAD="-lpthread"
341 THREAD_CFLAGS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
345 AC_TRY_LINK([#include <pthread.h>
346 void *func(void *p) { return 0; }
348 pthread_t pthread_id;
349 pthread_create (&pthread_id, 0, func, 0);],
350 thread_ok=yes,thread_ok=no)
351 if test "$thread_ok" = "yes"; then
352 AC_MSG_RESULT([yes,BSD])
353 THREAD_CFLAGS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
358 if test "$thread_ok" = "no"; then
362 LIBS="$OLIBS $LIBTHREAD"
365 dnl ----- libXSLT/libEXLT/libXML2
366 AC_SUBST(XML2_CFLAGS)
367 AC_SUBST(YAZ_CONFIG_CFLAGS)
372 AC_DEFINE(YAZ_HAVE_XML2)
373 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XML2=1"
379 AC_DEFINE(YAZ_HAVE_XSLT)
380 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_XSLT=1"
385 AC_DEFINE(YAZ_HAVE_EXSLT)
386 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS -DYAZ_HAVE_EXSLT=1"
390 YAZ_CONFIG_CFLAGS="$YAZ_CONFIG_CFLAGS $XML2_CFLAGS"
392 if test "$XML2_LIBS"; then
393 LIBS="$XML2_LIBS $LIBS"
397 dnl ------ Memory debugging
398 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
399 if test "$enable_memdebug" = "yes"; then
400 AC_DEFINE(TRACE_XMALLOC,2)
401 elif test "$enable_memdebug" = "no"; then
402 AC_DEFINE(TRACE_XMALLOC,0)
405 dnl ------ Using this for "in-source" yaz-config
406 AC_SUBST(YAZ_SRC_ROOT)
407 AC_SUBST(YAZ_BUILD_ROOT)
408 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
432 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])
436 "------------------------------------------------------------------------
439 YAZ Package: ${PACKAGE}
440 YAZ Version: ${VERSION}
441 Bugreport: ${PACKAGE_BUGREPORT}
442 Source code location: ${srcdir}
443 C Preprocessor: ${CPP}
444 C Preprocessor flags: ${CPPFLAGS}
446 C Compiler flags: ${CFLAGS}
447 Linker flags: ${LDFLAGS}
449 Host System Type: ${host}
450 Install path: ${prefix}
451 Automake: ${AUTOMAKE}
455 ------------------------------------------------------------------------"
457 dnl mode:shell-script
458 dnl sh-indentation: 2
459 dnl sh-basic-offset: 4