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