jeroen / openssl

OpenSSL bindings for R
Other
63 stars 21 forks source link

Weaken dependency on homebrew (OSX) #18

Closed daitakahashi closed 8 years ago

daitakahashi commented 8 years ago

The current configure script unconditionally assumes that OSX users use either homebrew's openssl or outdated one. Homebrew is a major packaging system in OSX, though, still alternative systems are available and actively developed (e.g., macports and fink). Those systems also provide well updated openssl, therefore, unconditional reliance on homebrew may result in unnecessarily download of a bottle. Here I propose a simple fix on configure. It checks openssl's version if pkg-config is available. Thank you very much.

--- configure.orig  2016-03-01 22:27:34.000000000 +0100
+++ configure   2016-03-01 22:22:38.000000000 +0100
@@ -14,20 +14,18 @@
 PKG_LIBS="-lssl -lcrypto"
 PKG_CFLAGS=""

+LEAST_ACCEPTABLE_OPENSSL_VERSION=0.9.9
+
 # Use pkg-config if available
 pkg-config --version >/dev/null 2>&1
 if [ $? -eq 0 ]; then
-  PKGCONFIG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME}`
-  PKGCONFIG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`
+  pkg-config --atleast-version=${LEAST_ACCEPTABLE_OPENSSL_VERSION} ${PKG_CONFIG_NAME}
+  if [ $? -eq 0 ]; then
+    PKGCONFIG_CFLAGS=`pkg-config --cflags ${PKG_CONFIG_NAME}`
+    PKGCONFIG_LIBS=`pkg-config --libs ${PKG_CONFIG_NAME}`
+  fi
 fi

-# Prevent OSX from linking against OpenSSL 0.9.8
-case "$OSTYPE" in "darwin"*)
-  unset PKGCONFIG_CFLAGS
-  unset PKGCONFIG_LIBS
-  ;;
-esac
-
 # Note that cflags may be empty in case of success
 if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
   echo "Found INCLUDE_DIR and/or LIB_DIR!"
jeroen commented 8 years ago

Thanks. This requires that the --atleast-version option is available on all platforms and older pkg-config versions. I want to make sure that we don't get a Unknown option --atleast-version error on older systems.

daitakahashi commented 8 years ago

I downloaded the oldest version of pkg-config available at the freedesktop.org (0.18.1, which released in 2005), and confirmed that the version already has --atleast-version option. So, I think, in practically, all systems with pkg-config support the option.

jeroen commented 8 years ago

OK thanks. I did it like this: https://github.com/jeroenooms/openssl/commit/8c341d5d92a35892ea601dfebd8ae28c2c62c489 can you confirm this works for you?

daitakahashi commented 8 years ago

Yes it works fine, thank you very much! (and sorry, that was not the oldest version...weird sorting order... but I think 2005 is old enough)

jeroen commented 8 years ago

Thanks this is a good suggestion. While you're at it could you let me know which other options are available in pkg-config 0.18.1? Does it have --exists ?

daitakahashi commented 8 years ago

The option --exists exists at least in pkg-config 0.10.0 released in 2002 or 2003.