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