1 dnl Zebra, Index Data Aps, 1995-2004
2 dnl $Id: configure.in,v 1.101 2004-09-27 10:44:47 adam Exp $
4 AC_INIT(include/idzebra/version.h)
5 AM_INIT_AUTOMAKE(idzebra,1.4.0)
6 dnl ------ Substitutions
9 AC_SUBST(READLINE_LIBS)
10 dnl ------ Perl substitutions
12 AC_SUBST(PERL_XS_INIT)
13 AC_SUBST(PERL_XS_INIT_INCLUDE)
18 dnl ------ Checking programs
24 AC_ARG_ENABLE(threads, [ --disable-threads disable threads],[enable_threads=$enableval],[enable_threads=yes])
25 if test "$enable_threads" = "yes"; then
32 dnl ------ Look for Tcl
33 dnl See if user has specified location of tclConfig.sh; otherwise
34 dnl see if tclConfig.sh exists in same prefix lcoation as tclsh; otherwise
39 AC_ARG_WITH(tclconfig, [ --with-tclconfig=DIR tclConfig.sh in DIR], [tclconfig=$withval])
40 if test "x$tclconfig" = xNONE; then
42 AC_PREFIX_PROGRAM(tclsh)
43 tclconfig=${prefix}/lib
45 if test ! -r ${tclconfig}/tclConfig.sh; then
46 # Not found, try search for Tcl on Debian systems.
47 for d in /usr/lib/tcl*; do
48 if test -f $d/tclConfig.sh; then
54 AC_MSG_CHECKING(for Tcl)
55 if test -r ${tclconfig}/tclConfig.sh; then
56 . ${tclconfig}/tclConfig.sh
57 if test -r ${tclconfig}/../generic/tcl.h; then
58 TCL_INCLUDE=-I${tclconfig}/../generic
59 TCL_LIB="$TCL_BUILD_LIB_SPEC $TCL_LIBS"
60 elif test -d ${TCL_PREFIX}/include/tcl${TCL_VERSION}; then
61 TCL_INCLUDE=-I${TCL_PREFIX}/include/tcl${TCL_VERSION}
62 TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
64 TCL_INCLUDE=-I${TCL_PREFIX}/include
65 TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
67 TCL_LIB=`echo $TCL_LIB|sed 's%-L/usr/lib%%g'`
68 SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
69 SHLIB_LD=$TCL_SHLIB_LD
70 SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
71 SHLIB_VERSION=$TCL_SHLIB_VERSION
72 AC_MSG_RESULT($TCL_VERSION)
73 AC_DEFINE(HAVE_TCL_H,1)
75 AC_MSG_RESULT(Not found)
76 AC_DEFINE(HAVE_TCL_H,0)
80 AC_CHECK_HEADERS(sys/times.h)
83 AC_CHECK_FUNCS(mkstemp)
85 dnl ------ GNU Readline
86 READLINE_SHARED_LIBADD=""
87 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
88 AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
91 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
92 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
93 if test "$ac_cv_lib_readline_readline" = "yes"; then
94 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
96 LIBS="$LIBS $READLINE_LIBS"
99 #include <readline/readline.h>
101 rl_attempted_completion_over = 0;
102 ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
105 #include <readline/readline.h>
107 rl_completion_matches (0, 0);
108 ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
113 AC_ARG_WITH(iconv, [ --with-iconv[=DIR] iconv library in DIR])
114 if test "$with_iconv" != "no"; then
115 AC_MSG_CHECKING(for iconv)
117 oldCPPFLAGS="${CPPFLAGS}"
118 if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
119 LIBS="$LIBS -L${with_iconv}/lib"
120 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
125 iconv_t t = iconv_open("", "");
127 AC_DEFINE(HAVE_ICONV_H)
134 iconv_t t = iconv_open("", "");
136 AC_DEFINE(HAVE_ICONV_H)
140 CPPFLAGS="$oldCPPFLAGS"
147 AC_CHECK_LIB(bz2,bzCompressInit)
148 if test "$ac_cv_lib_bz2_bzCompressInit" = "yes"; then
149 AC_CHECK_HEADERS(bzlib.h)
151 AC_CHECK_LIB(bz2,BZ2_bzCompressInit)
152 if test "$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yes"; then
153 AC_CHECK_HEADERS(bzlib.h)
160 AC_CHECK_LIB(dl,dlopen)
165 AC_ARG_WITH(expat, [ --with-expat[=DIR] EXPAT library in DIR],[expat=$withval])
166 if test "$expat" != "no"; then
169 if test "$expat" != "yes"; then
170 EXPAT_CFLAGS="-I$expat/include"
171 EXPAT_LIBS="-L$expat/lib"
172 CFLAGS="$EXPAT_CFLAGS $CFLAGS"
173 LIBS="$EXPAT_LIBS $LIBS"
175 AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="$EXPAT_LIBS -lexpat"])
176 if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
177 AC_CHECK_HEADERS(expat.h)
184 AC_ARG_WITH(perl, [ --with-perl[=FILE] perl binary location],[perl=$withval],[perl=yes])
186 dnl ------- 64 bit files
187 AC_MSG_CHECKING(for LFS)
188 AC_TRY_RUN([#define _FILE_OFFSET_BITS 64
189 #include <sys/types.h>
195 int main(int argc, char **argv)
201 if (sizeof(off_t) != 8)
204 sprintf (tmp_str, "%Ld", o+o+o);
205 if (strcmp (tmp_str, "6000000000"))
207 fd = creat ("config.tmp", 0644);
210 area.l_type = F_WRLCK;
211 area.l_whence = SEEK_SET;
212 area.l_len = area.l_start = 0L;
213 if (fcntl(fd, F_SETLKW, &area))
216 unlink ("config.tmp");
219 ],bits=64,bits=32,bits=32)
220 if test "$bits" = "64"; then
221 AC_DEFINE(_FILE_OFFSET_BITS,64)
227 AC_SUBST(SHARED_MODULE_LA)
229 AC_SUBST(STATIC_MODULE_OBJ)
231 AC_SUBST(STATIC_MODULE_LADD)
232 STATIC_MODULE_LADD=""
233 AC_DEFUN([ZEBRA_MODULE],[
234 AC_ARG_ENABLE(mod-$1,[$3],[myen=$enableval],[myen=$2])
235 AC_MSG_CHECKING([for module $1])
236 if test "$myen" = "yes"; then
239 if test "$enable_shared" != "yes"; then
240 if test "$myen" = "shared"; then
245 if test "$myen" = "shared"; then
246 AC_MSG_RESULT([shared])
247 SHARED_MODULE_LA="${SHARED_MODULE_LA} mod-$1.la"
248 elif test "$myen" = "static" -o "$myen" = "yes"; then
249 AC_MSG_RESULT([static])
250 STATIC_MODULE_OBJ="${STATIC_MODULE_OBJ} \$(mod_${m}_la_OBJECTS)"
251 STATIC_MODULE_LADD="${STATIC_MODULE_LADD} \$(mod_${m}_la_LADD)"
252 modcpp=`echo $1|tr a-z- A-Z_`
253 AC_DEFINE_UNQUOTED([IDZEBRA_STATIC_$modcpp])
254 elif test "$myen" = "no"; then
255 AC_MSG_RESULT([disabled])
257 AC_MSG_RESULT([bad value. Assuming disabled])
261 ZEBRA_MODULE(text,static, [ --enable-mod-text Text filter])
262 ZEBRA_MODULE(grs-sgml,static,[ --enable-mod-grs-sgml Simple SGML/XML filter])
263 ZEBRA_MODULE(grs-regx,shared,[ --enable-mod-grs-regx REGX/TCL filter])
264 ZEBRA_MODULE(grs-marc,shared,[ --enable-mod-grs-marc MARC filter])
265 ZEBRA_MODULE(grs-danbib,shared,[ --enable-mod-grs-danbib DanBib filter (DBC)])
266 ZEBRA_MODULE(grs-xml,shared, [ --enable-mod-grs-xml XML filter (Expat based)])
267 ZEBRA_MODULE(grs-perl,no, [ --enable-mod-grs-perl Perl filter])
269 PERL_XS_INIT_INCLUDE=''
271 if test "$myen" != "no"; then
272 AC_MSG_CHECKING(for perl binary)
273 if test "$perl" = "yes"; then
278 if test -x "$perlbin"; then
279 AC_MSG_RESULT($perlbin)
280 AC_MSG_CHECKING(perl core directory)
281 archdir=`$perlbin -MConfig -e 'print $Config{archlib}'`;
282 perlcore="$archdir/CORE";
283 if test -d "$perlcore"; then
284 PERL_BINARY="$perlbin"
285 AC_MSG_RESULT($perlcore)
287 AC_MSG_RESULT(Failed)
290 AC_MSG_CHECKING("for ExtUtils::Embed to determine ccopts")
291 PERL_CFLAGS=`$perlbin -MExtUtils::Embed -e ccopts 2>/dev/null`
292 if test "$PERL_CFLAGS"; then
295 PERL_CFLAGS="-I$perlcore"
296 AC_MSG_RESULT(Using defaults)
299 AC_MSG_CHECKING("for ExtUtils::Embed to determine ldflags")
300 PERL_LIBS=`$perlbin -MExtUtils::Embed -e ldopts 2>/dev/null`
301 if test "$PERL_LIBS"; then
304 PERL_LIBS="-L$perlcore -lperl -lm"
305 AC_MSG_RESULT(Using defaults)
308 AC_MSG_CHECKING("for ExtUtils::Embed to create xs_init")
309 xsf="recctrl/xsinit.h"
310 `rm $xsf 2>/dev/null`;
312 `$perlbin -MExtUtils::Embed -e xsinit -- -o $xsf 2>/dev/null`
313 if test -r "$xsf"; then
315 PERL_XS_INIT="xs_init"
316 PERL_XS_INIT_INCLUDE='#include "xsinit.h"'
318 AC_MSG_RESULT(XS libraries are not going to be available)
323 CFLAGS="$PERL_CFLAGS $CFLAGS"
324 LIBS="$PERL_LIBS $LIBS"
326 AC_MSG_CHECKING(for perl library)
331 ],AM_CONDITIONAL(perl,true)
332 AC_DEFINE(HAVE_PERL,1)
336 AC_MSG_RESULT(not found)
337 AC_DEFINE(HAVE_PERL,0))
341 AC_DEFINE(HAVE_PERL,0)
342 AC_MSG_RESULT(Not found)
346 dnl ------ ANSI C Header files
348 if test "$ac_cv_header_stdc" = "no"; then
349 AC_MSG_WARN(Your system doesn't seem to support ANSI C)
351 AC_SUBST(IDZEBRA_SRC_ROOT)
352 AC_SUBST(IDZEBRA_BUILD_ROOT)
353 IDZEBRA_SRC_ROOT=`cd ${srcdir}; pwd`
354 IDZEBRA_BUILD_ROOT=`pwd`
355 dnl ------ Create Makefiles
370 include/Makefile include/idzebra/Makefile
378 test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile
379 test/rusmarc/Makefile test/cddb/Makefile test/malxml/Makefile
380 test/config/Makefile test/sort2/Makefile
381 perl/Makefile.PL test/xelm/Makefile
382 test/dmoz/Makefile test/xpath/Makefile test/sort/Makefile test/zsh/Makefile
383 test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile
384 examples/Makefile examples/gils/Makefile examples/zthes/Makefile
387 ],[sed s%idzebra_echo_source=yes%idzebra_echo_source=no%g < idzebra-config > util/idzebra-config && chmod +x idzebra-config util/idzebra-config])
388 if test -x "$perlbin"; then
389 res=`cd perl ; $perlbin Makefile.PL ; cd .. ;`;
391 if test -z "$YAZLIB"; then
392 echo "YAZ was not found. Use --with-yaz=DIR to specify location."
393 test -f /etc/debian_version && echo "Debian package libyaz-dev is required."