1 dnl YAZ Toolkit, Index Data 1994-2006
2 dnl See the file LICENSE for details.
3 dnl $Id: configure.ac,v 1.26 2006-06-16 10:19:23 adam Exp $
5 AC_INIT([yaz],[2.1.23],[adam@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)
21 AC_PATH_PROG(pkgconfigpath, pkg-config, NONE)
27 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)
29 if test "$ac_cv_header_stdc" = "no"; then
30 AC_MSG_WARN([Your system doesn not seem to support ANSI C])
33 AC_CHECK_TYPES([long long])
37 AC_CHECK_FUNC(connect)
38 if test "$ac_cv_func_connect" = "no"; then
39 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", checkBoth=1)
41 if test "$checkBoth" = "1"; then
43 LIBS="$LIBS -lsocket -lnsl"
44 AC_CHECK_FUNC(accept, , [LIBS=$oldLibs])
46 AC_CHECK_FUNC(gethostbyname, ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
51 AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
54 if test "$openssl" != "no"; then
56 if test "$openssl" != "yes" -a "$openssl" != "default"; then
57 if test -x $openssl/bin/pkg-config; then
58 if $openssl/bin/pkg-config --exists openssl; then
59 SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
60 LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
61 sslver=`$openssl/bin/pkg-config --modversion openssl`
64 if test "$sslver" = "no"; then
65 SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
66 SSL_LIBPATH="-L$openssl/lib"
69 if test "$pkgconfigpath" != "NONE"; then
70 if $pkgconfigpath --exists openssl; then
71 SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
72 LIBS="$LIBS `$pkgconfigpath --libs openssl`"
73 sslver=`$pkgconfigpath --modversion openssl`
76 if test "$sslver" = "no"; then
77 SSL_CFLAGS="-I/usr/include/openssl"
80 if test "$sslver" = "no"; then
82 xCPPFLAGS="$CPPFLAGS";
83 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
84 AC_CHECK_LIB(crypto, main)
85 AC_CHECK_LIB(ssl, SSL_new)
86 if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
87 AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
88 LIBS="$SSL_LIBPATH $LIBS"
90 if test "$sslver" != "yes"; then
95 AC_MSG_CHECKING([for SSL])
96 if test "$sslver" != "no"; then
97 SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
98 AC_MSG_RESULT([$sslver])
101 AC_MSG_RESULT([None])
102 if test "$openssl" != "default"; then
103 AC_MSG_ERROR([OpenSSL development libraries missing])
108 dnl ------ GNU Readline
109 READLINE_SHARED_LIBADD=""
110 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
111 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
114 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
115 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
116 if test "$ac_cv_lib_readline_readline" = "yes"; then
117 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
119 LIBS="$LIBS $READLINE_LIBS"
122 #include <readline/readline.h>
124 rl_attempted_completion_over = 0;
125 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
128 #include <readline/readline.h>
130 rl_completion_matches (0, 0);
131 ],[AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES)])
135 AC_ARG_WITH(iconv, [ --with-iconv[=PREFIX] iconv library in PREFIX])
136 if test "$with_iconv" != "no"; then
137 AC_MSG_CHECKING(for iconv)
139 oldCPPFLAGS="${CPPFLAGS}"
140 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
141 LIBS="$LIBS -L${with_iconv}/lib"
142 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
147 iconv_t t = iconv_open("", "");
149 AC_DEFINE(HAVE_ICONV_H)
156 iconv_t t = iconv_open("", "");
158 AC_DEFINE(HAVE_ICONV_H)
162 CPPFLAGS="$oldCPPFLAGS"
167 dnl ------ various functions
168 AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
178 if test "$ac_cv_func_poll" = "yes" -a "$trypoll" = "yes"; then
179 AC_CHECK_HEADERS(sys/poll.h)
182 dnl We check for socklen_t by making prototypes with the
183 dnl various types. First socklen_t, then size_t, finally int.
184 dnl If the prototype succeeds, we are probably safe.
185 dnl That works if accept is not preprocessor defined (such sa AIX)
186 AC_MSG_CHECKING([for socklen_t])
187 AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
189 #include <sys/types.h>
190 #include <sys/socket.h>
201 extern int accept(int, struct sockaddr *, socklen_t *);
206 ],,[ac_cv_check_socklen_t=socklen_t],[
208 #include <sys/types.h>
209 #include <sys/socket.h>
220 extern int accept(int, struct sockaddr *, size_t t *);
225 ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
228 AC_MSG_RESULT($ac_cv_check_socklen_t)
229 AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
230 AC_DEFINE(YAZ_USE_NEW_LOG)
233 AC_ARG_ENABLE(tcpd,[ --enable-tcpd[=PREFIX] enable TCP wrapper for server if available])
234 if test "$enable_tcpd" -a "$enable_tcpd" != "no"; then
236 oldCPPFLAGS=$CPPFLAGS
237 if test "$enable_tcpd" != "yes"; then
238 LIBS="$LIBS -L$enable_tcpd/lib"
239 CPPFLAGS="$CPPFLAGS -I$enable_tcpd/include"
241 AC_MSG_CHECKING(for working tcpd.h)
242 LIBS="$LIBS -lwrap -lnsl"
243 AC_TRY_LINK([#include <syslog.h>
245 int allow_severity = LOG_INFO;
246 int deny_severity = LOG_WARNING;],
247 [struct request_info request_info; int i;
248 i = hosts_access(&request_info);],
249 tcpd_ok=1, tcpd_ok=0)
250 if test "$tcpd_ok" = "0"; then
252 AC_MSG_ERROR([tcpd development libraries missing])
254 CPPFLAGS=$oldCPPFLAGS
257 AC_DEFINE(HAVE_TCPD_H)
261 AC_SUBST(THREAD_CFLAGS)
266 dnl ------ GNU threads
267 AC_ARG_ENABLE(pth, [ --enable-pth enable GNU threads],[enable_pth=$enableval],[enable_pth=no])
269 if test "$enable_pth" = "yes"; then
271 AC_CHECK_LIB(pth,main)
272 if test "$ac_cv_lib_pth_main" = "yes"; then
273 AC_CHECK_HEADERS(pth.h)
274 if test "$ac_cv_header_pth_h" = "yes"; then
276 THREAD_CFLAGS="-DYAZ_GNU_THREADS=1"
280 LIBS="$OLIBS $LIBTHREAD"
283 dnl ------ POSIX Threads
284 AC_ARG_ENABLE(threads, [ --disable-threads disable POSIX threads],[enable_threads=$enableval],[enable_threads=yes])
285 if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
288 AC_CHECK_LIB(pthread,main)
289 AC_MSG_CHECKING(for working POSIX Threads)
290 AC_TRY_LINK([#include <pthread.h>
291 void *func(void *p) { return 0; }
293 pthread_t pthread_id;
294 pthread_create (&pthread_id, 0, func, 0);],
295 thread_ok=yes,thread_ok=no)
296 if test "$thread_ok" = "yes"; then
298 LIBTHREAD="-lpthread"
299 THREAD_CFLAGS="-DYAZ_POSIX_THREADS=1 -D_REENTRANT"
303 AC_TRY_LINK([#include <pthread.h>
304 void *func(void *p) { return 0; }
306 pthread_t pthread_id;
307 pthread_create (&pthread_id, 0, func, 0);],
308 thread_ok=yes,thread_ok=no)
309 if test "$thread_ok" = "yes"; then
310 AC_MSG_RESULT([yes,BSD])
311 THREAD_CFLAGS="-pthread -DYAZ_POSIX_THREADS=1 -D_REENTRANT"
316 if test "$thread_ok" = "no"; then
320 LIBS="$OLIBS $LIBTHREAD"
323 dnl ----- libXSLT/libEXLT/libXML2
324 AC_SUBST(XML2_CFLAGS)
330 if test "$XML2_LIBS"; then
331 LIBS="$XML2_LIBS $LIBS"
335 dnl ------ Memory debugging
336 AC_ARG_ENABLE(memdebug, [ --enable-memdebug enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
337 if test "$enable_memdebug" = "yes"; then
338 AC_DEFINE(TRACE_XMALLOC,2)
339 elif test "$enable_memdebug" = "no"; then
340 AC_DEFINE(TRACE_XMALLOC,0)
343 dnl ------ Using this for "in-source" yaz-config
344 AC_SUBST(YAZ_SRC_ROOT)
345 AC_SUBST(YAZ_BUILD_ROOT)
346 YAZ_SRC_ROOT=`cd ${srcdir}; pwd`
369 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > util/yaz-config && chmod +x yaz-config util/yaz-config])
373 "------------------------------------------------------------------------
376 YAZ Package: ${PACKAGE}
377 YAZ Version: ${VERSION}
378 Bugreport: ${PACKAGE_BUGREPORT}
379 Source code location: ${srcdir}
380 C Preprocessor: ${CPP}
381 C Preprocessor flags: ${CPPFLAGS}
383 C Compiler flags: ${CFLAGS}
384 Linker flags: ${LDFLAGS}
386 Host System Type: ${host}
387 Install path: ${prefix}
388 Automake: ${AUTOMAKE}
392 ------------------------------------------------------------------------"
394 dnl mode:shell-script
395 dnl sh-indentation: 2
396 dnl sh-basic-offset: 4