xslt/0000755000176200001440000000000014375165202011251 5ustar liggesusersxslt/NAMESPACE0000644000176200001440000000027114375146460012475 0ustar liggesusers# Generated by roxygen2: do not edit by hand S3method(xml_xslt,xml_document) export(xml_xslt) export(xslt_version) importFrom(Rcpp,sourceCpp) importFrom(xml2,read_xml) useDynLib(xslt) xslt/tools/0000755000176200001440000000000014375146460012416 5ustar liggesusersxslt/tools/winlibs.R0000644000176200001440000000066614375146460014220 0ustar liggesusers# Build against static libraries from rwinlib VERSION <- commandArgs(TRUE) if(!file.exists(sprintf("../windows/libxml2-%s/include/libxml2/libxml/parser.h", VERSION))){ if(getRversion() < "3.3.0") setInternet2() download.file(sprintf("https://github.com/rwinlib/libxml2/archive/v%s.zip", VERSION), "lib.zip", quiet = TRUE) dir.create("../windows", showWarnings = FALSE) unzip("lib.zip", exdir = "../windows") unlink("lib.zip") } xslt/man/0000755000176200001440000000000014375146460012031 5ustar liggesusersxslt/man/xslt.Rd0000644000176200001440000000236614375146460013321 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/xml_xslt.R \name{xslt} \alias{xslt} \alias{xml_xslt} \alias{xslt_version} \title{XSLT 1.0 Transformations} \usage{ xml_xslt(doc, stylesheet, params) xslt_version() } \arguments{ \item{doc}{xml document as returned by \link[xml2:read_xml]{xml2::read_xml}} \item{stylesheet}{another xml document containing the XSL stylesheet} \item{params}{named list or vector with additional XSLT parameters} } \description{ Transform an XML document by applying an XSL stylesheet. Usually returns the transformed \link[xml2:xml_new_document]{xml_document}, unless the stylesheet has \code{} in which case we return a text string. } \details{ This implementation supports XSLT 1.0 features plus most of the EXSLT set of processor-portable extensions functions. Unfortunately XSLT 2.0 or 3.0 features are only available in proprietary libraries and currently unsupported. However XSLT 2.0 is not widely adopted anyway because it is unavailable in most browsers. } \examples{ doc <- read_xml(system.file("examples/cd_catalog.xml", package = "xslt")) style <- read_xml(system.file("examples/cd_catalog.xsl", package = "xslt")) html <- xml_xslt(doc, style) cat(as.character(html)) } xslt/DESCRIPTION0000644000176200001440000000161014375165202012755 0ustar liggesusersPackage: xslt Version: 1.4.4 Title: Extensible Style-Sheet Language Transformations Description: An extension for the 'xml2' package to transform XML documents by applying an 'xslt' style-sheet. Authors@R: person("Jeroen", "Ooms", role = c("aut", "cre"), email = "jeroen@berkeley.edu", comment = c(ORCID = "0000-0002-4035-0289")) Maintainer: Jeroen Ooms URL: https://ropensci.r-universe.dev/xslt https://docs.ropensci.org/xslt/ BugReports: https://github.com/ropensci/xslt/issues Depends: xml2 (>= 1.3.0) Imports: Rcpp LinkingTo: Rcpp, xml2 SystemRequirements: libxslt: libxslt1-dev (deb), libxslt-devel (rpm) License: GPL (>= 2) RoxygenNote: 6.0.1 Suggests: testthat NeedsCompilation: yes Packaged: 2023-02-21 15:19:49 UTC; jeroen Author: Jeroen Ooms [aut, cre] () Repository: CRAN Date/Publication: 2023-02-21 16:00:02 UTC xslt/tests/0000755000176200001440000000000014375146460012420 5ustar liggesusersxslt/tests/testthat/0000755000176200001440000000000014375165202014253 5ustar liggesusersxslt/tests/testthat/cd_catalog.html0000644000176200001440000000142714375146460017232 0ustar liggesusers

My CD Collection

