diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/ExtUtils/MM_Unix.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/ExtUtils/MM_Unix.pm | 162 |
1 files changed, 131 insertions, 31 deletions
diff --git a/Master/tlpkg/tlperl/lib/ExtUtils/MM_Unix.pm b/Master/tlpkg/tlperl/lib/ExtUtils/MM_Unix.pm index fe53be12efd..ce1292740f0 100644 --- a/Master/tlpkg/tlperl/lib/ExtUtils/MM_Unix.pm +++ b/Master/tlpkg/tlperl/lib/ExtUtils/MM_Unix.pm @@ -14,8 +14,8 @@ use ExtUtils::MakeMaker qw($Verbose neatvalue _sprintf562); # If we make $VERSION an our variable parse_version() breaks use vars qw($VERSION); -$VERSION = '7.34'; -$VERSION = eval $VERSION; ## no critic [BuiltinFunctions::ProhibitStringyEval] +$VERSION = '7.44'; +$VERSION =~ tr/_//d; require ExtUtils::MM_Any; our @ISA = qw(ExtUtils::MM_Any); @@ -37,6 +37,10 @@ BEGIN { grep( $^O eq $_, qw(bsdos interix dragonfly) ) ); $Is{Android} = $^O =~ /android/; + if ( $^O eq 'darwin' && $^X eq '/usr/bin/perl' ) { + my @osvers = split /\./, $Config{osvers}; + $Is{ApplCor} = ( $osvers[0] >= 18 ); + } } BEGIN { @@ -54,15 +58,15 @@ ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker =head1 SYNOPSIS -C<require ExtUtils::MM_Unix;> + require ExtUtils::MM_Unix; =head1 DESCRIPTION The methods provided by this package are designed to be used in -conjunction with ExtUtils::MakeMaker. When MakeMaker writes a +conjunction with L<ExtUtils::MakeMaker>. When MakeMaker writes a Makefile, it creates one or more objects that inherit their methods -from a package C<MM>. MM itself doesn't provide any methods, but it -ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating +from a package L<MM|ExtUtils::MM>. MM itself doesn't provide any methods, but +it ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating specific packages take the responsibility for all the methods provided by MM_Unix. We are trying to reduce the number of the necessary overrides by defining rather primitive operations within @@ -89,8 +93,8 @@ Not all of the methods below are overridable in a Makefile.PL. Overridable methods are marked as (o). All methods are overridable by a platform specific MM_*.pm file. -Cross-platform methods are being moved into MM_Any. If you can't find -something that used to be in here, look in MM_Any. +Cross-platform methods are being moved into L<MM_Any|ExtUtils::MM_Any>. +If you can't find something that used to be in here, look in MM_Any. =cut @@ -132,6 +136,10 @@ sub c_o { my $command = '$(CCCMD)'; my $flags = '$(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE)'; + if ( $Is{ApplCor} ) { + $flags =~ s/"-I(\$\(PERL_INC\))"/-iwithsysroot "$1"/; + } + if (my $cpp = $Config{cpprun}) { my $cpp_cmd = $self->const_cccmd; $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/; @@ -151,8 +159,11 @@ EOF my @exts = qw(c cpp cxx cc); push @exts, 'C' if !$Is{OS2} and !$Is{Win32} and !$Is{Dos}; #Case-specific $m_o = $self->{XSMULTI} ? $self->xs_obj_opt('$*$(OBJ_EXT)') : ''; + my $dbgout = $self->dbgoutflag; for my $ext (@exts) { - push @m, "\n.$ext\$(OBJ_EXT) :\n\t$command $flags \$*.$ext" . ( $m_o ? " $m_o" : '' ) . "\n"; + push @m, "\n.$ext\$(OBJ_EXT) :\n\t$command $flags " + .($dbgout?"$dbgout ":'') + ."\$*.$ext" . ( $m_o ? " $m_o" : '' ) . "\n"; } return join "", @m; } @@ -170,6 +181,16 @@ sub xs_obj_opt { "-o $output_file"; } +=item dbgoutflag + +Returns a CC flag that tells the CC to emit a separate debugging symbol file +when compiling an object file. + +=cut + +sub dbgoutflag { + ''; +} =item cflags (o) @@ -398,6 +419,7 @@ sub constants { INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB INST_MAN1DIR INST_MAN3DIR MAN1EXT MAN3EXT + MAN1SECTION MAN3SECTION INSTALLDIRS INSTALL_BASE DESTDIR PREFIX PERLPREFIX SITEPREFIX VENDORPREFIX ), @@ -461,12 +483,20 @@ MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})." MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})." "; + push @m, q{ +SDKROOT := $(shell xcrun --show-sdk-path) +PERL_SYSROOT = $(SDKROOT) +} if $Is{ApplCor} && $self->{'PERL_INC'} =~ m!^/System/Library/Perl/!; push @m, q{ # Where is the Config information that we are using/depend on -CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_INCDEP)$(DFSEP)config.h -} if -e $self->catfile( $self->{PERL_INC}, 'config.h' ); +CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_SYSROOT)$(PERL_INCDEP)$(DFSEP)config.h +} if $Is{ApplCor}; + push @m, q{ +# Where is the Config information that we are using/depend on +CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_INCDEP)$(DFSEP)config.h +} if -e $self->catfile( $self->{PERL_INC}, 'config.h' ) && !$Is{ApplCor}; push @m, qq{ # Where to build things @@ -939,6 +969,7 @@ sub dynamic_lib { my ($v, $d, $f) = File::Spec->splitpath($ext); my @d = File::Spec->splitdir($d); shift @d if $d[0] eq 'lib'; + pop @d if $d[$#d] eq ''; my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f); # Dynamic library names may need special handling. @@ -1090,7 +1121,6 @@ Finds the executables PERL and FULLPERL sub find_perl { my($self, $ver, $names, $dirs, $trace) = @_; - if ($trace >= 2){ print "Looking for perl $ver by these names: @$names @@ -1243,12 +1273,15 @@ sub _fixin_replace_shebang { my ( $self, $file, $line ) = @_; # Now figure out the interpreter name. - my ( $cmd, $arg ) = split ' ', $line, 2; - $cmd =~ s!^.*/!!; + my ( $origcmd, $arg ) = split ' ', $line, 2; + (my $cmd = $origcmd) =~ s!^.*/!!; # Now look (in reverse) for interpreter in absolute PATH (unless perl). my $interpreter; - if ( $cmd =~ m{^perl(?:\z|[^a-z])} ) { + if ( defined $ENV{PERL_MM_SHEBANG} && $ENV{PERL_MM_SHEBANG} eq "relocatable" ) { + $interpreter = "/usr/bin/env perl"; + } + elsif ( $cmd =~ m{^perl(?:\z|[^a-z])} ) { if ( $Config{startperl} =~ m,^\#!.*/perl, ) { $interpreter = $Config{startperl}; $interpreter =~ s,^\#!,,; @@ -1270,6 +1303,24 @@ sub _fixin_replace_shebang { $interpreter = $maybefile; } } + + # If the shebang is absolute and exists in PATH, but was not + # the first one found, leave it alone if it's actually the + # same file as first one. This avoids packages built on + # merged-/usr systems with /usr/bin before /bin in the path + # breaking when installed on systems without merged /usr + if ($origcmd ne $interpreter and $self->file_name_is_absolute($origcmd)) { + my $origdir = dirname($origcmd); + if ($self->maybe_command($origcmd) && grep { $_ eq $origdir } @absdirs) { + my ($odev, $oino) = stat $origcmd; + my ($idev, $iino) = stat $interpreter; + if ($odev == $idev && $oino == $iino) { + warn "$origcmd is the same as $interpreter, leaving alone" + if $Verbose; + $interpreter = $origcmd; + } + } + } } # Figure out how to invoke interpreter on this machine. @@ -1450,6 +1501,25 @@ sub init_MANPODS { $self->$init_method(); } } + + # logic similar to picking man${num}ext in perl's Configure script + foreach my $num (1,3) { + my $installdirs = uc $self->{INSTALLDIRS}; + $installdirs = '' if $installdirs eq 'PERL'; + my @mandirs = File::Spec->splitdir( $self->_expand_macros( + $self->{ "INSTALL${installdirs}MAN${num}DIR" } ) ); + my $mandir = pop @mandirs; + my $section = $num; + + foreach ($num, "${num}p", "${num}pm", qw< l n o C L >, "L$num") { + if ( $mandir =~ /^(?:man|cat)$_$/ ) { + $section = $_; + last; + } + } + + $self->{"MAN${num}SECTION"} = $section; + } } @@ -2043,6 +2113,11 @@ sub init_PERL { # already escaped spaces. $self->{FULLPERL} =~ tr/"//d if $Is{VMS}; + # `dmake` can fail for image (aka, executable) names which start with double-quotes + # * push quote inward by at least one character (or the drive prefix, if present) + # * including any initial directory separator preserves the `file_name_is_absolute` property + $self->{FULLPERL} =~ s/^"(\S(:\\|:)?)/$1"/ if $self->is_make_type('dmake'); + # Little hack to get around VMS's find_perl putting "MCR" in front # sometimes. $self->{ABSPERL} = $self->{PERL}; @@ -2065,6 +2140,11 @@ sub init_PERL { # already escaped spaces. $self->{PERL} =~ tr/"//d if $Is{VMS}; + # `dmake` can fail for image (aka, executable) names which start with double-quotes + # * push quote inward by at least one character (or the drive prefix, if present) + # * including any initial directory separator preserves the `file_name_is_absolute` property + $self->{PERL} =~ s/^"(\S(:\\|:)?)/$1"/ if $self->is_make_type('dmake'); + # Are we building the core? $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE}; $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE}; @@ -2168,6 +2248,7 @@ sub init_xs { my ($v, $d, $f) = File::Spec->splitpath($ext); my @d = File::Spec->splitdir($d); shift @d if defined $d[0] and $d[0] eq 'lib'; + pop @d if $d[$#d] eq ''; my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f); my $instfile = $self->catfile($instdir, $f); push @statics, "$instfile\$(LIB_EXT)"; @@ -2738,14 +2819,14 @@ sub _find_static_libs { Called by a utility method of makeaperl. Checks whether a given file is an XS library by seeing whether it defines any symbols starting -with C<boot_>. +with C<boot_> (with an optional leading underscore - needed on MacOS). =cut sub xs_static_lib_is_xs { my ($self, $libfile) = @_; my $devnull = File::Spec->devnull; - return `nm $libfile 2>$devnull` =~ /\bboot_/; + return `nm $libfile 2>$devnull` =~ /\b_?boot_/; } =item makefile (o) @@ -2872,7 +2953,7 @@ sub parse_abstract { } close $fh; - if ( $pod_encoding and !( $] < 5.008 or !$Config{useperlio} ) ) { + if ( $pod_encoding and !( "$]" < 5.008 or !$Config{useperlio} ) ) { # Have to wrap in an eval{} for when running under PERL_CORE # Encode isn't available during build phase and parsing # ABSTRACT isn't important there @@ -2894,7 +2975,7 @@ It will return the string "undef" if it can't figure out what $VERSION is. $VERSION should be for all to see, so C<our $VERSION> or plain $VERSION are okay, but C<my $VERSION> is not. -C<<package Foo VERSION>> is also checked for. The first version +C<package Foo VERSION> is also checked for. The first version declaration found is used, but this may change as it differs from how Perl does it. @@ -3151,7 +3232,7 @@ PPD_PERLVERS } my $archname = $Config{archname}; - if ($] >= 5.008) { + if ("$]" >= 5.008) { # archname did not change from 5.6 to 5.8, but those versions may # not be not binary compatible so now we append the part of the # version that changes when binary compatibility may change @@ -3268,9 +3349,11 @@ sub processPL { my $m = ''; foreach my $plfile (sort keys %$pl_files) { - my $list = ref($pl_files->{$plfile}) - ? $pl_files->{$plfile} - : [$pl_files->{$plfile}]; + my $targets = $pl_files->{$plfile}; + my $list = + ref($targets) eq 'HASH' ? [ sort keys %$targets ] : + ref($targets) eq 'ARRAY' ? $pl_files->{$plfile} : + [$pl_files->{$plfile}]; foreach my $target (@$list) { if( $Is{VMS} ) { @@ -3294,13 +3377,27 @@ sub processPL { $perlrun = 'PERLRUNINST'; } + my $extra_inputs = ''; + if( ref($targets) eq 'HASH' ) { + my $inputs = ref($targets->{$target}) + ? $targets->{$target} + : [$targets->{$target}]; + + for my $input (@$inputs) { + if( $Is{VMS} ) { + $input = vmsify($self->eliminate_macros($input)); + } + $extra_inputs .= ' '.$input; + } + } + $m .= <<MAKE_FRAG; pure_all :: $target \$(NOECHO) \$(NOOP) -$target :: $plfile $pm_dep - \$($perlrun) $plfile $target +$target :: $plfile $pm_dep $extra_inputs + \$($perlrun) $plfile $target $extra_inputs MAKE_FRAG } @@ -3432,7 +3529,7 @@ sub escape_newlines { =item max_exec_len -Using POSIX::ARG_MAX. Otherwise falling back to 4096. +Using L<POSIX>::ARG_MAX. Otherwise falling back to 4096. =cut @@ -3957,13 +4054,15 @@ sub xs_o { my ($self) = @_; return '' unless $self->needs_linking(); my $m_o = $self->{XSMULTI} ? $self->xs_obj_opt('$*$(OBJ_EXT)') : ''; + my $dbgout = $self->dbgoutflag; + $dbgout = $dbgout ? "$dbgout " : ''; my $frag = ''; # dmake makes noise about ambiguous rule - $frag .= sprintf <<'EOF', $m_o unless $self->is_make_type('dmake'); + $frag .= sprintf <<'EOF', $dbgout, $m_o unless $self->is_make_type('dmake'); .xs$(OBJ_EXT) : $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc $(MV) $*.xsc $*.c - $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c %s + $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) %s$*.c %s EOF if ($self->{XSMULTI}) { for my $ext ($self->_xs_list_basenames) { @@ -3977,16 +4076,17 @@ EOF $self->_xsbuild_replace_macro($cccmd, 'xs', $ext, 'INC'); my $define = '$(DEFINE)'; $self->_xsbuild_replace_macro($define, 'xs', $ext, 'DEFINE'); - # 1 2 3 4 - $frag .= _sprintf562 <<'EOF', $ext, $cccmd, $m_o, $define; + # 1 2 3 4 5 + $frag .= _sprintf562 <<'EOF', $ext, $cccmd, $m_o, $define, $dbgout; %1$s$(OBJ_EXT): %1$s.xs $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc $(MV) $*.xsc $*.c - %2$s $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) %4$s $*.c %3$s + %2$s $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) %4$s %5$s$*.c %3$s EOF } } + $frag =~ s/"-I(\$\(PERL_INC\))"/-iwithsysroot "$1"/sg if $Is{ApplCor}; $frag; } |