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