*** /Library/Perl/ExtUtils/MM_Unix.pm	Wed Aug 21 18:19:49 2002
--- ExtUtils/MM_Unix.pm	Mon Nov 11 18:15:11 2002
***************
*** 6,16 ****
  
  use Exporter ();
  use Carp;
! use Config;
  use File::Basename qw(basename dirname fileparse);
  use File::Spec;
  use DirHandle;
! use strict;
  use vars qw($VERSION @ISA
              $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_VOS
              $Verbose %pm %static $Xsubpp_Version
--- 6,17 ----
  
  use Exporter ();
  use Carp;
! use Config         qw(%Config);
! use Pod::Man;
  use File::Basename qw(basename dirname fileparse);
  use File::Spec;
  use DirHandle;
! 
  use vars qw($VERSION @ISA
              $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_VOS
              $Verbose %pm %static $Xsubpp_Version
***************
*** 2711,2716 ****
--- 2712,2718 ----
      join "", @m;
  }
  
+ 
  =item manifypods (o)
  
  Defines targets and routines to translate the pods into manpages and
***************
*** 2719,2768 ****
  =cut
  
  sub manifypods {
!     my($self, %attribs) = @_;
!     return "\nmanifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
! 	%{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
!     my($dist);
!     my($pod2man_exe);
      if (defined $self->{PERL_SRC}) {
  	$pod2man_exe = File::Spec->catfile($self->{PERL_SRC},'pod','pod2man');
      } else {
  	$pod2man_exe = File::Spec->catfile($Config{scriptdirexp},'pod2man');
      }
      unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
!       # Maybe a build by uninstalled Perl?
!       $pod2man_exe = File::Spec->catfile($self->{PERL_INC}, "pod", "pod2man");
      }
      unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
  	# No pod2man but some MAN3PODS to be installed
! 	print <<END;
  
  Warning: I could not locate your pod2man program. Please make sure,
           your pod2man program is in your PATH before you execute 'make'
  
! END
!         $pod2man_exe = "-S pod2man";
      }
!     my(@m);
!     push @m,
! qq[POD2MAN_EXE = $pod2man_exe\n],
! qq[POD2MAN = \$(PERL) -we '%m=\@ARGV;for (keys %m){' \\\n],
! q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "],
!  $self->{MAKEFILE}, q[";' \\
! -e 'print "Manifying $$m{$$_}\n";' \\
! -e 'system(q[$(PERLRUN) $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
! -e 'chmod(oct($(PERM_RW)), $$m{$$_}) or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'
! ];
!     push @m, "\nmanifypods : pure_all ";
!     push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
! 
!     push(@m,"\n");
!     if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
! 	push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
! 	push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
!     }
!     join('', @m);
  }
  
  =item maybe_command
  
--- 2721,2853 ----
  =cut
  
  sub manifypods {
!     my $self    = shift;
!     my $targets = '';
! 
!     # TODO: remove this - it's a visual reminder for development only
!     warn "  +  using spurkis' manifypods!\n";
! 
!     return "\nmanifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n"
!       unless ( %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}} );
! 
!     $targets .= $self->manifypods_target;
! 
!     return $targets;
! }
! 
! 
! #
! # This returns a make target that enables you to do a "make manifypods"
! # to convert documents containing POD to man pages.
! #
! sub manifypods_target {
!     my $self          = shift;
!     my $man1pods      = '';
!     my $man3pods      = '';
!     my $dependencies  = '';
! 
!     # populate pod2man_files & dependencies:
!     foreach my $name (keys %{$self->{MAN1PODS}}) {
! 	$man1pods     .= " \\\n\t  $name \\\n\t    $self->{MAN1PODS}->{$name}";
! 	$dependencies .= " \\\n\t$name";
!     }
! 
!     foreach my $name (keys %{$self->{MAN3PODS}}) {
! 	$man3pods     .= " \\\n\t  $name \\\n\t    $self->{MAN3PODS}->{$name}";
! 	$dependencies .= " \\\n\t$name"
!     }
! 
!     # generate target:
!     my $pod2man_var = $self->pod2man();
!     my $target      = <<END_OF_TARGET;
! 
! # --- Begin manifypods section:
! $pod2man_var
! 
! manifypods : pure_all $dependencies
! 	$self->{NOECHO}\$(POD2MAN) =section 1 $man1pods
! 	$self->{NOECHO}\$(POD2MAN) =section 3 $man3pods
! 
! # --- End of manifypods section --- #
! 
! END_OF_TARGET
! }
! 
! 
! #
! # This returns a pod-to-man make variable that contains a perl script
! # that is used like this:
! #
! #    $(POD2MAN) [--section <man_section>]
! #               <infile> <outfile> [ <infile> <outfile> ... ]
! #
! # (adapted from manifypods() by spurkis, M. Schwern's idea to use Pod::Man)
! #
! sub pod2man {
!     my $self = shift;
! 
!     my $make_vars = <<'END_OF_PROGRAM';
! POD2MAN = $(PERL) -we '                                               \
!     use Pod::Man;                                                     \
!                                                                       \
!     my %args     = @ARGV;                                             \
!     my $$section = delete($$args{"=section"}) || "";                  \
!                                                                       \
!     print "Manifying section ", $$section || "[unknown]", " pods:\n"; \
!     my $$parser  = new Pod::Man(section => $$section);                \
!                                                                       \
!     foreach my $$infile (keys %args) {                                \
! 	my $$outfile = $$args{$$infile};                              \
! 	next if ((-e $$outfile) &&                                    \
! 		 (-M $$outfile < -M $$infile) &&                      \
! 		 (-M $$outfile < -M "Makefile"));                     \
! 	print "  +  $$outfile";                                       \
! 	$$parser->parse_from_file($$infile, $$outfile)                \
! 	  or (warn("Could not install $$outfile\n") and next);        \
! 	chmod(oct($(PERM_RW)), $$outfile)                             \
! 	  or (warn("chmod $(PERM_RW) $$outfile: $$!\n") and next);    \
! 	print "\n";                                                   \
!     }'
! END_OF_PROGRAM
! 
!     return $make_vars;
! }
! 
! 
! #
! # Finds and returns the pod2man binary.
! # (originally from manifypods() )
! #
! sub find_pod2man_exe {
!     my $self = shift;
!     my $pod2man_exe;
! 
      if (defined $self->{PERL_SRC}) {
  	$pod2man_exe = File::Spec->catfile($self->{PERL_SRC},'pod','pod2man');
      } else {
  	$pod2man_exe = File::Spec->catfile($Config{scriptdirexp},'pod2man');
      }
+ 
      unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
! 	# Maybe a build by uninstalled Perl?
! 	$pod2man_exe = File::Spec->catfile($self->{PERL_INC}, "pod", "pod2man");
      }
+ 
      unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
  	# No pod2man but some MAN3PODS to be installed
!         $pod2man_exe = "-S pod2man";
! 	print <<END_OF_MESSAGE;
  
  Warning: I could not locate your pod2man program. Please make sure,
           your pod2man program is in your PATH before you execute 'make'
  
! END_OF_MESSAGE
      }
! 
!     return $pod2man_exe;
  }
+ 
+ 
  
  =item maybe_command
  
