Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / MMtry.pm
CommitLineData
86530b38
AT
1# Copyright (c) 1995-1999 Nick Ing-Simmons. All rights reserved.
2# This program is free software; you can redistribute it and/or
3# modify it under the same terms as Perl itself.
4package Tk::MMtry;
5use Config;
6require Exporter;
7
8use vars qw($VERSION @EXPORT);
9$VERSION = '3.010'; # $Id: //depot/Tk8/Tk/MMtry.pm#10 $
10
11use base qw(Exporter);
12@EXPORT = qw(try_compile try_run);
13use strict;
14use File::Basename;
15
16my $stderr_too = ($^O eq 'MSWin32') ? '' : '2>&1';
17
18sub try_compile
19{
20 my $file = shift;
21 my $out = basename($file,'.c').$Config{'exe_ext'};
22 warn "Test Compiling $file\n";
23 my $msgs = `$Config{'cc'} -o $out $Config{'ccflags'} $file $stderr_too`;
24 my $ok = ($? == 0);
25 unlink($out) if (-f $out);
26 return $ok;
27}
28
29sub try_run
30{
31 my $file = shift;
32 my $out = basename($file,'.c').$Config{'exe_ext'};
33 warn "Test Compiling $file\n";
34 my $msgs = `$Config{'cc'} -o $out $Config{'ccflags'} $file $stderr_too`;
35 my $ok = ($? == 0);
36 if ($ok)
37 {
38 system($out);
39 $ok = ($? == 0);
40 }
41 unlink($out) if (-f $out);
42 return $ok;
43}
44
451;