Title Artist
Empire Burlesque Bob Dylan
Still got the blues Gary Moore
One night only Bee Gees
Romanza Andrea Bocelli
Black angel Savage Rose
1999 Grammy Nominees Many
xslt/tests/testthat/test-xslt.R0000644000176200001440000000154414375146460016356 0ustar liggesuserscontext("Transformation") test_that("XML document gets properly transformed using a stylesheet", { doc <- read_xml(system.file("examples/cd_catalog.xml", package = "xslt")) style <- read_xml(system.file("examples/cd_catalog.xsl", package = "xslt")) orig <- read_xml("cd_catalog.html") # Test several times to make sure the original docs do not get corrupted for(i in 1:5){ html <- xml_xslt(doc, style) expect_equal(as.character(html, options = "as_html"), as.character(orig, options = "as_html")) } }) # Example from https://github.com/ropensci/xslt/issues/1 test_that("XSLT output mode=text", { doc <- read_xml(system.file("examples/example.xml", package = "xslt")) style <- read_xml(system.file("examples/list.xsl", package = "xslt")) for(i in 1:5){ output <- xml_xslt(doc, style) expect_is(output, "character") } }) xslt/tests/testthat/doc.xml0000644000176200001440000000006014375146460015543 0ustar liggesusers xslt/tests/testthat/style.xml0000644000176200001440000000103114375146460016135 0ustar liggesusers author: reviewer: xslt/tests/testthat/test-param.R0000644000176200001440000000051014375146460016454 0ustar liggesuserscontext("Parameters") test_that("parameters are rendered", { doc <- xml2::read_xml("doc.xml") style <- xml2::read_xml("style.xml") expect_equal(xml_xslt(doc, style), "author: \nreviewer: \n") expect_equal(xml_xslt(doc, style, c(author="jeroen", reviewer="bert")), "author: jeroen\nreviewer: bert\n") }) xslt/tests/testthat.R0000644000176200001440000000006414375146460014403 0ustar liggesuserslibrary(testthat) library(xslt) test_check("xslt") xslt/src/0000755000176200001440000000000014375160163012041 5ustar liggesusersxslt/src/xslt.cpp0000644000176200001440000000242714375156201013542 0ustar liggesusers#include #include using namespace Rcpp; #include #include #include "xslt_types.h" extern char xsltlasterr[1024]; // [[Rcpp::export]] SEXP doc_xslt_apply(XPtrDoc doc, XPtrDoc xslt, std::vector params) { xmlDocPtr docPtr = xmlCopyDoc(doc.checked_get(), 1); xmlDocPtr sheetPtr = xmlCopyDoc(xslt.checked_get(), 1); xsltStylesheetPtr xsltPtr = xsltParseStylesheetDoc(sheetPtr); if(!xsltPtr) throw std::runtime_error(std::string("fatal problem(s) in xsltParseStylesheetDoc: ") + xsltlasterr); const char ** strparam = (const char **) calloc(params.size() + 1, sizeof(char*)); for(size_t i = 0; i < params.size(); i++) strparam[i] = params.at(i).c_str(); xmlDocPtr res = xsltApplyStylesheet(xsltPtr, docPtr, strparam); if(!res) throw std::runtime_error(std::string("fatal problem(s) in xsltApplyStylesheet: ") + xsltlasterr); if(xsltPtr->method && !strcmp("text", (char *) xsltPtr->method)){ xmlChar * str; int len; xsltSaveResultToString(&str, &len, res, xsltPtr); free(strparam); xmlFreeDoc(docPtr); xmlFreeDoc(sheetPtr); return Rcpp::CharacterVector(std::string((char*) str, len)); } free(strparam); xmlFreeDoc(docPtr); xmlFreeDoc(sheetPtr); return XPtrDoc(res); } xslt/src/Makevars.win0000644000176200001440000000076614375155307014346 0ustar liggesusersVERSION=2.10.3 RWINLIB=../windows/libxml2-$(VERSION) PKG_CPPFLAGS=-I$(RWINLIB)/include -I$(RWINLIB)/include/libxml2 \ -DLIBXML_STATIC -DLIBXSLT_STATIC -DLIBEXSLT_STATIC -DSTRICT_R_HEADERS PKG_LIBS = -L$(RWINLIB)/lib${subst gcc,,$(COMPILED_BY)}$(R_ARCH) \ -L$(RWINLIB)/lib$(R_ARCH)\ -lexslt -lxslt -lxml2 -llzma -liconv -lz -lws2_32 all: clean winlibs clean: rm -f $(OBJECTS) $(SHLIB) winlibs: "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION) .PHONY: all winlibs clean xslt/src/xslt_init.cpp0000644000176200001440000000266414375156353014600 0ustar liggesusers#include #include #include #include #include #include #include char xsltlasterr[1024] = {0}; void handleXsltError(void *ctx, const char *msg, ...){ va_list arg_ptr; va_start(arg_ptr, msg); vsnprintf(xsltlasterr, 1024, msg, arg_ptr); REprintf("xslt error: %s", xsltlasterr); } void handleError(void* userData, xmlError* error) { std::string message = std::string(error->message); message.resize(message.size() - 1); // trim off trailing newline if (error->level <= 2) { Rcpp::warning("%s [%i]", message, error->code); } else { Rcpp::stop("%s [%i]", message, error->code); } } extern "C" { void R_init_xslt(DllInfo *info) { // Check that header and libs are compatible LIBXML_TEST_VERSION xmlInitParser(); xmlSetStructuredErrorFunc(NULL, handleError); #if LIBXSLT_VERSION > 10115 xsltInit(); #endif xsltSetGenericErrorFunc(NULL, (xmlGenericErrorFunc) handleXsltError); exsltRegisterAll(); /* Required by R 3.4 */ R_registerRoutines(info, NULL, NULL, NULL, NULL); R_useDynamicSymbols(info, (Rboolean) TRUE); } void R_unload_xlst(DllInfo *info) { xsltCleanupGlobals(); } } // [[Rcpp::export]] std::string libxml2_version(){ return LIBXML_DOTTED_VERSION; } // [[Rcpp::export]] std::string libxslt_version(){ return LIBXSLT_DOTTED_VERSION; } xslt/src/Makevars.in0000644000176200001440000000015014375146460014142 0ustar liggesusersPKG_CPPFLAGS=@cflags@ -DSTRICT_R_HEADERS PKG_LIBS=@libs@ all: clean clean: rm -f $(OBJECTS) $(SHLIB) xslt/src/RcppExports.cpp0000644000176200001440000000271714375155307015051 0ustar liggesusers// Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #include "xslt_types.h" #include using namespace Rcpp; #ifdef RCPP_USE_GLOBAL_ROSTREAM Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); #endif // doc_xslt_apply SEXP doc_xslt_apply(XPtrDoc doc, XPtrDoc xslt, std::vector params); RcppExport SEXP _xslt_doc_xslt_apply(SEXP docSEXP, SEXP xsltSEXP, SEXP paramsSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< XPtrDoc >::type doc(docSEXP); Rcpp::traits::input_parameter< XPtrDoc >::type xslt(xsltSEXP); Rcpp::traits::input_parameter< std::vector >::type params(paramsSEXP); rcpp_result_gen = Rcpp::wrap(doc_xslt_apply(doc, xslt, params)); return rcpp_result_gen; END_RCPP } // libxml2_version std::string libxml2_version(); RcppExport SEXP _xslt_libxml2_version() { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = Rcpp::wrap(libxml2_version()); return rcpp_result_gen; END_RCPP } // libxslt_version std::string libxslt_version(); RcppExport SEXP _xslt_libxslt_version() { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = Rcpp::wrap(libxslt_version()); return rcpp_result_gen; END_RCPP } xslt/src/xslt_types.h0000644000176200001440000000003014375146460014425 0ustar liggesusers#include xslt/NEWS0000644000176200001440000000171514375157541011763 0ustar liggesusers1.4.4 - Fix a bug that would cause a crash for some invalid xslt input (#11) - Windows: update to libxml2 2.10.3 and libxslt 1.1.37 1.4.3 - Windows: update to libxml2 2.9.10 and libxslt 1.1.34 1.4.2 - Explicitly link to liblzma on MacOS to fix problem on CRAN. 1.4.1 - Fix build on CRAN MacOS (without pkg-config) 1.4 - Windows: update to libxml2 2.9.8 and libxslt 1.1.32 - now print a message instead of erroring - Force rebuild because libxml2 ABI has changed due to rcpp removal - Configure: include sdk path on MacOS 1.3 - Fix a pedantic warning about variable length arrays 1.2 - Add support for setting custom xslt parameters 1.1 - For stylesheets with output method="text" return a string instead of xml object - Fix a crash on Windows by making copies of the input docs before transforming - More stress testing in unit tests - Export xslt_version() function - Update maintainer details 1.0 - Initial release xslt/configure.win0000644000176200001440000000000014375146460013744 0ustar liggesusersxslt/R/0000755000176200001440000000000014375156210011451 5ustar liggesusersxslt/R/RcppExports.R0000644000176200001440000000065114375156210014067 0ustar liggesusers# Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 doc_xslt_apply <- function(doc, xslt, params) { .Call('_xslt_doc_xslt_apply', PACKAGE = 'xslt', doc, xslt, params) } libxml2_version <- function() { .Call('_xslt_libxml2_version', PACKAGE = 'xslt') } libxslt_version <- function() { .Call('_xslt_libxslt_version', PACKAGE = 'xslt') } xslt/R/xml_xslt.R0000644000176200001440000000335314375146460013460 0ustar liggesusers#' XSLT 1.0 Transformations #' #' Transform an XML document by applying an XSL stylesheet. Usually returns the #' transformed [xml_document][xml2::xml_new_document], unless the stylesheet has #' `` in which case we return a text string. #' #' This implementation supports XSLT 1.0 features plus most of the EXSLT set of #' processor-portable extensions functions. Unfortunately XSLT 2.0 or 3.0 features #' are only available in proprietary libraries and currently unsupported. However #' XSLT 2.0 is not widely adopted anyway because it is unavailable in most browsers. #' #' @export #' @rdname xslt #' @name xslt #' @useDynLib xslt #' @importFrom xml2 read_xml #' @importFrom Rcpp sourceCpp #' @param doc xml document as returned by [xml2::read_xml] #' @param stylesheet another xml document containing the XSL stylesheet #' @param params named list or vector with additional XSLT parameters #' @examples doc <- read_xml(system.file("examples/cd_catalog.xml", package = "xslt")) #' style <- read_xml(system.file("examples/cd_catalog.xsl", package = "xslt")) #' html <- xml_xslt(doc, style) #' cat(as.character(html)) xml_xslt <- function(doc, stylesheet, params){ UseMethod("xml_xslt") } #' @export xml_xslt.xml_document <- function(doc, stylesheet, params = NULL){ as_xml2 <- utils::getFromNamespace("xml_document", "xml2") stopifnot(inherits(stylesheet, "xml_document")) paramstr <- c(rbind(names(params), vapply(params, deparse, character(1)))) out <- doc_xslt_apply(doc$doc, stylesheet$doc, paramstr) if(is.character(out)) return(out) as_xml2(out) } #' @export #' @rdname xslt xslt_version <- function(){ list( xml2 = as.package_version(libxml2_version()), xslt = as.package_version(libxslt_version()) ) } xslt/MD50000644000176200001440000000251714375165202011566 0ustar liggesusersb4ec2eaf631dfe97ca1a6280d60636c1 *DESCRIPTION c74a7e20d534b588a75e4b808e16d2d2 *NAMESPACE 7aebd49193482a263fc12962034f9c0e *NEWS 8bbfe7f75278c94f56fde811cfd4917c *R/RcppExports.R 5460c4461bca804279b4c13fa4d1e1bb *R/xml_xslt.R 6071edd604dbeb75308cfbedc7790398 *cleanup 748d4770c2d2d7da9c3bd8313a9dd16d *configure d41d8cd98f00b204e9800998ecf8427e *configure.win 8729e9322e3522ac59acfc5f7c4f5f6e *inst/examples/cd_catalog.xml d68c4c1a791db9a8770d38e3eac3b1d4 *inst/examples/cd_catalog.xsl 249db4372d7793d1cd67cdff12ecb0e7 *inst/examples/example.xml 7107144ffe722c93b0fb1998bb976247 *inst/examples/list.xsl 3476778133a6ef688ffaaf7c4f1f8035 *man/xslt.Rd 5b7e45551afb537a5882cdcf6ff01790 *src/Makevars.in b680d89dd8561476ecad430e727941e0 *src/Makevars.win e4a6e77d745a7759abd41166170e1768 *src/RcppExports.cpp 523998a8fa0376a5e6be9ab7c7db4e6e *src/xslt.cpp ebb974054fe1be0932966bd636284748 *src/xslt_init.cpp 857cf2cf2c6fe1328620321b0e49b351 *src/xslt_types.h c189b8747dc38b0c9b3feeeaeb666ffd *tests/testthat.R 80fa95ee4ea8574f9757be5287de7dc7 *tests/testthat/cd_catalog.html 3f73feb1d048cc7c30d4caa9a6659069 *tests/testthat/doc.xml 6fc718f9bc236d38ffd8088e898e6149 *tests/testthat/style.xml 7aba5949af9369da8b8ba678cdbebfb1 *tests/testthat/test-param.R 1e20af70e82c931a04c3a0b8077ed27b *tests/testthat/test-xslt.R 3e59936d5eff44f9725265ab5a253510 *tools/winlibs.R xslt/inst/0000755000176200001440000000000014375146460012233 5ustar liggesusersxslt/inst/examples/0000755000176200001440000000000014375146460014051 5ustar liggesusersxslt/inst/examples/cd_catalog.xml0000644000176200001440000001137614375146460016663 0ustar liggesusers Empire Burlesque Bob Dylan USA Columbia 10.90 1985 Hide your heart Bonnie Tyler UK CBS Records 9.90 1988 Greatest Hits Dolly Parton USA RCA 9.90 1982 Still got the blues Gary Moore UK Virgin records 10.20 1990 Eros Eros Ramazzotti EU BMG 9.90 1997 One night only Bee Gees UK Polydor 10.90 1998 Sylvias Mother Dr.Hook UK CBS 8.10 1973 Maggie May Rod Stewart UK Pickwick 8.50 1990 Romanza Andrea Bocelli EU Polydor 10.80 1996 When a man loves a woman Percy Sledge USA Atlantic 8.70 1987 Black angel Savage Rose EU Mega 10.90 1995 1999 Grammy Nominees Many USA Grammy 10.20 1999 For the good times Kenny Rogers UK Mucik Master 8.70 1995 Big Willie style Will Smith USA Columbia 9.90 1997 Tupelo Honey Van Morrison UK Polydor 8.20 1971 Soulsville Jorn Hoel Norway WEA 7.90 1996 The very best of Cat Stevens UK Island 8.90 1990 Stop Sam Brown UK A and M 8.90 1988 Bridge of Spies T`Pau UK Siren 7.90 1987 Private Dancer Tina Turner UK Capitol 8.90 1983 Midt om natten Kim Larsen EU Medley 7.80 1983 Pavarotti Gala Concert Luciano Pavarotti UK DECCA 9.90 1991 The dock of the bay Otis Redding USA Atlantic 7.90 1987 Picture book Simply Red EU Elektra 7.20 1985 Red The Communards UK London 7.80 1987 Unchain my heart Joe Cocker USA EMI 8.20 1987 xslt/inst/examples/list.xsl0000644000176200001440000000216514375146460015560 0ustar liggesusers Label,Proposal_ID,Directorate,Division,Submission_Date "",,,, (), xslt/inst/examples/example.xml0000644000176200001440000017007514375146460016240 0ustar liggesusers true 110 0.4944445 60.6666 0.1405229 true 107 5.0202293 0.0 20161004 AAA DMS MPS 1111111 20161010 BBB EAR GEO 1111111 20161003 CCC CHE MPS 2222222 20161005 DDD DUE EHR 3333333 20161010 EEE IIP ENG 4444444 20161005 FFF CBET ENG 5555555 20161005 GGG DUE EHR 6666666 20161007 HHH CBET ENG 7777777 20161011 III IIP ENG 8888888 byQuery 2147483647 oil AND water AND fish standard 500 Proposal_Title$phrases 2.0 Project_Summary$phrases 1.0 Project_Description$phrases 1.0 2 8 3 2.9 2.5 2.5 0.0 0.0 0.0 0.0 project default 2 0.002 1.0 0.2 PREFER_SCOPE_SPECIFIC 1.5 0.0 0.5 0.35 0.4 0.1 0 1.0 1.0 0.4 1.0 0.0 1.0 1.0 1.0 1.0 1.0 true ap 2000 100 4 0.8999999761581421 0.8999999761581421 0.30000001192092896 -40.0 DF 1.0 cooccurrences 32 1.0 RR 8 true 100000 false ap 1000 100 4 0.8999999761581421 0.8999999761581421 0.30000001192092896 -1.0 false 7 mlt 100 20 2 8 true xml Proposal_ID true ORIGINAL false 10 false true true false true 20 2 true Proposal_ID 3 160 false false ⁌%s⁍ ⁌\%s⁍ Proposal_Title 3 160 false false ⁌%s⁍ ⁌\%s⁍ Directorate 3 160 false false ⁌%s⁍ ⁌\%s⁍ Division 3 160 false false ⁌%s⁍ ⁌\%s⁍ Submission_Date 3 160 false false ⁌%s⁍ ⁌\%s⁍ auto 1.0 0.1 8 true false xslt/inst/examples/cd_catalog.xsl0000644000176200001440000000114314375146460016660 0ustar liggesusers

My CD Collection

Title Artist
xslt/cleanup0000755000176200001440000000003514375160425012626 0ustar liggesusers#!/bin/sh rm -f src/Makevars xslt/configure0000755000176200001440000000535714375160425013174 0ustar liggesusers# Anticonf (tm) script by Jeroen Ooms (2020) # This script will query 'pkg-config' for the required cflags and ldflags. # If pkg-config is unavailable or does not find the library, try setting # INCLUDE_DIR and LIB_DIR manually via e.g: # R CMD INSTALL --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib' # Library settings PKG_CONFIG_NAME="libexslt" PKG_DEB_NAME="libxslt1-dev" PKG_RPM_NAME="libxslt-devel" PKG_CSW_NAME="libxslt_dev" PKG_TEST_HEADER="" PKG_CFLAGS="-I/usr/include/libxml2" PKG_LIBS="-lexslt -lxslt -lxml2" # Use pkg-config if available if [ `command -v pkg-config` ]; then PKGCONFIG_CFLAGS=`pkg-config --cflags --silence-errors $PKG_CONFIG_NAME` PKGCONFIG_LIBS=`pkg-config --libs $PKG_CONFIG_NAME` fi # Workaround: add SDK path on MacOS # Only -I include the libxml2 subdir, otherwise we can get header conflicts! if [ `uname` = "Darwin" ]; then XML2DIR=`xml2-config --cflags | sed 's#/usr/include$#/usr/include/libxml2#g'` PKGCONFIG_CFLAGS="${XML2DIR} ${PKGCONFIG_CFLAGS}" PKGCONFIG_LIBS="${PKGCONFIG_LIBS:-$PKG_LIBS} -llzma" fi # Note that cflags may be empty in case of success if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then echo "Found INCLUDE_DIR and/or LIB_DIR!" PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS" PKG_LIBS="-L$LIB_DIR $PKG_LIBS" elif [ "$PKGCONFIG_LIBS" ]; then echo "Found pkg-config cflags and libs!" PKG_CFLAGS=${PKGCONFIG_CFLAGS} PKG_LIBS=${PKGCONFIG_LIBS} fi # Find compiler CC=`${R_HOME}/bin/R CMD config CC` CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS` CPPFLAGS=`${R_HOME}/bin/R CMD config CPPFLAGS` # For debugging echo "Using PKG_CFLAGS=$PKG_CFLAGS" echo "Using PKG_LIBS=$PKG_LIBS" # Test configuration echo "#include $PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2>configure.log # Customize the error if [ $? -ne 0 ]; then echo "-----------------------------[ ANTICONF ]-------------------------------" echo "Configuration failed to find $PKG_CONFIG_NAME library. Try installing:" echo " * deb: $PKG_DEB_NAME (Debian, Ubuntu, etc)" echo " * rpm: $PKG_RPM_NAME (Fedora, CentOS, RHEL)" echo " * csw: $PKG_CSW_NAME (Solaris)" echo "If $PKG_CONFIG_NAME is already installed, check that 'pkg-config' is in your" echo "PATH and PKG_CONFIG_PATH contains a $PKG_CONFIG_NAME.pc file. If pkg-config" echo "is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:" echo "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'" echo "---------------------------[ ERROR MESSAGE ]----------------------------" cat configure.log echo "------------------------------------------------------------------------" exit 1 fi # Write to Makevars sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > src/Makevars # Success exit 0