forked from andyneff/cuda-waste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebash.sh
335 lines (294 loc) · 6.95 KB
/
rebash.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#
echo "Setting and checking the environment for building CUDA Waste."
echo "You can make this faster by setting up your environment manually."
echo
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
#############################################################
#
# Set up variables for JAVA/JAVAC.
#
#############################################################
echo "Looking for javac.exe"
javac &> /dev/null
if [ "$?" -gt 1 ]
then
echo javac.exe not found in path.
echo -n "Searching ... "
# well, let's try to find it.
p=`find "/cygdrive/c/Program Files/Java" -iname javac.exe 2> /dev/null`
x=""
for p2 in $p
do
if [ -e "$p2" ]
then
x="$p2"
fi
done
if [ "$x" == "" ]
then
echo No javac.exe found. Please install JDK SE from Oracle.com.
exit 1
fi
# move up the tree to export the path.
y=${x%%/javac.exe}
echo "found in "$y
export PATH="$y:$PATH"
export CLASSPATH=".;"`cygpath --dos $x`
else
echo javac.exe found.
fi
echo
#############################################################
#
# Set up SVN on path.
#
#############################################################
echo "Looking for svn.exe"
svn &> /dev/null
if [ "$?" -gt 1 ]
then
echo svn.exe not found in path.
echo -n "Searching ... "
# well, let's try to find it.
p=`find "/cygdrive/c/" -iname svn.exe 2> /dev/null`
x=""
for p2 in $p
do
if [ -e "$p2" ]
then
x="$p2"
fi
done
if [ "$x" == "" ]
then
echo 'No svn.exe found. Please install SVN from TortoiseSVN.net (preferred) or via Cygwin setup.'
exit 1
fi
# move up the tree to export the path.
y=${x%%/svn.exe}
echo "found in "$y
export PATH="$y:$PATH"
else
echo svn.exe found.
fi
echo
#############################################################
#
# Set up variables for CUDA Toolkit base, if not already set.
#
#############################################################
echo "Checking whether CUDA_PATH is set."
if [ "$CUDA_PATH" == "" ]
then
echo CUDA_PATH not set.
echo -n "Searching for NVIDIA GPU Computing Toolkit (CUDA) ..."
# well, let's try to find it.
p=`find "/cygdrive/c/" -name 'NVIDIA GPU Computing Toolkit' 2> /dev/null`
# now look for directory below that "v...", picking last one listed.
x=""
for p2 in $p/CUDA/v*
do
echo p2 = $p2
if [ -d "$p2" ]
then
x="$p2"
fi
done
if [ "$x" == "" ]
then
echo "No NVIDIA CUDA GPU Toolkit found. Please install the toolkit (http://www.nvidia.com/object/cuda_home_new.html)."
exit 1
fi
echo " found in "$x
export CUDA_PATH="$x"
else
echo CUDA_PATH is set to "$CUDA_PATH"
fi
export CUDA_PATH=`cygpath --dos $CUDA_PATH`
# I noticed that CUDA 5.5 doesn't seem to set the CUDA environmental
# variables correctly. They're assumed to contain a trailing slash.
# check that CUDA_PATH ends in a slash.
y=${CUDA_PATH##*\\}
if [ "$y" != "" ]
then
echo CUDA_PATH does not end in a slash. Fixing.
export CUDA_PATH="$CUDA_PATH\\"
fi
# check CUDA_PATH.
if [ -e "$CUDA_PATH" -a -d "$CUDA_PATH" ]
then
echo CUDA_PATH is valid.
else
echo CUDA_PATH is set, but does not look to be a directory that exists.
exit 1
fi
export CUDA_LIB_PATH="${CUDA_PATH%\\}\\lib\\"
export CUDA_INC_PATH="${CUDA_PATH%\\}include\\"
export CUDA_BIN_PATH="${CUDA_PATH%\\}bin\\"
echo
#############################################################
#
# Set up variable for zlib compression library.
#
#############################################################
if [ "$ZLIB_PATH" == "" ]
then
echo ZLIB_PATH not set.
echo -n "Looking ..."
# well, let's try to find it in downloads.
p=`find "$HOMEDRIVE/$HOMEPATH/Downloads" -name 'zlib.h' 2> /dev/null`
# now pick the last one.
x=""
for p2 in $p
do
if [ -f "$p2" ]
then
x="$p2"
fi
done
if [ "$x" == "" ]
then
echo Cannot find zlib.
exit 1
fi
y="${x%%zlib.h}"
echo "Found in "$y
export ZLIB_PATH="$y"
fi
echo ZLIB_PATH is "$ZLIB_PATH"
# check ZLIB_PATH.
if [ -e "$ZLIB_PATH" -a -d "$ZLIB_PATH" ]
then
echo ZLIB_PATH is set and exists.
else
echo ZLIB_PATH is set, but does not exist.
exit 1
fi
export ZLIB_PATH=`cygpath --dos $ZLIB_PATH`
echo
#############################################################
#
# Set up path for Antlr runtime libraries and include files.
#
#############################################################
if [ "$ANTLR_PATH" == "" ]
then
echo ANTLR_PATH not set.
echo -n "Looking ..."
# well, let's try to find it.
p=`find . -name antlr3.h 2> /dev/null`
# now pick the last one.
x=""
for j in $p
do
j2=${j%%/include/antlr3.h}
if [ -d $j2 ]
then
x="$j2"
pushd "$x"
x="`pwd`"
popd
fi
done
if [ "$x" == "" ]
then
echo Cannot find Antlr3 C libraries.
exit 1
fi
echo "Found in "$x
export ANTLR_PATH="$x"
echo $ANTLR_PATH
fi
if [ -d $ANTLR_PATH ]
then
echo Antlr3 is in $ANTLR_PATH.
else
echo Antlr3 does not exist.
exit 1
fi
export ANTLR_PATH=`cygpath --dos $ANTLR_PATH`
pwd=`pwd`
export ANTLR_JAR=`cygpath --dos $pwd/ptxp/antlr-3.2.jar`
export CLASSPATH="$ANTLR_JAR;$CLASSPATH"
echo
#############################################################
#
# Set up path for MSBuild.exe if people want that.
#
#############################################################
# get list of .NET directories.
p="$SYSTEMROOT/Microsoft.NET/Framework/v*"
l=`cygpath --unix $p`
# pick last in list that contains MSBuild.exe
for d in $l
do
p2=$d/MSBuild.exe
if [ -d $d -a -f $p2 ]
then
msbuild_dir=$d
fi
done
msbuild_dir=`cygpath --dos $msbuild_dir`
if [ -d $msbuild_dir ]
then
echo MSBuild.exe is in $msbuild_dir, and will be added to path.
echo
export PATH="$msbuild_dir:$PATH"
else
echo MSBuild.exe does not exist.
exit 1
fi
#############################################################
#
# Set up a variable for Visual Studio. The whole environment
# isn't set up, just one in order to boot strap using the
# file vcvars32.bat.
#
#############################################################
if [ "$VS_PATH" == "" ]
then
echo VS_PATH not set.
echo -n "Looking ..."
# well, let's try to find it.
p=`find "/cygdrive/c/Program Files (x86)" -name 'Microsoft Visual Studio*' 2> /dev/null`
# now look for directory below that "v...", picking last one listed.
x=""
for p2 in $p
do
if [ -d $p2/VC ]
then
x=$p2
fi
done
if [ "$x" == "" ]
then
echo Visual Studio not found.
exit 1
fi
echo "Found in "$x
export VS_PATH="$x"
fi
echo VS_PATH is "$VS_PATH"
# check VS_PATH.
if [ -e "$VS_PATH" -a -d "$VS_PATH" ]
then
echo VS_PATH is set and exists.
else
echo VS_PATH is set, but does not exist.
exit 1
fi
export VS_PATH=`cygpath --dos $VS_PATH`
echo
#############################################################
#
# Setup an shell with environment.
#
#############################################################
# The following lines are reset, and bash.exe *NOT* invoked with -l
# option. This is because if you try to do a build from the command
# line, or from devenv.exe, you get an message saying illegal option
# to CL.EXE with TMP.
export TMP="`cygpath --dos $tmp`"
export TEMP="`cygpath --dos $tmp`"
cmd /k "$VS_PATH\vc\bin\vcvars32.bat" "&&" set CHERE_INVOKING=y "&&" "c:\cygwin\bin\bash.exe" "-i"