X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExtUtils%2FMakeMaker.pm;h=261808cb59699a0ced63cf4084f3ab2f5e7a02fe;hb=2e65e370d35678c61f33c1e7f90fd07d0254d085;hp=772025923a9873f583ba4de23ac51c32db12a3b4;hpb=c8e599d3a7f82b1ac9916859e455d8fd113f5731;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm index 7720259..261808c 100644 --- a/lib/ExtUtils/MakeMaker.pm +++ b/lib/ExtUtils/MakeMaker.pm @@ -1,42 +1,37 @@ -# $Id: /local/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm 19606 2006-10-10T01:01:21.319714Z schwern $ +# $Id: /local/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm 66493 2008-09-27T21:35:25.560547Z schwern $ package ExtUtils::MakeMaker; -BEGIN {require 5.005_03;} +use strict; + +BEGIN {require 5.006;} require Exporter; use ExtUtils::MakeMaker::Config; use Carp (); use File::Path; -use vars qw( - @ISA @EXPORT @EXPORT_OK - $VERSION $Verbose %Config - @Prepend_parent @Parent - %Recognized_Att_Keys @Get_from_Config @MM_Sections @Overridable - $Filename - ); - -# Has to be on its own line with no $ after it to avoid being noticed by -# the version control system -use vars qw($Revision); -use strict; +our $Verbose = 0; # exported +our @Parent; # needs to be localized +our @Get_from_Config; # referenced by MM_Unix +our @MM_Sections; +our @Overridable; +my @Prepend_parent; +my %Recognized_Att_Keys; -$VERSION = '6.31_01'; -($Revision) = q$Revision: 19606 $ =~ /Revision:\s+(\S+)/; +our $VERSION = '6.46'; +our ($Revision) = q$Revision: 66493 $ =~ /Revision:\s+(\S+)/; +our $Filename = __FILE__; # referenced outside MakeMaker -@ISA = qw(Exporter); -@EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt); -@EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists); +our @ISA = qw(Exporter); +our @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt); +our @EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists + &WriteEmptyMakefile); # These will go away once the last of the Win32 & VMS specific code is # purged. my $Is_VMS = $^O eq 'VMS'; my $Is_Win32 = $^O eq 'MSWin32'; -# Our filename for diagnostic and debugging purposes. More reliable -# than %INC (think caseless filesystems) -$Filename = __FILE__; - full_setup(); require ExtUtils::MM; # Things like CPAN assume loading ExtUtils::MakeMaker @@ -44,7 +39,7 @@ require ExtUtils::MM; # Things like CPAN assume loading ExtUtils::MakeMaker require ExtUtils::MY; # XXX pre-5.8 versions of ExtUtils::Embed expect # loading ExtUtils::MakeMaker will give them MY. - # This will go when Embed is it's own CPAN module. + # This will go when Embed is its own CPAN module. sub WriteMakefile { @@ -67,41 +62,44 @@ sub WriteMakefile { # scalar. my %Att_Sigs; my %Special_Sigs = ( - C => 'array', - CONFIG => 'array', - CONFIGURE => 'code', - DIR => 'array', - DL_FUNCS => 'hash', - DL_VARS => 'array', - EXCLUDE_EXT => 'array', - EXE_FILES => 'array', - FUNCLIST => 'array', - H => 'array', - IMPORTS => 'hash', - INCLUDE_EXT => 'array', - LIBS => ['array',''], - MAN1PODS => 'hash', - MAN3PODS => 'hash', - PL_FILES => 'hash', - PM => 'hash', - PMLIBDIRS => 'array', - PMLIBPARENTDIRS => 'array', - PREREQ_PM => 'hash', - SKIP => 'array', - TYPEMAPS => 'array', - XS => 'hash', + C => 'ARRAY', + CONFIG => 'ARRAY', + CONFIGURE => 'CODE', + DIR => 'ARRAY', + DL_FUNCS => 'HASH', + DL_VARS => 'ARRAY', + EXCLUDE_EXT => 'ARRAY', + EXE_FILES => 'ARRAY', + FUNCLIST => 'ARRAY', + H => 'ARRAY', + IMPORTS => 'HASH', + INCLUDE_EXT => 'ARRAY', + LIBS => ['ARRAY',''], + MAN1PODS => 'HASH', + MAN3PODS => 'HASH', + META_ADD => 'HASH', + META_MERGE => 'HASH', + PL_FILES => 'HASH', + PM => 'HASH', + PMLIBDIRS => 'ARRAY', + PMLIBPARENTDIRS => 'ARRAY', + PREREQ_PM => 'HASH', + SKIP => 'ARRAY', + TYPEMAPS => 'ARRAY', + XS => 'HASH', + VERSION => ['version',''], _KEEP_AFTER_FLUSH => '', - clean => 'hash', - depend => 'hash', - dist => 'hash', - dynamic_lib=> 'hash', - linkext => 'hash', - macro => 'hash', - postamble => 'hash', - realclean => 'hash', - test => 'hash', - tool_autosplit => 'hash', + clean => 'HASH', + depend => 'HASH', + dist => 'HASH', + dynamic_lib=> 'HASH', + linkext => 'HASH', + macro => 'HASH', + postamble => 'HASH', + realclean => 'HASH', + test => 'HASH', + tool_autosplit => 'HASH', ); @Att_Sigs{keys %Recognized_Att_Keys} = ('') x keys %Recognized_Att_Keys; @@ -119,20 +117,29 @@ sub _verify_att { } my @sigs = ref $sig ? @$sig : $sig; - my $given = lc ref $val; - unless( grep $given eq $_, @sigs ) { - my $takes = join " or ", map { $_ ne '' ? "$_ reference" - : "string/number" - } @sigs; - my $has = $given ne '' ? "$given reference" - : "string/number"; + my $given = ref $val; + unless( grep { $given eq $_ || ($_ && eval{$val->isa($_)}) } @sigs ) { + my $takes = join " or ", map { _format_att($_) } @sigs; + + my $has = _format_att($given); warn "WARNING: $key takes a $takes not a $has.\n". " Please inform the author.\n"; } } } -sub prompt ($;$) { + +sub _format_att { + my $given = shift; + + return $given eq '' ? "string/number" + : uc $given eq $given ? "$given reference" + : "$given object" + ; +} + + +sub prompt ($;$) { ## no critic my($mess, $def) = @_; Carp::confess("prompt function called without an argument") unless defined $mess; @@ -209,7 +216,7 @@ sub full_setup { AUTHOR ABSTRACT ABSTRACT_FROM BINARY_LOCATION C CAPI CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DL_FUNCS DL_VARS - EXCLUDE_EXT EXE_FILES EXTRA_META FIRST_MAKEFILE + EXCLUDE_EXT EXE_FILES FIRST_MAKEFILE FULLPERL FULLPERLRUN FULLPERLRUNINST FUNCLIST H IMPORTS @@ -228,7 +235,8 @@ sub full_setup { SITELIBEXP SITEARCHEXP INC INCLUDE_EXT LDFROM LIB LIBPERL_A LIBS LICENSE - LINKTYPE MAKE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET + LINKTYPE MAKE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET + META_ADD META_MERGE MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NORECURS NO_VC OBJECT OPTIMIZE PERL_MALLOC_OK PERL PERLMAINCC PERLRUN PERLRUNINST PERL_CORE PERL_SRC PERM_RW PERM_RWX @@ -414,13 +422,18 @@ sub new { $self->{PREREQ_PM}->{$prereq} : 'unknown version' ; } } - if (%unsatisfied && $self->{PREREQ_FATAL}){ - my $failedprereqs = join ', ', map {"$_ $unsatisfied{$_}"} - keys %unsatisfied; - die qq{MakeMaker FATAL: prerequisites not found ($failedprereqs)\n - Please install these modules first and rerun 'perl Makefile.PL'.\n}; + + if (%unsatisfied && $self->{PREREQ_FATAL}){ + my $failedprereqs = join "\n", map {" $_ $unsatisfied{$_}"} + sort { $a cmp $b } keys %unsatisfied; + die <<"END"; +MakeMaker FATAL: prerequisites not found. +$failedprereqs + +Please install these modules first and rerun 'perl Makefile.PL'. +END } - + if (defined $self->{CONFIGURE}) { if (ref $self->{CONFIGURE} eq 'CODE') { %configure_att = %{&{$self->{CONFIGURE}}}; @@ -438,19 +451,19 @@ sub new { my $newclass = ++$PACKNAME; local @Parent = @Parent; # Protect against non-local exits { - no strict 'refs'; print "Blessing Object into class [$newclass]\n" if $Verbose>=2; mv_all_methods("MY",$newclass); bless $self, $newclass; push @Parent, $self; require ExtUtils::MY; + + no strict 'refs'; ## no critic; @{"$newclass\:\:ISA"} = 'MM'; } if (defined $Parent[-2]){ $self->{PARENT} = $Parent[-2]; - my $key; - for $key (@Prepend_parent) { + for my $key (@Prepend_parent) { next unless defined $self->{PARENT}{$key}; # Don't stomp on WriteMakefile() args. @@ -476,7 +489,7 @@ sub new { } if ($self->{PARENT}) { $self->{PARENT}->{CHILDREN}->{$newclass} = $self; - foreach my $opt (qw(POLLUTE PERL_CORE)) { + foreach my $opt (qw(POLLUTE PERL_CORE LINKTYPE)) { if (exists $self->{PARENT}->{$opt} and not exists $self->{$opt}) { @@ -491,6 +504,7 @@ sub new { parse_args($self,split(' ', $ENV{PERL_MM_OPT} || ''),@ARGV); } + $self->{NAME} ||= $self->guess_name; ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g; @@ -589,8 +603,7 @@ END } # turn the SKIP array into a SKIPHASH hash - my (%skip,$skip); - for $skip (@{$self->{SKIP} || []}) { + for my $skip (@{$self->{SKIP} || []}) { $self->{SKIPHASH}{$skip} = 1; } delete $self->{SKIP}; # free memory @@ -620,7 +633,9 @@ END my(%a) = %{$self->{$section} || {}}; push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:"; push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a; - push @{$self->{RESULT}}, $self->nicetext($self->$method( %a )); + push @{$self->{RESULT}}, $self->maketext_filter( + $self->$method( %a ) + ); } } @@ -630,32 +645,33 @@ END } sub WriteEmptyMakefile { - Carp::croak "WriteEmptyMakefile: Need even number of args" if @_ % 2; + Carp::croak "WriteEmptyMakefile: Need an even number of args" if @_ % 2; my %att = @_; my $self = MM->new(\%att); - if (-f $self->{MAKEFILE_OLD}) { - _unlink($self->{MAKEFILE_OLD}) or - warn "unlink $self->{MAKEFILE_OLD}: $!"; + + my $new = $self->{MAKEFILE}; + my $old = $self->{MAKEFILE_OLD}; + if (-f $old) { + _unlink($old) or warn "unlink $old: $!"; } - if ( -f $self->{MAKEFILE} ) { - _rename($self->{MAKEFILE}, $self->{MAKEFILE_OLD}) or - warn "rename $self->{MAKEFILE} => $self->{MAKEFILE_OLD}: $!" + if ( -f $new ) { + _rename($new, $old) or warn "rename $new => $old: $!" } - open MF, '>'.$self->{MAKEFILE} or die "open $self->{MAKEFILE} for write: $!"; - print MF <<'EOP'; -all: + open my $mfh, '>', $new or die "open $new for write: $!"; + print $mfh <<'EOP'; +all : -clean: +clean : -install: +install : -makemakerdflt: +makemakerdflt : -test: +test : EOP - close MF or die "close $self->{MAKEFILE} for write: $!"; + close $mfh or die "close $new for write: $!"; } sub check_manifest { @@ -774,7 +790,7 @@ sub check_hints { } sub _run_hintfile { - no strict 'vars'; + our $self; local($self) = shift; # make $self available to the hint file. my($hint_file) = shift; @@ -793,8 +809,6 @@ sub _run_hintfile { sub mv_all_methods { my($from,$to) = @_; - no strict 'refs'; - my($symtab) = \%{"${from}::"}; # Here you see the *current* list of methods that are overridable # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm @@ -817,19 +831,23 @@ sub mv_all_methods { next unless defined &{"${from}::$method"}; - *{"${to}::$method"} = \&{"${from}::$method"}; - - # delete would do, if we were sure, nobody ever called - # MY->makeaperl directly - - # delete $symtab->{$method}; - - # If we delete a method, then it will be undefined and cannot - # be called. But as long as we have Makefile.PLs that rely on - # %MY:: being intact, we have to fill the hole with an - # inheriting method: - - eval "package MY; sub $method { shift->SUPER::$method(\@_); }"; + { + no strict 'refs'; ## no critic + *{"${to}::$method"} = \&{"${from}::$method"}; + + # If we delete a method, then it will be undefined and cannot + # be called. But as long as we have Makefile.PLs that rely on + # %MY:: being intact, we have to fill the hole with an + # inheriting method: + + { + package MY; + my $super = "SUPER::".$method; + *{$method} = sub { + shift->$super(@_); + }; + } + } } # We have to clean out %INC also, because the current directory is @@ -878,19 +896,19 @@ sub skipcheck { sub flush { my $self = shift; - my($chunk); - local *FH; - print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n"; - unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ''); - open(FH,">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!"; + my $finalname = $self->{MAKEFILE}; + print STDOUT "Writing $finalname for $self->{NAME}\n"; + + unlink($finalname, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ()); + open(my $fh,">", "MakeMaker.tmp") + or die "Unable to open MakeMaker.tmp: $!"; - for $chunk (@{$self->{RESULT}}) { - print FH "$chunk\n"; + for my $chunk (@{$self->{RESULT}}) { + print $fh "$chunk\n"; } - close FH; - my($finalname) = $self->{MAKEFILE}; + close $fh; _rename("MakeMaker.tmp", $finalname) or warn "rename MakeMaker.tmp => $finalname: $!"; chmod 0644, $finalname unless $Is_VMS; @@ -1126,7 +1144,8 @@ else calls "prefix" than PREFIX is. To have everything installed in your home directory, do the following. - perl Makefile.PL INSTALL_BASE=~ + # Unix users, INSTALL_BASE=~ works fine + perl Makefile.PL INSTALL_BASE=/path/to/your/home/dir Like PREFIX, it sets several INSTALL* attributes at once. Unlike PREFIX it is easy to predict where the module will end up. The @@ -1152,7 +1171,8 @@ INSTALL_BASE was added in 6.31. PREFIX and LIB can be used to set several INSTALL* attributes in one go. Here's an example for installing into your home directory. - perl Makefile.PL PREFIX=~ + # Unix users, PREFIX=~ works fine + perl Makefile.PL PREFIX=/path/to/your/home/dir This will install all files in the module under your home directory, with man pages and libraries going into an appropriate place (usually @@ -1733,7 +1753,7 @@ MakeMaker will turn it into an array with one element. The licensing terms of your distribution. Generally its "perl" for the same license as Perl itself. -See L for the list of options. +See L for the list of options. Defaults to "unknown". @@ -1790,6 +1810,19 @@ C and will be installed during C. If it is intended, that a new perl binary be produced, this variable may hold a name for that binary. Defaults to perl +=item META_ADD + +=item META_MERGE + +A hashrefs of items to add to the F. + +They differ in how they behave if they have the same key as the +default metadata. META_ADD will override the default value with it's +own. META_MERGE will merge its value with the default. + +Unless you want to override the defaults, prefer META_MERGE so as to +get the advantage of any future defaults. + =item MYEXTLIB If the extension links to a library that it builds set this to the @@ -2056,16 +2089,23 @@ by the PREFIX. =item PREREQ_FATAL Bool. If this parameter is true, failing to have the required modules -(or the right versions thereof) will be fatal. perl Makefile.PL will die -with the proper message. +(or the right versions thereof) will be fatal. C +will C instead of simply informing the user of the missing dependencies. -Note: see L for a shortcut for stopping tests early if -you are missing dependencies. +It is I rare to have to use C. Its use by module +authors is I and should never be used lightly. +Module installation tools have ways of resolving umet dependencies but +to do that they need a F. Using C breaks this. +That's bad. -Do I use this parameter for simple requirements, which could be resolved -at a later time, e.g. after an unsuccessful B of your module. +The only situation where it is appropriate is when you have +dependencies that are indispensible to actually I a +F. For example, MakeMaker's F needs L. +If its not available it cannot write the F. -It is I rare to have to use C at all! +Note: see L for a shortcut for stopping tests early +if you are missing dependencies and are afraid that users might +use your module with an incomplete environment. =item PREREQ_PM @@ -2160,19 +2200,33 @@ will be evaluated with eval() and the value of the named variable B the eval() will be assigned to the VERSION attribute of the MakeMaker object. The following lines will be parsed o.k.: - $VERSION = '1.00'; - *VERSION = \'1.01'; - $VERSION = (q$Revision: 19606 $) =~ /(\d+)/g; + $VERSION = '1.00'; + *VERSION = \'1.01'; + ($VERSION) = q$Revision: 66493 $ =~ /(\d+)/g; $FOO::VERSION = '1.10'; *FOO::VERSION = \'1.11'; - our $VERSION = 1.2.3; # new for perl5.6.0 but these will fail: - my $VERSION = '1.01'; - local $VERSION = '1.02'; + # Bad + my $VERSION = '1.01'; + local $VERSION = '1.02'; local $FOO::VERSION = '1.30'; +"Version strings" are incompatible should not be used. + + # Bad + $VERSION = 1.2.3; + $VERSION = v1.2.3; + +L objects are fine. As of MakeMaker 6.35 version.pm will be +automatically loaded, but you must declare the dependency on version.pm. +For compatibility with older MakeMaker you should load on the same line +as $VERSION is declared. + + # All on one line + use version; our $VERSION = qv(1.2.3); + (Putting C or C on the preceding line will work o.k.) The file named in VERSION_FROM is not added as a dependency to @@ -2408,7 +2462,7 @@ directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory exists, it will be removed first. Additionally, it will create a META.yml module meta-data file in the -distdir and add this to the distdir's MANFIEST. You can shut this +distdir and add this to the distdir's MANIFEST. You can shut this behavior off with the NO_META flag. =item make disttest @@ -2419,7 +2473,7 @@ a make test in that directory. =item make tardist First does a distdir. Then a command $(PREOP) which defaults to a null -command, followed by $(TOUNIX), which defaults to a null command under +command, followed by $(TO_UNIX), which defaults to a null command under UNIX, and will convert files in distribution directory to UNIX format otherwise. Next it runs C on that directory into a tarfile and deletes the directory. Finishes with a command $(POSTOP) which @@ -2504,7 +2558,8 @@ to create the Module, but this is a normal state of things, then you can create a F which does nothing, but succeeds on all the "usual" build targets. To do so, use - ExtUtils::MakeMaker::WriteEmptyMakefile(); + use ExtUtils::MakeMaker qw(WriteEmptyMakefile); + WriteEmptyMakefile(); instead of WriteMakefile().