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