home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D2.iso / workshop / apache / files / ActivePerl-5.8.3.809-MSWin32-x86.msi / _2208f11cc15eb9783c3aa605c65ce893 < prev    next >
Encoding:
Text File  |  2004-02-02  |  1.1 KB  |  46 lines

  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.
  4. package Tk::MMtry;
  5. use Config;
  6. require Exporter;
  7.  
  8. use vars qw($VERSION @EXPORT);
  9. $VERSION = '3.010'; # $Id: //depot/Tk8/Tk/MMtry.pm#10 $
  10.  
  11. use base  qw(Exporter);
  12. @EXPORT = qw(try_compile try_run);
  13. use strict;
  14. use File::Basename;
  15.  
  16. my $stderr_too = ($^O eq 'MSWin32') ? '' : '2>&1';
  17.  
  18. sub 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.  
  29. sub 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.  
  45. 1;
  46.