added makefile entry fro examples/marcxml
[idzebra-moved-to-github.git] / configure.ac
1 dnl Zebra, Index Data ApS, 1995-2006
2 dnl $Id: configure.ac,v 1.13 2006-06-12 09:27:00 marc Exp $
3 dnl
4 AC_PREREQ(2.59)
5 AC_INIT([idzebra],[1.4.0],[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" = "shared"; then
291            AC_MSG_RESULT([shared])
292            SHARED_MODULE_LA="${SHARED_MODULE_LA} mod-$1.la"
293         elif test "$myen" = "static" -o "$myen" = "yes"; then
294            AC_MSG_RESULT([static])
295            STATIC_MODULE_OBJ="${STATIC_MODULE_OBJ} \$(mod_${m}_la_OBJECTS)"
296            STATIC_MODULE_LADD="${STATIC_MODULE_LADD} \$(mod_${m}_la_LADD)"
297            modcpp=`echo $1|tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
298            AC_DEFINE_UNQUOTED([IDZEBRA_STATIC_$modcpp])
299         elif test "$myen" = "no"; then
300            AC_MSG_RESULT([disabled])
301         else
302            AC_MSG_RESULT([$myen])
303            AC_MSG_ERROR([invalid --enable-mod-$1 value. Use on,off,static or shared])
304         fi
305 ])
306
307 ZEBRA_MODULE(text,static,    [  --enable-mod-text       Text filter])
308 ZEBRA_MODULE(grs-sgml,static,[  --enable-mod-grs-sgml   Simple SGML/XML filter])
309 ZEBRA_MODULE(grs-regx,shared,[  --enable-mod-grs-regx   REGX/TCL filter])
310 ZEBRA_MODULE(grs-marc,shared,[  --enable-mod-grs-marc   MARC filter])
311 ZEBRA_MODULE(safari,shared,  [  --enable-mod-safari Safari filter (DBC)])
312 if test "$ac_cv_header_expat_h" = "yes"; then
313    def="shared"
314 else
315    def="no"
316 fi
317 ZEBRA_MODULE(grs-xml,[$def], [  --enable-mod-grs-xml    XML filter (Expat based)])
318 if test "$XSLT_VER"; then
319    def="shared"
320 else
321    def="no"
322 fi
323 ZEBRA_MODULE(alvis,[$def],   [  --enable-mod-alvis      ALVIS filter])
324 dnl ------ ANSI C Header files
325 AC_STDC_HEADERS
326 if test "$ac_cv_header_stdc" = "no"; then
327         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
328 fi
329 AC_SUBST(IDZEBRA_SRC_ROOT)
330 AC_SUBST(IDZEBRA_BUILD_ROOT)
331 IDZEBRA_SRC_ROOT=`cd ${srcdir}; pwd`
332 IDZEBRA_BUILD_ROOT=`pwd`
333 dnl ------ Create Makefiles
334 AC_OUTPUT([
335   Makefile
336   util/Makefile
337   bfile/Makefile
338   dfa/Makefile
339   dict/Makefile
340   isamb/Makefile
341   isams/Makefile
342   isamc/Makefile
343   rset/Makefile
344   data1/Makefile
345   recctrl/Makefile
346   index/Makefile
347   include/Makefile include/idzebra/Makefile
348   tab/Makefile
349   doc/Makefile
350   doc/local.ent
351   doc/common/Makefile
352   doc/common/print.dsl
353   test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile
354   test/xslt/Makefile
355   test/xpath/Makefile
356   test/rusmarc/Makefile test/cddb/Makefile test/malxml/Makefile 
357   test/mbox/Makefile
358   test/config/Makefile test/sort2/Makefile
359   test/xelm/Makefile
360   test/dmoz/Makefile test/sort/Makefile test/zsh/Makefile
361   test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile
362   test/espec/Makefile
363   test/filters/Makefile
364   examples/Makefile examples/gils/Makefile examples/zthes/Makefile
365   examples/marc21/Makefile examples/marcxml/Makefile 
366   examples/alvis-oai/Makefile
367   idzebra.spec
368   idzebra-config
369   Doxyfile
370 ],[sed s%idzebra_echo_source=yes%idzebra_echo_source=no%g < idzebra-config > util/idzebra-config && chmod +x idzebra-config util/idzebra-config])
371
372
373 echo \ '
374 Build and install binaries with the usual
375   make
376   make check
377   make install
378
379 Build distribution tarball with
380   make dist
381
382 Verify distribution tarball with
383   make distcheck
384
385 Or just build the Debian packages without configuring
386   dpkg-buildpackage -rfakeroot
387 '
388
389 if test  -z "$YAZLIB"; then
390         echo "YAZ was not found. Use --with-yaz=DIR to specify location."
391         test -f /etc/debian_version && echo "Debian package libyaz-dev is required."
392 fi
393
394 echo \
395 "------------------------------------------------------------------------
396
397   ZEBRA Package:              ${PACKAGE}
398   ZEBRA Version:              ${VERSION}
399   Source code location:       ${srcdir}
400   C Preprocessor:             ${CPP}
401   C Preprocessor flags:       ${CPPFLAGS}
402   C Compiler:                 ${CC}
403   C Compiler flags:           ${CFLAGS}
404   Linker flags:               ${LDFLAGS}
405   Linked libs:                ${LIBS}
406   Host System Type:           ${host}
407   Install path:               ${prefix}
408   Automake:                   ${AUTOMAKE}
409   Archiver:                   ${AR}
410   Ranlib:                     ${RANLIB}
411   YAZ Version:                ${YAZVERSION}
412   YAZ Include:                ${YAZINC}
413   YAZ La Lib:                 ${YAZLALIB}
414   YAZ Lib:                    ${YAZLIB}
415   Bugreport:                  ${PACKAGE_BUGREPORT}
416
417 ------------------------------------------------------------------------"