summaryrefslogtreecommitdiff
path: root/make_ext.pl
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-11-04 03:46:09 -0500
committerTony Cook <tony@develop-help.com>2014-11-05 10:33:46 +1100
commit0e150199b288c3b3d5186fec8b44d7c72e873067 (patch)
tree4baf97bff05b3faf4107fc5efd158e5e9b26c4a5 /make_ext.pl
parent0d93ddf17505a64b7b9215047f3ff668b611792c (diff)
downloadperl-0e150199b288c3b3d5186fec8b44d7c72e873067.tar.gz
const fold OS versions in make_ext.pl
goto-LABEL is extremely slow in P5, so use a scalar to cache the result of file not existing.
Diffstat (limited to 'make_ext.pl')
-rw-r--r--make_ext.pl39
1 files changed, 21 insertions, 18 deletions
diff --git a/make_ext.pl b/make_ext.pl
index 6e7955d29f..126bf737d5 100644
--- a/make_ext.pl
+++ b/make_ext.pl
@@ -2,11 +2,11 @@
use strict;
use warnings;
use Config;
-use constant IS_CROSS => defined $Config::Config{usecrosscompile} ? 1 : 0;
-
-my $is_Win32 = $^O eq 'MSWin32';
-my $is_VMS = $^O eq 'VMS';
-my $is_Unix = !$is_Win32 && !$is_VMS;
+use constant{IS_CROSS => defined $Config::Config{usecrosscompile} ? 1 : 0,
+ IS_WIN32 => $^O eq 'MSWin32',
+ IS_VMS => $^O eq 'VMS',
+ IS_UNIX => $^O ne 'MSWin32' && $^O ne 'VMS',
+};
my @ext_dirs = qw(cpan dist ext);
my $ext_dirs_re = '(?:' . join('|', @ext_dirs) . ')';
@@ -139,7 +139,7 @@ if (!@extspec and !$static and !$dynamic and !$nonxs and !$dynaloader) {
my $perl;
my %extra_passthrough;
-if ($is_Win32) {
+if (IS_WIN32) {
require Cwd;
require FindExt;
my $build = Cwd::getcwd();
@@ -196,7 +196,7 @@ if ($is_Win32) {
chdir '..'
or die "Couldn't chdir to build directory: $!"; # now in the Perl build
}
-elsif ($is_VMS) {
+elsif (IS_VMS) {
$perl = $^X;
push @extspec, (split ' ', $Config{static_ext}) if $static;
push @extspec, (split ' ', $Config{dynamic_ext}) if $dynamic;
@@ -276,8 +276,8 @@ sub build_extension {
my $lib_dir = "$up/lib";
$ENV{PERL_CORE} = 1;
- my $makefile;
- if ($is_VMS) {
+ my ($makefile, $makefile_no_minus_f);
+ if (IS_VMS) {
$makefile = 'descrip.mms';
if ($target =~ /clean$/
&& !-f $makefile
@@ -289,6 +289,7 @@ sub build_extension {
}
if (-f $makefile) {
+ $makefile_no_minus_f = 0;
open my $mfh, $makefile or die "Cannot open $makefile: $!";
while (<$mfh>) {
# Plagiarised from CPAN::Distribution
@@ -339,9 +340,11 @@ sub build_extension {
_unlink($makefile);
}
}
+ } else {
+ $makefile_no_minus_f = 1;
}
- if (!-f $makefile) {
+ if ($makefile_no_minus_f || !-f $makefile) {
NO_MAKEFILE:
if (!-f 'Makefile.PL') {
unless (just_pm_to_blib($target, $ext_dir, $mname, $return_dir)) {
@@ -496,7 +499,7 @@ EOM
print "\nRunning Makefile.PL in $ext_dir\n" if $verbose;
my @args = ("-I$lib_dir", 'Makefile.PL');
- if ($is_VMS) {
+ if (IS_VMS) {
my $libd = VMS::Filespec::vmspath($lib_dir);
push @args, "INST_LIB=$libd", "INST_ARCHLIB=$libd";
} else {
@@ -504,7 +507,7 @@ EOM
'INSTALLMAN3DIR=none';
}
push @args, @$pass_through;
- _quote_args(\@args) if $is_VMS;
+ _quote_args(\@args) if IS_VMS;
print join(' ', $perl, @args), "\n" if $verbose;
my $code = do {
local $ENV{PERL_MM_USE_DEFAULT} = 1;
@@ -523,7 +526,7 @@ EOM
# some of them rely on a $(PERL) for their own distclean targets.
# But this always used to be a problem with the old /bin/sh version of
# this.
- if ($is_Unix) {
+ if (IS_UNIX) {
foreach my $clean_target ('realclean', 'veryclean') {
fallback_cleanup($return_dir, $clean_target, <<"EOS");
cd $ext_dir
@@ -546,7 +549,7 @@ EOS
print "Warning: No Makefile!\n";
}
- if ($is_VMS) {
+ if (IS_VMS) {
_quote_args($pass_through);
@$pass_through = (
"/DESCRIPTION=$makefile",
@@ -604,12 +607,12 @@ sub just_pm_to_blib {
my ($last) = $mname =~ /([^:]+)$/;
my ($first) = $mname =~ /^([^:]+)/;
- my $pm_to_blib = $is_VMS ? 'pm_to_blib.ts' : 'pm_to_blib';
+ my $pm_to_blib = IS_VMS ? 'pm_to_blib.ts' : 'pm_to_blib';
foreach my $leaf (<*>) {
if (-d $leaf) {
$leaf =~ s/\.DIR\z//i
- if $is_VMS;
+ if IS_VMS;
next if $leaf =~ /\A(?:\.|\.\.|t|demo)\z/;
if ($leaf eq 'lib') {
++$has_lib;
@@ -623,7 +626,7 @@ sub just_pm_to_blib {
return $leaf
unless -f _;
$leaf =~ s/\.\z//
- if $is_VMS;
+ if IS_VMS;
# Makefile.PL is "safe" to ignore because we will only be called for
# directories that hold a Makefile.PL if they are in the exception list.
next
@@ -703,7 +706,7 @@ sub just_pm_to_blib {
print $fh "$0 has handled pm_to_blib directly\n";
close $fh
or die "Can't close '$pm_to_blib': $!";
- if ($is_Unix) {
+ if (IS_UNIX) {
# Fake the fallback cleanup
my $fallback
= join '', map {s!^\.\./\.\./!!; "rm -f $_\n"} sort values %pm;