X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExtUtils%2FMM_Any.pm;h=a7afe2069cf47a7e44b3402bc0256fccf6ed0117;hb=cb06ebec412ca5c62617b8007098bd39019a09df;hp=4d89b0d04b6da522c0a1ceb4973f9c0fbb176afb;hpb=3c4b39bee8832007b7e91bfce8701d34cacab411;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/ExtUtils/MM_Any.pm b/lib/ExtUtils/MM_Any.pm index 4d89b0d..a7afe20 100644 --- a/lib/ExtUtils/MM_Any.pm +++ b/lib/ExtUtils/MM_Any.pm @@ -1,11 +1,12 @@ package ExtUtils::MM_Any; use strict; -use vars qw($VERSION @ISA); -$VERSION = '0.13'; +our $VERSION = '6.55_02'; +use Carp; use File::Spec; -BEGIN { @ISA = qw(File::Spec); } +use File::Basename; +BEGIN { our @ISA = qw(File::Spec); } # We need $Verbose use ExtUtils::MakeMaker qw($Verbose); @@ -73,7 +74,7 @@ Windows, VMS, OS/2, etc...) and the rest are sub families. Some examples: Cygwin98 ('Unix', 'Cygwin', 'Cygwin9x') - Windows NT ('Win32', 'WinNT') + Windows ('Win32') Win98 ('Win32', 'Win9x') Linux ('Unix', 'Linux') MacOS X ('Unix', 'Darwin', 'MacOS', 'MacOS X') @@ -108,6 +109,22 @@ sub os_flavor_is { } +=head3 can_load_xs + + my $can_load_xs = $self->can_load_xs; + +Returns true if we have the ability to load XS. + +This is important because miniperl, used to build XS modules in the +core, can not load XS. + +=cut + +sub can_load_xs { + return defined &DynaLoader::boot_DynaLoader ? 1 : 0; +} + + =head3 split_command my @cmds = $MM->split_command($cmd, @args); @@ -144,8 +161,8 @@ sub split_command { # newline. chomp $cmd; - # set aside 20% for macro expansion. - my $len_left = int($self->max_exec_len * 0.80); + # set aside 30% for macro expansion. + my $len_left = int($self->max_exec_len * 0.70); $len_left -= length $self->_expand_macros($cmd); do { @@ -235,6 +252,24 @@ sub wraplist { } +=head3 maketext_filter + + my $filter_make_text = $mm->maketext_filter($make_text); + +The text of the Makefile is run through this method before writing to +disk. It allows systems a chance to make portability fixes to the +Makefile. + +By default it does nothing. + +This method is protected and not intended to be called outside of +MakeMaker. + +=cut + +sub maketext_filter { return $_[1] } + + =head3 cd I my $subdir_cmd = $MM->cd($subdir, @cmds); @@ -324,7 +359,28 @@ this is the max size of a shell command line. $self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes. +=head3 make + + my $make = $MM->make; + +Returns the make variant we're generating the Makefile for. This attempts +to do some normalization on the information from %Config or the user. + +=cut + +sub make { + my $self = shift; + + my $make = lc $self->{MAKE}; + + # Truncate anything like foomake6 to just foomake. + $make =~ s/^(\w+make).*/$1/; + # Turn gnumake into gmake. + $make =~ s/^gnu/g/; + + return $make; +} =head2 Targets @@ -506,7 +562,7 @@ CODE my $make_frag = $mm->dir_target(@directories); Generates targets to create the specified directories and set its -permission to 0755. +permission to PERM_DIR. Because depending on a directory to just ensure it exists doesn't work too well (the modified time changes too often) dir_target() creates a @@ -526,7 +582,7 @@ sub dir_target { $make .= sprintf <<'MAKE', ($dir) x 7; %s$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) %s - $(NOECHO) $(CHMOD) 755 %s + $(NOECHO) $(CHMOD) $(PERM_DIR) %s $(NOECHO) $(TOUCH) %s$(DFSEP).exists MAKE @@ -626,7 +682,7 @@ confused or something gets snuck in before the real 'all' target. sub makemakerdflt_target { return <<'MAKE_FRAG'; -makemakerdflt: all +makemakerdflt : all $(NOECHO) $(NOOP) MAKE_FRAG @@ -654,10 +710,6 @@ sub manifypods_target { $dependencies .= " \\\n\t$name"; } - foreach my $name (keys %{$self->{MAN3PODS}}) { - $dependencies .= " \\\n\t$name" - } - my $manify = <{NO_META}; -metafile: +metafile : $(NOECHO) $(NOOP) MAKE_FRAG - my $prereq_pm = ''; - foreach my $mod ( sort { lc $a cmp lc $b } keys %{$self->{PREREQ_PM}} ) { - my $ver = $self->{PREREQ_PM}{$mod}; - $prereq_pm .= sprintf " %-30s %s\n", "$mod:", $ver; - } - - my $meta = <{DISTNAME} -version: $self->{VERSION} -version_from: $self->{VERSION_FROM} -installdirs: $self->{INSTALLDIRS} -requires: -$prereq_pm -distribution_type: module -generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION -YAML - + my @metadata = $self->metafile_data( + $self->{META_ADD} || {}, + $self->{META_MERGE} || {}, + ); + my $meta = $self->metafile_file(@metadata); my @write_meta = $self->echo($meta, 'META_new.yml'); return sprintf <<'MAKE_FRAG', join("\n\t", @write_meta); @@ -731,6 +766,297 @@ MAKE_FRAG } +=begin private + +=head3 _sort_pairs + + my @pairs = _sort_pairs($sort_sub, \%hash); + +Sorts the pairs of a hash based on keys ordered according +to C<$sort_sub>. + +=end private + +=cut + +sub _sort_pairs { + my $sort = shift; + my $pairs = shift; + return map { $_ => $pairs->{$_} } + sort $sort + keys %$pairs; +} + + +# Taken from Module::Build::Base +sub _hash_merge { + my ($self, $h, $k, $v) = @_; + if (ref $h->{$k} eq 'ARRAY') { + push @{$h->{$k}}, ref $v ? @$v : $v; + } elsif (ref $h->{$k} eq 'HASH') { + $self->_hash_merge($h->{$k}, $_, $v->{$_}) foreach keys %$v; + } else { + $h->{$k} = $v; + } +} + + +=head3 metafile_data + + my @metadata_pairs = $mm->metafile_data(\%meta_add, \%meta_merge); + +Returns the data which MakeMaker turns into the META.yml file. + +Values of %meta_add will overwrite any existing metadata in those +keys. %meta_merge will be merged with them. + +=cut + +sub metafile_data { + my $self = shift; + my($meta_add, $meta_merge) = @_; + + # The order in which standard meta keys should be written. + my @meta_order = qw( + name + version + abstract + author + license + distribution_type + + configure_requires + build_requires + requires + + resources + + provides + no_index + + generated_by + meta-spec + ); + + # Check the original args so we can tell between the user setting it + # to an empty hash and it just being initialized. + my $configure_requires; + if( $self->{ARGS}{CONFIGURE_REQUIRES} ) { + $configure_requires = $self->{CONFIGURE_REQUIRES}; + } else { + $configure_requires = { + 'ExtUtils::MakeMaker' => 0, + }; + } + my $build_requires; + if( $self->{ARGS}{BUILD_REQUIRES} ) { + $build_requires = $self->{BUILD_REQUIRES}; + } else { + $build_requires = { + 'ExtUtils::MakeMaker' => 0, + }; + } + + my %meta = ( + name => $self->{DISTNAME}, + version => $self->{VERSION}, + abstract => $self->{ABSTRACT}, + license => $self->{LICENSE} || 'unknown', + distribution_type => $self->{PM} ? 'module' : 'script', + + configure_requires => $configure_requires, + + build_requires => $build_requires, + + no_index => { + directory => [qw(t inc)] + }, + + generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION", + 'meta-spec' => { + url => 'http://module-build.sourceforge.net/META-spec-v1.4.html', + version => 1.4 + }, + ); + + # The author key is required and it takes a list. + $meta{author} = defined $self->{AUTHOR} ? [$self->{AUTHOR}] : []; + + $meta{requires} = $self->{PREREQ_PM} if defined $self->{PREREQ_PM}; + $meta{requires}{perl} = $self->{MIN_PERL_VERSION} if $self->{MIN_PERL_VERSION}; + + while( my($key, $val) = each %$meta_add ) { + $meta{$key} = $val; + } + + while( my($key, $val) = each %$meta_merge ) { + $self->_hash_merge(\%meta, $key, $val); + } + + my @meta_pairs; + + # Put the standard keys first in the proper order. + for my $key (@meta_order) { + next unless exists $meta{$key}; + + push @meta_pairs, $key, delete $meta{$key}; + } + + # Then tack everything else onto the end, alpha sorted. + for my $key (sort {lc $a cmp lc $b} keys %meta) { + push @meta_pairs, $key, $meta{$key}; + } + + return @meta_pairs +} + +=begin private + +=head3 _dump_hash + + $yaml = _dump_hash(\%options, %hash); + +Implements a fake YAML dumper for a hash given +as a list of pairs. No quoting/escaping is done. Keys +are supposed to be strings. Values are undef, strings, +hash refs or array refs of strings. + +Supported options are: + + delta => STR - indentation delta + use_header => BOOL - whether to include a YAML header + indent => STR - a string of spaces + default: '' + + max_key_length => INT - maximum key length used to align + keys and values of the same hash + default: 20 + key_sort => CODE - a sort sub + It may be undef, which means no sorting by keys + default: sub { lc $a cmp lc $b } + + customs => HASH - special options for certain keys + (whose values are hashes themselves) + may contain: max_key_length, key_sort, customs + +=end private + +=cut + +sub _dump_hash { + croak "first argument should be a hash ref" unless ref $_[0] eq 'HASH'; + my $options = shift; + my %hash = @_; + + # Use a list to preserve order. + my @pairs; + + my $k_sort + = exists $options->{key_sort} ? $options->{key_sort} + : sub { lc $a cmp lc $b }; + if ($k_sort) { + croak "'key_sort' should be a coderef" unless ref $k_sort eq 'CODE'; + @pairs = _sort_pairs($k_sort, \%hash); + } else { # list of pairs, no sorting + @pairs = @_; + } + + my $yaml = $options->{use_header} ? "--- #YAML:1.0\n" : ''; + my $indent = $options->{indent} || ''; + my $k_length = min( + ($options->{max_key_length} || 20), + max(map { length($_) + 1 } grep { !ref $hash{$_} } keys %hash) + ); + my $customs = $options->{customs} || {}; + + # printf format for key + my $k_format = "%-${k_length}s"; + + while( @pairs ) { + my($key, $val) = splice @pairs, 0, 2; + $val = '~' unless defined $val; + if(ref $val eq 'HASH') { + if ( keys %$val ) { + my %k_options = ( # options for recursive call + delta => $options->{delta}, + use_header => 0, + indent => $indent . $options->{delta}, + ); + if (exists $customs->{$key}) { + my %k_custom = %{$customs->{$key}}; + foreach my $k qw(key_sort max_key_length customs) { + $k_options{$k} = $k_custom{$k} if exists $k_custom{$k}; + } + } + $yaml .= $indent . "$key:\n" + . _dump_hash(\%k_options, %$val); + } + else { + $yaml .= $indent . "$key: {}\n"; + } + } + elsif (ref $val eq 'ARRAY') { + if( @$val ) { + $yaml .= $indent . "$key:\n"; + + for (@$val) { + croak "only nested arrays of non-refs are supported" if ref $_; + $yaml .= $indent . $options->{delta} . "- $_\n"; + } + } + else { + $yaml .= $indent . "$key: []\n"; + } + } + elsif( ref $val and !blessed($val) ) { + croak "only nested hashes, arrays and objects are supported"; + } + else { # if it's an object, just stringify it + $yaml .= $indent . sprintf "$k_format %s\n", "$key:", $val; + } + }; + + return $yaml; + +} + +sub blessed { + return eval { $_[0]->isa("UNIVERSAL"); }; +} + +sub max { + return (sort { $b <=> $a } @_)[0]; +} + +sub min { + return (sort { $a <=> $b } @_)[0]; +} + +=head3 metafile_file + + my $meta_yml = $mm->metafile_file(@metadata_pairs); + +Turns the @metadata_pairs into YAML. + +This method does not implement a complete YAML dumper, being limited +to dump a hash with values which are strings, undef's or nested hashes +and arrays of strings. No quoting/escaping is done. + +=cut + +sub metafile_file { + my $self = shift; + + my %dump_options = ( + use_header => 1, + delta => ' ' x 4, + key_sort => undef, + ); + return _dump_hash(\%dump_options, @_); + +} + + =head3 distmeta_target my $make_frag = $mm->distmeta_target; @@ -938,6 +1264,28 @@ MAKE_FRAG Methods which help initialize the MakeMaker object and macros. +=head3 init_ABSTRACT + + $mm->init_ABSTRACT + +=cut + +sub init_ABSTRACT { + my $self = shift; + + if( $self->{ABSTRACT_FROM} and $self->{ABSTRACT} ) { + warn "Both ABSTRACT_FROM and ABSTRACT are set. ". + "Ignoring ABSTRACT_FROM.\n"; + return; + } + + if ($self->{ABSTRACT_FROM}){ + $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or + carp "WARNING: Setting ABSTRACT via file ". + "'$self->{ABSTRACT_FROM}' failed\n"; + } +} + =head3 init_INST $mm->init_INST; @@ -1000,12 +1348,12 @@ INSTALLDIRS) and *PREFIX. sub init_INSTALL { my($self) = shift; - if( $self->{ARGS}{INSTALLBASE} and $self->{ARGS}{PREFIX} ) { - die "Only one of PREFIX or INSTALLBASE can be given. Not both.\n"; + if( $self->{ARGS}{INSTALL_BASE} and $self->{ARGS}{PREFIX} ) { + die "Only one of PREFIX or INSTALL_BASE can be given. Not both.\n"; } - if( $self->{ARGS}{INSTALLBASE} ) { - $self->init_INSTALL_from_INSTALLBASE; + if( $self->{ARGS}{INSTALL_BASE} ) { + $self->init_INSTALL_from_INSTALL_BASE; } else { $self->init_INSTALL_from_PREFIX; @@ -1045,12 +1393,19 @@ sub init_INSTALL_from_PREFIX { $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)' unless $Config{installsitebin}; + $self->{INSTALLSITESCRIPT} ||= '$(INSTALLSCRIPT)' + unless $Config{installsitescript}; unless( $Config{installvendorbin} ) { $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix} ? $Config{installbin} : ''; } + unless( $Config{installvendorscript} ) { + $self->{INSTALLVENDORSCRIPT} ||= $Config{usevendorprefix} + ? $Config{installscript} + : ''; + } my $iprefix = $Config{installprefixexp} || $Config{installprefix} || @@ -1111,6 +1466,12 @@ sub init_INSTALL_from_PREFIX { script => { s => $iprefix, t => 'perl', d => 'bin' }, + vendorscript=> { s => $vprefix, + t => 'vendor', + d => 'bin' }, + sitescript => { s => $sprefix, + t => 'site', + d => 'bin' }, ); my %man_layouts = @@ -1218,9 +1579,9 @@ sub init_INSTALL_from_PREFIX { } -=head3 init_from_INSTALLBASE +=head3 init_from_INSTALL_BASE - $mm->init_from_INSTALLBASE + $mm->init_from_INSTALL_BASE =cut @@ -1233,11 +1594,11 @@ my %map = ( ); $map{script} = $map{bin}; -sub init_INSTALL_from_INSTALLBASE { +sub init_INSTALL_from_INSTALL_BASE { my $self = shift; @{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} = - '$(INSTALLBASE)'; + '$(INSTALL_BASE)'; my %install; foreach my $thing (keys %map) { @@ -1246,14 +1607,13 @@ sub init_INSTALL_from_INSTALLBASE { my $key = "INSTALL".$dir.$uc_thing; $install{$key} ||= - $self->catdir('$(INSTALLBASE)', @{$map{$thing}}); + $self->catdir('$(INSTALL_BASE)', @{$map{$thing}}); } } # Adjust for variable quirks. $install{INSTALLARCHLIB} ||= delete $install{INSTALLARCH}; $install{INSTALLPRIVLIB} ||= delete $install{INSTALLLIB}; - delete @install{qw(INSTALLVENDORSCRIPT INSTALLSITESCRIPT)}; foreach my $key (keys %install) { $self->{$key} ||= $install{$key}; @@ -1305,9 +1665,8 @@ sub init_VERSION { if ($self->{VERSION_FROM}){ $self->{VERSION} = $self->parse_version($self->{VERSION_FROM}); if( $self->{VERSION} eq 'undef' ) { - require Carp; - Carp::carp("WARNING: Setting VERSION via file ". - "'$self->{VERSION_FROM}' failed\n"); + carp("WARNING: Setting VERSION via file ". + "'$self->{VERSION_FROM}' failed\n"); } } @@ -1338,7 +1697,7 @@ sub init_VERSION { } -=head3 init_others I +=head3 init_others $MM->init_others(); @@ -1360,8 +1719,7 @@ Defines at least these macros. MAKEFILE_OLD MAKE_APERL_FILE File used by MAKE_APERL - SHELL Program used to run - shell commands + SHELL Program used to run shell commands ECHO Print text adding a newline on the end RM_F Remove a file @@ -1370,12 +1728,163 @@ Defines at least these macros. TEST_F Test for a file's existence CP Copy a file MV Move a file - CHMOD Change permissions on a - file + CHMOD Change permissions on a file + FALSE Exit with non-zero + TRUE Exit with zero UMASK_NULL Nullify umask DEV_NULL Suppress all command output +=cut + +sub init_others { + my $self = shift; + + $self->{ECHO} ||= $self->oneliner('print qq{@ARGV}', ['-l']); + $self->{ECHO_N} ||= $self->oneliner('print qq{@ARGV}'); + + $self->{TOUCH} ||= $self->oneliner('touch', ["-MExtUtils::Command"]); + $self->{CHMOD} ||= $self->oneliner('chmod', ["-MExtUtils::Command"]); + $self->{RM_F} ||= $self->oneliner('rm_f', ["-MExtUtils::Command"]); + $self->{RM_RF} ||= $self->oneliner('rm_rf', ["-MExtUtils::Command"]); + $self->{TEST_F} ||= $self->oneliner('test_f', ["-MExtUtils::Command"]); + $self->{FALSE} ||= $self->oneliner('exit 1'); + $self->{TRUE} ||= $self->oneliner('exit 0'); + + $self->{MKPATH} ||= $self->oneliner('mkpath', ["-MExtUtils::Command"]); + + $self->{CP} ||= $self->oneliner('cp', ["-MExtUtils::Command"]); + $self->{MV} ||= $self->oneliner('mv', ["-MExtUtils::Command"]); + + $self->{MOD_INSTALL} ||= + $self->oneliner(<<'CODE', ['-MExtUtils::Install']); +install([ from_to => {@ARGV}, verbose => '$(VERBINST)', uninstall_shadows => '$(UNINST)', dir_mode => '$(PERM_DIR)' ]); +CODE + $self->{DOC_INSTALL} ||= $self->oneliner('perllocal_install', ["-MExtUtils::Command::MM"]); + $self->{UNINSTALL} ||= $self->oneliner('uninstall', ["-MExtUtils::Command::MM"]); + $self->{WARN_IF_OLD_PACKLIST} ||= + $self->oneliner('warn_if_old_packlist', ["-MExtUtils::Command::MM"]); + $self->{FIXIN} ||= $self->oneliner('MY->fixin(shift)', ["-MExtUtils::MY"]); + $self->{EQUALIZE_TIMESTAMP} ||= $self->oneliner('eqtime', ["-MExtUtils::Command"]); + + $self->{UNINST} ||= 0; + $self->{VERBINST} ||= 0; + + $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile'; + $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE}; + $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old'; + $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl'; + + # Not everybody uses -f to indicate "use this Makefile instead" + $self->{USEMAKEFILE} ||= '-f'; + + # Some makes require a wrapper around macros passed in on the command + # line. + $self->{MACROSTART} ||= ''; + $self->{MACROEND} ||= ''; + + $self->{SHELL} ||= $Config{sh}; + + # UMASK_NULL is not used by MakeMaker but some CPAN modules + # make use of it. + $self->{UMASK_NULL} ||= "umask 0"; + + # Not the greatest default, but its something. + $self->{DEV_NULL} ||= "> /dev/null 2>&1"; + + $self->{NOOP} ||= '$(TRUE)'; + $self->{NOECHO} = '@' unless defined $self->{NOECHO}; + + $self->{LD_RUN_PATH} = ""; + + $self->{LIBS} = $self->_fix_libs($self->{LIBS}); + + # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS} + foreach my $libs ( @{$self->{LIBS}} ){ + $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace + my(@libs) = $self->extliblist($libs); + if ($libs[0] or $libs[1] or $libs[2]){ + # LD_RUN_PATH now computed by ExtUtils::Liblist + ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, + $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs; + last; + } + } + + if ( $self->{OBJECT} ) { + $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g; + } else { + # init_dirscan should have found out, if we have C files + $self->{OBJECT} = ""; + $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]}; + } + $self->{OBJECT} =~ s/\n+/ \\\n\t/g; + + $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : ""; + $self->{PERLMAINCC} ||= '$(CC)'; + $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM}; + + # Sanity check: don't define LINKTYPE = dynamic if we're skipping + # the 'dynamic' section of MM. We don't have this problem with + # 'static', since we either must use it (%Config says we can't + # use dynamic loading) or the caller asked for it explicitly. + if (!$self->{LINKTYPE}) { + $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'} + ? 'static' + : ($Config{usedl} ? 'dynamic' : 'static'); + } + + return 1; +} + + +# Lets look at $self->{LIBS} carefully: It may be an anon array, a string or +# undefined. In any case we turn it into an anon array +sub _fix_libs { + my($self, $libs) = @_; + + return !defined $libs ? [''] : + !ref $libs ? [$libs] : + !defined $libs->[0] ? [''] : + $libs ; +} + + +=head3 tools_other + + my $make_frag = $MM->tools_other; + +Returns a make fragment containing definitions for the macros init_others() +initializes. + +=cut + +sub tools_other { + my($self) = shift; + my @m; + + # We set PM_FILTER as late as possible so it can see all the earlier + # on macro-order sensitive makes such as nmake. + for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH + UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP + FALSE TRUE + ECHO ECHO_N + UNINST VERBINST + MOD_INSTALL DOC_INSTALL UNINSTALL + WARN_IF_OLD_PACKLIST + MACROSTART MACROEND + USEMAKEFILE + PM_FILTER + FIXIN + } ) + { + next unless defined $self->{$tool}; + push @m, "$tool = $self->{$tool}\n"; + } + + return join "", @m; +} + =head3 init_DIRFILESEP I @@ -1434,7 +1943,19 @@ sub init_platform { } +=head3 init_MAKE + + $mm->init_MAKE + +Initialize MAKE from either a MAKE environment variable or $Config{make}. + +=cut + +sub init_MAKE { + my $self = shift; + $self->{MAKE} ||= $ENV{MAKE} || $Config{make}; +} =head2 Tools @@ -1556,6 +2077,59 @@ MAKE_FRAG } +=head3 arch_check + + my $arch_ok = $mm->arch_check( + $INC{"Config.pm"}, + File::Spec->catfile($Config{archlibexp}, "Config.pm") + ); + +A sanity check that what Perl thinks the architecture is and what +Config thinks the architecture is are the same. If they're not it +will return false and show a diagnostic message. + +When building Perl it will always return true, as nothing is installed +yet. + +The interface is a bit odd because this is the result of a +quick refactoring. Don't rely on it. + +=cut + +sub arch_check { + my $self = shift; + my($pconfig, $cconfig) = @_; + + return 1 if $self->{PERL_SRC}; + + my($pvol, $pthinks) = $self->splitpath($pconfig); + my($cvol, $cthinks) = $self->splitpath($cconfig); + + $pthinks = $self->canonpath($pthinks); + $cthinks = $self->canonpath($cthinks); + + my $ret = 1; + if ($pthinks ne $cthinks) { + print "Have $pthinks\n"; + print "Want $cthinks\n"; + + $ret = 0; + + my $arch = (grep length, $self->splitdir($pthinks))[-1]; + + print STDOUT <{UNINSTALLED_PERL}; +Your perl and your Config.pm seem to have different ideas about the +architecture they are running on. +Perl thinks: [$arch] +Config says: [$Config{archname}] +This may or may not cause problems. Please check your installation of perl +if you have problems building this extension. +END + } + + return $ret; +} + =head2 File::Spec wrappers @@ -1627,7 +2201,7 @@ sub installvars { return qw(PRIVLIB SITELIB VENDORLIB ARCHLIB SITEARCH VENDORARCH BIN SITEBIN VENDORBIN - SCRIPT + SCRIPT SITESCRIPT VENDORSCRIPT MAN1DIR SITEMAN1DIR VENDORMAN1DIR MAN3DIR SITEMAN3DIR VENDORMAN3DIR ); @@ -1670,6 +2244,81 @@ sub platform_constants { return ''; } +=begin private + +=head3 _PREREQ_PRINT + + $self->_PREREQ_PRINT; + +Implements PREREQ_PRINT. + +Refactored out of MakeMaker->new(). + +=end private + +=cut + +sub _PREREQ_PRINT { + my $self = shift; + + require Data::Dumper; + my @what = ('PREREQ_PM'); + push @what, 'MIN_PERL_VERSION' if $self->{MIN_PERL_VERSION}; + push @what, 'BUILD_REQUIRES' if $self->{BUILD_REQUIRES}; + print Data::Dumper->Dump([@{$self}{@what}], \@what); + exit 0; +} + + +=begin private + +=head3 _PRINT_PREREQ + + $mm->_PRINT_PREREQ; + +Implements PRINT_PREREQ, a slightly different version of PREREQ_PRINT +added by Redhat to, I think, support generating RPMs from Perl modules. + +Refactored out of MakeMaker->new(). + +=end private + +=cut + +sub _PRINT_PREREQ { + my $self = shift; + + my $prereqs= $self->_all_prereqs; + my @prereq = map { [$_, $prereqs->{$_}] } keys %$prereqs; + + if ( $self->{MIN_PERL_VERSION} ) { + push @prereq, ['perl' => $self->{MIN_PERL_VERSION}]; + } + + print join(" ", map { "perl($_->[0])>=$_->[1] " } + sort { $a->[0] cmp $b->[0] } @prereq), "\n"; + exit 0; +} + + +=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}} }; +} + =head1 AUTHOR