Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapted from openssl by @jeroen #31

Merged
merged 3 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
^codecov\.yml$
.lintr
^configure.log$
^README.Rmd$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Suggests:
testthat
LinkingTo: Rcpp, BH
ByteCompile: yes
SystemRequirements: OpenSSL >= 1.0.1
SystemRequirements: OpenSSL >= 1.0.2
VignetteBuilder: knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
20 changes: 15 additions & 5 deletions configure
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Anticonf (tm) script by Jeroen Ooms (2020)
# Anticonf (tm) script by Jeroen Ooms (2023)
# 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:
Expand All @@ -17,8 +17,13 @@ PKG_CFLAGS=""
# Build against a specific openssl version
# export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

# On MacOS we avoid legacy versions of openssl
if [ `uname` = "Darwin" ]; then
MINVERSION="--atleast-version=3"
fi

# Use pkg-config if available
pkg-config ${PKG_CONFIG_NAME} --atleast-version=1.0 2>/dev/null
pkg-config ${PKG_CONFIG_NAME} ${MINVERSION} 2>/dev/null
if [ $? -eq 0 ]; then
PKGCONFIG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME}`
PKGCONFIG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`
Expand All @@ -37,14 +42,19 @@ elif [ `uname` = "Darwin" ]; then
test ! "$CI" && brew --version 2>/dev/null
if [ $? -eq 0 ]; then
BREWDIR=`brew --prefix`
PKG_CFLAGS="-I$BREWDIR/opt/openssl/include -I$BREWDIR/opt/[email protected]/include"
PKG_LIBS="-L$BREWDIR/opt/openssl/lib -L$BREWDIR/opt/[email protected]/lib $PKG_LIBS"
PKG_CFLAGS="-I$BREWDIR/opt/openssl/include"
PKG_LIBS="-L$BREWDIR/opt/openssl/lib $PKG_LIBS"
else
curl -sfL "https://autobrew.github.io/scripts/$PKG_BREW_NAME" > autobrew
. ./autobrew
fi
fi

# Fix broken homebrew [email protected]
if echo "$PKG_LIBS" | grep -q '/opt/homebrew/Cellar/openssl@3/3.3.0 -lssl -lcrypto'; then
PKG_LIBS=$(echo "$PKG_LIBS" | sed 's|/opt/homebrew/Cellar/openssl@3/3.3.0|/opt/homebrew/Cellar/openssl@3/3.3.0/lib|g')
fi

# Find compiler
CC=`${R_HOME}/bin/R CMD config CC`
CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
Expand Down Expand Up @@ -76,7 +86,7 @@ fi

# Try to link against the correct OpenSSL version
if [ -z "$AUTOBREW" ]; then
SONAME=`${CC} -E ${PKG_CFLAGS} src/tests/soname.h | sh | xargs`
SONAME=`${CC} -E ${PKG_CFLAGS} src/tests/soname.h | grep 'echo' | sh | xargs`
if [ "$SONAME" ]; then
if [ `uname` = "Darwin" ]; then
PKG_LIBS_VERSIONED=`echo "${PKG_LIBS}" | sed "s/-lssl/-lssl.${SONAME}/" | sed "s/-lcrypto/-lcrypto.${SONAME}/"`
Expand Down
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')
}
Loading