2014-06-10 20:25:35 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-10-15 18:00:44 +00:00
|
|
|
#
|
|
|
|
# TROUBLESHOOTING
|
|
|
|
# - See the 'options' array. Comment/uncomment lines as you see fit.
|
|
|
|
# - If you see 'undefined reference to `clock_gettime'', try ./build -lrt instead.
|
|
|
|
#
|
|
|
|
# BUGS
|
|
|
|
# masterpassword@lyndir.com
|
|
|
|
#
|
|
|
|
# AUTHOR
|
|
|
|
# Maarten Billemont
|
|
|
|
#
|
2014-10-15 12:44:41 +00:00
|
|
|
cd "${BASH_SOURCE%/*}"
|
|
|
|
set -e
|
2014-06-07 05:27:18 +00:00
|
|
|
|
2014-10-15 20:26:09 +00:00
|
|
|
# optional features.
|
2014-10-15 18:00:44 +00:00
|
|
|
options=(
|
2014-10-15 20:27:33 +00:00
|
|
|
#-DDEBUG # Turn on debugging verbosity.
|
2014-10-15 18:00:44 +00:00
|
|
|
)
|
2014-10-15 20:26:09 +00:00
|
|
|
# available targets.
|
|
|
|
targets=(
|
|
|
|
mpw # C CLI version of Master Password.
|
|
|
|
mpw-bench # C CLI Master Password benchmark utility.
|
|
|
|
)
|
2014-10-15 18:00:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
### DEPENDENCIES
|
|
|
|
|
2014-10-15 12:44:41 +00:00
|
|
|
if ! [[ -e lib/scrypt/scrypt-scryptenc.o ]]; then
|
|
|
|
# libscrypt not built.
|
|
|
|
pushd lib/scrypt
|
|
|
|
if [[ ! -e configure ]]; then
|
|
|
|
# libscrypt needs configure.
|
|
|
|
if [[ ! -e configure.ac ]]; then
|
|
|
|
# libscrypt needs sources.
|
|
|
|
source .source
|
2014-10-15 19:32:10 +00:00
|
|
|
if hash git-svn 2>/dev/null; then
|
2014-10-15 12:44:41 +00:00
|
|
|
echo
|
|
|
|
echo "Fetching libscrypt using git-svn..."
|
|
|
|
git-svn clone --prefix=origin/ --stdlayout "$svn" .
|
|
|
|
printf '%s' "$(git describe --always)" > scrypt-version
|
2014-10-15 19:32:10 +00:00
|
|
|
elif hash svn 2>/dev/null; then
|
2014-10-15 12:44:41 +00:00
|
|
|
echo
|
|
|
|
echo "Fetching libscrypt using svn..."
|
|
|
|
svn checkout http://scrypt.googlecode.com/svn/trunk/ .
|
|
|
|
printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > scrypt-version
|
|
|
|
else
|
|
|
|
echo >&2 "error: Missing git-svn or svn."
|
|
|
|
echo >&2 "error: Please install either or manually check out the sources"
|
|
|
|
echo >&2 "error: from: $home"
|
|
|
|
echo >&2 "error: into: $PWD"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2014-06-07 19:51:11 +00:00
|
|
|
|
2014-10-15 12:44:41 +00:00
|
|
|
# Sources available.
|
|
|
|
echo
|
|
|
|
echo "Generating libscrypt's build scripts..."
|
|
|
|
aclocal
|
|
|
|
autoheader
|
|
|
|
autoconf
|
|
|
|
mkdir -p config.aux
|
|
|
|
automake --add-missing
|
|
|
|
fi
|
|
|
|
|
|
|
|
# configure available.
|
|
|
|
echo
|
|
|
|
echo "Building libscrypt..."
|
|
|
|
./configure
|
|
|
|
make
|
2014-06-07 19:51:11 +00:00
|
|
|
|
2014-10-15 12:44:41 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2014-10-15 20:26:09 +00:00
|
|
|
|
|
|
|
### MPW
|
|
|
|
mpw() {
|
|
|
|
CFLAGS=(
|
|
|
|
# include paths
|
|
|
|
-I"lib/scrypt/lib" -I"lib/scrypt/libcperciva"
|
|
|
|
)
|
|
|
|
LDFLAGS=(
|
|
|
|
# library paths
|
|
|
|
-L"." -L"lib/scrypt"
|
|
|
|
# link libraries
|
|
|
|
-l"crypto"
|
|
|
|
# scrypt
|
|
|
|
"lib/scrypt/scrypt-crypto_aesctr.o"
|
|
|
|
"lib/scrypt/scrypt-sha256.o"
|
|
|
|
"lib/scrypt/scrypt-crypto_scrypt-nosse.o"
|
|
|
|
"lib/scrypt/scrypt-memlimit.o"
|
|
|
|
"lib/scrypt/scrypt-scryptenc_cpuperf.o"
|
|
|
|
"lib/scrypt/scrypt-scryptenc.o"
|
|
|
|
)
|
|
|
|
|
|
|
|
cc "${CFLAGS[@]}" "${options[@]}" -c types.c -o types.o "$@"
|
|
|
|
cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "${options[@]}" "types.o" mpw.c -o mpw "$@"
|
|
|
|
echo "done! Now run ./install or use ./mpw"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
### MPW-BENCH
|
|
|
|
mpw-bench() {
|
|
|
|
CFLAGS=(
|
|
|
|
# include paths
|
|
|
|
-I"lib/scrypt/lib" -I"lib/scrypt/libcperciva"
|
|
|
|
-I"lib/bcrypt"
|
|
|
|
)
|
|
|
|
LDFLAGS=(
|
|
|
|
# library paths
|
|
|
|
-L"." -L"lib/scrypt"
|
|
|
|
-L"lib/bcrypt"
|
|
|
|
# libraries
|
|
|
|
-l"crypto"
|
|
|
|
# scrypt
|
|
|
|
"lib/scrypt/scrypt-crypto_aesctr.o"
|
|
|
|
"lib/scrypt/scrypt-sha256.o"
|
|
|
|
"lib/scrypt/scrypt-crypto_scrypt-nosse.o"
|
|
|
|
"lib/scrypt/scrypt-memlimit.o"
|
|
|
|
"lib/scrypt/scrypt-scryptenc_cpuperf.o"
|
|
|
|
"lib/scrypt/scrypt-scryptenc.o"
|
|
|
|
# bcrypt
|
|
|
|
"lib/bcrypt/crypt_blowfish.o"
|
|
|
|
"lib/bcrypt/crypt_gensalt.o"
|
|
|
|
"lib/bcrypt/wrapper.o"
|
|
|
|
"lib/bcrypt/x86.o"
|
|
|
|
)
|
|
|
|
|
|
|
|
cc "${CFLAGS[@]}" "${options[@]}" -c types.c -o types.o "$@"
|
|
|
|
cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "${options[@]}" "types.o" mpw-bench.c -o mpw-bench "$@"
|
|
|
|
echo "done! Now use ./mpw-bench"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
### TARGETS
|
2014-10-15 12:44:41 +00:00
|
|
|
|
2014-10-15 18:00:44 +00:00
|
|
|
cc() {
|
2014-10-15 19:32:10 +00:00
|
|
|
if hash llvm-gcc 2>/dev/null; then
|
2014-10-15 20:03:46 +00:00
|
|
|
llvm-gcc "$@"
|
2014-10-15 18:00:44 +00:00
|
|
|
else
|
2014-10-15 19:32:10 +00:00
|
|
|
gcc -std=gnu99 "$@"
|
2014-10-15 18:00:44 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-10-15 20:26:09 +00:00
|
|
|
for target in "${targets[@]}"; do
|
|
|
|
echo
|
|
|
|
echo "Building target: $target..."
|
|
|
|
"$target" "$@"
|
|
|
|
done
|