Add thirdparty libs

This commit is contained in:
JusicP
2020-10-22 20:43:01 +03:00
parent 76cfb7b813
commit 940d664def
4391 changed files with 1144864 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Use this script to switch back to the previous Crypto++ version before
# building the docs. Before running the script, copy it to the root
# directory. After running this script, you can 'make docs'
sed 's|Library 8.3 API|Library 8.2 API|g' cryptlib.h > cryptlib.h.new
mv cryptlib.h.new cryptlib.h
sed 's|= 8.3|= 8.2|g' Doxyfile > Doxyfile.new
mv Doxyfile.new Doxyfile
sed 's|CRYPTOPP_MINOR 3|CRYPTOPP_MINOR 2|g' config_ver.h > config_ver.h.new
mv config_ver.h.new config_ver.h
sed 's|CRYPTOPP_VERSION 830|CRYPTOPP_VERSION 820|g' config_ver.h > config_ver.h.new
mv config_ver.h.new config_ver.h
+905
View File
@@ -0,0 +1,905 @@
#!/usr/bin/env bash
# Written and placed in public domain by Jeffrey Walton
#
# This script attempts to update various config_xxx.h files based on the
# current toolchain. It fills a gap where some features are misdetected based
# on compiler version and associated macros, but the feature is (or is not)
# present. For example, modern Android toolchains should be AES-NI and AVX
# capable, but the project removes the feature support.
#
# Use the same compiler and environment to run configure and the makefile.
#
# To use the script, copy the script to the root of the Crypto++ directory.
# Set the environment, and then run the tool:
#
# export CXX="..."
# export CXXFLAGS="..."
# export LDFLAGS="..."
# ./configure.sh
#
# Android and iOS would use the following if you are using setenv-android.sh
# or setenv-ios.sh to set the environment. Otherwise the script expects
# CXX and CXXFLAGS to be set properly for Android or iOS.
#
# export CXXFLAGS="$IOS_CXXFLAGS --sysroot=$IOS_SYSROOT"
# or
# export CXXFLAGS="$ANDROID_CXXFLAGS --sysroot=$ANDROID_SYSROOT"
#
# Do not use this script for a multiarch environment unless the cpu features
# are the same for each arch. For example, -arch i386 -arch x86_64 could
# cause problems if x86 only included SSE4.2, while x64 included AVX.
#
# A wiki page is available for this script at
# https://www.cryptopp.com/wiki/Configure.sh
#
# This script was added at Crypto++ 8.3. Also see GH #850. This script will
# work with earlier versions of the library that use config_xxx.h files.
# The monolithic config.h was split into config_xxx.h in May 2019 at
# Crypto++ 8.3. Also see GH #835, PR #836.
# shellcheck disable=SC2086
# Verify the file exists and is writeable.
if [[ ! -w ./config_asm.h ]]; then
echo "Crypto++ is too old. Unable to locate config_asm.h"
exit 1
fi
TMPDIR="${TMPDIR:-$HOME/tmp}"
TPROG="${TPROG:-TestPrograms/test_cxx.cxx}"
TOUT="${TOUT:-a.out}"
CXX="${CXX:-c++}"
LD="${LD:-ld}"
CXXFLAGS="${CXXFLAGS:--DNDEBUG -g2 -O3}"
GREP="${GREP:-grep}"
if [[ -z "$(command -v ${CXX} 2>/dev/null)" ]]; then
echo "Compiler is not valid. Please install a compiler"
exit 1
fi
if [[ -z "$(command -v ${LD} 2>/dev/null)" ]]; then
echo "Linker is not valid. Please install a linker"
exit 1
fi
# Solaris fixup
if [[ -d /usr/gnu/bin ]]; then
GREP=/usr/gnu/bin/grep
fi
SUN_COMPILER=$(${CXX} -V 2>/dev/null | ${GREP} -i -c -E 'CC: (Sun|Studio)')
XLC_COMPILER=$(${CXX} -qversion 2>/dev/null | ${GREP} -i -c "IBM XL")
CLANG_COMPILER=$(${CXX} --version 2>/dev/null | ${GREP} -i -c -E 'clang|llvm')
if [[ "$SUN_COMPILER" -ne 0 ]]
then
IS_X86=$(uname -m 2>&1 | ${GREP} -c -E 'i386|i486|i585|i686')
IS_X64=$(uname -m 2>&1 | ${GREP} -c -E 'i86pc|x86_64|amd64')
IS_IA32=$(uname -m 2>&1 | ${GREP} -c -E 'i86pc|i386|i486|i585|i686|x86_64|amd64')
IS_ARM32=0
IS_ARMV8=0
IS_PPC=0
IS_PPC64=0
elif [[ "$XLC_COMPILER" -ne 0 ]]
then
IS_X86=0
IS_X64=0
IS_IA32=0
IS_ARM32=0
IS_ARMV8=0
IS_PPC=$(uname -m 2>&1 | ${GREP} -c -E 'ppc|powerpc')
IS_PPC64=$(uname -m 2>&1 | ${GREP} -c -E 'ppc64|powerpc64')
elif [[ "$CLANG_COMPILER" -ne 0 ]]
then
IS_X86=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'i386|i486|i585|i686')
IS_X64=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'i86pc|x86_64|amd64')
IS_IA32=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'i86pc|i386|i486|i585|i686|x86_64|amd64')
IS_ARM32=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'arm|armhf|armv7|eabihf|armv8')
IS_ARMV8=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'aarch32|aarch64|arm64')
IS_PPC=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'ppc|powerpc')
IS_PPC64=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -c -E 'ppc64|powerpc64')
else
IS_X86=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'i386|i486|i585|i686')
IS_X64=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'i86pc|x86_64|amd64')
IS_IA32=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'i86pc|i386|i486|i585|i686|x86_64|amd64')
IS_ARM32=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'arm|armhf|armv7|eabihf|armv8')
IS_ARMV8=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'aarch32|aarch64|arm64')
IS_PPC=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'ppc|powerpc')
IS_PPC64=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'ppc64|powerpc64')
fi
# Default values for setenv-*.sh scripts
IS_IOS="${IS_IOS:-0}"
IS_ANDROID="${IS_ANDROID:-0}"
TIMESTAMP=$(date "+%A, %B %d %Y, %I:%M %p")
# ===========================================================================
# ================================== Fixups =================================
# ===========================================================================
# A 64-bit platform often matches the 32-bit variant due to appending '64'
if [[ "${IS_X64}" -ne 0 ]]; then IS_X86=0; fi
if [[ "${IS_ARMV8}" -ne 0 ]]; then IS_ARM32=0; fi
if [[ "${IS_PPC64}" -ne 0 ]]; then IS_PPC=0; fi
# ===========================================================================
# =================================== Info ==================================
# ===========================================================================
if [[ "${IS_X86}" -ne 0 ]]; then echo "Configuring for x86"; fi
if [[ "${IS_X64}" -ne 0 ]]; then echo "Configuring for x86_64"; fi
if [[ "${IS_ARM32}" -ne 0 ]]; then echo "Configuring for ARM32"; fi
if [[ "${IS_ARMV8}" -ne 0 ]]; then echo "Configuring for Aarch64"; fi
if [[ "${IS_PPC}" -ne 0 ]]; then echo "Configuring for PowerPC"; fi
if [[ "${IS_PPC64}" -ne 0 ]]; then echo "Configuring for PowerPC64"; fi
echo "Compiler: $(command -v ${CXX})"
echo "Linker: $(command -v ${LD})"
# ===========================================================================
# =============================== config_asm.h ==============================
# ===========================================================================
rm -f config_asm.h.new
# Common header
{
echo '// config_asm.h rewritten by configure.sh script'
echo '//' "${TIMESTAMP}"
echo '// Also see https://www.cryptopp.com/wiki/configure.sh'
echo ''
echo '#ifndef CRYPTOPP_CONFIG_ASM_H'
echo '#define CRYPTOPP_CONFIG_ASM_H'
echo ''
} >> config_asm.h.new
#############################################################################
# Pickup CRYPTOPP_DISABLE_ASM
disable_asm=$($GREP -c '\-DCRYPTOPP_DISABLE_ASM' <<< "${CPPFLAGS} ${CXXFLAGS}")
if [[ "$disable_asm" -ne 0 ]]; then
# Shell redirection
{
echo ''
echo '// Set in CPPFLAGS or CXXFLAGS'
echo '#define CRYPTOPP_DISABLE_ASM 1'
} >> config_asm.h.new
fi
#############################################################################
# Intel x86-based machines
if [[ "$disable_asm" -eq 0 && "$IS_IA32" -ne 0 ]]; then
if [[ "${SUN_COMPILER}" -ne 0 ]]; then
SSE2_FLAG=-xarch=sse2
SSE3_FLAG=-xarch=sse3
SSSE3_FLAG=-xarch=ssse3
SSE41_FLAG=-xarch=sse4_1
SSE42_FLAG=-xarch=sse4_2
CLMUL_FLAG=-xarch=aes
AESNI_FLAG=-xarch=aes
RDRAND_FLAG=-xarch=avx_i
RDSEED_FLAG=-xarch=avx2_i
AVX_FLAG=-xarch=avx
AVX2_FLAG=-xarch=avx2
SHANI_FLAG=-xarch=sha
else
SSE2_FLAG=-msse2
SSE3_FLAG=-msse3
SSSE3_FLAG=-mssse3
SSE41_FLAG=-msse4.1
SSE42_FLAG=-msse4.2
CLMUL_FLAG=-mpclmul
AESNI_FLAG=-maes
RDRAND_FLAG=-mrdrnd
RDSEED_FLAG=-mrdseed
AVX_FLAG=-mavx
AVX2_FLAG=-mavx2
SHANI_FLAG=-msha
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE2_FLAG} TestPrograms/test_x86_sse2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -ne 0 ]]; then
echo '#define CRYPTOPP_DISABLE_ASM 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE2_FLAG} TestPrograms/test_asm_sse2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_X86_ASM_AVAILABLE 1'
if [[ "${IS_X64}" -ne 0 ]]; then
echo '#define CRYPTOPP_X64_ASM_AVAILABLE 1'
echo '#define CRYPTOPP_SSE2_ASM_AVAILABLE 1'
fi
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE2_FLAG} TestPrograms/test_x86_sse2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
have_sse2=1
echo '#define CRYPTOPP_SSE2_INTRIN_AVAILABLE 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE3_FLAG} TestPrograms/test_x86_sse3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
have_sse3=1
echo '#define CRYPTOPP_SSE3_AVAILABLE 1'
else
have_sse3=0
echo '#define CRYPTOPP_DISABLE_SSE3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSSE3_FLAG} TestPrograms/test_x86_ssse3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse3" -ne 0 ]]; then
have_ssse3=1
echo '#define CRYPTOPP_SSSE3_ASM_AVAILABLE 1'
echo '#define CRYPTOPP_SSSE3_AVAILABLE 1'
else
have_ssse3=0
echo '#define CRYPTOPP_DISABLE_SSSE3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE41_FLAG} TestPrograms/test_x86_sse41.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_ssse3" -ne 0 ]]; then
have_sse41=1
echo '#define CRYPTOPP_SSE41_AVAILABLE 1'
else
have_sse41=0
echo '#define CRYPTOPP_DISABLE_SSE4 1'
echo '#define CRYPTOPP_DISABLE_SSE41 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE42_FLAG} TestPrograms/test_x86_sse42.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse41" -ne 0 ]]; then
have_sse42=1
echo '#define CRYPTOPP_SSE42_AVAILABLE 1'
else
have_sse42=0
echo '#define CRYPTOPP_DISABLE_SSE4 1'
echo '#define CRYPTOPP_DISABLE_SSE42 1'
fi
########################################################
# AES, CLMUL, RDRAND, RDSEED, SHA and AVX tied to SSE4.2
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${CLMUL_FLAG} TestPrograms/test_x86_clmul.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_CLMUL_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_CLMUL 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${AESNI_FLAG} TestPrograms/test_x86_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_AESNI_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_AESNI 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${RDRAND_FLAG} TestPrograms/test_x86_rdrand.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_RDRAND_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_RDRAND 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${RDSEED_FLAG} TestPrograms/test_x86_rdseed.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_RDSEED_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_RDSEED 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SHANI_FLAG} TestPrograms/test_x86_sha.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_SHANI_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_SHANI 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${AVX_FLAG} TestPrograms/test_x86_avx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
have_avx=1
echo '#define CRYPTOPP_AVX_AVAILABLE 1'
else
have_avx=0
echo '#define CRYPTOPP_DISABLE_AVX 1'
fi
#####################
# AVX2 depends on AVX
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${AVX2_FLAG} TestPrograms/test_x86_avx2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_avx" -ne 0 ]]; then
have_avx2=1
echo '#define CRYPTOPP_AVX2_AVAILABLE 1'
else
have_avx2=0
echo '#define CRYPTOPP_DISABLE_AVX2 1'
fi
# No flags, requires inline ASM
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_x86_via_rng.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_PADLOCK_RNG_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_PADLOCK_RNG 1'
fi
# No flags, requires inline ASM
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_x86_via_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_PADLOCK_AES_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_PADLOCK_AES 1'
fi
# No flags, requires inline ASM
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_x86_via_sha.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_PADLOCK_SHA_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_PADLOCK_SHA 1'
fi
# Clang workaround
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_asm_mixed.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -ne 0 ]]; then
echo '#define CRYPTOPP_DISABLE_MIXED_ASM 1'
fi
if [[ "${SUN_COMPILER}" -ne 0 ]]; then
echo ''
echo '// Fixup for SunCC 12.1-12.4. Bad code generation in AES_Encrypt and friends.'
echo '#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5130)'
echo '# undef CRYPTOPP_AESNI_AVAILABLE'
echo '#endif'
echo ''
echo '// Fixup for SunCC 12.1-12.6. Compiler crash on GCM_Reduce_CLMUL.'
echo '// http://github.com/weidai11/cryptopp/issues/226'
echo '#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5150)'
echo '# undef CRYPTOPP_CLMUL_AVAILABLE'
echo '#endif'
fi
} >> config_asm.h.new
fi
#############################################################################
# ARM 32-bit machines
if [[ "$disable_asm" -eq 0 && "$IS_ARM32" -ne 0 ]]; then
# IS_IOS is set when ./setenv-ios is run
if [[ "$IS_IOS" -ne 0 ]]; then
ARMV7_FLAG="-arch arm"
NEON_FLAG="-arch arm"
elif [[ "$CLANG_COMPILER" -ne 0 ]]; then
ARMV7_FLAG="-march=armv7"
NEON_FLAG="-march=armv7 -mfpu=neon"
else
ARMV7_FLAG="-march=armv7"
NEON_FLAG="-mfpu=neon"
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${NEON_FLAG} TestPrograms/test_arm_neon_header.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_HEADER 1'
HDRFLAGS="-DCRYPTOPP_ARM_NEON_HEADER=1"
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV7_FLAG} TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_ARMV7_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_ARMV7 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${NEON_FLAG} TestPrograms/test_arm_neon.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_NEON 1'
fi
# Cryptogams is special. Attempt to compile the actual source files
# TestPrograms/test_cxx.cxx is needed for main().
CXX_RESULT=$(${CXX} ${CXXFLAGS} aes_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_AES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} sha1_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_SHA1 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} sha256_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_SHA256 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} sha512_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_SHA512 1'
fi
} >> config_asm.h.new
fi
#############################################################################
# ARM 64-bit machines
if [[ "$disable_asm" -eq 0 && "$IS_ARMV8" -ne 0 ]]; then
# IS_IOS is set when ./setenv-ios is run
if [[ "$IS_IOS" -ne 0 ]]; then
ARMV8_FLAG="-arch arm64"
ARMV81_CRC_FLAG="-arch arm64"
ARMV81_CRYPTO_FLAG="-arch arm64"
ARMV84_CRYPTO_FLAG="-arch arm64"
else
ARMV8_FLAG="-march=armv8-a"
ARMV81_CRC_FLAG="-march=armv8-a+crc"
ARMV81_CRYPTO_FLAG="-march=armv8-a+crypto"
ARMV84_CRYPTO_FLAG="-march=armv8.4-a+crypto"
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_arm_neon_header.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_HEADER 1'
HDRFLAGS="-DCRYPTOPP_ARM_NEON_HEADER=1"
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} TestPrograms/test_arm_acle_header.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_ACLE_HEADER 1'
HDRFLAGS="${HDRFLAGS} -DCRYPTOPP_ARM_ACLE_HEADER=1"
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} TestPrograms/test_arm_neon.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_NEON 1'
fi
# This should be an unneeded test. ASIMD on Aarch64 is NEON on A32 and T32
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} TestPrograms/test_arm_asimd.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_ASIMD_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_ASIMD 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRC_FLAG} TestPrograms/test_arm_crc.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_CRC32_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_CRC32 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_AES_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_AES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_pmull.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_PMULL_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_PMULL 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_sha1.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA_AVAILABLE 1'
echo '#define CRYPTOPP_ARM_SHA1_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA 1'
echo '#define CRYPTOPP_DISABLE_ARM_SHA1 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_sha256.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA2_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA2 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sha3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA3_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sha512.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA512_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA512 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sm3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SM3_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SM3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sm4.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SM4_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SM4 1'
fi
} >> config_asm.h.new
fi
#############################################################################
# PowerPC machines
if [[ "$disable_asm" -eq 0 && ("$IS_PPC" -ne 0 || "$IS_PPC64" -ne 0) ]]; then
if [[ "${XLC_COMPILER}" -ne 0 ]]; then
POWER9_FLAG="-qarch=pwr9 -qaltivec"
POWER8_FLAG="-qarch=pwr8 -qaltivec"
POWER7_VSX_FLAG="-qarch=pwr7 -qvsx -qaltivec"
POWER7_PWR_FLAG="-qarch=pwr7 -qaltivec"
ALTIVEC_FLAG="-qaltivec"
else
POWER9_FLAG="-mcpu=power9"
POWER8_FLAG="-mcpu=power8"
POWER7_VSX_FLAG="-mcpu=power7 -mvsx"
POWER7_PWR_FLAG="-mcpu=power7"
ALTIVEC_FLAG="-maltivec"
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${ALTIVEC_FLAG} TestPrograms/test_ppc_altivec.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
have_altivec=1
echo '#define CRYPTOPP_ALTIVEC_AVAILABLE 1'
else
have_altivec=0
echo '#define CRYPTOPP_DISABLE_ALTIVEC 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER7_PWR_FLAG} TestPrograms/test_ppc_power7.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_altivec" -ne 0 ]]; then
have_power7=1
echo '#define CRYPTOPP_POWER7_AVAILABLE 1'
else
have_power7=0
echo '#define CRYPTOPP_DISABLE_POWER7 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_power8.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power7" -ne 0 ]]; then
have_power8=1
echo '#define CRYPTOPP_POWER8_AVAILABLE 1'
else
have_power8=0
echo '#define CRYPTOPP_DISABLE_POWER8 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER9_FLAG} TestPrograms/test_ppc_power9.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -ne 0 && "$have_power8" -ne 0 ]]; then
have_power9=1
echo '#define CRYPTOPP_POWER9_AVAILABLE 1'
else
have_power9=0
echo '#define CRYPTOPP_DISABLE_POWER9 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power8" -ne 0 ]]; then
echo '#define CRYPTOPP_POWER8_AES_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_POWER8_AES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_vmull.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power8" -ne 0 ]]; then
echo '#define CRYPTOPP_POWER8_VMULL_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_POWER8_VMULL 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_sha.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power8" -ne 0 ]]; then
echo '#define CRYPTOPP_POWER8_SHA_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_POWER8_SHA 1'
fi
} >> config_asm.h.new
fi
# Common footer
{
echo ''
echo '#endif // CRYPTOPP_CONFIG_ASM_H'
echo ''
} >> config_asm.h.new
if [[ -e config_asm.h ]]; then
cp config_asm.h config_asm.h.old
mv config_asm.h.new config_asm.h
fi
# ===========================================================================
# =============================== config_cxx.h ==============================
# ===========================================================================
rm -f config_cxx.h.new
# Common header
{
echo '// config_cxx.h rewritten by configure.sh script'
echo '//' "${TIMESTAMP}"
echo '// Also see https://www.cryptopp.com/wiki/configure.sh'
echo ''
echo '#ifndef CRYPTOPP_CONFIG_CXX_H'
echo '#define CRYPTOPP_CONFIG_CXX_H'
} >> config_cxx.h.new
# Shell redirection
{
echo ''
echo '// ***************** C++98 and C++03 ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx98_exception.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '// Ancient Crypto++ define, dating back to C++98.'
echo '#define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 1'
echo '#define CRYPTOPP_CXX98_UNCAUGHT_EXCEPTION 1'
else
echo '// Ancient Crypto++ define, dating back to C++98.'
echo '// #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 1'
echo '// #define CRYPTOPP_CXX98_UNCAUGHT_EXCEPTION 1'
fi
echo ''
echo '// ***************** C++11 and above ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11 1'
else
echo '// test_cxx11.cxx returned non-zero result'
echo '// #define CRYPTOPP_CXX11 1'
fi
echo ''
echo '#if defined(CRYPTOPP_CXX11)'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_atomic.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ATOMIC 1'
else
echo '// #define CRYPTOPP_CXX11_ATOMIC 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_auto.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_AUTO 1'
else
echo '// #define CRYPTOPP_CXX11_AUTO 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_sync.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_SYNCHRONIZATION 1'
else
echo '// #define CRYPTOPP_CXX11_SYNCHRONIZATION 1'
fi
# CRYPTOPP_CXX11_DYNAMIC_INIT is old name
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_staticinit.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_STATIC_INIT 1'
echo '#define CRYPTOPP_CXX11_DYNAMIC_INIT 1'
else
echo '// #define CRYPTOPP_CXX11_STATIC_INIT 1'
echo '// #define CRYPTOPP_CXX11_DYNAMIC_INIT 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_deletefn.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_DELETED_FUNCTIONS 1'
else
echo '// #define CRYPTOPP_CXX11_DELETED_FUNCTIONS 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_alignas.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ALIGNAS 1'
else
echo '// #define CRYPTOPP_CXX11_ALIGNAS 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_alignof.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ALIGNOF 1'
else
echo '// #define CRYPTOPP_CXX11_ALIGNOF 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_initializer.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_INITIALIZER_LIST 1'
else
echo '// #define CRYPTOPP_CXX11_INITIALIZER_LIST 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_lambda.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_LAMBDA 1'
else
echo '// #define CRYPTOPP_CXX11_LAMBDA 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_noexcept.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_NOEXCEPT 1'
else
echo '// #define CRYPTOPP_CXX11_NOEXCEPT 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_vartemplates.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1'
else
echo '// #define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_constexpr.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_CONSTEXPR 1'
else
echo '// #define CRYPTOPP_CXX11_CONSTEXPR 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_enumtype.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_STRONG_ENUM 1'
else
echo '// #define CRYPTOPP_CXX11_STRONG_ENUM 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_nullptr.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_NULLPTR 1'
else
echo '// #define CRYPTOPP_CXX11_NULLPTR 1'
fi
# 2-argument static assert
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_assert.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ASSERT 1'
else
echo '// #define CRYPTOPP_CXX11_ASSERT 1'
fi
echo ''
echo '#endif // CRYPTOPP_CXX11'
echo ''
echo '// ***************** C++14 and above ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx14.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX14 1'
else
echo '// test_cxx14.cxx returned non-zero result'
echo '// #define CRYPTOPP_CXX14 1'
fi
echo ''
echo '#if defined(CRYPTOPP_CXX14)'
echo ''
echo '// No dead bodies here. Move on...'
echo ''
echo '#endif // CRYPTOPP_CXX14'
echo ''
echo '// ***************** C++17 and above ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx17.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX17 1'
else
echo '// test_cxx17.cxx returned non-zero result'
echo '// #define CRYPTOPP_CXX17 1'
fi
echo ''
echo '#if defined(CRYPTOPP_CXX17)'
echo ''
# 1-argument static assert
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx17_assert.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX17_ASSERT 1'
else
echo '// #define CRYPTOPP_CXX17_ASSERT 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx17_exceptions.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1'
else
echo '// #define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1'
fi
echo ''
echo '#endif // CRYPTOPP_CXX17'
echo ''
echo '// ***************** C++ fixups ********************'
echo ''
echo '#if defined(CRYPTOPP_CXX11_NOEXCEPT)'
echo '# define CRYPTOPP_THROW noexcept(false)'
echo '# define CRYPTOPP_NO_THROW noexcept(true)'
echo '#else'
echo '# define CRYPTOPP_THROW'
echo '# define CRYPTOPP_NO_THROW'
echo '#endif // CRYPTOPP_CXX11_NOEXCEPT'
echo ''
echo '// C++11 nullptr_t type safety and analysis'
echo '#if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR)'
echo '# define NULLPTR nullptr'
echo '#elif !defined(NULLPTR)'
echo '# define NULLPTR NULL'
echo '#endif // CRYPTOPP_CXX11_NULLPTR'
} >> config_cxx.h.new
# Common footer
{
echo ''
echo '#endif // CRYPTOPP_CONFIG_CXX_H'
echo ''
} >> config_cxx.h.new
if [[ -e config_cxx.h ]]; then
cp config_cxx.h config_cxx.h.old
mv config_cxx.h.new config_cxx.h
fi
rm -f "${TOUT}"
exit 0
+30
View File
@@ -0,0 +1,30 @@
# coverity-linux.txt - Scan build submission instructions for Unix and Linux.
# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
# Copyright assigned to Crypto++ project.
#
# The following are copy/paste instructions for invoking cov-build, building the library and submitting the artifacts for a scan.
#
# For more information see http://cryptopp.com/wiki/Coverity_Scan.
##################################################################
reset
make distclean &>/dev/null
# Usually we test with these flags
# CXXFLAGS="-DNDEBUG -g3 -O2"
cov-build --dir cov-int make -j 2
tar czvf cryptopp.tgz cov-int
CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX
COVERITY_SCAN_NAME="Rijndael-AliasedTable-SSE2-Linux-i686"
curl \
--form token="$CRYPTOPP_COVERITY_TOKEN" \
--form email=webmaster@cryptopp.com \
--form file=@cryptopp.tgz \
--form version="$COVERITY_SCAN_NAME" \
--form description="$COVERITY_SCAN_NAME" \
https://scan.coverity.com/builds?project=Cryptopp
+36
View File
@@ -0,0 +1,36 @@
# coverity-linux.txt - Scan build submission instructions for Unix and Linux.
# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
# Copyright assigned to Crypto++ project.
#
# The following are copy/paste instructions for invoking cov-build, building the library and submitting the artifacts for a scan.
#
# For more information see http://cryptopp.com/wiki/Coverity_Scan.
##################################################################
reset
make distclean &>/dev/null
# Usually we test with these flags
CXXFLAGS="-DNDEBUG -g3 -O2" cov-build --dir cov-int make -j 2
# Sometimes we need these flags (add COVERITY_UNSUPPORTED)
# COVERITY_UNSUPPORTED=1 CXXFLAGS="-DNDEBUG -g3 -O2" cov-build --dir cov-int make -j 2
# Sometimes we need these flags (alternate compile, C++11)
# CXX=/opt/local/bin/clang++-mp-3.7 COVERITY_UNSUPPORTED=1 CXXFLAGS="-DNDEBUG -g3 -O2 -std=c++11" cov-build --dir cov-int make -j 2
tar czvf cryptopp.tgz cov-int
CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX
COVERITY_SCAN_NAME="Cryptopp-MacOSX-x86_64"
curl
--form token="$CRYPTOPP_COVERITY_TOKEN" \
--form email=webmaster@cryptopp.com \
--form file=@cryptopp.tgz \
--form version="$COVERITY_SCAN_NAME" \
--form description="$COVERITY_SCAN_NAME" \
https://scan.coverity.com/builds?project=Cryptopp
+30
View File
@@ -0,0 +1,30 @@
REM coverity-windows.txt - Scan build submission instructions for Windows using cryptest.nmake.
REM Written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
REM Copyright assigned to Crypto++ project.
REM
REM The following are copy/paste instructions for invoking cov-build, building the library and
REM submitting the artifacts for a scan. Also see http://cryptopp.com/wiki/Coverity_Scan.
REM ################################################################
cls
del /f cryptopp.zip
rmdir /q /s cov-int
nmake /f cryptest.nmake clean
REM Uncomment CXXFLAGS in makefile. Pay attention to X86, X64 or ARM
cov-build.exe --dir cov-int nmake /f cryptest.nmake
7z.exe a -r -tzip -mx=9 cryptopp.zip cov-int
set CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX
set COVERITY_SCAN_NAME=Rijndael-AliasedTable-SSE2-Windows-X64
curl.exe ^
--form token="%CRYPTOPP_COVERITY_TOKEN%" ^
--form email=webmaster@cryptopp.com ^
--form file=@cryptopp.zip ^
--form version="%COVERITY_SCAN_NAME%" ^
--form description="%COVERITY_SCAN_NAME%" ^
https://scan.coverity.com/builds?project=Cryptopp
+18
View File
@@ -0,0 +1,18 @@
REM cryptdll-windows.cmd - written and placed in public domain by Jeffrey Walton
REM Copyright assigned to the Crypto++ project.
REM
REM For details see https://cryptopp.com/wiki/MSBuild_(Command_Line)
REM
REM Build the Win32/Debug cryptest.exe
msbuild /t:Build /p:Configuration=Debug;Platform=Win32 cryptlib.vcxproj
msbuild /t:Build /p:Configuration=Debug;Platform=Win32 cryptest.vcxproj
REM Build the Win32/Release cryptopp.dll
msbuild /t:Build /p:Configuration=Release;Platform=Win32 cryptdll.vcxproj
REM Build the FIPS test driver
msbuild /t:Build /p:Configuration=Release;Platform=Win32 dlltest.vcxproj
REM Run the FIPS test driver
.\Win32\DLL_Output\Release\dlltest.exe
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# ====================================================================
# Tests Android cross-compiles
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
# ====================================================================
if [ -z "$(command -v ./setenv-android.sh)" ]; then
echo "Failed to locate setenv-android.sh"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
# Temp directory
if [[ -z "$TMPDIR" ]]; then
TMPDIR="$HOME/tmp"
mkdir -p "$TMPDIR"
fi
MAKE_JOBS=2
# Cleanup old artifacts
rm -rf "$TMPDIR/build.failed" 2>/dev/null
rm -rf "$TMPDIR/build.log" 2>/dev/null
PLATFORMS=(armv7a aarch64 x86 x86_64)
for platform in "${PLATFORMS[@]}"
do
# setenv-android.sh reads these two variables for configuration info.
export ANDROID_API="23"
export ANDROID_CPU="$platform"
make -f GNUmakefile-cross distclean > /dev/null 2>&1
echo
echo "===================================================================="
echo "Testing for Android support of $platform"
# Test if we can set the environment for the platform
if ! ./setenv-android.sh > /dev/null 2>&1;
then
echo
echo "There were problems testing $platform"
echo "$platform ==> SKIPPED" >> "$TMPDIR/build.log"
continue
fi
echo
echo "Building for $platform..."
echo
# run in subshell to not keep any envars
(
source ./setenv-android.sh
if make -k -j "$MAKE_JOBS" -f GNUmakefile-cross static dynamic cryptest.exe;
then
echo "$platform ==> SUCCESS" >> "$TMPDIR/build.log"
else
echo "$platform ==> FAILURE" >> "$TMPDIR/build.log"
touch "$TMPDIR/build.failed"
fi
)
done
echo ""
echo "====================================================="
cat "$TMPDIR/build.log"
# let the script fail if any of the builds failed
if [ -f "$TMPDIR/build.failed" ]; then
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
+175
View File
@@ -0,0 +1,175 @@
#!/usr/bin/env bash
PWD_DIR=$(pwd)
function cleanup {
cd "$PWD_DIR"
}
trap cleanup EXIT
#############################################################################
GREP=grep
SED=sed
AWK=awk
MAKE=make
# Fixup, Solaris and friends
if [[ -d /usr/xpg4/bin ]]; then
SED=/usr/xpg4/bin/sed
AWK=/usr/xpg4/bin/awk
GREP=/usr/xpg4/bin/grep
elif [[ -d /usr/bin/posix ]]; then
SED=/usr/bin/posix/sed
AWK=/usr/bin/posix/awk
GREP=/usr/bin/posix/grep
fi
# Fixup for sed and "illegal byte sequence"
IS_DARWIN=$(uname -s 2>/dev/null | "$GREP" -i -c darwin)
if [[ "$IS_DARWIN" -ne 0 ]]; then
export LC_ALL=C
fi
# Fixup for Solaris and BSDs
if [[ ! -z $(command -v gmake 2>/dev/null) ]]; then
MAKE=gmake
else
MAKE=make
fi
# Fixup for missing libtool
if [[ ! -z $(command -v glibtoolize 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v glibtoolize)
elif [[ ! -z $(command -v libtoolize 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v libtoolize)
elif [[ ! -z $(command -v glibtool 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v glibtool)
elif [[ ! -z $(command -v libtool 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v libtool)
fi
#############################################################################
if [[ -z $(command -v autoupdate 2>/dev/null) ]]; then
echo "Cannot find autoupdate. Things may fail."
fi
if [[ -z "$LIBTOOLIZE" ]]; then
echo "Cannot find libtoolize. Things may fail."
fi
if [[ -z $(command -v automake 2>/dev/null) ]]; then
echo "Cannot find automake. Things may fail."
fi
if [[ -z $(command -v autoreconf 2>/dev/null) ]]; then
echo "Cannot find autoreconf. Things may fail."
fi
if [[ -z $(command -v curl 2>/dev/null) ]]; then
echo "Cannot find cURL. Things may fail."
fi
#############################################################################
files=(configure.ac Makefile.am libcryptopp.pc.in)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! curl -o "$file" --silent --insecure "https://raw.githubusercontent.com/noloader/cryptopp-autotools/master/$file"; then
echo "$file download failed"
exit 1
fi
done
mkdir -p m4/
#############################################################################
echo "Running autoupdate"
if ! autoupdate &>/dev/null; then
echo "autoupdate failed."
exit 1
fi
# Run autoreconf twice on failure. Also see
# https://github.com/tracebox/tracebox/issues/57
echo "Running autoreconf"
if ! autoreconf --force --install &>/dev/null; then
echo "autoreconf failed, running again."
if ! autoreconf --force --install; then
echo "autoreconf failed, again."
exit 1
fi
fi
#############################################################################
# Update config.sub config.guess. GNU recommends using the latest for all projects.
echo "Updating config.sub"
curl -o config.sub.new --silent --insecure 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub'
# Solaris removes +w, can't overwrite
chmod +w build-aux/config.sub
mv config.sub.new build-aux/config.sub
chmod +x build-aux/config.sub
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
echo "Removing config.sub quarantine"
xattr -d "com.apple.quarantine" build-aux/config.sub &>/dev/null
fi
echo "Updating config.guess"
curl -o config.guess.new --silent --insecure 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess'
# Solaris removes +w, can't overwrite
chmod +w build-aux/config.guess
mv config.guess.new build-aux/config.guess
chmod +x build-aux/config.guess
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
echo "Removing config.guess quarantine"
xattr -d "com.apple.quarantine" build-aux/config.guess &>/dev/null
fi
#############################################################################
echo "Running configure"
echo ""
if ! ./configure; then
echo "configure failed."
exit 1
fi
#############################################################################
echo ""
echo "Building test artifacts"
echo ""
"$MAKE" clean &>/dev/null
if ! "$MAKE" -j2 -f Makefile; then
echo "make failed."
exit 1
fi
#############################################################################
echo ""
echo "Testing library"
echo ""
if ! ./cryptest v; then
echo "cryptest v failed."
exit 1
fi
if ! ./cryptest tv all; then
echo "cryptest tv all failed."
exit 1
fi
# Return success
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
+90
View File
@@ -0,0 +1,90 @@
#!/usr/bin/env bash
PWD_DIR=$(pwd)
function cleanup {
cd "$PWD_DIR"
}
trap cleanup EXIT
# Fixup ancient Bash
# https://unix.stackexchange.com/q/468579/56041
if [[ -z "$BASH_SOURCE" ]]; then
BASH_SOURCE="$0"
fi
# Fixup for Solaris and BSDs
if [[ ! -z $(command -v gmake) ]]; then
MAKE=gmake
else
MAKE=make
fi
# Fixup for AIX
if [[ -z "$CMAKE" ]]; then
CMAKE=cmake
fi
#############################################################################
if [[ -z $(command -v "$CMAKE") ]]; then
echo "Cannot find $CMAKE. Things may fail."
fi
if [[ -z $(command -v curl) ]]; then
echo "Cannot find cURL. Things may fail."
fi
#############################################################################
files=(CMakeLists.txt cryptopp-config.cmake)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! curl -o "$file" --silent --insecure "https://raw.githubusercontent.com/noloader/cryptopp-cmake/master/$file"; then
echo "$file download failed"
exit 1
fi
done
rm -rf "$PWD_DIR/cmake_build"
mkdir -p "$PWD_DIR/cmake_build"
cd "$PWD_DIR/cmake_build"
#############################################################################
echo ""
echo "Building test artifacts"
echo ""
if [[ ! -z "$CXX" ]];
then
if ! CXX="$CXX" "$CMAKE" -DCMAKE_CXX_COMPILER="$CXX" ../; then
echo "cmake failed"
exit 1
fi
else
if ! "$CMAKE" ../; then
echo "cmake failed"
exit 1
fi
fi
"$MAKE" clean &>/dev/null
if ! "$MAKE" -j2 -f Makefile VERBOSE=1; then
echo "make failed"
exit 1
fi
if ! ./cryptest.exe v; then
echo "cryptest.exe v failed"
exit 1
fi
if ! ./cryptest.exe tv all; then
echo "cryptest.exe v failed"
exit 1
fi
# Return success
exit 0
+12
View File
@@ -0,0 +1,12 @@
// cryptest-coverity.cpp - Coverity modeling file.
// Written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
//
// For more information see http://cryptopp.com/wiki/Coverity_Scan.
//
// Also see https://scan.coverity.com/tune#what-is-model
///////////////////////////////////////////////////////////////////
void special_abort(const char* msg) {
__coverity_panic__();
}
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
# ====================================================================
# Tests iOS cross-compiles
#
# See http://www.cryptopp.com/wiki/iOS_(Command_Line) for more details
# ====================================================================
if [ -z "$(command -v ./setenv-ios.sh)" ]; then
echo "Failed to locate setenv-ios.sh"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
# Temp directory
if [[ -z "$TMPDIR" ]]; then
TMPDIR="$HOME/tmp"
mkdir "$TMPDIR"
fi
MAKE_JOBS=2
# Cleanup old artifacts
rm -rf "$TMPDIR/build.failed" 2>/dev/null
rm -rf "$TMPDIR/build.log" 2>/dev/null
# Hack a Bash data structure...
PLATFORMS=()
PLATFORMS+=("iPhoneOS:armv7")
PLATFORMS+=("iPhoneOS:arm64")
PLATFORMS+=("AppleTVOS:armv7")
PLATFORMS+=("AppleTVOS:arm64")
PLATFORMS+=("WatchOS:armv7")
PLATFORMS+=("WatchOS:arm64")
PLATFORMS+=("iPhoneSimulator:i386")
PLATFORMS+=("iPhoneSimulator:x86_64")
PLATFORMS+=("AppleTVSimulator:i386")
PLATFORMS+=("AppleTVSimulator:x86_64")
PLATFORMS+=("WatchSimulator:i386")
PLATFORMS+=("WatchSimulator:x86_64")
for platform in "${PLATFORMS[@]}"
do
sdk=$(echo "${platform[@]}" | awk -F':' '{print $1}')
cpu=$(echo "${platform[@]}" | awk -F':' '{print $2}')
# setenv-ios.sh reads these two variables for configuration info.
export IOS_SDK="$sdk"
export IOS_CPU="$cpu"
make -f GNUmakefile-cross distclean > /dev/null 2>&1
echo
echo "====================================================="
echo "Testing for iOS support of $platform"
# Test if we can set the environment for the platform
if ! ./setenv-ios.sh > /dev/null 2>&1;
then
echo
echo "$platform not supported by Xcode"
echo "$platform ==> SKIPPED" >> "$TMPDIR/build.log"
continue
fi
echo
echo "Building for $platform..."
echo
# run in subshell to not keep any envars
(
source ./setenv-ios.sh
if make -k -j "$MAKE_JOBS" -f GNUmakefile-cross static dynamic cryptest.exe;
then
echo "$platform ==> SUCCESS" >> "$TMPDIR/build.log"
else
echo "$platform ==> FAILURE" >> "$TMPDIR/build.log"
touch "$TMPDIR/build.failed"
fi
)
done
echo ""
echo "====================================================="
cat "$TMPDIR/build.log"
# let the script fail if any of the builds failed
if [ -f "$TMPDIR/build.failed" ]; then
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env bash
PWD_DIR=$(pwd)
function cleanup {
cd "$PWD_DIR"
}
trap cleanup EXIT
#############################################################################
GREP=grep
SED=sed
AWK=awk
MAKE=make
# Fixup, Solaris and friends
if [[ (-d /usr/xpg4/bin) ]]; then
SED=/usr/xpg4/bin/sed
AWK=/usr/xpg4/bin/awk
GREP=/usr/xpg4/bin/grep
elif [[ (-d /usr/bin/posix) ]]; then
SED=/usr/bin/posix/sed
AWK=/usr/bin/posix/awk
GREP=/usr/bin/posix/grep
fi
# Fixup for sed and "illegal byte sequence"
IS_DARWIN=$(uname -s | "$GREP" -i -c darwin)
if [[ "$IS_DARWIN" -ne 0 ]]; then
export LC_ALL=C
fi
# Fixup for Solaris and BSDs
if [[ ! -z $(command -v gmake) ]]; then
MAKE=gmake
else
MAKE=make
fi
#############################################################################
if [[ -z $(command -v "$MAKE") ]]; then
echo "Cannot find $MAKE. Things may fail."
fi
if [[ -z $(command -v curl) ]]; then
echo "Cannot find cURL. Things may fail."
fi
if [[ -z $(command -v openssl) ]]; then
echo "Cannot find openssl. Things may fail."
fi
#############################################################################
files=(pem_create.sh pem_verify.sh pem_test.cxx pem_eol.cxx
pem.h pem_common.cpp pem_common.h pem_read.cpp pem_write.cpp
x509cert.h x509cert.cpp)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! curl -o "$file" --silent --insecure "https://raw.githubusercontent.com/noloader/cryptopp-pem/master/$file"; then
echo "$file download failed"
exit 1
fi
done
# Add execute to scripts
chmod +x *.sh
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr) ]]; then
echo "Removing pem_create.sh pem_verify.sh quarantine"
xattr -d "com.apple.quarantine" pem_create.sh pem_verify.sh &>/dev/null
fi
#############################################################################
echo ""
echo "Building test artifacts"
echo ""
"$MAKE" clean &>/dev/null
if ! "$MAKE" -j 2; then
echo "make failed."
exit 1
fi
if ! ./cryptest.exe v; then
echo "cryptest v failed."
exit 1
fi
if ! ./pem_create.sh; then
echo "pem_create.sh failed."
exit 1
fi
if ! ./pem_verify.sh; then
echo "pem_verify.sh failed."
exit 1
fi
# Return success
exit 0
+328
View File
@@ -0,0 +1,328 @@
#!/usr/bin/env bash
# cryptest.sh - written and placed in public domain by Jeffrey Walton and Uri
# Blumenthal.
# This is a test script that can be used on some Linux/Unix/Apple machines to
# automate testing of the shared object to ensure linking and symbols don't go
# missing from release to release.
# Fixup ancient Bash
# https://unix.stackexchange.com/q/468579/56041
if [[ -z "$BASH_SOURCE" ]]; then
BASH_SOURCE="$0"
fi
############################################
# Cleanup
PWD_DIR=$(pwd)
function cleanup {
rm -f adhoc.cpp *.a *.o *.so *.dylib
cd "$PWD_DIR"
}
trap cleanup EXIT
############################################
# Tags to test
OLD_VERSION_TAG=CRYPTOPP_8_2_0
NEW_VERSION_TAG=master
############################################
# If local repo is dirty, then promt first
DIRTY=$(git diff --shortstat 2> /dev/null | tail -1)
if [[ ! (-z "$DIRTY") ]]; then
echo
echo "The local repo is dirty. Continuing will reset the repo and lose changes."
read -p "Type 'Y' to proceed or 'N' to exit. Proceed? " -n 1 -r
echo # (optional) move to a new line
if [[ !($REPLY =~ ^[Yy]$) ]]; then
exit 0
fi
else
echo
echo "The local repo is clean. Proceeding..."
fi
############################################
echo
echo "****************************************************************"
echo "Testing '$NEW_VERSION_TAG' against '$OLD_VERSION_TAG'"
echo "****************************************************************"
############################################
# Setup tools and platforms
GREP=grep
EGREP=egrep
SED=sed
AWK=awk
CXXFILT=c++filt
THIS_SYSTEM=$(uname -s 2>&1)
IS_DARWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c darwin)
IS_LINUX=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c linux)
IS_CYGWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c cygwin)
IS_MINGW=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c mingw)
IS_OPENBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c openbsd)
IS_FREEBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c freebsd)
IS_NETBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c netbsd)
IS_SOLARIS=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c sunos)
THIS_MACHINE=$(uname -m 2>&1)
IS_X86=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(i386|i486|i586|i686)")
IS_X64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(amd64|x86_64)")
IS_PPC=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(Power|PPC)")
IS_ARM32=$(echo -n "$THIS_MACHINE" | "$GREP" -v "64" | "$EGREP" -i -c "(arm|aarch32)")
IS_ARM64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(arm64|aarch64)")
IS_S390=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "s390")
IS_X32=0
# Fixup
if [[ "$IS_SOLARIS" -ne "0" ]]; then
IS_X64=$(isainfo 2>/dev/null | "$GREP" -i -c "amd64")
if [[ "$IS_X64" -ne "0" ]]; then
IS_X86=0
fi
# Need something more powerful than the Posix versions
if [[ (-e "/usr/gnu/bin/grep") ]]; then
GREP=/usr/gnu/bin/grep
fi
if [[ (-e "/usr/gnu/bin/egrep") ]]; then
EGREP=/usr/gnu/bin/egrep
fi
if [[ (-e "/usr/gnu/bin/sed") ]]; then
SED=/usr/gnu/bin/sed
fi
if [[ (-e "/usr/gnu/bin/c++filt") ]]; then
CXXFILT=/usr/gnu/bin/c++filt
fi
if [[ (-e "/usr/gnu/bin/awk") ]]; then
AWK=/usr/gnu/bin/awk
else
AWK=nawk;
fi
fi
if [[ "$IS_DARWIN" -ne "0" ]]; then
SED_OPTS=(-i '')
else
SED_OPTS=(-i)
fi
# Fixup
if [[ ("$IS_FREEBSD" -ne "0" || "$IS_OPENBSD" -ne "0" || "$IS_NETBSD" -ne "0") ]]; then
MAKE=gmake
elif [[ ("$IS_SOLARIS" -ne "0") ]]; then
MAKE=$(which gmake 2>/dev/null | "$GREP" -v "no gmake" | head -1)
if [[ (-z "$MAKE") && (-e "/usr/sfw/bin/gmake") ]]; then
MAKE=/usr/sfw/bin/gmake
fi
else
MAKE=make
fi
# We need to use the C++ compiler to determine feature availablility. Otherwise
# mis-detections occur on a number of platforms.
if [[ ((-z "$CXX") || ("$CXX" == "gcc")) ]]; then
if [[ ("$CXX" == "gcc") ]]; then
CXX=g++
elif [[ "$IS_DARWIN" -ne "0" ]]; then
CXX=c++
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
if [[ (-e "/opt/developerstudio12.5/bin/CC") ]]; then
CXX=/opt/developerstudio12.5/bin/CC
elif [[ (-e "/opt/solarisstudio12.4/bin/CC") ]]; then
CXX=/opt/solarisstudio12.4/bin/CC
elif [[ (-e "/opt/solarisstudio12.3/bin/CC") ]]; then
CXX=/opt/solarisstudio12.3/bin/CC
elif [[ (-e "/opt/solstudio12.2/bin/CC") ]]; then
CXX=/opt/solstudio12.2/bin/CC
elif [[ (-e "/opt/solstudio12.1/bin/CC") ]]; then
CXX=/opt/solstudio12.1/bin/CC
elif [[ (-e "/opt/solstudio12.0/bin/CC") ]]; then
CXX=/opt/solstudio12.0/bin/CC
elif [[ (! -z $(which CC 2>/dev/null | "$GREP" -v "no CC" | head -1)) ]]; then
CXX=$(which CC | head -1)
elif [[ (! -z $(which g++ 2>/dev/null | "$GREP" -v "no g++" | head -1)) ]]; then
CXX=$(which g++ | head -1)
else
CXX=CC
fi
elif [[ ($(which g++ 2>&1 | "$GREP" -v "no g++" | "$GREP" -i -c g++) -ne "0") ]]; then
CXX=g++
else
CXX=c++
fi
fi
SUN_COMPILER=$("$CXX" -V 2>&1 | "$EGREP" -i -c "CC: (Sun|Studio)")
GCC_COMPILER=$("$CXX" --version 2>&1 | "$GREP" -i -v "clang" | "$EGREP" -i -c "(gcc|g\+\+)")
INTEL_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "\(icc\)")
MACPORTS_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "MacPorts")
CLANG_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "clang")
if [[ ("$SUN_COMPILER" -eq "0") ]]; then
AMD64=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$EGREP" -c "(__x64_64__|__amd64__)")
ILP32=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$EGREP" -c "(__ILP32__|__ILP32)")
if [[ ("$AMD64" -ne "0") && ("$ILP32" -ne "0") ]]; then
IS_X32=1
fi
fi
############################################
# CPU is logical count, memory is in MiB. Low resource boards have
# fewer than 4 cores and 1GB or less memory. We use this to
# determine if we can build in parallel without an OOM kill.
CPU_COUNT=1
MEM_SIZE=512
if [[ (-e "/proc/cpuinfo") && (-e "/proc/meminfo") ]]; then
CPU_COUNT=$(cat /proc/cpuinfo | "$GREP" -c '^processor')
MEM_SIZE=$(cat /proc/meminfo | "$GREP" "MemTotal" | "$AWK" '{print $2}')
MEM_SIZE=$(($MEM_SIZE/1024))
elif [[ "$IS_DARWIN" -ne "0" ]]; then
CPU_COUNT=$(sysctl -a 2>&1 | "$GREP" 'hw.availcpu' | "$AWK" '{print $3; exit}')
MEM_SIZE=$(sysctl -a 2>&1 | "$GREP" 'hw.memsize' | "$AWK" '{print $3; exit;}')
MEM_SIZE=$(($MEM_SIZE/1024/1024))
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
CPU_COUNT=$(psrinfo 2>/dev/null | wc -l | "$AWK" '{print $1}')
MEM_SIZE=$(prtconf 2>/dev/null | "$GREP" Memory | "$AWK" '{print $3}')
fi
# Some ARM devboards cannot use 'make -j N', even with multiple cores and RAM
# An 8-core Cubietruck Plus with 2GB RAM experiences OOM kills with '-j 2'.
HAVE_SWAP=1
if [[ "$IS_LINUX" -ne "0" ]]; then
if [[ (-e "/proc/meminfo") ]]; then
SWAP_SIZE=$(cat /proc/meminfo | "$GREP" "SwapTotal" | "$AWK" '{print $2}')
if [[ "$SWAP_SIZE" -eq "0" ]]; then
HAVE_SWAP=0
fi
else
HAVE_SWAP=0
fi
fi
if [[ ("$CPU_COUNT" -ge "2" && "$MEM_SIZE" -ge "1280" && "$HAVE_SWAP" -ne "0") ]]; then
if [[ ("$WANT_NICE" -eq "1") ]]; then
CPU_COUNT=$(echo -n "$CPU_COUNT 2" | "$AWK" '{print int($1/$2)}')
fi
MAKEARGS=(-j "$CPU_COUNT")
fi
###############################################################################
###############################################################################
"$MAKE" distclean &>/dev/null
git checkout master -f &>/dev/null
git checkout "$OLD_VERSION_TAG" -f &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Failed to checkout $OLD_VERSION_TAG"
exit 1
fi
echo
echo "****************************************************************"
echo "Building dynamic library for $OLD_VERSION_TAG"
echo "****************************************************************"
echo
if [[ "$IS_DARWIN" -ne "0" ]]; then
LINK_LIBRARY=libcryptopp.dylib
else
LINK_LIBRARY=libcryptopp.so
fi
LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile dynamic
if [[ ! -f "$LINK_LIBRARY" ]]; then
echo "Failed to make $OLD_VERSION_TAG library"
exit 1
fi
echo
echo "****************************************************************"
echo "Building cryptest.exe for $OLD_VERSION_TAG"
echo "****************************************************************"
echo
"$MAKE" "${MAKEARGS[@]}" -f GNUmakefile cryptest.exe
if [[ ! -f "cryptest.exe" ]]; then
echo "Failed to make cryptest.exe"
exit 1
fi
echo
echo "****************************************************************"
echo "Running $OLD_VERSION_TAG cryptest.exe using $OLD_VERSION_TAG library"
echo "****************************************************************"
echo
if [[ "$IS_DARWIN" -ne "0" ]]; then
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
else
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
fi
echo
echo "****************************************************************"
echo "Removing dynamic library and artifacts for $OLD_VERSION_TAG"
echo "****************************************************************"
rm -f adhoc.cpp *.a *.o *.so *.dylib
git checkout "$NEW_VERSION_TAG" -f &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Failed to checkout $OLD_VERSION_TAG"
exit 1
fi
echo
echo "****************************************************************"
echo "Building dynamic library for $NEW_VERSION_TAG"
echo "****************************************************************"
echo
LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile dynamic
if [[ ! -f "$LINK_LIBRARY" ]]; then
echo "Failed to make $NEW_VERSION_TAG library"
exit 1
fi
echo
echo "****************************************************************"
echo "Running $OLD_VERSION_TAG cryptest.exe using $NEW_VERSION_TAG library"
echo "****************************************************************"
echo
if [[ "$IS_DARWIN" -ne "0" ]]; then
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
else
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
fi
git checkout master -f &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Failed to checkout Master"
exit 1
fi
exit 0
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
for file in $(find . -maxdepth 1 -type f -name '*.cpp'); do
echo "Tidying $file"
clang-tidy $file -checks=-clang-analyzer-optin.cplusplus.VirtualCall -- -std=c++03
done
+7268
View File
File diff suppressed because it is too large Load Diff
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# This scripts queries and modifies CPU scaling frequencies to produce more
# accurate benchmark results. To move from a low energy state to a higher
# one, run 'governor.sh performance'. To move back to a low power state
# run 'governor.sh powersave' or 'governor.sh ondemand' or reboot. The script
# based on code by Andy Polyakov, http://www.openssl.org/~appro/cryptogams/.
# Fixup ancient Bash
# https://unix.stackexchange.com/q/468579/56041
if [[ -z "${BASH_SOURCE[0]}" ]]; then
BASH_SOURCE="$0"
fi
if [[ "$EUID" -ne 0 ]]; then
echo "This script must be run as root"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
if [ "x$1" = "x" ]; then
echo "usage: $0 on[demand]|pe[rformance]|po[wersave]|us[erspace]?"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
# "on demand" may result in a "invalid write argument" or similar
case $1 in
on*|de*) governor="ondemand";;
po*|pw*) governor="powersave";;
pe*) governor="performance";;
co*) governor="conservative";;
us*) governor="userspace";;
\?) ;;
*) echo "$1: unrecognized governor";;
esac
if [ -z "$governor" ]; then
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
cpus=$(ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 2>/dev/null)
if [ -z "$cpus" ]; then
echo "Failed to read CPU system device tree"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
echo "Current CPU governor scaling settings:"
count=0
for cpu in $cpus; do
echo " CPU $count: $(cat "$cpu")"
((count++))
done
if [ "x$governor" != "x" ]; then
for cpu in $cpus; do
echo "$governor" > "$cpu"
done
fi
echo "New CPU governor scaling settings:"
count=0
for cpu in $cpus; do
echo " CPU $count: $(cat "$cpu")"
((count++))
done
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
# ====================================================================
# Tests Android cross-compiles
#
# This script installs a SDK and NDK to test Android cross-compiles.
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
# ====================================================================
# NDK-r19: https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip
# SDK for r19: https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
# SDK for Mac: https://dl.google.com/android/repository/sdk-tools-mac-4333796.zip
# NDK-r20: https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip
# SDK for r20: https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
# SDK for Mac: https://dl.google.com/android/repository/commandlinetools-mac-6200805_latest.zip
# NDK-r21: https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip
# SDK for r21: https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
# SDK for Mac: https://dl.google.com/android/repository/commandlinetools-mac-6200805_latest.zip
if [ -z "$ANDROID_SDK_ROOT" ]; then
echo "ERROR: ANDROID_SDK_ROOT is not set. Please set it."
echo "SDK root is $ANDROID_SDK_ROOT"
exit 1
fi
if [ -z "$ANDROID_NDK_ROOT" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not set. Please set it."
echo "NDK root is $ANDROID_NDK_ROOT"
exit 1
fi
IS_DARWIN=$(uname -s 2>/dev/null | grep -i -c darwin)
IS_LINUX=$(uname -s 2>/dev/null | grep -i -c linux)
# Keep this in sync with the move at the end.
if [ "$IS_LINUX" -eq 1 ]; then
SDK_URL=https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
NDK_URL=https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip
elif [ "$IS_DARWIN" -eq 1 ]; then
SDK_URL=https://dl.google.com/android/repository/commandlinetools-mac-6200805_latest.zip
NDK_URL=https://dl.google.com/android/repository/android-ndk-r20b-darwin-x86_64.zip
else
echo "Unknown platform: \"$(uname -s 2>/dev/null)\". Please fix this script."
fi
# install android deps
if [ -n "$(command -v apt-get)" ]; then
apt-get -qq update 2>/dev/null
apt-get -qq install --no-install-recommends openjdk-8-jdk unzip curl 2>/dev/null
fi
echo "Downloading SDK"
if ! curl -k -s -o android-sdk.zip "$SDK_URL";
then
echo "Failed to download SDK"
exit 1
fi
echo "Downloading NDK"
if ! curl -k -s -o android-ndk.zip "$NDK_URL";
then
echo "Failed to download NDK"
exit 1
fi
echo "Unpacking SDK to $ANDROID_SDK_ROOT"
if ! unzip -qq android-sdk.zip -d "$ANDROID_SDK_ROOT";
then
echo "Failed to unpack SDK"
exit 1
fi
echo "Unpacking NDK to $ANDROID_NDK_ROOT"
if ! unzip -qq android-ndk.zip -d "$HOME";
then
echo "Failed to unpack NDK"
exit 1
fi
if ! mv "$HOME/android-ndk-r20b" "$ANDROID_NDK_ROOT";
then
echo "Failed to move $HOME/android-ndk-r20b to $ANDROID_NDK_ROOT"
exit 1
fi
rm -f android-sdk.zip
rm -f android-ndk.zip
# We don't set ANDROID_HOME to ANDROID_SDK_ROOT.
# https://stackoverflow.com/a/47028911/608639
touch "$ANDROID_SDK_ROOT/repositories.cfg"
echo "Finished preparing SDK and NDK"
exit 0
+166
View File
@@ -0,0 +1,166 @@
#!/usr/bin/env bash
# make-benchmarks - Scan build submission instructions for Unix and Linux.
# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
# Copyright assigned to Crypto++ project.
#
# The following builds the benchmarks under 5.6.2, 5.6.4 and Master. The results can then be
# compared to ensure an speed penalty is not inadvertently taken. Crypto++ 5.6.2 is significant
# because its the last version Wei worked on before turning the library over to the community.
###############################################################################
# Set to suite your taste. Speed is in GiHz
if [[ -z "$CPU_FREQ" ]]; then
if [[ ! -z "CRYPTOPP_CPU_SPEED" ]]; then
CPU_FREQ="$CRYPTOPP_CPU_SPEED"
else
CPU_FREQ=2.8
fi
fi
echo "***************************************************"
echo "Using CPU frequency of $CPU_FREQ GiHz."
echo "Please modify this script if its not correct"
echo
###############################################################################
current=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
git fetch --all &>/dev/null &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "$PWD does not appear to be a Git repository"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
###############################################################################
# Try to find a fast option
OPT=
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O3 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-O3
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO3 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-xO3
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O2 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-O2
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO2 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-xO2
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-O
fi
fi
##################################################################
echo "***************************************************"
echo "**************** Crypto++ 5.6.2 *******************"
echo "***************************************************"
echo
git checkout -f CRYPTOPP_5_6_2 &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "git checkout CRYPTOPP_5_6_2 failed"
else
rm -f *.o benchmarks.html benchmarks-562.html &>/dev/null
CXXFLAGS="-DNDEBUG $OPT" make
if [[ "$?" -eq "0" ]]; then
echo "Running benchmarks for Crypto++ 5.6.2"
./cryptest.exe b 3 "$CPU_FREQ" > benchmarks-562.html
if [[ "$?" -ne "0" ]]; then
rm -rf benchmarks-562.html &>/dev/null
echo "Failed to create benchmarks for Crypto++ 5.6.2"
fi
else
echo "Failed to make benchmarks for Crypto++ 5.6.2"
fi
fi
##################################################################
echo "***************************************************"
echo "**************** Crypto++ 5.6.4 *******************"
echo "***************************************************"
echo
git checkout -f CRYPTOPP_5_6_4 &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "git checkout CRYPTOPP_5_6_4 failed"
else
rm -f *.o benchmarks.html benchmarks-564.html &>/dev/null
CXXFLAGS="-DNDEBUG $OPT" make
if [[ "$?" -eq "0" ]]; then
echo "Running benchmarks for Crypto++ 5.6.4"
./cryptest.exe b 3 "$CPU_FREQ" > benchmarks-564.html
if [[ "$?" -ne "0" ]]; then
rm -rf benchmarks-564.html &>/dev/null
echo "Failed to create benchmarks for Crypto++ 5.6.4"
fi
else
echo "Failed to make benchmarks for Crypto++ 5.6.4"
fi
fi
##################################################################
echo "***************************************************"
echo "*************** Crypto++ Master *******************"
echo "***************************************************"
echo
git checkout -f master &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "git checkout master failed"
else
rm -f *.o benchmarks.html benchmarks-master.html &>/dev/null
CXXFLAGS="-DNDEBUG $OPT" make
if [[ "$?" -eq "0" ]]; then
echo "Running benchmarks for Crypto++ Master"
./cryptest.exe b 3 "$CPU_FREQ" > benchmarks-master.html
if [[ "$?" -ne "0" ]]; then
rm -rf benchmarks-master.html &>/dev/null
echo "Failed to create benchmarks for Crypto++ Master"
fi
else
echo "Failed to make benchmarks for Crypto++ Master"
fi
fi
##################################################################
if [[ ! -z "$current" ]]; then
git checkout -f "$current"
fi
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Use this script to reset a fork to Wei Dai's master
# https://stackoverflow.com/questions/9646167/clean-up-a-fork-and-restart-it-from-the-upstream
git remote add upstream https://github.com/weidai11/cryptopp 2>/dev/null
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
+297
View File
@@ -0,0 +1,297 @@
#!/usr/bin/env bash
# ====================================================================
# Sets the cross compile environment for Android
#
# Based upon OpenSSL's setenv-android.sh by TH, JW, and SM.
# Heavily modified by JWW for Crypto++.
# Modified by Skycoder42 Android NDK-r19 and above.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# Also see:
# https://android.googlesource.com/platform/ndk.git/+/HEAD/docs/UnifiedHeaders.md
# https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
# ====================================================================
#########################################
##### Some validation #####
#########################################
# cryptest-android.sh may run this script without sourcing.
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
echo "setenv-android.sh is usually sourced, but not this time."
fi
# This supports 'source setenv-android.sh 23 arm64' and friends
if [[ -z "$ANDROID_API" && -n "$1" ]]; then
printf "Using positional arg, ANDROID_API=%s\n" "$1"
ANDROID_API="$1"
fi
# This supports 'source setenv-android.sh 23 arm64' and friends
if [[ -z "$ANDROID_CPU" && -n "$2" ]]; then
printf "Using positional arg, ANDROID_CPU=%s\n" "$2"
ANDROID_CPU="$2"
fi
if [ -z "$ANDROID_API" ]; then
echo "ANDROID_API is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ -z "$ANDROID_CPU" ]; then
echo "ANDROID_CPU is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#########################################
##### Clear old options #####
#########################################
unset IS_IOS
unset IS_ANDROID
unset IS_ARM_EMBEDDED
unset ANDROID_CXXFLAGS
unset ANDROID_SYSROOT
#####################################################################
# ANDROID_NDK_ROOT should always be set by the user (even when not running this script)
# http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77.
# If the user did not specify the NDK location, try and pick it up. Something like
# ANDROID_NDK_ROOT=/opt/android-ndk-r19c or ANDROID_NDK_ROOT=/usr/local/android-ndk-r20.
if [ -n "${ANDROID_NDK_ROOT}" ]; then
echo "ANDROID_NDK_ROOT is $ANDROID_NDK_ROOT"
else
echo "ANDROID_NDK_ROOT is empty. Searching for the NDK"
ANDROID_NDK_ROOT=$(find /opt -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_NDK_ROOT=$(find /usr/local -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
fi
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_NDK_ROOT=$(find "$HOME" -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
fi
if [ -d "$HOME/Library/Android/sdk/ndk-bundle" ]; then
ANDROID_NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle"
fi
fi
# Error checking
if [ ! -d "$ANDROID_NDK_ROOT" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not a valid path. Please set it."
echo "Root is $ANDROID_NDK_ROOT"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#####################################################################
# Need to set HOST_TAG to darwin-x86_64, linux-x86_64,
# windows, or windows-x86_64
if [[ "$(uname -s | grep -i -c darwin)" -ne 0 ]]; then
HOST_TAG=darwin-x86_64
elif [[ "$(uname -s | grep -i -c linux)" -ne 0 ]]; then
HOST_TAG=linux-x86_64
else
echo "ERROR: Unknown host"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_TAG/bin"
ANDROID_SYSROOT="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOST_TAG/sysroot"
# Error checking
if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
echo "ERROR: ANDROID_TOOLCHAIN is not a valid path. Please set it."
echo "Path is $ANDROID_TOOLCHAIN"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -d "$ANDROID_SYSROOT" ]; then
echo "ERROR: ANDROID_SYSROOT is not a valid path. Please set it."
echo "Path is $ANDROID_SYSROOT"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#####################################################################
THE_ARCH=$(tr '[:upper:]' '[:lower:]' <<< "$ANDROID_CPU")
# https://developer.android.com/ndk/guides/abis.html
case "$THE_ARCH" in
armv7*|armeabi*)
CC="armv7a-linux-androideabi$ANDROID_API-clang"
CXX="armv7a-linux-androideabi$ANDROID_API-clang++"
LD="arm-linux-androideabi-ld"
AS="arm-linux-androideabi-as"
AR="arm-linux-androideabi-ar"
RANLIB="arm-linux-androideabi-ranlib"
STRIP="arm-linux-androideabi-strip"
ANDROID_CXXFLAGS="-march=armv7-a -mthumb -mfloat-abi=softfp -funwind-tables -fexceptions -frtti"
;;
armv8*|aarch64|arm64*)
CC="aarch64-linux-android$ANDROID_API-clang"
CXX="aarch64-linux-android$ANDROID_API-clang++"
LD="aarch64-linux-android-ld"
AS="aarch64-linux-android-as"
AR="aarch64-linux-android-ar"
RANLIB="aarch64-linux-android-ranlib"
STRIP="aarch64-linux-android-strip"
ANDROID_CXXFLAGS="-funwind-tables -fexceptions -frtti"
;;
i686|x86)
CC="i686-linux-android$ANDROID_API-clang"
CXX="i686-linux-android$ANDROID_API-clang++"
LD="i686-linux-android-ld"
AS="i686-linux-android-as"
AR="i686-linux-android-ar"
RANLIB="i686-linux-android-ranlib"
STRIP="i686-linux-android-strip"
ANDROID_CXXFLAGS="-mtune=intel -mssse3 -mfpmath=sse -funwind-tables -fexceptions -frtti"
;;
x86_64|x64)
CC="x86_64-linux-android$ANDROID_API-clang"
CXX="x86_64-linux-android$ANDROID_API-clang++"
LD="x86_64-linux-android-ld"
AS="x86_64-linux-android-as"
AR="x86_64-linux-android-ar"
RANLIB="x86_64-linux-android-ranlib"
STRIP="x86_64-linux-android-strip"
ANDROID_CXXFLAGS="-march=x86-64 -msse4.2 -mpopcnt -mtune=intel -funwind-tables -fexceptions -frtti"
;;
*)
echo "ERROR: Unknown architecture $ANDROID_CPU"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
;;
esac
#####################################################################
# GNUmakefile-cross and Autotools expect these to be set.
# They are also used in the tests below.
export IS_ANDROID=1
export CPP CC CXX LD AS AR RANLIB STRIP
export ANDROID_CXXFLAGS ANDROID_API ANDROID_CPU ANDROID_SYSROOT
# Do NOT use ANDROID_SYSROOT_INC or ANDROID_SYSROOT_LD
# https://github.com/android/ndk/issues/894#issuecomment-470837964
#####################################################################
# Error checking
if [ ! -e "$ANDROID_TOOLCHAIN/$CC" ]; then
echo "ERROR: Failed to find Android clang. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$ANDROID_TOOLCHAIN/$CXX" ]; then
echo "ERROR: Failed to find Android clang++. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$ANDROID_TOOLCHAIN/$RANLIB" ]; then
echo "ERROR: Failed to find Android ranlib. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$ANDROID_TOOLCHAIN/$AR" ]; then
echo "ERROR: Failed to find Android ar. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$ANDROID_TOOLCHAIN/$AS" ]; then
echo "ERROR: Failed to find Android as. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$ANDROID_TOOLCHAIN/$LD" ]; then
echo "ERROR: Failed to find Android ld. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#####################################################################
# Add tools to head of path, if not present already
LENGTH=${#ANDROID_TOOLCHAIN}
SUBSTR=${PATH:0:$LENGTH}
if [ "$SUBSTR" != "$ANDROID_TOOLCHAIN" ]; then
export PATH="$ANDROID_TOOLCHAIN:$PATH"
fi
#####################################################################
# Now that we are using cpu-features from Android rather than CPU probing, we
# need to copy cpu-features.h and cpu-features.c from the NDK into our source
# directory and then build it.
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" ]]; then
echo "ERROR: Unable to locate cpu-features.h"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" .
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" ]]; then
echo "ERROR: Unable to locate cpu-features.c"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" .
# Cleanup the sources for the C++ compiler
# https://github.com/weidai11/cryptopp/issues/926
sed -i 's/p = memmem/p = (const char*)memmem/g' cpu-features.c
sed -i 's/p = memmem/p = (const char*)memmem/g' cpu-features.c
sed -i 's/p = memchr/p = (const char*)memchr/g' cpu-features.c
sed -i 's/p = memchr/p = (const char*)memchr/g' cpu-features.c
sed -i 's/q = memmem/q = (const char*)memmem/g' cpu-features.c
sed -i 's/q = memmem/q = (const char*)memmem/g' cpu-features.c
sed -i 's/q = memchr/q = (const char*)memchr/g' cpu-features.c
sed -i 's/q = memchr/q = (const char*)memchr/g' cpu-features.c
sed -i 's/cpuinfo = malloc/cpuinfo = (char*)malloc/g' cpu-features.c
#####################################################################
VERBOSE=${VERBOSE:-1}
if [ "$VERBOSE" -gt 0 ]; then
echo "ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN"
echo "ANDROID_API: $ANDROID_API"
echo "ANDROID_CPU: $ANDROID_CPU"
echo "ANDROID_SYSROOT: $ANDROID_SYSROOT"
echo "ANDROID_CXXFLAGS: $ANDROID_CXXFLAGS"
if [ -e "cpu-features.h" ] && [ -e "cpu-features.c" ]; then
echo "CPU FEATURES: cpu-features.h and cpu-features.c are present"
fi
fi
#####################################################################
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'. You can create a versioned"
echo "shared object using 'HAS_SOLIB_VERSION=1 make -f GNUmakefile-cross'"
echo "*******************************************************************************"
echo
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 0 || return 0
+148
View File
@@ -0,0 +1,148 @@
#!/usr/bin/env bash
# ====================================================================
# Sets the cross compile environment for ARM Embedded
#
# Written by Jeffrey Walton, noloader gmail account
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# This script only supports Ubuntu at the moment. It does not support Fedora.
# See http://www.cryptopp.com/wiki/ARM_Embedded_(Command_Line) for details.
# ====================================================================
# cryptest-embedded.sh may run this script without sourcing.
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
echo "setenv-embedded.sh is usually sourced, but not this time."
fi
# Unset old options
unset IS_CROSS_COMPILE
unset IS_IOS
unset IS_ANDROID
unset IS_ARM_EMBEDDED
if [ -z "${ARM_EMBEDDED_TOOLCHAIN-}" ]; then
ARM_EMBEDDED_TOOLCHAIN="/usr/bin"
fi
if [ ! -d "$ARM_EMBEDDED_TOOLCHAIN" ]; then
echo "ARM_EMBEDDED_TOOLCHAIN is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Fedora
# TOOL_PREFIX="arm-linux-gnu"
# Ubuntu
TOOL_PREFIX="arm-linux-gnueabi"
export CPP="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-cpp"
export CC="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-gcc"
export CXX="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-g++"
export LD="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-ld"
export AR="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-ar"
export AS="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-as"
export RANLIB="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-ranlib"
# export RANLIB="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-gcc-ranlib-4.7"
# Test a few of the tools
if [ ! -e "$CPP" ]; then
echo "ERROR: CPP is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$CC" ]; then
echo "ERROR: CC is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$CXX" ]; then
echo "ERROR: CXX is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$AR" ]; then
echo "ERROR: AR is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$AS" ]; then
echo "ERROR: AS is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$RANLIB" ]; then
echo "ERROR: RANLIB is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$LD" ]; then
echo "ERROR: LD is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# The Crypto++ Makefile uses these to disable host settings like
# IS_LINUX or IS_DARWIN, and incorporate settings for ARM_EMBEDDED
export IS_ARM_EMBEDDED=1
# GNUmakefile-cross uses these to to set CXXFLAGS for ARM_EMBEDDED
if [ -z "$ARM_EMBEDDED_SYSROOT" ]; then
export ARM_EMBEDDED_SYSROOT="/usr/arm-linux-gnueabi"
fi
if [ ! -d "$ARM_EMBEDDED_SYSROOT" ]; then
echo "ERROR: ARM_EMBEDDED_SYSROOT is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Fix C++ header paths for Ubuntu
# ARM_EMBEDDED_TOOLCHAIN_VERSION="4.7.3"
ARM_EMBEDDED_TOOLCHAIN_VERSION="5.4.0"
ARM_EMBEDDED_CXX_HEADERS="$ARM_EMBEDDED_SYSROOT/include/c++/$ARM_EMBEDDED_TOOLCHAIN_VERSION"
if [ ! -d "$ARM_EMBEDDED_CXX_HEADERS" ]; then
echo "ERROR: ARM_EMBEDDED_CXX_HEADERS is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -d "$ARM_EMBEDDED_CXX_HEADERS/arm-linux-gnueabi" ]; then
echo "ERROR: ARM_EMBEDDED_CXX_HEADERS is not valid"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Finally, the flags...
# export ARM_EMBEDDED_FLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -Wl,--fix-cortex-a8 -I$ARM_EMBEDDED_CXX_HEADERS -I$ARM_EMBEDDED_CXX_HEADERS/arm-linux-gnueabi"
# Add additional flags below, like -mcpu=cortex-m3.
if [ -z "$ARM_EMBEDDED_FLAGS" ]; then
export ARM_EMBEDDED_FLAGS="-I$ARM_EMBEDDED_CXX_HEADERS -I$ARM_EMBEDDED_CXX_HEADERS/arm-linux-gnueabi"
fi
# And print stuff to wow the user...
VERBOSE=${VERBOSE:-1}
if [ "$VERBOSE" -gt 0 ]; then
echo "CPP: $CPP"
echo "CXX: $CXX"
echo "AR: $AR"
echo "LD: $LD"
echo "RANLIB: $RANLIB"
echo "ARM_EMBEDDED_TOOLCHAIN: $ARM_EMBEDDED_TOOLCHAIN"
echo "ARM_EMBEDDED_CXX_HEADERS: $ARM_EMBEDDED_CXX_HEADERS"
echo "ARM_EMBEDDED_FLAGS: $ARM_EMBEDDED_FLAGS"
echo "ARM_EMBEDDED_SYSROOT: $ARM_EMBEDDED_SYSROOT"
fi
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'. You can create a versioned"
echo "shared object using 'HAS_SOLIB_VERSION=1 make -f GNUmakefile-cross'"
echo "*******************************************************************************"
echo
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 0 || return 0
+314
View File
@@ -0,0 +1,314 @@
#!/usr/bin/env bash
# ====================================================================
# Sets the cross compile environment for Xcode/iOS
#
# Based upon OpenSSL's setenv-ios.sh by TH, JW, and SM.
# Heavily modified by JWW for Crypto++.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/iOS_(Command_Line) for more details
# ====================================================================
#########################################
##### Some validation #####
#########################################
# In the past we could mostly infer arch or cpu from the SDK (and mostly
# vice-versa). Nowadays we need the user to set it for us because Apple
# platforms have both 32-bit or 64-bit variations.
# cryptest-ios.sh may run this script without sourcing.
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
echo "setenv-ios.sh is usually sourced, but not this time."
fi
# This supports 'source setenv-ios.sh iPhone arm64' and friends
if [[ -z "$IOS_SDK" && -n "$1" ]]; then
printf "Using positional arg, IOS_SDK=%s\n" "$1"
IOS_SDK="$1"
fi
# This supports 'source setenv-ios.sh iPhone arm64' and friends
if [[ -z "$IOS_CPU" && -n "$2" ]]; then
printf "Using positional arg, IOS_CPU=%s\n" "$2"
IOS_CPU="$2"
fi
if [ -z "$IOS_SDK" ]; then
echo "IOS_SDK is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ -z "$IOS_CPU" ]; then
echo "IOS_CPU is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#########################################
##### Clear old options #####
#########################################
unset IS_IOS
unset IS_ANDROID
unset IS_ARM_EMBEDDED
unset IOS_CXXFLAGS
unset IOS_SYSROOT
#########################################
##### Small Fixups, if needed #####
#########################################
if [[ "$IOS_SDK" == "iPhone" ]]; then
IOS_SDK=iPhoneOS
fi
if [[ "$IOS_SDK" == "iPhoneOSSimulator" ]]; then
IOS_SDK=iPhoneSimulator
fi
if [[ "$IOS_SDK" == "TV" || "$IOS_SDK" == "AppleTV" ]]; then
IOS_SDK=AppleTVOS
fi
if [[ "$IOS_SDK" == "Watch" || "$IOS_SDK" == "AppleWatch" ]]; then
IOS_SDK=WatchOS
fi
if [[ "$IOS_CPU" == "aarch64" || "$IOS_CPU" == "arm64"* || "$IOS_CPU" == "armv8"* ]] ; then
IOS_CPU=arm64
fi
########################################
##### Environment #####
########################################
# The flags below were tested with Xcode 8 on Travis. If
# you use downlevel versions of Xcode, then you can push
# xxx-version-min=n lower. For example, Xcode 7 can use
# -miphoneos-version-min=5. However, Xcode 7 lacks
# AppleTVOS and WatchOS support.
# iPhones can be either 32-bit or 64-bit
if [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "armv7"* ]]; then
MIN_VER=-miphoneos-version-min=6
elif [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "arm64" ]]; then
MIN_VER=-miphoneos-version-min=6
# Fixups for convenience
elif [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "i386" ]]; then
IOS_SDK=iPhoneSimulator
# MIN_VER=-miphoneos-version-min=6
MIN_VER=-miphonesimulator-version-min=6
elif [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "x86_64" ]]; then
IOS_SDK=iPhoneSimulator
# MIN_VER=-miphoneos-version-min=6
MIN_VER=-miphonesimulator-version-min=6
# Simulator builds
elif [[ "$IOS_SDK" == "iPhoneSimulator" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-miphonesimulator-version-min=6
elif [[ "$IOS_SDK" == "iPhoneSimulator" && "$IOS_CPU" == "x86_64" ]]; then
MIN_VER=-miphonesimulator-version-min=6
# Apple TV can be 32-bit Intel (1st gen), 32-bit ARM (2nd, 3rd gen) or 64-bit ARM (4th gen)
elif [[ "$IOS_SDK" == "AppleTVOS" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-mappletvos-version-min=6
elif [[ "$IOS_SDK" == "AppleTVOS" && "$IOS_CPU" == "armv7"* ]]; then
MIN_VER=-mappletvos-version-min=6
elif [[ "$IOS_SDK" == "AppleTVOS" && "$IOS_CPU" == "arm64" ]]; then
MIN_VER=-mappletvos-version-min=6
# Simulator builds
elif [[ "$IOS_SDK" == "AppleTVSimulator" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-mappletvsimulator-version-min=6
elif [[ "$IOS_SDK" == "AppleTVSimulator" && "$IOS_CPU" == "x86_64" ]]; then
MIN_VER=-mappletvsimulator-version-min=6
# Watch can be either 32-bit or 64-bit ARM. TODO: figure out which
# -mwatchos-version-min=n is needed for arm64. 9 is not enough.
elif [[ "$IOS_SDK" == "WatchOS" && "$IOS_CPU" == "armv7"* ]]; then
MIN_VER=-mwatchos-version-min=6
elif [[ "$IOS_SDK" == "WatchOS" && "$IOS_CPU" == "arm64" ]]; then
MIN_VER=-mwatchos-version-min=10
# Simulator builds. TODO: figure out which -watchos-version-min=n
# is needed for arm64. 6 compiles and links, but is it correct?
elif [[ "$IOS_SDK" == "WatchSimulator" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-mwatchsimulator-version-min=6
elif [[ "$IOS_SDK" == "WatchSimulator" && "$IOS_CPU" == "x86_64" ]]; then
MIN_VER=-mwatchsimulator-version-min=6
# And the final catch-all
else
echo "IOS_SDK and IOS_CPU are not valid. Please fix them"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#####################################################################
# Xcode 6 and below cannot handle -miphonesimulator-version-min
# Fix it so the simulator will compile as expected. This trick
# may work on other platforms, but it was not tested.
if [ -n "$(command -v xcodebuild 2>/dev/null)" ]; then
# Output of xcodebuild is similar to "Xcode 6.2". The first cut gets
# the dotted decimal value. The second cut gets the major version.
XCODE_VERSION=$(xcodebuild -version 2>/dev/null | head -n 1 | cut -f2 -d" " | cut -f1 -d".")
if [ -z "$XCODE_VERSION" ]; then XCODE_VERSION=100; fi
if [ "$XCODE_VERSION" -le 6 ]; then
MIN_VER="${MIN_VER//iphonesimulator/iphoneos}"
fi
fi
#####################################################################
# Allow a user override? I think we should be doing this. The use case is:
# move /Applications/Xcode somewhere else for a side-by-side installation.
if [ -z "${XCODE_DEVELOPER-}" ]; then
XCODE_DEVELOPER=$(xcode-select -print-path 2>/dev/null)
fi
if [ ! -d "$XCODE_DEVELOPER" ]; then
echo "ERROR: unable to find XCODE_DEVELOPER directory."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# XCODE_DEVELOPER_SDK is the SDK location.
XCODE_DEVELOPER_SDK="$XCODE_DEVELOPER/Platforms/$IOS_SDK.platform"
if [ ! -d "$XCODE_DEVELOPER_SDK" ]; then
echo "ERROR: unable to find XCODE_DEVELOPER_SDK directory."
echo " Is the SDK supported by Xcode and installed?"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# XCODE_TOOLCHAIN is the location of the actual compiler tools.
if [ -d "$XCODE_DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/" ]; then
XCODE_TOOLCHAIN="$XCODE_DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
elif [ -d "$XCODE_DEVELOPER_SDK/Developer/usr/bin/" ]; then
XCODE_TOOLCHAIN="$XCODE_DEVELOPER_SDK/Developer/usr/bin/"
fi
if [ -z "$XCODE_TOOLCHAIN" ] || [ ! -d "$XCODE_TOOLCHAIN" ]; then
echo "ERROR: unable to find Xcode cross-compiler tools."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# XCODE_SDK is the SDK name/version being used - adjust the list as appropriate.
# For example, remove 4.3, 6.2, and 6.1 if they are not installed. We go back to
# the 1.0 SDKs because Apple WatchOS uses low numbers, like 2.0 and 2.1.
XCODE_SDK=""
for i in $(seq -f "%.1f" 30.0 -0.1 1.0)
do
if [ -d "$XCODE_DEVELOPER_SDK/Developer/SDKs/$IOS_SDK$i.sdk" ]; then
XCODE_SDK="$IOS_SDK$i.sdk"
break
fi
done
# Error checking
if [ -z "$XCODE_SDK" ]; then
echo "ERROR: unable to find a SDK."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
IOS_CXXFLAGS="-arch $IOS_CPU $MIN_VER"
# The simulators need to disable ASM. They don't receive arch flags.
# https://github.com/weidai11/cryptopp/issues/635
if [[ "$IOS_SDK" == "iPhoneSimulator" || "$IOS_SDK" == "AppleTVSimulator" || "$IOS_SDK" == "WatchSimulator" ]]; then
IOS_CXXFLAGS="$IOS_CXXFLAGS -DCRYPTOPP_DISABLE_ASM"
fi
echo "Configuring for $IOS_SDK ($IOS_CPU)"
IS_IOS=1
IOS_SYSROOT="$XCODE_DEVELOPER_SDK/Developer/SDKs/$XCODE_SDK"
#####################################################################
CPP=cpp; CC=clang; CXX=clang++; LD=ld
AS=as; AR=libtool; RANLIB=ranlib; STRIP=strip
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$CC" ]; then
echo "ERROR: Failed to find iOS clang. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$CXX" ]; then
echo "ERROR: Failed to find iOS clang++. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$RANLIB" ]; then
echo "ERROR: Failed to find iOS ranlib. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$AR" ]; then
echo "ERROR: Failed to find iOS ar. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$AS" ]; then
echo "ERROR: Failed to find iOS as. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$LD" ]; then
echo "ERROR: Failed to find iOS ld. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#####################################################################
# Add tools to head of path, if not present already
LENGTH=${#XCODE_TOOLCHAIN}
SUBSTR=${PATH:0:$LENGTH}
if [ "$SUBSTR" != "$XCODE_TOOLCHAIN" ]; then
export PATH="$XCODE_TOOLCHAIN:$PATH"
fi
#####################################################################
# GNUmakefile-cross and Autotools expect these to be set.
# They are also used in the tests below.
export IS_IOS=1
export CPP CC CXX LD AS AR RANLIB STRIP
export IOS_CXXFLAGS IOS_SDK IOS_CPU IOS_SYSROOT
#####################################################################
VERBOSE=${VERBOSE:-1}
if [ "$VERBOSE" -gt 0 ]; then
echo "XCODE_TOOLCHAIN: $XCODE_TOOLCHAIN"
echo "IOS_SDK: $IOS_SDK"
echo "IOS_CPU: $IOS_CPU"
echo "IOS_SYSROOT: $IOS_SYSROOT"
echo "IOS_CXXFLAGS: $IOS_CXXFLAGS"
fi
#####################################################################
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'. You can create a versioned"
echo "shared object using 'HAS_SOLIB_VERSION=1 make -f GNUmakefile-cross'"
echo "*******************************************************************************"
echo
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 0 || return 0
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Written and placed in public domain by Jeffrey Walton
#
# This script fetches TweetNaCl from Bernstein's site, and then
# prepares it for use in Crypto++ by applying tweetnacl.patch.
# The script should be run from the Crypto++ root directory on a
# Unix machine because of the use of Unix tools like wget.
curl https://tweetnacl.cr.yp.to/20140427/tweetnacl.h > tweetnacl.h
curl https://tweetnacl.cr.yp.to/20140427/tweetnacl.c > tweetnacl.c
# Fix whitespace
sed -e 's/[[:space:]]*$//' tweetnacl.h > tweetnacl.h.fixed
mv tweetnacl.h.fixed tweetnacl.h
sed -e 's/[[:space:]]*$//' tweetnacl.c > tweetnacl.c.fixed
mv tweetnacl.c.fixed tweetnacl.c
if [[ -e "TestScripts/tweetnacl.patch" ]]; then
cp "TestScripts/tweetnacl.patch" .
fi
if [[ ! -e "tweetnacl.patch" ]]; then
echo "Cannot find tweetnacl.patch. Please make sure it exists in the root directory."
echo "It can be created with 'diff -u tweetnacl.c tweetnacl.cpp > tweetnacl.patch'"
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
fi
# Normalize line endings
dos2unix tweetnacl.h tweetnacl.cpp tweetnacl.patch
# Apply patch
patch --unified --binary -p0 < tweetnacl.patch
mv tweetnacl.c tweetnacl.cpp
# Place things where they belong in source control
cp tweetnacl.sh TestScripts/
cp tweetnacl.patch TestScripts/
# Fix whitespace
sed -e 's/[[:space:]]*$//' tweetnacl.h > tweetnacl.h.fixed
mv tweetnacl.h.fixed tweetnacl.h
sed -e 's/[[:space:]]*$//' tweetnacl.cpp > tweetnacl.cpp.fixed
mv tweetnacl.cpp.fixed tweetnacl.cpp
# Convert to MS DOS for source control
unix2dos tweetnacl.h tweetnacl.cpp