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