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