Bump to version 1.4.1.
[idzebra-moved-to-github.git] / configure.ac
1 dnl Zebra, Index Data ApS, 1995-2006
2 dnl $Id: configure.ac,v 1.15 2006-06-13 12:03:58 adam Exp $
3 dnl
4 AC_PREREQ(2.59)
5 AC_INIT([idzebra],[1.4.1],[adam@indexdata.dk])
6 AC_CONFIG_SRCDIR(configure.ac)
7 AC_CONFIG_AUX_DIR(config)
8 AM_INIT_AUTOMAKE([1.8])
9 dnl ------ Substitutions
10 AC_SUBST(TCL_INCLUDE)
11 AC_SUBST(TCL_LIB)
12 AC_SUBST(READLINE_LIBS)
13 dnl
14 dnl ------ Checking programs
15 AC_PROG_CC
16 AC_PROG_CPP
17 AM_DISABLE_SHARED
18 AM_PROG_LIBTOOL
19 dnl
20 dnl ------ headers
21 AC_CHECK_HEADERS(sys/resource.h sys/times.h sys/time.h sys/wait.h unistd.h)
22 dnl ------ crypt
23 AC_CHECK_LIB(crypt, crypt)
24 if test "$ac_cv_lib_crypt_crypt" = "yes"; then
25         AC_CHECK_HEADERS(crypt.h)
26 fi
27 dnl
28 dnl ------ threads
29 AC_ARG_ENABLE(threads, [  --disable-threads       disable threads],[enable_threads=$enableval],[enable_threads=yes])
30 if test "$enable_threads" = "yes"; then
31         yazflag=threads
32 else
33         yazflag=""
34 fi
35 dnl
36 dnl ------ YAZ
37 YAZ_INIT($yazflag,2.1.20)
38 YAZ_DOC
39 dnl ----- libXSLT
40 AC_SUBST(XSLT_LIBS)
41 AC_SUBST(XSLT_CFLAGS)
42 xsltdir=yes
43 AC_ARG_WITH(xslt,[[  --with-xslt[=PREFIX]    use libxslt in PREFIX]],xsltdir=$withval)
44 if test "$xsltdir" = "yes"; then
45         for d in /usr /usr/local; do
46                 if test -x $d/bin/xslt-config; then
47                         xsltdir=$d
48                 fi
49         done
50 fi
51 if test "$xsltdir" != "no"; then
52         AC_MSG_CHECKING(for libXSLT)
53
54         if test -x $xsltdir/bin/xslt-config; then
55                 XSLT_VER=`$xsltdir/bin/xslt-config --version`
56                 AC_MSG_RESULT($XSLT_VER)
57                 have_xslt_version=`echo "$XSLT_VER" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
58                 if test $have_xslt_version -lt 1001011; then
59                         AC_MSG_WARN([libXSLT too old. Use 1.1.11 or later.])
60                         XSLT_VER=""
61                 else
62                         XSLT_LIBS=`$xsltdir/bin/xslt-config --libs`
63                         XSLT_CFLAGS=`$xsltdir/bin/xslt-config --cflags`
64                         AC_DEFINE(HAVE_XSLT)
65                 fi
66         else
67                 AC_MSG_RESULT(Not found)
68         fi
69 fi
70 dnl ------ Look for Tcl
71 dnl See if user has specified location of tclConfig.sh; otherwise
72 dnl see if tclConfig.sh exists in same prefix lcoation as tclsh; otherwise
73 dnl disable Tcl.
74 TCL_LIB=""
75 TCL_INCLUDE=""
76 tclconfig=NONE
77 AC_ARG_WITH(tclconfig, [  --with-tclconfig=DIR    tclConfig.sh in DIR], [tclconfig=$withval])
78 if test "x$tclconfig" = xNONE; then
79         saveprefix=${prefix}
80         AC_PREFIX_PROGRAM(tclsh)
81         tclconfig=${prefix}/lib
82         prefix=${saveprefix}
83         if test ! -r ${tclconfig}/tclConfig.sh; then
84                 # Not found, try search for Tcl on Debian systems.
85                 for d in /usr/lib/tcl*; do
86                         if test -f $d/tclConfig.sh; then
87                                 tclconfig=$d
88                         fi
89                 done
90         fi
91 fi
92 AC_MSG_CHECKING(for Tcl)
93 if test -r ${tclconfig}/tclConfig.sh; then
94         . ${tclconfig}/tclConfig.sh
95         if test -r ${tclconfig}/../generic/tcl.h; then
96                 TCL_INCLUDE=-I${tclconfig}/../generic
97                 TCL_LIB="$TCL_BUILD_LIB_SPEC $TCL_LIBS"
98         elif test -d ${TCL_PREFIX}/include/tcl${TCL_VERSION}; then
99                 TCL_INCLUDE=-I${TCL_PREFIX}/include/tcl${TCL_VERSION}
100                 TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
101         else
102                 TCL_INCLUDE=-I${TCL_PREFIX}/include
103                 TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
104         fi
105         TCL_LIB=`echo $TCL_LIB|sed 's%-L/usr/lib%%g'`
106         SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
107         SHLIB_LD=$TCL_SHLIB_LD
108         SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
109         SHLIB_VERSION=$TCL_SHLIB_VERSION
110         AC_MSG_RESULT($TCL_VERSION)
111         AC_DEFINE(HAVE_TCL_H,1)
112
113         # The Mac OSX -framework causes problems with Libtool
114         # and dependancy libs.. so apply Tcl libs everywhere
115         # bug #461
116         case $host in
117         *-*-darwin*)
118                 LIBS="$LIBS $TCL_LIB";
119                 ;;
120         esac
121
122 else
123         AC_MSG_RESULT(Not found)
124         AC_DEFINE(HAVE_TCL_H,0)
125 fi
126 dnl
127 dnl ------ mkstemp
128 AC_CHECK_FUNCS(mkstemp)
129 dnl
130 dnl ------ GNU Readline
131 READLINE_SHARED_LIBADD=""
132 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
133         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
134 )
135 READLINE_LIBS=""
136 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
137 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
138 if test "$ac_cv_lib_readline_readline" = "yes"; then
139         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
140         xLIBS=$LIBS
141         LIBS="$LIBS $READLINE_LIBS"
142         AC_TRY_LINK([
143         #include <stdio.h>
144         #include <readline/readline.h>
145         ],[
146                 rl_attempted_completion_over = 0;
147         ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
148         AC_TRY_LINK([
149         #include <stdio.h>
150         #include <readline/readline.h>
151         ],[
152                 rl_completion_matches (0, 0);
153         ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
154         LIBS=$xLIBS
155 fi
156 dnl
157 dnl ------ iconv
158 AC_ARG_WITH(iconv, [  --with-iconv[=DIR]        iconv library in DIR])
159 if test "$with_iconv" != "no"; then
160         AC_MSG_CHECKING(for iconv)
161         oldLIBS="$LIBS"
162         oldCPPFLAGS="${CPPFLAGS}"
163         if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
164                 LIBS="$LIBS -L${with_iconv}/lib"
165                 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
166         fi
167         AC_TRY_LINK([
168                 #include <iconv.h>
169         ],[
170                 iconv_t t = iconv_open("", "");
171         ],[
172                 AC_DEFINE(HAVE_ICONV_H)
173                 AC_MSG_RESULT(yes)
174         ],[
175                 LIBS="$LIBS -liconv"
176                 AC_TRY_LINK([
177                         #include <iconv.h>
178                 ],[
179                         iconv_t t = iconv_open("", "");
180                 ],[
181                         AC_DEFINE(HAVE_ICONV_H)
182                         AC_MSG_RESULT(yes)
183                 ],[
184                         LIBS="$oldLIBS"
185                         CPPFLAGS="$oldCPPFLAGS"
186                         AC_MSG_RESULT(no)
187                 ])
188         ])
189 fi
190 dnl
191 dnl ------- BZIP2
192 AC_CHECK_LIB(bz2,bzCompressInit)
193 if test "$ac_cv_lib_bz2_bzCompressInit" = "yes"; then
194         AC_CHECK_HEADERS(bzlib.h)
195 else
196         AC_CHECK_LIB(bz2,BZ2_bzCompressInit)
197         if test "$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yes"; then
198                 AC_CHECK_HEADERS(bzlib.h)
199         fi
200 fi
201 dnl
202 dnl ------ -lm
203 AC_CHECK_LIB(m,sqrt)
204 dnl ------ -ldl
205 AC_CHECK_LIB(dl,dlopen)
206 dnl
207 dnl ------ EXPAT
208 expat=yes
209 AC_SUBST(EXPAT_LIBS)
210 AC_ARG_WITH(expat,   [  --with-expat[=DIR]        EXPAT library in DIR],[expat=$withval])
211 if test "$expat" != "no"; then
212         xLIBS="$LIBS";
213         xCFLAGS="$CFLAGS";
214         if test "$expat" != "yes"; then
215                 EXPAT_CFLAGS="-I$expat/include"
216                 EXPAT_LIBS="-L$expat/lib"
217                 CFLAGS="$EXPAT_CFLAGS $CFLAGS"
218                 LIBS="$EXPAT_LIBS $LIBS"
219         fi
220         AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="$EXPAT_LIBS -lexpat"])
221         if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
222                 AC_CHECK_HEADERS(expat.h)
223         fi
224         LIBS="$xLIBS"
225         CFLAGS="$xCFLAGS"
226 fi
227 dnl
228 dnl ------- 64 bit files
229 AC_MSG_CHECKING(for LFS)
230 AC_TRY_RUN([#define _FILE_OFFSET_BITS 64
231 #include <sys/types.h>
232 #include <unistd.h>
233 #include <string.h>
234 #include <stdio.h>
235 #include <fcntl.h>
236 #include <errno.h>
237 int main(int argc, char **argv)
238 {
239         off_t o;
240         char tmp_str[32];
241         int fd;
242         struct flock area;
243         if (sizeof(off_t) != 8) 
244                 exit (1);
245         o = 2000000000;
246         sprintf (tmp_str, "%Ld", o+o+o);
247         if (strcmp (tmp_str, "6000000000"))
248                 exit (1);
249         fd = creat ("config.tmp", 0644);
250         if (fd < 0)
251                 exit (1);
252         area.l_type = F_WRLCK;
253         area.l_whence = SEEK_SET;
254         area.l_len = area.l_start = 0L;
255         if (fcntl(fd, F_SETLKW, &area))
256                 exit (1);
257         close (fd);
258         unlink ("config.tmp");
259         exit (0);
260 }
261 ],bits=64,bits=32,bits=32)
262 if test "$bits" = "64"; then
263         AC_DEFINE(_FILE_OFFSET_BITS,64)
264         AC_MSG_RESULT(yes)
265 else
266         AC_MSG_RESULT(no)
267 fi
268 AC_CHECK_SIZEOF([off_t])
269 AC_CHECK_SIZEOF([long long])
270 AC_CHECK_SIZEOF([long])
271 dnl ------ Modules
272 AC_SUBST(SHARED_MODULE_LA)
273 SHARED_MODULE_LA=""
274 AC_SUBST(STATIC_MODULE_OBJ)
275 STATIC_MODULE_OBJ=""
276 AC_SUBST(STATIC_MODULE_LADD)
277 STATIC_MODULE_LADD=""
278 AC_DEFUN([ZEBRA_MODULE],[
279         AC_ARG_ENABLE(mod-$1,[$3],[myen=$enableval],[myen=$2])
280         AC_MSG_CHECKING([for module $1])
281         if test "$myen" = "yes"; then
282            myen="shared" 
283         fi
284         if test "$enable_shared" != "yes"; then
285            if test "$myen" = "shared"; then
286               myen="static"
287            fi
288         fi
289         m=`echo $1|tr .- __`
290         if test "$myen" = "no"; then
291            AC_MSG_RESULT([disabled])
292         elif test "$2" = "disabled"; then
293            AC_MSG_RESULT([disabled])
294            AC_MSG_ERROR([Cannot enable mod-$1 because of missing libs (XML, etc)])
295         elif test "$myen" = "shared"; then
296            AC_MSG_RESULT([shared])
297            SHARED_MODULE_LA="${SHARED_MODULE_LA} mod-$1.la"
298         elif test "$myen" = "static" -o "$myen" = "yes"; then
299            AC_MSG_RESULT([static])
300            STATIC_MODULE_OBJ="${STATIC_MODULE_OBJ} \$(mod_${m}_la_OBJECTS)"
301            STATIC_MODULE_LADD="${STATIC_MODULE_LADD} \$(mod_${m}_la_LADD)"
302            modcpp=`echo $1|tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
303            AC_DEFINE_UNQUOTED([IDZEBRA_STATIC_$modcpp])
304         else
305            AC_MSG_RESULT([$myen])
306            AC_MSG_ERROR([invalid --enable-mod-$1 value. Use on,off,static or shared])
307         fi
308 ])
309
310 ZEBRA_MODULE(text,static,    [  --enable-mod-text       Text filter])
311 ZEBRA_MODULE(grs-sgml,static,[  --enable-mod-grs-sgml   Simple SGML/XML filter])
312 ZEBRA_MODULE(grs-regx,shared,[  --enable-mod-grs-regx   REGX/TCL filter])
313 ZEBRA_MODULE(grs-marc,shared,[  --enable-mod-grs-marc   MARC filter])
314 ZEBRA_MODULE(safari,shared,  [  --enable-mod-safari Safari filter (DBC)])
315 if test "$ac_cv_header_expat_h" = "yes"; then
316    def="shared"
317 else
318    def="disabled"
319 fi
320 ZEBRA_MODULE(grs-xml,[$def], [  --enable-mod-grs-xml    XML filter (Expat based)])
321 if test "$XSLT_VER"; then
322    def="shared"
323 else
324    def="disabled"
325 fi
326 ZEBRA_MODULE(alvis,[$def],   [  --enable-mod-alvis      ALVIS filter (Requires libxslt)])
327 dnl ------ ANSI C Header files
328 AC_STDC_HEADERS
329 if test "$ac_cv_header_stdc" = "no"; then
330         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
331 fi
332 AC_SUBST(IDZEBRA_SRC_ROOT)
333 AC_SUBST(IDZEBRA_BUILD_ROOT)
334 IDZEBRA_SRC_ROOT=`cd ${srcdir}; pwd`
335 IDZEBRA_BUILD_ROOT=`pwd`
336 dnl ------ Create Makefiles
337 AC_OUTPUT([
338   Makefile
339   util/Makefile
340   bfile/Makefile
341   dfa/Makefile
342   dict/Makefile
343   isamb/Makefile
344   isams/Makefile
345   isamc/Makefile
346   rset/Makefile
347   data1/Makefile
348   recctrl/Makefile
349   index/Makefile
350   include/Makefile include/idzebra/Makefile
351   tab/Makefile
352   doc/Makefile
353   doc/local.ent
354   doc/common/Makefile
355   doc/common/print.dsl
356   test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile
357   test/xslt/Makefile
358   test/xpath/Makefile
359   test/rusmarc/Makefile test/cddb/Makefile test/malxml/Makefile 
360   test/mbox/Makefile
361   test/config/Makefile test/sort2/Makefile
362   test/xelm/Makefile
363   test/dmoz/Makefile test/sort/Makefile test/zsh/Makefile
364   test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile
365   test/espec/Makefile
366   test/filters/Makefile
367   examples/Makefile examples/gils/Makefile examples/zthes/Makefile
368   examples/marc21/Makefile examples/marcxml/Makefile 
369   examples/alvis-oai/Makefile
370   idzebra.spec
371   idzebra-config
372   Doxyfile
373 ],[sed s%idzebra_echo_source=yes%idzebra_echo_source=no%g < idzebra-config > util/idzebra-config && chmod +x idzebra-config util/idzebra-config])
374
375
376 echo \ '
377 Build and install binaries with the usual
378   make
379   make check
380   make install
381
382 Build distribution tarball with
383   make dist
384
385 Verify distribution tarball with
386   make distcheck
387
388 Or just build the Debian packages without configuring
389   dpkg-buildpackage -rfakeroot
390 '
391
392 if test  -z "$YAZLIB"; then
393         echo "YAZ was not found. Use --with-yaz=DIR to specify location."
394         test -f /etc/debian_version && echo "Debian package libyaz-dev is required."
395 fi
396
397 echo \
398 "------------------------------------------------------------------------
399
400   ZEBRA Package:              ${PACKAGE}
401   ZEBRA Version:              ${VERSION}
402   Source code location:       ${srcdir}
403   C Preprocessor:             ${CPP}
404   C Preprocessor flags:       ${CPPFLAGS}
405   C Compiler:                 ${CC}
406   C Compiler flags:           ${CFLAGS}
407   Linker flags:               ${LDFLAGS}
408   Linked libs:                ${LIBS}
409   Host System Type:           ${host}
410   Install path:               ${prefix}
411   Automake:                   ${AUTOMAKE}
412   Archiver:                   ${AR}
413   Ranlib:                     ${RANLIB}
414   YAZ Version:                ${YAZVERSION}
415   YAZ Include:                ${YAZINC}
416   YAZ La Lib:                 ${YAZLALIB}
417   YAZ Lib:                    ${YAZLIB}
418   Bugreport:                  ${PACKAGE_BUGREPORT}
419
420 ------------------------------------------------------------------------"