2
0

Add bcrypt dependency and ability to compile arbitrary dependencies in C build script.

This commit is contained in:
Maarten Billemont 2014-10-15 22:17:49 -04:00
parent 7736788920
commit f0b659a0c7
3 changed files with 97 additions and 40 deletions

1
.gitignore vendored
View File

@ -34,5 +34,6 @@ MasterPassword/Java/**/target
# C # C
MasterPassword/C/*.o MasterPassword/C/*.o
MasterPassword/C/mpw MasterPassword/C/mpw
MasterPassword/C/mpw-bench
MasterPassword/C/lib/*/* MasterPassword/C/lib/*/*
!MasterPassword/C/lib/*/.source !MasterPassword/C/lib/*/.source

View File

@ -11,6 +11,7 @@
# Maarten Billemont # Maarten Billemont
# #
cd "${BASH_SOURCE%/*}" cd "${BASH_SOURCE%/*}"
shopt -s extglob
set -e set -e
# optional features. # optional features.
@ -26,55 +27,105 @@ targets=(
### DEPENDENCIES ### DEPENDENCIES
if ! [[ -e lib/scrypt/scrypt-scryptenc.o ]]; then fetch() {
# libscrypt not built. if hash wget 2>/dev/null; then
pushd lib/scrypt wget -O "${1##*/}" "$1"
if [[ ! -e configure ]]; then elif hash curl 2>/dev/null; then
# libscrypt needs configure. curl "$1" > "${1##*/}"
if [[ ! -e configure.ac ]]; then fi
# libscrypt needs sources. }
source .source fetchSource() (
if hash git-svn 2>/dev/null; then echo
echo echo "Fetching dependency ${PWD##*/}..."
echo "Fetching libscrypt using git-svn..." source .source
git-svn clone --prefix=origin/ --stdlayout "$svn" .
printf '%s' "$(git describe --always)" > scrypt-version if [[ $git ]] && hash git 2>/dev/null; then
elif hash svn 2>/dev/null; then echo
echo echo "Fetching ${PWD##*/} using git..."
echo "Fetching libscrypt using svn..." git-svn clone --prefix=origin/ --stdlayout "$svn" .
svn checkout http://scrypt.googlecode.com/svn/trunk/ . printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > scrypt-version return
else
echo >&2 "error: Missing git-svn or svn." elif [[ $svn ]] && hash git-svn 2>/dev/null; then
echo >&2 "error: Please install either or manually check out the sources" echo
echo >&2 "error: from: $home" echo "Fetching ${PWD##*/} using git-svn..."
echo >&2 "error: into: $PWD" git-svn clone --prefix=origin/ --stdlayout "$svn" .
exit 1 printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
return
elif [[ $svn ]] && hash svn 2>/dev/null; then
echo
echo "Fetching ${PWD##*/} using svn..."
svn checkout "$svn/trunk" .
printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > "${PWD##*/}-version"
return
elif [[ $pkg ]]; then
set -x
fetch "$pkg"
if [[ $pkg = *.tar.gz || $pkg = *.tgz ]]; then
tar -xvzf "${pkg##*/}"
files=(!("${pkg##*/}"))
if [[ -d $files ]] && (( ${#files[@]} == 1 )); then
mv "$files"/* .
rmdir "$files"
fi fi
fi fi
return
# Sources available.
echo
echo "Generating libscrypt's build scripts..."
aclocal
autoheader
autoconf
mkdir -p config.aux
automake --add-missing
fi fi
# configure available.
echo
echo "Building libscrypt..."
./configure
make
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
)
depend() {
echo
echo "Checking dependency $1..."
objects=( "lib/$1"/*.o )
[[ -e $objects ]] && return
pushd "lib/$1"
files=( * )
[[ -e $files ]] || fetchSource
echo
echo "Configuring dependency $1..."
if [[ -e configure.ac ]]; then
if [[ ! -e configure ]]; then
# create configure using autotools.
aclocal
autoheader
autoconf
mkdir -p config.aux
automake --add-missing
fi
fi
if [[ -e configure ]]; then
./configure
fi
echo
echo "Building dependency $1..."
if [[ -e Makefile ]]; then
make
else
echo >&2 "error: Don't know how to build: $1"
exit 1
fi
popd popd
fi }
### MPW ### MPW
mpw() { mpw() {
depend scrypt
echo "Building target: $target..."
CFLAGS=( CFLAGS=(
# include paths # include paths
-I"lib/scrypt/lib" -I"lib/scrypt/libcperciva" -I"lib/scrypt/lib" -I"lib/scrypt/libcperciva"
@ -101,6 +152,10 @@ mpw() {
### MPW-BENCH ### MPW-BENCH
mpw-bench() { mpw-bench() {
depend scrypt
depend bcrypt
echo "Building target: $target..."
CFLAGS=( CFLAGS=(
# include paths # include paths
-I"lib/scrypt/lib" -I"lib/scrypt/libcperciva" -I"lib/scrypt/lib" -I"lib/scrypt/libcperciva"
@ -144,6 +199,5 @@ cc() {
for target in "${targets[@]}"; do for target in "${targets[@]}"; do
echo echo
echo "Building target: $target..."
"$target" "$@" "$target" "$@"
done done

View File

@ -0,0 +1,2 @@
home=http://www.openwall.com/crypt/
pkg=http://www.openwall.com/crypt/crypt_blowfish-1.3.tar.gz