|
@@ -41,6 +41,131 @@ endif()
|
|
|
# Configure JNI.
|
|
|
include(HadoopJNI)
|
|
|
|
|
|
+#
|
|
|
+# Endian configuration, as per http://austingroupbugs.net/view.php?id=162#c665
|
|
|
+#
|
|
|
+
|
|
|
+# Work out the endianness, set header macro values.
|
|
|
+include(TestBigEndian)
|
|
|
+include(CheckIncludeFile)
|
|
|
+include(CheckSymbolExists)
|
|
|
+test_big_endian(_bigendian)
|
|
|
+if(_bigendian)
|
|
|
+ set(HADOOP_BYTE_ORDER "HADOOP_BIG_ENDIAN")
|
|
|
+else()
|
|
|
+ set(HADOOP_BYTE_ORDER "HADOOP_LITTLE_ENDIAN")
|
|
|
+endif()
|
|
|
+
|
|
|
+# Linux, NetBSD, FreeBSD and OpenBSD all provide htoXXX definitions in endian.h or sys/endian.h.
|
|
|
+check_include_file("endian.h" _endian_h)
|
|
|
+if (_endian_h)
|
|
|
+ set(HADOOP_ENDIAN_H "endian.h")
|
|
|
+else()
|
|
|
+ check_include_file("sys/endian.h" _sys_endian_h)
|
|
|
+ if (_sys_endian_h)
|
|
|
+ set(HADOOP_ENDIAN_H "sys/endian.h")
|
|
|
+ endif()
|
|
|
+endif()
|
|
|
+if(DEFINED HADOOP_ENDIAN_H)
|
|
|
+check_symbol_exists("be64toh" ${HADOOP_ENDIAN_H} _be64toh)
|
|
|
+ if( _be64toh)
|
|
|
+ set(HADOOP_HTOBE16 "htobe16")
|
|
|
+ set(HADOOP_HTOLE16 "htole16")
|
|
|
+ set(HADOOP_BE16TOH "be16toh")
|
|
|
+ set(HADOOP_LE16TOH "le16toh")
|
|
|
+ set(HADOOP_HTOBE32 "htobe32")
|
|
|
+ set(HADOOP_HTOLE32 "htole32")
|
|
|
+ set(HADOOP_BE32TOH "be32toh")
|
|
|
+ set(HADOOP_LE32TOH "le32toh")
|
|
|
+ set(HADOOP_HTOBE64 "htobe64")
|
|
|
+ set(HADOOP_HTOLE64 "htole64")
|
|
|
+ set(HADOOP_BE64TOH "be64toh")
|
|
|
+ set(HADOOP_LE64TOH "le64toh")
|
|
|
+ set(_have_endian TRUE)
|
|
|
+ unset(_be64toh)
|
|
|
+ else()
|
|
|
+ message(FATAL_ERROR "endian.h located but doesn't contain be64toh")
|
|
|
+ endif()
|
|
|
+endif()
|
|
|
+
|
|
|
+# Solaris doesn't provide htoXXX, we have to provide alternatives.
|
|
|
+if(NOT _have_endian)
|
|
|
+ check_include_file("sys/byteorder.h" _sys_byteorder_h)
|
|
|
+ if(_sys_byteorder_h)
|
|
|
+ set(HADOOP_ENDIAN_H "sys/byteorder.h")
|
|
|
+ check_symbol_exists("BSWAP_64" ${HADOOP_ENDIAN_H} _bswap_64)
|
|
|
+ endif()
|
|
|
+ if(_sys_byteorder_h AND _bswap_64)
|
|
|
+ if(_bigendian)
|
|
|
+ set(HADOOP_HTOBE16 "")
|
|
|
+ set(HADOOP_HTOLE16 "BSWAP_16")
|
|
|
+ set(HADOOP_BE16TOH "")
|
|
|
+ set(HADOOP_LE16TOH "BSWAP_16")
|
|
|
+ set(HADOOP_HTOBE32 "")
|
|
|
+ set(HADOOP_HTOLE32 "BSWAP_32")
|
|
|
+ set(HADOOP_BE32TOH "")
|
|
|
+ set(HADOOP_LE32TOH "BSWAP_32")
|
|
|
+ set(HADOOP_HTOBE64 "")
|
|
|
+ set(HADOOP_HTOLE64 "BSWAP_64")
|
|
|
+ set(HADOOP_BE64TOH "")
|
|
|
+ set(HADOOP_LE64TOH "BSWAP_64")
|
|
|
+ else()
|
|
|
+ set(HADOOP_HTOBE16 "BSWAP_16")
|
|
|
+ set(HADOOP_HTOLE16 "")
|
|
|
+ set(HADOOP_BE16TOH "BSWAP_16")
|
|
|
+ set(HADOOP_LE16TOH "")
|
|
|
+ set(HADOOP_HTOBE32 "BSWAP_32")
|
|
|
+ set(HADOOP_HTOLE32 "")
|
|
|
+ set(HADOOP_BE32TOH "BSWAP_32")
|
|
|
+ set(HADOOP_LE32TOH "")
|
|
|
+ set(HADOOP_HTOBE64 "BSWAP_64")
|
|
|
+ set(HADOOP_HTOLE64 "")
|
|
|
+ set(HADOOP_BE64TOH "BSWAP_64")
|
|
|
+ set(HADOOP_LE64TOH "")
|
|
|
+ endif()
|
|
|
+ set(_have_endian TRUE)
|
|
|
+ unset(_sys_byteorder_h)
|
|
|
+ unset(_bswap_64)
|
|
|
+ endif()
|
|
|
+endif()
|
|
|
+
|
|
|
+# OSX uses libkern/OSByteOrder.h and OSSwapXtoY.
|
|
|
+if(NOT _have_endian)
|
|
|
+ check_include_file("libkern/OSByteOrder.h" _libkern_osbyteorder_h)
|
|
|
+ if(_libkern_osbyteorder_h)
|
|
|
+ set(HADOOP_ENDIAN_H "libkern/OSByteOrder.h")
|
|
|
+ check_symbol_exists("OSSwapHostToLittleInt64" ${HADOOP_ENDIAN_H} _osswaphosttolittleint64)
|
|
|
+ endif()
|
|
|
+ if(_libkern_osbyteorder_h AND _osswaphosttolittleint64)
|
|
|
+ set(HADOOP_HTOBE16 "OSSwapHostToBigInt16")
|
|
|
+ set(HADOOP_HTOLE16 "OSSwapHostToLittleInt16")
|
|
|
+ set(HADOOP_BE16TOH "OSSwapBigToHostInt16")
|
|
|
+ set(HADOOP_LE16TOH "OSSwapLittleToHostInt16")
|
|
|
+ set(HADOOP_HTOBE32 "OSSwapHostToBigInt32")
|
|
|
+ set(HADOOP_HTOLE32 "OSSwapHostToLittleInt32")
|
|
|
+ set(HADOOP_BE32TOH "OSSwapBigToHostInt32")
|
|
|
+ set(HADOOP_LE32TOH "OSSwapLittleToHostInt32")
|
|
|
+ set(HADOOP_HTOBE64 "OSSwapHostToBigInt64")
|
|
|
+ set(HADOOP_HTOLE64 "OSSwapHostToLittleInt64")
|
|
|
+ set(HADOOP_BE64TOH "OSSwapBigToHostInt64")
|
|
|
+ set(HADOOP_LE64TOH "OSSwapLittleToHostInt64")
|
|
|
+ set(_have_endian TRUE)
|
|
|
+ unset(_libkern_osbyteorder_h)
|
|
|
+ unset(_osswaphosttolittleint64)
|
|
|
+ endif()
|
|
|
+endif()
|
|
|
+
|
|
|
+# Bail if we don't know the endian definitions for this platform.
|
|
|
+if(NOT _have_endian)
|
|
|
+ message(FATAL_ERROR "Can't provide endianness definitions for this platform")
|
|
|
+endif()
|
|
|
+
|
|
|
+# Configure the hadoop_endian.h header file.
|
|
|
+configure_file(${CMAKE_SOURCE_DIR}/hadoop_endian.h.cmake ${CMAKE_BINARY_DIR}/hadoop_endian.h)
|
|
|
+unset(_bigendian)
|
|
|
+unset(_have_endian)
|
|
|
+unset(HADOOP_ENDIAN_H)
|
|
|
+
|
|
|
# Require zlib.
|
|
|
set(STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
|
|
hadoop_set_find_shared_library_version("1")
|