2
0
MasterPassword/MasterPassword/C/build

150 lines
3.8 KiB
Plaintext
Raw Normal View History

2014-06-10 20:25:35 +00:00
#!/usr/bin/env bash
#
# 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
#
cd "${BASH_SOURCE%/*}"
set -e
2014-10-15 20:26:09 +00:00
# optional features.
options=(
2014-10-15 20:27:33 +00:00
#-DDEBUG # Turn on debugging verbosity.
)
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.
)
### DEPENDENCIES
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
if hash git-svn 2>/dev/null; then
echo
echo "Fetching libscrypt using git-svn..."
git-svn clone --prefix=origin/ --stdlayout "$svn" .
printf '%s' "$(git describe --always)" > scrypt-version
elif hash svn 2>/dev/null; then
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
# 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
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
cc() {
if hash llvm-gcc 2>/dev/null; then
llvm-gcc "$@"
else
gcc -std=gnu99 "$@"
fi
}
2014-10-15 20:26:09 +00:00
for target in "${targets[@]}"; do
echo
echo "Building target: $target..."
"$target" "$@"
done