Scan: allow preferred position > number + 1
[idzebra-moved-to-github.git] / configure.ac
1 dnl This file is part of the Zebra server.
2 dnl   Copyright (C) 1994-2011 Index Data
3 dnl
4 AC_PREREQ(2.60)
5 AC_INIT([idzebra],[2.0.48],[zebra-help@indexdata.dk])
6 AC_CONFIG_HEADERS([include/config.h])
7 AC_CONFIG_SRCDIR([configure.ac])
8 AC_CONFIG_AUX_DIR([config])
9 AM_INIT_AUTOMAKE([1.9])
10 PACKAGE_SUFFIX="-2.0"
11 AC_SUBST(PACKAGE_SUFFIX)
12 dnl http://www.gnu.org/software/libtool/manual.html#Versioning
13 ZEBRALIBS_VERSION_INFO=0:1:0
14 AC_SUBST([ZEBRALIBS_VERSION_INFO])
15 main_zebralib=index/libidzebra${PACKAGE_SUFFIX}.la
16 AC_SUBST(main_zebralib)
17 dnl ------ Substitutions
18 AC_SUBST([TCL_INCLUDE])
19 AC_SUBST([TCL_LIB])
20 AC_SUBST([ZEBRA_CFLAGS])
21 dnl
22 dnl ------ Checking programs
23 AC_PROG_CC
24 AC_PROG_CPP
25 AM_PROG_LIBTOOL
26 dnl
27 dnl ------ headers
28 AC_CHECK_HEADERS([sys/resource.h sys/time.h sys/wait.h sys/utsname.h unistd.h])
29 dnl ------ crypt
30 AC_CHECK_LIB([crypt],[crypt])
31 if test "$ac_cv_lib_crypt_crypt" = "yes"; then
32     AC_CHECK_HEADERS([crypt.h])
33 fi
34 dnl
35 dnl ------ YAZ
36 YAZ_INIT([server icu],[3.0.47])
37 if test "$YAZVERSION" = "NONE"; then
38     AC_MSG_ERROR([YAZ development libraries required])
39 fi
40 YAZ_DOC
41 dnl ------ Look for Tcl
42 dnl See if user has specified location of tclConfig.sh; otherwise
43 dnl see if tclConfig.sh exists in same prefix lcoation as tclsh; otherwise
44 dnl disable Tcl.
45 TCL_LIB=""
46 TCL_INCLUDE=""
47 tclconfig=NONE
48 AC_ARG_WITH(tclconfig, [  --with-tclconfig=DIR    tclConfig.sh in DIR], [tclconfig=$withval])
49 if test "x$tclconfig" = xNONE; then
50     saveprefix=${prefix}
51     AC_PREFIX_PROGRAM(tclsh)
52     tclconfig=${prefix}/lib
53     prefix=${saveprefix}
54     if test ! -r ${tclconfig}/tclConfig.sh; then
55         # Not found, try search for Tcl on Debian systems.
56         for d in /usr/lib/tcl*; do
57             if test -f $d/tclConfig.sh; then
58                 tclconfig=$d
59             fi
60         done
61     fi
62 fi
63 AC_MSG_CHECKING(for Tcl)
64 if test -r ${tclconfig}/tclConfig.sh; then
65     . ${tclconfig}/tclConfig.sh
66     if test -r ${tclconfig}/../generic/tcl.h; then
67         TCL_INCLUDE=-I${tclconfig}/../generic
68         TCL_LIB="$TCL_BUILD_LIB_SPEC $TCL_LIBS"
69     elif test -d ${TCL_PREFIX}/include/tcl${TCL_VERSION}; then
70         TCL_INCLUDE=-I${TCL_PREFIX}/include/tcl${TCL_VERSION}
71         TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
72     else
73         TCL_INCLUDE=-I${TCL_PREFIX}/include
74         TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS"
75     fi
76     TCL_LIB=`echo $TCL_LIB|sed 's%-L/usr/lib%%g'`
77     SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
78     SHLIB_LD=$TCL_SHLIB_LD
79     SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
80     SHLIB_VERSION=$TCL_SHLIB_VERSION
81     AC_MSG_RESULT($TCL_VERSION)
82
83     old_CPPFLAGS=$CPPFLAGS
84     CPPFLAGS="${TCL_INCLUDE} $CPPFLAGS"
85     AC_CHECK_HEADERS(tcl.h)
86     CPPFLAGS=${old_CPPFLAGS}
87
88     # The Mac OSX -framework causes problems with Libtool
89     # and dependancy libs.. so apply Tcl libs everywhere bug #461
90     case $host in
91         *-*-darwin*)
92             LIBS="$LIBS $TCL_LIB";
93             ;;
94     esac
95     
96 else
97     AC_MSG_RESULT(Not found)
98     AC_DEFINE(HAVE_TCL_H,0)
99 fi
100 dnl
101 dnl ------ various functions
102 AC_CHECK_FUNCS(mkstemp atoll)
103 dnl
104 dnl ------ iconv
105 AC_ARG_WITH(iconv, [  --with-iconv[=DIR]        iconv library in DIR])
106 if test "$with_iconv" != "no"; then
107     AC_MSG_CHECKING(for iconv)
108     oldLIBS="$LIBS"
109     oldCPPFLAGS="${CPPFLAGS}"
110     if test "$with_iconv" != "yes" -a "$with_iconv" != ""; then
111         LIBS="$LIBS -L${with_iconv}/lib"
112         CPPFLAGS="${CPPFLAGS} -I${with_iconv}/include"
113     fi
114     AC_TRY_LINK([
115                 #include <iconv.h>
116             ],[
117             iconv_t t = iconv_open("", "");
118             ],[
119             AC_DEFINE([HAVE_ICONV_H],[1],[Whether iconv.h is defined])
120             AC_MSG_RESULT(yes)
121             ],[
122             LIBS="$LIBS -liconv"
123             AC_TRY_LINK([
124                         #include <iconv.h>
125                     ],[
126                     iconv_t t = iconv_open("", "");
127                     ],[
128                     AC_DEFINE([HAVE_ICONV_H],[1])
129                     AC_MSG_RESULT(yes)
130                     ],[
131                     LIBS="$oldLIBS"
132                     CPPFLAGS="$oldCPPFLAGS"
133                     AC_MSG_RESULT(no)
134                     ])
135             ])
136 fi
137 dnl
138 dnl ------- BZIP2
139 AC_CHECK_LIB(bz2,bzCompressInit)
140 if test "$ac_cv_lib_bz2_bzCompressInit" = "yes"; then
141     AC_CHECK_HEADERS(bzlib.h)
142 else
143     AC_CHECK_LIB(bz2,BZ2_bzCompressInit)
144     if test "$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yes"; then
145         AC_CHECK_HEADERS(bzlib.h)
146     fi
147 fi
148 dnl
149 dnl ------- zlib
150 AC_CHECK_LIB([z],[compress2])
151 if test "$ac_cv_lib_z_compress2" = "yes"; then
152     AC_CHECK_HEADERS([zlib.h])
153 fi
154 dnl ------ -lm
155 AC_CHECK_LIB([m], [sqrt])
156 dnl ------ -ldl
157 AC_CHECK_LIB([dl], [dlopen])
158 dnl
159 dnl ------ EXPAT
160 expat=yes
161 AC_SUBST([EXPAT_LIBS])
162 AC_ARG_WITH(expat,   [  --with-expat[=DIR]        EXPAT library in DIR],[expat=$withval])
163 if test "$expat" != "no"; then
164     xLIBS="$LIBS";
165     xCFLAGS="$CFLAGS";
166     if test "$expat" != "yes"; then
167         EXPAT_CFLAGS="-I$expat/include"
168         EXPAT_LIBS="-L$expat/lib"
169         CFLAGS="$EXPAT_CFLAGS $CFLAGS"
170         LIBS="$EXPAT_LIBS $LIBS"
171     fi
172     AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="$EXPAT_LIBS -lexpat"])
173     if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
174                 AC_CHECK_HEADERS(expat.h)
175     fi
176     LIBS="$xLIBS"
177     CFLAGS="$xCFLAGS"
178 fi
179 dnl
180 dnl ------- 64 bit files
181 AC_SYS_LARGEFILE
182 AC_CHECK_TYPES([long long])
183 if test "${ac_cv_type_long_long}" = "yes"; then
184     ZINT_VALUE=1
185 else
186     ZINT_VALUE=0
187 fi 
188 ZEBRA_CFLAGS="-DZEBRA_ZINT=${ZINT_VALUE}"
189 AC_DEFINE_UNQUOTED([ZEBRA_ZINT],${ZINT_VALUE},[Whehter zint is long long])
190 dnl ------ Modules
191 AC_SUBST([SHARED_MODULE_LA])
192 SHARED_MODULE_LA=""
193 AC_SUBST([STATIC_MODULE_OBJ])
194 STATIC_MODULE_OBJ=""
195 AC_SUBST([STATIC_MODULE_LADD])
196 STATIC_MODULE_LADD=""
197 AC_DEFUN([ZEBRA_MODULE],[
198         AC_ARG_ENABLE(mod-$1,[$3],[myen=$enableval],[myen=$2])
199         AC_MSG_CHECKING([for module $1])
200         if test "$myen" = "yes"; then
201            myen="shared" 
202         fi
203         if test "$enable_shared" != "yes"; then
204             if test "$myen" = "shared"; then
205                 myen="static"
206             fi
207         fi
208         m=`echo $1|tr .- __`
209         if test "$myen" = "no" -o "$myen" = "disabled"; then
210             AC_MSG_RESULT([disabled])
211         elif test "$2" = "disabled"; then
212             AC_MSG_RESULT([disabled])
213             AC_MSG_ERROR([Cannot enable mod-$1 because of missing libs (XML, etc)])
214         elif test "$myen" = "shared"; then
215             AC_MSG_RESULT([shared])
216             SHARED_MODULE_LA="${SHARED_MODULE_LA} mod-$1.la"
217         elif test "$myen" = "static"; then
218             AC_MSG_RESULT([static])
219             STATIC_MODULE_OBJ="${STATIC_MODULE_OBJ} \$(mod_${m}_la_OBJECTS)"
220             STATIC_MODULE_LADD="${STATIC_MODULE_LADD} \$(mod_${m}_la_LADD)"
221             modcpp=`echo $1|tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
222             AC_DEFINE_UNQUOTED([IDZEBRA_STATIC_$modcpp])
223         else
224             AC_MSG_RESULT([$myen])
225             AC_MSG_ERROR([invalid --enable-mod-$1 value. Use on,off,static or shared])
226         fi
227         ])
228
229 AC_DEFINE([IDZEBRA_STATIC_GRS_SGML],[1],[Whether module grs.sgml is static])
230 AC_DEFINE([IDZEBRA_STATIC_TEXT],[0],[Whether module text is static])
231 ZEBRA_MODULE(text,shared,    [  --enable-mod-text       Text filter])
232 AC_DEFINE([IDZEBRA_STATIC_GRS_REGX],[0],[Whether module grs.regx is static])
233 ZEBRA_MODULE(grs-regx,shared,[  --enable-mod-grs-regx   REGX/TCL filter])
234 AC_DEFINE([IDZEBRA_STATIC_GRS_MARC],[0],[Whether module grs.marc is static])
235 ZEBRA_MODULE(grs-marc,shared,[  --enable-mod-grs-marc   MARC filter])
236 if test "$ac_cv_header_expat_h" = "yes"; then
237     def="shared"
238 else
239     def="disabled"
240 fi
241 AC_DEFINE([IDZEBRA_STATIC_GRS_XML],[0],[Whether module grs.xml is static])
242 ZEBRA_MODULE(grs-xml,[$def], [  --enable-mod-grs-xml    XML filter (Expat based)])
243 oldCPPFLAGS="$CPPFLAGS"
244 CPPFLAGS="$CPPFLAGS $YAZINC"
245 AC_PREPROC_IFELSE(
246    [AC_LANG_PROGRAM([[
247 #if YAZ_HAVE_XML2
248 #include <libxml/xmlversion.h>
249 #include <libxml/parser.h>
250 #include <libxml/tree.h>
251 #include <libxml/xmlIO.h>
252 #include <libxslt/transform.h>
253 #include <libxslt/xsltutils.h>
254 #else
255 #error Libxml2 not available
256 #endif
257 ]],[[
258 #if LIBXML_VERSION < 20615
259 #error Libxml2 version < 2.6.15. xmlreader not reliable/present
260 #endif
261 ]])],
262    [def="shared"],
263    [def="disabled"])
264 CPPFLAGS=$oldCPPFLAGS
265 AC_DEFINE([IDZEBRA_STATIC_DOM],[0],[Whether module dom is static])
266 ZEBRA_MODULE(dom,[$def],   [  --enable-mod-dom        XML/XSLT filter (Requires libxslt)])
267 AC_DEFINE([IDZEBRA_STATIC_ALVIS],[0],[Whether module alvis is static])
268 ZEBRA_MODULE(alvis,[$def], [  --enable-mod-alvis      ALVIS filter (Requires libxslt)])
269 AC_DEFINE([IDZEBRA_STATIC_SAFARI],[0],[Whether module safari is static])
270 ZEBRA_MODULE(safari,shared,[  --enable-mod-safari     Safari filter (DBC)])
271
272 dnl ------ ANSI C Header files
273 AC_STDC_HEADERS
274 if test "$ac_cv_header_stdc" = "no"; then
275     AC_MSG_WARN([Your system does not seem to support ANSI C])
276 fi
277 AC_SUBST([IDZEBRA_SRC_ROOT])
278 AC_SUBST([IDZEBRA_BUILD_ROOT])
279 IDZEBRA_SRC_ROOT=`cd ${srcdir}; pwd`
280 IDZEBRA_BUILD_ROOT=`pwd`
281 dnl
282 dnl ------ versioning
283 dnl
284 WIN_FILEVERSION=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { m = $4; printf("%d,%d,%d,%d", $1, $2, $3 == "" ? "0" : $3, $4 == "" ? "1" : $4);}'`
285 AC_SUBST([WIN_FILEVERSION])
286 VERSION_HEX=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { printf("%x", ($1 * 256 + $2) * 256 + $3);}'`
287 AC_SUBST([VERSION_HEX])
288 if test -d ${srcdir}/.git; then
289     VERSION_SHA1=`git show --pretty=format:%H|head -1`
290 else
291     VERSION_SHA1=`head -1 ${srcdir}/ChangeLog|awk '{print $2}'`
292 fi
293 AC_SUBST([VERSION_SHA1])
294 dnl
295 dnl ------ Create Makefiles
296 dnl
297 AC_OUTPUT([
298   Makefile
299   util/Makefile
300   bfile/Makefile
301   dfa/Makefile
302   dict/Makefile
303   isamb/Makefile
304   isams/Makefile
305   isamc/Makefile
306   rset/Makefile
307   data1/Makefile
308   index/Makefile
309   include/Makefile include/idzebra/Makefile
310   tab/Makefile
311   doc/Makefile
312   doc/local.ent
313   doc/common/Makefile
314   doc/common/print.dsl
315   test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile
316   test/xslt/Makefile
317   test/xpath/Makefile
318   test/rusmarc/Makefile test/cddb/Makefile test/malxml/Makefile 
319   test/mbox/Makefile
320   test/config/Makefile
321   test/dmoz/Makefile test/zsh/Makefile
322   test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile
323   test/espec/Makefile
324   test/filters/Makefile
325   examples/Makefile 
326   examples/gils/Makefile 
327   examples/marc21/Makefile 
328   examples/marcxml/Makefile 
329   examples/oai-pmh/Makefile
330   examples/zthes/Makefile
331   idzebra-config-2.0
332   Doxyfile
333   win/version.nsi
334   include/idzebra/version.h
335 ],[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])
336
337 echo \
338 "------------------------------------------------------------------------
339
340   ZEBRA Package:              ${PACKAGE}
341   ZEBRA Version:              ${VERSION}
342   Source code location:       ${srcdir}
343   C Preprocessor:             ${CPP}
344   C Preprocessor flags:       ${CPPFLAGS}
345   C Compiler:                 ${CC}
346   C Compiler flags:           ${CFLAGS}
347   Linker flags:               ${LDFLAGS}
348   Linked libs:                ${LIBS}
349   Host System Type:           ${host}
350   Install path:               ${prefix}
351   Automake:                   ${AUTOMAKE}
352   Archiver:                   ${AR}
353   Ranlib:                     ${RANLIB}
354   YAZ Version:                ${YAZVERSION}
355   YAZ Include:                ${YAZINC}
356   YAZ La Lib:                 ${YAZLALIB}
357   YAZ Lib:                    ${YAZLIB}
358   Bugreport:                  ${PACKAGE_BUGREPORT}
359
360 ------------------------------------------------------------------------"
361 dnl Local Variables:
362 dnl mode:shell-script
363 dnl sh-indentation:2
364 dnl sh-basic-offset: 4
365 dnl End: