Merge pull request #1443 from sharvilshah/libressl

[#1329] Statically link against brew bottled libressl on OS X
This commit is contained in:
Teddy Reed 2015-08-18 01:09:45 -07:00
commit 73da2f1448
3 changed files with 30 additions and 8 deletions

View File

@ -64,7 +64,7 @@ endif()
if(PLATFORM STREQUAL "") if(PLATFORM STREQUAL "")
WARNING_LOG("Unable to detect osquery platform: ./tools/provision.sh failed") WARNING_LOG("Unable to detect osquery platform: ./tools/provision.sh failed")
message(FATAL "Cannot proceed without knowing the build platform") message(FATAL_ERROR "Cannot proceed without knowing the build platform")
endif() endif()
list(GET PLATFORM 0 OSQUERY_BUILD_PLATFORM) list(GET PLATFORM 0 OSQUERY_BUILD_PLATFORM)
list(GET PLATFORM 1 OSQUERY_BUILD_DISTRO) list(GET PLATFORM 1 OSQUERY_BUILD_DISTRO)
@ -267,16 +267,27 @@ endif()
# Make sure the generated paths exist # Make sure the generated paths exist
execute_process(COMMAND mkdir -p "${CMAKE_BINARY_DIR}/generated") execute_process(COMMAND mkdir -p "${CMAKE_BINARY_DIR}/generated")
# We need to link some packages as dynamic/dependent. # Apple has deprecated OpenSSL, static link with brew bottled libressl
set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so) if(APPLE)
find_package(OpenSSL REQUIRED) if(NOT DEFINED ENV{BUILD_LINK_SHARED})
find_package(BZip2 REQUIRED) set(CMAKE_FIND_LIBRARY_SUFFIXES .a .dylib .so)
find_package(Dl REQUIRED) else()
find_package(Readline REQUIRED) set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so)
endif()
execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
set(OPENSSL_ROOT_DIR "${BREW_PREFIX}/opt/libressl")
find_package(OpenSSL REQUIRED)
include_directories("${OPENSSL_INCLUDE_DIR}")
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so)
find_package(OpenSSL REQUIRED)
endif()
# Make sure the OpenSSL/ssl library has a TLS client method. # Make sure the OpenSSL/ssl library has a TLS client method.
# Prefer the highest version of TLS, but accept 1.2, 1.1, or 1.0. # Prefer the highest version of TLS, but accept 1.2, 1.1, or 1.0.
include(CheckLibraryExists) include(CheckLibraryExists)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY} "TLSv1_2_client_method" "" OPENSSL_TLSV12) CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY} "TLSv1_2_client_method" "" OPENSSL_TLSV12)
CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY} "TLSv1_1_client_method" "" OPENSSL_TLSV11) CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY} "TLSv1_1_client_method" "" OPENSSL_TLSV11)
CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY} "TLSv1_client_method" "" OPENSSL_TLSV10) CHECK_LIBRARY_EXISTS(${OPENSSL_SSL_LIBRARY} "TLSv1_client_method" "" OPENSSL_TLSV10)
@ -289,9 +300,17 @@ elseif(OPENSSL_TLSV11)
elseif(OPENSSL_TLSV10) elseif(OPENSSL_TLSV10)
add_definitions(-DSSL_TXT_TLSV1) add_definitions(-DSSL_TXT_TLSV1)
else() else()
message(FATAL "Cannot find any TLS client methods") message(FATAL_ERROR "Cannot find any TLS client methods")
endif() endif()
# We need to link some packages as dynamic/dependent.
set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so)
find_package(BZip2 REQUIRED)
find_package(Dl REQUIRED)
find_package(Readline REQUIRED)
# Most dependent packages/libs we want static. # Most dependent packages/libs we want static.
if(NOT DEFINED ENV{BUILD_LINK_SHARED}) if(NOT DEFINED ENV{BUILD_LINK_SHARED})
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .dylib .so) set(CMAKE_FIND_LIBRARY_SUFFIXES .a .dylib .so)

View File

@ -18,6 +18,7 @@ function main_darwin() {
brew update brew update
package libressl
package wget package wget
package cmake package cmake
package makedepend package makedepend

View File

@ -399,6 +399,8 @@ function package() {
HOMEBREW_ARGS="--build-bottle --with-lite" HOMEBREW_ARGS="--build-bottle --with-lite"
elif [[ $1 = "gflags" ]]; then elif [[ $1 = "gflags" ]]; then
HOMEBREW_ARGS="--build-bottle --with-static" HOMEBREW_ARGS="--build-bottle --with-static"
elif [[ $1 = "libressl" ]]; then
HOMEBREW_ARGS="--build-bottle"
fi fi
brew install -v $HOMEBREW_ARGS $1 || brew upgrade -v $HOMEBREW_ARGS $@ brew install -v $HOMEBREW_ARGS $1 || brew upgrade -v $HOMEBREW_ARGS $@
fi fi