1# An input file for autoconf to configure 2# the XML parsing facilities for both R and S. 3# Currently this works for R. 4# 5# This was originally implemented by Friedrich Leisch 6# with modifications for subsequent versions 7# by Duncan Temple Lang. 8# 9 10AC_INIT 11AC_CONFIG_SRCDIR([DESCRIPTION]) 12 13 14dnl The different command line arguments for configure. 15dnl They can also be specified by setting environment variables. 16 17 18dnl 19dnl Establish the command line arguments accepted by this script. 20dnl 21dnl 22 23 dnl whether to use Splus. 24AC_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) 25 26 dnl explicitly force the use of the old names. If this doesn't match the header 27 dnl files that are actually found, then 28AC_ARG_WITH(oldlibxml,[], USE_OLD_ROOT_CHILD_NAMES=1; FORCE_OLD=1;echo "Using old libxml names") 29 30 dnl tell the configuration that we are using libxml2. 31AC_ARG_WITH(libxml2,[ --with-libxml2 indicate that the libxml version is 2.0 or higher], 32 [ if test "${withval}" = "yes" ; then 33 LIBXML2="-DLIBXML2=1"; 34 USE_XML2="yes" ; 35 fi], USE_XML2="yes") 36 37 38AC_ARG_WITH(xml-config,[ --with-xml-config the name of the xml-config program to use.], 39 [ XML_CONFIG=${withval}]) 40 41 42 dnl compile for use with libxml. This is the default. 43AC_ARG_WITH(libxml, [ --with-libxml use the libxml library (default)], 44 [ if test "${withval}" = no; then 45 USE_LIBXML=false; 46 else 47 USE_LIBXML=true; 48 fi], 49 USE_LIBXML=true) 50 51# Default is false for expat since we can 52# do event driven parsing with libxml. 53AC_ARG_WITH(expat, 54 [ --with-expat use expat library (off by default)], 55 [ if test "${withval}" = no; then 56 USE_EXPAT= ; 57 else 58 USE_EXPAT=true; 59 fi], 60 USE_EXPAT= ) 61 62dnl Here we add a flag which we will use below in the case that 63dnl the user declaratively adds this option in. 64AC_ARG_WITH(xml_output_buffer, 65 [ --with-xml-output-buffer use ADD_XML_OUTPUT_BUFFER_CODE (conditionally on)], 66 [ if test "${withval}" = "yes" ; then 67 ADD_XML_OUTPUT_BUFFER="yes"; 68 else 69 ADD_XML_OUTPUT_BUFFER="no"; 70 fi], 71 ADD_XML_OUTPUT_BUFFER=no) 72 73dnl 74dnl End of command line argument declarations. 75dnl Now compute the relevant settings. 76dnl 77 78 79 dnl Get the C compiler, including any values set by the user 80 dnl We need this to perform compilation and link checks. 81AC_PROG_CC 82AC_PROG_CPP 83 84 85 86dnl ====================================================== 87 88dnl Check whether we are compiling this for use with SPlus 89dnl and if so, figure out which version. 90if test -n "${USE_SPLUS}" ; then 91 # Allows the user to say --with-splus=/usr/local/bin/Splus5 92 # This could be fooled, but unlikely unless the user does something 93 # "clever" 94 if test -x ${with_splus} ; then 95 SPLUS=${with_splus} 96 else 97 SPLUS=Splus 98 fi 99 100 # Get the major version of the Splus being run. 101 dnl Shouldn't this be perl -epn 102 SPLUS_VERSION=`echo 'cat(version$major,"\n",sep="")' | ${SPLUS} | perl -e 'while(<STDIN>){ $x = $_;} printf $x;'` 103 104 # If this is version 3, we are in trouble. 105 if test ${SPLUS_VERSION} -lt 5 ; then 106 echo "This package does not work with SPlus 3, but only SPlus 5 and 6" 107 exit 1 108 fi 109fi # end of USE_SPLUS. 110 111 112 113AC_ARG_WITH(xmlsec, [ --with-xmlsec add support (experimental) for XML security with xmlsec. Specify no, xmlsec1 or xmlsec1-openssl], 114 [ if test "${withval}" = no; then 115 USE_XMLSEC=false 116 else 117 USE_XMLSEC=${withval} 118 fi], 119 USE_XMLSEC=true) 120 121 122dnl 123 124 125dnl Redirection: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html 126if test -n "" ; then 127 128 # turned off for now 129 #XXX get the redirection correct 130"$R_HOME/bin/R" CMD SHLIB testRemoveFinalizers.c &> AS_MESSAGE_FD 131if test "$?" = 0 ; then 132 $R_HOME/bin/R --no-echo --vanilla < testRemoveFinalizers.R &> AS_MESSAGE_FD 133fi 134 135if ! test "$?" = 0 ; then 136 echo "No ability to remove finalizers on externalptr objects in this verison of R"; 137 EXPORT_MEMORY_MANAGEMENT="FALSE" 138else 139 echo "Have R_RemoveExtPtrWeakRef" ; 140 PKG_CPPFLAGS="$PKG_CPPFLAGS -DR_HAS_REMOVE_FINALIZERS=1"; 141 EXPORT_MEMORY_MANAGEMENT="TRUE" 142fi 143else 144 EXPORT_MEMORY_MANAGEMENT="FALSE" 145fi 146 147dnl ====================================================== 148 149AC_PATH_PROGS(SED, sed) 150 151AC_PATH_PROGS(PKG_CONFIG, pkg-config) 152 153dnl In this section, we try to find the different 154dnl characteristics of the libxml library. 155 156dnl We are looking to see if 157dnl a) it is version 1.8.* or version 2.* 158dnl b) whether it is installed with include files in <wherever>/gnome-xml 159dnl or in a private, uninstalled form in which case the include 160dnl directory is usually libxml/ 161 162if test -n "${USE_LIBXML}" ; then 163 164 dnl If the user gave us xml*-config, then use that. 165 if test -n "${XML_CONFIG}" && test -x "${XML_CONFIG}" ; then 166 USING_USER_XML_CONFIG="yes" 167 168 XML_VERSION="`${XML_CONFIG} --version | ${SED} -e 's/\..*//g'`" 169 if test "${XML_VERSION}" = "2" ; then 170 USE_XML2="yes" 171 LIBXML2="-DLIBXML2=1"; 172 fi 173 echo "User defined xml-config: ${XML_CONFIG}, XML Version: ${XML_VERSION}, XML2: ${USE_XML2}" 174 fi 175 176 177 LANGUAGE_DEFS="${LANGUAGE_DEFS} -DHAVE_VALIDITY=1" 178 179 dnl if the user has not specified anything about libxml, 180 dnl then lets look for xml-config. We let the user give this 181 dnl as an environment variable `XML_CONFIG'. 182 183 if test -z "${LIBXML_INCDIR}" && test -z "${LIBXML_LIBDIR}" ; then 184 185 dnl find xml*-config 186 187 dnl If they ask explicitly for xml2, find it or fail otherwise. 188 if test "${USE_XML2}" = "yes" ; then 189 if test -z "${XML_CONFIG}" ; then 190 AC_PATH_PROGS(XML_CONFIG, xml2-config) 191 if test -z "${XML_CONFIG}" ; then 192 echo "Cannot find xml2-config" 193 exit 1 194 fi 195 fi 196 fi 197 198 dnl Otherwise, if they implicitly ask for xml-config 199 dnl find that. 200 if test -z "${XML_CONFIG}" ; then 201 AC_PATH_PROGS(XML_CONFIG, xml-config) 202 fi 203 204 dnl and if they don't have libxml version 1, see if they 205 dnl have libxml2 206 207 if test "${USE_XML2}" = "maybe" ; then 208 if test -z "${XML_CONFIG}" ; then 209 AC_PATH_PROGS(XML_CONFIG, xml2-config) 210 if test -z "${XML_CONFIG}" ; then 211 echo "Cannot find xml2-config" 212 exit 1 213 else 214 echo "Using libxml version `$XML_CONFIG --version`" 215 fi 216 fi 217 fi 218 219 if test -n "${XML_CONFIG}" ; then 220 221 echo "USE_XML2 = ${USE_XML2}" 222 if test "${USE_XML2}" != "no" && test -z "${FORCE_XML2}"; then 223 224dnl This is not needed now, but is a way to test whether we should use -E or -r to get 225dnl extended regular expression usage with this version of sed. 226 echo "foo" | sed -Ee 's/foo/bar/' > /dev/null 2>&1 227 if test "$?" = "0" ; then 228 SED_EXTENDED_ARG="-E" 229 else 230 SED_EXTENDED_ARG="-r" 231 fi 232 233 echo "SED_EXTENDED_ARG: ${SED_EXTENDED_ARG}" 234 235 236 MINOR=`${XML_CONFIG} --version | ${SED} -e 's/^2\.\([[0-9]]\{1,\}\).*/\1/'` 237 PATCH=`${XML_CONFIG} --version | ${SED} -e 's/^2\.[[0-9]]\{1,\}\.\([[0-9]]\{1,\}\)$/\1/'` 238 239 echo "Minor $MINOR, Patch $PATCH for `$XML_CONFIG --version`" 240 if test $MINOR -lt 6 ; then 241 echo "" 242 echo "**** You should use a recent version of libxml2, i.e. 2.6.22 or higher ****" 243 echo "" 244 exit 1 245 fi 246 247 if test "$MINOR" -eq 6 -a "$PATCH" -lt 3 ; then 248 echo "" 249 echo "**** There are problems compiling this package with libxml2-2.6.1 or libmxml2-2.6.2. ****" 250 echo "**** You will probably encounter compilation errors, so we are terminating the build. ****" 251 echo "" 252 exit 1 253 fi 254 255 fi 256 257 258 LIBXML_INCDIR=`${XML_CONFIG} --cflags` 259 LIBXML_LIBDIR=`${XML_CONFIG} --libs` 260 FOUND_LIBXML_INCLUDES="Ok" 261 fi 262 fi dnl USE_XML2 263 264 265 266 dnl If the user has specified LIBXML_INCDIR, then 267 dnl we use that. 268 dnl Otherwise, we try to find the parser.h file. 269 270 if test -n "${LIBXML_INCDIR}" && test -z "${XML_CONFIG}" ; then 271echo "Checking directory of LIBXML_INCDIR" 272 if test -d $LIBXML_INCDIR ; then 273 274 dnl Maybe also test for ${LIBXML_INCDIR}/parser.h 275 dnl in case somebody points us directly at the include directory. 276 277 if test -r ${LIBXML_INCDIR}/libxml/parser.h ; then 278 FOUND_LIBXML_INCLUDES="Ok" 279 elif test -r ${LIBXML_INCDIR}/gnome-xml/parser.h ; then 280 FOUND_LIBXML_INCLUDES="Ok" 281 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DFROM_GNOME_XML_DIR=1" 282 else 283 echo "You specified LIBXML_INCDIR, but we couldn't find parser.h" 284 echo "Please specify it correctly and re-run the INSTALL'ation." 285 exit 1 286 fi 287 else 288 echo "The LIBXML_INCDIR value you specified ($LIBXML_INCDIR) is not a directory." 289 echo "Please specify it correctly and re-run the INSTALL'ation." 290 exit 1 291 fi 292 fi 293 294 295 dnl We should have exited if we cannot find parser.h 296 dnl LIBXML_INCDIR. 297 298 if test -z "${FOUND_LIBXML_INCLUDES}" ; then 299 300 dnl the idea is that we loop over different directories 301 dnl looking for parser.h. We look in the sub-directory 302 dnl gnome-xml/ 303 TMP_CPPFLAGS=${CPPFLAGS} 304 for dir in ${LIBXML_INCDIR} /usr/local/include /usr/include ; do 305 306 CPPFLAGS="${TMP_CPPFLAGS} -I${dir}" 307 AC_CHECK_HEADER(libxml/parser.h, FROM_LIBXML_DIR=1) 308 if test -n "${FROM_LIBXML_DIR}" ; then 309 LIBXML_INCDIR="-I${dir}" 310 CPPFLAGS="${TMP_CPPFLAGS} -I${dir} -I${dir}/libxml" 311 PKG_CPPFLAGS="${TMP_CPPFLAGS} -I${dir} -I${dir}/libxml" 312 echo "Found the libxml parser.h in $dir/libxml/" 313 break 314 fi 315 316 CPPFLAGS="${TMP_CPPFLAGS} -I${dir}/gnome-xml" 317 318 AC_CHECK_HEADER(gnome-xml/parser.h, FROM_GNOME_XML_DIR=1) 319 if test -n "${FROM_GNOME_XML_DIR}" ; then 320 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DFROM_GNOME_XML_DIR=1" 321 CPPFLAGS="${CPPFLAGS} -DFROM_GNOME_XML_DIR=1" 322 LIBXML_INCDIR="-I${dir}" 323 echo "Found the gnome-xml parser in $dir" 324 break 325 fi 326 done 327 328 if test -z "${FROM_GNOME_XML_DIR}" ; then 329 CPPFLAGS=${TMP_CPPFLAGS} 330 fi 331 332 fi # end of -z FOUND_LIBXML_INCLUDES 333 334 335 if test -z "${LIBXML_INCDIR}"; then 336 AC_CHECK_HEADER(libxml/parser.h, LIBXML_INCDIR="libxml/") 337 fi 338 339 if test -z "${LIBXML_INCDIR}" ; then 340 echo "Cannot find parser.h. Set the value of the environment variable" 341 echo " LIBXML_INCDIR" 342 echo "to point to where it can be found." 343 exit 1; 344 else 345 echo "Located parser file ${LIBXML_INCDIR}/parser.h" 346 fi 347 348dnl Do we need this? XXX 349#LIBS="${LIBS} ${LIBXML_INCDIR}" 350 351 if test -z "${LIBXML2}" ; then 352CPPFLAGS="${PKG_CPPFLAGS} ${LIBXML_INCDIR}" 353echo "Checking for 1.8: ${CPPFLAGS}" 354 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 355#ifdef FROM_GNOME_XML_DIR 356#include <gnome-xml/parser.h> 357#else 358#include <libxml/parser.h> 359#endif]], [[ xmlAttr *attr; 360 attr->val = NULL; 361]])],[echo "Using libxml 1.8.*!"],[LIBXML2="-DLIBXML2=1"; echo "Using libxml2.*" ]) 362 fi 363 364# AC_EGREP_HEADER(xmlParseFile, ${LIBXML_INCDIR}parser.h, 365# HAVE_LIBXML_HEADER=true, 366# AC_MSG_ERROR("header files for libxml seem to be incorrect")) 367 368 369 AC_CHECK_LIB(z, gzopen) 370 if test -n "${LIBXML2}" ; then 371 AC_CHECK_LIB(xml2, xmlParseFile, LIBS="${LIBS} -lxml2"; USE_XMLLIB_NAME=xml2, NO_XML_LIB=1, "${LIBXML_LIBDIR--L.}") 372 else 373 NO_XML_LIB=1 374 fi 375 376 if test -n "${NO_XML_LIB}" ; then 377 AC_CHECK_LIB(xml, xmlParseFile, LIBS="${LIBS} -lxml";USE_XMLLIB_NAME=xml, AC_MSG_ERROR("libxml not found"), "${LIBXML_LIBDIR--L.}") 378 fi 379 380 if test -n "${LIBXML_LIBDIR}" ; then 381 LIBS="${LIBXML_LIBDIR--L.} ${LIBS}" 382 LD_PATH="${LIBXML_LIBDIR-.}" 383 fi 384 385 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DLIBXML" 386 if test -z "${FROM_GNOME_XML_DIR}" ; then 387 PKG_CPPFLAGS="${PKG_CPPFLAGS} ${LIBXML_INCDIR--I.}" 388 fi 389 390 391if test -z "${LIBXML2}" ; then 392 dnl Now we try to test whether we have a really old libxml 393 dnl which uses childs and root instead of xmlChildren and xmlRootNode 394 395 if test -z "${USE_OLD_ROOT_CHILD_NAMES}" ; then 396 CPPFLAGS=${PKG_CPPFLAGS} 397 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 398#ifdef FROM_GNOME_XML_DIR 399#include <gnome-xml/parser.h> 400#else 401#include <libxml/parser.h> 402#endif]], [[ xmlDocPtr node; 403 node->xmlRootNode = NULL; 404 ]])],[echo "New style libxml!"],[USE_OLD_ROOT_CHILD_NAMES=1; echo "Need to use old-style libxml names"]) 405 406 echo "Using old root child names? ${USE_OLD_ROOT_CHILD_NAMES-0}" 407 fi # USE_OLD_ROOT_CHILD_NAMES 408else # -z "${LIBXML2}" 409 CPPFLAGS=${PKG_CPPFLAGS} 410 if test -d "${LIBXML_LIBDIR}" ; then 411 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBXML_LIBDIR} 412 export LD_LIBRARY_PATH 413 fi 414 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 415#ifdef FROM_GNOME_XML_DIR 416#include <gnome-xml/parser.h> 417#else 418#include <libxml/parser.h> 419#endif 420int 421main(int argc, char *argv[]) 422{ 423 xmlCheckVersion(20000); 424 return(0); 425} 426 ]])],[ LIBXML2_OK=1],[LIBXML2_OK=0],[]) 427 428 if test "${LIBXML2_OK}" = "0" ; then 429 echo "You are trying to use a version 2.* edition of libxml" 430 echo "but an incompatible library. The header files and library seem to be" 431 echo "mismatched. If you have specified LIBXML_INCDIR, make certain to also" 432 echo "specify an appropriate LIBXML_LIBDIR if the libxml2 library is not in the default" 433 echo "directories." 434 exit 1 435 fi 436 fi 437 438 if test -n "${USE_OLD_ROOT_CHILD_NAMES}" ; then 439 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DUSE_OLD_ROOT_CHILD_NAMES=1" 440 fi 441fi 442 443 444 445if test "${USE_XMLLIB_NAME}" = "xml2" ; then 446 AC_CHECK_LIB(xml2, xmlHashSize, echo "Using built-in xmlHashSize", PKG_CPPFLAGS="${PKG_CPPFLAGS} -DOWN_XML_HASH_SIZE=1") 447fi 448 449if test "${USE_LIBXML}" ; then 450 451 echo "Checking DTD parsing (presence of externalSubset)..." 452 453 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 454#ifdef FROM_GNOME_XML_DIR 455#include <gnome-xml/parser.h> 456#else 457#include <libxml/parser.h> 458#endif]], [[ 459 xmlParserCtxtPtr ctxt; 460 ctxt->inSubset = 0; 461 ctxt->sax->externalSubset = NULL; 462 ]])],[USE_EXT_SUBSET=1],[]) 463 464 if test -n "${USE_EXT_SUBSET}" ; then 465 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DUSE_EXTERNAL_SUBSET=1" 466 fi 467 468 469 470 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 471#ifdef FROM_GNOME_XML_DIR 472#include <gnome-xml/parser.h> 473#else 474#include <libxml/parser.h> 475#endif]], [[ 476 xmlNodePtr node; 477 int x; 478 x = node->type == XML_DTD_NODE; 479 480 ]])],[ROOT_HAS_DTD_NODE=1],[echo "No XML_DTD_NODE defined"]) 481 482 if test -n "${ROOT_HAS_DTD_NODE}" ; then 483 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DROOT_HAS_DTD_NODE=1" 484 fi 485 486 AC_CHECK_LIB(${USE_XMLLIB_NAME},xmlHashSize, echo "Found xmlHashSize", echo "No xmlHashSize") 487 488 489 490 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 491#ifdef FROM_GNOME_XML_DIR 492#include <gnome-xml/parser.h> 493#else 494#include <libxml/parser.h> 495#endif]], [[ 496 xmlEntityPtr ent; 497 ent->checked = 1; 498 ]])],[ENTITY_HAS_CHECKED="yes"],[ENTITY_HAS_CHECKED="no"]) 499 500 if test "${ENTITY_HAS_CHECKED}" = "no" ; then 501 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DNO_CHECKED_ENTITY_FIELD=1" 502 fi 503 504 505 506fi 507 508dnl Here we added the check of the flag to determine if the user wants to force 509dnl the XML_OUTPUT_BUFFER code in XMLTree.c 510AC_CHECK_LIB(${USE_XMLLIB_NAME}, xmlOutputBufferCreateBuffer, [echo "have xmlOutputBufferCreateBuffer()"; if test "${ADD_XML_OUTPUT_BUFFER}" = "yes" ; then PKG_CPPFLAGS="${PKG_CPPFLAGS} -DADD_XML_OUTPUT_BUFFER_CODE=1"; else ADD_XML_OUTPUT_BUFFER=no ; fi; ], [ echo "Using local xmlOutputBufferCreateBuffer. You might think about installing a newer version of libxml2, at least 2.6.23" ; PKG_CPPFLAGS="${PKG_CPPFLAGS} -DADD_XML_OUTPUT_BUFFER_CODE=1"; ADD_XML_OUTPUT_BUFFER=1]) 511 512AC_CHECK_LIB(${USE_XMLLIB_NAME}, xmlDocDumpFormatMemoryEnc, PKG_CPPFLAGS="${PKG_CPPFLAGS} -DDUMP_WITH_ENCODING=1") 513 514if test -z "${FROM_GNOME_XML_DIR}" ; then 515 AC_CHECK_HEADER(libxml/xmlversion.h, PKG_CPPFLAGS="${PKG_CPPFLAGS} -DUSE_XML_VERSION_H=1") 516fi 517 518AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 519#ifdef FROM_GNOME_XML_DIR 520#include <gnome-xml/tree.h> 521#else 522#include <libxml/tree.h> 523#endif]], [[ 524 xmlElementPtr el; 525 int x; 526 x = el->etype; 527]])],[PKG_CPPFLAGS="${PKG_CPPFLAGS} -DXML_ELEMENT_ETYPE=1" 528],[]) 529 530AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 531#ifdef FROM_GNOME_XML_DIR 532#include <gnome-xml/tree.h> 533#else 534#include <libxml/tree.h> 535#endif]], [[ 536 xmlAttributePtr el; 537 int x; 538 x = el->atype; 539]])],[PKG_CPPFLAGS="${PKG_CPPFLAGS} -DXML_ATTRIBUTE_ATYPE=1" 540],[]) 541 542 543 544if test -n "${USE_EXPAT}" ; then 545 AC_CHECK_HEADER(xmltok/xmlparse.h, XMLPARSE_INCDIR="xmltok/") 546 if test -z "${XMLPARSE_INCDIR}" ; then 547 AC_CHECK_HEADER(xmlparse/xmlparse.h, XMLPARSE_INCDIR="xmlparse/") 548 fi 549 AC_EGREP_HEADER(XML_Parse, ${XMLPARSE_INCDIR}xmlparse.h, 550 HAVE_EXPAT_HEADER=true, 551 AC_MSG_ERROR("header file xmlparse.h seems to be incorrect")) 552 AC_CHECK_LIB(xmltok, XmlInitEncoding,,AC_MSG_ERROR("libxmltok not found")) 553 AC_CHECK_LIB(xmlparse, XML_Parse,, 554 AC_MSG_ERROR("libxmlparse not found"), -lxmltok) 555 PKG_CPPFLAGS="${PKG_CPPFLAGS} -DLIBEXPAT -I${XMLPARSE_INCDIR}" 556 LD_PATH="${LD_PATH}:${LIBXML_LIBDIR}" 557fi 558 559 560if test -n "${USE_EXPAT}" ; then 561 SUPPORTS_EXPAT="TRUE" 562else 563 SUPPORTS_EXPAT="FALSE" 564fi 565 566echo "Expat: ${USE_EXPAT} ${SUPPORTS_EXPAT}" 567 568if test -n "${USE_LIBXML}" ; then 569 SUPPORTS_LIBXML="TRUE" 570else 571 SUPPORTS_LIBXML="FALSE" 572fi 573 574 575 576if test -z "${USE_SPLUS}" ; then 577 578 LANGUAGE_DEFS="-DUSE_R=1 -D_R_=1 ${LANGUAGE_DEFS}" 579dnl PKG_SYS_FILE='system.file("scripts", name, pkg="RSPerl")' 580 581else 582 583 dnl Test to see if the patch has been made to renamin the attribute() 584 dnl routine in libxml 585 586 if test ${SUPPORTS_LIBXML}="TRUE" ; then 587 588 AC_CHECK_LIB(xml, attribute, NEED_LIBXML_PATCH=1) 589 if test -n "${NEED_LIBXML_PATCH}" ; then 590 echo "The XML package will not work with S-Plus and the current libxml" 591 echo "because of a conflict from both having a routine named attribute()" 592 echo "We suggest that you modify the SAX.c file in the libxml and re-install." 593 echo "See PATCH.attribute in this package's distribution." 594 exit 1 595 fi 596 597 fi # ? SUPPORTS_LIBXML = "TRUE" 598 599 LANGUAGE_DEFS="-D_S_=1 -DUSE_S=1 -D_S4_=1 -D_SPLUS${SPLUS_VERSION}_ -DNO_SPLUS_THREAD_DEF=1 ${LANGUAGE_DEFS}" 600 INSTALL_DIR=`pwd` 601 PKG_SYS_FILE="paste(\"${INSTALL_DIR}/inst/scripts/\", name,sep=\"\")" 602 603fi dnl end of if S-Plus. 604 605 606AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 607#include "parser.h" 608]], [[ 609 extern int xmlSkipBlankChars(xmlParserCtxtPtr ctxt); 610 xmlParserCtxtPtr p; 611 xmlSkipBlankChars(p); 612]])],[echo "No need for old SKIP_BLANKS definition" 613],[BLANKS_DEF="-DOLD_SKIP_BLANKS=1" 614]) 615 616 617if test -n "LIBXML2" ; then 618 619TMP_CFLAGS="${CFLAGS}" 620CFLAGS="${CFLAGS} -pedantic-errors" 621echo "Checking for return type of xmlHashScan element routine." 622 623AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 624#ifdef FROM_GNOME_XML_DIR 625#include <gnome-xml/SAX.h> 626#include <gnome-xml/hash.h> 627#else 628#include <libxml/SAX.h> 629#include <libxml/hash.h> 630#endif 631]], [[ 632 void *(*foo)(void *, void *, xmlChar*); 633 xmlElementTablePtr table; 634 xmlHashScan(table, foo, NULL); 635]])],[echo "xmlHashScan wants a return value."],[echo "No return value for xmlHashScan"; PKG_CPPFLAGS="${PKG_CPPFLAGS} -DNO_XML_HASH_SCANNER_RETURN=1" 636]) 637 638CFLAGS="${TMP_CFLAGS}" 639 640 641 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 642 #include <libxml/tree.h> 643 ]], [[ 644 xmlNsPtr ns; 645 ns->context; 646 ]])],[PKG_CPPFLAGS="$PKG_CPPFLAGS -DLIBXML_NAMESPACE_HAS_CONTEXT=1"; echo "xmlNs has a context field"],[echo "No context field in xmlNs structure."]) 647 648 649fi 650 651 652CPPFLAGS="$CPPFLAGS -I$R_HOME/include" 653echo "Checking for cetype_t enumeration" 654AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 655 #include <Rinternals.h> 656]], [[ 657 cetype_t t; 658]])],[PKG_CPPFLAGS="${PKG_CPPFLAGS} -DHAVE_R_CETYPE_T=1"; echo "Using recent version of R with cetype_t enumeration type for encoding"],[echo "No cetype_t enumeration defined in R headers."]) 659 660AC_SUBST(DUMP_WITH_ENCODING) 661 662PKG_LIBS=${LIBS} 663 664 665dnl ---------------------------------------------------- 666dnl Add -m to the linker flags (actually libraries) 667dnl to supress errors about multiple definitions of 668dnl symbols. 669dnl 670dnl This is not needed anymore as we no longer define 671dnl xmlParserError in our code and override the one 672dnl in libmxml. If we do find a situation (e.g. version 673dnl of libxml that doesn't allow us to play with routine 674dnl pointers to do this, we will need to define 675dnl NEED_XML_PARSER_ERROR 676dnl 677dnl AC_CANONICAL_HOST 678dnl Doesn't work on my machine. Where do we find it - R? 679 680if test -n "${NEED_XML_PARSER_ERROR}" ; then 681 AC_PATH_PROG(UNAME, uname) 682 if test -n "${UNAME}" ; then 683 host_os=`${UNAME}` 684 if test "${host_os}" = "Darwin" ; then 685 PKG_LIBS="-m $PKG_LIBS" 686 fi 687 fi 688fi 689 690 691dnl --------------------------------------------------- 692 693 694AC_PATH_PROGS(XMLSEC_CONFIG, xmlsec1-config) 695 696if test -n "$XMLSEC_CONFIG" ; then 697 PKG_CPPFLAGS="$PKG_CPPFLAGS `$XMLSEC_CONFIG --cflags`" 698 PKG_LIBS="$PKG_LIBS `$XMLSEC_CONFIG --libs`" 699 XMLSEC_DEFS=-DHAVE_LIBXML_SEC=1 700fi 701 702AC_ARG_ENABLE(nodegc, [ --enable-nodegc enable node garbage collection], 703 [ if test "${enableval}" = "yes" || test "${enableval}" = "default" ; then 704 LANGUAGE_DEFS="${LANGUAGE_DEFS} -DXML_REF_COUNT_NODES=1" 705 fi; 706 echo "enabling nodegc? ${enableval}"], 707 [echo "nodegc default $enableval"; LANGUAGE_DEFS="${LANGUAGE_DEFS} -DXML_REF_COUNT_NODES=1"]) 708 709 710 711AC_ARG_ENABLE(xml-debug, [ --enable-xml-debug enable debugging information, primarily for memory management], 712 [ if test "${enableval}" = "yes" || test "${enableval}" = "default" ; then 713 LANGUAGE_DEFS="${LANGUAGE_DEFS} -DR_XML_DEBUG=1" 714 fi; 715 echo "enabling xml-debug? ${enableval}"], 716 [echo "xml-debug default $enableval"; LANGUAGE_DEFS="${LANGUAGE_DEFS}"]) 717 718 719dnl --------------------------------------------------- 720 721AC_DEFUN([CHECK_ENUM], [ 722 723AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 724#ifdef FROM_GNOME_XML_DIR 725#include <gnome-xml/parser.h> 726#else 727#include <libxml/parser.h> 728#endif 729]], [[ 730 int val; 731 val = $1; 732]])],[PKG_CPPFLAGS="$PKG_CPPFLAGS -DHAVE_$1=1"; echo "Version has $1"],[echo "No $1 enumeration value."]) 733]) 734 735 736CHECK_ENUM(XML_WITH_ZLIB) 737 738 739 740AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 741#ifdef FROM_GNOME_XML_DIR 742#include <gnome-xml/parser.h> 743#else 744#include <libxml/parser.h> 745#endif 746]], [[ 747 xmlFeature f; 748 xmlHasFeature(f); 749]])],[PKG_CPPFLAGS="$PKG_CPPFLAGS -DHAVE_XML_HAS_FEATURE=1"; echo "Version has xmlHasFeature()"],[echo "No xmlHasFeature."]) 750 751 752 753 754dnl --------------------------------------------- 755 756 757AC_SUBST(XMLSEC_DEFS) 758 759AC_SUBST(LIBXML2) 760 761AC_SUBST(LANGUAGE_DEFS) 762AC_SUBST(LIBXML_INCDIR) 763AC_SUBST(XMLPARSE_INCDIR) 764AC_SUBST(PKG_LIBS) 765AC_SUBST(PKG_CPPFLAGS) 766 767AC_SUBST(SUPPORTS_LIBXML) 768AC_SUBST(SUPPORTS_EXPAT) 769 770AC_SUBST(LD_PATH) 771 772AC_SUBST(EXPORT_MEMORY_MANAGEMENT) 773 774if test -n "${USE_SPLUS}" ; then 775 AC_SUBST(SPLUS) 776 SPLUS_MAKEFILE=GNUmakefile.Splus 777fi 778 779 780echo "" 781echo "****************************************" 782echo "Configuration information:" 783echo "" 784echo "Libxml settings" 785echo "" 786echo "libxml include directory: ${LIBXML_INCDIR}" 787echo "libxml library directory: ${LIBS}" 788echo "libxml 2: ${LIBXML2-no}" 789echo "" 790echo "Compilation flags: ${PKG_CPPFLAGS} ${LANGUAGE_DEFS} $XMLSEC_DEFS" 791echo "Link flags: ${PKG_LIBS}" 792 793 794echo "" 795echo "****************************************" 796 797if test "$ADD_XML_OUTPUT_BUFFER" = "no" ; then 798 ADD_XML_OUTPUT_BUFFER=0 799fi 800if test "$ADD_XML_OUTPUT_BUFFER" = "yes" ; then 801 ADD_XML_OUTPUT_BUFFER=1 802fi 803 804AC_SUBST(ADD_XML_OUTPUT_BUFFER) 805 806 807if test -n "${_R_CHECK_TIMINGS_}" ; then 808 PKG_CPPFLAGS="$PKG_CPPFLAGS -DNO_XML_MEMORY_SHOW_ROUTINE=1" 809fi 810 811 812 dnl create the different targets 813 dnl We had NAMESPACE here when were conditionally exporting the functions to 814 dnl remove finalizers on a node or document. Need to add NAMESPACE.in in 815 dnl Install/GNUmakefile.admin 816AC_CONFIG_FILES([src/Makevars R/supports.R inst/scripts/RSXML.csh inst/scripts/RSXML.bsh ${SPLUS_MAKEFILE}]) 817AC_OUTPUT 818chmod +x cleanup 819 820 821 dnl Set things up for an S-Plus chapter. 822if test -n "${USE_SPLUS}" ; then 823 mv GNUmakefile.Splus GNUmakefile 824 825 echo "Creating S-Plus chapter" 826 cd src 827 C_SRC_FILES="DocParse.c RSDTD.c Utils.c" 828 ${SPLUS} CHAPTER ${C_SRC_FILES} 829 echo "include Makevars" >> makefile 830 echo 'CFLAGS:= $(PKG_CPPFLAGS) $(CFLAGS)' >> makefile 831 echo 'LOCAL_LIBS=$(PKG_LIBS) ' >> makefile 832 cd .. 833fi 834 835 836