Makefile updates for Automake 1.5+. Test script updates
[idzebra-moved-to-github.git] / configure.in
1 dnl Zebra, Index Data Aps, 1995-2003
2 dnl $Id: configure.in,v 1.78 2003-05-21 14:39:21 adam Exp $
3 dnl
4 AC_INIT(include/zebraver.h)
5 AM_INIT_AUTOMAKE(idzebra,1.3.11)
6 dnl ------ Substitutions
7 AC_SUBST(TCL_INCLUDE)
8 AC_SUBST(TCL_LIB)
9 AC_SUBST(READLINE_LIBS)
10 dnl ------ Perl substitutions
11 AC_SUBST(PERL_BINARY)
12 AC_SUBST(PERL_XS_INIT)
13 AC_SUBST(PERL_XS_INIT_INCLUDE)
14 AC_SUBST(PERL_LIBS)
15 AC_SUBST(PERL_CFLAGS)
16 AC_SUBST(ZPERL_LIBS)
17 dnl
18 dnl ------ Checking programs
19 AC_PROG_CC
20 AC_PROG_CPP
21 AC_PROG_INSTALL
22 AC_PROG_RANLIB
23 dnl
24 dnl ----- DOCBOOK DTD
25 AC_SUBST(DTD_DIR)
26 AC_ARG_WITH(dtd, [  --with-dtd[=DIR]        Use docbookx.dtd in DIR],
27 [
28    if test -f "$withval/docbookx.dtd"; then
29       DTD_DIR=$withval
30    fi
31 ],[
32    AC_MSG_CHECKING(for docbookx.dtd)
33    for d in /usr/share/sgml/docbook/dtd/xml/4.1.2 \
34          /usr/share/sgml/docbook/xml-dtd-4.1.2* \
35          /usr/share/sgml/docbook/xml-dtd-4.1 \
36          /usr/share/sgml/docbook/dtd/xml/4.0 \
37             /usr/lib/sgml/dtd/docbook-xml 
38    do
39      if test -f $d/docbookx.dtd; then
40        AC_MSG_RESULT($d)
41        DTD_DIR=$d
42        break
43      fi
44    done
45    if test -z "$DTD_DIR"; then
46       AC_MSG_RESULT(Not found)
47    fi
48 ])
49 AC_SUBST(DSSSL_DIR)
50 AC_ARG_WITH(dsssl,[  --with-dsssl[=DIR]      Use DSSSL in DIR/{html,print}/docbook.dsl],
51 [
52    if test -f "$withval/html/docbook.dsl"; then
53       DSSSL_DIR=$withval
54    fi
55 ],[
56    AC_MSG_CHECKING(for docbook.dsl)
57    for d in /usr/share/sgml/docbook/stylesheet/dsssl/modular \
58             /usr/share/sgml/docbook/dsssl-stylesheets-1.* \
59             /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh 
60    do
61      if test -f $d/html/docbook.dsl; then
62        AC_MSG_RESULT($d)
63        DSSSL_DIR=$d
64        break
65      fi
66    done
67    if test -z "$DSSSL_DIR"; then
68       AC_MSG_RESULT(Not found)
69    fi
70 ])
71 dnl
72 AC_ARG_ENABLE(threads, [  --disable-threads       disable threads],[enable_threads=$enableval],[enable_threads=yes])
73 if test "$enable_threads" = "yes"; then
74         AM_CONDITIONAL(ISTHR,true)
75         yazflag=threads
76 else
77         AM_CONDITIONAL(ISTHR,false)
78         yazflag=""
79 fi
80 YAZ_INIT($yazflag)
81
82 dnl ------ Look for Tcl
83 dnl See if user has specified location of tclConfig.sh; otherwise
84 dnl see if tclConfig.sh exists in same prefix lcoation as tclsh; otherwise
85 dnl disable Tcl.
86 TCL_LIB=""
87 TCL_INCLUDE=""
88 tclconfig=NONE
89 AC_ARG_WITH(tclconfig, [  --with-tclconfig=DIR    tclConfig.sh in DIR], [tclconfig=$withval])
90 if test "x$tclconfig" = xNONE; then
91         saveprefix=${prefix}
92         AC_PREFIX_PROGRAM(tclsh)
93         tclconfig=${prefix}/lib
94         prefix=${saveprefix}
95         if test ! -r ${tclconfig}/tclConfig.sh; then
96                 # Not found, try search for Tcl on Debian systems.
97                 for d in /usr/lib/tcl*; do
98                         if test -f $d/tclConfig.sh; then
99                                 tclconfig=$d
100                         fi
101                 done
102         fi
103 fi
104 AC_MSG_CHECKING(for Tcl)
105 if test -r ${tclconfig}/tclConfig.sh; then
106         . ${tclconfig}/tclConfig.sh
107         if test -r ${tclconfig}/../generic/tcl.h; then
108                 TCL_INCLUDE=-I${tclconfig}/../generic
109                 TCL_LIB="$TCL_BUILD_LIB_SPEC $TCL_LIBS"
110         elif test -d ${TCL_PREFIX}/include/tcl${TCL_VERSION}; then
111                 TCL_INCLUDE=-I${TCL_PREFIX}/include/tcl${TCL_VERSION}
112                 TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
113         else
114                 TCL_INCLUDE=-I${TCL_PREFIX}/include
115                 TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
116         fi
117         TCL_LIB=`echo $TCL_LIB|sed 's%-L/usr/lib%%g'`
118         SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
119         SHLIB_LD=$TCL_SHLIB_LD
120         SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
121         SHLIB_VERSION=$TCL_SHLIB_VERSION
122         AC_MSG_RESULT($TCL_VERSION)
123         AC_DEFINE(HAVE_TCL_H,1)
124 else
125         AC_MSG_RESULT(Not found)
126         AC_DEFINE(HAVE_TCL_H,0)
127 fi
128 dnl
129 dnl ------ times
130 AC_CHECK_HEADERS(sys/times.h)
131 dnl
132 dnl ------ mkstemp
133 AC_CHECK_FUNCS(mkstemp)
134 dnl
135 dnl ------ GNU Readline
136 READLINE_SHARED_LIBADD=""
137 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
138         AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
139 )
140 READLINE_LIBS=""
141 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
142 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
143 if test "$ac_cv_lib_readline_readline" = "yes"; then
144         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
145         xLIBS=$LIBS
146         LIBS="$LIBS $READLINE_LIBS"
147         AC_TRY_LINK([
148         #include <stdio.h>
149         #include <readline/readline.h>
150         ],[
151         static void f()
152         {
153                 rl_attempted_completion_over = 0;
154         }
155         ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
156         AC_TRY_LINK([
157         #include <stdio.h>
158         #include <readline/readline.h>
159         ],[
160         static void f()
161         {
162                 rl_completion_matches (0, 0);
163         }
164         ],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
165         LIBS=$xLIBS
166 fi
167 dnl
168 dnl ------ iconv
169 AC_ARG_WITH(iconv, [  --with-iconv[=DIR]      iconv library in DIR])
170 if test "$with_iconv" != "no"; then
171         AC_MSG_CHECKING(for iconv)
172         oldLIBS="$LIBS"
173         oldCPPFLAGS="${CPPFLAGS}"
174         if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
175                 LIBS="$LIBS -L${with_iconv}/lib"
176                 CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
177         fi
178         AC_TRY_LINK([
179                 #include <iconv.h>
180         ],[
181                 static void f() {iconv_t t = iconv_open("", ""); }
182         ],[
183                 AC_DEFINE(HAVE_ICONV_H)
184                 AC_MSG_RESULT(yes)
185         ],[
186                 LIBS="$LIBS -liconv"
187                 AC_TRY_LINK([
188                         #include <iconv.h>
189                 ],[
190                         static void f() {iconv_t t = iconv_open("", ""); }
191                 ],[
192                         AC_DEFINE(HAVE_ICONV_H)
193                         AC_MSG_RESULT(yes)
194                 ],[
195                         LIBS="$oldLIBS"
196                         CPPFLAGS="$oldCPPFLAGS"
197                         AC_MSG_RESULT(no)
198                 ])
199         ])
200 fi
201 dnl
202 dnl ------- BZIP2
203 AC_CHECK_LIB(bz2,bzCompressInit)
204 if test "$ac_cv_lib_bz2_bzCompressInit" = "yes"; then
205         AC_CHECK_HEADERS(bzlib.h)
206 else
207         AC_CHECK_LIB(bz2,BZ2_bzCompressInit)
208         if test "$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yes"; then
209                 AC_CHECK_HEADERS(bzlib.h)
210         fi
211 fi
212 dnl
213 dnl ------ -lm
214 AC_CHECK_LIB(m,sqrt)
215 dnl
216 dnl ------ EXPAT
217 expat=yes
218 AC_ARG_WITH(expat,   [  --with-expat[=DIR]      EXPAT library in DIR],[expat=$withval])
219 if test "$expat" != "no"; then
220         xLIBS="$LIBS";
221         xCFLAGS="$CFLAGS";
222         if test "$expat" != "yes"; then
223                 EXPAT_CFLAGS="-I$expat/include"
224                 EXPAT_LIBS="-L$expat/lib"
225                 CFLAGS="$EXPAT_CFLAGS $CFLAGS"
226                 LIBS="$EXPAT_LIBS $LIBS"
227         fi
228         AC_CHECK_LIB(expat,XML_ParserCreate,[LIBS="$LIBS -lexpat"])
229         if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
230                 AC_CHECK_HEADERS(expat.h)
231         else
232                 LIBS="$xLIBS"
233                 CFLAGS="$xCFLAGS"
234         fi
235 fi
236 dnl
237 dnl ------ PERL
238 AM_CONDITIONAL(perl,false)
239 perl=no
240 PERL_XS_INIT="NULL"
241 PERL_XS_INIT_INCLUDE=''
242 PERL_BINARY=""
243 AC_ARG_WITH(perl,   [  --with-perl[=FILE]      perl binary location],[perl=$withval])
244 if test "$perl" != "no"; then
245         AC_MSG_CHECKING(for perl binary)
246         if test "$perl" = "yes"; then
247             perlbin=`which perl`
248         else
249             perlbin="$perl"
250         fi 
251         if test -x "$perlbin"; then
252             AC_MSG_RESULT($perlbin)     
253             AC_MSG_CHECKING(perl core directory)
254             archdir=`$perlbin -MConfig -e 'print $Config{archlib}'`;
255             perlcore="$archdir/CORE";
256             if test -d "$perlcore"; then
257                 PERL_BINARY="$perlbin"
258                 AC_MSG_RESULT($perlcore)        
259             else
260                 AC_MSG_RESULT(Failed)   
261             fi
262
263             AC_MSG_CHECKING("for ExtUtils::Embed to determine ccopts")
264             PERL_CFLAGS=`$perlbin -MExtUtils::Embed -e ccopts 2>/dev/null`
265             if test "$PERL_CFLAGS"; then
266                 AC_MSG_RESULT(OK)       
267             else
268                 PERL_CFLAGS="-I$perlcore"
269                 AC_MSG_RESULT(Using defaults)   
270             fi
271
272             AC_MSG_CHECKING("for ExtUtils::Embed to determine ldflags")
273             PERL_LIBS=`$perlbin -MExtUtils::Embed -e ldopts 2>/dev/null`
274             if test "$PERL_LIBS"; then
275                 AC_MSG_RESULT(OK)       
276             else
277                 PERL_LIBS="-L$perlcore -lperl -lm"
278                 AC_MSG_RESULT(Using defaults)   
279             fi
280
281             AC_MSG_CHECKING("for ExtUtils::Embed to create xs_init")
282             xsf="recctrl/xsinit.h"
283             `rm $xsf 2>/dev/null`;
284
285             `$perlbin -MExtUtils::Embed -e xsinit -- -o $xsf 2>/dev/null`
286             if test -r "$xsf"; then
287                 AC_MSG_RESULT(OK)       
288                 PERL_XS_INIT="xs_init"
289                 PERL_XS_INIT_INCLUDE='#include "xsinit.h"'
290             else
291                 AC_MSG_RESULT(XS libraries are not going to be available)
292             fi
293
294             xLIBS="$LIBS"
295             xCFLAGS="$CFLAGS"
296             CFLAGS="$PERL_CFLAGS $CFLAGS"
297             LIBS="$PERL_LIBS $LIBS"
298
299             AC_MSG_CHECKING(for perl library)
300             AC_TRY_LINK([
301             #include <stdio.h>
302              ],[
303             static void f()
304             {
305                 ;
306             }
307                 ],AM_CONDITIONAL(perl,true)
308                   AC_DEFINE(HAVE_PERL,1)
309                   AC_MSG_RESULT(found)
310                   ZPERL_LIBS="$xLIBS"
311                         ,
312                   AC_MSG_RESULT(not found)
313                   AC_DEFINE(HAVE_PERL,0)
314                   LIBS="$xLIBS"
315                   CFLAGS="$xCFLAGS")
316         else
317             AC_DEFINE(HAVE_PERL,0)
318             AC_MSG_RESULT(Not found)
319         fi
320 fi
321 dnl ------- 64 bit files
322 AC_MSG_CHECKING(for LFS)
323 AC_TRY_RUN([#define _FILE_OFFSET_BITS 64
324 #include <sys/types.h>
325 #include <unistd.h>
326 #include <string.h>
327 #include <stdio.h>
328 #include <fcntl.h>
329 #include <errno.h>
330 int main(int argc, char **argv)
331 {
332         off_t o;
333         char tmp_str[32];
334         int fd;
335         struct flock area;
336         if (sizeof(off_t) != 8) 
337                 exit (1);
338         o = 2000000000;
339         sprintf (tmp_str, "%Ld", o+o+o);
340         if (strcmp (tmp_str, "6000000000"))
341                 exit (1);
342         fd = creat ("config.tmp", 0644);
343         if (fd < 0)
344                 exit (1);
345         area.l_type = F_WRLCK;
346         area.l_whence = SEEK_SET;
347         area.l_len = area.l_start = 0L;
348         if (fcntl(fd, F_SETLKW, &area))
349                 exit (1);
350         close (fd);
351         unlink ("config.tmp");
352         exit (0);
353 }
354 ],bits=64,bits=32,bits=32)
355 if test "$bits" = "64"; then
356         AC_DEFINE(_FILE_OFFSET_BITS,64)
357         AC_MSG_RESULT(yes)
358 else
359         AC_MSG_RESULT(no)
360 fi
361 dnl
362 dnl ------ ANSI C Header files
363 AC_STDC_HEADERS
364 if test "$ac_cv_header_stdc" = "no"; then
365         AC_MSG_WARN(Your system doesn't seem to support ANSI C)
366 fi
367 dnl ------ Create Makefiles
368 AC_OUTPUT([
369   Makefile
370   util/Makefile
371   bfile/Makefile
372   dfa/Makefile
373   dict/Makefile
374   isamb/Makefile
375   isams/Makefile
376   isamc/Makefile
377   isam/Makefile
378   rset/Makefile
379   data1/Makefile
380   recctrl/Makefile
381   recctrl/perlread.h
382   index/Makefile
383   include/Makefile
384   tab/Makefile
385   doc/Makefile
386   doc/zebra.xml
387   doc/zebrahtml.dsl
388   doc/zebraprint.dsl
389   doc/zebraphp.dsl
390   doc/tkl.xsl
391   test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile
392   test/rusmarc/Makefile test/cddb/Makefile
393   perl/Makefile.PL test/xelm/Makefile
394   test/dmoz/Makefile test/xpath/Makefile test/sort/Makefile
395   examples/Makefile examples/gils/Makefile examples/zthes/Makefile
396   idzebra.spec
397 ])
398 if test -x "$perlbin"; then
399         res=`cd perl ; $perlbin Makefile.PL ; cd .. ;`;
400 fi
401 if test  -z "$YAZLIB"; then
402         echo "YAZ was not found. Use --with-yazconfig=DIR to specify location."
403         test -f /etc/debian_version && echo "Debian package libyaz-dev is required."
404 fi
405