xref: /aoo41x/main/oowintool (revision dfafe007)
1 cdf0e10cSrcweir#!/usr/bin/perl -w
2 b31e36b3SAndrew Rist# *************************************************************
3 b31e36b3SAndrew Rist#
4 b31e36b3SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5 b31e36b3SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6 b31e36b3SAndrew Rist#  distributed with this work for additional information
7 b31e36b3SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8 b31e36b3SAndrew Rist#  to you under the Apache License, Version 2.0 (the
9 b31e36b3SAndrew Rist#  "License"); you may not use this file except in compliance
10 b31e36b3SAndrew Rist#  with the License.  You may obtain a copy of the License at
11 b31e36b3SAndrew Rist#
12 b31e36b3SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13 b31e36b3SAndrew Rist#
14 b31e36b3SAndrew Rist#  Unless required by applicable law or agreed to in writing,
15 b31e36b3SAndrew Rist#  software distributed under the License is distributed on an
16 b31e36b3SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 b31e36b3SAndrew Rist#  KIND, either express or implied.  See the License for the
18 b31e36b3SAndrew Rist#  specific language governing permissions and limitations
19 b31e36b3SAndrew Rist#  under the License.
20 b31e36b3SAndrew Rist#
21 b31e36b3SAndrew Rist# *************************************************************
22 cdf0e10cSrcweir
23 cdf0e10cSrcweiruse File::Copy;
24 cdf0e10cSrcweir
25 cdf0e10cSrcweirmy $output_format = 'u';
26 cdf0e10cSrcweir
27 cdf0e10cSrcweirsub reg_get_value($)
28 cdf0e10cSrcweir{
29 cdf0e10cSrcweir    # it is believed that the registry moves keys around
30 cdf0e10cSrcweir    # depending on OS version, this will de-mangle that
31 cdf0e10cSrcweir    my $key = shift;
32 cdf0e10cSrcweir    my $fhandle;
33 cdf0e10cSrcweir    my $value;
34 cdf0e10cSrcweir
35 cdf0e10cSrcweir    open ($fhandle, "/proc/registry/$key") || return;
36 cdf0e10cSrcweir    # reg keys have 0x00 0x5c at the end
37 cdf0e10cSrcweir    $value = (split /\0/, <$fhandle>)[0];
38 cdf0e10cSrcweir    close ($fhandle);
39 cdf0e10cSrcweir
40 cdf0e10cSrcweir    if ( defined $value ) {
41 cdf0e10cSrcweir        chomp ($value);
42 cdf0e10cSrcweir        $value =~ s|\r\n||;
43 cdf0e10cSrcweir#    print "Value '$value' at '$key'\n";
44 cdf0e10cSrcweir    }
45 cdf0e10cSrcweir
46 cdf0e10cSrcweir    return $value;
47 cdf0e10cSrcweir}
48 cdf0e10cSrcweir
49 cdf0e10cSrcweirsub reg_find_key($)
50 cdf0e10cSrcweir{
51 cdf0e10cSrcweir    # it is believed that the registry moves keys around
52 cdf0e10cSrcweir    # depending on OS version, this will de-mangle that
53 cdf0e10cSrcweir    my $key = shift;
54 cdf0e10cSrcweir    $key =~ s| |\\ |;
55 cdf0e10cSrcweir    $key = `cd /proc/registry/ ; ls $key`;
56 cdf0e10cSrcweir
57 cdf0e10cSrcweir    return $key;
58 cdf0e10cSrcweir}
59 cdf0e10cSrcweir
60 cdf0e10cSrcweirsub print_syntax()
61 cdf0e10cSrcweir{
62 cdf0e10cSrcweir    print "oowintool [option] ...\n";
63 cdf0e10cSrcweir    print " encoding options\n";
64 cdf0e10cSrcweir    print "   -w   - windows form\n";
65 cdf0e10cSrcweir    print "   -u   - unix form (default)\n";
66 cdf0e10cSrcweir    print " commands:\n";
67 cdf0e10cSrcweir    print "   --msvc-ver              - dump version of MSVC eg. 6.0\n";
68 cdf0e10cSrcweir    print "   --msvc-copy-dlls <dest> - copy msvc[pr]??.dlls into <dest>/msvcp??/\n";
69 cdf0e10cSrcweir    print "   --msvc-productdir       - dump productdir\n";
70 cdf0e10cSrcweir    print "   --msvs-productdir       - dump productdir\n";
71 cdf0e10cSrcweir    print "   --dotnetsdk-dir         - dump .Net SDK path\n";
72 cdf0e10cSrcweir    print "   --csc-compilerdir       - dump .Net SDK compiler path\n";
73 cdf0e10cSrcweir    print "   --psdk-home             - dump psdk install dir\n";
74 cdf0e10cSrcweir    print "   --jdk-home              - dump the jdk install dir\n";
75 cdf0e10cSrcweir    print "   --nsis-dir              - dump NSIS path\n";
76 cdf0e10cSrcweir    print "   --help                  - this message\n";
77 cdf0e10cSrcweir}
78 cdf0e10cSrcweir
79 cdf0e10cSrcweirsub cygpath($$$)
80 cdf0e10cSrcweir{
81 cdf0e10cSrcweir    my ($path, $input_format, $format) = @_;
82 cdf0e10cSrcweir
83 cdf0e10cSrcweir    return $path if ( ! defined $path );
84 cdf0e10cSrcweir    # Strip trailing path separators
85 cdf0e10cSrcweir    if ($input_format eq 'u') {
86 cdf0e10cSrcweir	$path =~ s|/*\s*$||;
87 cdf0e10cSrcweir    } else {
88 cdf0e10cSrcweir	$path =~ s|\\*\s*$||;
89 cdf0e10cSrcweir    }
90 cdf0e10cSrcweir
91 cdf0e10cSrcweir    # 'Unterminated quoted string errors' from 'ash' when
92 cdf0e10cSrcweir    # forking cygpath  so - reimplement cygpath in perl [ gack ]
93 cdf0e10cSrcweir    if ($format eq 'u' && $input_format eq 'w') {
94 cdf0e10cSrcweir	$path =~ s|\\|/|g;
95 cdf0e10cSrcweir	$path =~ s|([a-zA-Z]):/|/cygdrive/$1/|g;
96 cdf0e10cSrcweir    }
97 cdf0e10cSrcweir    elsif ($format eq 'w' && $input_format eq 'u') {
98 cdf0e10cSrcweir	$path =~ s|/cygdrive/([a-zA-Z])/|/$1/|g;
99 cdf0e10cSrcweir	$path =~ s|/|\\|g;
100 cdf0e10cSrcweir    }
101 cdf0e10cSrcweir
102 cdf0e10cSrcweir    return $path;
103 cdf0e10cSrcweir}
104 cdf0e10cSrcweir
105 cdf0e10cSrcweirsub print_path($$)
106 cdf0e10cSrcweir{
107 cdf0e10cSrcweir    my ($path, $unix) = @_;
108 cdf0e10cSrcweir
109 cdf0e10cSrcweir    $path = cygpath ($path, $unix, $output_format);
110 cdf0e10cSrcweir
111 cdf0e10cSrcweir    print $path;
112 cdf0e10cSrcweir}
113 cdf0e10cSrcweir
114 cdf0e10cSrcweirsub print_psdk_home()
115 cdf0e10cSrcweir{
116 cdf0e10cSrcweir    my ($value, $key);
117 cdf0e10cSrcweir    $value = reg_get_value ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v6.1/InstallationFolder');
118 cdf0e10cSrcweir    if (!defined $value)
119 cdf0e10cSrcweir    {
120 cdf0e10cSrcweir        $value = reg_get_value ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/CurrentInstallFolder');
121 01d9dfefSHerbert Dürr    }
122 cdf0e10cSrcweir    if (!defined $value)
123 cdf0e10cSrcweir    {
124 cdf0e10cSrcweir	    $value = reg_get_value ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/Directories/Install Dir');
125 01d9dfefSHerbert Dürr    }
126 cdf0e10cSrcweir    if (!defined $value)
127 cdf0e10cSrcweir    {
128 cdf0e10cSrcweir	    $key = reg_find_key ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/*/Install Dir');
129 cdf0e10cSrcweir	    $value = reg_get_value ($key);
130 01d9dfefSHerbert Dürr    }
131 cdf0e10cSrcweir    if (!defined $value)
132 cdf0e10cSrcweir    {
133 cdf0e10cSrcweir        my $dir = cygpath (find_msvc()->{'product_dir'}, 'w', $output_format);
134 cdf0e10cSrcweir		$value = `/bin/find "$dir" -iname platformsdk | head -n 1`;
135 cdf0e10cSrcweir    }
136 cdf0e10cSrcweir
137 cdf0e10cSrcweir    defined $value || die "psdk not found";
138 cdf0e10cSrcweir
139 cdf0e10cSrcweir    print cygpath ($value, 'w', $output_format);
140 cdf0e10cSrcweir}
141 cdf0e10cSrcweir
142 cdf0e10cSrcweirmy %msvc_net_2003 = (
143 cdf0e10cSrcweir    'ver' => '7.1',
144 cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/7.1/Setup/VC/ProductDir',
145 cdf0e10cSrcweir    'dll_path' => '../Visual Studio .NET Professional 2003 - English',
146 cdf0e10cSrcweir    'dll_suffix' => '71'
147 cdf0e10cSrcweir);
148 cdf0e10cSrcweirmy %msvs_net_2003 = (
149 cdf0e10cSrcweir    'ver' => '7.1',
150 cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/7.1/Setup/VS/ProductDir',
151 cdf0e10cSrcweir    'dll_path' => 'Visual Studio .NET Professional 2003 - English',
152 cdf0e10cSrcweir    'dll_suffix' => '71'
153 cdf0e10cSrcweir);
154 cdf0e10cSrcweirmy %msvs_net_2003_ea = (
155 cdf0e10cSrcweir    'ver' => '7.1',
156 cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/7.1/Setup/VS/ProductDir',
157 cdf0e10cSrcweir    'dll_path' => 'Visual Studio .NET Enterprise Architect 2003 - English', # testme ...
158 cdf0e10cSrcweir    'dll_suffix' => '71'
159 cdf0e10cSrcweir);
160 cdf0e10cSrcweirmy %msvs_express_2005 = (
161 cdf0e10cSrcweir    'ver' => '8.0',
162 cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/8.0/Setup/VS/ProductDir',
163 cdf0e10cSrcweir    'dll_path' => '../SDK/v2.0/Bin',
164 cdf0e10cSrcweir    'dll_suffix' => '80'
165 cdf0e10cSrcweir);
166 cdf0e10cSrcweirmy %msvc_express_2005 = (
167 cdf0e10cSrcweir    'ver' => '8.0',
168 cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/8.0/Setup/VC/ProductDir',
169 cdf0e10cSrcweir    'dll_path' => '../SDK/v2.0/Bin',
170 cdf0e10cSrcweir    'dll_suffix' => '80'
171 cdf0e10cSrcweir);
172 cdf0e10cSrcweirmy %msvs_2005 = (
173 cdf0e10cSrcweir    'ver' => '8.0',
174 cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/8.0/Setup/VS/ProductDir',
175 cdf0e10cSrcweir    'dll_path' => 'Visual Studio .NET Professional 2005 - English',
176 cdf0e10cSrcweir    'dll_suffix' => '80'
177 cdf0e10cSrcweir);
178 cdf0e10cSrcweirmy %msvc_2005 = (
179 cdf0e10cSrcweir    'ver' => '8.0',
180 cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/8.0/Setup/VC/ProductDir',
181 cdf0e10cSrcweir    'dll_path' => '../SDK/v2.0/Bin',
182 cdf0e10cSrcweir    'dll_suffix' => '80'
183 cdf0e10cSrcweir);
184 cdf0e10cSrcweirmy %msvs_2008 = (
185 cdf0e10cSrcweir    'ver' => '9.0',
186 cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/9.0/Setup/VS/ProductDir',
187 cdf0e10cSrcweir    'dll_path' => 'VC/redist/x86/Microsoft.VC90.CRT',
188 cdf0e10cSrcweir    'dll_suffix' => '90'
189 cdf0e10cSrcweir);
190 cdf0e10cSrcweirmy %msvc_2008 = (
191 cdf0e10cSrcweir    'ver' => '9.0',
192 cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/9.0/Setup/VC/ProductDir',
193 cdf0e10cSrcweir    'dll_path' => 'redist/x86/Microsoft.VC90.CRT',
194 cdf0e10cSrcweir    'dll_suffix' => '90'
195 cdf0e10cSrcweir);
196 cdf0e10cSrcweirmy %msvs_express_2008 = (
197 cdf0e10cSrcweir    'ver' => '9.0',
198 cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/9.0/Setup/VS/ProductDir',
199 cdf0e10cSrcweir    'dll_path' => 'VC/redist/x86/Microsoft.VC90.CRT',
200 cdf0e10cSrcweir    'dll_suffix' => '90'
201 cdf0e10cSrcweir);
202 cdf0e10cSrcweirmy %msvc_express_2008 = (
203 cdf0e10cSrcweir    'ver' => '9.0',
204 cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/9.0/Setup/VC/ProductDir',
205 cdf0e10cSrcweir    'dll_path' => 'redist/x86/Microsoft.VC90.CRT',
206 cdf0e10cSrcweir    'dll_suffix' => '90'
207 cdf0e10cSrcweir);
208 cdf0e10cSrcweir
209 cdf0e10cSrcweirsub find_msvs()
210 cdf0e10cSrcweir{
211 cdf0e10cSrcweir    my @ms_versions = ( \%msvs_2008, \%msvs_express_2008, \%msvs_2005, \%msvs_express_2005, \%msvs_net_2003_ea, \%msvs_net_2003 );
212 cdf0e10cSrcweir
213 cdf0e10cSrcweir    for $ver (@ms_versions)
214 cdf0e10cSrcweir    {
215 cdf0e10cSrcweir	my $install = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/" . $ver->{'key'});
216 cdf0e10cSrcweir	if (defined $install && $install ne '') {
217 cdf0e10cSrcweir	    $ver->{'product_dir'} = $install;
218 cdf0e10cSrcweir	    return $ver;
219 cdf0e10cSrcweir	}
220 *dfafe007SMatthias Seidel	$install = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/" . $ver->{'key'});
221 *dfafe007SMatthias Seidel	if (defined $install && $install ne '') {
222 *dfafe007SMatthias Seidel	    $ver->{'product_dir'} = $install;
223 *dfafe007SMatthias Seidel	    return $ver;
224 *dfafe007SMatthias Seidel	}
225 cdf0e10cSrcweir    }
226 cdf0e10cSrcweir    die "Can't find MS Visual Studio / VC++";
227 cdf0e10cSrcweir}
228 cdf0e10cSrcweir
229 cdf0e10cSrcweirsub find_msvc()
230 cdf0e10cSrcweir{
231 cdf0e10cSrcweir    my @ms_versions = ( \%msvc_2008, \%msvc_express_2008, \%msvc_2005, \%msvc_express_2005, \%msvc_net_2003 );
232 cdf0e10cSrcweir
233 cdf0e10cSrcweir    for $ver (@ms_versions)
234 cdf0e10cSrcweir    {
235 cdf0e10cSrcweir	my $install = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/" . $ver->{'key'});
236 cdf0e10cSrcweir	if (defined $install && $install ne '') {
237 cdf0e10cSrcweir	    $ver->{'product_dir'} = $install;
238 cdf0e10cSrcweir	    return $ver;
239 cdf0e10cSrcweir	}
240 *dfafe007SMatthias Seidel	$install = reg_get_value("HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/" . $ver->{'key'});
241 *dfafe007SMatthias Seidel	if (defined $install && $install ne '') {
242 *dfafe007SMatthias Seidel	    $ver->{'product_dir'} = $install;
243 *dfafe007SMatthias Seidel	    return $ver;
244 *dfafe007SMatthias Seidel	}
245 cdf0e10cSrcweir    }
246 cdf0e10cSrcweir    die "Can't find MS Visual Studio / VC++";
247 cdf0e10cSrcweir}
248 cdf0e10cSrcweir
249 cdf0e10cSrcweirsub print_msvc_ver()
250 cdf0e10cSrcweir{
251 cdf0e10cSrcweir    my $ver = find_msvc();
252 cdf0e10cSrcweir    print $ver->{'ver'};
253 cdf0e10cSrcweir}
254 cdf0e10cSrcweir
255 cdf0e10cSrcweirsub print_msvc_product_dir()
256 cdf0e10cSrcweir{
257 cdf0e10cSrcweir    my $ver = find_msvc();
258 cdf0e10cSrcweir    print cygpath ($ver->{'product_dir'}, 'w', $output_format);
259 cdf0e10cSrcweir}
260 cdf0e10cSrcweir
261 cdf0e10cSrcweirsub print_msvs_productdir()
262 cdf0e10cSrcweir{
263 cdf0e10cSrcweir    my $ver = find_msvs();
264 cdf0e10cSrcweir    print cygpath ($ver->{'product_dir'}, 'w', $output_format);
265 cdf0e10cSrcweir}
266 cdf0e10cSrcweir
267 cdf0e10cSrcweirsub print_csc_compiler_dir()
268 cdf0e10cSrcweir{
269 cdf0e10cSrcweir    my $dir = cygpath (reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/InstallRoot"), 'w', $output_format);
270 cdf0e10cSrcweir    my $csc_exe = `/bin/find "$dir" -iname csc.exe | grep "v2\." | head -n 1`;
271 cdf0e10cSrcweir    print `dirname $csc_exe`;
272 cdf0e10cSrcweir}
273 cdf0e10cSrcweir
274 cdf0e10cSrcweirsub print_dotnetsdk_dir()
275 cdf0e10cSrcweir{
276 cdf0e10cSrcweir    my $dir =
277 cdf0e10cSrcweir          reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/sdkInstallRootv1.1") ||
278 cdf0e10cSrcweir          reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/sdkInstallRootv2.0");
279 cdf0e10cSrcweir    print cygpath ($dir, 'w', $output_format);
280 cdf0e10cSrcweir}
281 cdf0e10cSrcweir
282 cdf0e10cSrcweirsub print_jdk_dir()
283 cdf0e10cSrcweir{
284 cdf0e10cSrcweir    my $dir =
285 01d9dfefSHerbert Dürr	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.7/JavaHome") ||
286 01d9dfefSHerbert Dürr	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.6/JavaHome") ||
287 cdf0e10cSrcweir	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.5/JavaHome") ||
288 cdf0e10cSrcweir	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.4/JavaHome") ||
289 cdf0e10cSrcweir	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.3/JavaHome");
290 cdf0e10cSrcweir    print cygpath($dir, 'w', $output_format);
291 cdf0e10cSrcweir}
292 cdf0e10cSrcweir
293 cdf0e10cSrcweirsub print_nsis_dir()
294 cdf0e10cSrcweir{
295 cdf0e10cSrcweir    my $dir = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/NSIS/@");
296 cdf0e10cSrcweir    print cygpath ($dir, 'w', $output_format) if defined $dir;
297 cdf0e10cSrcweir}
298 cdf0e10cSrcweir
299 cdf0e10cSrcweirsub copy_dll($$$)
300 cdf0e10cSrcweir{
301 cdf0e10cSrcweir    my ($src, $fname, $dest) = @_;
302 cdf0e10cSrcweir
303 cdf0e10cSrcweir    -f "$src/$fname" || die "can't find $src";
304 cdf0e10cSrcweir    -d $dest || die "no directory $dest";
305 cdf0e10cSrcweir
306 cdf0e10cSrcweir	print STDERR "Copying $src/$fname to $dest\n";
307 cdf0e10cSrcweir    copy ("$src/$fname", $dest) || die "copy failed: $!";
308 cdf0e10cSrcweir    chmod (0755, "$dest/$fname") || die "failed to set dll executable: $!";
309 cdf0e10cSrcweir}
310 cdf0e10cSrcweir
311 cdf0e10cSrcweirsub msvc_find_version($)
312 cdf0e10cSrcweir{
313 cdf0e10cSrcweir    my $checkpath = shift;
314 cdf0e10cSrcweir    my $ver = find_msvc();
315 cdf0e10cSrcweir    my $srcdir = (cygpath ($ver->{'product_dir'}, 'w', 'u') . '/' .
316 cdf0e10cSrcweir		  $ver->{$checkpath});
317 cdf0e10cSrcweir    -d $srcdir && return $ver;
318 cdf0e10cSrcweir    $ver = find_msvs();
319 cdf0e10cSrcweir    $srcdir = (cygpath ($ver->{'product_dir'}, 'w', 'u') . '/' .
320 cdf0e10cSrcweir		  $ver->{$checkpath});
321 cdf0e10cSrcweir    -d $srcdir && return $ver;
322 cdf0e10cSrcweir    return undef;
323 cdf0e10cSrcweir}
324 cdf0e10cSrcweir
325 cdf0e10cSrcweirsub msvc_copy_dlls($)
326 cdf0e10cSrcweir{
327 cdf0e10cSrcweir    my $dest = shift;
328 cdf0e10cSrcweir    my $ver = msvc_find_version('dll_path');
329 cdf0e10cSrcweir    defined $ver || return;
330 cdf0e10cSrcweir    my $srcdir = (cygpath ($ver->{'product_dir'}, 'w', 'u') . '/' .
331 cdf0e10cSrcweir		  $ver->{'dll_path'});
332 cdf0e10cSrcweir
333 cdf0e10cSrcweir    copy_dll ($srcdir, "msvcp" . $ver->{'dll_suffix'} . ".dll",
334 cdf0e10cSrcweir	      $dest . $ver->{'dll_suffix'});
335 cdf0e10cSrcweir    copy_dll ($srcdir, "msvcr" . $ver->{'dll_suffix'} . ".dll",
336 cdf0e10cSrcweir	      $dest . $ver->{'dll_suffix'});
337 cdf0e10cSrcweir    if ($ver->{'dll_suffix'} >= 90) {
338 cdf0e10cSrcweir        copy_dll ($srcdir, "msvcm" . $ver->{'dll_suffix'} . ".dll",
339 cdf0e10cSrcweir                  $dest . $ver->{'dll_suffix'});
340 cdf0e10cSrcweir        copy_dll ($srcdir, "Microsoft.VC90.CRT.manifest", $dest . $ver->{'dll_suffix'});
341 cdf0e10cSrcweir    }
342 cdf0e10cSrcweir}
343 cdf0e10cSrcweir
344 cdf0e10cSrcweirif (!@ARGV) {
345 cdf0e10cSrcweir    print_syntax();
346 cdf0e10cSrcweir    exit 1;
347 cdf0e10cSrcweir}
348 cdf0e10cSrcweir
349 cdf0e10cSrcweirmy @commands = ();
350 cdf0e10cSrcweirmy $opt;
351 cdf0e10cSrcweirwhile (@ARGV) {
352 cdf0e10cSrcweir    $opt = shift @ARGV;
353 cdf0e10cSrcweir
354 cdf0e10cSrcweir    if ($opt eq '-w' || $opt eq '-u') {
355 cdf0e10cSrcweir	$output_format = substr($opt, 1, 1);
356 cdf0e10cSrcweir    } else {
357 cdf0e10cSrcweir	push @commands, $opt;
358 cdf0e10cSrcweir    }
359 cdf0e10cSrcweir}
360 cdf0e10cSrcweir
361 cdf0e10cSrcweirwhile (@commands) {
362 cdf0e10cSrcweir    $opt = shift @commands;
363 cdf0e10cSrcweir
364 cdf0e10cSrcweir    if (0) {
365 cdf0e10cSrcweir    } elsif ($opt eq '--msvc-ver') {
366 cdf0e10cSrcweir	print_msvc_ver();
367 cdf0e10cSrcweir    } elsif ($opt eq '--msvc-copy-dlls') {
368 cdf0e10cSrcweir	my $dest = shift @commands;
369 cdf0e10cSrcweir	defined $dest || die "copy-dlls requires a destination directory";
370 cdf0e10cSrcweir	msvc_copy_dlls( $dest );
371 cdf0e10cSrcweir    } elsif ($opt eq '--msvs-productdir') {
372 cdf0e10cSrcweir	print_msvs_productdir();
373 cdf0e10cSrcweir    } elsif ($opt eq '--msvc-productdir') {
374 cdf0e10cSrcweir	print_msvc_product_dir();
375 cdf0e10cSrcweir    } elsif ($opt eq '--dotnetsdk-dir') {
376 cdf0e10cSrcweir	print_dotnetsdk_dir();
377 cdf0e10cSrcweir    } elsif ($opt eq '--csc-compilerdir') {
378 cdf0e10cSrcweir	print_csc_compiler_dir();
379 cdf0e10cSrcweir    } elsif ($opt eq '--psdk-home') {
380 cdf0e10cSrcweir	print_psdk_home();
381 cdf0e10cSrcweir    } elsif ($opt eq '--jdk-home') {
382 cdf0e10cSrcweir	print_jdk_dir();
383 cdf0e10cSrcweir    } elsif ($opt eq '--nsis-dir') {
384 cdf0e10cSrcweir	print_nsis_dir();
385 cdf0e10cSrcweir    } elsif ($opt eq '--help' || $opt eq '/?') {
386 cdf0e10cSrcweir	print_syntax();
387 cdf0e10cSrcweir    } else {
388 cdf0e10cSrcweir	print "Unknown option '$opt'\n";
389 cdf0e10cSrcweir	print_syntax();
390 cdf0e10cSrcweir	exit 1;
391 cdf0e10cSrcweir    }
392 cdf0e10cSrcweir}
393 cdf0e10cSrcweir
394