summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Tk/MMtry.pm
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2010-05-12 16:54:37 +0000
committerNorbert Preining <preining@logic.at>2010-05-12 16:54:37 +0000
commit661c41a09e39a182865e0b51e34cc995a0dc96e8 (patch)
tree2f79bb1406e22fdcb2587be8ffda6c0c609d7932 /Master/tlpkg/tlperl/lib/Tk/MMtry.pm
parentb645030efc22e13c2498a1522083634ab91b2de1 (diff)
move tlperl.straw to tlperl
git-svn-id: svn://tug.org/texlive/trunk@18210 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Tk/MMtry.pm')
-rwxr-xr-xMaster/tlpkg/tlperl/lib/Tk/MMtry.pm58
1 files changed, 58 insertions, 0 deletions
diff --git a/Master/tlpkg/tlperl/lib/Tk/MMtry.pm b/Master/tlpkg/tlperl/lib/Tk/MMtry.pm
new file mode 100755
index 00000000000..110f6b2ae81
--- /dev/null
+++ b/Master/tlpkg/tlperl/lib/Tk/MMtry.pm
@@ -0,0 +1,58 @@
+# Copyright (c) 1995-2003 Nick Ing-Simmons. All rights reserved.
+# This program is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+package Tk::MMtry;
+use Config;
+require Exporter;
+
+use vars qw($VERSION @EXPORT $VERBOSE);
+#$VERSION = sprintf '4.%03d', q$Revision: #9 $ =~ /\D(\d+)\s*$/;
+$VERSION = '4.010';
+
+use base qw(Exporter);
+@EXPORT = qw(try_compile try_run);
+use strict;
+use File::Basename;
+use File::Spec;
+
+my $stderr_too = ($^O eq 'MSWin32') ? '' : '2>&1';
+
+sub try_compile
+{
+ my ($file,$inc,$lib,$def) = @_;
+ $inc = [] unless $inc;
+ $lib = [] unless $lib;
+ $def = [] unless $def;
+ my $out = basename($file,'.c').$Config{'exe_ext'};
+ warn "Test Compiling $file\n";
+ my $msgs = `$Config{'cc'} -o $out $Config{'ccflags'} @$inc $file @$lib @$def $stderr_too`;
+ my $ok = ($? == 0);
+ warn "$msgs\n" if $VERBOSE && $msgs;
+ unlink($out) if (-f $out);
+ return $ok;
+}
+
+sub try_run
+{
+ my ($file,$inc,$lib,$def) = @_;
+ $inc = [] unless $inc;
+ $lib = [] unless $lib;
+ $def = [] unless $def;
+ my $out = basename($file,'.c').$Config{'exe_ext'};
+ warn "Test Compile/Run $file\n";
+ my $cmdline = "$Config{'cc'} -o $out $Config{'ccflags'} @$inc $file @$lib @$def";
+ my $msgs = `$cmdline $stderr_too`;
+ my $ok = ($? == 0);
+ warn "$cmdline:\n$msgs\n" if $VERBOSE && $msgs;
+ if ($ok)
+ {
+ my $path = File::Spec->rel2abs($out);
+ $msgs = `$path $stderr_too`;
+ $ok = ($? == 0);
+ warn "$path:$msgs\n" if $VERBOSE && $msgs;
+ }
+ unlink($out) if (-f $out);
+ return $ok;
+}
+
+1;