blob: 4211bd1dfce6dd6790d1e80c1a1965697066f3e0 (
plain) (
blame)
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
|
#! /bin/sh
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 2007-2009. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# %CopyrightEnd%
#
# first find some tool we know exists, i.e. cl.exe
lookup_prog_in_path ()
{
PROG=$1
save_ifs=$IFS
IFS=:
for p in $PATH; do
# In cygwin the programs are not always executable and have .exe suffix...
if [ "X$TARGET" = "Xwin32" ]; then
if [ -f $p/$PROG.exe ]; then
echo $p/$PROG
break;
fi
else
if [ -x $p/$PROG ]; then
echo $p/$PROG
break;
fi
fi
done
IFS=$save_ifs
}
remove_path_element()
{
EL=$1
PA=$2
ACC=""
save_ifs=$IFS
IFS=/
set $PA
N=$#
while [ $N -gt 1 ]; do
if [ '!' -z "$1" ]; then
ACC="${ACC}/$1"
fi
N=`expr $N - 1`
shift
done
UP=`echo $1 | tr [:lower:] [:upper:]`
ELUP=`echo $EL | tr [:lower:] [:upper:]`
IFS=$save_ifs
if [ "$UP" = "$ELUP" ]; then
echo "$ACC"
else
echo "${ACC}/$1"
fi
#echo "ACC=$ACC" >&2
#echo "1=$1" >&2
}
add_path_element()
{
EL=$1
PA=$2
ELUP=`echo $EL | tr [:lower:] [:upper:]`
#echo "PA=$PA" >&2
for x in ${PA}/*; do
#echo "X=$x" >&2
UP=`basename "$x" | tr [:lower:] [:upper:]`
#echo "UP=$UP" >&2
if [ "$UP" = "$ELUP" ]; then
echo "$x"
return 0;
fi
done
echo "$PA"
}
CLPATH=`lookup_prog_in_path cl`
if [ -z "$CLPATH" ]; then
echo "Can not locate cl.exe and vcredist_x86.exe - OK if using mingw" >&2
exit 1
fi
#echo $CLPATH
BPATH=$CLPATH
for x in cl bin vc; do
#echo $x
NBPATH=`remove_path_element $x "$BPATH"`
if [ "$NBPATH" = "$BPATH" ]; then
echo "Failed to locate vcredist_x86.exe because cl.exe was in an unexpected location" >&2
exit 2
fi
BPATH="$NBPATH"
done
BPATH_LIST=$BPATH
# rc.exe is in the Microsoft SDK directory of VS2008
RCPATH=`lookup_prog_in_path rc`
fail=false
if [ '!' -z "$RCPATH" ]; then
BPATH=$RCPATH
for x in rc bin v6.0A ; do
NBPATH=`remove_path_element $x "$BPATH"`
if [ "$NBPATH" = "$BPATH" ]; then
fail=true
break;
fi
BPATH="$NBPATH"
done
if [ $fail = false ]; then
BPATH_LIST="$BPATH_LIST $BPATH"
fi
fi
# Frantic search through two roots with different
# version directories. We want to be very specific about the
# directory structures as we woildnt want to find the wrong
# redistributables...
#echo $BPATH
for BP in $BPATH_LIST; do
for verdir in "sdk v2.0" "sdk v3.5" "v6.0A"; do
BPATH=$BP
fail=false
for x in $verdir bootstrapper packages vcredist_x86 vcredist_x86.exe; do
#echo "x=$x"
#echo "BPATH=$BPATH"
NBPATH=`add_path_element $x "$BPATH"`
if [ "$NBPATH" = "$BPATH" ]; then
fail=true
break;
fi
BPATH="$NBPATH"
done
if [ $fail = false ]; then
break;
fi
done
if [ $fail = false ]; then
echo $BPATH
exit 0
fi
done
echo "Failed to locate vcredist_x86.exe because directory structure was unexpected" >&2
exit 3
|