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