diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/ExtUtils/MM_Any.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/ExtUtils/MM_Any.pm | 579 |
1 files changed, 372 insertions, 207 deletions
diff --git a/Master/tlpkg/tlperl/lib/ExtUtils/MM_Any.pm b/Master/tlpkg/tlperl/lib/ExtUtils/MM_Any.pm index 7679dc415a6..433a8dd7a31 100644 --- a/Master/tlpkg/tlperl/lib/ExtUtils/MM_Any.pm +++ b/Master/tlpkg/tlperl/lib/ExtUtils/MM_Any.pm @@ -1,7 +1,8 @@ package ExtUtils::MM_Any; use strict; -our $VERSION = '7.10_02'; +our $VERSION = '7.24'; +$VERSION = eval $VERSION; use Carp; use File::Spec; @@ -9,7 +10,7 @@ use File::Basename; BEGIN { our @ISA = qw(File::Spec); } # We need $Verbose -use ExtUtils::MakeMaker qw($Verbose); +use ExtUtils::MakeMaker qw($Verbose neatvalue _sprintf562); use ExtUtils::MakeMaker::Config; @@ -17,9 +18,10 @@ use ExtUtils::MakeMaker::Config; # So we don't have to keep calling the methods over and over again, # we have these globals to cache the values. Faster and shrtr. my $Curdir = __PACKAGE__->curdir; -my $Rootdir = __PACKAGE__->rootdir; -my $Updir = __PACKAGE__->updir; +#my $Updir = __PACKAGE__->updir; +my $METASPEC_URL = 'https://metacpan.org/pod/CPAN::Meta::Spec'; +my $METASPEC_V = 2; =head1 NAME @@ -348,6 +350,34 @@ sub _expand_macros { } +=head3 make_type + +Returns a suitable string describing the type of makefile being written. + +=cut + +# override if this isn't suitable! +sub make_type { return 'Unix-style'; } + + +=head3 stashmeta + + my @recipelines = $MM->stashmeta($text, $file); + +Generates a set of C<@recipelines> which will result in the literal +C<$text> ending up in literal C<$file> when the recipe is executed. Call +it once, with all the text you want in C<$file>. Make macros will not +be expanded, so the locations will be fixed at configure-time, not +at build-time. + +=cut + +sub stashmeta { + my($self, $text, $file) = @_; + $self->echo($text, $file, { allow_variables => 0, append => 0 }); +} + + =head3 echo my @commands = $MM->echo($text); @@ -367,7 +397,7 @@ all C<$>. Example of use: - my $make = map "\t$_\n", $MM->echo($text, $file); + my $make = join '', map "\t$_\n", $MM->echo($text, $file); =cut @@ -480,13 +510,14 @@ Usage might be something like: $oneliner = $MM->oneliner('print "Foo\n"'); $make = '$oneliner > somefile'; -All dollar signs must be doubled in the $perl_code if you expect them -to be interpreted normally, otherwise it will be considered a make -macro. Also remember to quote make macros else it might be used as a -bareword. For example: +Dollar signs in the $perl_code will be protected from make using the +C<quote_literal> method, unless they are recognised as being a make +variable, C<$(varname)>, in which case they will be left for make +to expand. Remember to quote make macros else it might be used as a +bareword. For example: # Assign the value of the $(VERSION_FROM) make macro to $vf. - $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"'); + $oneliner = $MM->oneliner('$vf = "$(VERSION_FROM)"'); Its currently very simple and may be expanded sometime in the figure to include more flexible code and switches. @@ -620,6 +651,11 @@ The blibdirs.ts target is deprecated. Depend on blibdirs instead. =cut +sub _xs_list_basenames { + my ($self) = @_; + map { (my $b = $_) =~ s/\.xs$//; $b } sort keys %{ $self->{XS} }; +} + sub blibdirs_target { my $self = shift; @@ -628,6 +664,14 @@ sub blibdirs_target { bin script man1dir man3dir ); + if ($self->{XSMULTI}) { + for my $ext ($self->_xs_list_basenames) { + my ($v, $d, $f) = File::Spec->splitpath($ext); + my @d = File::Spec->splitdir($d); + shift @d if $d[0] eq 'lib'; + push @dirs, $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f); + } + } my @exists = map { $_.'$(DFSEP).exists' } @dirs; @@ -666,6 +710,10 @@ clean :: clean_subdirs '); my @files = sort values %{$self->{XS}}; # .c files from *.xs files + push @files, map { + my $file = $_; + map { $file.$_ } $self->{OBJ_EXT}, qw(.def _def.old .bs .bso .exp .base); + } $self->_xs_list_basenames; my @dirs = qw(blib); # Normally these are all under blib but they might have been @@ -862,6 +910,110 @@ MAKE_FRAG } +=head3 xs_dlsyms_ext + +Returns file-extension for C<xs_make_dlsyms> method's output file, +including any "." character. + +=cut + +sub xs_dlsyms_ext { + die "Pure virtual method"; +} + +=head3 xs_dlsyms_extra + +Returns any extra text to be prepended to the C<$extra> argument of +C<xs_make_dlsyms>. + +=cut + +sub xs_dlsyms_extra { + ''; +} + +=head3 xs_dlsyms_iterator + +Iterates over necessary shared objects, calling C<xs_make_dlsyms> method +for each with appropriate arguments. + +=cut + +sub xs_dlsyms_iterator { + my ($self, $attribs) = @_; + if ($self->{XSMULTI}) { + my @m; + for my $ext ($self->_xs_list_basenames) { + my @parts = File::Spec->splitdir($ext); + shift @parts if $parts[0] eq 'lib'; + my $name = join '::', @parts; + push @m, $self->xs_make_dlsyms( + $attribs, + $ext . $self->xs_dlsyms_ext, + "$ext.xs", + $name, + $parts[-1], + {}, [], {}, [], + $self->xs_dlsyms_extra . q!, 'FILE' => ! . neatvalue($ext), + ); + } + return join "\n", @m; + } else { + return $self->xs_make_dlsyms( + $attribs, + $self->{BASEEXT} . $self->xs_dlsyms_ext, + 'Makefile.PL', + $self->{NAME}, + $self->{DLBASE}, + $attribs->{DL_FUNCS} || $self->{DL_FUNCS} || {}, + $attribs->{FUNCLIST} || $self->{FUNCLIST} || [], + $attribs->{IMPORTS} || $self->{IMPORTS} || {}, + $attribs->{DL_VARS} || $self->{DL_VARS} || [], + $self->xs_dlsyms_extra, + ); + } +} + +=head3 xs_make_dlsyms + + $self->xs_make_dlsyms( + \%attribs, # hashref from %attribs in caller + "$self->{BASEEXT}.def", # output file for Makefile target + 'Makefile.PL', # dependency + $self->{NAME}, # shared object's "name" + $self->{DLBASE}, # last ::-separated part of name + $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}, # various params + $attribs{FUNCLIST} || $self->{FUNCLIST} || [], + $attribs{IMPORTS} || $self->{IMPORTS} || {}, + $attribs{DL_VARS} || $self->{DL_VARS} || [], + # optional extra param that will be added as param to Mksymlists + ); + +Utility method that returns Makefile snippet to call C<Mksymlists>. + +=cut + +sub xs_make_dlsyms { + my ($self, $attribs, $target, $dep, $name, $dlbase, $funcs, $funclist, $imports, $vars, $extra) = @_; + my @m = ( + "\n$target: $dep\n", + q! $(PERLRUN) -MExtUtils::Mksymlists \\ + -e "Mksymlists('NAME'=>\"!, $name, + q!\", 'DLBASE' => '!,$dlbase, + # The above two lines quoted differently to work around + # a bug in the 4DOS/4NT command line interpreter. The visible + # result of the bug was files named q('extension_name',) *with the + # single quotes and the comma* in the extension build directories. + q!', 'DL_FUNCS' => !,neatvalue($funcs), + q!, 'FUNCLIST' => !,neatvalue($funclist), + q!, 'IMPORTS' => !,neatvalue($imports), + q!, 'DL_VARS' => !, neatvalue($vars) + ); + push @m, $extra if defined $extra; + push @m, qq!);"\n!; + join '', @m; +} + =head3 dynamic (o) Defines the dynamic target. @@ -873,7 +1025,7 @@ sub dynamic { my($self) = shift; ' -dynamic :: $(FIRST_MAKEFILE) $(BOOTSTRAP) $(INST_DYNAMIC) +dynamic :: $(FIRST_MAKEFILE) config $(INST_BOOT) $(INST_DYNAMIC) $(NOECHO) $(NOOP) '; } @@ -921,14 +1073,14 @@ sub manifypods_target { } my $manify = <<END; -manifypods : pure_all $dependencies +manifypods : pure_all config $dependencies END my @man_cmds; foreach my $section (qw(1 3)) { my $pods = $self->{"MAN${section}PODS"}; - my $p2m = sprintf <<CMD, $] > 5.008 ? " -u" : ""; - \$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)%s + my $p2m = sprintf <<'CMD', $section, $] > 5.008 ? " -u" : ""; + $(NOECHO) $(POD2MAN) --section=%s --perm_rw=$(PERM_RW)%s CMD push @man_cmds, $self->split_command($p2m, map {($_,$pods->{$_})} sort keys %$pods); } @@ -939,12 +1091,16 @@ CMD return $manify; } -sub _has_cpan_meta { - return eval { - require CPAN::Meta; - CPAN::Meta->VERSION(2.112150); - 1; - }; +{ + my $has_cpan_meta; + sub _has_cpan_meta { + return $has_cpan_meta if defined $has_cpan_meta; + return $has_cpan_meta = !!eval { + require CPAN::Meta; + CPAN::Meta->VERSION(2.112150); + 1; + }; + } } =head3 metafile_target @@ -966,34 +1122,18 @@ metafile : $(NOECHO) $(NOOP) MAKE_FRAG - my %metadata = $self->metafile_data( + my $metadata = $self->metafile_data( $self->{META_ADD} || {}, $self->{META_MERGE} || {}, ); - _fix_metadata_before_conversion( \%metadata ); - - # paper over validation issues, but still complain, necessary because - # there's no guarantee that the above will fix ALL errors - my $meta = eval { CPAN::Meta->create( \%metadata, { lazy_validation => 1 } ) }; - warn $@ if $@ and - $@ !~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/; + my $meta = $self->_fix_metadata_before_conversion( $metadata ); - # use the original metadata straight if the conversion failed - # or if it can't be stringified. - if( !$meta || - !eval { $meta->as_string( { version => "1.4" } ) } || - !eval { $meta->as_string } - ) - { - $meta = bless \%metadata, 'CPAN::Meta'; - } - - my @write_metayml = $self->echo( + my @write_metayml = $self->stashmeta( $meta->as_string({version => "1.4"}), 'META_new.yml' ); - my @write_metajson = $self->echo( - $meta->as_string(), 'META_new.json' + my @write_metajson = $self->stashmeta( + $meta->as_string({version => "2.0"}), 'META_new.json' ); my $metayml = join("\n\t", @write_metayml); @@ -1014,7 +1154,7 @@ MAKE_FRAG =head3 _fix_metadata_before_conversion - _fix_metadata_before_conversion( \%metadata ); + $mm->_fix_metadata_before_conversion( \%metadata ); Fixes errors in the metadata before it's handed off to CPAN::Meta for conversion. This hopefully results in something that can be used further @@ -1025,7 +1165,7 @@ on, no guarantee is made though. =cut sub _fix_metadata_before_conversion { - my ( $metadata ) = @_; + my ( $self, $metadata ) = @_; # we should never be called unless this already passed but # prefer to be defensive in case somebody else calls this @@ -1034,18 +1174,24 @@ sub _fix_metadata_before_conversion { my $bad_version = $metadata->{version} && !CPAN::Meta::Validator->new->version( 'version', $metadata->{version} ); - # just delete all invalid versions if( $bad_version ) { warn "Can't parse version '$metadata->{version}'\n"; $metadata->{version} = ''; } - my $validator = CPAN::Meta::Validator->new( $metadata ); - return if $validator->is_valid; - + my $validator2 = CPAN::Meta::Validator->new( $metadata ); + my @errors; + push @errors, $validator2->errors if !$validator2->is_valid; + my $validator14 = CPAN::Meta::Validator->new( + { + %$metadata, + 'meta-spec' => { version => 1.4 }, + } + ); + push @errors, $validator14->errors if !$validator14->is_valid; # fix non-camelcase custom resource keys (only other trick we know) - for my $error ( $validator->errors ) { + for my $error ( @errors ) { my ( $key ) = ( $error =~ /Custom resource '(.*)' must be in CamelCase./ ); next if !$key; @@ -1053,17 +1199,39 @@ sub _fix_metadata_before_conversion { ( my $new_key = $key ) =~ s/[^_a-zA-Z]//g; # if that doesn't work, uppercase first one - $new_key = ucfirst $new_key if !$validator->custom_1( $new_key ); + $new_key = ucfirst $new_key if !$validator14->custom_1( $new_key ); # copy to new key if that worked $metadata->{resources}{$new_key} = $metadata->{resources}{$key} - if $validator->custom_1( $new_key ); + if $validator14->custom_1( $new_key ); # and delete old one in any case delete $metadata->{resources}{$key}; } - return; + # paper over validation issues, but still complain, necessary because + # there's no guarantee that the above will fix ALL errors + my $meta = eval { CPAN::Meta->create( $metadata, { lazy_validation => 1 } ) }; + warn $@ if $@ and + $@ !~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/; + + # use the original metadata straight if the conversion failed + # or if it can't be stringified. + if( !$meta || + !eval { $meta->as_string( { version => $METASPEC_V } ) } || + !eval { $meta->as_string } + ) { + $meta = bless $metadata, 'CPAN::Meta'; + } + + my $now_license = $meta->as_struct({ version => 2 })->{license}; + if ($self->{LICENSE} and $self->{LICENSE} ne 'unknown' and + @{$now_license} == 1 and $now_license->[0] eq 'unknown' + ) { + warn "Invalid LICENSE value '$self->{LICENSE}' ignored\n"; + } + + $meta; } @@ -1104,10 +1272,10 @@ sub _hash_merge { =head3 metafile_data - my @metadata_pairs = $mm->metafile_data(\%meta_add, \%meta_merge); + my $metadata_hashref = $mm->metafile_data(\%meta_add, \%meta_merge); Returns the data which MakeMaker turns into the META.yml file -and the META.json file. +and the META.json file. It is always in version 2.0 of the format. Values of %meta_add will overwrite any existing metadata in those keys. %meta_merge will be merged with them. @@ -1118,48 +1286,59 @@ sub metafile_data { my $self = shift; my($meta_add, $meta_merge) = @_; + $meta_add ||= {}; + $meta_merge ||= {}; + + my $version = _normalize_version($self->{VERSION}); + my $release_status = ($version =~ /_/) ? 'unstable' : 'stable'; my %meta = ( # required - name => $self->{DISTNAME}, - version => _normalize_version($self->{VERSION}), abstract => $self->{ABSTRACT} || 'unknown', - license => $self->{LICENSE} || 'unknown', + author => defined($self->{AUTHOR}) ? $self->{AUTHOR} : ['unknown'], dynamic_config => 1, - - # optional - distribution_type => $self->{PM} ? 'module' : 'script', - - no_index => { - directory => [qw(t inc)] - }, - generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION", + license => [ $self->{LICENSE} || 'unknown' ], 'meta-spec' => { - url => 'http://module-build.sourceforge.net/META-spec-v1.4.html', - version => 1.4 + url => $METASPEC_URL, + version => $METASPEC_V, }, + name => $self->{DISTNAME}, + release_status => $release_status, + version => $version, + + # optional + no_index => { directory => [qw(t inc)] }, ); + $self->_add_requirements_to_meta(\%meta); - # The author key is required and it takes a list. - $meta{author} = defined $self->{AUTHOR} ? $self->{AUTHOR} : []; + if (!eval { require JSON::PP; require CPAN::Meta::Converter; CPAN::Meta::Converter->VERSION(2.141170) }) { + return \%meta; + } - { - my $vers = _metaspec_version( $meta_add, $meta_merge ); - my $method = $vers =~ m!^2! - ? '_add_requirements_to_meta_v2' - : '_add_requirements_to_meta_v1_4'; - %meta = $self->$method( %meta ); + # needs to be based on the original version + my $v1_add = _metaspec_version($meta_add) !~ /^2/; + + for my $frag ($meta_add, $meta_merge) { + $frag = CPAN::Meta::Converter->new($frag, default_version => "1.4")->upgrade_fragment; } + # if we upgraded a 1.x _ADD fragment, we gave it a prereqs key that + # will override all prereqs, which is more than the user asked for; + # instead, we'll go inside the prereqs and override all those while( my($key, $val) = each %$meta_add ) { - $meta{$key} = $val; + if ($v1_add and $key eq 'prereqs') { + $meta{$key}{$_} = $val->{$_} for keys %$val; + } elsif ($key ne 'meta-spec') { + $meta{$key} = $val; + } } while( my($key, $val) = each %$meta_merge ) { + next if $key eq 'meta-spec'; $self->_hash_merge(\%meta, $key, $val); } - return %meta; + return \%meta; } @@ -1167,84 +1346,61 @@ sub metafile_data { =cut +sub _add_requirements_to_meta { + my ( $self, $meta ) = @_; + # Check the original args so we can tell between the user setting it + # to an empty hash and it just being initialized. + $meta->{prereqs}{configure}{requires} = $self->{ARGS}{CONFIGURE_REQUIRES} + ? $self->{CONFIGURE_REQUIRES} + : { 'ExtUtils::MakeMaker' => 0, }; + $meta->{prereqs}{build}{requires} = $self->{ARGS}{BUILD_REQUIRES} + ? $self->{BUILD_REQUIRES} + : { 'ExtUtils::MakeMaker' => 0, }; + $meta->{prereqs}{test}{requires} = $self->{TEST_REQUIRES} + if $self->{ARGS}{TEST_REQUIRES}; + $meta->{prereqs}{runtime}{requires} = $self->{PREREQ_PM} + if $self->{ARGS}{PREREQ_PM}; + $meta->{prereqs}{runtime}{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION}) + if $self->{MIN_PERL_VERSION}; +} + +# spec version of given fragment - if not given, assume 1.4 sub _metaspec_version { - my ( $meta_add, $meta_merge ) = @_; - return $meta_add->{'meta-spec'}->{version} - if defined $meta_add->{'meta-spec'} - and defined $meta_add->{'meta-spec'}->{version}; - return $meta_merge->{'meta-spec'}->{version} - if defined $meta_merge->{'meta-spec'} - and defined $meta_merge->{'meta-spec'}->{version}; + my ( $meta ) = @_; + return $meta->{'meta-spec'}->{version} + if defined $meta->{'meta-spec'} + and defined $meta->{'meta-spec'}->{version}; return '1.4'; } sub _add_requirements_to_meta_v1_4 { - my ( $self, %meta ) = @_; - + my ( $self, $meta ) = @_; # Check the original args so we can tell between the user setting it # to an empty hash and it just being initialized. if( $self->{ARGS}{CONFIGURE_REQUIRES} ) { - $meta{configure_requires} = $self->{CONFIGURE_REQUIRES}; + $meta->{configure_requires} = $self->{CONFIGURE_REQUIRES}; } else { - $meta{configure_requires} = { + $meta->{configure_requires} = { 'ExtUtils::MakeMaker' => 0, }; } - if( $self->{ARGS}{BUILD_REQUIRES} ) { - $meta{build_requires} = $self->{BUILD_REQUIRES}; + $meta->{build_requires} = $self->{BUILD_REQUIRES}; } else { - $meta{build_requires} = { + $meta->{build_requires} = { 'ExtUtils::MakeMaker' => 0, }; } - if( $self->{ARGS}{TEST_REQUIRES} ) { - $meta{build_requires} = { - %{ $meta{build_requires} }, + $meta->{build_requires} = { + %{ $meta->{build_requires} }, %{ $self->{TEST_REQUIRES} }, }; } - - $meta{requires} = $self->{PREREQ_PM} + $meta->{requires} = $self->{PREREQ_PM} if defined $self->{PREREQ_PM}; - $meta{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION}) + $meta->{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION}) if $self->{MIN_PERL_VERSION}; - - return %meta; -} - -sub _add_requirements_to_meta_v2 { - my ( $self, %meta ) = @_; - - # Check the original args so we can tell between the user setting it - # to an empty hash and it just being initialized. - if( $self->{ARGS}{CONFIGURE_REQUIRES} ) { - $meta{prereqs}{configure}{requires} = $self->{CONFIGURE_REQUIRES}; - } else { - $meta{prereqs}{configure}{requires} = { - 'ExtUtils::MakeMaker' => 0, - }; - } - - if( $self->{ARGS}{BUILD_REQUIRES} ) { - $meta{prereqs}{build}{requires} = $self->{BUILD_REQUIRES}; - } else { - $meta{prereqs}{build}{requires} = { - 'ExtUtils::MakeMaker' => 0, - }; - } - - if( $self->{ARGS}{TEST_REQUIRES} ) { - $meta{prereqs}{test}{requires} = $self->{TEST_REQUIRES}; - } - - $meta{prereqs}{runtime}{requires} = $self->{PREREQ_PM} - if $self->{ARGS}{PREREQ_PM}; - $meta{prereqs}{runtime}{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION}) - if $self->{MIN_PERL_VERSION}; - - return %meta; } # Adapted from Module::Build::Base @@ -1253,7 +1409,7 @@ sub _normalize_version { $version = 0 unless defined $version; if ( ref $version eq 'version' ) { # version objects - $version = $version->is_qv ? $version->normal : $version->stringify; + $version = $version->stringify; } elsif ( $version =~ /^[^v][^.]*\.[^.]+\./ ) { # no leading v, multiple dots # normalize string tuples without "v": "1.2.3" -> "v1.2.3" @@ -1426,12 +1582,12 @@ sub distmeta_target { $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']), exit unless -e q{META.yml}; eval { maniadd({q{META.yml} => q{Module YAML meta-data (added by MakeMaker)}}) } - or print "Could not add META.yml to MANIFEST: $${'@'}\n" + or die "Could not add META.yml to MANIFEST: ${'@'}" CODE $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']) exit unless -f q{META.json}; eval { maniadd({q{META.json} => q{Module JSON meta-data (added by MakeMaker)}}) } - or print "Could not add META.json to MANIFEST: $${'@'}\n" + or die "Could not add META.json to MANIFEST: ${'@'}" CODE ); @@ -1464,21 +1620,15 @@ sub mymeta { my $v2 = 1; unless ( $mymeta ) { - my @metadata = $self->metafile_data( + $mymeta = $self->metafile_data( $self->{META_ADD} || {}, $self->{META_MERGE} || {}, ); - $mymeta = {@metadata}; $v2 = 0; } # Overwrite the non-configure dependency hashes - - my $method = $v2 - ? '_add_requirements_to_meta_v2' - : '_add_requirements_to_meta_v1_4'; - - $mymeta = { $self->$method( %$mymeta ) }; + $self->_add_requirements_to_meta($mymeta); $mymeta->{dynamic_config} = 0; @@ -1530,13 +1680,9 @@ sub write_mymeta { return unless _has_cpan_meta(); - _fix_metadata_before_conversion( $mymeta ); + my $meta_obj = $self->_fix_metadata_before_conversion( $mymeta ); - # this can still blow up - # not sure if i should just eval this and skip file creation if it - # blows up - my $meta_obj = CPAN::Meta->new( $mymeta, { lazy_validation => 1 } ); - $meta_obj->save( 'MYMETA.json' ); + $meta_obj->save( 'MYMETA.json', { version => "2.0" } ); $meta_obj->save( 'MYMETA.yml', { version => "1.4" } ); return 1; } @@ -1574,8 +1720,8 @@ sub realclean { } # Occasionally files are repeated several times from different sources - { my(%f) = map { ($_ => 1) } @files; @files = keys %f; } - { my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; } + { my(%f) = map { ($_ => 1) } @files; @files = sort keys %f; } + { my(%d) = map { ($_ => 1) } @dirs; @dirs = sort keys %d; } my $rm_cmd = join "\n\t", map { "$_" } $self->split_command('- $(RM_F)', @files); @@ -1584,7 +1730,7 @@ sub realclean { my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd; # Delete temporary files (via clean) and also delete dist files -realclean purge :: clean realclean_subdirs +realclean purge :: realclean_subdirs %s %s MAKE @@ -1606,28 +1752,20 @@ target to call realclean on any subdirectories which contain Makefiles. sub realclean_subdirs_target { my $self = shift; - - return <<'NOOP_FRAG' unless @{$self->{DIR}}; -realclean_subdirs : - $(NOECHO) $(NOOP) -NOOP_FRAG - - my $rclean = "realclean_subdirs :\n"; - + my @m = <<'EOF'; +# so clean is forced to complete before realclean_subdirs runs +realclean_subdirs : clean +EOF + return join '', @m, "\t\$(NOECHO) \$(NOOP)\n" unless @{$self->{DIR}}; foreach my $dir (@{$self->{DIR}}) { foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) { - my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2); -chdir '%s'; system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s'; + my $subrclean .= $self->oneliner(_sprintf562 <<'CODE', $dir, $makefile); +chdir '%1$s'; system '$(MAKE) $(USEMAKEFILE) %2$s realclean' if -f '%2$s'; CODE - - $rclean .= sprintf <<'RCLEAN', $subrclean; - - %s -RCLEAN - + push @m, "\t- $subrclean\n"; } } - - return $rclean; + return join '', @m; } @@ -1666,7 +1804,7 @@ sub distsignature_target { my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']); eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } - or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n" + or die "Could not add SIGNATURE to MANIFEST: ${'@'}" CODE my $sign_dist = $self->cd('$(DISTVNAME)' => 'cpansign -s'); @@ -1700,7 +1838,7 @@ sub special_targets { my $make_frag = <<'MAKE_FRAG'; .SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) -.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir +.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir pure_all subdirs clean_subdirs makemakerdflt manifypods realclean_subdirs subdirs_dynamic subdirs_pure_nolink subdirs_static subdirs-test_dynamic subdirs-test_static test_dynamic test_static MAKE_FRAG @@ -2291,7 +2429,7 @@ sub init_others { if ( $self->{OBJECT} ) { $self->{OBJECT} = join(" ", @{$self->{OBJECT}}) if ref $self->{OBJECT}; $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g; - } elsif ( $self->{MAGICXS} && @{$self->{O_FILES}||[]} ) { + } elsif ( ($self->{MAGICXS} || $self->{XSMULTI}) && @{$self->{O_FILES}||[]} ) { $self->{OBJECT} = join(" ", @{$self->{O_FILES}}); $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g; } else { @@ -2659,38 +2797,50 @@ sub find_tests { my $tests = $mm->find_tests_recursive; Returns a string suitable for feeding to the shell to return all -tests in t/ but recursively. +tests in t/ but recursively. Equivalent to + + my $tests = $mm->find_tests_recursive_in('t'); =cut sub find_tests_recursive { - my($self) = shift; - return '' unless -d 't'; + my $self = shift; + return $self->find_tests_recursive_in('t'); +} + +=head3 find_tests_recursive_in + + my $tests = $mm->find_tests_recursive_in($dir); + +Returns a string suitable for feeding to the shell to return all +tests in $dir recursively. + +=cut + +sub find_tests_recursive_in { + my($self, $dir) = @_; + return '' unless -d $dir; require File::Find; - my %testfiles; + my $base_depth = grep { $_ ne '' } File::Spec->splitdir( (File::Spec->splitpath($dir))[1] ); + my %depths; my $wanted = sub { return unless m!\.t$!; my ($volume,$directories,$file) = File::Spec->splitpath( $File::Find::name ); - my @dirs = File::Spec->splitdir( $directories ); - for ( @dirs ) { - next if $_ eq 't'; - unless ( $_ ) { - $_ = '*.t'; - next; - } - $_ = '*'; - } - my $testfile = join '/', @dirs; - $testfiles{ $testfile } = 1; + my $depth = grep { $_ ne '' } File::Spec->splitdir( $directories ); + $depth -= $base_depth; + $depths{ $depth } = 1; }; - File::Find::find( $wanted, 't' ); + File::Find::find( $wanted, $dir ); - return join ' ', sort keys %testfiles; + return join ' ', + map { $dir . '/*' x $_ . '.t' } + sort { $a <=> $b } + keys %depths; } =head3 extra_clean_files @@ -2764,6 +2914,39 @@ sub platform_constants { return ''; } +=head3 post_constants (o) + +Returns an empty string per default. Dedicated to overrides from +within Makefile.PL after all constants have been defined. + +=cut + +sub post_constants { + ""; +} + +=head3 post_initialize (o) + +Returns an empty string per default. Used in Makefile.PLs to add some +chunk of text to the Makefile after the object is initialized. + +=cut + +sub post_initialize { + ""; +} + +=head3 postamble (o) + +Returns an empty string. Can be used in Makefile.PLs to write some +text to the Makefile at the end. + +=cut + +sub postamble { + ""; +} + =begin private =head3 _PREREQ_PRINT @@ -2799,7 +2982,7 @@ sub _PREREQ_PRINT { Implements PRINT_PREREQ, a slightly different version of PREREQ_PRINT added by Redhat to, I think, support generating RPMs from Perl modules. -Should not include BUILD_REQUIRES as RPMs do not incluide them. +Should not include BUILD_REQUIRES as RPMs do not include them. Refactored out of MakeMaker->new(). @@ -2825,24 +3008,6 @@ sub _PRINT_PREREQ { =begin private -=head3 _all_prereqs - - my $prereqs = $self->_all_prereqs; - -Returns a hash ref of both PREREQ_PM and BUILD_REQUIRES. - -=end private - -=cut - -sub _all_prereqs { - my $self = shift; - - return { %{$self->{PREREQ_PM}}, %{$self->{BUILD_REQUIRES}} }; -} - -=begin private - =head3 _perl_header_files my $perl_header_files= $self->_perl_header_files; |