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. }
fetchSource() (
echo
echo "Fetching dependency ${PWD##*/}..."
source .source source .source
if hash git-svn 2>/dev/null; then
if [[ $git ]] && hash git 2>/dev/null; then
echo echo
echo "Fetching libscrypt using git-svn..." echo "Fetching ${PWD##*/} using git..."
git-svn clone --prefix=origin/ --stdlayout "$svn" . git-svn clone --prefix=origin/ --stdlayout "$svn" .
printf '%s' "$(git describe --always)" > scrypt-version printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
elif hash svn 2>/dev/null; then return
elif [[ $svn ]] && hash git-svn 2>/dev/null; then
echo echo
echo "Fetching libscrypt using svn..." echo "Fetching ${PWD##*/} using git-svn..."
svn checkout http://scrypt.googlecode.com/svn/trunk/ . git-svn clone --prefix=origin/ --stdlayout "$svn" .
printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > scrypt-version printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
else 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
return
fi
echo >&2 "error: Missing git-svn or svn." echo >&2 "error: Missing git-svn or svn."
echo >&2 "error: Please install either or manually check out the sources" echo >&2 "error: Please install either or manually check out the sources"
echo >&2 "error: from: $home" echo >&2 "error: from: $home"
echo >&2 "error: into: $PWD" echo >&2 "error: into: $PWD"
exit 1 exit 1
fi )
fi depend() {
# Sources available.
echo echo
echo "Generating libscrypt's build scripts..." 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 aclocal
autoheader autoheader
autoconf autoconf
mkdir -p config.aux mkdir -p config.aux
automake --add-missing automake --add-missing
fi fi
fi
# configure available. if [[ -e configure ]]; then
echo
echo "Building libscrypt..."
./configure ./configure
make 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