ext-cryptopp/TestScripts/cryptest-cmake.sh

77 lines
1.3 KiB
Bash
Raw Normal View History

2018-06-29 19:28:16 -04:00
#!/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
2018-09-10 09:00:25 -04:00
# Fixup for Solaris and BSDs
if [[ ! -z $(command -v gmake) ]]; then
MAKE=gmake
else
MAKE=make
2018-09-10 09:00:25 -04:00
fi
2018-11-18 18:49:16 -05:00
# Fixup for AIX
if [[ -z "$CMAKE" ]]; then
CMAKE=cmake
fi
2019-10-14 22:20:47 -04:00
#############################################################################
2018-06-29 19:28:16 -04:00
2019-10-14 22:20:47 -04:00
files=(CMakeLists.txt cryptopp-config.cmake)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! wget -O "$file" -q --no-check-certificate "https://raw.githubusercontent.com/noloader/cryptopp-autotools/master/$file"; then
echo "$file download failed"
exit 1
fi
done
2018-06-29 19:28:16 -04:00
rm -rf "$PWD_DIR/cmake_build"
mkdir -p "$PWD_DIR/cmake_build"
cd "$PWD_DIR/cmake_build"
2018-06-29 19:28:16 -04:00
2019-10-14 22:20:47 -04:00
#############################################################################
2018-10-29 04:58:32 -04:00
if [[ ! -z "$CXX" ]];
then
2018-11-18 18:54:57 -05:00
if ! CXX="$CXX" "$CMAKE" -DCMAKE_CXX_COMPILER="$CXX" ../; then
2018-10-29 04:58:32 -04:00
echo "cmake failed"
2019-10-14 22:20:47 -04:00
exit 1
2018-10-29 04:58:32 -04:00
fi
else
2018-11-18 18:54:57 -05:00
if ! "$CMAKE" ../; then
2018-10-29 04:58:32 -04:00
echo "cmake failed"
2019-10-14 22:20:47 -04:00
exit 1
2018-10-29 04:58:32 -04:00
fi
2018-06-29 19:28:16 -04:00
fi
2018-09-10 09:00:25 -04:00
"$MAKE" clean 2>/dev/null
2018-09-10 09:00:25 -04:00
if ! "$MAKE" -j2 -f Makefile VERBOSE=1; then
2018-06-29 19:28:16 -04:00
echo "make failed"
2019-10-14 22:20:47 -04:00
exit 1
2018-06-29 19:28:16 -04:00
fi
if ! ./cryptest.exe v; then
echo "cryptest.exe v failed"
2019-10-14 22:20:47 -04:00
exit 1
2018-06-29 19:28:16 -04:00
fi
if ! ./cryptest.exe tv all; then
echo "cryptest.exe v failed"
2019-10-14 22:20:47 -04:00
exit 1
2018-06-29 19:28:16 -04:00
fi
# Return success
2019-10-14 22:20:47 -04:00
exit 0