11
11
# Maarten Billemont
12
12
#
13
13
cd " ${BASH_SOURCE%/* } "
14
+ shopt -s extglob
14
15
set -e
15
16
16
17
# optional features.
@@ -26,55 +27,105 @@ targets=(
26
27
27
28
# ## DEPENDENCIES
28
29
29
- if ! [[ -e lib/scrypt/scrypt-scryptenc.o ]]; then
30
- # libscrypt not built.
31
- pushd lib/scrypt
32
- if [[ ! -e configure ]]; then
33
- # libscrypt needs configure.
34
- if [[ ! -e configure.ac ]]; then
35
- # libscrypt needs sources.
36
- source .source
37
- if hash git-svn 2> /dev/null; then
38
- echo
39
- echo " Fetching libscrypt using git-svn..."
40
- git-svn clone --prefix=origin/ --stdlayout " $svn " .
41
- printf ' %s' " $( git describe --always) " > scrypt-version
42
- elif hash svn 2> /dev/null; then
43
- echo
44
- echo " Fetching libscrypt using svn..."
45
- svn checkout http://scrypt.googlecode.com/svn/trunk/ .
46
- printf ' r%s' " $( svn info | awk ' /^Revision:/{ print $2 }' ) " > scrypt-version
47
- else
48
- echo >&2 " error: Missing git-svn or svn."
49
- echo >&2 " error: Please install either or manually check out the sources"
50
- echo >&2 " error: from: $home "
51
- echo >&2 " error: into: $PWD "
52
- exit 1
30
+ fetch () {
31
+ if hash wget 2> /dev/null; then
32
+ wget -O " ${1##*/ } " " $1 "
33
+ elif hash curl 2> /dev/null; then
34
+ curl " $1 " > " ${1##*/ } "
35
+ fi
36
+ }
37
+ fetchSource () (
38
+ echo
39
+ echo " Fetching dependency ${PWD##*/ } ..."
40
+ source .source
41
+
42
+ if [[ $git ]] && hash git 2> /dev/null; then
43
+ echo
44
+ echo " Fetching ${PWD##*/ } using git..."
45
+ git-svn clone --prefix=origin/ --stdlayout " $svn " .
46
+ printf ' %s' " $( git describe --always) " > " ${PWD##*/ } -version"
47
+ return
48
+
49
+ elif [[ $svn ]] && hash git-svn 2> /dev/null; then
50
+ echo
51
+ echo " Fetching ${PWD##*/ } using git-svn..."
52
+ git-svn clone --prefix=origin/ --stdlayout " $svn " .
53
+ printf ' %s' " $( git describe --always) " > " ${PWD##*/ } -version"
54
+ return
55
+
56
+ elif [[ $svn ]] && hash svn 2> /dev/null; then
57
+ echo
58
+ echo " Fetching ${PWD##*/ } using svn..."
59
+ svn checkout " $svn /trunk" .
60
+ printf ' r%s' " $( svn info | awk ' /^Revision:/{ print $2 }' ) " > " ${PWD##*/ } -version"
61
+ return
62
+
63
+ elif [[ $pkg ]]; then
64
+ set -x
65
+ fetch " $pkg "
66
+ if [[ $pkg = * .tar.gz || $pkg = * .tgz ]]; then
67
+ tar -xvzf " ${pkg##*/ } "
68
+ files=(! (" ${pkg##*/ } " ))
69
+ if [[ -d $files ]] && (( ${# files[@]} == 1 )) ; then
70
+ mv " $files " /* .
71
+ rmdir " $files "
53
72
fi
54
73
fi
74
+ return
55
75
56
- # Sources available.
57
- echo
58
- echo " Generating libscrypt's build scripts..."
59
- aclocal
60
- autoheader
61
- autoconf
62
- mkdir -p config.aux
63
- automake --add-missing
64
76
fi
65
-
66
- # configure available.
77
+
78
+ echo >&2 " error: Missing git-svn or svn."
79
+ echo >&2 " error: Please install either or manually check out the sources"
80
+ echo >&2 " error: from: $home "
81
+ echo >&2 " error: into: $PWD "
82
+ exit 1
83
+ )
84
+ depend () {
85
+
67
86
echo
68
- echo " Building libscrypt..."
69
- ./configure
70
- make
87
+ echo " Checking dependency $1 ..."
88
+ objects=( " lib/$1 " /* .o )
89
+ [[ -e $objects ]] && return
90
+
91
+ pushd " lib/$1 "
92
+ files=( * )
93
+ [[ -e $files ]] || fetchSource
71
94
95
+ echo
96
+ echo " Configuring dependency $1 ..."
97
+ if [[ -e configure.ac ]]; then
98
+ if [[ ! -e configure ]]; then
99
+ # create configure using autotools.
100
+ aclocal
101
+ autoheader
102
+ autoconf
103
+ mkdir -p config.aux
104
+ automake --add-missing
105
+ fi
106
+ fi
107
+
108
+ if [[ -e configure ]]; then
109
+ ./configure
110
+ fi
111
+
112
+ echo
113
+ echo " Building dependency $1 ..."
114
+ if [[ -e Makefile ]]; then
115
+ make
116
+ else
117
+ echo >&2 " error: Don't know how to build: $1 "
118
+ exit 1
119
+ fi
72
120
popd
73
- fi
121
+ }
74
122
75
123
76
124
# ## MPW
77
125
mpw () {
126
+ depend scrypt
127
+
128
+ echo " Building target: $target ..."
78
129
CFLAGS=(
79
130
# include paths
80
131
-I" lib/scrypt/lib" -I" lib/scrypt/libcperciva"
@@ -101,6 +152,10 @@ mpw() {
101
152
102
153
# ## MPW-BENCH
103
154
mpw-bench () {
155
+ depend scrypt
156
+ depend bcrypt
157
+
158
+ echo " Building target: $target ..."
104
159
CFLAGS=(
105
160
# include paths
106
161
-I" lib/scrypt/lib" -I" lib/scrypt/libcperciva"
@@ -144,6 +199,5 @@ cc() {
144
199
145
200
for target in " ${targets[@]} " ; do
146
201
echo
147
- echo " Building target: $target ..."
148
202
" $target " " $@ "
149
203
done
0 commit comments