2 dnl The contents of this file are subject to the Mozilla Public
3 dnl License Version 1.1 (the "License"); you may not use this file
4 dnl except in compliance with the License. You may obtain a copy of
5 dnl the License at http://www.mozilla.org/MPL/
7 dnl Software distributed under the License is distributed on an "AS
8 dnl IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 dnl implied. See the License for the specific language governing
10 dnl rights and limitations under the License.
12 dnl The Original Code is the Charlie project.
14 dnl The Initial Developer of the Original Code is Ginger Alliance Ltd.
15 dnl Portions created by Ginger Alliance are
16 dnl Copyright (C) 1999-2002 Ginger Alliance Ltd.
17 dnl All Rights Reserved.
21 dnl Alternatively, the contents of this file may be used under the
22 dnl terms of the GNU General Public License Version 2 or later (the
23 dnl "GPL"), in which case the provisions of the GPL are applicable
24 dnl instead of those above. If you wish to allow use of your
25 dnl version of this file only under the terms of the GPL and not to
26 dnl allow others to use your version of this file under the MPL,
27 dnl indicate your decision by deleting the provisions above and
28 dnl replace them with the notice and other provisions required by
29 dnl the GPL. If you do not delete the provisions above, a recipient
30 dnl may use your version of this file under either the MPL or the
39 dnl --------------------------------------------------
40 dnl common initialization stuff
41 dnl !!! keep synchronized with other files !!!
42 dnl vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
44 dnl for better portability we need higher version of autoconf
45 dnl on most platforms it may work w/ lower version number
47 AC_CONFIG_AUX_DIR(tools)
49 AM_INIT_AUTOMAKE($PKG_NAME, $PKG_VERSION, 'z')
50 AM_CONFIG_HEADER( autocfg/config.h:autocfg/config.h.in )
60 AC_PROG_CXX($EXTRA_CXX)
64 dnl default no warnings
66 AC_ARG_ENABLE(warnings,
67 [ --enable-warnings display all warning while compiling])
68 if test -z "$enable_warnings"; then
71 if test x$enable_warnings != xno; then
72 CXXWARNING_FLAGS='-Wall -W -Winline -Wno-unused-parameter'
73 AC_MSG_CHECKING([Whether $CXX accepts -Wno-unused-parameter])
74 old_cxxflags="$CXXFLAGS"
75 CXXFLAGS="$old_cxxflags $CXXWARNING_FLAGS"
76 AC_TRY_COMPILE([ ], [return 0;], [AC_MSG_RESULT(yes)],
78 CXXWARNING_FLAGS="-Wall -W -Winline"
80 CXXFLAGS="$old_cxxflags"
82 AC_SUBST(CXXWARNING_FLAGS)
84 AC_ARG_ENABLE(abort-on-error,
85 [ --enable-abort-on-error abort processor on XSLT error],
86 AC_DEFINE(SABLOT_ABORT_ON_ERROR, 1,
87 [abort on XSLT error]))
89 AC_ARG_ENABLE(adding-meta,
90 [ --disable-adding-meta do not output the META html tag])
91 if test x$enable_adding_meta = xno; then
92 AC_DEFINE(SABLOT_DISABLE_ADDING_META, 1,
93 [define if don't want to generate the META html tag])
96 AC_ARG_ENABLE(document-errors,
97 [ --disable-document-errors ignore errors in the document() function])
98 if test x$enable_document_errors = xno; then
99 AC_DEFINE(SABLOT_DISABLE_DOC_ERRORS, 1,
100 [define if don't want to produce errors in the document() function])
103 AC_ARG_ENABLE(javascript,
104 [ --enable-javascript enable JavaScript extensions (e.g. exslt.org)])
105 if test x$enable_javascript = xyes; then
107 AC_DEFINE(ENABLE_JS, 1, [define, whether to build the JS extension])
111 AC_ARG_WITH(js-prefix,
112 [ --with-js-prefix=DIR set alternate JavaScript prefix],
113 [if test -x $withval ; then
114 #on Redhat js header files are in include/js
115 if test -x $withval/include/js ; then
116 CFLAGS="$CFLAGS -I$withval/include/js"
117 CXXFLAGS="$CXXFLAGS -I$withval/include/js"
118 CPPFLAGS="$CPPFLAGS -I$withval/include/js"
120 if test -x $withval/include ; then
121 CFLAGS="$CFLAGS -I$withval/include"
122 CPPFLAGS="$CPPFLAGS -I$withval/include"
123 CXXFLAGS="$CXXFLAGS -I$withval/include"
125 AC_MSG_ERROR([prefix for JavaScript not valid (include dir)])
128 if test -x $withval/lib ; then
129 LDFLAGS="$LDFLAGS -L$withval/lib"
131 AC_MSG_ERROR([prefix for JavaScript library invalid (libdir)])
134 AC_MSG_ERROR([prefix for JavaScript library invalid (not a directory)])
139 dnl make it easier to link with expat and iconv
140 AC_ARG_WITH(expat-prefix,
141 [ --with-expat-prefix=DIR set alternate expat prefix],
142 [if test -x $withval ; then
143 if test -x $withval/include ; then
144 CFLAGS="$CFLAGS -I$withval/include"
145 CPPFLAGS="$CPPFLAGS -I$withval/include"
146 CXXFLAGS="$CXXFLAGS -I$withval/include"
148 AC_MSG_ERROR([prefix for Expat not valid (include dir)])
150 if test -x $withval/lib ; then
151 LDFLAGS="$LDFLAGS -L$withval/lib"
153 AC_MSG_ERROR([prefix for Expat library invalid (libdir)])
156 AC_MSG_ERROR([prefix for Expat library invalid (not a directory)])
161 AC_ARG_WITH(iconv-prefix,
162 [ --with-iconv-prefix=DIR set alternate iconv prefix],
163 [if test -x $withval ; then
164 if test -x $withval/include ; then
165 CFLAGS="$CFLAGS -I$withval/include"
166 CXXFLAGS="$CXXFLAGS -I$withval/include"
167 CPPFLAGS="$CPPFLAGS -I$withval/include"
169 AC_MSG_ERROR([prefix for Iconv not valid (include dir)])
171 if test -x $withval/lib ; then
172 LDFLAGS="$LDFLAGS -L$withval/lib"
174 AC_MSG_ERROR([prefix for Iconv library invalid (libdir)])
177 AC_MSG_ERROR([prefix for Iconv library invalid (not a directory)])
182 dnl PH removed this to keep the compatibility with pre 2.5 autoconf
183 dnl AC_ARG_VAR(PERL, [
184 dnl path to perl binary to be used in various scripts
185 dnl to build documentation])
187 dnl environment PERL_PROG is used instead
190 [ --with-perl=PATH use perl binary to install apidocs],
191 [if test -x $withval ; then
192 AC_MSG_CHECKING([perl version of $withval])
193 perlv=`$withval -v | sed -n -e "s%^This is perl, v\(ersion \)\?\(5.*\) built.*$%\2%p"`
194 if test -z "$perlv" ; then
195 AC_MSG_ERROR([You need to provide a path to perl 5])
197 AC_MSG_RESULT([$perlv ok])
198 AC_SUBST(PERL_PROG, [$withval])
201 AC_MSG_ERROR([Perl $withval is not executable])
204 [AC_PATH_PROG([PERL_PROG], [perl], [/usr/bin/perl])]
206 AC_MSG_CHECKING([XML::Parser perl module])
207 PERL_SOURCE='eval { require XML::Parser; }; print "yes" unless $@; '
208 BUILD_APIDOCS=`echo $PERL_SOURCE | $PERL_PROG`
209 if test "x$BUILD_APIDOCS" = "xyes"; then
212 AC_MSG_RESULT([no: documentation requires XML::Parser module and will not be built.])
214 AC_SUBST([BUILD_APIDOCS])
217 AC_ARG_WITH(html-dir,
218 [ --with-html-dir=DIR path to install HTML documentation (defaults to docdir)],
219 [AC_MSG_CHECKING([html dir])
221 if test -x $withval ; then
223 AC_MSG_RESULT($withval)
226 AC_MSG_WARN([Directory $withval does not exist and will be created])
229 [if test "x$BUILD_APIDOCS" = "xyes"; then
230 AC_MSG_NOTICE([Setting html dir to $datadir/doc/html])
231 HTML_DIR=$datadir/doc/html
237 AC_ARG_ENABLE(perlconnect,
238 [ --enable-perlconnect enable JS engine perlconnect)])
239 if test x$enable_perlconnect = xyes; then
240 perlconnect_enabled=1
242 perlconnect_enabled=0
245 AC_ARG_ENABLE(iconv-typecast,
246 [ --enable-iconv-typecast typecast the second parameter of iconv to char**])
247 if test x$enable_iconv_typecast = xyes; then
248 force_iconv_typecast=1
251 AC_ARG_ENABLE(check-leaks,
252 [ --enable-check-leaks enable memory leak checking (optional)])
253 if test x$enable_check_leaks = xyes; then
254 AC_DEFINE(CHECK_LEAKS, 1, [define whether to check for memory leaks])
259 [ --disable-dom disable the DOM interface (smaller)],
260 __dom_given=1, __dom_given=0)
263 if test x$__dom_given = x1; then
264 if test x$enable_dom = xyes; then
265 AC_DEFINE(ENABLE_DOM, 1, [define if we want to publish the DOM interface])
268 AC_DEFINE(DISABLE_DOM, 1,
269 [define if we want to supress the DOM interface (needed in sdom.h)])
272 AC_DEFINE(ENABLE_DOM, 1, [define if we want to publish the DOM interface])
277 if test x$enable_javascript = xyes -a x$__has_dom = x0; then
278 AC_MSG_ERROR(--disable-dom must not be specified with --enable-javascript)
283 dnl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
284 dnl end of initialization stuff
285 dnl --------------------------------------------------
287 dnl --------------------------------------------------
288 dnl miscellaneous - initial
289 dnl vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
291 dnl here we collect needed libraries
294 AC_MSG_CHECKING(whether to build under GPL)
295 if test ! x$SABLOT_GPL = 'x'; then
296 AC_DEFINE(SABLOT_GPL, 1, [define if we want to build under GPL])
304 AC_MSG_CHECKING(whether to build the debugger)
305 AC_ARG_ENABLE(debugger,
306 [ --enable-debugger enable xslt debugger])
307 if test x$enable_debugger = xyes; then
309 AC_DEFINE(SABLOT_DEBUGGER, 1, [define if we want to build the debugger])
310 AC_ARG_WITH(readline,
311 [ --with-readline use the GNU readline in the debugger],
313 if test x$userl = x1; then
314 if test x$SABLOT_GPL = 'x'; then
315 AC_MSG_ERROR(you must compile under GNU's GPL to use the debugger)
317 AC_CHECK_LIB(ncurses, initscr,
318 [__rllib=-lncurses; OTHER_LIBS="$OTHER_LIBS -lncurses"],
321 AC_CHECK_LIB(readline, readline, [OTHER_LIBS="$OTHER_LIBS -lreadline"],
323 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
326 dnl EMACS_SITE_LISP='undefined'
327 dnl AC_CHECK_PROG(has_emacs, emacs, yes, no)
328 dnl if test $has_emacs = yes; then
329 dnl EMACS_SITE_LISP=`emacs --batch --load=emacs/config.el --funcall=find-path`
331 dnl AC_SUBST(EMACS_SITE_LISP)
338 dnl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
339 dnl end of miscellaneous - initial
340 dnl --------------------------------------------------
342 dnl --------------------------------------------------
343 dnl Expat stuff - keep in sysc
344 dnl vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
346 dnl check for presence of the new Expat library
347 AC_MSG_CHECKING(where to find xml parser)
348 dnl steal the output descriptor
351 AC_CHECK_LIB(expat, XML_Parse, [xmle=1; EXPAT_LIBS=-lexpat], xmle=0)
353 if test $xmle = 0; then
354 AC_CHECK_LIB(xmlparse, XML_Parse,
355 [xmlp=1; EXPAT_LIBS="EXPAT_LIBS=-lxmlparse -lxmltok"],
359 dnl return output descriptor
360 if test ! x$silent = xyes; then
365 if test $xmle = 1; then
370 resmsg='not found (panic)'
374 AC_MSG_RESULT($resmsg);
375 if test $panic = 1; then
376 AC_MSG_ERROR(Couldn't find the expat libraries)
379 dnl Expat headers location (according Linux distribution etc.)
380 dnl different headers for different library version required
381 if test $xmle = 1; then
382 AC_CHECK_HEADERS( expat.h, has_expat_headers=1, has_expat_headers=0 )
384 AC_CHECK_HEADERS( xmlparse.h xmltok/xmlparse.h, has_expat_headers=1,
385 has_expat_headers=0 )
388 if test $has_expat_headers = 0; then
389 AC_MSG_ERROR(Couldn't find the expat header file(s))
392 dnl check wheter expat.h can be included (1.95.6 is broken - bad bad boys)
393 AC_MSG_CHECKING(whether expat.h is broken)
402 AC_MSG_ERROR([You probably have expat version 1.95.6. Please refer to:
403 http://sourceforge.net/tracker/index.php?func=detail&aid=676844&group_id=10127&atid=110127
404 for a description of the problem.])
407 dnl check XML_SetReturnNSTriplet
408 AC_CHECK_LIB(expat, XML_SetReturnNSTriplet, has_extrip=1, has_extrip=0)
410 if test $has_extrip = 1; then
411 AC_MSG_CHECKING(whether XML_SetReturnNSTriplet works)
417 const char* xml = "<?xml version='1.0'?><a:b xmlns:a='http'/>";
419 void tcStartElement(void *data, const char *elName, const char **atts)
421 const char *q = elName;
424 if (q) { cnt++; q++; }
427 void tcEndElement(void *data, const char *elName) {}
428 int main (int argc, char* argv[])
430 XML_Parser theParser = XML_ParserCreateNS(NULL, '|');
431 XML_SetElementHandler(theParser, tcStartElement, tcEndElement);
432 XML_SetReturnNSTriplet(theParser, 1);
433 XML_Parse(theParser, xml, strlen(xml), 1);
434 XML_ParserFree(theParser);
435 return cnt == 2 ? 0 : 1;
436 }], extrip_ok=1, extrip_ok=0, extrip_ok=0)
440 if test $extrip_ok = 1; then
442 AC_DEFINE(EXPAT_SUPPORTS_TRIPLETS, 1,
443 [define whether Expat supports (working) XML_SetReturnNSTriplet])
449 dnl AC_SUBST(EXPAT_DIR)
452 dnl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
453 dnl end of expat stuff
454 dnl --------------------------------------------------
456 dnl --------------------------------------------------
457 dnl headers, functions, libraries, keep in sync. state
458 dnl for easier maintenance - keep synchronized!!
459 dnl vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
461 AC_CHECK_HEADER( sys/types.h, sabcfg_types_h=1, sabcfg_types_h=0 )
462 dnl sabcfg_types_h=koko
463 AC_SUBST(sabcfg_types_h)
465 AC_CHECK_HEADERS( timeb.h sys/timeb.h sys/time.h \
466 unistd.h ieeefp.h sunmath.h )
468 dnl check wheter iconv is the part of libc.
469 AC_CHECK_HEADERS( iconv.h, has_iconv=1, has_iconv=0)
471 dnl if we have iconv library, we have to decide if it
472 dnl is present in libc
475 if test $has_iconv = 1; then
476 AC_MSG_CHECKING(where to find iconv_open)
478 AC_CHECK_FUNCS(iconv_open, iconv_in_libc=1, iconv_in_libc=0)
479 AC_CHECK_LIB(iconv, iconv_open, iconv_in_iconv=1, iconv_in_iconv=0)
480 AC_CHECK_LIB(iconv, libiconv_open, libiconv_in_iconv=1, libiconv_in_iconv=0)
481 if test ! x$silent = xyes; then
484 #standalone library rules over libc
485 if test $iconv_in_iconv = 1 -o $libiconv_in_iconv = 1; then
486 AC_MSG_RESULT(libiconv)
488 elif test $iconv_in_libc = 1; then
491 AC_MSG_RESULT(not found (panic))
492 AC_MSG_ERROR([iconv.h found, while iconv library not found])
494 #we have iconv at this moment, so we'll check out the need of
495 #typecast in the call of iconv
496 AC_MSG_CHECKING(whether to typecast in iconv)
497 if test x$force_iconv_typecast = x1; then
498 AC_MSG_RESULT(forced)
499 AC_DEFINE(SABLOT_ICONV_CAST_OK, 1,
500 [define whether second param of iconv has to be typecasted])
502 AC_TRY_COMPILE([#include <iconv.h>],[
504 const char *src = "nothing";
509 iconv(cd, &src, &insize, &outbuf, &outsize);
511 iconv_cast=0, iconv_cast=1)
512 if test $iconv_cast = 1; then
514 AC_DEFINE(SABLOT_ICONV_CAST_OK, 1,
515 [define whether second param of iconv has to be typecasted])
523 dnl check for the need of -lm library spec.
524 AC_MSG_CHECKING(whether to force -lm switch)
525 AC_TRY_LINK([#include <math.h>],
526 { double foo; foo = ceil(1.234); },
527 link_libm=0, link_libm=1)
528 if test $link_libm = 1; then
530 OTHER_LIBS="$OTHER_LIBS -lm"
536 if test $js_enabled = 1; then
537 dnl get default libname
538 if test x$SABLOT_JSLIB = x; then
541 dnl check library and header
542 dnl we have to specify perl libraries for Charlie
543 dnl PERLCFLAGS := $(shell perl -MExtUtils::Embed -e ccopts)
544 if test $perlconnect_enabled = 1; then
545 AC_CHECK_PROG(has_perl, perl, yes, no)
546 if test $has_perl = yes; then
547 PERLLDFLAGS=`perl -MExtUtils::Embed -e ldopts`
548 dnl perl erroneously reports compiler flag -rdynamic (interpreted by ld
549 dnl as -r) when it really meant -export-dynamic.
550 PERLLDFLAGS=`echo $PERLLDFLAGS | perl -pe 's/-rdynamic/-export-dynamic/'`
556 AC_CHECK_LIB($SABLOT_JSLIB, js_NewContext,
557 [has_js=1; OTHER_LIBS="$OTHER_LIBS -l$SABLOT_JSLIB $PERLLDFLAGS"],
558 has_js=0, $PERLLDFLAGS)
559 if test $has_js = 1; then
560 echo '#define XP_UNIX' >> confdefs.h
561 AC_CHECK_HEADERS( jsapi.h, has_js_header=1, has_js_header=0 )
562 if test $has_js_header = 0; then
563 AC_MSG_ERROR(required file jsapi.h not found)
566 AC_MSG_ERROR(JavaScript library not found)
570 dnl check for the presence of miscellaneous functions
571 AC_CHECK_FUNCS( ftime gettimeofday , break )
572 AC_CHECK_FUNCS( mtrace )
575 AC_CHECK_FUNCS( setvbuf )
577 dnl check for isnan etc...in the std. way and try link if not found
578 dnl this is due HPUX, where isnan & Co. are defined as macros
580 AC_CHECK_FUNC( isnan, [has_isnan=1; AC_DEFINE(HAVE_ISNAN, 1, isnan)], has_isnan=0)
581 AC_CHECK_FUNC( isinf, [has_isinf=1; AC_DEFINE(HAVE_ISINF, 1, isinf)], has_isinf=0)
582 AC_CHECK_FUNC( finite,[has_finite=1;AC_DEFINE(HAVE_FINITE, 1, finite)], has_finite=0)
584 dnl check for macro isnan in math
585 if test $has_isnan = 0; then
586 AC_MSG_CHECKING(for macro isnan)
587 AC_TRY_LINK( [#include <math.h>], { int foo; foo = isnan(0); },
588 has_isnan=1, has_isnan=0 )
589 if test $has_isnan = 1; then
591 AC_DEFINE(HAVE_ISNAN, 1, isnan)
597 dnl check for macro isinf in math
598 if test $has_isinf = 0; then
599 AC_MSG_CHECKING(for macro isinf)
600 AC_TRY_LINK( [#include <math.h>], { int foo; foo = isinf(0); },
601 has_isinf=1, has_isinf=0 )
602 if test $has_isinf = 1; then
604 AC_DEFINE(HAVE_ISINF, 1, isinf)
610 dnl check for macro finite in math
611 if test $has_finite = 0; then
612 AC_MSG_CHECKING(for macro finite)
613 AC_TRY_LINK( [#include <math.h>], { int foo; foo = finite(0); },
614 has_finite=1, has_finite=0 )
615 if test $has_finite = 1; then
617 AC_DEFINE(HAVE_FINITE, 1, finite)
623 dnl wchar.h (not present on FreeBSD)
624 AC_CHECK_HEADER( wchar.h, has_wchar=1, has_wchar=0)
626 if test $has_wchar = 1; then
627 AC_DEFINE(HAVE_WCHAR_H, 1, [define if you have wchar.h header])
628 AC_CHECK_FUNCS( wcsxfrm wcscmp )
631 dnl if test $has_wchar = 0; then
632 dnl AC_MSG_ERROR(The header <wchar.h> not found. This problem occurs on
633 dnl certain platforms (e.g. FreeBSD). Please check your system configuration.)
638 dnl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
639 dnl end of headers etc.
640 dnl --------------------------------------------------
642 dnl --------------------------------------------------
644 dnl vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
646 AC_OUTPUT( src/engine/sabcfg.h
647 Makefile src/Makefile src/engine/Makefile
648 src/command/Makefile src/command/sablot-config
649 doc/Makefile doc/man/Makefile doc/misc/Makefile
650 doc/apidoc/Makefile utils/Makefile
651 utils/apidoc/Makefile )
654 dnl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
655 dnl end of output files
656 dnl --------------------------------------------------
658 dnl --------------------------------------------------
659 dnl notices and messages
660 dnl vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
662 if test $has_wchar = 0; then
663 AC_MSG_WARN([Your system doesn't support standard widechar library (wchar.h), result of the <xsl:sort> instruction may be undefined])
666 dnl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
668 dnl --------------------------------------------------
670 dnl vim600: ts=2 sw=2 et nocin nosi