Revision f8a9164611b9031c37003fed9b2ec9e1de629d2a authored by Duncan Temple Lang on 27 November 2000, 00:00:00 UTC, committed by Gabor Csardi on 27 November 2000, 00:00:00 UTC
1 parent 6043dd5
configure.in
# An input file for autoconf to configure
# the XML parsing facilities for both R and S.
# Currently this works for R.
#
# This was implemented by Friedrich Leisch
# with some modifications for the next version
# by Duncan Temple Lang.
#
AC_INIT(DESCRIPTION)
dnl The different command line arguments for configure.
dnl They can also be specified by setting environment variables.
dnl whether to use Splus.
AC_ARG_WITH(splus,[ --with-splus Compile as an SPlus library (rather than R). Value can be the (fully qualified) name of the Splus script.], USE_SPLUS=1)
dnl explicitly force the use of the old names. If this doesn't match the header
dnl files that are actually found, then
AC_ARG_WITH(oldlibxml,[], USE_OLD_ROOT_CHILD_NAMES=1; FORCE_OLD=1;echo "Using old libxml names")
dnl tell the configuration that we are using libxml2.
AC_ARG_WITH(libxml2,[ --with-libxml2 indicate that the libxml version is 2.0 or higher],
[ if test "${withval}" = yes; then
LIBXML2="-DLIBXML2=1";
fi])
dnl compile for use with libxml. This is the default.
AC_ARG_WITH(libxml, [ --with-libxml use the libxml library (default)],
[ if test "${withval}" = no; then
USE_LIBXML=false;
else
USE_LIBXML=true;
fi],
USE_LIBXML=true)
# Default is false for expat since we can
# do event driven parsing with libxml.
AC_ARG_WITH(expat,
[ --with-expat use expat library (off by default)],
[ if test "${withval}" = no; then
USE_EXPAT= ;
else
USE_EXPAT=true;
fi],
USE_EXPAT= )
dnl Get the C compiler, including any values set by the user
AC_PROG_CC
AC_PROG_CPP
dnl ======================================================
dnl Check whether we are compiling this for use with SPlus
dnl and if so, figure out which version.
if test -n "${USE_SPLUS}" ; then
# Allows the user to say --with-splus=/usr/local/bin/Splus5
# This could be fooled, but unlikely unless the user does something
# "clever"
if test -x ${with_splus} ; then
SPLUS=${with_splus}
else
SPLUS=Splus
fi
# Get the major version of the Splus being run.
SPLUS_VERSION=`echo 'cat(version$major,"\n",sep="")' | ${SPLUS} | perl -e 'while(<STDIN>){ $x = $_;} printf $x;'`
# If this is version 3, we are in trouble.
if test ${SPLUS_VERSION} -lt 5 ; then
echo "This package does not work with SPlus 3, but only SPlus 5 and 6"
exit 1
fi
fi # end of USE_SPLUS.
dnl ======================================================
dnl ======================================================
dnl In this section, we try to find the different
dnl characteristics of the libxml library.
dnl We are looking to see if
dnl a) it is version 1.8.* or version 2.2.*
dnl b) whether it is installed with include files in <wherever>/gnome-xml
dnl or in a private, uninstalled form in which case the include
dnl directory is usually libxml/
if test -n "${USE_LIBXML}" ; then
if test -z "${LIBXML_INCDIR}" && test -z "${LIBXML_LIBDIR}" ; then
if test -z "${XML_CONFIG}" ; then
AC_PATH_PROGS(XML_CONFIG, xml-config)
fi
if test -n "${XML_CONFIG}" ; then
LIBXML_INCDIR=`${XML_CONFIG} --cflags | sed -e 's/-I//g'`
LIBXML_LIBDIR=`${XML_CONFIG} --libs`
fi
fi
dnl If the user has specified LIBXML_INCDIR, then
dnl we use that.
dnl Otherwise, we try to find the parser.h file.
if test -n "${LIBXML_INCDIR}" ; then
if test -d $LIBXML_INCDIR ; then
dnl Maybe also test for ${LIBXML_INCDIR}/parser.h
dnl in case somebody points us directly at the include directory.
if test -r ${LIBXML_INCDIR}/libxml/parser.h ; then
FOUND_LIBXML_INCLUDES="Ok"
elif test -r ${LIBXML_INCDIR}/gnome-xml/parser.h ; then
FOUND_LIBXML_INCLUDES="Ok"
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DFROM_GNOME_XML_DIR=1"
else
echo "You specified LIBXML_INCDIR, but we couldn't find parser.h"
echo "Please specify it correctly and re-run the INSTALL'ation."
exit 1
fi
else
echo "The LIBXML_INCDIR value you specified ($LIBXML_INCDIR) is not a directory."
echo "Please specify it correctly and re-run the INSTALL'ation."
exit 1
fi
fi
dnl We should have exited if we cannot find parser.h
dnl LIBXML_INCDIR.
if test -z "${FOUND_LIBXML_INCLUDES}" ; then
dnl the idea is that we loop over different directories
dnl looking for parser.h. We look in the sub-directory
dnl gnome-xml/
TMP_CPPFLAGS=${CPPFLAGS}
for dir in ${LIBXML_INCDIR} /usr/local/include /usr/include ; do
CPPFLAGS="${TMP_CPPFLAGS} -I${dir}"
AC_CHECK_HEADER(libxml/parser.h, FROM_LIBXML_DIR=1)
if test -n "${FROM_LIBXML_DIR}" ; then
LIBXML_INCDIR="${dir}"
CPPFLAGS="${TMP_CPPFLAGS} -I${dir} -I${dir}/libxml"
PKG_CPPFLAGS="${TMP_CPPFLAGS} -I${dir} -I${dir}/libxml"
echo "Found the libxml parser.h in $dir/libxml/"
break
fi
CPPFLAGS="${TMP_CPPFLAGS} -I${dir}/gnome-xml"
AC_CHECK_HEADER(gnome-xml/parser.h, FROM_GNOME_XML_DIR=1)
if test -n "${FROM_GNOME_XML_DIR}" ; then
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DFROM_GNOME_XML_DIR=1"
CPPFLAGS="${CPPFLAGS} -DFROM_GNOME_XML_DIR=1"
LIBXML_INCDIR="${dir}"
echo "Found the gnome-xml parser in $dir"
break
fi
done
if test -z "${FROM_GNOME_XML_DIR}" ; then
CPPFLAGS=${TMP_CPPFLAGS}
fi
fi # end of -z FOUND_LIBXML_INCLUDES
if test -z "${LIBXML_INCDIR}"; then
AC_CHECK_HEADER(libxml/parser.h, LIBXML_INCDIR="libxml/")
fi
if test -z "${LIBXML_INCDIR}" ; then
echo "Cannot find parser.h. Set the value of the environment variable"
echo " LIBXML_INCDIR"
echo "to point to where it can be found."
exit 1;
else
echo "Located parser file ${LIBXML_INCDIR}/parser.h"
fi
if test -z "${LIBXML2}" ; then
CPPFLAGS="${PKG_CPPFLAGS} -I${LIBXML_INCDIR}"
echo "${CPPFLAGS}"
AC_TRY_COMPILE([
#ifdef FROM_GNOME_XML_DIR
#include <gnome-xml/parser.h>
#else
#include <libxml/parser.h>
#endif],
[ xmlAttr *attr;
attr->val = NULL;
], [echo "Using libxml 1.8.*!"],[LIBXML2="-DLIBXML2=1"; echo "Using libxml2.*" ])
fi
# AC_EGREP_HEADER(xmlParseFile, ${LIBXML_INCDIR}parser.h,
# HAVE_LIBXML_HEADER=true,
# AC_MSG_ERROR("header files for libxml seem to be incorrect"))
AC_CHECK_LIB(z, gzopen)
if test -n "${LIBXML2}" ; then
AC_CHECK_LIB(xml2, xmlParseFile, LIBS="${LIBS} -lxml2"; USE_XMLLIB_NAME=xml2, NO_XML_LIB=1, "-L${LIBXML_LIBDIR-.}")
else
NO_XML_LIB=1
fi
if test -n "${NO_XML_LIB}" ; then
AC_CHECK_LIB(xml, xmlParseFile, LIBS="${LIBS} -lxml";USE_XMLLIB_NAME=xml, AC_MSG_ERROR("libxml not found"), "-L${LIBXML_LIBDIR-.}")
fi
if test -n "${LIBXML_LIBDIR}" ; then
LIBS="-L${LIBXML_LIBDIR-.} ${LIBS}"
LD_PATH="${LIBXML_LIBDIR-.}"
fi
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DLIBXML"
if test -z "${FROM_GNOME_XML_DIR}" ; then
PKG_CPPFLAGS="${PKG_CPPFLAGS} -I${LIBXML_INCDIR-.}"
fi
if test -z "${LIBXML2}" ; then
dnl Now we try to test whether we have a really old libxml
dnl which uses childs and root instead of xmlChildren and xmlRootNode
if test -z "${USE_OLD_ROOT_CHILD_NAMES}" ; then
CPPFLAGS=${PKG_CPPFLAGS}
AC_TRY_COMPILE([
#ifdef FROM_GNOME_XML_DIR
#include <gnome-xml/parser.h>
#else
#include <libxml/parser.h>
#endif],
[ xmlDocPtr node;
node->xmlRootNode = NULL;
], [echo "New style libxml!"],[USE_OLD_ROOT_CHILD_NAMES=1; echo "Need to use old-style libxml names"])
echo "Using old root child names? ${USE_OLD_ROOT_CHILD_NAMES-0}"
fi # USE_OLD_ROOT_CHILD_NAMES
else # -z "${LIBXML2}"
CPPFLAGS=${PKG_CPPFLAGS}
AC_TRY_RUN([
#ifdef FROM_GNOME_XML_DIR
#include <gnome-xml/parser.h>
#else
#include <libxml/parser.h>
#endif
int
main(int argc, char *argv)
{
xmlCheckVersion(20000);
return(0);
}
],[ LIBXML2_OK=1],[LIBXML2_OK=0])
if test "${LIBXML2_OK}" = "0" ; then
echo "You are trying to use a version 2.* edition of libxml"
echo "but an incompatible library. The header files and library seem to be"
echo "mismatched. If you have specified LIBXML_INCDIR, make certain to also"
echo "specify an appropriate LIBXML_LIBDIR if the libxml2 library is not in the default"
echo "directories."
exit 1
fi
fi
if test -n "${USE_OLD_ROOT_CHILD_NAMES}" ; then
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DUSE_OLD_ROOT_CHILD_NAMES=1"
fi
fi
if test "${USE_XMLLIB_NAME}" = "xml2" ; then
AC_CHECK_LIB(xml2, xmlHashSize, echo "Using built-in xmlHashSize", PKG_CPPFLAGS="${PKG_CPPFLAGS} -DOWN_XML_HASH_SIZE=1")
fi
if test "${USE_LIBXML}" ; then
echo "Checking DTD parsing (presence of externalSubset)..."
AC_TRY_COMPILE([
#ifdef FROM_GNOME_XML_DIR
#include <gnome-xml/parser.h>
#else
#include <libxml/parser.h>
#endif],
[
xmlParserCtxtPtr ctxt;
ctxt->inSubset = 0;
ctxt->sax->externalSubset = NULL;
], USE_EXT_SUBSET=1)
if test -n "${USE_EXT_SUBSET}" ; then
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DUSE_EXTERNAL_SUBSET=1"
fi
AC_TRY_COMPILE([
#ifdef FROM_GNOME_XML_DIR
#include <gnome-xml/parser.h>
#else
#include <libxml/parser.h>
#endif],
[
xmlNodePtr node;
int x;
x = node->type == XML_DTD_NODE;
], ROOT_HAS_DTD_NODE=1, echo "No XML_DTD_NODE defined")
if test -n "${ROOT_HAS_DTD_NODE}" ; then
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DROOT_HAS_DTD_NODE=1"
fi
AC_CHECK_LIB(${USE_XMLLIB_NAME},xmlHashSize, echo "Found xmlHashSize", echo "No xmlHashSize")
fi
if test -n "${USE_EXPAT}" ; then
AC_CHECK_HEADER(xmltok/xmlparse.h, XMLPARSE_INCDIR="xmltok/")
if test -z "${XMLPARSE_INCDIR}" ; then
AC_CHECK_HEADER(xmlparse/xmlparse.h, XMLPARSE_INCDIR="xmlparse/")
fi
AC_EGREP_HEADER(XML_Parse, ${XMLPARSE_INCDIR}xmlparse.h,
HAVE_EXPAT_HEADER=true,
AC_MSG_ERROR("header file xmlparse.h seems to be incorrect"))
AC_CHECK_LIB(xmltok, XmlInitEncoding,,AC_MSG_ERROR("libxmltok not found"))
AC_CHECK_LIB(xmlparse, XML_Parse,,
AC_MSG_ERROR("libxmlparse not found"), -lxmltok)
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DLIBEXPAT -I${XMLPARSE_INCDIR}"
LD_PATH="${LD_PATH}:${LIBXML_LIBDIR}"
fi
if test -n "${USE_EXPAT}" ; then
SUPPORTS_EXPAT="TRUE"
else
SUPPORTS_EXPAT="FALSE"
fi
echo "Expat: ${USE_EXPAT} ${SUPPORTS_EXPAT}"
if test -n "${USE_LIBXML}" ; then
SUPPORTS_LIBXML="TRUE"
else
SUPPORTS_LIBXML="FALSE"
fi
if test -z "${USE_SPLUS}" ; then
LANGUAGE_DEFS="-DUSE_R=1 -D_R_=1"
PKG_SYS_FILE='system.file("scripts", name, pkg="RSPerl")'
else # so compiling for R.
dnl Test to see if the patch has been made to renamin the attribute()
dnl routine in libxml
if test ${SUPPORTS_LIBXML}="TRUE" ; then
AC_CHECK_LIB(xml, attribute, NEED_LIBXML_PATCH=1)
if test -n "${NEED_LIBXML_PATCH}" ; then
echo "The XML package will not work with S-Plus and the current libxml"
echo "because of a conflict from both having a routine named attribute()"
echo "We suggest that you modify the SAX.c file in the libxml and re-install."
echo "See PATCH.attribute in this package's distribution."
exit 1
fi
fi # ? SUPPORTS_LIBXML = "TRUE"
LANGUAGE_DEFS="-D_S_=1 -DUSE_S=1 -D_S4_=1 -D_SPLUS${SPLUS_VERSION}_ -DNO_SPLUS_THREAD_DEF=1"
INSTALL_DIR=`pwd`
PKG_SYS_FILE="paste(\"${INSTALL_DIR}/inst/scripts/\", name,sep=\"\")"
fi
AC_TRY_LINK(
[
#include "parser.h"
],
[
extern int xmlSkipBlankChars(xmlParserCtxtPtr ctxt);
xmlParserCtxtPtr p;
xmlSkipBlankChars(p);
],
echo "No need for old SKIP_BLANKS definition"
, BLANKS_DEF="-DOLD_SKIP_BLANKS=1"
)
PKG_LIBS=${LIBS}
AC_SUBST(LIBXML2)
AC_SUBST(LANGUAGE_DEFS)
AC_SUBST(LIBXML_INCDIR)
AC_SUBST(XMLPARSE_INCDIR)
AC_SUBST(PKG_LIBS)
AC_SUBST(PKG_CPPFLAGS)
AC_SUBST(SUPPORTS_LIBXML)
AC_SUBST(SUPPORTS_EXPAT)
AC_SUBST(LD_PATH)
if test -n "${USE_SPLUS}" ; then
AC_SUBST(SPLUS)
SPLUS_MAKEFILE=GNUmakefile.Splus
fi
echo ""
echo "****************************************"
echo "Configuration information:"
echo ""
echo "Libxml settings"
echo ""
echo "libxml include directory: ${LIBXML_INCDIR}"
echo "libxml library directory: ${LIBS}"
echo "libxml 2: ${LIBXML2-no}"
echo ""
echo "Compilation flags: ${PKG_CPPFLAGS}"
echo "Link flags: ${PKG_LIBS}"
echo ""
echo "****************************************"
dnl create the different targets
AC_OUTPUT(cleanup src/Makevars R/supports.R inst/scripts/RSXML.csh inst/scripts/RSXML.bsh ${SPLUS_MAKEFILE})
chmod +x cleanup
dnl
if test -n "${USE_SPLUS}" ; then
mv GNUmakefile.Splus GNUmakefile
echo "Creating S-Plus chapter"
cd src
C_SRC_FILES="DocParse.c RSDTD.c Utils.c"
${SPLUS} CHAPTER ${C_SRC_FILES}
echo "include Makevars" >> makefile
echo 'CFLAGS:= $(PKG_CPPFLAGS) $(CFLAGS)' >> makefile
echo 'LOCAL_LIBS=$(PKG_LIBS) ' >> makefile
cd ..
fi
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...