bring MM_VMS::perldepend into 21st century
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MakeMaker.pm
index 7f6bf1a..a6e56b3 100644 (file)
@@ -2,7 +2,7 @@ BEGIN {require 5.002;} # MakeMaker 5.17 was the last MakeMaker that was compatib
 
 package ExtUtils::MakeMaker;
 
-$VERSION = "5.46";
+$VERSION = "5.47";
 $Version_OK = "5.17";  # Makefiles older than $Version_OK will die
                        # (Will be checked from MakeMaker version 4.13 onwards)
 ($Revision = substr(q$Revision: 1.222 $, 10)) =~ s/\s+$//;
@@ -139,7 +139,7 @@ sub prompt ($;$) {
     my $ans;
     local $|=1;
     print "$mess $dispdef";
-    if ($ISA_TTY) {
+    if ($ISA_TTY && !$ENV{PERL_MM_USE_DEFAULT}) {
        chomp($ans = <STDIN>);
     } else {
        print "$def\n";
@@ -152,7 +152,7 @@ sub eval_in_subdirs {
     my($dir);
     use Cwd qw(cwd abs_path);
     my $pwd = cwd();
-    local @INC = map eval {abs_path($_)} || $_, @INC;
+    local @INC = map eval {abs_path($_) if -e} || $_, @INC;
 
     foreach $dir (@{$self->{DIR}}){
        my($abs) = $self->catdir($pwd,$dir);
@@ -210,7 +210,8 @@ sub full_setup {
     PERL_LIB PERL_SRC PERM_RW PERM_RWX
     PL_FILES PM PM_FILTER PMLIBDIRS POLLUTE PPM_INSTALL_EXEC
     PPM_INSTALL_SCRIPT PREFIX
-    PREREQ_PM SKIP TEST_LIBS TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG
+    PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ
+    SKIP TEST_LIBS TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG
     XS_VERSION clean depend dist dynamic_lib linkext macro realclean
     tool_autosplit
     MACPERL_SRC MACPERL_LIB MACLIBS_68K MACLIBS_PPC MACLIBS_SC MACLIBS_MRC
@@ -327,6 +328,17 @@ sub ExtUtils::MakeMaker::new {
     my($class,$self) = @_;
     my($key);
 
+    if ("@ARGV" =~ /\bPREREQ_PRINT\b/) {
+       require Data::Dumper;
+        print Data::Dumper->Dump([$self->{PREREQ_PM}], [qw(PREREQ_PM)]);
+   }
+
+    # PRINT_PREREQ is RedHatism.
+    if ("@ARGV" =~ /\bPRINT_PREREQ\b/) {
+       print join(" ", map { "perl($_)>=$self->{PREREQ_PM}->{$_} " } sort keys %{$self->{PREREQ_PM}}), "\n";
+       exit 0;
+   }
+
     print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose;
     if (-f "MANIFEST" && ! -f "Makefile"){
        check_manifest();
@@ -339,25 +351,26 @@ sub ExtUtils::MakeMaker::new {
     my %configure_att;         # record &{$self->{CONFIGURE}} attributes
     my(%initial_att) = %$self; # record initial attributes
 
+    my(%unsatisfied) = ();
     my($prereq);
     foreach $prereq (sort keys %{$self->{PREREQ_PM}}) {
        my $eval = "require $prereq";
        eval $eval;
 
        if ($@) {
-           warn "Warning: prerequisite $prereq failed to load: $@";
-       }
-       elsif ($prereq->VERSION < $self->{PREREQ_PM}->{$prereq} ){
-           warn "Warning: prerequisite $prereq $self->{PREREQ_PM}->{$prereq} not found";
-# Why is/was this 'delete' here?  We need PREREQ_PM later to make PPDs.
-#      } else {
-#          delete $self->{PREREQ_PM}{$prereq};
+           warn "Warning: prerequisite $prereq $self->{PREREQ_PM}->{$prereq} not found.\n" unless $self->{PREREQ_FATAL};
+           $unsatisfied{$prereq} = 'not installed';
+       } elsif ($prereq->VERSION < $self->{PREREQ_PM}->{$prereq} ){
+           warn "Warning: prerequisite $prereq $self->{PREREQ_PM}->{$prereq} not found. We have"
+               . ($prereq->VERSION || 'unknown version') unless $self->{PREREQ_FATAL};
+           $unsatisfied{$prereq} = $self->{PREREQ_PM}->{$prereq} ? $self->{PREREQ_PM}->{$prereq} : 'unknown version' ;
        }
     }
-#    if (@unsatisfied){
+    if (%unsatisfied && $self->{PREREQ_FATAL}){
 #        unless (defined $ExtUtils::MakeMaker::useCPAN) {
-#            print qq{MakeMaker WARNING: prerequisites not found (@unsatisfied)
-# Please install these modules first and rerun 'perl Makefile.PL'.\n};
+       my $failedprereqs = join ', ', map {"$_ $unsatisfied{$_}"} keys %unsatisfied;
+       die qq{MakeMaker FATAL: prerequisites not found ($failedprereqs)
+                Please install these modules first and rerun 'perl Makefile.PL'.\n};
 #            if ($ExtUtils::MakeMaker::hasCPAN) {
 #                $ExtUtils::MakeMaker::useCPAN = prompt(qq{Should I try to use the CPAN module to fetch them for you?},"yes");
 #            } else {
@@ -369,10 +382,10 @@ sub ExtUtils::MakeMaker::new {
 #            require CPAN;
 #            CPAN->import(@unsatisfied);
 #        } else {
-#            die qq{prerequisites not found (@unsatisfied)};
+#            die qq{prerequisites not found (@unsatisfied)};
 #        }
 #      warn qq{WARNING: prerequisites not found (@unsatisfied)};
-#    }
+    }
 
     if (defined $self->{CONFIGURE}) {
        if (ref $self->{CONFIGURE} eq 'CODE') {
@@ -414,7 +427,7 @@ sub ExtUtils::MakeMaker::new {
        }
        if ($self->{PARENT}) {
            $self->{PARENT}->{CHILDREN}->{$newclass} = $self;
-           foreach my $opt (qw(CAPI POLLUTE PERL_CORE)) {
+           foreach my $opt (qw(POLLUTE PERL_CORE)) {
                if (exists $self->{PARENT}->{$opt}
                    and not exists $self->{$opt})
                    {
@@ -1234,17 +1247,6 @@ Ref to array of *.c file names. Initialised from a directory scan
 and the values portion of the XS attribute hash. This is not
 currently used by MakeMaker but may be handy in Makefile.PLs.
 
-=item CAPI
-
-[This attribute is obsolete in Perl 5.6.  PERL_OBJECT builds are C-compatible
-by default.]
-
-Switch to force usage of the Perl C API even when compiling for PERL_OBJECT.
-
-Note that this attribute is passed through to any recursive build,
-but if and only if the submodule's Makefile.PL itself makes no mention
-of the 'CAPI' attribute.
-
 =item CCFLAGS
 
 String that will be included in the compiler call command line between
@@ -1798,6 +1800,37 @@ extension (e.g. Fcntl for SDBM_File) are the keys of the hash and the
 desired version is the value. If the required version number is 0, we
 only check if any version is installed already.
 
+=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.
+
+Note: see L<Test::Harness> for a shortcut for stopping tests early if
+you are missing dependencies.
+
+Do I<not> use this parameter for simple requirements, which could be resolved
+at a later time, e.g. after an unsuccessful B<make test> of your module.
+
+It is I<extremely> rare to have to use C<PREREQ_FATAL> at all!
+
+=item PREREQ_PRINT
+
+Bool.  If this parameter is true, the prerequisites will be printed to
+stdout and MakeMaker will exit.  The output format is
+
+$PREREQ_PM = {
+               'A::B' => Vers1,
+               'C::D' => Vers2,
+               ...
+             };
+
+=item PRINT_PREREQ
+
+RedHatism for C<PREREQ_PRINT>.  The output format is different, though:
+
+    perl(A::B)>=Vers1 perl(C::D)>=Vers2 ...
+
 =item SKIP
 
 Arrayref. E.g. [qw(name1 name2)] skip (do not write) sections of the
@@ -2143,6 +2176,11 @@ Command line options used by C<MakeMaker-E<gt>new()>, and thus by
 C<WriteMakefile()>.  The string is split on whitespace, and the result
 is processed before any actual command line arguments are processed.
 
+=item PERL_MM_USE_DEFAULT
+
+If set to a true value then MakeMaker's prompt function will
+always return the default without waiting for user input.
+
 =back
 
 =head1 SEE ALSO
@@ -2157,6 +2195,9 @@ Andy Dougherty <F<doughera@lafcol.lafayette.edu>>, Andreas KE<ouml>nig
 support by Charles Bailey <F<bailey@newman.upenn.edu>>.  OS/2 support
 by Ilya Zakharevich <F<ilya@math.ohio-state.edu>>.
 
+Contact the MakeMaker mailing list <F<makemaker@perl.org>> if you have
+any questions.
+
 Send patches and bug reports to <F<perlbug@perl.org>>.
 
 =cut