From 7cdbb406e9476a3ee1080e6693d88639388457b4 Mon Sep 17 00:00:00 2001 From: Jeffrey Hanson Date: Sat, 4 Sep 2021 17:40:10 +1200 Subject: [PATCH] improve versioning for rwinlib dl --- src/Makevars.win | 7 ++++--- tools/winlibs.R | 13 +++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Makevars.win b/src/Makevars.win index 050a207..ccadb75 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -8,8 +8,9 @@ CXX_STD = CXX11 PKG_CPPFLAGS = -I$(RWINLIB)/include -PKG_LIBS = -L$(RWINLIB)/lib$(BUILD)$(R_ARCH)$(CRT) \ - -L$(RWINLIB)/lib$(R_ARCH) \ +PKG_LIBS = \ + -L$(RWINLIB)/lib$(BUILD) \ + -L$(RWINLIB)/lib$(R_ARCH)$(CRT) \ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) \ -lmpfr -lgmp -lgmpxx @@ -19,6 +20,6 @@ clean: rm -f $(SHLIB) $(OBJECTS) winlibs: - "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" + "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION) .PHONY: all winlibs clean diff --git a/tools/winlibs.R b/tools/winlibs.R index ed41e92..640aa62 100644 --- a/tools/winlibs.R +++ b/tools/winlibs.R @@ -1,12 +1,17 @@ +# Determine GMP version from command line arguments +VERSION <- commandArgs(TRUE) + +# Verify R version validity if (getRversion() < "3.3.0") { stop("R version too old. On Windows this package requires at least R-3.3") } -# Download gmp-6.1.2 from rwinlib -if (!file.exists("../windows/gmp-6.1.2/include/gmpxx.hpp")) { +# Download GMP from rwinlib (https://github.com/rwinlib/gmp) +test_file <- sprintf("../windows/gmp-%s/include/gmpxx.h", VERSION) +if (!file.exists(test_file)) { download.file( - "https://github.com/rwinlib/gmp/archive/v6.1.2.zip", "lib.zip", - quiet = TRUE) + sprintf("https://github.com/rwinlib/gmp/archive/v%s.zip", VERSION), + "lib.zip", quiet = TRUE) dir.create("../windows", showWarnings = FALSE) unzip("lib.zip", exdir = "../windows") unlink("lib.zip")