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