Skip to content

Commit

Permalink
Fix: detect openssl installed from homebrew on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Jan 3, 2019
1 parent 3b3fd41 commit fe07222
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/ci
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ format() {
prepare_build() {
on_linux verify_linux_environment

on_osx brew install crystal
on_osx brew install crystal openssl

# Make sure binaries from llvm are available in PATH
on_osx brew install jq
Expand Down
16 changes: 16 additions & 0 deletions src/openssl/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ else
OPENSSL_CFLAGS="-I$OPENSSL_DIR/include"
fi

if [ -z $OPENSSL_CFLAGS ] && [ "`uname -s`" = "Darwin" ]; then
OPENSSL_DIR=/usr/local/opt/openssl

# check default homebrew install directory (fast):
if [ -d "$OPENSSL_DIR/include" ]; then
OPENSSL_CFLAGS="-I$OPENSSL_DIR/include"
else
# ask homebrew (slower):
OPENSSL_DIR=$(command -v brew > /dev/null && brew --prefix openssl)

if [ -n "$OPENSSL_DIR" ] && [ -d "$OPENSSL_DIR/include" ]; then
OPENSSL_CFLAGS="-I$OPENSSL_DIR/include"
fi
fi
fi

# extract version numbers from OpenSSL/LibreSSL C headers:
LIBRESSL_VERSION_NUMBER=$(printf "#include <openssl/opensslv.h>\nLIBRESSL_VERSION_NUMBER" | ${CC:-cc} $OPENSSL_CFLAGS -E - 2> /dev/null | tail -n 1)
OPENSSL_VERSION_NUMBER=$(printf "#include <openssl/opensslv.h>\nOPENSSL_VERSION_NUMBER" | ${CC:-cc} $OPENSSL_CFLAGS -E - 2> /dev/null | tail -n 1)
Expand Down

0 comments on commit fe07222

Please sign in to comment.