Version 2.0.2
[idzebra-moved-to-github.git] / configure.ac
1 dnl Zebra, Index Data ApS, 1995-2006
2 dnl $Id: configure.ac,v 1.29 2006-09-22 12:44:01 adam Exp $
3 dnl
4 AC_PREREQ(2.59)
5 AC_INIT([idzebra],[2.0.2],[adam@indexdata.dk])
6 AC_CONFIG_SRCDIR(configure.ac)
7 AC_CONFIG_AUX_DIR(config)
8 AM_INIT_AUTOMAKE([1.8])
9 PACKAGE_SUFFIX="-2.0"
10 AC_SUBST(PACKAGE_SUFFIX)
11 dnl http://www.gnu.org/software/libtool/manual.html#Versioning
12 ZEBRALIBS_VERSION_INFO=0:1:0
13 AC_SUBST(ZEBRALIBS_VERSION_INFO)
14 main_zebralib=index/libidzebra${PACKAGE_SUFFIX}.la
15 AC_SUBST(main_zebralib)
16 dnl ------ Substitutions
17 AC_SUBST(TCL_INCLUDE)
18 AC_SUBST(TCL_LIB)
19 AC_SUBST(READLINE_LIBS)
20 dnl
21 dnl ------ Checking programs
22 AC_PROG_CC
23 AC_PROG_CPP
24 AM_PROG_LIBTOOL
25 dnl
26 dnl ------ headers
27 AC_CHECK_HEADERS(sys/resource.h sys/times.h sys/time.h sys/wait.h unistd.h)
28 dnl ------ crypt
29 AC_CHECK_LIB(crypt, crypt)
30 if test "$ac_cv_lib_crypt_crypt" = "yes"; then
31     AC_CHECK_HEADERS(crypt.h)
32 fi
33 dnl
34 dnl ------ threads
35 AC_ARG_ENABLE(threads, [  --disable-threads       disable threads],[enable_threads=$enableval],[enable_threads=yes])
36 if test "$enable_threads" = "yes"; then
37     yazflag=threads
38 else
39     yazflag=""
40 fi
41 dnl
42 dnl ------ YAZ
43 YAZ_INIT($yazflag,2.1.20)
44 if test "$YAZVERSION" = "NONE"; then
45     AC_MSG_ERROR([YAZ development libraries required])
46 fi
47 YAZ_DOC
48 dnl ----- libXSLT
49 AC_SUBST(XSLT_LIBS)
50 AC_SUBST(XSLT_CFLAGS)
51 xsltdir=yes
52 AC_ARG_WITH(xslt,[[  --with-xslt[=PREFIX]    use libxslt in PREFIX]],xsltdir=$withval)
53 if test "$xsltdir" = "yes"; then
54     for d in /usr /usr/local; do
55         if test -x $d/bin/xslt-config; then
56             xsltdir=$d
57         fi
58     done
59 fi
60 if test "$xsltdir" != "no"; then
61     AC_MSG_CHECKING(for libXSLT)
62     
63     if test -x $xsltdir/bin/xslt-config; then
64         XSLT_VER=`$xsltdir/bin/xslt-config --version`
65         AC_MSG_RESULT($XSLT_VER)
66         have_xslt_version=`echo "$XSLT_VER" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
67         if test $have_xslt_version -lt 1001011; then
68             AC_MSG_WARN([libXSLT too old. Use 1.1.11 or later.])
69             XSLT_VER=""
70         else
71             XSLT_LIBS=`$xsltdir/bin/xslt-config --libs`
72             XSLT_CFLAGS=`$xsltdir/bin/xslt-config --cflags`
73             AC_DEFINE(HAVE_XSLT)
74         fi
75     else
76         AC_MSG_RESULT(Not found)
77     fi
78 fi
79 dnl ------ Look for Tcl
80 dnl See if user has specified location of tclConfig.sh; otherwise
81 dnl see if tclConfig.sh exists in same prefix lcoation as tclsh; otherwise
82 dnl disable Tcl.
83 TCL_LIB=""
84 TCL_INCLUDE=""
85 tclconfig=NONE
86 AC_ARG_WITH(tclconfig, [  --with-tclconfig=DIR    tclConfig.sh in DIR], [tclconfig=$withval])
87 if test "x$tclconfig" = xNONE; then
88     saveprefix=${prefix}
89     AC_PREFIX_PROGRAM(tclsh)
90     tclconfig=${prefix}/lib
91     prefix=${saveprefix}
92     if test ! -r ${tclconfig}/tclConfig.sh; then
93         # Not found, try search for Tcl on Debian systems.
94         for d in /usr/lib/tcl*; do
95             if test -f $d/tclConfig.sh; then
96                 tclconfig=$d
97             fi
98         done
99     fi
100 fi
101 AC_MSG_CHECKING(for Tcl)
102 if test -r ${tclconfig}/tclConfig.sh; then
103     . ${tclconfig}/tclConfig.sh
104     if test -r ${tclconfig}/../generic/tcl.h; then
105         TCL_INCLUDE=-I${tclconfig}/../generic
106         TCL_LIB="$TCL_BUILD_LIB_SPEC $TCL_LIBS"
107     elif test -d ${TCL_PREFIX}/include/tcl${TCL_VERSION}; then
108         TCL_INCLUDE=-I${TCL_PREFIX}/include/tcl${TCL_VERSION}
109         TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
110     else
111         TCL_INCLUDE=-I${TCL_PREFIX}/include
112         TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
113     fi
114     TCL_LIB=`echo $TCL_LIB|sed 's%-L/usr/lib%%g'`
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     
122     # The Mac OSX -framework causes problems with Libtool
123     # and dependancy libs.. so apply Tcl libs everywhere bug #461
124     case $host in
125         *-*-darwin*)
126             LIBS="$LIBS $TCL_LIB";
127             ;;
128     esac
129     
130 else
131     AC_MSG_RESULT(Not found)
132     AC_DEFINE(HAVE_TCL_H,0)
133 fi
134 dnl
135 dnl ------ various functions
136 AC_CHECK_FUNCS(mkstemp)
137 dnl
138 dnl ------ GNU Readline
139 READLINE_SHARED_LIBADD=""
140 AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
141     AC_CHECK_LIB(termcap, tgetent, [READLINE_SHARED_LIBADD="-ltermcap"])
142 )
143 READLINE_LIBS=""
144 AC_CHECK_LIB(readline, readline, [READLINE_LIBS="$READLINE_LIBS -lreadline $READLINE_SHARED_LIBADD"],,$READLINE_SHARED_LIBADD)
145 AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
146 if test "$ac_cv_lib_readline_readline" = "yes"; then
147     AC_CHECK_HEADERS(readline/readline.h readline/history.h)
148     xLIBS=$LIBS
149     LIBS="$LIBS $READLINE_LIBS"
150     AC_TRY_LINK([
151         #include <stdio.h>
152         #include <readline/readline.h>
153         ],[
154             rl_attempted_completion_over = 0;
155             ],AC_DEFINE(HAVE_READLINE_COMPLETION_OVER))
156     AC_TRY_LINK([
157         #include <stdio.h>
158         #include <readline/readline.h>
159             ],[
160             rl_completion_matches (0, 0);
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             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                     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 ------ -ldl
213 AC_CHECK_LIB(dl,dlopen)
214 dnl
215 dnl ------ EXPAT
216 expat=yes
217 AC_SUBST(EXPAT_LIBS)
218 AC_ARG_WITH(expat,   [  --with-expat[=DIR]        EXPAT library in DIR],[expat=$withval])
219 if test "$expat" != "no"; then
220     xLIBS="$LIBS";
221     xCFLAGS="$CFLAGS";
222     if test "$expat" != "yes"; then
223         EXPAT_CFLAGS="-I$expat/include"
224         EXPAT_LIBS="-L$expat/lib"
225         CFLAGS="$EXPAT_CFLAGS $CFLAGS"
226         LIBS="$EXPAT_LIBS $LIBS"
227     fi
228     AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="$EXPAT_LIBS -lexpat"])
229     if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
230                 AC_CHECK_HEADERS(expat.h)
231     fi
232     LIBS="$xLIBS"
233     CFLAGS="$xCFLAGS"
234 fi
235 dnl
236 dnl ------- 64 bit files
237 AC_MSG_CHECKING(for LFS)
238 AC_TRY_RUN([#define _FILE_OFFSET_BITS 64
239 #include <sys/types.h>
240 #include <unistd.h>
241 #include <string.h>
242 #include <stdio.h>
243 #include <fcntl.h>
244 #include <errno.h>
245 int main(int argc, char **argv)
246 {
247         off_t o;
248         char tmp_str[32];
249         int fd;
250         struct flock area;
251         if (sizeof(off_t) != 8) 
252                 exit (1);
253         o = 2000000000;
254         if ((o+o+o) / 3 != o)
255                 exit(1);
256         fd = creat ("config.tmp", 0644);
257         if (fd < 0)
258                 exit (1);
259         area.l_type = F_WRLCK;
260         area.l_whence = SEEK_SET;
261         area.l_len = area.l_start = 0L;
262         if (fcntl(fd, F_SETLKW, &area))
263                 exit (1);
264         close (fd);
265         unlink ("config.tmp");
266         exit (0);
267 }
268 ],bits=64,bits=32,bits=32)
269 if test "$bits" = "64"; then
270     AC_DEFINE(_FILE_OFFSET_BITS,64)
271     AC_MSG_RESULT(yes)
272 else
273     AC_MSG_RESULT(no)
274 fi
275 AC_CHECK_SIZEOF([off_t])
276 AC_CHECK_SIZEOF([long long])
277 AC_CHECK_SIZEOF([long])
278 dnl ------ Modules
279 AC_SUBST(SHARED_MODULE_LA)
280 SHARED_MODULE_LA=""
281 AC_SUBST(STATIC_MODULE_OBJ)
282 STATIC_MODULE_OBJ=""
283 AC_SUBST(STATIC_MODULE_LADD)
284 STATIC_MODULE_LADD=""
285 AC_DEFUN([ZEBRA_MODULE],[
286         AC_ARG_ENABLE(mod-$1,[$3],[myen=$enableval],[myen=$2])
287         AC_MSG_CHECKING([for module $1])
288         if test "$myen" = "yes"; then
289            myen="shared" 
290         fi
291         if test "$enable_shared" != "yes"; then
292             if test "$myen" = "shared"; then
293                 myen="static"
294             fi
295         fi
296         m=`echo $1|tr .- __`
297         if test "$myen" = "no" -o "$myen" = "disabled"; then
298             AC_MSG_RESULT([disabled])
299         elif test "$2" = "disabled"; then
300             AC_MSG_RESULT([disabled])
301             AC_MSG_ERROR([Cannot enable mod-$1 because of missing libs (XML, etc)])
302         elif test "$myen" = "shared"; then
303             AC_MSG_RESULT([shared])
304             SHARED_MODULE_LA="${SHARED_MODULE_LA} mod-$1.la"
305         elif test "$myen" = "static"; then
306             AC_MSG_RESULT([static])
307             STATIC_MODULE_OBJ="${STATIC_MODULE_OBJ} \$(mod_${m}_la_OBJECTS)"
308             STATIC_MODULE_LADD="${STATIC_MODULE_LADD} \$(mod_${m}_la_LADD)"
309             modcpp=`echo $1|tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
310             AC_DEFINE_UNQUOTED([IDZEBRA_STATIC_$modcpp])
311         else
312             AC_MSG_RESULT([$myen])
313             AC_MSG_ERROR([invalid --enable-mod-$1 value. Use on,off,static or shared])
314         fi
315         ])
316
317 ZEBRA_MODULE(text,static,    [  --enable-mod-text       Text filter])
318 ZEBRA_MODULE(grs-sgml,static,[  --enable-mod-grs-sgml   Simple SGML/XML filter])
319 ZEBRA_MODULE(grs-regx,shared,[  --enable-mod-grs-regx   REGX/TCL filter])
320 ZEBRA_MODULE(grs-marc,shared,[  --enable-mod-grs-marc   MARC filter])
321 ZEBRA_MODULE(safari,shared,  [  --enable-mod-safari Safari filter (DBC)])
322 if test "$ac_cv_header_expat_h" = "yes"; then
323     def="shared"
324 else
325     def="disabled"
326 fi
327 ZEBRA_MODULE(grs-xml,[$def], [  --enable-mod-grs-xml    XML filter (Expat based)])
328 if test "$XSLT_VER"; then
329     def="shared"
330 else
331     def="disabled"
332 fi
333 ZEBRA_MODULE(alvis,[$def],   [  --enable-mod-alvis      ALVIS filter (Requires libxslt)])
334 dnl ------ ANSI C Header files
335 AC_STDC_HEADERS
336 if test "$ac_cv_header_stdc" = "no"; then
337     AC_MSG_WARN(Your system doesn't seem to support ANSI C)
338 fi
339 AC_SUBST(IDZEBRA_SRC_ROOT)
340 AC_SUBST(IDZEBRA_BUILD_ROOT)
341 IDZEBRA_SRC_ROOT=`cd ${srcdir}; pwd`
342 IDZEBRA_BUILD_ROOT=`pwd`
343 dnl ------ Create Makefiles
344 AC_OUTPUT([
345   Makefile
346   util/Makefile
347   bfile/Makefile
348   dfa/Makefile
349   dict/Makefile
350   isamb/Makefile
351   isams/Makefile
352   isamc/Makefile
353   rset/Makefile
354   data1/Makefile
355   index/Makefile
356   include/Makefile include/idzebra/Makefile
357   tab/Makefile
358   doc/Makefile
359   doc/local.ent
360   doc/common/Makefile
361   doc/common/print.dsl
362   test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile
363   test/xslt/Makefile
364   test/xpath/Makefile
365   test/rusmarc/Makefile test/cddb/Makefile test/malxml/Makefile 
366   test/mbox/Makefile
367   test/config/Makefile test/sort2/Makefile
368   test/xelm/Makefile
369   test/dmoz/Makefile test/sort/Makefile test/zsh/Makefile
370   test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile
371   test/espec/Makefile
372   test/filters/Makefile
373   examples/Makefile examples/gils/Makefile examples/zthes/Makefile
374   examples/marc21/Makefile examples/marcxml/Makefile 
375   examples/alvis-oai/Makefile
376   idzebra.spec
377   idzebra-config-2.0
378   Doxyfile
379 ],[sed s%echo_source=yes%echo_source=no%g < idzebra-config-2.0 > util/idzebra-config-2.0 && chmod +x idzebra-config-2.0 util/idzebra-config-2.0])
380
381 echo \
382 "------------------------------------------------------------------------
383
384   ZEBRA Package:              ${PACKAGE}
385   ZEBRA Version:              ${VERSION}
386   Source code location:       ${srcdir}
387   C Preprocessor:             ${CPP}
388   C Preprocessor flags:       ${CPPFLAGS}
389   C Compiler:                 ${CC}
390   C Compiler flags:           ${CFLAGS}
391   Linker flags:               ${LDFLAGS}
392   Linked libs:                ${LIBS}
393   Host System Type:           ${host}
394   Install path:               ${prefix}
395   Automake:                   ${AUTOMAKE}
396   Archiver:                   ${AR}
397   Ranlib:                     ${RANLIB}
398   YAZ Version:                ${YAZVERSION}
399   YAZ Include:                ${YAZINC}
400   YAZ La Lib:                 ${YAZLALIB}
401   YAZ Lib:                    ${YAZLIB}
402   Bugreport:                  ${PACKAGE_BUGREPORT}
403
404 ------------------------------------------------------------------------"
405 dnl Local Variables:
406 dnl mode:shell-script
407 dnl sh-indentation:2
408 dnl sh-basic-offset: 4
409 dnl End: