ext-cryptopp/TestScripts/cryptest-autotools.sh

176 lines
4.3 KiB
Bash
Raw Normal View History

2018-06-29 21:04:22 +00:00
#!/usr/bin/env bash
2018-09-10 13:00:25 +00:00
PWD_DIR=$(pwd)
function cleanup {
2019-07-04 20:06:51 +00:00
cd "$PWD_DIR"
2018-09-10 13:00:25 +00:00
}
trap cleanup EXIT
2019-05-23 01:03:19 +00:00
#############################################################################
GREP=grep
SED=sed
AWK=awk
MAKE=make
# Fixup, Solaris and friends
2020-07-09 23:50:38 +00:00
if [[ -d /usr/xpg4/bin ]]; then
SED=/usr/xpg4/bin/sed
AWK=/usr/xpg4/bin/awk
GREP=/usr/xpg4/bin/grep
2020-07-09 23:50:38 +00:00
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"
2020-07-09 23:50:38 +00:00
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
2020-07-09 23:50:38 +00:00
if [[ ! -z $(command -v gmake 2>/dev/null) ]]; then
MAKE=gmake
else
MAKE=make
fi
2018-08-03 03:21:59 +00:00
# Fixup for missing libtool
2020-07-09 23:50:38 +00:00
if [[ ! -z $(command -v glibtoolize 2>/dev/null) ]]; then
2020-07-07 20:08:14 +00:00
export LIBTOOLIZE=$(command -v glibtoolize)
2020-07-09 23:50:38 +00:00
elif [[ ! -z $(command -v libtoolize 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v libtoolize)
elif [[ ! -z $(command -v glibtool 2>/dev/null) ]]; then
2020-07-07 20:08:14 +00:00
export LIBTOOLIZE=$(command -v glibtool)
2020-07-09 23:50:38 +00:00
elif [[ ! -z $(command -v libtool 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v libtool)
2018-08-03 03:21:59 +00:00
fi
2019-05-23 01:03:19 +00:00
#############################################################################
2020-07-09 23:50:38 +00:00
if [[ -z $(command -v autoupdate 2>/dev/null) ]]; then
2018-08-01 17:57:35 +00:00
echo "Cannot find autoupdate. Things may fail."
fi
2018-08-03 03:21:59 +00:00
if [[ -z "$LIBTOOLIZE" ]]; then
2018-08-01 17:57:35 +00:00
echo "Cannot find libtoolize. Things may fail."
fi
2020-07-09 23:50:38 +00:00
if [[ -z $(command -v automake 2>/dev/null) ]]; then
echo "Cannot find automake. Things may fail."
fi
2020-07-09 23:50:38 +00:00
if [[ -z $(command -v autoreconf 2>/dev/null) ]]; then
2018-08-01 17:57:35 +00:00
echo "Cannot find autoreconf. Things may fail."
fi
2020-07-09 23:50:38 +00:00
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"
2019-05-23 01:03:19 +00:00
if ! autoupdate &>/dev/null; then
echo "autoupdate failed."
2019-10-15 02:20:47 +00:00
exit 1
fi
2018-08-03 03:21:59 +00:00
# Run autoreconf twice on failure. Also see
# https://github.com/tracebox/tracebox/issues/57
echo "Running autoreconf"
2019-05-23 01:03:19 +00:00
if ! autoreconf --force --install &>/dev/null; then
2018-08-03 03:21:59 +00:00
echo "autoreconf failed, running again."
2019-05-23 01:03:19 +00:00
if ! autoreconf --force --install; then
2018-08-01 17:57:35 +00:00
echo "autoreconf failed, again."
2019-10-15 02:20:47 +00:00
exit 1
fi
2018-06-29 21:04:22 +00:00
fi
2019-05-23 01:03:19 +00:00
#############################################################################
# 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'
2019-05-20 07:48:02 +00:00
# Solaris removes +w, can't overwrite
2020-07-07 19:54:56 +00:00
chmod +w build-aux/config.sub
mv config.sub.new build-aux/config.sub
chmod +x build-aux/config.sub
2020-07-09 23:50:38 +00:00
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
2019-07-04 20:06:51 +00:00
echo "Removing config.sub quarantine"
2020-07-07 19:54:56 +00:00
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'
2019-05-20 07:48:02 +00:00
# Solaris removes +w, can't overwrite
2020-07-07 19:54:56 +00:00
chmod +w build-aux/config.guess
mv config.guess.new build-aux/config.guess
chmod +x build-aux/config.guess
2020-07-09 23:50:38 +00:00
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
2019-07-04 20:06:51 +00:00
echo "Removing config.guess quarantine"
2020-07-07 19:54:56 +00:00
xattr -d "com.apple.quarantine" build-aux/config.guess &>/dev/null
fi
2019-05-23 01:03:19 +00:00
#############################################################################
echo "Running configure"
echo ""
2018-06-29 21:04:22 +00:00
if ! ./configure; then
2018-08-01 17:57:35 +00:00
echo "configure failed."
2019-10-15 02:20:47 +00:00
exit 1
2018-06-29 21:04:22 +00:00
fi
2019-10-15 02:34:32 +00:00
#############################################################################
echo ""
2019-10-15 02:34:32 +00:00
echo "Building test artifacts"
echo ""
2019-05-23 01:03:19 +00:00
"$MAKE" clean &>/dev/null
if ! "$MAKE" -j2 -f Makefile; then
2018-08-01 17:57:35 +00:00
echo "make failed."
2019-10-15 02:20:47 +00:00
exit 1
2018-06-29 21:04:22 +00:00
fi
2020-07-10 04:01:12 +00:00
#############################################################################
echo ""
echo "Testing library"
echo ""
if ! ./cryptest v; then
echo "cryptest v failed."
2019-10-15 02:20:47 +00:00
exit 1
2018-06-29 21:04:22 +00:00
fi
if ! ./cryptest tv all; then
echo "cryptest tv all failed."
2019-10-15 02:20:47 +00:00
exit 1
2018-06-29 21:04:22 +00:00
fi
# Return success
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0