HADOOP-11216. Improve Openssl library finding. (cmccabe via yliu)
This commit is contained in:
parent
c7d1db7495
commit
51f621c01c
|
@ -271,6 +271,8 @@ Release 2.6.0 - UNRELEASED
|
||||||
proxy-users on Delegation-token management operations. (Zhijie Shen via
|
proxy-users on Delegation-token management operations. (Zhijie Shen via
|
||||||
vinodkv)
|
vinodkv)
|
||||||
|
|
||||||
|
HADOOP-11216. Improve Openssl library finding. (cmccabe via yliu)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-10838. Byte array native checksumming. (James Thomas via todd)
|
HADOOP-10838. Byte array native checksumming. (James Thomas via todd)
|
||||||
|
|
|
@ -545,6 +545,7 @@
|
||||||
<openssl.include></openssl.include>
|
<openssl.include></openssl.include>
|
||||||
<require.openssl>false</require.openssl>
|
<require.openssl>false</require.openssl>
|
||||||
<runningWithNative>true</runningWithNative>
|
<runningWithNative>true</runningWithNative>
|
||||||
|
<bundle.openssl.in.bin>false</bundle.openssl.in.bin>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -665,7 +666,7 @@
|
||||||
<openssl.include></openssl.include>
|
<openssl.include></openssl.include>
|
||||||
<require.openssl>false</require.openssl>
|
<require.openssl>false</require.openssl>
|
||||||
<runningWithNative>true</runningWithNative>
|
<runningWithNative>true</runningWithNative>
|
||||||
<bundle.openssl.in.bin>true</bundle.openssl.in.bin>
|
<bundle.openssl.in.bin>false</bundle.openssl.in.bin>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -78,16 +78,34 @@ macro(set_find_shared_library_version LVERS)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
endmacro(set_find_shared_library_version LVERS)
|
endmacro(set_find_shared_library_version LVERS)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Alter the behavior of find_package and find_library so that we find only
|
||||||
|
# shared libraries without any version suffix. You should save
|
||||||
|
# CMAKE_FIND_LIBRARY_SUFFIXES before calling this function and restore it
|
||||||
|
# afterwards.
|
||||||
|
#
|
||||||
|
macro(set_find_shared_library_without_version)
|
||||||
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
# Mac OS uses .dylib
|
||||||
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib")
|
||||||
|
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
|
# No effect
|
||||||
|
ELSE()
|
||||||
|
# Most UNIX variants use .so
|
||||||
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
|
||||||
|
ENDIF()
|
||||||
|
endmacro(set_find_shared_library_version LVERS)
|
||||||
|
|
||||||
if (NOT GENERATED_JAVAH)
|
if (NOT GENERATED_JAVAH)
|
||||||
# Must identify where the generated headers have been placed
|
# Must identify where the generated headers have been placed
|
||||||
MESSAGE(FATAL_ERROR "You must set the cmake variable GENERATED_JAVAH")
|
MESSAGE(FATAL_ERROR "You must set the cmake variable GENERATED_JAVAH")
|
||||||
endif (NOT GENERATED_JAVAH)
|
endif (NOT GENERATED_JAVAH)
|
||||||
find_package(JNI REQUIRED)
|
find_package(JNI REQUIRED)
|
||||||
|
|
||||||
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES)
|
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
set_find_shared_library_version("1")
|
set_find_shared_library_version("1")
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES)
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${STORED_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_GNU_SOURCE")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_GNU_SOURCE")
|
||||||
|
@ -97,7 +115,7 @@ set(T main/native/src/test/org/apache/hadoop)
|
||||||
|
|
||||||
GET_FILENAME_COMPONENT(HADOOP_ZLIB_LIBRARY ${ZLIB_LIBRARIES} NAME)
|
GET_FILENAME_COMPONENT(HADOOP_ZLIB_LIBRARY ${ZLIB_LIBRARIES} NAME)
|
||||||
|
|
||||||
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES)
|
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
set_find_shared_library_version("1")
|
set_find_shared_library_version("1")
|
||||||
find_package(BZip2 QUIET)
|
find_package(BZip2 QUIET)
|
||||||
if (BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES)
|
if (BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES)
|
||||||
|
@ -112,7 +130,7 @@ else (BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES)
|
||||||
MESSAGE(FATAL_ERROR "Required bzip2 library and/or header files could not be found.")
|
MESSAGE(FATAL_ERROR "Required bzip2 library and/or header files could not be found.")
|
||||||
ENDIF(REQUIRE_BZIP2)
|
ENDIF(REQUIRE_BZIP2)
|
||||||
endif (BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES)
|
endif (BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES)
|
||||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES)
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${STORED_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
|
||||||
INCLUDE(CheckFunctionExists)
|
INCLUDE(CheckFunctionExists)
|
||||||
INCLUDE(CheckCSourceCompiles)
|
INCLUDE(CheckCSourceCompiles)
|
||||||
|
@ -121,13 +139,13 @@ CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE)
|
||||||
CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE)
|
CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE)
|
||||||
CHECK_LIBRARY_EXISTS(dl dlopen "" NEED_LINK_DL)
|
CHECK_LIBRARY_EXISTS(dl dlopen "" NEED_LINK_DL)
|
||||||
|
|
||||||
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES)
|
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
set_find_shared_library_version("1")
|
set_find_shared_library_version("1")
|
||||||
find_library(SNAPPY_LIBRARY
|
find_library(SNAPPY_LIBRARY
|
||||||
NAMES snappy
|
NAMES snappy
|
||||||
PATHS ${CUSTOM_SNAPPY_PREFIX} ${CUSTOM_SNAPPY_PREFIX}/lib
|
PATHS ${CUSTOM_SNAPPY_PREFIX} ${CUSTOM_SNAPPY_PREFIX}/lib
|
||||||
${CUSTOM_SNAPPY_PREFIX}/lib64 ${CUSTOM_SNAPPY_LIB})
|
${CUSTOM_SNAPPY_PREFIX}/lib64 ${CUSTOM_SNAPPY_LIB})
|
||||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES)
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${STORED_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
find_path(SNAPPY_INCLUDE_DIR
|
find_path(SNAPPY_INCLUDE_DIR
|
||||||
NAMES snappy.h
|
NAMES snappy.h
|
||||||
PATHS ${CUSTOM_SNAPPY_PREFIX} ${CUSTOM_SNAPPY_PREFIX}/include
|
PATHS ${CUSTOM_SNAPPY_PREFIX} ${CUSTOM_SNAPPY_PREFIX}/include
|
||||||
|
@ -145,37 +163,53 @@ else (SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR)
|
||||||
ENDIF(REQUIRE_SNAPPY)
|
ENDIF(REQUIRE_SNAPPY)
|
||||||
endif (SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR)
|
endif (SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR)
|
||||||
|
|
||||||
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES)
|
# Find the no-suffix version of libcrypto.
|
||||||
set_find_shared_library_version("1.0.0")
|
# See HADOOP-11216 for details.
|
||||||
|
SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
set_find_shared_library_without_version()
|
||||||
SET(OPENSSL_NAME "crypto")
|
SET(OPENSSL_NAME "crypto")
|
||||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
SET(OPENSSL_NAME "eay32")
|
SET(OPENSSL_NAME "eay32")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
MESSAGE("CUSTOM_OPENSSL_PREFIX = ${CUSTOM_OPENSSL_PREFIX}")
|
||||||
find_library(OPENSSL_LIBRARY
|
find_library(OPENSSL_LIBRARY
|
||||||
NAMES ${OPENSSL_NAME}
|
NAMES ${OPENSSL_NAME}
|
||||||
PATHS ${CUSTOM_OPENSSL_PREFIX} ${CUSTOM_OPENSSL_PREFIX}/lib
|
PATHS ${CUSTOM_OPENSSL_PREFIX} ${CUSTOM_OPENSSL_PREFIX}/lib
|
||||||
${CUSTOM_OPENSSL_PREFIX}/lib64 ${CUSTOM_OPENSSL_LIB} NO_DEFAULT_PATH)
|
${CUSTOM_OPENSSL_PREFIX}/lib64 ${CUSTOM_OPENSSL_LIB} NO_DEFAULT_PATH)
|
||||||
find_library(OPENSSL_LIBRARY
|
find_library(OPENSSL_LIBRARY NAMES ${OPENSSL_NAME})
|
||||||
NAMES ${OPENSSL_NAME})
|
|
||||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES)
|
|
||||||
find_path(OPENSSL_INCLUDE_DIR
|
find_path(OPENSSL_INCLUDE_DIR
|
||||||
NAMES openssl/evp.h
|
NAMES openssl/evp.h
|
||||||
PATHS ${CUSTOM_OPENSSL_PREFIX} ${CUSTOM_OPENSSL_PREFIX}/include
|
PATHS ${CUSTOM_OPENSSL_PREFIX} ${CUSTOM_OPENSSL_PREFIX}/include
|
||||||
${CUSTOM_OPENSSL_INCLUDE} NO_DEFAULT_PATH)
|
${CUSTOM_OPENSSL_INCLUDE} NO_DEFAULT_PATH)
|
||||||
find_path(OPENSSL_INCLUDE_DIR
|
find_path(OPENSSL_INCLUDE_DIR NAMES openssl/evp.h)
|
||||||
NAMES openssl/evp.h)
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${STORED_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
SET(USABLE_OPENSSL 0)
|
||||||
if (OPENSSL_LIBRARY AND OPENSSL_INCLUDE_DIR)
|
if (OPENSSL_LIBRARY AND OPENSSL_INCLUDE_DIR)
|
||||||
GET_FILENAME_COMPONENT(HADOOP_OPENSSL_LIBRARY ${OPENSSL_LIBRARY} NAME)
|
GET_FILENAME_COMPONENT(HADOOP_OPENSSL_LIBRARY ${OPENSSL_LIBRARY} NAME)
|
||||||
|
INCLUDE(CheckCSourceCompiles)
|
||||||
|
SET(OLD_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
|
||||||
|
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
|
CHECK_C_SOURCE_COMPILES("#include \"${OPENSSL_INCLUDE_DIR}/openssl/evp.h\"\nint main(int argc, char **argv) { return !EVP_aes_256_ctr; }" HAS_NEW_ENOUGH_OPENSSL)
|
||||||
|
SET(CMAKE_REQUIRED_INCLUDES ${OLD_CMAKE_REQUIRED_INCLUDES})
|
||||||
|
if(NOT HAS_NEW_ENOUGH_OPENSSL)
|
||||||
|
MESSAGE("The OpenSSL library installed at ${OPENSSL_LIBRARY} is too old. You need a version at least new enough to have EVP_aes_256_ctr.")
|
||||||
|
else(NOT HAS_NEW_ENOUGH_OPENSSL)
|
||||||
|
SET(USABLE_OPENSSL 1)
|
||||||
|
endif(NOT HAS_NEW_ENOUGH_OPENSSL)
|
||||||
|
endif (OPENSSL_LIBRARY AND OPENSSL_INCLUDE_DIR)
|
||||||
|
if (USABLE_OPENSSL)
|
||||||
SET(OPENSSL_SOURCE_FILES
|
SET(OPENSSL_SOURCE_FILES
|
||||||
"${D}/crypto/OpensslCipher.c"
|
"${D}/crypto/OpensslCipher.c"
|
||||||
"${D}/crypto/random/OpensslSecureRandom.c")
|
"${D}/crypto/random/OpensslSecureRandom.c")
|
||||||
else (OPENSSL_LIBRARY AND OPENSSL_INCLUDE_DIR)
|
else (USABLE_OPENSSL)
|
||||||
|
MESSAGE("Cannot find a usable OpenSSL library. OPENSSL_LIBRARY=${OPENSSL_LIBRARY}, OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}, CUSTOM_OPENSSL_INCLUDE_DIR=${CUSTOM_OPENSSL_INCLUDE_DIR}, CUSTOM_OPENSSL_PREFIX=${CUSTOM_OPENSSL_PREFIX}, CUSTOM_OPENSSL_INCLUDE=${CUSTOM_OPENSSL_INCLUDE}")
|
||||||
|
IF(REQUIRE_OPENSSL)
|
||||||
|
MESSAGE(FATAL_ERROR "Terminating build because require.openssl was specified.")
|
||||||
|
ENDIF(REQUIRE_OPENSSL)
|
||||||
|
SET(OPENSSL_LIBRARY "")
|
||||||
SET(OPENSSL_INCLUDE_DIR "")
|
SET(OPENSSL_INCLUDE_DIR "")
|
||||||
SET(OPENSSL_SOURCE_FILES "")
|
SET(OPENSSL_SOURCE_FILES "")
|
||||||
IF(REQUIRE_OPENSSL)
|
endif (USABLE_OPENSSL)
|
||||||
MESSAGE(FATAL_ERROR "Required openssl library could not be found. OPENSSL_LIBRARY=${OPENSSL_LIBRARY}, OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}, CUSTOM_OPENSSL_INCLUDE_DIR=${CUSTOM_OPENSSL_INCLUDE_DIR}, CUSTOM_OPENSSL_PREFIX=${CUSTOM_OPENSSL_PREFIX}, CUSTOM_OPENSSL_INCLUDE=${CUSTOM_OPENSSL_INCLUDE}")
|
|
||||||
ENDIF(REQUIRE_OPENSSL)
|
|
||||||
endif (OPENSSL_LIBRARY AND OPENSSL_INCLUDE_DIR)
|
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${GENERATED_JAVAH}
|
${GENERATED_JAVAH}
|
||||||
|
|
Loading…
Reference in New Issue