Skip to content

Commit

Permalink
adapted from openssl by @jeroen
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Apr 26, 2024
1 parent d5ef401 commit 129a4f6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
PKG_CPPFLAGS = @cflags@
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` -lz @libs@
PKG_LIBS = -lz @libs@

all: clean

$(SHLIB): $(OBJECTS)

clean:
rm -f $(OBJECTS) $(SHLIB)
2 changes: 0 additions & 2 deletions src/Makevars.ucrt

This file was deleted.

24 changes: 18 additions & 6 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
VERSION=1.1.1k
PKG_CPPFLAGS= -I../windows/openssl-$(VERSION)/include
PKG_LIBS = -L../windows/openssl-$(VERSION)/lib${R_ARCH}${CRT} -lz -lcrypto -lws2_32 -lcrypt32
RWINLIB = ../windows/libssl
TARGET = lib$(subst gcc,,$(COMPILED_BY))$(R_ARCH)
PKG_CPPFLAGS = -I$(RWINLIB)/include -DOPENSSL_SUPPRESS_DEPRECATED

all: clean winlibs
PKG_LIBS = \
-L$(RWINLIB)/$(TARGET) \
-L$(RWINLIB)/lib \
-lssl -lcrypto -lz -lws2_32 -lcrypt32

#all: clean
all: $(SHLIB)

$(OBJECTS): winlibs

$(SHLIB): $(OBJECTS)

winlibs:
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R"

clean:
rm -f $(SHLIB) $(OBJECTS)

winlibs:
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION)
.PHONY: all clean winlibs
24 changes: 16 additions & 8 deletions tools/winlibs.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Build against mingw-w64 build of openssl
VERSION <- commandArgs(TRUE)
if (!file.exists(sprintf("../windows/openssl-%s/include/openssl/ssl.h", VERSION))){
if (getRversion() < "3.3.0") setInternet2()
download.file(sprintf("https://github.com/rwinlib/openssl/archive/v%s.zip", VERSION),
"lib.zip", quiet = TRUE)
if(!file.exists("../windows/libssl/include/openssl/pem.h")){
unlink("../windows", recursive = TRUE)
url <- if(grepl("aarch", R.version$platform)){
"https://github.com/r-windows/bundles/releases/download/openssl-3.1.2/openssl-3.1.2-clang-aarch64.tar.xz"
} else if(grepl("clang", Sys.getenv('R_COMPILED_BY'))){
"https://github.com/r-windows/bundles/releases/download/openssl-3.1.2/openssl-3.1.2-clang-x86_64.tar.xz"
} else if(getRversion() >= "4.2") {
"https://github.com/r-windows/bundles/releases/download/openssl-3.1.2/openssl-3.1.2-ucrt-x86_64.tar.xz"
} else {
"https://github.com/rwinlib/openssl/archive/v3.1.1.tar.gz"
}
download.file(url, basename(url), quiet = TRUE)
dir.create("../windows", showWarnings = FALSE)
unzip("lib.zip", exdir = "../windows")
unlink("lib.zip")
untar(basename(url), exdir = "../windows", tar = 'internal')
unlink(basename(url))
setwd("../windows")
file.rename(list.files(), 'libssl')
}

0 comments on commit 129a4f6

Please sign in to comment.