diff --git a/src/Makevars.win b/src/Makevars.win index badc575d..49d9e77c 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,18 +1,24 @@ -VERSION=2.10.3 -RWINLIB=../windows/libxml2-$(VERSION) -PKG_CPPFLAGS=-I../inst/include -I$(RWINLIB)/include/libxml2 \ - -DLIBXML_STATIC +PKG_CONFIG_NAME = libxml-2.0 +PKG_CONFIG ?= $(BINPREF)pkg-config +PKG_LIBS := $(shell $(PKG_CONFIG) --libs $(PKG_CONFIG_NAME)) +STATIC_CFLAGS = -DLIBXML_STATIC -I../inst/include +ifneq ($(PKG_LIBS),) +$(info using $(PKG_CONFIG_NAME) from Rtools) +PKG_CPPFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_CONFIG_NAME)) $(STATIC_CFLAGS) +else +RWINLIB = ../windows/libxml2-2.10.3 +PKG_CPPFLAGS = -I$(RWINLIB)/include -I$(RWINLIB)/include/libxml2 $(STATIC_CFLAGS) PKG_LIBS = -L$(RWINLIB)/lib${subst gcc,,$(COMPILED_BY)}$(R_ARCH) \ - -L$(RWINLIB)/lib$(R_ARCH)\ - -lxml2 -llzma -liconv -lz -lws2_32 + -L$(RWINLIB)/lib$(R_ARCH) -lxml2 -llzma -liconv -lz -lws2_32 +endif -all: clean winlibs +all: $(SHLIB) -clean: - rm -f $(OBJECTS) $(SHLIB) +$(OBJECTS): $(RWINLIB) -winlibs: - "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION) +$(RWINLIB): + "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" -.PHONY: all winlibs clean +clean: + rm -f $(SHLIB) $(OBJECTS) diff --git a/tools/winlibs.R b/tools/winlibs.R index c327922f..36cf6b81 100644 --- a/tools/winlibs.R +++ b/tools/winlibs.R @@ -1,8 +1,6 @@ # 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) +if(!file.exists("../windows/libxml2-2.10.3/include/libxml2/libxml/parser.h")){ + download.file("https://github.com/rwinlib/libxml2/archive/v2.10.3.zip", "lib.zip", quiet = TRUE) dir.create("../windows", showWarnings = FALSE) unzip("lib.zip", exdir = "../windows") unlink("lib.zip")