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