From: Michihiro NAKAJIMA Date: Sun, 14 Sep 2014 13:27:45 +0000 (+0900) Subject: Fix build failure on FreeBSD 9.2. X-Git-Tag: v3.1.900a~221 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce08c48484fd9f6bc2023c2f3647ee3a82a159c1;p=thirdparty%2Flibarchive.git Fix build failure on FreeBSD 9.2. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 24ff970fc..e49c1aeb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -601,6 +601,7 @@ IF(ENABLE_NETTLE) SET(HAVE_NETTLE_SHA_H 1) INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR}) LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARIES}) + LA_CHECK_INCLUDE_FILE("nettle/pbkdf2.h" HAVE_NETTLE_PBKDF2_H) ENDIF(NETTLE_FOUND) MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR) MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index b66bb5433..baca049dd 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -727,6 +727,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETTLE_MD5_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETTLE_PBKDF2_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETTLE_RIPEMD160_H 1 @@ -748,6 +751,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `pipe' function. */ #cmakedefine HAVE_PIPE 1 +/* Define to 1 if you have the `PKCS5_PBKDF2_HMAC_SHA1' function. */ +#cmakedefine HAVE_PKCS5_PBKDF2_HMAC_SHA1 1 + /* Define to 1 if you have the `poll' function. */ #cmakedefine HAVE_POLL 1 diff --git a/configure.ac b/configure.ac index 46311b5d3..6682efb00 100644 --- a/configure.ac +++ b/configure.ac @@ -784,6 +784,8 @@ if test "x$with_nettle" != "xno"; then CRYPTO_CHECK(SHA512, NETTLE, sha512) if test "x$found_NETTLE" != "xyes"; then LIBS=$saved_LIBS + else + AC_CHECK_HEADERS([nettle/pbkdf2.h]) fi fi if test "x$with_openssl" != "xno"; then @@ -815,6 +817,8 @@ if test "x$with_openssl" != "xno"; then CRYPTO_CHECK(SHA512, OPENSSL, sha512) if test "x$found_OPENSSL" != "xyes"; then LIBS=$saved_LIBS + else + AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1]) fi fi diff --git a/libarchive/archive_cryptor.c b/libarchive/archive_cryptor.c index 03b598fa8..0a332bafe 100644 --- a/libarchive/archive_cryptor.c +++ b/libarchive/archive_cryptor.c @@ -44,7 +44,7 @@ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt, return 0; } -#elif defined(HAVE_LIBNETTLE) +#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_PBKDF2_H) static int pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt, @@ -55,7 +55,7 @@ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt, return 0; } -#elif defined(HAVE_LIBCRYPTO) +#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_PKCS5_PBKDF2_HMAC_SHA1) static int pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt, diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h index 5bd550782..7e2033b19 100644 --- a/libarchive/archive_cryptor_private.h +++ b/libarchive/archive_cryptor_private.h @@ -46,7 +46,9 @@ typedef struct { } archive_crypto_ctx; #elif defined(HAVE_LIBNETTLE) +#if defined(HAVE_NETTLE_PBKDF2_H) #include +#endif #include typedef struct { diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index 4daba9474..223ef02f6 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -1712,10 +1712,11 @@ lha_crc16(uint16_t crc, const void *pp, size_t len) * remove the stament which will not be executed. */ #ifdef _MSC_VER /* Visual Studio */ # define bswap16(x) _byteswap_ushort(x) -#elif defined(__GNUC__) || defined(__clang__) +#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8) \ + || defined(__clang__) # define bswap16(x) __builtin_bswap16(x) #else -# define bswap16(x) ((((b) >> 8) & 0xff) | ((b) << 8)) +# define bswap16(x) ((((x) >> 8) & 0xff) | ((x) << 8)) #endif #define CRC16W do { \ if(u.c[0] == 1) { /* Big endian */ \