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