diff options
Diffstat (limited to 'gnu/usr.bin/perl/lib/ExtUtils')
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/Command.pm | 90 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/Install.pm | 432 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/Liblist.pm | 17 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/MM_OS2.pm | 55 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/MM_Unix.pm | 2267 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/MM_VMS.pm | 1491 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/MM_Win32.pm | 701 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/MakeMaker.pm | 489 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/MakeMaker/FAQ.pod | 6 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/Manifest.pm | 331 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/typemap | 1 | ||||
-rw-r--r-- | gnu/usr.bin/perl/lib/ExtUtils/xsubpp | 80 |
12 files changed, 3137 insertions, 2823 deletions
diff --git a/gnu/usr.bin/perl/lib/ExtUtils/Command.pm b/gnu/usr.bin/perl/lib/ExtUtils/Command.pm index 6593ab3a350..12e2b99ea5a 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/Command.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/Command.pm @@ -11,7 +11,7 @@ require Exporter; use vars qw(@ISA @EXPORT $VERSION); @ISA = qw(Exporter); @EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f); -$VERSION = '1.04'; +$VERSION = '1.05'; my $Is_VMS = $^O eq 'VMS'; @@ -21,16 +21,16 @@ ExtUtils::Command - utilities to replace common UNIX commands in Makefiles etc. =head1 SYNOPSIS - perl -MExtUtils::Command -e cat files... > destination - perl -MExtUtils::Command -e mv source... destination - perl -MExtUtils::Command -e cp source... destination - perl -MExtUtils::Command -e touch files... - perl -MExtUtils::Command -e rm_f file... - perl -MExtUtils::Command -e rm_rf directories... - perl -MExtUtils::Command -e mkpath directories... - perl -MExtUtils::Command -e eqtime source destination - perl -MExtUtils::Command -e chmod mode files... - perl -MExtUtils::Command -e test_f file + perl -MExtUtils::Command -e cat files... > destination + perl -MExtUtils::Command -e mv source... destination + perl -MExtUtils::Command -e cp source... destination + perl -MExtUtils::Command -e touch files... + perl -MExtUtils::Command -e rm_f files... + perl -MExtUtils::Command -e rm_rf directories... + perl -MExtUtils::Command -e mkpath directories... + perl -MExtUtils::Command -e eqtime source destination + perl -MExtUtils::Command -e test_f file + perl -MExtUtils::Command=chmod -e chmod mode files... =head1 DESCRIPTION @@ -57,6 +57,7 @@ sub expand_wildcards @ARGV = map(/[$wild_regex]/o ? glob($_) : $_,@ARGV); } + =item cat Concatenates all files mentioned on command line to STDOUT. @@ -78,8 +79,7 @@ Sets modified time of dst to that of src sub eqtime { my ($src,$dst) = @ARGV; - open(F,">$dst"); - close(F); + local @ARGV = ($dst); touch(); # in case $dst doesn't exist utime((stat($src))[8,9],$dst); } @@ -120,17 +120,14 @@ Makes files exist, with current timestamp =cut -sub touch -{ - my $t = time; - expand_wildcards(); - while (@ARGV) - { - my $file = shift(@ARGV); - open(FILE,">>$file") || die "Cannot write $file:$!"; - close(FILE); - utime($t,$t,$file); - } +sub touch { + my $t = time; + expand_wildcards(); + foreach my $file (@ARGV) { + open(FILE,">>$file") || die "Cannot write $file:$!"; + close(FILE); + utime($t,$t,$file); + } } =item mv source... destination @@ -140,16 +137,13 @@ Multiple sources are allowed if destination is an existing directory. =cut -sub mv -{ - my $dst = pop(@ARGV); - expand_wildcards(); - croak("Too many arguments") if (@ARGV > 1 && ! -d $dst); - while (@ARGV) - { - my $src = shift(@ARGV); - move($src,$dst); - } +sub mv { + my $dst = pop(@ARGV); + expand_wildcards(); + croak("Too many arguments") if (@ARGV > 1 && ! -d $dst); + foreach my $src (@ARGV) { + move($src,$dst); + } } =item cp source... destination @@ -159,29 +153,25 @@ Multiple sources are allowed if destination is an existing directory. =cut -sub cp -{ - my $dst = pop(@ARGV); - expand_wildcards(); - croak("Too many arguments") if (@ARGV > 1 && ! -d $dst); - while (@ARGV) - { - my $src = shift(@ARGV); - copy($src,$dst); - } +sub cp { + my $dst = pop(@ARGV); + expand_wildcards(); + croak("Too many arguments") if (@ARGV > 1 && ! -d $dst); + foreach my $src (@ARGV) { + copy($src,$dst); + } } =item chmod mode files... -Sets UNIX like permissions 'mode' on all the files. +Sets UNIX like permissions 'mode' on all the files. e.g. 0666 =cut -sub chmod -{ - my $mode = shift(@ARGV); - expand_wildcards(); - chmod($mode,@ARGV) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!"; +sub chmod { + my $mode = shift(@ARGV); + expand_wildcards(); + chmod(oct $mode,@ARGV) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!"; } =item mkpath directory... diff --git a/gnu/usr.bin/perl/lib/ExtUtils/Install.pm b/gnu/usr.bin/perl/lib/ExtUtils/Install.pm index b8fb4e37258..18510ade4b7 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/Install.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/Install.pm @@ -2,17 +2,16 @@ package ExtUtils::Install; use 5.00503; use vars qw(@ISA @EXPORT $VERSION); -$VERSION = 1.29; +$VERSION = 1.32; use Exporter; use Carp (); use Config qw(%Config); @ISA = ('Exporter'); @EXPORT = ('install','uninstall','pm_to_blib', 'install_default'); -$Is_VMS = $^O eq 'VMS'; +$Is_VMS = $^O eq 'VMS'; +$Is_MacPerl = $^O eq 'MacOS'; -my $splitchar = $^O eq 'VMS' ? '|' : ($^O eq 'os2' || $^O eq 'dos') ? ';' : ':'; -my @PERL_ENV_LIB = split $splitchar, defined $ENV{'PERL5LIB'} ? $ENV{'PERL5LIB'} : $ENV{'PERLLIB'} || ''; my $Inc_uninstall_warn_handler; # install relative to here @@ -20,33 +19,67 @@ my $Inc_uninstall_warn_handler; my $INSTALL_ROOT = $ENV{PERL_INSTALL_ROOT}; use File::Spec; +my $Curdir = File::Spec->curdir; +my $Updir = File::Spec->updir; -sub install_rooted_file { - if (defined $INSTALL_ROOT) { - File::Spec->catfile($INSTALL_ROOT, $_[0]); - } else { - $_[0]; - } -} -sub install_rooted_dir { - if (defined $INSTALL_ROOT) { - File::Spec->catdir($INSTALL_ROOT, $_[0]); - } else { - $_[0]; - } -} +=head1 NAME -#our(@EXPORT, @ISA, $Is_VMS); -#use strict; +ExtUtils::Install - install files from here to there -sub forceunlink { - chmod 0666, $_[0]; - unlink $_[0] or Carp::croak("Cannot forceunlink $_[0]: $!") -} +=head1 SYNOPSIS + + use ExtUtils::Install; + + install({ 'blib/lib' => 'some/install/dir' } ); + + uninstall($packlist); + + pm_to_blib({ 'lib/Foo/Bar.pm' => 'blib/lib/Foo/Bar.pm' }); + + +=head1 DESCRIPTION + +Handles the installing and uninstalling of perl modules, scripts, man +pages, etc... + +Both install() and uninstall() are specific to the way +ExtUtils::MakeMaker handles the installation and deinstallation of +perl modules. They are not designed as general purpose tools. + +=head2 Functions + +=over 4 + +=item B<install> + + install(\%from_to); + install(\%from_to, $verbose, $dont_execute, $uninstall_shadows); + +Copies each directory tree of %from_to to its corresponding value +preserving timestamps and permissions. + +There are two keys with a special meaning in the hash: "read" and +"write". These contain packlist files. After the copying is done, +install() will write the list of target files to $from_to{write}. If +$from_to{read} is given the contents of this file will be merged into +the written file. The read and the written file may be identical, but +on AFS it is quite likely that people are installing to a different +directory than the one where the files later appear. + +If $verbose is true, will print out each file removed. Default is +false. This is "make install VERBINST=1" + +If $dont_execute is true it will only print what it was going to do +without actually doing it. Default is false. + +If $uninstall_shadows is true any differing versions throughout @INC +will be uninstalled. This is "make install UNINST=1" + +=cut sub install { - my($hash,$verbose,$nonono,$inc_uninstall) = @_; + my($from_to,$verbose,$nonono,$inc_uninstall) = @_; $verbose ||= 0; $nonono ||= 0; @@ -57,32 +90,29 @@ sub install { use File::Find qw(find); use File::Path qw(mkpath); use File::Compare qw(compare); - use File::Spec; - my(%hash) = %$hash; + my(%from_to) = %$from_to; my(%pack, $dir, $warn_permissions); my($packlist) = ExtUtils::Packlist->new(); # -w doesn't work reliably on FAT dirs $warn_permissions++ if $^O eq 'MSWin32'; local(*DIR); for (qw/read write/) { - $pack{$_}=$hash{$_}; - delete $hash{$_}; + $pack{$_}=$from_to{$_}; + delete $from_to{$_}; } my($source_dir_or_file); - foreach $source_dir_or_file (sort keys %hash) { + foreach $source_dir_or_file (sort keys %from_to) { #Check if there are files, and if yes, look if the corresponding #target directory is writable for us opendir DIR, $source_dir_or_file or next; for (readdir DIR) { - next if $_ eq "." || $_ eq ".." || $_ eq ".exists"; - my $targetdir = install_rooted_dir($hash{$source_dir_or_file}); - if (-w $targetdir || - mkpath($targetdir)) { - last; - } else { + next if $_ eq $Curdir || $_ eq $Updir || $_ eq ".exists"; + my $targetdir = install_rooted_dir($from_to{$source_dir_or_file}); + mkpath($targetdir) unless $nonono; + if (!$nonono && !-w $targetdir) { warn "Warning: You do not have permissions to " . - "install into $hash{$source_dir_or_file}" + "install into $from_to{$source_dir_or_file}" unless $warn_permissions++; } } @@ -92,8 +122,7 @@ sub install { $packlist->read($tmpfile) if (-f $tmpfile); my $cwd = cwd(); - my($source); - MOD_INSTALL: foreach $source (sort keys %hash) { + MOD_INSTALL: foreach my $source (sort keys %from_to) { #copy the tree to the target directory without altering #timestamp and permission and remember for the .packlist #file. The packlist file contains the absolute paths of the @@ -104,29 +133,39 @@ sub install { #there are any files in arch. So we depend on having ./blib/arch #hardcoded here. - my $targetroot = install_rooted_dir($hash{$source}); + my $targetroot = install_rooted_dir($from_to{$source}); - if ($source eq "blib/lib" and - exists $hash{"blib/arch"} and - directory_not_empty("blib/arch")) { - $targetroot = install_rooted_dir($hash{"blib/arch"}); - print "Files found in blib/arch: installing files in blib/lib into architecture dependent library tree\n"; + my $blib_lib = File::Spec->catdir('blib', 'lib'); + my $blib_arch = File::Spec->catdir('blib', 'arch'); + if ($source eq $blib_lib and + exists $from_to{$blib_arch} and + directory_not_empty($blib_arch)) { + $targetroot = install_rooted_dir($from_to{$blib_arch}); + print "Files found in $blib_arch: installing files in $blib_lib into architecture dependent library tree\n"; } - chdir($source) or next; + + chdir $source or next; find(sub { - my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, - $atime,$mtime,$ctime,$blksize,$blocks) = stat; + my ($mode,$size,$atime,$mtime) = (stat)[2,7,8,9]; return unless -f _; - return if $_ eq ".exists"; + + my $origfile = $_; + return if $origfile eq ".exists"; my $targetdir = File::Spec->catdir($targetroot, $File::Find::dir); - my $targetfile = File::Spec->catfile($targetdir, $_); + my $targetfile = File::Spec->catfile($targetdir, $origfile); + my $sourcedir = File::Spec->catdir($source, $File::Find::dir); + my $sourcefile = File::Spec->catfile($sourcedir, $origfile); + + my $save_cwd = cwd; + chdir $cwd; # in case the target is relative + # 5.5.3's File::Find missing no_chdir option. my $diff = 0; if ( -f $targetfile && -s _ == $size) { # We have a good chance, we can skip this one - $diff = compare($_,$targetfile); + $diff = compare($sourcefile, $targetfile); } else { - print "$_ differs\n" if $verbose>1; + print "$sourcefile differs\n" if $verbose>1; $diff++; } @@ -137,7 +176,7 @@ sub install { mkpath($targetdir,0,0755) unless $nonono; print "mkpath($targetdir,0,0755)\n" if $verbose>1; } - copy($_,$targetfile) unless $nonono; + copy($sourcefile, $targetfile) unless $nonono; print "Installing $targetfile\n"; utime($atime,$mtime + $Is_VMS,$targetfile) unless $nonono>1; print "utime($atime,$mtime,$targetfile)\n" if $verbose>1; @@ -147,27 +186,54 @@ sub install { } else { print "Skipping $targetfile (unchanged)\n" if $verbose; } - - if (! defined $inc_uninstall) { # it's called - } elsif ($inc_uninstall == 0){ - inc_uninstall($_,$File::Find::dir,$verbose,1); # nonono set to 1 - } else { - inc_uninstall($_,$File::Find::dir,$verbose,0); # nonono set to 0 + + if (defined $inc_uninstall) { + inc_uninstall($sourcefile,$File::Find::dir,$verbose, + $inc_uninstall ? 0 : 1); } + # Record the full pathname. $packlist->{$targetfile}++; - }, "."); + # File::Find can get confused if you chdir in here. + chdir $save_cwd; + + # File::Find seems to always be Unixy except on MacPerl :( + }, $Is_MacPerl ? $Curdir : '.' ); chdir($cwd) or Carp::croak("Couldn't chdir to $cwd: $!"); } if ($pack{'write'}) { $dir = install_rooted_dir(dirname($pack{'write'})); - mkpath($dir,0,0755); + mkpath($dir,0,0755) unless $nonono; print "Writing $pack{'write'}\n"; - $packlist->write(install_rooted_file($pack{'write'})); + $packlist->write(install_rooted_file($pack{'write'})) unless $nonono; } } +sub install_rooted_file { + if (defined $INSTALL_ROOT) { + File::Spec->catfile($INSTALL_ROOT, $_[0]); + } else { + $_[0]; + } +} + + +sub install_rooted_dir { + if (defined $INSTALL_ROOT) { + File::Spec->catdir($INSTALL_ROOT, $_[0]); + } else { + $_[0]; + } +} + + +sub forceunlink { + chmod 0666, $_[0]; + unlink $_[0] or Carp::croak("Cannot forceunlink $_[0]: $!") +} + + sub directory_not_empty ($) { my($dir) = @_; my $files = 0; @@ -181,6 +247,28 @@ sub directory_not_empty ($) { return $files; } + +=item B<install_default> I<DISCOURAGED> + + install_default(); + install_default($fullext); + +Calls install() with arguments to copy a module from blib/ to the +default site installation location. + +$fullext is the name of the module converted to a directory +(ie. Foo::Bar would be Foo/Bar). If $fullext is not specified, it +will attempt to read it from @ARGV. + +This is primarily useful for install scripts. + +B<NOTE> This function is not really useful because of the hard-coded +install location with no way to control site vs core vs vendor +directories and the strange way in which the module name is given. +Consider its use discouraged. + +=cut + sub install_default { @_ < 2 or die "install_default should be called with 0 or 1 argument"; my $FULLEXT = @_ ? shift : $ARGV[0]; @@ -205,9 +293,28 @@ sub install_default { },1,0,0); } + +=item B<uninstall> + + uninstall($packlist_file); + uninstall($packlist_file, $verbose, $dont_execute); + +Removes the files listed in a $packlist_file. + +If $verbose is true, will print out each file removed. Default is +false. + +If $dont_execute is true it will only print what it was going to do +without actually doing it. Default is false. + +=cut + sub uninstall { use ExtUtils::Packlist; my($fil,$verbose,$nonono) = @_; + $verbose ||= 0; + $nonono ||= 0; + die "no packlist file found: $fil" unless -f $fil; # my $my_req = $self->catfile(qw(auto ExtUtils Install forceunlink.al)); # require $my_req; # Hairy, but for the first @@ -222,14 +329,19 @@ sub uninstall { } sub inc_uninstall { - my($file,$libdir,$verbose,$nonono) = @_; + my($filepath,$libdir,$verbose,$nonono) = @_; my($dir); + my $file = (File::Spec->splitpath($filepath))[2]; my %seen_dir = (); + + my @PERL_ENV_LIB = split $Config{path_sep}, defined $ENV{'PERL5LIB'} + ? $ENV{'PERL5LIB'} : $ENV{'PERLLIB'} || ''; + foreach $dir (@INC, @PERL_ENV_LIB, @Config{qw(archlibexp privlibexp sitearchexp sitelibexp)}) { - next if $dir eq "."; + next if $dir eq $Curdir; next if $seen_dir{$dir}++; my($targetfile) = File::Spec->catfile($dir,$libdir,$file); next unless -f $targetfile; @@ -238,9 +350,9 @@ sub inc_uninstall { # know, which is the file we just installed (AFS). So we leave # an identical file in place my $diff = 0; - if ( -f $targetfile && -s _ == -s $file) { + if ( -f $targetfile && -s _ == -s $filepath) { # We have a good chance, we can skip this one - $diff = compare($file,$targetfile); + $diff = compare($filepath,$targetfile); } else { print "#$file and $targetfile differ\n" if $verbose>1; $diff++; @@ -251,7 +363,10 @@ sub inc_uninstall { if ($verbose) { $Inc_uninstall_warn_handler ||= new ExtUtils::Install::Warn; $libdir =~ s|^\./||s ; # That's just cosmetics, no need to port. It looks prettier. - $Inc_uninstall_warn_handler->add("$libdir/$file",$targetfile); + $Inc_uninstall_warn_handler->add( + File::Spec->catfile($libdir, $file), + $targetfile + ); } # if not verbose, we just say nothing } else { @@ -263,6 +378,7 @@ sub inc_uninstall { sub run_filter { my ($cmd, $src, $dest) = @_; + local(*CMD, *SRC); open(CMD, "|$cmd >$dest") || die "Cannot fork: $!"; open(SRC, $src) || die "Cannot open $src: $!"; my $buf; @@ -274,6 +390,24 @@ sub run_filter { close CMD or die "Filter command '$cmd' failed for $src"; } + +=item B<pm_to_blib> + + pm_to_blib(\%from_to, $autosplit_dir); + pm_to_blib(\%from_to, $autosplit_dir, $filter_cmd); + +Copies each key of %from_to to its corresponding value efficiently. +Filenames with the extension .pm are autosplit into the $autosplit_dir. + +$filter_cmd is an optional shell command to run each .pm file through +prior to splitting and copying. Input is the contents of the module, +output the new module contents. + +You can have an environment variable PERL_INSTALL_ROOT set which will +be prepended as a directory to each installed file (and directory). + +=cut + sub pm_to_blib { my($fromto,$autodir,$pm_filter) = @_; @@ -297,41 +431,65 @@ sub pm_to_blib { } mkpath($autodir,0,0755); - foreach (keys %$fromto) { - my $dest = $fromto->{$_}; - next if -f $dest && -M $dest < -M $_; + while(my($from, $to) = each %$fromto) { + if( -f $to && -s $from == -s $to && -M $to < -M $from ) { + print "Skip $to (unchanged)\n"; + next; + } # When a pm_filter is defined, we need to pre-process the source first # to determine whether it has changed or not. Therefore, only perform # the comparison check when there's no filter to be ran. # -- RAM, 03/01/2001 - my $need_filtering = defined $pm_filter && length $pm_filter && /\.pm$/; + my $need_filtering = defined $pm_filter && length $pm_filter && + $from =~ /\.pm$/; - if (!$need_filtering && 0 == compare($_,$dest)) { - print "Skip $dest (unchanged)\n"; + if (!$need_filtering && 0 == compare($from,$to)) { + print "Skip $to (unchanged)\n"; next; } - if (-f $dest){ - forceunlink($dest); + if (-f $to){ + forceunlink($to); } else { - mkpath(dirname($dest),0,0755); + mkpath(dirname($to),0,0755); } if ($need_filtering) { - run_filter($pm_filter, $_, $dest); - print "$pm_filter <$_ >$dest\n"; + run_filter($pm_filter, $from, $to); + print "$pm_filter <$from >$to\n"; } else { - copy($_,$dest); - print "cp $_ $dest\n"; + copy($from,$to); + print "cp $from $to\n"; } - my($mode,$atime,$mtime) = (stat)[2,8,9]; - utime($atime,$mtime+$Is_VMS,$dest); - chmod(0444 | ( $mode & 0111 ? 0111 : 0 ),$dest); - next unless /\.pm$/; - autosplit($dest,$autodir); + my($mode,$atime,$mtime) = (stat $from)[2,8,9]; + utime($atime,$mtime+$Is_VMS,$to); + chmod(0444 | ( $mode & 0111 ? 0111 : 0 ),$to); + next unless $from =~ /\.pm$/; + _autosplit($to,$autodir); } } + +=begin _private + +=item _autosplit + +From 1.0307 back, AutoSplit will sometimes leave an open filehandle to +the file being split. This causes problems on systems with mandatory +locking (ie. Windows). So we wrap it and close the filehandle. + +=end _private + +=cut + +sub _autosplit { + my $retval = autosplit(@_); + close *AutoSplit::IN if defined *AutoSplit::IN{IO}; + + return $retval; +} + + package ExtUtils::Install::Warn; sub new { bless {}, shift } @@ -342,87 +500,57 @@ sub add { } sub DESTROY { - unless(defined $INSTALL_ROOT) { - my $self = shift; - my($file,$i,$plural); - foreach $file (sort keys %$self) { - $plural = @{$self->{$file}} > 1 ? "s" : ""; - print "## Differing version$plural of $file found. You might like to\n"; - for (0..$#{$self->{$file}}) { - print "rm ", $self->{$file}[$_], "\n"; - $i++; - } - } - $plural = $i>1 ? "all those files" : "this file"; - print "## Running 'make install UNINST=1' will unlink $plural for you.\n"; - } + unless(defined $INSTALL_ROOT) { + my $self = shift; + my($file,$i,$plural); + foreach $file (sort keys %$self) { + $plural = @{$self->{$file}} > 1 ? "s" : ""; + print "## Differing version$plural of $file found. You might like to\n"; + for (0..$#{$self->{$file}}) { + print "rm ", $self->{$file}[$_], "\n"; + $i++; + } + } + $plural = $i>1 ? "all those files" : "this file"; + print "## Running 'make install UNINST=1' will unlink $plural for you.\n"; + } } -1; +=back -__END__ -=head1 NAME +=head1 ENVIRONMENT -ExtUtils::Install - install files from here to there +=over 4 -=head1 SYNOPSIS +=item B<PERL_INSTALL_ROOT> -B<use ExtUtils::Install;> +Will be prepended to each install path. -B<install($hashref,$verbose,$nonono);> +=back -B<uninstall($packlistfile,$verbose,$nonono);> +=head1 AUTHOR -B<pm_to_blib($hashref);> +Original author lost in the mists of time. Probably the same as Makemaker. -=head1 DESCRIPTION +Currently maintained by Michael G Schwern <F<schwern@pobox.com>> -Both install() and uninstall() are specific to the way -ExtUtils::MakeMaker handles the installation and deinstallation of -perl modules. They are not designed as general purpose tools. +Send patches and ideas to <F<makemaker@perl.org>>. -install() takes three arguments. A reference to a hash, a verbose -switch and a don't-really-do-it switch. The hash ref contains a -mapping of directories: each key/value pair is a combination of -directories to be copied. Key is a directory to copy from, value is a -directory to copy to. The whole tree below the "from" directory will -be copied preserving timestamps and permissions. +Send bug reports via http://rt.cpan.org/. Please send your +generated Makefile along with your report. -There are two keys with a special meaning in the hash: "read" and -"write". After the copying is done, install will write the list of -target files to the file named by C<$hashref-E<gt>{write}>. If there is -another file named by C<$hashref-E<gt>{read}>, the contents of this file will -be merged into the written file. The read and the written file may be -identical, but on AFS it is quite likely that people are installing to a -different directory than the one where the files later appear. - -install_default() takes one or less arguments. If no arguments are -specified, it takes $ARGV[0] as if it was specified as an argument. -The argument is the value of MakeMaker's C<FULLEXT> key, like F<Tk/Canvas>. -This function calls install() with the same arguments as the defaults -the MakeMaker would use. - -The argument-less form is convenient for install scripts like - - perl -MExtUtils::Install -e install_default Tk/Canvas - -Assuming this command is executed in a directory with a populated F<blib> -directory, it will proceed as if the F<blib> was build by MakeMaker on -this machine. This is useful for binary distributions. - -uninstall() takes as first argument a file containing filenames to be -unlinked. The second argument is a verbose switch, the third is a -no-don't-really-do-it-now switch. - -pm_to_blib() takes a hashref as the first argument and copies all keys -of the hash to the corresponding values efficiently. Filenames with -the extension pm are autosplit. Second argument is the autosplit -directory. If third argument is not empty, it is taken as a filter command -to be ran on each .pm file, the output of the command being what is finally -copied, and the source for auto-splitting. +For more up-to-date information, see http://www.makemaker.org. + + +=head1 LICENSE + +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +See F<http://www.perl.com/perl/misc/Artistic.html> -You can have an environment variable PERL_INSTALL_ROOT set which will -be prepended as a directory to each installed file (and directory). =cut + +1; diff --git a/gnu/usr.bin/perl/lib/ExtUtils/Liblist.pm b/gnu/usr.bin/perl/lib/ExtUtils/Liblist.pm index de79088abbf..4b098083d98 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/Liblist.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/Liblist.pm @@ -1,18 +1,24 @@ package ExtUtils::Liblist; use vars qw($VERSION); -$VERSION = '1.00'; +$VERSION = '1.01'; use File::Spec; require ExtUtils::Liblist::Kid; @ISA = qw(ExtUtils::Liblist::Kid File::Spec); +# Backwards compatibility with old interface. +sub ext { + goto &ExtUtils::Liblist::Kid::ext; +} + sub lsdir { shift; my $rex = qr/$_[1]/; opendir DIR, $_[0]; - grep /$rex/, readdir DIR; + my @out = grep /$rex/, readdir DIR; closedir DIR; + return @out; } __END__ @@ -23,9 +29,12 @@ ExtUtils::Liblist - determine libraries to use and how to use them =head1 SYNOPSIS -C<require ExtUtils::Liblist;> + require ExtUtils::Liblist; + + $MM->ext($potential_libs, $verbose, $need_names); -C<ExtUtils::Liblist::ext($self, $potential_libs, $verbose, $need_names);> + # Usually you can get away with: + ExtUtils::Liblist->ext($potential_libs, $verbose, $need_names) =head1 DESCRIPTION diff --git a/gnu/usr.bin/perl/lib/ExtUtils/MM_OS2.pm b/gnu/usr.bin/perl/lib/ExtUtils/MM_OS2.pm index fb72f5fbe03..b85a0075990 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/MM_OS2.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/MM_OS2.pm @@ -6,7 +6,7 @@ use vars qw($VERSION @ISA); use ExtUtils::MakeMaker qw(neatvalue); use File::Spec; -$VERSION = '1.03'; +$VERSION = '1.04'; require ExtUtils::MM_Any; require ExtUtils::MM_Unix; @@ -32,16 +32,20 @@ the semantics. =over 4 +=item init_dist (o) + +Define TO_UNIX to convert OS2 linefeeds to Unix style. + =cut -sub dist { - my($self, %attribs) = @_; +sub init_dist { + my($self) = @_; - $attribs{TO_UNIX} ||= sprintf <<'MAKE_TEXT', $self->{NOECHO}; -%s$(TEST_F) tmp.zip && $(RM) tmp.zip; $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM) tmp.zip + $self->{TO_UNIX} ||= <<'MAKE_TEXT'; +$(NOECHO) $(TEST_F) tmp.zip && $(RM_F) tmp.zip; $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM_F) tmp.zip MAKE_TEXT - return $self->SUPER::dist(%attribs); + $self->SUPER::init_dist; } sub dlsyms { @@ -117,38 +121,33 @@ sub maybe_command { return; } -sub perl_archive { - return "\$(PERL_INC)/libperl\$(LIB_EXT)"; -} +=item init_linker -=item perl_archive_after +=cut -This is an internal method that returns path to a library which -should be put on the linker command line I<after> the external libraries -to be linked to dynamic extensions. This may be needed if the linker -is one-pass, and Perl includes some overrides for C RTL functions, -such as malloc(). +sub init_linker { + my $self = shift; -=cut + $self->{PERL_ARCHIVE} = "\$(PERL_INC)/libperl\$(LIB_EXT)"; -sub perl_archive_after -{ - return "\$(PERL_INC)/libperl_override\$(LIB_EXT)" unless $OS2::is_aout; - return ""; + $self->{PERL_ARCHIVE_AFTER} = $OS2::is_aout + ? '' + : '$(PERL_INC)/libperl_override$(LIB_EXT)'; + $self->{EXPORT_LIST} = '$(BASEEXT).def'; } -sub export_list -{ - my ($self) = @_; - return "$self->{BASEEXT}.def"; -} +=item os_flavor -1; +OS/2 is OS/2 -__END__ +=cut -=pod +sub os_flavor { + return('OS/2'); +} =back =cut + +1; diff --git a/gnu/usr.bin/perl/lib/ExtUtils/MM_Unix.pm b/gnu/usr.bin/perl/lib/ExtUtils/MM_Unix.pm index ff813bc0ef0..97987332547 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/MM_Unix.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/MM_Unix.pm @@ -6,30 +6,42 @@ use strict; use Exporter (); use Carp; -use Config; +use Config qw(%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 + $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Win95 $Is_Dos $Is_VOS + $Is_QNX $Is_AIX $Is_OSF $Is_IRIX $Is_NetBSD $Is_BSD + $Is_SunOS4 $Is_Solaris $Is_SunOS + $Verbose %pm %static %Config_Override ); use ExtUtils::MakeMaker qw($Verbose neatvalue); -$VERSION = '1.33'; +$VERSION = '1.42'; require ExtUtils::MM_Any; @ISA = qw(ExtUtils::MM_Any); -$Is_OS2 = $^O eq 'os2'; -$Is_Mac = $^O eq 'MacOS'; -$Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare'; -$Is_Dos = $^O eq 'dos'; -$Is_VOS = $^O eq 'vos'; -$Is_VMS = $^O eq 'VMS'; +$Is_OS2 = $^O eq 'os2'; +$Is_Mac = $^O eq 'MacOS'; +$Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare'; +$Is_Win95 = $Is_Win32 && Win32::IsWin95(); +$Is_Dos = $^O eq 'dos'; +$Is_VOS = $^O eq 'vos'; +$Is_VMS = $^O eq 'VMS'; +$Is_QNX = $^O eq 'qnx'; +$Is_AIX = $^O eq 'aix'; +$Is_OSF = $^O eq 'dec_osf'; +$Is_IRIX = $^O eq 'irix'; +$Is_NetBSD = $^O eq 'netbsd'; +$Is_SunOS4 = $^O eq 'sunos'; +$Is_Solaris = $^O eq 'solaris'; +$Is_SunOS = $Is_SunOS4 || $Is_Solaris; +$Is_BSD = $^O =~ /^(?:free|net|open)bsd|bsdos$/; + =head1 NAME @@ -65,7 +77,8 @@ will be overridable via the MY class. The following description of methods is still under development. Please refer to the code for not suitably documented -sections and complain loudly to the makemaker mailing list. +sections and complain loudly to the makemaker@perl.org mailing list. +Better yet, provide a patch. Not all of the methods below are overridable in a Makefile.PL. Overridable methods are marked as (o). All methods are @@ -75,102 +88,26 @@ L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>). =cut # So we don't have to keep calling the methods over and over again, -# we have these globals to cache the values. They have to be global -# else the SelfLoaded methods can't see them. -use vars qw($Curdir $Rootdir $Updir); -$Curdir = File::Spec->curdir; -$Rootdir = File::Spec->rootdir; -$Updir = File::Spec->updir; - -sub c_o; -sub clean; -sub const_cccmd; -sub const_config; -sub const_loadlibs; -sub constants; -sub depend; -sub dir_target; -sub dist; -sub dist_basics; -sub dist_ci; -sub dist_core; -sub dist_dir; -sub dist_test; -sub dlsyms; -sub dynamic; -sub dynamic_bs; -sub dynamic_lib; -sub exescan; -sub export_list; -sub extliblist; -sub find_perl; -sub fixin; -sub force; -sub guess_name; -sub has_link_code; -sub init_dirscan; -sub init_main; -sub init_others; -sub install; -sub installbin; -sub libscan; -sub linkext; -sub lsdir; -sub macro; -sub makeaperl; -sub makefile; -sub manifypods; -sub maybe_command; -sub maybe_command_in_dirs; -sub needs_linking; -sub nicetext; -sub parse_abstract; -sub parse_version; -sub pasthru; -sub perl_archive; -sub perl_archive_after; -sub perl_script; -sub perldepend; -sub pm_to_blib; -sub ppd; -sub post_constants; -sub post_initialize; -sub postamble; -sub prefixify; -sub processPL; -sub quote_paren; -sub realclean; -sub replace_manpage_separator; -sub static; -sub static_lib; -sub staticmake; -sub subdir_x; -sub subdirs; -sub test; -sub test_via_harness; -sub test_via_script; -sub tool_autosplit; -sub tool_xsubpp; -sub tools_other; -sub top_targets; -sub writedoc; -sub xs_c; -sub xs_cpp; -sub xs_o; -sub xsubpp_version; - -#use SelfLoader; - -# SelfLoader not smart enough to avoid autoloading DESTROY -sub DESTROY { } - -#1; - -#__DATA__ - -=head2 SelfLoaded methods +# we have these globals to cache the values. Faster and shrtr. +my $Curdir = __PACKAGE__->curdir; +my $Rootdir = __PACKAGE__->rootdir; +my $Updir = __PACKAGE__->updir; + + +=head2 Methods + +=over 4 + +=item os_flavor (o) + +Simply says that we're Unix. + +=cut + +sub os_flavor { + return('Unix'); +} -=over 2 =item c_o (o) @@ -343,27 +280,11 @@ sub clean { # Delete temporary files but do not touch installed files. We don\'t delete # the Makefile here so a later make realclean still has a makefile to use. -clean :: +clean :: clean_subdirs '); - # clean subdirectories first - for $dir (@{$self->{DIR}}) { - if ($Is_Win32 && Win32::IsWin95()) { - push @m, <<EOT; - cd $dir - \$(TEST_F) $self->{MAKEFILE} - \$(MAKE) clean - cd .. -EOT - } - else { - push @m, <<EOT; - -cd $dir && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) clean -EOT - } - } my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files - if ( $^O eq 'qnx' ) { + if ( $Is_QNX ) { my @errfiles = @{$self->{C}}; for ( @errfiles ) { s/.c$/.err/; @@ -373,6 +294,7 @@ EOT push(@otherfiles, $attribs{FILES}) if $attribs{FILES}; push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all + $(INST_ARCHAUTODIR)/extralibs.ld perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso @@ -384,17 +306,52 @@ EOT } else { push(@otherfiles, qw[core core.*perl.*.? *perl.core]); + + # core.\d+ + push(@otherfiles, map { "core." . "[0-9]"x$_ } (1..5)); } - push @m, "\t-$self->{RM_RF} @otherfiles\n"; + push @m, "\t-\$(RM_RF) @otherfiles\n"; # See realclean and ext/utils/make_ext for usage of Makefile.old push(@m, - "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old \$(DEV_NULL)\n"); + "\t-\$(MV) \$(FIRST_MAKEFILE) \$(MAKEFILE_OLD) \$(DEV_NULL)\n"); push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP}; join("", @m); } + +=item clean_subdirs_target + + my $make_frag = $MM->clean_subdirs_target; + +Returns the clean_subdirs target. This is used by the clean target to +call clean on any subdirectories which contain Makefiles. + +=cut + +sub clean_subdirs_target { + my($self) = shift; + + # No subdirectories, no cleaning. + return <<'NOOP_FRAG' unless @{$self->{DIR}}; +clean_subdirs : + $(NOECHO) $(NOOP) +NOOP_FRAG + + + my $clean = "clean_subdirs :\n"; + + for my $dir (@{$self->{DIR}}) { + $clean .= sprintf <<'MAKE_FRAG', $dir; + -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) clean +MAKE_FRAG + } + + return $clean; +} + + =item const_cccmd (o) Returns the full compiler call for C programs and stores the @@ -430,7 +387,7 @@ sub const_config { my(%once_only); foreach $m (@{$self->{CONFIG}}){ # SITE*EXP macros are defined in &constants; avoid duplicates here - next if $once_only{$m} or $m eq 'sitelibexp' or $m eq 'sitearchexp'; + next if $once_only{$m}; $self->{uc $m} = quote_paren($self->{uc $m}); push @m, uc($m) , ' = ' , $self->{uc $m}, "\n"; $once_only{$m} = 1; @@ -466,53 +423,58 @@ sub const_loadlibs { =item constants (o) -Initializes lots of constants and .SUFFIXES and .PHONY + my $make_frag = $mm->constants; + +Prints out macros for lots of constants. =cut sub constants { my($self) = @_; - my(@m,$tmp); + my @m = (); - for $tmp (qw/ + for my $macro (qw( - AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION - VERSION_SYM XS_VERSION - INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB + AR_STATIC_ARGS DIRFILESEP + NAME NAME_SYM + VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION + XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION + INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB + INST_MAN1DIR INST_MAN3DIR + MAN1EXT MAN3EXT INSTALLDIRS - PREFIX SITEPREFIX VENDORPREFIX - INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB - INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH - INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN INSTALLSCRIPT - PERL_LIB PERL_ARCHLIB - SITELIBEXP SITEARCHEXP + DESTDIR PREFIX + PERLPREFIX SITEPREFIX VENDORPREFIX + ), + (map { ("INSTALL".$_, + "DESTINSTALL".$_) + } $self->installvars), + qw( + PERL_LIB + PERL_ARCHLIB LIBPERL_A MYEXTLIB - FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC - PERL_INC PERL FULLPERL PERLRUN FULLPERLRUN PERLRUNINST - FULLPERLRUNINST ABSPERL ABSPERLRUN ABSPERLRUNINST - FULL_AR PERL_CORE NOOP NOECHO - - / ) + FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE + PERLMAINCC PERL_SRC PERL_INC + PERL FULLPERL ABSPERL + PERLRUN FULLPERLRUN ABSPERLRUN + PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST + PERL_CORE + PERM_RW PERM_RWX + + ) ) { - next unless defined $self->{$tmp}; + next unless defined $self->{$macro}; # pathnames can have sharp signs in them; escape them so # make doesn't think it is a comment-start character. - $self->{$tmp} =~ s/#/\\#/g; - push @m, "$tmp = $self->{$tmp}\n"; + $self->{$macro} =~ s/#/\\#/g; + push @m, "$macro = $self->{$macro}\n"; } push @m, qq{ -VERSION_MACRO = VERSION -DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\" -XS_VERSION_MACRO = XS_VERSION -XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\" -PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -}; - - push @m, qq{ -MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'} -MM_VERSION = $ExtUtils::MakeMaker::VERSION +MAKEMAKER = $self->{MAKEMAKER} +MM_VERSION = $self->{MM_VERSION} +MM_REVISION = $self->{MM_REVISION} }; push @m, q{ @@ -522,115 +484,64 @@ MM_VERSION = $ExtUtils::MakeMaker::VERSION # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. }; - for $tmp (qw/ + for my $macro (qw/ FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT LDFROM LINKTYPE PM_FILTER / ) { - next unless defined $self->{$tmp}; - push @m, "$tmp = $self->{$tmp}\n"; + next unless defined $self->{$macro}; + push @m, "$macro = $self->{$macro}\n"; } push @m, " # Handy lists of source code files: -XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})." -C_FILES = ".join(" \\\n\t", @{$self->{C}})." -O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})." -H_FILES = ".join(" \\\n\t", @{$self->{H}})." -MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})." -MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})." +XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})." +C_FILES = ".$self->wraplist(@{$self->{C}})." +O_FILES = ".$self->wraplist(@{$self->{O_FILES}})." +H_FILES = ".$self->wraplist(@{$self->{H}})." +MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})." +MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})." "; - for $tmp (qw/ - INST_MAN1DIR MAN1EXT - INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DIR - INST_MAN3DIR MAN3EXT - INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DIR - /) - { - next unless defined $self->{$tmp}; - push @m, "$tmp = $self->{$tmp}\n"; - } - - for $tmp (qw( - PERM_RW PERM_RWX - ) - ) - { - my $method = lc($tmp); - # warn "self[$self] method[$method]"; - push @m, "$tmp = ", $self->$method(), "\n"; - } push @m, q{ -.NO_CONFIG_REC: Makefile -} if $ENV{CLEARCASE_ROOT}; - - # why not q{} ? -- emacs - push @m, qq{ -# work around a famous dec-osf make(1) feature(?): -makemakerdflt: all +# Where is the Config information that we are using/depend on +CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h +}; -.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc \$(OBJ_EXT) -# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that -# some make implementations will delete the Makefile when we rebuild it. Because -# we call false(1) when we rebuild it. So make(1) is not completely wrong when it -# does so. Our milage may vary. -# .PRECIOUS: Makefile # seems to be not necessary anymore + push @m, qq{ +# Where to build things +INST_LIBDIR = $self->{INST_LIBDIR} +INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR} -.PHONY: all config static dynamic test linkext manifest +INST_AUTODIR = $self->{INST_AUTODIR} +INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR} -# Where is the Config information that we are using/depend on -CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h +INST_STATIC = $self->{INST_STATIC} +INST_DYNAMIC = $self->{INST_DYNAMIC} +INST_BOOT = $self->{INST_BOOT} }; - my @parentdir = split(/::/, $self->{PARENT_NAME}); - push @m, q{ -# Where to put things: -INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{ -INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{ -INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{ -INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{ + push @m, qq{ +# Extra linker info +EXPORT_LIST = $self->{EXPORT_LIST} +PERL_ARCHIVE = $self->{PERL_ARCHIVE} +PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER} }; - if ($self->has_link_code()) { - push @m, ' -INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT) -INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT) -INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs -'; - } else { - push @m, ' -INST_STATIC = -INST_DYNAMIC = -INST_BOOT = -'; - } - - $tmp = $self->export_list; - push @m, " -EXPORT_LIST = $tmp -"; - $tmp = $self->perl_archive; - push @m, " -PERL_ARCHIVE = $tmp -"; - $tmp = $self->perl_archive_after; push @m, " -PERL_ARCHIVE_AFTER = $tmp -"; - push @m, q{ -TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{ +TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})." -PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ -}; +PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}})." +"; join('',@m); } + =item depend (o) Same as macro for the depend attribute. @@ -669,8 +580,8 @@ sub dir_target { my($self,@dirs) = @_; my(@m,$dir,$targdir); foreach $dir (@dirs) { - my($src) = File::Spec->catfile($self->{PERL_INC},'perl.h'); - my($targ) = File::Spec->catfile($dir,'.exists'); + my($src) = $self->catfile($self->{PERL_INC},'perl.h'); + my($targ) = $self->catfile($dir,'.exists'); # catfile may have adapted syntax of $dir to target OS, so... if ($Is_VMS) { # Just remove file name; dirspec is often in macro ($targdir = $targ) =~ s:/?\.exists\z::; @@ -681,53 +592,131 @@ sub dir_target { next if $self->{DIR_TARGET}{$self}{$targdir}++; push @m, qq{ $targ :: $src - $self->{NOECHO}\$(MKPATH) $targdir - $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) $src $targ + \$(NOECHO) \$(MKPATH) $targdir + \$(NOECHO) \$(EQUALIZE_TIMESTAMP) $src $targ }; push(@m, qq{ - -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $targdir + -\$(NOECHO) \$(CHMOD) \$(PERM_RWX) $targdir }) unless $Is_VMS; } join "", @m; } -=item dist (o) +=item init_DEST + + $mm->init_DEST + +Defines the DESTDIR and DEST* variables paralleling the INSTALL*. + +=cut + +sub init_DEST { + my $self = shift; + + # Initialize DESTDIR + $self->{DESTDIR} ||= ''; + + # Make DEST variables. + foreach my $var ($self->installvars) { + my $destvar = 'DESTINSTALL'.$var; + $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')'; + } +} + + +=item init_dist + + $mm->init_dist; Defines a lot of macros for distribution support. + macro description default + + TAR tar command to use tar + TARFLAGS flags to pass to TAR cvf + + ZIP zip command to use zip + ZIPFLAGS flags to pass to ZIP -r + + COMPRESS compression command to gzip --best + use for tarfiles + SUFFIX suffix to put on .gz + compressed files + + SHAR shar command to use shar + + PREOP extra commands to run before + making the archive + POSTOP extra commands to run after + making the archive + + TO_UNIX a command to convert linefeeds + to Unix style in your archive + + CI command to checkin your ci -u + sources to version control + RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q + just after CI is run + + DIST_CP $how argument to manicopy() best + when the distdir is created + + DIST_DEFAULT default target to use to tardist + create a distribution + + DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION) + (minus suffixes) + +=cut + +sub init_dist { + my $self = shift; + + $self->{TAR} ||= 'tar'; + $self->{TARFLAGS} ||= 'cvf'; + $self->{ZIP} ||= 'zip'; + $self->{ZIPFLAGS} ||= '-r'; + $self->{COMPRESS} ||= 'gzip --best'; + $self->{SUFFIX} ||= '.gz'; + $self->{SHAR} ||= 'shar'; + $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST + $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir + $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)'; + + $self->{CI} ||= 'ci -u'; + $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q'; + $self->{DIST_CP} ||= 'best'; + $self->{DIST_DEFAULT} ||= 'tardist'; + + ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME}; + $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION}; + +} + +=item dist (o) + + my $dist_macros = $mm->dist(%overrides); + +Generates a make fragment defining all the macros initialized in +init_dist. + +%overrides can be used to override any of the above. + =cut sub dist { my($self, %attribs) = @_; - # VERSION should be sanitised before use as a file name - $attribs{VERSION} ||= '$(VERSION)'; - $attribs{NAME} ||= '$(DISTNAME)'; - $attribs{TAR} ||= 'tar'; - $attribs{TARFLAGS} ||= 'cvf'; - $attribs{ZIP} ||= 'zip'; - $attribs{ZIPFLAGS} ||= '-r'; - $attribs{COMPRESS} ||= 'gzip --best'; - $attribs{SUFFIX} ||= '.gz'; - $attribs{SHAR} ||= 'shar'; - $attribs{PREOP} ||= "$self->{NOECHO}\$(NOOP)"; # eg update MANIFEST - $attribs{POSTOP} ||= "$self->{NOECHO}\$(NOOP)"; # eg remove the distdir - $attribs{TO_UNIX} ||= "$self->{NOECHO}\$(NOOP)"; - - $attribs{CI} ||= 'ci -u'; - $attribs{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q'; - $attribs{DIST_CP} ||= 'best'; - $attribs{DIST_DEFAULT} ||= 'tardist'; - - $attribs{DISTVNAME} ||= "$attribs{NAME}-$attribs{VERSION}"; - - # We've already printed out VERSION and NAME variables. - delete $attribs{VERSION}; - delete $attribs{NAME}; - my $make = ''; - while(my($var, $value) = each %attribs) { - $make .= "$var = $value\n"; + foreach my $key (qw( + TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR + PREOP POSTOP TO_UNIX + CI RCS_LABEL DIST_CP DIST_DEFAULT + DISTNAME DISTVNAME + )) + { + my $value = $attribs{$key} || $self->{$key}; + $make .= "$key = $value\n"; } return $make; @@ -770,35 +759,116 @@ Defines a check in target for RCS. sub dist_ci { my($self) = shift; - my @m; - push @m, q{ + return q{ ci : $(PERLRUN) "-MExtUtils::Manifest=maniread" \\ - -e "@all = keys %{ maniread() };" \\ - -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\ - -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");' + -e "@all = keys %{ maniread() };" \\ + -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\ + -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" }; - join "", @m; } =item dist_core (o) -Defines the targets dist, tardist, zipdist, uutardist, shdist + my $dist_make_fragment = $MM->dist_core; + +Puts the targets necessary for 'make dist' together into one make +fragment. =cut sub dist_core { my($self) = shift; - my @m; - push @m, q{ -dist : $(DIST_DEFAULT) - }.$self->{NOECHO}.q{$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \ - -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "}.$self->{MAKEFILE}.q{";' + my $make_frag = ''; + foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile + shdist)) + { + my $method = $target.'_target'; + $make_frag .= "\n"; + $make_frag .= $self->$method(); + } + + return $make_frag; +} + + +=item B<dist_target> + + my $make_frag = $MM->dist_target; + +Returns the 'dist' target to make an archive for distribution. This +target simply checks to make sure the Makefile is up-to-date and +depends on $(DIST_DEFAULT). + +=cut + +sub dist_target { + my($self) = shift; + + my $date_check = $self->oneliner(<<'CODE', ['-l']); +print 'Warning: Makefile possibly out of date with $(VERSION_FROM)' + if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)'; +CODE + + return sprintf <<'MAKE_FRAG', $date_check; +dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) + $(NOECHO) %s +MAKE_FRAG +} + +=item B<tardist_target> + + my $make_frag = $MM->tardist_target; + +Returns the 'tardist' target which is simply so 'make tardist' works. +The real work is done by the dynamically named tardistfile_target() +method, tardist should have that as a dependency. + +=cut + +sub tardist_target { + my($self) = shift; + + return <<'MAKE_FRAG'; tardist : $(DISTVNAME).tar$(SUFFIX) + $(NOECHO) $(NOOP) +MAKE_FRAG +} + +=item B<zipdist_target> + + my $make_frag = $MM->zipdist_target; + +Returns the 'zipdist' target which is simply so 'make zipdist' works. +The real work is done by the dynamically named zipdistfile_target() +method, zipdist should have that as a dependency. + +=cut + +sub zipdist_target { + my($self) = shift; + return <<'MAKE_FRAG'; zipdist : $(DISTVNAME).zip + $(NOECHO) $(NOOP) +MAKE_FRAG +} + +=item B<tarfile_target> + + my $make_frag = $MM->tarfile_target; + +The name of this target is the name of the tarball generated by +tardist. This target does the actual work of turning the distdir into +a tarball. + +=cut + +sub tarfile_target { + my($self) = shift; + return <<'MAKE_FRAG'; $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) @@ -806,39 +876,84 @@ $(DISTVNAME).tar$(SUFFIX) : distdir $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(POSTOP) +MAKE_FRAG +} + +=item zipfile_target + + my $make_frag = $MM->zipfile_target; + +The name of this target is the name of the zip file generated by +zipdist. This target does the actual work of turning the distdir into +a zip file. +=cut + +sub zipfile_target { + my($self) = shift; + + return <<'MAKE_FRAG'; $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(POSTOP) +MAKE_FRAG +} + +=item uutardist_target + + my $make_frag = $MM->uutardist_target; +Converts the tarfile into a uuencoded file + +=cut + +sub uutardist_target { + my($self) = shift; + + return <<'MAKE_FRAG'; uutardist : $(DISTVNAME).tar$(SUFFIX) - uuencode $(DISTVNAME).tar$(SUFFIX) \\ - $(DISTVNAME).tar$(SUFFIX) > \\ - $(DISTVNAME).tar$(SUFFIX)_uu + uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu +MAKE_FRAG +} + +=item shdist_target + + my $make_frag = $MM->shdist_target; + +Converts the distdir into a shell archive. + +=cut + +sub shdist_target { + my($self) = shift; + + return <<'MAKE_FRAG'; shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar $(RM_RF) $(DISTVNAME) $(POSTOP) -}; - join "", @m; +MAKE_FRAG } -=item dist_dir +=item distdir Defines the scratch directory target that will hold the distribution before tar-ing (or shar-ing). =cut -sub dist_dir { +# For backwards compatibility. +*dist_dir = *distdir; + +sub distdir { my($self) = shift; return <<'MAKE_FRAG'; -distdir : +distdir : metafile metafile_addtomanifest $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" @@ -877,7 +992,7 @@ files. sub dlsyms { my($self,%attribs) = @_; - return '' unless ($^O eq 'aix' && $self->needs_linking() ); + return '' unless ($Is_AIX && $self->needs_linking() ); my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; @@ -916,11 +1031,8 @@ sub dynamic { my($self) = shift; ' -## $(INST_PM) has been moved to the all: target. -## It remains here for awhile to allow for old usage: "make dynamic" -#dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM) -dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) - '.$self->{NOECHO}.'$(NOOP) +dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) + $(NOECHO) $(NOOP) '; } @@ -936,25 +1048,25 @@ sub dynamic_bs { BOOTSTRAP = ' unless $self->has_link_code(); - return ' -BOOTSTRAP = '."$self->{BASEEXT}.bs".' + return <<'MAKE_FRAG'; +BOOTSTRAP = $(BASEEXT).bs # As Mkbootstrap might not write a file (if none is required) # we use touch to prevent make continually trying to remake it. # The DynaLoader only reads a non-empty file. -$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists - '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" - '.$self->{NOECHO}.'$(PERLRUN) \ +$(BOOTSTRAP): $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" + $(NOECHO) $(PERLRUN) \ "-MExtUtils::Mkbootstrap" \ - -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');" - '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP) + -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');" + $(NOECHO) $(TOUCH) $(BOOTSTRAP) $(CHMOD) $(PERM_RW) $@ -$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists - '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT) - -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT) +$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(RM_RF) $(INST_BOOT) + -$(CP) $(BOOTSTRAP) $(INST_BOOT) $(CHMOD) $(PERM_RW) $@ -'; +MAKE_FRAG } =item dynamic_lib (o) @@ -973,27 +1085,29 @@ sub dynamic_lib { my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":"; my($ldfrom) = '$(LDFROM)'; - $armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':'); + $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':'); my(@m); my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : ''; # Useful on other systems too? + my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : ''; push(@m,' # This section creates the dynamically loadable $(INST_DYNAMIC) # from $(OBJECT) and possibly $(MYEXTLIB). ARMAYBE = '.$armaybe.' OTHERLDFLAGS = '.$ld_opt.$otherldflags.' INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' +INST_DYNAMIC_FIX = '.$ld_fix.' -$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP) +$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP) '); if ($armaybe ne ':'){ $ldfrom = 'tmp$(LIB_EXT)'; push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n"); push(@m,' $(RANLIB) '."$ldfrom\n"); } - $ldfrom = "-all $ldfrom -none" if ($^O eq 'dec_osf'); + $ldfrom = "-all $ldfrom -none" if $Is_OSF; # The IRIX linker doesn't use LD_RUN_PATH - my $ldrun = $^O eq 'irix' && $self->{LD_RUN_PATH} ? + my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ? qq{-rpath "$self->{LD_RUN_PATH}"} : ''; # For example in AIX the shared objects/libraries from previous builds @@ -1006,7 +1120,7 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists my $libs = '$(LDLOADLIBS)'; - if ($^O eq 'netbsd') { + if ($Is_NetBSD) { # Use nothing on static perl platforms, and to the flags needed # to link against the shared libperl library on shared perl # platforms. We peek at lddlflags to see if we need -Wl,-R @@ -1022,7 +1136,7 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists push(@m, ' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) '.$ldrun.' $(LDDLFLAGS) '.$ldfrom. -' $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) $(PERL_ARCHIVE) '.$libs.' $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST)'); +' $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) $(PERL_ARCHIVE) '.$libs.' $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) $(INST_DYNAMIC_FIX)'); push @m, ' $(CHMOD) $(PERM_RWX) $@ '; @@ -1065,34 +1179,65 @@ sub find_perl { my($self, $ver, $names, $dirs, $trace) = @_; my($name, $dir); if ($trace >= 2){ - print "Looking for perl $ver by these names: + print "Looking for perl $ver by these names: @$names in these dirs: @$dirs "; } + + my $stderr_duped = 0; + local *STDERR_COPY; + unless ($Is_BSD) { + if( open(STDERR_COPY, '>&STDERR') ) { + $stderr_duped = 1; + } + else { + warn <<WARNING; +find_perl() can't dup STDERR: $! +You might see some garbage while we search for Perl +WARNING + } + } + foreach $name (@$names){ - foreach $dir (@$dirs){ - next unless defined $dir; # $self->{PERL_SRC} may be undefined - my ($abs, $val); - if (File::Spec->file_name_is_absolute($name)) { # /foo/bar - $abs = $name; - } elsif (File::Spec->canonpath($name) eq File::Spec->canonpath(basename($name))) { # foo - $abs = File::Spec->catfile($dir, $name); - } else { # foo/bar - $abs = File::Spec->canonpath(File::Spec->catfile($Curdir, $name)); - } - print "Checking $abs\n" if ($trace >= 2); - next unless $self->maybe_command($abs); - print "Executing $abs\n" if ($trace >= 2); - $val = `$abs -e 'require $ver; print "VER_OK\n" ' 2>&1`; - if ($val =~ /VER_OK/) { - print "Using PERL=$abs\n" if $trace; - return $abs; - } elsif ($trace >= 2) { - print "Result: `$val'\n"; - } - } + foreach $dir (@$dirs){ + next unless defined $dir; # $self->{PERL_SRC} may be undefined + my ($abs, $val); + if ($self->file_name_is_absolute($name)) { # /foo/bar + $abs = $name; + } elsif ($self->canonpath($name) eq + $self->canonpath(basename($name))) { # foo + $abs = $self->catfile($dir, $name); + } else { # foo/bar + $abs = $self->catfile($Curdir, $name); + } + print "Checking $abs\n" if ($trace >= 2); + next unless $self->maybe_command($abs); + print "Executing $abs\n" if ($trace >= 2); + + my $version_check = qq{$abs -e "require $ver; print qq{VER_OK\n}"}; + # To avoid using the unportable 2>&1 to supress STDERR, + # we close it before running the command. + # However, thanks to a thread library bug in many BSDs + # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 ) + # we cannot use the fancier more portable way in here + # but instead need to use the traditional 2>&1 construct. + if ($Is_BSD) { + $val = `$version_check 2>&1`; + } else { + close STDERR if $stderr_duped; + $val = `$version_check`; + open STDERR, '>&STDERR_COPY' if $stderr_duped; + } + + if ($val =~ /^VER_OK/) { + print "Using PERL=$abs\n" if $trace; + return $abs; + } elsif ($trace >= 2) { + print "Result: '$val'\n"; + } + } } print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n"; 0; # false and not empty @@ -1134,6 +1279,9 @@ sub fixin { # stolen from the pink Camel book, more or less my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/; for my $file (@files) { + my $file_new = "$file.new"; + my $file_bak = "$file.bak"; + local(*FIXIN); local(*FIXOUT); open(FIXIN, $file) or croak "Can't process '$file': $!"; @@ -1154,13 +1302,13 @@ sub fixin { # stolen from the pink Camel book, more or less $interpreter = $Config{perlpath}; } } else { - my(@absdirs) = reverse grep {File::Spec->file_name_is_absolute} File::Spec->path; + my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path; $interpreter = ''; my($dir); foreach $dir (@absdirs) { if ($self->maybe_command($cmd)) { warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter; - $interpreter = File::Spec->catfile($dir,$cmd); + $interpreter = $self->catfile($dir,$cmd); } } } @@ -1185,11 +1333,10 @@ eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}' next; } - unless ( open(FIXOUT,">$file.new") ) { + unless ( open(FIXOUT,">$file_new") ) { warn "Can't create new $file: $!\n"; next; } - my($dev,$ino,$mode) = stat FIXIN; # Print out the new #! line (or equivalent). local $\; @@ -1198,19 +1345,21 @@ eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}' close FIXIN; close FIXOUT; - unless ( rename($file, "$file.bak") ) { - warn "Can't rename $file to $file.bak: $!"; + chmod 0666, $file_bak; + unlink $file_bak; + unless ( rename($file, $file_bak) ) { + warn "Can't rename $file to $file_bak: $!"; next; } - unless ( rename("$file.new", $file) ) { - warn "Can't rename $file.new to $file: $!"; - unless ( rename("$file.bak", $file) ) { - warn "Can't rename $file.bak back to $file either: $!"; - warn "Leaving $file renamed as $file.bak\n"; + unless ( rename($file_new, $file) ) { + warn "Can't rename $file_new to $file: $!"; + unless ( rename($file_bak, $file) ) { + warn "Can't rename $file_bak back to $file either: $!"; + warn "Leaving $file renamed as $file_bak\n"; } next; } - unlink "$file.bak"; + unlink $file_bak; } continue { close(FIXIN) if fileno(FIXIN); system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';; @@ -1227,7 +1376,7 @@ sub force { my($self) = shift; '# Phony target to force checking subdirectories. FORCE: - '.$self->{NOECHO}.'$(NOOP) + $(NOECHO) $(NOOP) '; } @@ -1273,14 +1422,17 @@ sub has_link_code { =item init_dirscan -Initializes DIR, XS, PM, C, O_FILES, H, PL_FILES, MAN*PODS, EXE_FILES. +Scans the directory structure and initializes DIR, XS, XS_FILES, PM, +C, C_FILES, O_FILES, H, H_FILES, PL_FILES, MAN*PODS, EXE_FILES. + +Called by init_main. =cut sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) my($self) = @_; my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods); - local(%pm); #the sub in find() has to see this hash + my %pm; @ignore{qw(Makefile.PL test.pl t)} = (1,1,1); @@ -1296,7 +1448,8 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) next unless $self->libscan($name); if (-d $name){ next if -l $name; # We do not support symlinks at all - $dir{$name} = $name if (-f File::Spec->catfile($name,"Makefile.PL")); + next if $self->{NORECURS}; + $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL")); } elsif ($name =~ /\.xs\z/){ my($c); ($c = $name) =~ s/\.xs\z/.c/; $xs{$name} = $c; @@ -1316,10 +1469,10 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) ($pl_files{$name} = $name) =~ s/[._]pl\z//i ; } else { - $pm{$name} = File::Spec->catfile($self->{INST_LIBDIR},$name); + $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name); } } elsif ($name =~ /\.(p[ml]|pod)\z/){ - $pm{$name} = File::Spec->catfile($self->{INST_LIBDIR},$name); + $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name); } } @@ -1349,14 +1502,14 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) # (which includes PARENT_NAME). This is a subtle distinction but one # that's important for nested modules. - if ($Is_VMS) { - # avoid logical name collisions by adding directory syntax - $self->{PMLIBDIRS} = ['./lib', './' . $self->{BASEEXT}] - unless $self->{PMLIBDIRS}; - } - else { - $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}] - unless $self->{PMLIBDIRS}; + unless( $self->{PMLIBDIRS} ) { + if( $Is_VMS ) { + # Avoid logical name vs directory collisions + $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"]; + } + else { + $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]; + } } #only existing directories that aren't in $dir are allowed @@ -1376,13 +1529,14 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) require File::Find; File::Find::find(sub { if (-d $_){ - if ($_ eq "CVS" || $_ eq "RCS"){ + unless ($self->libscan($_)){ $File::Find::prune = 1; } return; } return if /\#/; return if /~$/; # emacs temp files + return if /,v$/; # RCS files my $path = $File::Find::name; my $prefix = $self->{INST_LIBDIR}; @@ -1391,7 +1545,7 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) $prefix = $self->{INST_LIB} if ($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i; - my($inst) = File::Spec->catfile($prefix,$striplibpath); + my($inst) = $self->catfile($prefix,$striplibpath); local($_) = $inst; # for backwards compatibility $inst = $self->libscan($inst); print "libscan($path) => '$inst'\n" if ($Verbose >= 2); @@ -1400,21 +1554,25 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) }, @{$self->{PMLIBDIRS}}); } - $self->{DIR} = [sort keys %dir] unless $self->{DIR}; - $self->{XS} = \%xs unless $self->{XS}; - $self->{PM} = \%pm unless $self->{PM}; - $self->{C} = [sort keys %c] unless $self->{C}; - my(@o_files) = @{$self->{C}}; - $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files] ; - $self->{H} = [sort keys %h] unless $self->{H}; - $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES}; + $self->{PM} ||= \%pm; + $self->{PL_FILES} ||= \%pl_files; + + $self->{DIR} ||= [sort keys %dir]; + + $self->{XS} ||= \%xs; + $self->{C} ||= [sort keys %c]; + my @o_files = @{$self->{C}}; + $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files]; + + $self->{H} ||= [sort keys %h]; # Set up names of manual pages to generate from pods my %pods; foreach my $man (qw(MAN1 MAN3)) { unless ($self->{"${man}PODS"}) { $self->{"${man}PODS"} = {}; - $pods{$man} = 1 unless $self->{"INST_${man}DIR"} =~ /^(none|\s*)$/; + $pods{$man} = 1 unless + $self->{"INST_${man}DIR"} =~ /^(none|\s*)$/; } } @@ -1425,7 +1583,7 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) my($ispod)=0; if (open(FH,"<$name")) { while (<FH>) { - if (/^=(head[1-4]|item|pod)\b/) { + if (/^=(?:head\d+|item|pod)\b/) { $ispod=1; last; } @@ -1438,7 +1596,7 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) next unless $ispod; if ($pods{MAN1}) { $self->{MAN1PODS}->{$name} = - File::Spec->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)"); + $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)"); } } } @@ -1454,7 +1612,7 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) my($ispod)=0; if (open(FH,"<$name")) { while (<FH>) { - if (/^=(head[1-4]|item|pod)\b/) { + if (/^=head1\s+\w+/) { $ispod=1; last; } @@ -1479,26 +1637,42 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) } my($manpagename) = $name; $manpagename =~ s/\.p(od|m|l)\z//; - unless ($manpagename =~ s!^\W*lib\W+!!s) { # everything below lib is ok - $manpagename = File::Spec->catfile(split(/::/,$self->{PARENT_NAME}),$manpagename); + # everything below lib is ok + unless($manpagename =~ s!^\W*lib\W+!!s) { + $manpagename = $self->catfile( + split(/::/,$self->{PARENT_NAME}),$manpagename + ); } if ($pods{MAN3}) { $manpagename = $self->replace_manpage_separator($manpagename); $self->{MAN3PODS}->{$name} = - File::Spec->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)"); + $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)"); } } } } +=item init_DIRFILESEP + +Using / for Unix. Called by init_main. + +=cut + +sub init_DIRFILESEP { + my($self) = shift; + + $self->{DIRFILESEP} = '/'; +} + + =item init_main Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE, EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*, -INSTALL*, INSTALLDIRS, LD, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME, +INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME, OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB, PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION, -VERSION_FROM, VERSION_SYM, XS_VERSION. +VERSION_SYM, XS_VERSION. =cut @@ -1514,7 +1688,7 @@ sub init_main { ### Only UNIX: ### ($self->{FULLEXT} = ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket - $self->{FULLEXT} = File::Spec->catdir(split /::/, $self->{NAME}); + $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME}); # Copied from DynaLoader: @@ -1549,17 +1723,17 @@ sub init_main { unless ($self->{PERL_SRC}){ my($dir); foreach $dir ($Updir, - File::Spec->catdir($Updir,$Updir), - File::Spec->catdir($Updir,$Updir,$Updir), - File::Spec->catdir($Updir,$Updir,$Updir,$Updir), - File::Spec->catdir($Updir,$Updir,$Updir,$Updir,$Updir)) + $self->catdir($Updir,$Updir), + $self->catdir($Updir,$Updir,$Updir), + $self->catdir($Updir,$Updir,$Updir,$Updir), + $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir)) { if ( - -f File::Spec->catfile($dir,"config_h.SH") + -f $self->catfile($dir,"config_h.SH") && - -f File::Spec->catfile($dir,"perl.h") + -f $self->catfile($dir,"perl.h") && - -f File::Spec->catfile($dir,"lib","Exporter.pm") + -f $self->catfile($dir,"lib","Exporter.pm") ) { $self->{PERL_SRC}=$dir ; last; @@ -1571,28 +1745,28 @@ sub init_main { $self->{PERL_CORE} and !$self->{PERL_SRC}; if ($self->{PERL_SRC}){ - $self->{PERL_LIB} ||= File::Spec->catdir("$self->{PERL_SRC}","lib"); + $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib"); if (defined $Cross::platform) { $self->{PERL_ARCHLIB} = - File::Spec->catdir("$self->{PERL_SRC}","xlib",$Cross::platform); + $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform); $self->{PERL_INC} = - File::Spec->catdir("$self->{PERL_SRC}","xlib",$Cross::platform, + $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform, $Is_Win32?("CORE"):()); } else { $self->{PERL_ARCHLIB} = $self->{PERL_LIB}; $self->{PERL_INC} = ($Is_Win32) ? - File::Spec->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC}; + $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC}; } # catch a situation that has occurred a few times in the past: unless ( - -s File::Spec->catfile($self->{PERL_SRC},'cflags') + -s $self->catfile($self->{PERL_SRC},'cflags') or $Is_VMS && - -s File::Spec->catfile($self->{PERL_SRC},'perlshr_attr.opt') + -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt') or $Is_Mac or @@ -1617,20 +1791,20 @@ from the perl source tree. my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC}; $self->{PERL_LIB} ||= $Config{privlibexp}; $self->{PERL_ARCHLIB} ||= $Config{archlibexp}; - $self->{PERL_INC} = File::Spec->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now + $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now my $perl_h; - if (not -f ($perl_h = File::Spec->catfile($self->{PERL_INC},"perl.h")) + if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h")) and not $old){ # Maybe somebody tries to build an extension with an # uninstalled Perl outside of Perl build tree my $found; for my $dir (@INC) { - $found = $dir, last if -e File::Spec->catdir($dir, "Config.pm"); + $found = $dir, last if -e $self->catdir($dir, "Config.pm"); } if ($found) { my $inc = dirname $found; - if (-e File::Spec->catdir($inc, "perl.h")) { + if (-e $self->catdir($inc, "perl.h")) { $self->{PERL_LIB} = $found; $self->{PERL_ARCHLIB} = $found; $self->{PERL_INC} = $inc; @@ -1642,7 +1816,7 @@ EOP } } - unless(-f ($perl_h = File::Spec->catfile($self->{PERL_INC},"perl.h"))) + unless(-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))) { die qq{ Error: Unable to locate installed Perl libraries or Perl source code. @@ -1668,10 +1842,6 @@ usually solves this kind of problem. # MakeMaker. $self->{INSTALLDIRS} ||= "site"; - - $self->init_INST; - $self->init_INSTALL; - $self->{MAN1EXT} ||= $Config{man1ext}; $self->{MAN3EXT} ||= $Config{man3ext}; @@ -1681,8 +1851,8 @@ usually solves this kind of problem. $self->{CONFIG} = [] unless (ref $self->{CONFIG}); push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config); push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags}; - my(%once_only,$m); - foreach $m (@{$self->{CONFIG}}){ + my(%once_only); + foreach my $m (@{$self->{CONFIG}}){ next if $once_only{$m}; print STDOUT "CONFIG key '$m' does not exist in Config.pm\n" unless exists $Config{$m}; @@ -1700,7 +1870,6 @@ usually solves this kind of problem. $self->{AR_STATIC_ARGS} ||= "cr"; # These should never be needed - $self->{LD} ||= 'ld'; $self->{OBJ_EXT} ||= '.o'; $self->{LIB_EXT} ||= '.a'; @@ -1711,61 +1880,32 @@ usually solves this kind of problem. # make a simple check if we find Exporter warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory (Exporter.pm not found)" - unless -f File::Spec->catfile("$self->{PERL_LIB}","Exporter.pm") || + unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") || $self->{NAME} eq "ExtUtils::MakeMaker"; - - # Determine VERSION and VERSION_FROM - ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME}; - if ($self->{VERSION_FROM}){ - $self->{VERSION} = $self->parse_version($self->{VERSION_FROM}); - if( $self->{VERSION} eq 'undef' ) { - carp "WARNING: Setting VERSION via file ". - "'$self->{VERSION_FROM}' failed\n"; - } - } - - # strip blanks - if (defined $self->{VERSION}) { - $self->{VERSION} =~ s/^\s+//; - $self->{VERSION} =~ s/\s+$//; - } - else { - $self->{VERSION} = ''; - } - ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g; - - $self->{DISTVNAME} = "$self->{DISTNAME}-$self->{VERSION}"; - - # Graham Barr and Paul Marquess had some ideas how to ensure - # version compatibility between the *.pm file and the - # corresponding *.xs file. The bottomline was, that we need an - # XS_VERSION macro that defaults to VERSION: - $self->{XS_VERSION} ||= $self->{VERSION}; - - - # --- Initialize Perl Binary Locations - $self->init_PERL; } =item init_others -Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, -OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, NOOP, FIRST_MAKEFILE, -MAKEFILE, NOECHO, RM_F, RM_RF, TEST_F, TOUCH, CP, MV, CHMOD, UMASK_NULL +Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD, +OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP, +FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F, +TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N =cut sub init_others { # --- Initialize Other Attributes my($self) = shift; + $self->{LD} ||= 'ld'; + # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS} # 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: # May check $Config{libs} too, thus not empty. - $self->{LIBS}=[''] unless $self->{LIBS}; + $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS}; - $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq 'SCALAR'; + $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0]; $self->{LD_RUN_PATH} = ""; my($libs); foreach $libs ( @{$self->{LIBS}} ){ @@ -1801,36 +1941,62 @@ sub init_others { # --- Initialize Other Attributes : ($Config{usedl} ? 'dynamic' : 'static'); }; - # These get overridden for VMS and maybe some other systems - $self->{NOOP} ||= '$(SHELL) -c true'; - $self->{FIRST_MAKEFILE} ||= "Makefile"; - $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE}; - $self->{MAKE_APERL_FILE} ||= "Makefile.aperl"; - $self->{NOECHO} = '@' unless defined $self->{NOECHO}; - $self->{RM_F} ||= "rm -f"; - $self->{RM_RF} ||= "rm -rf"; - $self->{TOUCH} ||= "touch"; - $self->{TEST_F} ||= "test -f"; - $self->{CP} ||= "cp"; - $self->{MV} ||= "mv"; - $self->{CHMOD} ||= "chmod"; - $self->{UMASK_NULL} ||= "umask 0"; - $self->{DEV_NULL} ||= "> /dev/null 2>&1"; + $self->{NOOP} ||= '$(SHELL) -c true'; + $self->{NOECHO} = '@' unless defined $self->{NOECHO}; + + $self->{MAKEFILE} ||= 'Makefile'; + $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE}; + $self->{MAKEFILE_OLD} ||= '$(FIRST_MAKEFILE).old'; + $self->{MAKE_APERL_FILE} ||= '$(FIRST_MAKEFILE).aperl'; + + $self->{SHELL} ||= $Config{sh} || '/bin/sh'; + + $self->{ECHO} ||= 'echo'; + $self->{ECHO_N} ||= 'echo -n'; + $self->{RM_F} ||= "rm -f"; + $self->{RM_RF} ||= "rm -rf"; + $self->{TOUCH} ||= "touch"; + $self->{TEST_F} ||= "test -f"; + $self->{CP} ||= "cp"; + $self->{MV} ||= "mv"; + $self->{CHMOD} ||= "chmod"; + $self->{MKPATH} ||= '$(PERLRUN) "-MExtUtils::Command" -e mkpath'; + $self->{EQUALIZE_TIMESTAMP} ||= + '$(PERLRUN) "-MExtUtils::Command" -e eqtime'; + + $self->{UNINST} ||= 0; + $self->{VERBINST} ||= 0; + $self->{MOD_INSTALL} ||= + $self->oneliner(<<'CODE', ['-MExtUtils::Install']); +install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)'); +CODE + $self->{DOC_INSTALL} ||= + '$(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install'; + $self->{UNINSTALL} ||= + '$(PERLRUN) "-MExtUtils::Command::MM" -e uninstall'; + $self->{WARN_IF_OLD_PACKLIST} ||= + '$(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist'; + + $self->{UMASK_NULL} ||= "umask 0"; + $self->{DEV_NULL} ||= "> /dev/null 2>&1"; + + return 1; } =item init_INST $mm->init_INST; -Called by init_main. Sets up all INST_* variables. +Called by init_main. Sets up all INST_* variables except those related +to XS code. Those are handled in init_xs. =cut sub init_INST { my($self) = shift; - $self->{INST_ARCHLIB} ||= File::Spec->catdir($Curdir,"blib","arch"); - $self->{INST_BIN} ||= File::Spec->catdir($Curdir,'blib','bin'); + $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch"); + $self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin'); # INST_LIB typically pre-set if building an extension after # perl has been built and installed. Setting INST_LIB allows @@ -1839,30 +2005,29 @@ sub init_INST { if ($self->{PERL_CORE}) { if (defined $Cross::platform) { $self->{INST_LIB} = $self->{INST_ARCHLIB} = - File::Spec->catdir($self->{PERL_LIB},"..","xlib", + $self->catdir($self->{PERL_LIB},"..","xlib", $Cross::platform); } else { $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB}; } } else { - $self->{INST_LIB} = File::Spec->catdir($Curdir,"blib","lib"); + $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib"); } } my @parentdir = split(/::/, $self->{PARENT_NAME}); - $self->{INST_LIBDIR} = File::Spec->catdir($self->{INST_LIB},@parentdir); - $self->{INST_ARCHLIBDIR} = File::Spec->catdir($self->{INST_ARCHLIB}, - @parentdir); - $self->{INST_AUTODIR} = File::Spec->catdir($self->{INST_LIB},'auto', - $self->{FULLEXT}); - $self->{INST_ARCHAUTODIR} = File::Spec->catdir($self->{INST_ARCHLIB}, - 'auto',$self->{FULLEXT}); + $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir); + $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir); + $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto', + '$(FULLEXT)'); + $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto', + '$(FULLEXT)'); - $self->{INST_SCRIPT} ||= File::Spec->catdir($Curdir,'blib','script'); + $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script'); - $self->{INST_MAN1DIR} ||= File::Spec->catdir($Curdir,'blib','man1'); - $self->{INST_MAN3DIR} ||= File::Spec->catdir($Curdir,'blib','man3'); + $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1'); + $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3'); return 1; } @@ -1872,7 +2037,7 @@ sub init_INST { $mm->init_INSTALL; Called by init_main. Sets up all INSTALL_* variables (except -INSTALLDIRS) and PREFIX. +INSTALLDIRS) and *PREFIX. =cut @@ -1881,15 +2046,15 @@ sub init_INSTALL { $self->init_lib2arch; - if( $Config{usevendorprefix} ) { - $Config_Override{installvendorman1dir} = - File::Spec->catdir($Config{vendorprefixexp}, 'man', 'man$(MAN1EXT)'); - $Config_Override{installvendorman3dir} = - File::Spec->catdir($Config{vendorprefixexp}, 'man', 'man$(MAN3EXT)'); - } - else { - $Config_Override{installvendorman1dir} = ''; - $Config_Override{installvendorman3dir} = ''; + # Initialize installvendorman*dir if necessary + foreach my $num (1, 3) { + my $k = 'installvendorman'.$num.'dir'; + + unless ($Config{$k}) { + $Config_Override{$k} = $Config{usevendorprefix} ? + $self->catdir($Config{vendorprefixexp}, 'man', "man$num") : + ''; + } } my $iprefix = $Config{installprefixexp} || $Config{installprefix} || @@ -1904,32 +2069,36 @@ sub init_INSTALL { # it up. unless( $Config{installsiteman1dir} ) { $Config_Override{installsiteman1dir} = - File::Spec->catdir($sprefix, 'man', 'man$(MAN1EXT)'); + $self->catdir($sprefix, 'man', 'man1'); } unless( $Config{installsiteman3dir} ) { $Config_Override{installsiteman3dir} = - File::Spec->catdir($sprefix, 'man', 'man$(MAN3EXT)'); + $self->catdir($sprefix, 'man', 'man3'); } unless( $Config{installsitebin} ) { $Config_Override{installsitebin} = - File::Spec->catdir($sprefix, 'bin'); + $self->catdir($sprefix, 'bin'); } - my $u_prefix = $self->{PREFIX} || ''; - my $u_sprefix = $self->{SITEPREFIX} || $u_prefix; - my $u_vprefix = $self->{VENDORPREFIX} || $u_prefix; + $self->{PREFIX} ||= ''; - $self->{PREFIX} ||= $u_prefix || $iprefix; - $self->{SITEPREFIX} ||= $u_sprefix || $sprefix; - $self->{VENDORPREFIX} ||= $u_vprefix || $vprefix; + if( $self->{PREFIX} ) { + @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} = + ('$(PREFIX)') x 3; + } + else { + $self->{PERLPREFIX} ||= $iprefix; + $self->{SITEPREFIX} ||= $sprefix; + $self->{VENDORPREFIX} ||= $vprefix; + } my $arch = $Config{archname}; my $version = $Config{version}; # default style - my $libstyle = 'lib/perl5'; + my $libstyle = $Config{installstyle} || 'lib/perl5'; my $manstyle = ''; if( $self->{LIBSTYLE} ) { @@ -1947,73 +2116,73 @@ sub init_INSTALL { my %bin_layouts = ( bin => { s => $iprefix, - r => $u_prefix, + t => 'perl', d => 'bin' }, vendorbin => { s => $vprefix, - r => $u_vprefix, + t => 'vendor', d => 'bin' }, sitebin => { s => $sprefix, - r => $u_sprefix, + t => 'site', d => 'bin' }, script => { s => $iprefix, - r => $u_prefix, + t => 'perl', d => 'bin' }, ); my %man_layouts = ( man1dir => { s => $iprefix, - r => $u_prefix, - d => 'man/man$(MAN1EXT)', + t => 'perl', + d => 'man/man1', style => $manstyle, }, siteman1dir => { s => $sprefix, - r => $u_sprefix, - d => 'man/man$(MAN1EXT)', + t => 'site', + d => 'man/man1', style => $manstyle, }, vendorman1dir => { s => $vprefix, - r => $u_vprefix, - d => 'man/man$(MAN1EXT)', + t => 'vendor', + d => 'man/man1', style => $manstyle, }, man3dir => { s => $iprefix, - r => $u_prefix, - d => 'man/man$(MAN3EXT)', + t => 'perl', + d => 'man/man3', style => $manstyle, }, siteman3dir => { s => $sprefix, - r => $u_sprefix, - d => 'man/man$(MAN3EXT)', + t => 'site', + d => 'man/man3', style => $manstyle, }, vendorman3dir => { s => $vprefix, - r => $u_vprefix, - d => 'man/man$(MAN3EXT)', + t => 'vendor', + d => 'man/man3', style => $manstyle, }, ); my %lib_layouts = ( privlib => { s => $iprefix, - r => $u_prefix, + t => 'perl', d => '', style => $libstyle, }, vendorlib => { s => $vprefix, - r => $u_vprefix, + t => 'vendor', d => '', style => $libstyle, }, sitelib => { s => $sprefix, - r => $u_sprefix, + t => 'site', d => 'site_perl', style => $libstyle, }, archlib => { s => $iprefix, - r => $u_prefix, + t => 'perl', d => "$version/$arch", style => $libstyle }, vendorarch => { s => $vprefix, - r => $u_vprefix, + t => 'vendor', d => "$version/$arch", style => $libstyle }, sitearch => { s => $sprefix, - r => $u_sprefix, + t => 'site', d => "site_perl/$version/$arch", style => $libstyle }, ); @@ -2026,7 +2195,7 @@ sub init_INSTALL { if( $var =~ /arch/ ) { $self->{$Installvar} ||= - File::Spec->catdir($self->{LIB}, $Config{archname}); + $self->catdir($self->{LIB}, $Config{archname}); } else { $self->{$Installvar} ||= $self->{LIB}; @@ -2034,10 +2203,15 @@ sub init_INSTALL { } } + my %type2prefix = ( perl => 'PERLPREFIX', + site => 'SITEPREFIX', + vendor => 'VENDORPREFIX' + ); my %layouts = (%bin_layouts, %man_layouts, %lib_layouts); while( my($var, $layout) = each(%layouts) ) { - my($s, $r, $d, $style) = @{$layout}{qw(s r d style)}; + my($s, $t, $d, $style) = @{$layout}{qw(s t d style)}; + my $r = '$('.$type2prefix{$t}.')'; print STDERR "Prefixing $var\n" if $Verbose >= 2; @@ -2045,22 +2219,34 @@ sub init_INSTALL { my $Installvar = uc $installvar; next if $self->{$Installvar}; - if( $r ) { - $d = "$style/$d" if $style; - $self->prefixify($installvar, $s, $r, $d); - } - else { - $self->{$Installvar} = $Config_Override{$installvar} || - $Config{$installvar}; - } + $d = "$style/$d" if $style; + $self->prefixify($installvar, $s, $r, $d); print STDERR " $Installvar == $self->{$Installvar}\n" if $Verbose >= 2; } + # Generate these if they weren't figured out. + $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH}; + $self->{VENDORLIBEXP} ||= $self->{INSTALLVENDORLIB}; + return 1; } +=item init_linker + +Unix has no need of special linker flags. + +=cut + +sub init_linker { + my($self) = shift; + $self->{PERL_ARCHIVE} ||= ''; + $self->{PERL_ARCHIVE_AFTER} ||= ''; + $self->{EXPORT_LIST} ||= ''; +} + + =begin _protected =item init_lib2arch @@ -2113,6 +2299,7 @@ Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the PERL is allowed to be miniperl FULLPERL must be a complete perl + ABSPERL is PERL converted to an absolute path *PERLRUN contains everything necessary to run perl, find it's @@ -2134,8 +2321,15 @@ sub init_PERL { } # Build up a set of file names (not command names). - my $thisperl = File::Spec->canonpath($^X); - $thisperl .= $Config{exe_ext} unless $thisperl =~ m/$Config{exe_ext}$/i; + my $thisperl = $self->canonpath($^X); + $thisperl .= $Config{exe_ext} unless + # VMS might have a file version # at the end + $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i + : $thisperl =~ m/$Config{exe_ext}$/i; + + # We need a relative path to perl when in the core. + $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE}; + my @perls = ($thisperl); push @perls, map { "$_$Config{exe_ext}" } ('perl', 'perl5', "perl$Config{version}"); @@ -2155,19 +2349,26 @@ sub init_PERL { # don't check if perl is executable, maybe they have decided to # supply switches with perl + # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe. + my $perl_name = 'perl'; + $perl_name = 'ndbgperl' if $Is_VMS && + defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define'; + + # XXX This logic is flawed. If "miniperl" is anywhere in the path + # it will get confused. It should be fixed to work only on the filename. # Define 'FULLPERL' to be a non-miniperl (used in test: target) - ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i + ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i unless $self->{FULLPERL}; # Little hack to get around VMS's find_perl putting "MCR" in front # sometimes. $self->{ABSPERL} = $self->{PERL}; my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//; - if( File::Spec->file_name_is_absolute($self->{ABSPERL}) ) { + if( $self->file_name_is_absolute($self->{ABSPERL}) ) { $self->{ABSPERL} = '$(PERL)'; } else { - $self->{ABSPERL} = File::Spec->rel2abs($self->{ABSPERL}); + $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL}); $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr; } @@ -2176,10 +2377,12 @@ sub init_PERL { # How do we run perl? foreach my $perl (qw(PERL FULLPERL ABSPERL)) { - $self->{$perl.'RUN'} = "\$($perl)"; + my $run = $perl.'RUN'; + + $self->{$run} = "\$($perl)"; # Make sure perl can find itself before it's installed. - $self->{$perl.'RUN'} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"} + $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"} if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE}; $self->{$perl.'RUNINST'} = @@ -2189,6 +2392,39 @@ sub init_PERL { return 1; } + +=item init_platform (o) + +Add MM_Unix_VERSION. + +=item platform_constants (o) + +=cut + +sub init_platform { + my($self) = shift; + + $self->{MM_Unix_VERSION} = $VERSION; + $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '. + '-Dfree=Perl_mfree -Drealloc=Perl_realloc '. + '-Dcalloc=Perl_calloc'; + +} + +sub platform_constants { + my($self) = shift; + my $make_frag = ''; + + foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF)) + { + next unless defined $self->{$macro}; + $make_frag .= "$macro = $self->{$macro}\n"; + } + + return $make_frag; +} + + =item init_PERM $mm->init_PERM @@ -2200,12 +2436,38 @@ Called by init_main. Initializes PERL_* sub init_PERM { my($self) = shift; - $self->{PERM_RW} = 644; - $self->{PERM_RWX} = 755; + $self->{PERM_RW} = 644 unless defined $self->{PERM_RW}; + $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX}; return 1; } - + + +=item init_xs + + $mm->init_xs + +Sets up macros having to do with XS code. Currently just INST_STATIC, +INST_DYNAMIC and INST_BOOT. + +=cut + +sub init_xs { + my $self = shift; + + if ($self->has_link_code()) { + $self->{INST_STATIC} = + $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)'); + $self->{INST_DYNAMIC} = + $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)'); + $self->{INST_BOOT} = + $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs'); + } else { + $self->{INST_STATIC} = ''; + $self->{INST_DYNAMIC} = ''; + $self->{INST_BOOT} = ''; + } +} =item install (o) @@ -2229,71 +2491,83 @@ install_vendor :: all pure_vendor_install doc_vendor_install pure_install :: pure_$(INSTALLDIRS)_install doc_install :: doc_$(INSTALLDIRS)_install - }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod pure__install : pure_site_install - @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install - @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_perl_install :: - }.$self->{NOECHO}.q{$(MOD_INSTALL) \ - read }.File::Spec->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ - write }.File::Spec->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ - $(INST_LIB) $(INSTALLPRIVLIB) \ - $(INST_ARCHLIB) $(INSTALLARCHLIB) \ - $(INST_BIN) $(INSTALLBIN) \ - $(INST_SCRIPT) $(INSTALLSCRIPT) \ - $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ - $(INST_MAN3DIR) $(INSTALLMAN3DIR) - }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \ - }.File::Spec->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{ + $(NOECHO) $(MOD_INSTALL) \ + read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ + write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \ + $(INST_LIB) $(DESTINSTALLPRIVLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ + $(INST_BIN) $(DESTINSTALLBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{ pure_site_install :: - }.$self->{NOECHO}.q{$(MOD_INSTALL) \ - read }.File::Spec->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \ - write }.File::Spec->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \ - $(INST_LIB) $(INSTALLSITELIB) \ - $(INST_ARCHLIB) $(INSTALLSITEARCH) \ - $(INST_BIN) $(INSTALLSITEBIN) \ - $(INST_SCRIPT) $(INSTALLSCRIPT) \ - $(INST_MAN1DIR) $(INSTALLSITEMAN1DIR) \ - $(INST_MAN3DIR) $(INSTALLSITEMAN3DIR) - }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \ - }.File::Spec->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{ + $(NOECHO) $(MOD_INSTALL) \ + read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \ + write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \ + $(INST_LIB) $(DESTINSTALLSITELIB) \ + $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ + $(INST_BIN) $(DESTINSTALLSITEBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{ pure_vendor_install :: - }.$self->{NOECHO}.q{$(MOD_INSTALL) \ - $(INST_LIB) $(INSTALLVENDORLIB) \ - $(INST_ARCHLIB) $(INSTALLVENDORARCH) \ - $(INST_BIN) $(INSTALLVENDORBIN) \ - $(INST_SCRIPT) $(INSTALLSCRIPT) \ - $(INST_MAN1DIR) $(INSTALLVENDORMAN1DIR) \ - $(INST_MAN3DIR) $(INSTALLVENDORMAN3DIR) + $(NOECHO) $(MOD_INSTALL) \ + read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \ + write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \ + $(INST_LIB) $(DESTINSTALLVENDORLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ + $(INST_BIN) $(DESTINSTALLVENDORBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) doc_perl_install :: - -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB) - -}.$self->{NOECHO}.q{$(DOC_INSTALL) \ + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLPRIVLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ - >> }.File::Spec->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{ + >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ doc_site_install :: - -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB) - -}.$self->{NOECHO}.q{$(DOC_INSTALL) \ + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ - >> }.File::Spec->catfile('$(INSTALLSITEARCH)','perllocal.pod').q{ + >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ doc_vendor_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLVENDORLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ }; @@ -2301,12 +2575,13 @@ doc_vendor_install :: uninstall :: uninstall_from_$(INSTALLDIRS)dirs uninstall_from_perldirs :: - }.$self->{NOECHO}. - q{$(UNINSTALL) }.File::Spec->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ + $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ uninstall_from_sitedirs :: - }.$self->{NOECHO}. - q{$(UNINSTALL) }.File::Spec->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ + $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ + +uninstall_from_vendordirs :: + $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ }; join("",@m); @@ -2325,57 +2600,49 @@ sub installbin { my(@m, $from, $to, %fromto, @to); push @m, $self->dir_target(qw[$(INST_SCRIPT)]); for $from (@{$self->{EXE_FILES}}) { - my($path)= File::Spec->catfile('$(INST_SCRIPT)', basename($from)); + my($path)= $self->catfile('$(INST_SCRIPT)', basename($from)); local($_) = $path; # for backwards compatibility $to = $self->libscan($path); print "libscan($from) => '$to'\n" if ($Verbose >=2); $fromto{$from}=$to; } @to = values %fromto; + + my $fixin; + if( $Is_Win32 ) { + $fixin = $self->{PERL_CORE} ? '$(PERLRUN) ../../win32/bin/pl2bat.pl' + : 'pl2bat.bat'; + } + else { + $fixin = q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"}; + } + push(@m, qq{ EXE_FILES = @{$self->{EXE_FILES}} -} . ($Is_Win32 - ? q{FIXIN = pl2bat.bat -} : q{FIXIN = $(PERLRUN) "-MExtUtils::MY" \ - -e "MY->fixin(shift)" -}).qq{ +FIXIN = $fixin + pure_all :: @to - $self->{NOECHO}\$(NOOP) + \$(NOECHO) \$(NOOP) realclean :: - $self->{RM_F} @to + \$(RM_F) @to }); while (($from,$to) = each %fromto) { last unless defined $from; my $todir = dirname($to); push @m, " -$to: $from $self->{MAKEFILE} " . File::Spec->catdir($todir,'.exists') . " - $self->{NOECHO}$self->{RM_F} $to - $self->{CP} $from $to +$to: $from \$(FIRST_MAKEFILE) " . $self->catdir($todir,'.exists') . " + \$(NOECHO) \$(RM_F) $to + \$(CP) $from $to \$(FIXIN) $to - -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $to + -\$(NOECHO) \$(CHMOD) \$(PERM_RWX) $to "; } join "", @m; } -=item libscan (o) - -Takes a path to a file that is found by init_dirscan and returns false -if we don't want to include this file in the library. Mainly used to -exclude RCS, CVS, and SCCS directories from installation. - -=cut - -# '; - -sub libscan { - my($self,$path) = @_; - return '' if $path =~ m:\b(RCS|CVS|SCCS)\b: ; - $path; -} =item linkext (o) @@ -2390,7 +2657,7 @@ sub linkext { $attribs{LINKTYPE} : '$(LINKTYPE)'; " linkext :: $linktype - $self->{NOECHO}\$(NOOP) + \$(NOECHO) \$(NOOP) "; } @@ -2461,8 +2728,8 @@ $(MAP_TARGET) :: static $(MAKE_APERL_FILE) $(MAKE) -f $(MAKE_APERL_FILE) $@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) - }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) - }.$self->{NOECHO}.q{$(PERLRUNINST) \ + $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) + $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR=}, $dir, q{ \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=}; @@ -2592,10 +2859,10 @@ MAP_PRELIBS = $Config{perllibs} $Config{cryptlib} if (! -f $libperl and ! -f $lperl) { # We did not find a static libperl. Maybe there is a shared one? - if ($^O eq 'solaris' or $^O eq 'sunos') { + if ($Is_SunOS) { $lperl = $libperl = "$dir/$Config{libperl}"; # SUNOS ld does not take the full path to a shared library - $libperl = '' if $^O eq 'sunos'; + $libperl = '' if $Is_SunOS4; } } @@ -2614,10 +2881,10 @@ LLIBPERL = $llibperl "; push @m, " -\$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)." - $self->{NOECHO}$self->{RM_F} \$\@ - $self->{NOECHO}\$(TOUCH) \$\@ -"; +\$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)\$(DIRFILESEP).exists ".join(" \\\n\t", @$extra).' + $(NOECHO) $(RM_F) $@ + $(NOECHO) $(TOUCH) $@ +'; my $catfile; foreach $catfile (@$extra){ @@ -2627,10 +2894,10 @@ LLIBPERL = $llibperl push @m, " \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS) - $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call' - $self->{NOECHO}echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)' - $self->{NOECHO}echo 'To remove the intermediate files say' - $self->{NOECHO}echo ' make -f $makefilename map_clean' + \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call' + \$(NOECHO) \$(ECHO) ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)' + \$(NOECHO) \$(ECHO) 'To remove the intermediate files say' + \$(NOECHO) \$(ECHO) ' make -f $makefilename map_clean' $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c "; @@ -2638,25 +2905,25 @@ $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c push @m, qq{ $tmp/perlmain.c: $makefilename}, q{ - }.$self->{NOECHO}.q{echo Writing $@ - }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\ + $(NOECHO) $(ECHO) Writing $@ + $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\ -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@ }; - push @m, "\t",$self->{NOECHO}.q{$(PERL) $(INSTALLSCRIPT)/fixpmain + push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0); push @m, q{ doc_inst_perl: - }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod - -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB) - -}.$self->{NOECHO}.q{$(DOC_INSTALL) \ + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ "Perl binary" "$(MAP_TARGET)" \ MAP_STATIC "$(MAP_STATIC)" \ MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \ MAP_LIBPERL "$(MAP_LIBPERL)" \ - >> }.File::Spec->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{ + >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{ }; @@ -2664,7 +2931,7 @@ doc_inst_perl: inst_perl: pure_inst_perl doc_inst_perl pure_inst_perl: $(MAP_TARGET) - }.$self->{CP}.q{ $(MAP_TARGET) }.File::Spec->catfile('$(INSTALLBIN)','$(MAP_TARGET)').q{ + }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{ clean :: map_clean @@ -2692,17 +2959,17 @@ $(OBJECT) : $(FIRST_MAKEFILE) ' if $self->{OBJECT}; push @m, q{ -# We take a very conservative approach here, but it\'s worth it. +# We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. -}.$self->{MAKEFILE}.q{ : Makefile.PL $(CONFIGDEP) - }.$self->{NOECHO}.q{echo "Makefile out-of-date with respect to $?" - }.$self->{NOECHO}.q{echo "Cleaning current config before rebuilding Makefile..." - -}.$self->{NOECHO}.q{$(RM_F) }."$self->{MAKEFILE}.old".q{ - -}.$self->{NOECHO}.q{$(MV) }."$self->{MAKEFILE} $self->{MAKEFILE}.old".q{ - -$(MAKE) -f }.$self->{MAKEFILE}.q{.old clean $(DEV_NULL) || $(NOOP) +$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) + $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" + $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." + $(NOECHO) $(RM_F) $(MAKEFILE_OLD) + $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) $(PERLRUN) Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{ - }.$self->{NOECHO}.q{echo "==> Your Makefile has been rebuilt. <==" - }.$self->{NOECHO}.q{echo "==> Please rerun the make command. <==" + $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" + $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" false }; @@ -2710,58 +2977,6 @@ $(OBJECT) : $(FIRST_MAKEFILE) join "", @m; } -=item manifypods (o) - -Defines targets and routines to translate the pods into manpages and -put them into the INST_* directories. - -=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 @@ -2775,44 +2990,6 @@ sub maybe_command { return; } -=item maybe_command_in_dirs - -method under development. Not yet used. Ask Ilya :-) - -=cut - -sub maybe_command_in_dirs { # $ver is optional argument if looking for perl -# Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here - my($self, $names, $dirs, $trace, $ver) = @_; - my($name, $dir); - foreach $dir (@$dirs){ - next unless defined $dir; # $self->{PERL_SRC} may be undefined - foreach $name (@$names){ - my($abs,$tryabs); - if (File::Spec->file_name_is_absolute($name)) { # /foo/bar - $abs = $name; - } elsif (File::Spec->canonpath($name) eq File::Spec->canonpath(basename($name))) { # bar - $abs = File::Spec->catfile($dir, $name); - } else { # foo/bar - $abs = File::Spec->catfile($Curdir, $name); - } - print "Checking $abs for $name\n" if ($trace >= 2); - next unless $tryabs = $self->maybe_command($abs); - print "Substituting $tryabs instead of $abs\n" - if ($trace >= 2 and $tryabs ne $abs); - $abs = $tryabs; - if (defined $ver) { - print "Executing $abs\n" if ($trace >= 2); - if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) { - print "Using PERL=$abs\n" if $trace; - return $abs; - } - } else { # Do not look for perl - return $abs; - } - } - } -} =item needs_linking (o) @@ -2825,7 +3002,7 @@ sub needs_linking { my($self) = shift; my($child,$caller); $caller = (caller(0))[3]; - confess("Needs_linking called too early") if + confess("needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/; return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING}; if ($self->has_link_code or $self->{MAKEAPERL}){ @@ -2905,8 +3082,7 @@ sub parse_version { $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; next if $inpod || /^\s*#/; chop; - # next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/; - next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/; + next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/; my $eval = qq{ package ExtUtils::MakeMaker::_version; no strict; @@ -2984,10 +3160,10 @@ sub perldepend { # We do NOT just update config.h because that is not sufficient. # An out of date config.h is not fatal but complains loudly! $(PERL_INC)/config.h: $(PERL_SRC)/config.sh - -}.$self->{NOECHO}.q{echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false + -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh - }.$self->{NOECHO}.q{echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh" + $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh" cd $(PERL_SRC) && $(MAKE) lib/Config.pm } if $self->{PERL_SRC}; @@ -3018,10 +3194,8 @@ PERL_HDRS = \ $(PERL_INC)/nostdio.h \ $(PERL_INC)/op.h \ $(PERL_INC)/opcode.h \ - $(PERL_INC)/opnames.h \ $(PERL_INC)/patchlevel.h \ $(PERL_INC)/perl.h \ - $(PERL_INC)/perlapi.h \ $(PERL_INC)/perlio.h \ $(PERL_INC)/perlsdio.h \ $(PERL_INC)/perlsfio.h \ @@ -3038,9 +3212,7 @@ PERL_HDRS = \ $(PERL_INC)/thrdvar.h \ $(PERL_INC)/thread.h \ $(PERL_INC)/unixish.h \ - $(PERL_INC)/utf8.h \ - $(PERL_INC)/util.h \ - $(PERL_INC)/warnings.h + $(PERL_INC)/util.h $(OBJECT) : $(PERL_HDRS) } if $self->{OBJECT}; @@ -3064,7 +3236,7 @@ interpreted as an octal value. =cut sub perm_rw { - shift->{PERM_RW} || "644"; + return shift->{PERM_RW}; } =item perm_rwx (o) @@ -3077,7 +3249,7 @@ See also perl_rw. =cut sub perm_rwx { - shift->{PERM_RWX} || "755"; + return shift->{PERM_RWX}; } =item pm_to_blib @@ -3087,36 +3259,23 @@ destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION> =cut -sub _pm_to_blib_flush { - my ($self, $autodir, $rr, $ra, $rl) = @_; - $$rr .= -q{ }.$self->{NOECHO}.q[$(PERLRUNINST) "-MExtUtils::Install" \ - -e "pm_to_blib({qw{].qq[@$ra].q[}},'].$autodir.q{','$(PM_FILTER)')" -}; - @$ra = (); - $$rl = 0; -} - sub pm_to_blib { my $self = shift; - my($autodir) = File::Spec->catdir('$(INST_LIB)','auto'); + my($autodir) = $self->catdir('$(INST_LIB)','auto'); my $r = q{ pm_to_blib: $(TO_INST_PM) }; - my %pm_to_blib = %{$self->{PM}}; - my @a; - my $l = 0; - while (my ($pm, $blib) = each %pm_to_blib) { - my $la = length $pm; - my $lb = length $blib; - if ($l + $la + $lb + @a / 2 > 200) { # limit line length - _pm_to_blib_flush($self, $autodir, \$r, \@a, \$l); - } - push @a, $pm, $blib; - $l += $la + $lb; - } - _pm_to_blib_flush($self, $autodir, \$r, \@a, \$l); - return $r.q{ }.$self->{NOECHO}.q{$(TOUCH) $@}; + + my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']); +pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)') +CODE + + my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}}); + + $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds; + $r .= q{ $(NOECHO) $(TOUCH) $@}; + + return $r; } =item post_constants (o) @@ -3127,7 +3286,6 @@ within Makefile.PL after all constants have been defined. =cut sub post_constants{ - my($self) = shift; ""; } @@ -3139,7 +3297,6 @@ chunk of text to the Makefile after the object is initialized. =cut sub post_initialize { - my($self) = shift; ""; } @@ -3151,7 +3308,6 @@ text to the Makefile at the end. =cut sub postamble { - my($self) = shift; ""; } @@ -3181,40 +3337,38 @@ sub ppd { my $author = $self->{AUTHOR} || ''; $author =~ s/</</g; $author =~ s/>/>/g; - $author =~ s/@/\\@/g; - - my $make_ppd = sprintf <<'PPD_OUT', $pack_ver, $abstract, $author; -# Creates a PPD (Perl Package Description) for a binary distribution. -ppd: - @$(PERL) -e "print qq{<SOFTPKG NAME=\"$(DISTNAME)\" VERSION=\"%s\">\n\t<TITLE>$(DISTNAME)</TITLE>\n\t<ABSTRACT>%s</ABSTRACT>\n\t<AUTHOR>%s</AUTHOR>\n}" > $(DISTNAME).ppd -PPD_OUT + my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author; +<SOFTPKG NAME="$(DISTNAME)" VERSION="%s"> + <TITLE>$(DISTNAME)</TITLE> + <ABSTRACT>%s</ABSTRACT> + <AUTHOR>%s</AUTHOR> +PPD_HTML - $make_ppd .= ' @$(PERL) -e "print qq{\t<IMPLEMENTATION>\n'; + $ppd_xml .= " <IMPLEMENTATION>\n"; foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) { my $pre_req = $prereq; $pre_req =~ s/::/-/g; my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}), (0) x 4) [0 .. 3]; - $make_ppd .= sprintf q{\t\t<DEPENDENCY NAME=\"%s\" VERSION=\"%s\" />\n}, $pre_req, $dep_ver; - } - $make_ppd .= qq[}" >> \$(DISTNAME).ppd\n]; - - - $make_ppd .= sprintf <<'PPD_OUT', $Config{archname}; - @$(PERL) -e "print qq{\t\t<OS NAME=\"$(OSNAME)\" />\n\t\t<ARCHITECTURE NAME=\"%s\" />\n + $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver; + <DEPENDENCY NAME="%s" VERSION="%s" /> PPD_OUT - chomp $make_ppd; + } + $ppd_xml .= sprintf <<'PPD_OUT', $Config{archname}; + <OS NAME="$(OSNAME)" /> + <ARCHITECTURE NAME="%s" /> +PPD_OUT if ($self->{PPM_INSTALL_SCRIPT}) { if ($self->{PPM_INSTALL_EXEC}) { - $make_ppd .= sprintf q{\t\t<INSTALL EXEC=\"%s\">%s</INSTALL>\n}, + $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n}, $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT}; } else { - $make_ppd .= sprintf q{\t\t<INSTALL>%s</INSTALL>\n}, + $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n}, $self->{PPM_INSTALL_SCRIPT}; } } @@ -3222,13 +3376,20 @@ PPD_OUT my ($bin_location) = $self->{BINARY_LOCATION} || ''; $bin_location =~ s/\\/\\\\/g; - $make_ppd .= sprintf q{\t\t<CODEBASE HREF=\"%s\" />\n}, $bin_location; - $make_ppd .= q{\t</IMPLEMENTATION>\n}; - $make_ppd .= q{</SOFTPKG>\n}; + $ppd_xml .= sprintf <<'PPD_XML', $bin_location; + <CODEBASE HREF="%s" /> + </IMPLEMENTATION> +</SOFTPKG> +PPD_XML - $make_ppd .= '}" >> $(DISTNAME).ppd'; + my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd'); + + return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds; +# Creates a PPD (Perl Package Description) for a binary distribution. +ppd: + %s +PPD_OUT - return $make_ppd; } =item prefixify @@ -3236,8 +3397,12 @@ PPD_OUT $MM->prefixify($var, $prefix, $new_prefix, $default); Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to -replace it's $prefix with a $new_prefix. Should the $prefix fail to -match it sill simply set it to the $new_prefix + $default. +replace it's $prefix with a $new_prefix. + +Should the $prefix fail to match I<AND> a PREFIX was given as an +argument to WriteMakefile() it will set it to the $new_prefix + +$default. This is for systems whose file layouts don't neatly fit into +our ideas of prefixes. This is for heuristics which attempt to create directory structures that mirror those of the installed perl. @@ -3259,15 +3424,17 @@ sub prefixify { my $path = $self->{uc $var} || $Config_Override{lc $var} || $Config{lc $var} || ''; + $rprefix .= '/' if $sprefix =~ m|/$|; + print STDERR " prefixify $var => $path\n" if $Verbose >= 2; print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2; - unless( $path =~ s{^\Q$sprefix\E\b}{$rprefix}s ) { + if( $path !~ s{^\Q$sprefix\E\b}{$rprefix}s && $self->{ARGS}{PREFIX} ) { print STDERR " cannot prefix, using default.\n" if $Verbose >= 2; print STDERR " no default!\n" if !$default && $Verbose >= 2; - $path = File::Spec->catdir($rprefix, $default) if $default; + $path = $self->catdir($rprefix, $default) if $default; } print " now $path\n" if $Verbose >= 2; @@ -3293,7 +3460,7 @@ sub processPL { foreach $target (@$list) { push @m, " all :: $target - $self->{NOECHO}\$(NOOP) + \$(NOECHO) \$(NOOP) $target :: $plfile \$(PERLRUNINST) $plfile $target @@ -3312,11 +3479,11 @@ but handles simple ones. =cut sub quote_paren { - local $_ = shift; - s/\$\((.+?)\)/\$\\\\($1\\\\)/g; # protect $(...) - s/(?<!\\)([()])/\\$1/g; # quote unprotected - s/\$\\\\\((.+?)\\\\\)/\$($1)/g; # unprotect $(...) - return $_; + my $arg = shift; + $arg =~ s/\$\((.+?)\)/\$\\\\($1\\\\)/g; # protect $(...) + $arg =~ s/(?<!\\)([()])/\\$1/g; # quote unprotected + $arg =~ s/\$\\\\\((.+?)\\\\\)/\$($1)/g; # unprotect $(...) + return $arg; } =item realclean (o) @@ -3331,57 +3498,74 @@ sub realclean { push(@m,' # Delete temporary files (via clean) and also delete installed files -realclean purge :: clean +realclean purge :: clean realclean_subdirs + $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) + $(RM_RF) $(DISTVNAME) '); - # realclean subdirectories first (already cleaned) - my $sub; - if( $Is_Win32 && Win32::IsWin95() ) { - $sub = <<'REALCLEAN'; - -cd %s - -$(PERLRUN) -e "exit unless -f shift; system q{$(MAKE) realclean}" %s - -cd .. -REALCLEAN - } - else { - $sub = <<'REALCLEAN'; - -cd %s && $(TEST_F) %s && $(MAKE) %s realclean -REALCLEAN - } - foreach(@{$self->{DIR}}){ - push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old")); - push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",'')); - } - push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n"); - push(@m, " $self->{RM_RF} \$(DISTVNAME)\n"); if( $self->has_link_code ){ - push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n"); - push(@m, " $self->{RM_F} \$(INST_STATIC)\n"); + push(@m, " \$(RM_F) \$(INST_DYNAMIC) \$(INST_BOOT)\n"); + push(@m, " \$(RM_F) \$(INST_STATIC)\n"); } + + my @files = values %{$self->{PM}}; + push @files, $attribs{FILES} if $attribs{FILES}; + push @files, '$(FIRST_MAKEFILE)', '$(MAKEFILE_OLD)'; + + # Occasionally files are repeated several times from different sources + { my(%f) = map { ($_,1) } @files; @files = keys %f; } + # Issue a several little RM_F commands rather than risk creating a # very long command line (useful for extensions such as Encode # that have many files). - if (keys %{$self->{PM}}) { - my $line = ""; - foreach (values %{$self->{PM}}) { - if (length($line) + length($_) > 80) { - push @m, "\t$self->{RM_F} $line\n"; - $line = $_; - } - else { - $line .= " $_"; - } - } - push @m, "\t$self->{RM_F} $line\n" if $line; + my $line = ""; + foreach my $file (@files) { + if (length($line) + length($file) > 200) { + push @m, "\t\$(RM_F) $line\n"; + $line = $file; + } + else { + $line .= " $file"; + } } - my(@otherfiles) = ($self->{MAKEFILE}, - "$self->{MAKEFILE}.old"); # Makefiles last - push(@otherfiles, $attribs{FILES}) if $attribs{FILES}; - push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles; - push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP}; + push @m, "\t\$(RM_F) $line\n" if $line; + push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP}; + join("", @m); } + +=item realclean_subdirs_target + + my $make_frag = $MM->realclean_subdirs_target; + +Returns the realclean_subdirs target. This is used by the realclean +target to call realclean on any subdirectories which contain Makefiles. + +=cut + +sub realclean_subdirs_target { + my $self = shift; + + return <<'NOOP_FRAG' unless @{$self->{DIR}}; +realclean_subdirs : + $(NOECHO) $(NOOP) +NOOP_FRAG + + my $rclean = "realclean_subdirs :\n"; + + foreach my $dir (@{$self->{DIR}}){ + $rclean .= sprintf <<'RCLEAN', $dir, $dir; + -cd %s && $(TEST_F) $(MAKEFILE_OLD) && $(MAKE) -f $(MAKEFILE_OLD) realclean + -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) realclean +RCLEAN + + } + + return $rclean; +} + + =item replace_manpage_separator my $man_name = $MM->replace_manpage_separator($file_path); @@ -3399,6 +3583,79 @@ sub replace_manpage_separator { return $man; } + +=item oneliner (o) + +=cut + +sub oneliner { + my($self, $cmd, $switches) = @_; + $switches = [] unless defined $switches; + + # Strip leading and trailing newlines + $cmd =~ s{^\n+}{}; + $cmd =~ s{\n+$}{}; + + my @cmds = split /\n/, $cmd; + $cmd = join " \n\t-e ", map $self->quote_literal($_), @cmds; + $cmd = $self->escape_newlines($cmd); + + $switches = join ' ', @$switches; + + return qq{\$(PERLRUN) $switches -e $cmd}; +} + + +=item quote_literal + +=cut + +sub quote_literal { + my($self, $text) = @_; + + # I think all we have to quote is single quotes and I think + # this is a safe way to do it. + $text =~ s{'}{'\\''}g; + + return "'$text'"; +} + + +=item escape_newlines + +=cut + +sub escape_newlines { + my($self, $text) = @_; + + $text =~ s{\n}{\\\n}g; + + return $text; +} + + +=item max_exec_len + +Using POSIX::ARG_MAX. Otherwise falling back to 4096. + +=cut + +sub max_exec_len { + my $self = shift; + + if (!defined $self->{_MAX_EXEC_LEN}) { + if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) { + $self->{_MAX_EXEC_LEN} = $arg_max; + } + else { # POSIX minimum exec size + $self->{_MAX_EXEC_LEN} = 4096; + } + } + + return $self->{_MAX_EXEC_LEN}; +} + + =item static (o) Defines the static target. @@ -3412,9 +3669,8 @@ sub static { ' ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" -#static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM) -static :: '.$self->{MAKEFILE}.' $(INST_STATIC) - '.$self->{NOECHO}.'$(NOOP) +static :: $(FIRST_MAKEFILE) $(INST_STATIC) + $(NOECHO) $(NOOP) '; } @@ -3426,19 +3682,20 @@ Defines how to produce the *.a (or equivalent) files. sub static_lib { my($self) = @_; -# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC -# return '' unless $self->needs_linking(); #might be because of a subdir - return '' unless $self->has_link_code; my(@m); push(@m, <<'END'); -$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists + +$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(RM_RF) $@ END + # If this extension has its own library (eg SDBM_File) # then copy that to $(INST_STATIC) and add $(OBJECT) into it. - push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB}; + push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB}; + $(CP) $(MYEXTLIB) $@ +MAKE_FRAG my $ar; if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) { @@ -3448,20 +3705,19 @@ END } else { $ar = 'AR'; } - push @m, - "\t\$($ar) ".'$(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@'."\n"; - push @m, -q{ $(CHMOD) $(PERM_RWX) $@ - }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld -}; + push @m, sprintf <<'MAKE_FRAG', $ar; + $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@ + $(CHMOD) $(PERM_RWX) $@ + $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld +MAKE_FRAG + # Old mechanism - still available: - push @m, -"\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs -} if $self->{PERL_SRC} && $self->{EXTRALIBS}; - push @m, "\n"; + push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS}; + $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs +MAKE_FRAG - push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); - join('', "\n",@m); + push @m, "\n", $self->dir_target('$(INST_ARCHAUTODIR)'); + join('', @m); } =item staticmake (o) @@ -3479,7 +3735,7 @@ sub staticmake { # And as it's not yet built, we add the current extension # but only if it has some C code (or XS code, which implies C code) if (@{$self->{C}}) { - @static = File::Spec->catfile($self->{INST_ARCHLIB}, + @static = $self->catfile($self->{INST_ARCHLIB}, "auto", $self->{FULLEXT}, "$self->{BASEEXT}$self->{LIB_EXT}" @@ -3514,34 +3770,11 @@ Helper subroutine for subdirs sub subdir_x { my($self, $subdir) = @_; - my(@m); - if ($Is_Win32 && Win32::IsWin95()) { - if ($Config{'make'} =~ /dmake/i) { - # dmake-specific - return <<EOT; -subdirs :: -@[ - cd $subdir - \$(MAKE) -f \$(FIRST_MAKEFILE) all \$(PASTHRU) - cd .. -] -EOT - } elsif ($Config{'make'} =~ /nmake/i) { - # nmake-specific - return <<EOT; -subdirs :: - cd $subdir - \$(MAKE) -f \$(FIRST_MAKEFILE) all \$(PASTHRU) - cd .. -EOT - } - } else { - return <<EOT; + return sprintf <<'EOT', $subdir; subdirs :: - $self->{NOECHO}cd $subdir && \$(MAKE) -f \$(FIRST_MAKEFILE) all \$(PASTHRU) + $(NOECHO)cd %s && $(MAKE) -f $(FIRST_MAKEFILE) all $(PASTHRU) EOT - } } =item subdirs (o) @@ -3601,14 +3834,14 @@ testdb :: testdb_\$(LINKTYPE) test :: \$(TEST_TYPE) "); - if ($Is_Win32 && Win32::IsWin95()) { - push(@m, map(qq{\t$self->{NOECHO}\$(PERLRUN) -e "exit unless -f shift; chdir '$_'; system q{\$(MAKE) test \$(PASTHRU)}" $self->{MAKEFILE}\n}, @{$self->{DIR}})); + if ($Is_Win95) { + push(@m, map(qq{\t\$(NOECHO) \$(PERLRUN) -e "exit unless -f shift; chdir '$_'; system q{\$(MAKE) test \$(PASTHRU)}" \$(FIRST_MAKEFILE)\n}, @{$self->{DIR}})); } else { - push(@m, map("\t$self->{NOECHO}cd $_ && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n", @{$self->{DIR}})); + push(@m, map("\t\$(NOECHO) cd $_ && \$(TEST_F) \$(FIRST_MAKEFILE) && \$(MAKE) test \$(PASTHRU)\n", @{$self->{DIR}})); } - push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n") + push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n") unless $tests or -f "test.pl" or @{$self->{DIR}}; push(@m, "\n"); @@ -3665,87 +3898,38 @@ sub test_via_script { return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script); } -=item tool_autosplit (o) -Defines a simple perl call that runs autosplit. May be deprecated by -pm_to_blib soon. - -=cut - -sub tool_autosplit { - my($self, %attribs) = @_; - my($asl) = ""; - $asl = "\$\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN}; - - return sprintf <<'MAKE_FRAG', $asl; -# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;' +=item tools_other (o) -MAKE_FRAG + my $make_frag = $MM->tools_other; -} +Returns a make fragment containing definitions for: -=item tools_other (o) +SHELL, CHMOD, CP, MV, NOOP, NOECHO, RM_F, RM_RF, TEST_F, TOUCH, +DEV_NULL, UMASK_NULL, MKPATH, EQUALIZE_TIMESTAMP, +WARN_IF_OLD_PACKLIST, UNINST, VERBINST, MOD_INSTALL, DOC_INSTALL and +UNINSTALL -Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in -the Makefile. Also defines the perl programs MKPATH, -WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL. +init_others() initializes all these values. =cut sub tools_other { my($self) = shift; my @m; - my $bin_sh = $Config{sh} || '/bin/sh'; - push @m, qq{ -SHELL = $bin_sh -}; - for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) { - push @m, "$_ = $self->{$_}\n"; + for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH + UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP + ECHO ECHO_N + UNINST VERBINST + MOD_INSTALL DOC_INSTALL UNINSTALL + WARN_IF_OLD_PACKLIST + } ) + { + next unless defined $self->{$tool}; + push @m, "$tool = $self->{$tool}\n"; } - push @m, q{ -# The following is a portable way to say mkdir -p -# To see which directories are created, change the if 0 to if 1 -MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath - -# This helps us to minimize the effect of the .exists files A yet -# better solution would be to have a stable file in the perl -# distribution with a timestamp of zero. But this solution doesn't -# need any changes to the core distribution and works with older perls -EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime -}; - - - return join "", @m if $self->{PARENT}; - - push @m, q{ -# Here we warn users that an old packlist file was found somewhere, -# and that they should call some uninstall routine -WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \\ --e 'print "WARNING: I have found an old package in\n";' \\ --e 'print "\t$$ARGV[0].\n";' \\ --e 'print "Please make sure the two installations are not conflicting\n";' - -UNINST=0 -VERBINST=0 - -MOD_INSTALL = $(PERL) "-I$(INST_LIB)" "-I$(PERL_LIB)" "-MExtUtils::Install" \ --e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');" - -DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \ --e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", $$arg=shift, "|", $$arg, ">";' \ --e 'print "=over 4";' \ --e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \ --e 'print "=back";' - -UNINSTALL = $(PERLRUN) "-MExtUtils::Install" \ --e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \ --e 'print " packlist above carefully.\n There may be errors. Remove the";' \ --e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"' -}; - return join "", @m; } @@ -3758,8 +3942,17 @@ Determines typemaps, xsubpp version, prototype behaviour. sub tool_xsubpp { my($self) = shift; return "" unless $self->needs_linking; - my($xsdir) = File::Spec->catdir($self->{PERL_LIB},"ExtUtils"); - my(@tmdeps) = File::Spec->catdir('$(XSUBPPDIR)','typemap'); + + my $xsdir; + foreach my $dir (@INC) { + $xsdir = $self->catdir($dir, 'ExtUtils'); + if( -r $self->catfile($xsdir, "xsubpp") ) { + last; + } + } + + my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils"); + my(@tmdeps) = $self->catfile($tmdir,'typemap'); if( $self->{TYPEMAPS} ){ my $typemap; foreach $typemap (@{$self->{TYPEMAPS}}){ @@ -3778,27 +3971,11 @@ sub tool_xsubpp { } - my $xsubpp_version = $self->xsubpp_version(File::Spec->catfile($xsdir,"xsubpp")); - - # What are the correct thresholds for version 1 && 2 Paul? - if ( $xsubpp_version > 1.923 ){ - $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG}; - } else { - if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) { - print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp. - Your version of xsubpp is $xsubpp_version and cannot handle this. - Please upgrade to a more recent version of xsubpp. -}; - } else { - $self->{XSPROTOARG} = ""; - } - } - - my $xsubpp = "xsubpp"; + $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG}; return qq{ XSUBPPDIR = $xsdir -XSUBPP = \$(XSUBPPDIR)/$xsubpp +XSUBPP = \$(XSUBPPDIR)/xsubpp XSPROTOARG = $self->{XSPROTOARG} XSUBPPDEPS = @tmdeps \$(XSUBPP) XSUBPPARGS = @tmargs @@ -3806,59 +3983,20 @@ XSUBPP_EXTRA_ARGS = }; }; -sub xsubpp_version -{ - my($self,$xsubpp) = @_; - return $Xsubpp_Version if defined $Xsubpp_Version; # global variable - - my ($version) ; - - # try to figure out the version number of the xsubpp on the system - - # first try the -v flag, introduced in 1.921 & 2.000a2 - - return "" unless $self->needs_linking; - - my $command = qq{$self->{PERL} "-I$self->{PERL_LIB}" $xsubpp -v 2>&1}; - print "Running $command\n" if $Verbose >= 2; - $version = `$command` ; - warn "Running '$command' exits with status " . ($?>>8) if $?; - chop $version ; - - return $Xsubpp_Version = $1 if $version =~ /^xsubpp version (.*)/ ; - - # nope, then try something else - - my $counter = '000'; - my ($file) = 'temp' ; - $counter++ while -e "$file$counter"; # don't overwrite anything - $file .= $counter; - open(F, ">$file") or die "Cannot open file '$file': $!\n" ; - print F <<EOM ; -MODULE = fred PACKAGE = fred +=item all_target -int -fred(a) - int a; -EOM +Build man pages, too - close F ; - - $command = "$self->{PERL} $xsubpp $file 2>&1"; - print "Running $command\n" if $Verbose >= 2; - my $text = `$command` ; - warn "Running '$command' exits with status " . ($?>>8) if $?; - unlink $file ; - - # gets 1.2 -> 1.92 and 2.000a1 - return $Xsubpp_Version = $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ; +=cut - # it is either 1.0 or 1.1 - return $Xsubpp_Version = 1.1 if $text =~ /^Warning: ignored semicolon/ ; +sub all_target { + my $self = shift; - # none of the above, so 1.0 - return $Xsubpp_Version = "1.0" ; + return <<'MAKE_EXT'; +all :: pure_all manifypods + $(NOECHO) $(NOOP) +MAKE_EXT } =item top_targets (o) @@ -3873,43 +4011,39 @@ sub top_targets { my($self) = shift; my(@m); - push @m, ' -all :: pure_all manifypods - '.$self->{NOECHO}.'$(NOOP) -' - unless $self->{SKIPHASH}{'all'}; + push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'}; push @m, ' pure_all :: config pm_to_blib subdirs linkext - '.$self->{NOECHO}.'$(NOOP) + $(NOECHO) $(NOOP) subdirs :: $(MYEXTLIB) - '.$self->{NOECHO}.'$(NOOP) + $(NOECHO) $(NOOP) -config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists - '.$self->{NOECHO}.'$(NOOP) +config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) -config :: $(INST_ARCHAUTODIR)/.exists - '.$self->{NOECHO}.'$(NOOP) +config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) -config :: $(INST_AUTODIR)/.exists - '.$self->{NOECHO}.'$(NOOP) +config :: $(INST_AUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) '; push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); if (%{$self->{MAN1PODS}}) { - push @m, qq[ -config :: \$(INST_MAN1DIR)/.exists - $self->{NOECHO}\$(NOOP) + push @m, q[ +config :: $(INST_MAN1DIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) ]; push @m, $self->dir_target(qw[$(INST_MAN1DIR)]); } if (%{$self->{MAN3PODS}}) { - push @m, qq[ -config :: \$(INST_MAN3DIR)/.exists - $self->{NOECHO}\$(NOOP) + push @m, q[ +config :: $(INST_MAN3DIR)$(DIRFILESEP).exists + $(NOECHO) $(NOOP) ]; push @m, $self->dir_target(qw[$(INST_MAN3DIR)]); @@ -3989,47 +4123,6 @@ sub xs_o { # many makes are too dumb to use xs_c then c_o '; } -=item perl_archive - -This is internal method that returns path to libperl.a equivalent -to be linked to dynamic extensions. UNIX does not have one but other -OSs might have one. - -=cut - -sub perl_archive -{ - return ""; -} - -=item perl_archive_after - -This is an internal method that returns path to a library which -should be put on the linker command line I<after> the external libraries -to be linked to dynamic extensions. This may be needed if the linker -is one-pass, and Perl includes some overrides for C RTL functions, -such as malloc(). - -=cut - -sub perl_archive_after -{ - return ""; -} - -=item export_list - -This is internal method that returns name of a file that is -passed to linker to define symbols to be exported. -UNIX does not have one but OS2 and Win32 do. - -=cut - -sub export_list -{ - return ""; -} - 1; diff --git a/gnu/usr.bin/perl/lib/ExtUtils/MM_VMS.pm b/gnu/usr.bin/perl/lib/ExtUtils/MM_VMS.pm index 3fedae852f5..f9a50831e14 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/MM_VMS.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/MM_VMS.pm @@ -7,18 +7,25 @@ package ExtUtils::MM_VMS; use strict; -use Carp qw( &carp ); use Config; require Exporter; -use VMS::Filespec; + +BEGIN { + # so we can compile the thing on non-VMS platforms. + if( $^O eq 'VMS' ) { + require VMS::Filespec; + VMS::Filespec->import; + } +} + use File::Basename; -use File::Spec; use vars qw($Revision @ISA $VERSION); -($VERSION) = $Revision = '5.65'; +($VERSION) = '5.70'; +($Revision) = q$Revision: 1.7 $ =~ /Revision:\s+(\S+)/; require ExtUtils::MM_Any; require ExtUtils::MM_Unix; -@ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix File::Spec ); +@ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix ); use ExtUtils::MakeMaker qw($Verbose neatvalue); @@ -52,9 +59,8 @@ Converts a list into a string wrapped at approximately 80 columns. sub wraplist { my($self) = shift; my($line,$hlen) = ('',0); - my($word); - foreach $word (@_) { + foreach my $word (@_) { # Perl bug -- seems to occasionally insert extra elements when # traversing array (scalar(@array) doesn't show them, but # foreach(@array) does) (5.00307) @@ -158,25 +164,33 @@ sub find_perl { my($rslt); my($inabs) = 0; local *TCF; - # Check in relative directories first, so we pick up the current - # version of Perl if we're running MakeMaker as part of the main build. - @sdirs = sort { my($absa) = File::Spec->file_name_is_absolute($a); - my($absb) = File::Spec->file_name_is_absolute($b); - if ($absa && $absb) { return $a cmp $b } - else { return $absa ? 1 : ($absb ? -1 : ($a cmp $b)); } - } @$dirs; - # Check miniperl before perl, and check names likely to contain - # version numbers before "generic" names, so we pick up an - # executable that's less likely to be from an old installation. - @snames = sort { my($ba) = $a =~ m!([^:>\]/]+)$!; # basename - my($bb) = $b =~ m!([^:>\]/]+)$!; - my($ahasdir) = (length($a) - length($ba) > 0); - my($bhasdir) = (length($b) - length($bb) > 0); - if ($ahasdir and not $bhasdir) { return 1; } - elsif ($bhasdir and not $ahasdir) { return -1; } - else { $bb =~ /\d/ <=> $ba =~ /\d/ - or substr($ba,0,1) cmp substr($bb,0,1) - or length($bb) <=> length($ba) } } @$names; + + if( $self->{PERL_CORE} ) { + # Check in relative directories first, so we pick up the current + # version of Perl if we're running MakeMaker as part of the main build. + @sdirs = sort { my($absa) = $self->file_name_is_absolute($a); + my($absb) = $self->file_name_is_absolute($b); + if ($absa && $absb) { return $a cmp $b } + else { return $absa ? 1 : ($absb ? -1 : ($a cmp $b)); } + } @$dirs; + # Check miniperl before perl, and check names likely to contain + # version numbers before "generic" names, so we pick up an + # executable that's less likely to be from an old installation. + @snames = sort { my($ba) = $a =~ m!([^:>\]/]+)$!; # basename + my($bb) = $b =~ m!([^:>\]/]+)$!; + my($ahasdir) = (length($a) - length($ba) > 0); + my($bhasdir) = (length($b) - length($bb) > 0); + if ($ahasdir and not $bhasdir) { return 1; } + elsif ($bhasdir and not $ahasdir) { return -1; } + else { $bb =~ /\d/ <=> $ba =~ /\d/ + or substr($ba,0,1) cmp substr($bb,0,1) + or length($bb) <=> length($ba) } } @$names; + } + else { + @sdirs = @$dirs; + @snames = @$names; + } + # Image names containing Perl version use '_' instead of '.' under VMS foreach $name (@snames) { $name =~ s/\.(\d+)$/_$1/; } if ($trace >= 2){ @@ -187,7 +201,7 @@ sub find_perl { } foreach $dir (@sdirs){ next unless defined $dir; # $self->{PERL_SRC} may be undefined - $inabs++ if File::Spec->file_name_is_absolute($dir); + $inabs++ if $self->file_name_is_absolute($dir); if ($inabs == 1) { # We've covered relative dirs; everything else is an absolute # dir (probably an installed location). First, we'll try potential @@ -196,7 +210,7 @@ sub find_perl { $inabs++; # Should happen above in next $dir, but just in case . . . } foreach $name (@snames){ - if ($name !~ m![/:>\]]!) { push(@cand,File::Spec->catfile($dir,$name)); } + if ($name !~ m![/:>\]]!) { push(@cand,$self->catfile($dir,$name)); } else { push(@cand,$self->fixpath($name,0)); } } } @@ -211,9 +225,9 @@ sub find_perl { $rslt = `\@temp_mmvms.com` ; unlink('temp_mmvms.com'); if ($rslt =~ /VER_OK/) { - print "Using PERL=$name\n" if $trace; - return $name; - } + print "Using PERL=$name\n" if $trace; + return $name; + } } next unless $vmsfile = $self->maybe_command($name); $vmsfile =~ s/;[\d\-]*$//; # Clip off version number; we can use a newer version as well @@ -267,42 +281,6 @@ sub maybe_command { return 0; } -=item maybe_command_in_dirs (override) - -Uses DCL argument quoting on test command line. - -=cut - -sub maybe_command_in_dirs { # $ver is optional argument if looking for perl - my($self, $names, $dirs, $trace, $ver) = @_; - my($name, $dir); - foreach $dir (@$dirs){ - next unless defined $dir; # $self->{PERL_SRC} may be undefined - foreach $name (@$names){ - my($abs,$tryabs); - if (File::Spec->file_name_is_absolute($name)) { - $abs = $name; - } else { - $abs = File::Spec->catfile($dir, $name); - } - print "Checking $abs for $name\n" if ($trace >= 2); - next unless $tryabs = $self->maybe_command($abs); - print "Substituting $tryabs instead of $abs\n" - if ($trace >= 2 and $tryabs ne $abs); - $abs = $tryabs; - if (defined $ver) { - print "Executing $abs\n" if ($trace >= 2); - if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) { - print "Using $abs\n" if $trace; - return $abs; - } - } else { # Do not look for perl - return $abs; - } - } - } -} - =item perl_script (override) If name passed in doesn't specify a readable file, appends F<.com> or @@ -332,10 +310,42 @@ sub replace_manpage_separator { $man; } +=item init_DEST + +(override) Because of the difficulty concatenating VMS filepaths we +must pre-expand the DEST* variables. + +=cut + +sub init_DEST { + my $self = shift; + + $self->SUPER::init_DEST; + + # Expand DEST variables. + foreach my $var ($self->installvars) { + my $destvar = 'DESTINSTALL'.$var; + $self->{$destvar} = File::Spec->eliminate_macros($self->{$destvar}); + } +} + + +=item init_DIRFILESEP + +No seperator between a directory path and a filename on VMS. + +=cut + +sub init_DIRFILESEP { + my($self) = shift; + + $self->{DIRFILESEP} = ''; + return 1; +} + + =item init_main (override) -Override DISTVNAME so it uses VERSION_SYM to avoid getting too many -dots in the name. =cut @@ -343,7 +353,34 @@ sub init_main { my($self) = shift; $self->SUPER::init_main; - $self->{DISTVNAME} = "$self->{DISTNAME}-$self->{VERSION_SYM}"; + + $self->{DEFINE} ||= ''; + if ($self->{DEFINE} ne '') { + my(@terms) = split(/\s+/,$self->{DEFINE}); + my(@defs,@udefs); + foreach my $def (@terms) { + next unless $def; + my $targ = \@defs; + if ($def =~ s/^-([DU])//) { # If it was a Unix-style definition + $targ = \@udefs if $1 eq 'U'; + $def =~ s/='(.*)'$/=$1/; # then remove shell-protection '' + $def =~ s/^'(.*)'$/$1/; # from entire term or argument + } + if ($def =~ /=/) { + $def =~ s/"/""/g; # Protect existing " from DCL + $def = qq["$def"]; # and quote to prevent parsing of = + } + push @$targ, $def; + } + + $self->{DEFINE} = ''; + if (@defs) { + $self->{DEFINE} = '/Define=(' . join(',',@defs) . ')'; + } + if (@udefs) { + $self->{DEFINE} .= '/Undef=(' . join(',',@udefs) . ')'; + } + } } =item init_others (override) @@ -351,238 +388,201 @@ sub init_main { Provide VMS-specific forms of various utility commands, then hand off to the default MM_Unix method. +DEV_NULL should probably be overriden with something. + +Also changes EQUALIZE_TIMESTAMP to set revision date of target file to +one second later than source file, since MMK interprets precisely +equal revision dates for a source and target file as a sign that the +target needs to be updated. + =cut sub init_others { my($self) = @_; - $self->{NOOP} = 'Continue'; - $self->{FIRST_MAKEFILE} ||= 'Descrip.MMS'; - $self->{MAKE_APERL_FILE} ||= 'Makeaperl.MMS'; - $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE}; - $self->{NOECHO} ||= '@ '; - $self->{RM_F} = '$(PERL) -e "foreach (@ARGV) { 1 while ( -d $_ ? rmdir $_ : unlink $_)}"'; - $self->{RM_RF} = '$(PERLRUN) -e "use File::Path; @dirs = map(VMS::Filespec::unixify($_),@ARGV); rmtree(\@dirs,0,0)"'; - $self->{TOUCH} = '$(PERL) -e "$t=time; foreach (@ARGV) { -e $_ ? utime($t,$t,@ARGV) : (open(F,qq(>$_)),close F)}"'; - $self->{CHMOD} = '$(PERL) -e "chmod @ARGV"'; # expect Unix syntax from MakeMaker + $self->{NOOP} = 'Continue'; + $self->{NOECHO} ||= '@ '; + + $self->{MAKEFILE} ||= 'Descrip.MMS'; + $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE}; + $self->{MAKE_APERL_FILE} ||= 'Makeaperl.MMS'; + $self->{MAKEFILE_OLD} ||= '$(FIRST_MAKEFILE)_old'; + + $self->{ECHO} ||= '$(PERLRUN) -le "print qq{@ARGV}"'; + $self->{ECHO_N} ||= '$(PERLRUN) -e "print qq{@ARGV}"'; + $self->{TOUCH} ||= '$(PERLRUN) "-MExtUtils::Command" -e touch'; + $self->{CHMOD} ||= '$(PERLRUN) "-MExtUtils::Command" -e chmod'; + $self->{RM_F} ||= '$(PERLRUN) "-MExtUtils::Command" -e rm_f'; + $self->{RM_RF} ||= '$(PERLRUN) "-MExtUtils::Command" -e rm_rf'; + $self->{TEST_F} ||= '$(PERLRUN) "-MExtUtils::Command" -e test_f'; + $self->{EQUALIZE_TIMESTAMP} ||= '$(PERLRUN) -we "open F,qq{>>$ARGV[1]};close F;utime(0,(stat($ARGV[0]))[9]+1,$ARGV[1])"'; + + $self->{MOD_INSTALL} ||= + $self->oneliner(<<'CODE', ['-MExtUtils::Install']); +install({split(' ',<STDIN>)}, '$(VERBINST)', 0, '$(UNINST)'); +CODE + + $self->{SHELL} ||= 'Posix'; + $self->{CP} = 'Copy/NoConfirm'; $self->{MV} = 'Rename/NoConfirm'; $self->{UMASK_NULL} = '! '; - + $self->SUPER::init_others; + + if ($self->{OBJECT} =~ /\s/) { + $self->{OBJECT} =~ s/(\\)?\n+\s+/ /g; + $self->{OBJECT} = $self->wraplist( + map $self->fixpath($_,0), split /,?\s+/, $self->{OBJECT} + ); + } + + $self->{LDFROM} = $self->wraplist( + map $self->fixpath($_,0), split /,?\s+/, $self->{LDFROM} + ); } -=item constants (override) -Fixes up numerous file and directory macros to insure VMS syntax -regardless of input syntax. Also adds a few VMS-specific macros -and makes lists of files comma-separated. +=item init_platform (override) + +Add PERL_VMS, MM_VMS_REVISION and MM_VMS_VERSION. + +MM_VMS_REVISION is for backwards compatibility before MM_VMS had a +$VERSION. =cut -sub constants { - my($self) = @_; - my(@m,$def,$macro); +sub init_platform { + my($self) = shift; - # Be kind about case for pollution - for (@ARGV) { $_ = uc($_) if /POLLUTE/i; } + $self->{MM_VMS_REVISION} = $Revision; + $self->{MM_VMS_VERSION} = $VERSION; + $self->{PERL_VMS} = $self->catdir($self->{PERL_SRC}, 'VMS') + if $self->{PERL_SRC}; +} - $self->{DEFINE} ||= ''; - if ($self->{DEFINE} ne '') { - my(@terms) = split(/\s+/,$self->{DEFINE}); - my(@defs,@udefs); - foreach $def (@terms) { - next unless $def; - my $targ = \@defs; - if ($def =~ s/^-([DU])//) { # If it was a Unix-style definition - if ($1 eq 'U') { $targ = \@udefs; } - $def =~ s/='(.*)'$/=$1/; # then remove shell-protection '' - $def =~ s/^'(.*)'$/$1/; # from entire term or argument - } - if ($def =~ /=/) { - $def =~ s/"/""/g; # Protect existing " from DCL - $def = qq["$def"]; # and quote to prevent parsing of = - } - push @$targ, $def; - } - $self->{DEFINE} = ''; - if (@defs) { - $self->{DEFINE} = '/Define=(' . join(',',@defs) . ')'; - } - if (@udefs) { - $self->{DEFINE} .= '/Undef=(' . join(',',@udefs) . ')'; - } - } - if ($self->{OBJECT} =~ /\s/) { - $self->{OBJECT} =~ s/(\\)?\n+\s+/ /g; - $self->{OBJECT} = $self->wraplist(map($self->fixpath($_,0),split(/,?\s+/,$self->{OBJECT}))); - } - $self->{LDFROM} = $self->wraplist(map($self->fixpath($_,0),split(/,?\s+/,$self->{LDFROM}))); +=item platform_constants +=cut - foreach $macro ( qw [ - INST_BIN INST_SCRIPT INST_LIB INST_ARCHLIB - INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB - INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH - INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN INSTALLSCRIPT - INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DIR - INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DIR - PERL_LIB PERL_ARCHLIB - PERL_INC PERL_SRC FULLEXT ] ) { - next unless defined $self->{$macro}; - next if $macro =~ /MAN/ && $self->{$macro} eq 'none'; - $self->{$macro} = $self->fixpath($self->{$macro},1); +sub platform_constants { + my($self) = shift; + my $make_frag = ''; + + foreach my $macro (qw(PERL_VMS MM_VMS_REVISION MM_VMS_VERSION)) + { + next unless defined $self->{$macro}; + $make_frag .= "$macro = $self->{$macro}\n"; } - $self->{PERL_VMS} = File::Spec->catdir($self->{PERL_SRC},q(VMS)) - if ($self->{PERL_SRC}); - + return $make_frag; +} - # Fix up file specs - foreach $macro ( qw[LIBPERL_A FIRST_MAKEFILE MAKE_APERL_FILE MYEXTLIB] ) { - next unless defined $self->{$macro}; - $self->{$macro} = $self->fixpath($self->{$macro},0); - } - foreach $macro (qw/ - AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION VERSION_SYM - XS_VERSION - INST_BIN INST_LIB INST_ARCHLIB INST_SCRIPT - INSTALLDIRS - PREFIX SITEPREFIX VENDORPREFIX - INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB - INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH - INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN INSTALLSCRIPT - PERL_LIB PERL_ARCHLIB - SITELIBEXP SITEARCHEXP - LIBPERL_A MYEXTLIB - FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_VMS - PERL_INC PERL FULLPERL PERLRUN FULLPERLRUN PERLRUNINST - FULLPERLRUNINST ABSPERL ABSPERLRUN ABSPERLRUNINST - PERL_CORE NOECHO NOOP - / ) { - next unless defined $self->{$macro}; - push @m, "$macro = $self->{$macro}\n"; - } +=item init_VERSION (override) +Override the *DEFINE_VERSION macros with VMS semantics. Translate the +MAKEMAKER filepath to VMS style. - push @m, q[ -VERSION_MACRO = VERSION -DEFINE_VERSION = "$(VERSION_MACRO)=""$(VERSION)""" -XS_VERSION_MACRO = XS_VERSION -XS_DEFINE_VERSION = "$(XS_VERSION_MACRO)=""$(XS_VERSION)""" - -MAKEMAKER = ],File::Spec->catfile($self->{PERL_LIB},'ExtUtils','MakeMaker.pm'),qq[ -MM_VERSION = $ExtUtils::MakeMaker::VERSION -MM_REVISION = $ExtUtils::MakeMaker::Revision -MM_VMS_REVISION = $ExtUtils::MM_VMS::Revision - -# FULLEXT = Pathname for extension directory (eg DBD/Oracle). -# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. -# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) -# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. -]; +=cut - for my $tmp (qw/ - FULLEXT VERSION_FROM OBJECT LDFROM - / ) { - next unless defined $self->{$tmp}; - push @m, "$tmp = ",$self->fixpath($self->{$tmp},0),"\n"; - } +sub init_VERSION { + my $self = shift; - for my $tmp (qw/ - BASEEXT PARENT_NAME DLBASE INC DEFINE LINKTYPE - / ) { - next unless defined $self->{$tmp}; - push @m, "$tmp = $self->{$tmp}\n"; - } + $self->SUPER::init_VERSION; - for my $tmp (qw/ XS MAN1PODS MAN3PODS PM /) { - # Where is the space coming from? --jhi - next unless $self ne " " && defined $self->{$tmp}; - my(%tmp,$key); - for $key (keys %{$self->{$tmp}}) { - $tmp{$self->fixpath($key,0)} = $self->fixpath($self->{$tmp}{$key},0); - } - $self->{$tmp} = \%tmp; + $self->{DEFINE_VERSION} = '"$(VERSION_MACRO)=""$(VERSION)"""'; + $self->{XS_DEFINE_VERSION} = '"$(XS_VERSION_MACRO)=""$(XS_VERSION)"""'; + $self->{MAKEMAKER} = vmsify($INC{'ExtUtils/MakeMaker.pm'}); +} + + +=item constants (override) + +Fixes up numerous file and directory macros to insure VMS syntax +regardless of input syntax. Also makes lists of files +comma-separated. + +=cut + +sub constants { + my($self) = @_; + + # Be kind about case for pollution + for (@ARGV) { $_ = uc($_) if /POLLUTE/i; } + + # Cleanup paths for directories in MMS macros. + foreach my $macro ( qw [ + INST_BIN INST_SCRIPT INST_LIB INST_ARCHLIB + PERL_LIB PERL_ARCHLIB + PERL_INC PERL_SRC ], + (map { 'INSTALL'.$_ } $self->installvars) + ) + { + next unless defined $self->{$macro}; + next if $macro =~ /MAN/ && $self->{$macro} eq 'none'; + $self->{$macro} = $self->fixpath($self->{$macro},1); } - for my $tmp (qw/ C O_FILES H /) { - next unless defined $self->{$tmp}; - my(@tmp,$val); - for $val (@{$self->{$tmp}}) { - push(@tmp,$self->fixpath($val,0)); - } - $self->{$tmp} = \@tmp; + # Cleanup paths for files in MMS macros. + foreach my $macro ( qw[LIBPERL_A FIRST_MAKEFILE MAKEFILE_OLD + MAKE_APERL_FILE MYEXTLIB] ) + { + next unless defined $self->{$macro}; + $self->{$macro} = $self->fixpath($self->{$macro},0); } - push @m,' + # Fixup files for MMS macros + # XXX is this list complete? + for my $macro (qw/ + FULLEXT VERSION_FROM OBJECT LDFROM + / ) { + next unless defined $self->{$macro}; + $self->{$macro} = $self->fixpath($self->{$macro},0); + } -# Handy lists of source code files: -XS_FILES = ',$self->wraplist(sort keys %{$self->{XS}}),' -C_FILES = ',$self->wraplist(@{$self->{C}}),' -O_FILES = ',$self->wraplist(@{$self->{O_FILES}} ),' -H_FILES = ',$self->wraplist(@{$self->{H}}),' -MAN1PODS = ',$self->wraplist(sort keys %{$self->{MAN1PODS}}),' -MAN3PODS = ',$self->wraplist(sort keys %{$self->{MAN3PODS}}),' -'; + for my $macro (qw/ XS MAN1PODS MAN3PODS PM /) { + # Where is the space coming from? --jhi + next unless $self ne " " && defined $self->{$macro}; + my %tmp = (); + for my $key (keys %{$self->{$macro}}) { + $tmp{$self->fixpath($key,0)} = + $self->fixpath($self->{$macro}{$key},0); + } + $self->{$macro} = \%tmp; + } - for my $tmp (qw/ - INST_MAN1DIR MAN1EXT - INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DIR - INST_MAN3DIR MAN3EXT - INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DIR - /) { - next unless defined $self->{$tmp}; - push @m, "$tmp = $self->{$tmp}\n"; + for my $macro (qw/ C O_FILES H /) { + next unless defined $self->{$macro}; + my @tmp = (); + for my $val (@{$self->{$macro}}) { + push(@tmp,$self->fixpath($val,0)); + } + $self->{$macro} = \@tmp; } -push @m," -makemakerdflt : all - \$(NOECHO) \$(NOOP) + return $self->SUPER::constants; +} -.SUFFIXES : -.SUFFIXES : \$(OBJ_EXT) .c .cpp .cxx .xs -# Here is the Config.pm that we are using/depend on -CONFIGDEP = \$(PERL_ARCHLIB)Config.pm, \$(PERL_INC)config.h \$(VERSION_FROM) +=item special_targets -# Where to put things: -INST_LIBDIR = $self->{INST_LIBDIR} -INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR} +Clear the default .SUFFIXES and put in our own list. -INST_AUTODIR = $self->{INST_AUTODIR} -INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR} -"; +=cut - if ($self->has_link_code()) { - push @m,' -INST_STATIC = $(INST_ARCHAUTODIR)$(BASEEXT)$(LIB_EXT) -INST_DYNAMIC = $(INST_ARCHAUTODIR)$(DLBASE).$(DLEXT) -INST_BOOT = $(INST_ARCHAUTODIR)$(BASEEXT).bs -'; - } else { - my $shr = $Config{'dbgprefix'} . 'PERLSHR'; - push @m,' -INST_STATIC = -INST_DYNAMIC = -INST_BOOT = -EXPORT_LIST = $(BASEEXT).opt -PERL_ARCHIVE = ',($ENV{$shr} ? $ENV{$shr} : "Sys\$Share:$shr.$Config{'dlext'}"),' -'; - } +sub special_targets { + my $self = shift; - $self->{TO_INST_PM} = [ sort keys %{$self->{PM}} ]; - $self->{PM_TO_BLIB} = [ %{$self->{PM}} ]; - push @m,' -TO_INST_PM = ',$self->wraplist(@{$self->{TO_INST_PM}}),' + my $make_frag .= <<'MAKE_FRAG'; +.SUFFIXES : +.SUFFIXES : $(OBJ_EXT) .c .cpp .cxx .xs -PM_TO_BLIB = ',$self->wraplist(@{$self->{PM_TO_BLIB}}),' -'; +MAKE_FRAG - join('',@m); + return $make_frag; } =item cflags (override) @@ -723,78 +723,6 @@ sub const_cccmd { $self->{CONST_CCCMD} = join('',@m); } -=item pm_to_blib (override) - -DCL I<still> accepts a maximum of 255 characters on a command -line, so we write the (potentially) long list of file names -to a temp file, then persuade Perl to read it instead of the -command line to find args. - -=cut - -sub pm_to_blib { - my($self) = @_; - my($autodir) = File::Spec->catdir($self->{INST_LIB},'auto'); - my(%files) = @{$self->{PM_TO_BLIB}}; - - my $m = <<'MAKE_FRAG'; - -# Dummy target to match Unix target name; we use pm_to_blib.ts as -# timestamp file to avoid repeated invocations under VMS -pm_to_blib : pm_to_blib.ts - $(NOECHO) $(NOOP) - -# As always, keep under DCL's 255-char limit -pm_to_blib.ts : $(TO_INST_PM) -MAKE_FRAG - - if( keys %files ) { - $m .= <<'MAKE_FRAG'; - $(NOECHO) $(RM_F) .MM_tmp -MAKE_FRAG - - my $line = ''; - while (my($from, $to) = each %files) { - $line .= " $from $to"; - if (length($line) > 128) { - $m .= sprintf <<'MAKE_FRAG', $line; - $(NOECHO) $(PERL) -e "print '%s'" >>.MM_tmp -MAKE_FRAG - $line = ''; - } - } - $m .= sprintf <<'MAKE_FRAG', $line if $line; - $(NOECHO) $(PERL) -e "print '%s'" >>.MM_tmp -MAKE_FRAG - - $m .= sprintf <<'MAKE_FRAG', $autodir; - $(PERLRUN) "-MExtUtils::Install" -e "pm_to_blib({split(' ',<STDIN>)},'%s','$(PM_FILTER)')" <.MM_tmp - $(NOECHO) $(RM_F) .MM_tmp -MAKE_FRAG - - } - $m .= <<'MAKE_FRAG'; - $(NOECHO) $(TOUCH) pm_to_blib.ts -MAKE_FRAG - - return $m; -} - -=item tool_autosplit (override) - -Use VMS-style quoting on command line. - -=cut - -sub tool_autosplit { - my($self, %attribs) = @_; - my($asl) = ""; - $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN}; - q{ -# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(PERLRUN) -e "use AutoSplit;}.$asl.q{autosplit($ARGV[0], $ARGV[1], 0, 1, 1) ;" -}; -} =item tool_sxubpp (override) @@ -805,10 +733,17 @@ Use VMS-style quoting on xsubpp command line. sub tool_xsubpp { my($self) = @_; return '' unless $self->needs_linking; - my($xsdir) = File::Spec->catdir($self->{PERL_LIB},'ExtUtils'); - # drop back to old location if xsubpp is not in new location yet - $xsdir = File::Spec->catdir($self->{PERL_SRC},'ext') unless (-f File::Spec->catfile($xsdir,'xsubpp')); - my(@tmdeps) = '$(XSUBPPDIR)typemap'; + + my $xsdir; + foreach my $dir (@INC) { + $xsdir = $self->catdir($dir, 'ExtUtils'); + if( -r $self->catfile($xsdir, "xsubpp") ) { + last; + } + } + + my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils"); + my(@tmdeps) = $self->catfile($tmdir,'typemap'); if( $self->{TYPEMAPS} ){ my $typemap; foreach $typemap (@{$self->{TYPEMAPS}}){ @@ -831,23 +766,11 @@ sub tool_xsubpp { (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)) { unshift(@tmargs,'-nolinenumbers'); } - my $xsubpp_version = $self->xsubpp_version(File::Spec->catfile($xsdir,'xsubpp')); - # What are the correct thresholds for version 1 && 2 Paul? - if ( $xsubpp_version > 1.923 ){ - $self->{XSPROTOARG} = '' unless defined $self->{XSPROTOARG}; - } else { - if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) { - print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp. - Your version of xsubpp is $xsubpp_version and cannot handle this. - Please upgrade to a more recent version of xsubpp. -}; - } else { - $self->{XSPROTOARG} = ""; - } - } - " + $self->{XSPROTOARG} = '' unless defined $self->{XSPROTOARG}; + + return " XSUBPPDIR = $xsdir XSUBPP = \$(PERLRUN) \$(XSUBPPDIR)xsubpp XSPROTOARG = $self->{XSPROTOARG} @@ -856,136 +779,71 @@ XSUBPPARGS = @tmargs "; } -=item xsubpp_version (override) -Test xsubpp exit status according to VMS rules ($sts & 1 ==E<gt> good) -rather than Unix rules ($sts == 0 ==E<gt> good). +=item tools_other (override) -=cut +Throw in some dubious extra macros for Makefile args. -sub xsubpp_version -{ - my($self,$xsubpp) = @_; - my ($version) ; - return '' unless $self->needs_linking; +Also keep around the old $(SAY) macro in case somebody's using it. - # try to figure out the version number of the xsubpp on the system +=cut - # first try the -v flag, introduced in 1.921 & 2.000a2 +sub tools_other { + my($self) = @_; - my $command = qq{$self->{PERL} "-I$self->{PERL_LIB}" $xsubpp -v}; - print "Running: $command\n" if $Verbose; - $version = `$command` ; - if ($?) { - use vmsish 'status'; - warn "Running '$command' exits with status $?"; - } - chop $version ; + # XXX Are these necessary? Does anyone override them? They're longer + # than just typing the literal string. + my $extra_tools = <<'EXTRA_TOOLS'; - return $1 if $version =~ /^xsubpp version (.*)/ ; +# Assumes $(MMS) invokes MMS or MMK +# (It is assumed in some cases later that the default makefile name +# (Descrip.MMS for MM[SK]) is used.) +USEMAKEFILE = /Descrip= +USEMACROS = /Macro=( +MACROEND = ) - # nope, then try something else +# Just in case anyone is using the old macro. +SAY = $(ECHO) - my $counter = '000'; - my ($file) = 'temp' ; - $counter++ while -e "$file$counter"; # don't overwrite anything - $file .= $counter; +EXTRA_TOOLS - local(*F); - open(F, ">$file") or die "Cannot open file '$file': $!\n" ; - print F <<EOM ; -MODULE = fred PACKAGE = fred + return $self->SUPER::tools_other . $extra_tools; +} -int -fred(a) - int a; -EOM +=item init_dist (override) - close F ; +VMSish defaults for some values. - $command = "$self->{PERLRUN} $xsubpp $file"; - print "Running: $command\n" if $Verbose; - my $text = `$command` ; - if ($?) { - use vmsish 'status'; - warn "Running '$command' exits with status $?"; - } - unlink $file ; + macro description default - # gets 1.2 -> 1.92 and 2.000a1 - return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ; + ZIPFLAGS flags to pass to ZIP -Vu - # it is either 1.0 or 1.1 - return 1.1 if $text =~ /^Warning: ignored semicolon/ ; + COMPRESS compression command to gzip + use for tarfiles + SUFFIX suffix to put on -gz + compressed files - # none of the above, so 1.0 - return "1.0" ; -} + SHAR shar command to use vms_share -=item tools_other (override) + DIST_DEFAULT default target to use to tardist + create a distribution -Adds a few MM[SK] macros, and shortens some the installatin commands, -in order to stay under DCL's 255-character limit. Also changes -EQUALIZE_TIMESTAMP to set revision date of target file to one second -later than source file, since MMK interprets precisely equal revision -dates for a source and target file as a sign that the target needs -to be updated. + DISTVNAME Use VERSION_SYM instead of $(DISTNAME)-$(VERSION_SYM) + VERSION for the name =cut -sub tools_other { +sub init_dist { my($self) = @_; - qq! -# Assumes \$(MMS) invokes MMS or MMK -# (It is assumed in some cases later that the default makefile name -# (Descrip.MMS for MM[SK]) is used.) -USEMAKEFILE = /Descrip= -USEMACROS = /Macro=( -MACROEND = ) -MAKEFILE = Descrip.MMS -SHELL = Posix -TOUCH = $self->{TOUCH} -CHMOD = $self->{CHMOD} -CP = $self->{CP} -MV = $self->{MV} -RM_F = $self->{RM_F} -RM_RF = $self->{RM_RF} -SAY = Write Sys\$Output -UMASK_NULL = $self->{UMASK_NULL} -MKPATH = Create/Directory -EQUALIZE_TIMESTAMP = \$(PERL) -we "open F,qq{>\$ARGV[1]};close F;utime(0,(stat(\$ARGV[0]))[9]+1,\$ARGV[1])" -!. ($self->{PARENT} ? '' : -qq!WARN_IF_OLD_PACKLIST = \$(PERL) -e "if (-f \$ARGV[0]){print qq[WARNING: Old package found (\$ARGV[0]); please check for collisions\\n]}" -MOD_INSTALL = \$(PERLRUN) "-MExtUtils::Install" -e "install({split(' ',<STDIN>)},1);" -DOC_INSTALL = \$(PERL) -e "\@ARGV=split(/\\|/,<STDIN>);print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];while(\$key=shift && \$val=shift){print qq[=item *\\n\\nC<\$key: \$val>\\n\\n];}print qq[=back\\n\\n]" -UNINSTALL = \$(PERLRUN) "-MExtUtils::Install" -e "uninstall(\$ARGV[0],1,1);" -!); -} - -=item dist (override) - -Provide VMSish defaults for some values, then hand off to -default MM_Unix method. - -=cut - -sub dist { - my($self, %attribs) = @_; - $attribs{VERSION} ||= $self->{VERSION_SYM}; - $attribs{NAME} ||= $self->{DISTNAME}; - $attribs{ZIPFLAGS} ||= '-Vu'; - $attribs{COMPRESS} ||= 'gzip'; - $attribs{SUFFIX} ||= '-gz'; - $attribs{SHAR} ||= 'vms_share'; - $attribs{DIST_DEFAULT} ||= 'zipdist'; - - # Sanitize these for use in $(DISTVNAME) filespec - $attribs{VERSION} =~ s/[^\w\$]/_/g; - $attribs{NAME} =~ s/[^\w\$]/-/g; + $self->{ZIPFLAGS} ||= '-Vu'; + $self->{COMPRESS} ||= 'gzip'; + $self->{SUFFIX} ||= '-gz'; + $self->{SHAR} ||= 'vms_share'; + $self->{DIST_DEFAULT} ||= 'zipdist'; - $attribs{DISTVNAME} ||= '$(DISTNAME)-$(VERSION_SYM)'; + $self->SUPER::init_dist; - return $self->SUPER::dist(%attribs); + $self->{DISTVNAME} = "$self->{DISTNAME}-$self->{VERSION_SYM}"; } =item c_o (override) @@ -1042,62 +900,6 @@ sub xs_o { # many makes are too dumb to use xs_c then c_o '; } -=item top_targets (override) - -Path seperator differences. - -=cut - -sub top_targets { - my($self) = shift; - my(@m); - push @m, ' -all :: pure_all manifypods - $(NOECHO) $(NOOP) - -pure_all :: config pm_to_blib subdirs linkext - $(NOECHO) $(NOOP) - -subdirs :: $(MYEXTLIB) - $(NOECHO) $(NOOP) - -config :: $(MAKEFILE) $(INST_LIBDIR).exists - $(NOECHO) $(NOOP) - -config :: $(INST_ARCHAUTODIR).exists - $(NOECHO) $(NOOP) - -config :: $(INST_AUTODIR).exists - $(NOECHO) $(NOOP) -'; - - push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); - if (%{$self->{MAN1PODS}}) { - push @m, q[ -config :: $(INST_MAN1DIR).exists - $(NOECHO) $(NOOP) -]; - push @m, $self->dir_target(qw[$(INST_MAN1DIR)]); - } - if (%{$self->{MAN3PODS}}) { - push @m, q[ -config :: $(INST_MAN3DIR).exists - $(NOECHO) $(NOOP) -]; - push @m, $self->dir_target(qw[$(INST_MAN3DIR)]); - } - - push @m, ' -$(O_FILES) : $(H_FILES) -' if @{$self->{O_FILES} || []} && @{$self->{H} || []}; - - push @m, q{ -help : - perldoc ExtUtils::MakeMaker -}; - - join('',@m); -} =item dlsyms (override) @@ -1204,7 +1006,7 @@ INST_DYNAMIC_DEP = $inst_dynamic_dep "; push @m, ' -$(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt $(INST_ARCHAUTODIR).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) +$(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) If F$TrnLNm("',$shr,'").eqs."" Then Define/NoLog/User ',"$shr Sys\$Share:$shr.$Config{'dlext'}",' Link $(LDFLAGS) /Shareable=$(MMS$TARGET)$(OTHERLDFLAGS) $(BASEEXT).opt/Option,$(PERL_INC)perlshr_attr.opt/Option @@ -1231,13 +1033,13 @@ BOOTSTRAP = '."$self->{BASEEXT}.bs".' # As MakeMaker mkbootstrap might not write a file (if none is required) # we use touch to prevent make continually trying to remake it. # The DynaLoader only reads a non-empty file. -$(BOOTSTRAP) : $(MAKEFILE) '."$self->{BOOTDEP}".' $(INST_ARCHAUTODIR).exists - $(NOECHO) $(SAY) "Running mkbootstrap for $(NAME) ($(BSLOADLIBS))" +$(BOOTSTRAP) : $(FIRST_MAKEFILE) '."$self->{BOOTDEP}".' $(INST_ARCHAUTODIR)$(DIRFILESEP).exists + $(NOECHO) $(ECHO) "Running mkbootstrap for $(NAME) ($(BSLOADLIBS))" $(NOECHO) $(PERLRUN) - -e "use ExtUtils::Mkbootstrap; Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');" $(NOECHO) $(TOUCH) $(MMS$TARGET) -$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR).exists +$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(NOECHO) $(RM_RF) $(INST_BOOT) - $(CP) $(BOOTSTRAP) $(INST_BOOT) '; @@ -1261,7 +1063,7 @@ $(INST_STATIC) : my(@m,$lib); push @m,' # Rely on suffix rule for update action -$(OBJECT) : $(INST_ARCHAUTODIR).exists +$(OBJECT) : $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) '; @@ -1289,56 +1091,6 @@ $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) } -=item manifypods (override) - -Use VMS-style quoting on command line, and VMS logical name -to specify fallback location at build time if we can't find pod2man. - -=cut - - -sub manifypods { - my($self, %attribs) = @_; - return "\nmanifypods :\n\t\$(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'); - } - if (not ($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. As a last choice, - I will look for the file to which the logical name POD2MAN - points when MMK is invoked. - -END - $pod2man_exe = "pod2man"; - } - my(@m); - push @m, -qq[POD2MAN_EXE = $pod2man_exe\n], -q[POD2MAN = $(PERLRUN) "-MPod::Man" -we "%m=@ARGV;for(keys %m){" - --e "Pod::Man->new->parse_from_file($_,$m{$_}) }" -]; - push @m, "\nmanifypods : \$(MAN1PODS) \$(MAN3PODS)\n"; - if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) { - my($pod); - foreach $pod (sort keys %{$self->{MAN1PODS}}) { - push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ]; - push @m, "$pod $self->{MAN1PODS}{$pod}\n"; - } - foreach $pod (sort keys %{$self->{MAN3PODS}}) { - push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ]; - push @m, "$pod $self->{MAN3PODS}{$pod}\n"; - } - } - join('', @m); -} - =item processPL (override) Use VMS-style quoting on command line. @@ -1380,7 +1132,7 @@ sub installbin { my($self) = @_; return '' unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY"; return '' unless @{$self->{EXE_FILES}}; - my(@m, $from, $to, %fromto, @to, $line); + my(@m, $from, $to, %fromto, @to); my(@exefiles) = map { vmsify($_) } @{$self->{EXE_FILES}}; for $from (@exefiles) { my($path) = '$(INST_SCRIPT)' . basename($from); @@ -1393,9 +1145,13 @@ sub installbin { push @m, " EXE_FILES = @exefiles +pure_all :: @to + \$(NOECHO) \$(NOOP) + realclean :: "; - $line = ''; #avoid unitialized var warning + + my $line = ''; foreach $to (@to) { if (length($line) + length($to) > 80) { push @m, "\t\$(RM_F) $line\n"; @@ -1408,11 +1164,15 @@ realclean :: while (($from,$to) = each %fromto) { last unless defined $from; my $todir; - if ($to =~ m#[/>:\]]#) { $todir = dirname($to); } - else { ($todir = $to) =~ s/[^\)]+$//; } + if ($to =~ m#[/>:\]]#) { + $todir = dirname($to); + } + else { + ($todir = $to) =~ s/[^\)]+$//; + } $todir = $self->fixpath($todir,1); push @m, " -$to : $from \$(MAKEFILE) ${todir}.exists +$to : $from \$(FIRST_MAKEFILE) ${todir}\$(DIRFILESEP).exists \$(CP) $from $to ", $self->dir_target($todir); @@ -1455,13 +1215,8 @@ sub clean { push @m, ' # Delete temporary files but do not touch installed files. We don\'t delete # the Descrip.MMS here so that a later make realclean still has it to use. -clean :: +clean :: clean_subdirs '; - foreach $dir (@{$self->{DIR}}) { # clean subdirectories first - my($vmsdir) = $self->fixpath($dir,1); - push( @m, ' If F$Search("'.$vmsdir.'$(MAKEFILE)").nes."" Then \\',"\n\t", - '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS)$(MMSQUALIFIERS) clean`;"',"\n"); - } push @m, ' $(RM_F) *.Map *.Dmp *.Lis *.cpp *.$(DLEXT) *$(OBJ_EXT) *$(LIB_EXT) *.Opt $(BOOTSTRAP) $(BASEEXT).bso .MM_Tmp '; @@ -1469,24 +1224,29 @@ clean :: # Unlink realclean, $attribs{FILES} is a string here; it may contain # a list or a macro that expands to a list. if ($attribs{FILES}) { - my($word,$key,@filist); - if (ref $attribs{FILES} eq 'ARRAY') { @filist = @{$attribs{FILES}}; } - else { @filist = split /\s+/, $attribs{FILES}; } - foreach $word (@filist) { - if (($key) = $word =~ m#^\$\((.*)\)$# and ref $self->{$key} eq 'ARRAY') { - push(@otherfiles, @{$self->{$key}}); + my @filelist = ref $attribs{FILES} eq 'ARRAY' + ? @{$attribs{FILES}} + : split /\s+/, $attribs{FILES}; + + foreach my $word (@filelist) { + if ($word =~ m#^\$\((.*)\)$# and + ref $self->{$1} eq 'ARRAY') + { + push(@otherfiles, @{$self->{$1}}); } else { push(@otherfiles, $word); } } } - push(@otherfiles, qw[ blib $(MAKE_APERL_FILE) extralibs.ld perlmain.c pm_to_blib.ts ]); - push(@otherfiles,File::Spec->catfile('$(INST_ARCHAUTODIR)','extralibs.all')); - my($file,$line); - $line = ''; #avoid unitialized var warning + push(@otherfiles, qw[ blib $(MAKE_APERL_FILE) + perlmain.c pm_to_blib pm_to_blib.ts ]); + push(@otherfiles, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all')); + push(@otherfiles, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld')); + # Occasionally files are repeated several times from different sources - { my(%of) = map { ($_,1) } @otherfiles; @otherfiles = keys %of; } + { my(%of) = map { ($_ => 1) } @otherfiles; @otherfiles = keys %of; } - foreach $file (@otherfiles) { + my $line = ''; + foreach my $file (@otherfiles) { $file = $self->fixpath($file); if (length($line) + length($file) > 80) { push @m, "\t\$(RM_RF) $line\n"; @@ -1499,6 +1259,39 @@ clean :: join('', @m); } + +=item clean_subdirs_target + + my $make_frag = $MM->clean_subdirs_target; + +VMS semantics for changing directories and rerunning make very different. + +=cut + +sub clean_subdirs_target { + my($self) = shift; + + # No subdirectories, no cleaning. + return <<'NOOP_FRAG' unless @{$self->{DIR}}; +clean_subdirs : + $(NOECHO) $(NOOP) +NOOP_FRAG + + + my $clean = "clean_subdirs :\n"; + + foreach my $dir (@{$self->{DIR}}) { # clean subdirectories first + $dir = $self->fixpath($dir,1); + + $clean .= sprintf <<'MAKE_FRAG', $dir, $dir; + If F$Search("%s$(FIRST_MAKEFILE)").nes."" Then $(PERLRUN) -e "chdir '%s'; print `$(MMS)$(MMSQUALIFIERS) clean`;" +MAKE_FRAG + } + + return $clean; +} + + =item realclean (override) Guess what we're working around? Also, use MM[SK] for subdirectories. @@ -1514,7 +1307,7 @@ realclean :: clean '); foreach(@{$self->{DIR}}){ my($vmsdir) = $self->fixpath($_,1); - push(@m, ' If F$Search("'."$vmsdir".'$(MAKEFILE)").nes."" Then \\',"\n\t", + push(@m, ' If F$Search("'."$vmsdir".'$(FIRST_MAKEFILE)").nes."" Then \\',"\n\t", '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS)$(MMSQUALIFIERS) realclean`;"',"\n"); } push @m, " \$(RM_RF) \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n"; @@ -1523,17 +1316,18 @@ realclean :: clean # corresponding %$self keys (i.e. they're defined in Descrip.MMS as a # combination of macros). In order to stay below DCL's 255 char limit, # we put only 2 on a line. - my($file,$line,$fcnt); - my(@files) = qw{ $(MAKEFILE) $(MAKEFILE)_old }; + my($file,$fcnt); + my(@files) = values %{$self->{PM}}; + push @files, qw{ $(FIRST_MAKEFILE) $(MAKEFILE_OLD) }; if ($self->has_link_code) { push(@files,qw{ $(INST_DYNAMIC) $(INST_STATIC) $(INST_BOOT) $(OBJECT) }); } - push(@files, values %{$self->{PM}}); - $line = ''; #avoid unitialized var warning + # Occasionally files are repeated several times from different sources { my(%f) = map { ($_,1) } @files; @files = keys %f; } + + my $line = ''; foreach $file (@files) { - $file = $self->fixpath($file); if (length($line) + length($file) > 80 || ++$fcnt >= 2) { push @m, "\t\$(RM_F) $line\n"; $line = "$file"; @@ -1569,32 +1363,32 @@ realclean :: clean join('', @m); } +=item zipfile_target (o) -=item dist_core (override) +=item tarfile_target (o) -Syntax for invoking F<VMS_Share> differs from that for Unix F<shar>, -so C<shdist> target actions are VMS-specific. +=item shdist_target (o) -=cut - -sub dist_core { - my($self) = @_; -q[ -dist : $(DIST_DEFAULT) - $(NOECHO) $(PERL) -le "print 'Warning: $m older than $vf' if -e ($vf = '$(VERSION_FROM)') && -M $vf < -M ($m = '$(MAKEFILE)')" +Syntax for invoking shar, tar and zip differs from that for Unix. -zipdist : $(DISTVNAME).zip - $(NOECHO) $(NOOP) +=cut -tardist : $(DISTVNAME).tar$(SUFFIX) - $(NOECHO) $(NOOP) +sub zipfile_target { + my($self) = shift; + return <<'MAKE_FRAG'; $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) "$(ZIPFLAGS)" $(MMS$TARGET) [.$(DISTVNAME)...]*.*; $(RM_RF) $(DISTVNAME) $(POSTOP) +MAKE_FRAG +} + +sub tarfile_target { + my($self) = shift; + return <<'MAKE_FRAG'; $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) @@ -1602,13 +1396,19 @@ $(DISTVNAME).tar$(SUFFIX) : distdir $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(POSTOP) +MAKE_FRAG +} +sub shdist_target { + my($self) = shift; + + return <<'MAKE_FRAG'; shdist : distdir $(PREOP) - $(SHAR) [.$(DISTVNAME...]*.*; $(DISTVNAME).share + $(SHAR) [.$(DISTVNAME)...]*.*; $(DISTVNAME).share $(RM_RF) $(DISTVNAME) $(POSTOP) -]; +MAKE_FRAG } =item dist_test (override) @@ -1642,18 +1442,18 @@ VMS-style command line quoting in a few cases. sub install { my($self, %attribs) = @_; - my(@m,@docfiles); + my(@m,@exe_files); if ($self->{EXE_FILES}) { my($line,$file) = ('',''); foreach $file (@{$self->{EXE_FILES}}) { $line .= "$file "; if (length($line) > 128) { - push(@docfiles,qq[\t\$(NOECHO) \$(PERL) -e "print '$line'" >>.MM_tmp\n]); + push(@exe_files,qq[\t\$(NOECHO) \$(ECHO) "$line" >>.MM_tmp\n]); $line = ''; } } - push(@docfiles,qq[\t\$(NOECHO) \$(PERL) -e "print '$line'" >>.MM_tmp\n]) if $line; + push(@exe_files,qq[\t\$(NOECHO) \$(ECHO) "$line" >>.MM_tmp\n]) if $line; } push @m, q[ @@ -1670,77 +1470,82 @@ pure_install :: pure_$(INSTALLDIRS)_install $(NOECHO) $(NOOP) doc_install :: doc_$(INSTALLDIRS)_install - $(NOECHO) $(SAY) "Appending installation info to $(INSTALLARCHLIB)perllocal.pod" + $(NOECHO) $(NOOP) pure__install : pure_site_install - $(NOECHO) $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site" + $(NOECHO) $(ECHO) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site" doc__install : doc_site_install - $(NOECHO) $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site" + $(NOECHO) $(ECHO) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site" # This hack brought to you by DCL's 255-character command line limit pure_perl_install :: $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'read '.File::Spec->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').' '" >.MM_tmp - $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'write '.File::Spec->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').' '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_LIB) $(INSTALLPRIVLIB) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLARCHLIB) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_BIN) $(INSTALLBIN) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_SCRIPT) $(INSTALLSCRIPT) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLMAN1DIR) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLMAN3DIR) '" >>.MM_tmp - $(MOD_INSTALL) <.MM_tmp - $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp; - $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].File::Spec->catfile($self->{SITEARCHEXP},'auto',$self->{FULLEXT},'.packlist').q[ + $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'write '.File::Spec->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').' '" >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_LIB) $(DESTINSTALLPRIVLIB) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_ARCHLIB) $(DESTINSTALLARCHLIB) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_BIN) $(DESTINSTALLBIN) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_SCRIPT) $(DESTINSTALLSCRIPT) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) " >>.MM_tmp + $(NOECHO) $(MOD_INSTALL) <.MM_tmp + $(NOECHO) $(RM_F) .MM_tmp + $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].$self->catfile($self->{SITEARCHEXP},'auto',$self->{FULLEXT},'.packlist').q[ # Likewise pure_site_install :: $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'read '.File::Spec->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').' '" >.MM_tmp - $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'write '.File::Spec->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').' '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_LIB) $(INSTALLSITELIB) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLSITEARCH) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_BIN) $(INSTALLSITEBIN) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_SCRIPT) $(INSTALLSCRIPT) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLSITEMAN1DIR) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLSITEMAN3DIR) '" >>.MM_tmp - $(MOD_INSTALL) <.MM_tmp - $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp; - $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].File::Spec->catfile($self->{PERL_ARCHLIB},'auto',$self->{FULLEXT},'.packlist').q[ + $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'write '.File::Spec->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').' '" >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_LIB) $(DESTINSTALLSITELIB) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_ARCHLIB) $(DESTINSTALLSITEARCH) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_BIN) $(DESTINSTALLSITEBIN) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_SCRIPT) $(DESTINSTALLSCRIPT) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) " >>.MM_tmp + $(NOECHO) $(MOD_INSTALL) <.MM_tmp + $(NOECHO) $(RM_F) .MM_tmp + $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].$self->catfile($self->{PERL_ARCHLIB},'auto',$self->{FULLEXT},'.packlist').q[ pure_vendor_install :: - $(NOECHO) $(PERL) -e "print '$(INST_LIB) $(INSTALLVENDORLIB) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLVENDORARCH) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_BIN) $(INSTALLVENDORBIN) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_SCRIPT) $(INSTALLSCRIPT) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLVENDORMAN1DIR) '" >>.MM_tmp - $(NOECHO) $(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLVENDORMAN3DIR) '" >>.MM_tmp - $(MOD_INSTALL) <.MM_tmp - $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp; + $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'read '.File::Spec->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').' '" >.MM_tmp + $(NOECHO) $(PERLRUN) "-MFile::Spec" -e "print 'write '.File::Spec->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').' '" >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_LIB) $(DESTINSTALLVENDORLIB) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_BIN) $(DESTINSTALLVENDORBIN) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_SCRIPT) $(DESTINSTALLSCRIPT) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) " >>.MM_tmp + $(NOECHO) $(ECHO_N) "$(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) " >>.MM_tmp + $(NOECHO) $(MOD_INSTALL) <.MM_tmp + $(NOECHO) $(RM_F) .MM_tmp # Ditto doc_perl_install :: - $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLPRIVLIB)|'" >.MM_tmp - $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES)|'" >>.MM_tmp -],@docfiles, -q% $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp - $(NOECHO) $(PERL) -e "print q[print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp - $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp - $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp - $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.File::Spec->catfile($self->{INSTALLARCHLIB},'perllocal.pod').q[ - $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;,.MM2_tmp; + $(NOECHO) $(ECHO) "Appending installation info to ].$self->catfile($self->{DESTINSTALLARCHLIB}, 'perllocal.pod').q[" + $(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + $(NOECHO) $(ECHO_N) "installed into|$(INSTALLPRIVLIB)|" >.MM_tmp + $(NOECHO) $(ECHO_N) "LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES) " >>.MM_tmp +],@exe_files, +q[ $(NOECHO) $(DOC_INSTALL) "Module" "$(NAME)" <.MM_tmp >>].$self->catfile($self->{DESTINSTALLARCHLIB},'perllocal.pod').q[ + $(NOECHO) $(RM_F) .MM_tmp # And again doc_site_install :: - $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLSITELIB)|'" >.MM_tmp - $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES)|'" >>.MM_tmp -],@docfiles, -q% $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp - $(NOECHO) $(PERL) -e "print q[print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp - $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp - $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp - $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.File::Spec->catfile($self->{INSTALLARCHLIB},'perllocal.pod').q[ - $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;,.MM2_tmp; + $(NOECHO) $(ECHO) "Appending installation info to ].$self->catfile($self->{DESTINSTALLARCHLIB}, 'perllocal.pod').q[" + $(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + $(NOECHO) $(ECHO_N) "installed into|$(INSTALLSITELIB)|" >.MM_tmp + $(NOECHO) $(ECHO_N) "LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES) " >>.MM_tmp +],@exe_files, +q[ $(NOECHO) $(DOC_INSTALL) "Module" "$(NAME)" <.MM_tmp >>].$self->catfile($self->{DESTINSTALLARCHLIB},'perllocal.pod').q[ + $(NOECHO) $(RM_F) .MM_tmp doc_vendor_install :: + $(NOECHO) $(ECHO) "Appending installation info to ].$self->catfile($self->{DESTINSTALLARCHLIB}, 'perllocal.pod').q[" + $(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + $(NOECHO) $(ECHO_N) "installed into|$(INSTALLVENDORLIB)|" >.MM_tmp + $(NOECHO) $(ECHO_N) "LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES) " >>.MM_tmp +],@exe_files, +q[ $(NOECHO) $(DOC_INSTALL) "Module" "$(NAME)" <.MM_tmp >>].$self->catfile($self->{DESTINSTALLARCHLIB},'perllocal.pod').q[ + $(NOECHO) $(RM_F) .MM_tmp ]; @@ -1749,16 +1554,16 @@ uninstall :: uninstall_from_$(INSTALLDIRS)dirs $(NOECHO) $(NOOP) uninstall_from_perldirs :: - $(NOECHO) $(UNINSTALL) ].File::Spec->catfile($self->{PERL_ARCHLIB},'auto',$self->{FULLEXT},'.packlist').q[ - $(NOECHO) $(SAY) "Uninstall is now deprecated and makes no actual changes." - $(NOECHO) $(SAY) "Please check the list above carefully for errors, and manually remove" - $(NOECHO) $(SAY) "the appropriate files. Sorry for the inconvenience." + $(NOECHO) $(UNINSTALL) ].$self->catfile($self->{PERL_ARCHLIB},'auto',$self->{FULLEXT},'.packlist').q[ + $(NOECHO) $(ECHO) "Uninstall is now deprecated and makes no actual changes." + $(NOECHO) $(ECHO) "Please check the list above carefully for errors, and manually remove" + $(NOECHO) $(ECHO) "the appropriate files. Sorry for the inconvenience." uninstall_from_sitedirs :: - $(NOECHO) $(UNINSTALL) ],File::Spec->catfile($self->{SITEARCHEXP},'auto',$self->{FULLEXT},'.packlist'),"\n",q[ - $(NOECHO) $(SAY) "Uninstall is now deprecated and makes no actual changes." - $(NOECHO) $(SAY) "Please check the list above carefully for errors, and manually remove" - $(NOECHO) $(SAY) "the appropriate files. Sorry for the inconvenience." + $(NOECHO) $(UNINSTALL) ].$self->catfile($self->{SITEARCHEXP},'auto',$self->{FULLEXT},'.packlist').q[ + $(NOECHO) $(ECHO) "Uninstall is now deprecated and makes no actual changes." + $(NOECHO) $(ECHO) "Please check the list above carefully for errors, and manually remove" + $(NOECHO) $(ECHO) "the appropriate files. Sorry for the inconvenience." ]; join('',@m); @@ -1780,24 +1585,24 @@ sub perldepend { $(OBJECT) : $(PERL_INC)EXTERN.h, $(PERL_INC)INTERN.h, $(PERL_INC)XSUB.h $(OBJECT) : $(PERL_INC)av.h, $(PERL_INC)cc_runtime.h, $(PERL_INC)config.h $(OBJECT) : $(PERL_INC)cop.h, $(PERL_INC)cv.h, $(PERL_INC)embed.h -$(OBJECT) : $(PERL_INC)embedvar.h, $(PERL_INC)fakethr.h, $(PERL_INC)form.h +$(OBJECT) : $(PERL_INC)embedvar.h, $(PERL_INC)form.h $(OBJECT) : $(PERL_INC)gv.h, $(PERL_INC)handy.h, $(PERL_INC)hv.h $(OBJECT) : $(PERL_INC)intrpvar.h, $(PERL_INC)iperlsys.h, $(PERL_INC)keywords.h $(OBJECT) : $(PERL_INC)mg.h, $(PERL_INC)nostdio.h, $(PERL_INC)op.h -$(OBJECT) : $(PERL_INC)opcode.h, $(PERL_INC)opnames.h, $(PERL_INC)patchlevel.h -$(OBJECT) : $(PERL_INC)perl.h, $(PERL_INC)perlapi.h, $(PERL_INC)perlio.h -$(OBJECT) : $(PERL_INC)perlsdio.h, $(PERL_INC)perlsfio.h, $(PERL_INC)perlvars.h +$(OBJECT) : $(PERL_INC)opcode.h, $(PERL_INC)patchlevel.h +$(OBJECT) : $(PERL_INC)perl.h, $(PERL_INC)perlio.h +$(OBJECT) : $(PERL_INC)perlsdio.h, $(PERL_INC)perlvars.h $(OBJECT) : $(PERL_INC)perly.h, $(PERL_INC)pp.h, $(PERL_INC)pp_proto.h $(OBJECT) : $(PERL_INC)proto.h, $(PERL_INC)regcomp.h, $(PERL_INC)regexp.h $(OBJECT) : $(PERL_INC)regnodes.h, $(PERL_INC)scope.h, $(PERL_INC)sv.h -$(OBJECT) : $(PERL_INC)thrdvar.h, $(PERL_INC)thread.h, $(PERL_INC)utf8.h -$(OBJECT) : $(PERL_INC)util.h, $(PERL_INC)vmsish.h, $(PERL_INC)warnings.h +$(OBJECT) : $(PERL_INC)thrdvar.h, $(PERL_INC)thread.h +$(OBJECT) : $(PERL_INC)util.h, $(PERL_INC)vmsish.h ' if $self->{OBJECT}; if ($self->{PERL_SRC}) { my(@macros); - my($mmsquals) = '$(USEMAKEFILE)[.vms]$(MAKEFILE)'; + my($mmsquals) = '$(USEMAKEFILE)[.vms]$(FIRST_MAKEFILE)'; push(@macros,'__AXP__=1') if $Config{'archname'} eq 'VMS_AXP'; push(@macros,'DECC=1') if $Config{'vms_cc_type'} eq 'decc'; push(@macros,'GNUC=1') if $Config{'vms_cc_type'} eq 'gcc'; @@ -1850,16 +1655,16 @@ $(OBJECT) : $(FIRST_MAKEFILE) ] if $self->{OBJECT}; push @m,q[ -# We take a very conservative approach here, but it\'s worth it. -# We move $(MAKEFILE) to $(MAKEFILE)_old here to avoid gnu make looping. -$(MAKEFILE) : Makefile.PL $(CONFIGDEP) - $(NOECHO) $(SAY) "$(MAKEFILE) out-of-date with respect to $(MMS$SOURCE_LIST)" - $(NOECHO) $(SAY) "Cleaning current config before rebuilding $(MAKEFILE) ..." - - $(MV) $(MAKEFILE) $(MAKEFILE)_old - - $(MMS)$(MMSQUALIFIERS) $(USEMAKEFILE)$(MAKEFILE)_old clean +# We take a very conservative approach here, but it's worth it. +# We move $(FIRST_MAKEFILE) to $(MAKEFILE_OLD) here to avoid gnu make looping. +$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) + $(NOECHO) $(ECHO) "$(FIRST_MAKEFILE) out-of-date with respect to $(MMS$SOURCE_LIST)" + $(NOECHO) $(ECHO) "Cleaning current config before rebuilding $(FIRST_MAKEFILE) ..." + - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + - $(MMS)$(MMSQUALIFIERS) $(USEMAKEFILE)$(MAKEFILE_OLD) clean $(PERLRUN) Makefile.PL ],join(' ',map(qq["$_"],@ARGV)),q[ - $(NOECHO) $(SAY) "$(MAKEFILE) has been rebuilt." - $(NOECHO) $(SAY) "Please run $(MMS) to build the extension." + $(NOECHO) $(ECHO) "$(FIRST_MAKEFILE) has been rebuilt." + $(NOECHO) $(ECHO) "Please run $(MMS) to build the extension." ]; join('',@m); @@ -1899,10 +1704,10 @@ testdb :: testdb_\$(LINKTYPE) "; foreach(@{$self->{DIR}}){ my($vmsdir) = $self->fixpath($_,1); - push(@m, ' If F$Search("',$vmsdir,'$(MAKEFILE)").nes."" Then $(PERL) -e "chdir ',"'$vmsdir'", + push(@m, ' If F$Search("',$vmsdir,'$(FIRST_MAKEFILE)").nes."" Then $(PERL) -e "chdir ',"'$vmsdir'", '; print `$(MMS)$(MMSQUALIFIERS) $(PASTHRU2) test`'."\n"); } - push(@m, "\t\$(NOECHO) \$(SAY) \"No tests defined for \$(NAME) extension.\"\n") + push(@m, "\t\$(NOECHO) \$(ECHO) \"No tests defined for \$(NAME) extension.\"\n") unless $tests or -f "test.pl" or @{$self->{DIR}}; push(@m, "\n"); @@ -1949,7 +1754,7 @@ use vars qw(%olbs); sub makeaperl { my($self, %attribs) = @_; - my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = + my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmpdir, $libperl) = @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)}; my(@m); push @m, " @@ -1963,10 +1768,10 @@ MAP_TARGET = $target unless ($self->{MAKEAPERL}) { push @m, q{ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) - $(NOECHO) $(SAY) "Writing ""$(MMS$TARGET)"" for this $(MAP_TARGET)" + $(NOECHO) $(ECHO) "Writing ""$(MMS$TARGET)"" for this $(MAP_TARGET)" $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR=}, $dir, q{ \ - MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ + FIRST_MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 }; push @m, map(q[ \\\n\t\t"$_"], @ARGV),q{ @@ -2091,23 +1896,23 @@ $(MAP_TARGET) :: $(MAKE_APERL_FILE) $shrtarget =~ s/^([^.]*)/$1Shr/; $shrtarget = $targdir . $shrtarget; $target = "Perlshr.$Config{'dlext'}" unless $target; - $tmp = "[]" unless $tmp; - $tmp = $self->fixpath($tmp,1); + $tmpdir = "[]" unless $tmpdir; + $tmpdir = $self->fixpath($tmpdir,1); if (@optlibs) { $extralist = join(' ',@optlibs); } else { $extralist = ''; } # Let ExtUtils::Liblist find the necessary libs for us (but skip PerlShr) # that's what we're building here). push @optlibs, grep { !/PerlShr/i } split ' ', +($self->ext())[2]; if ($libperl) { - unless (-f $libperl || -f ($libperl = File::Spec->catfile($Config{'installarchlib'},'CORE',$libperl))) { + unless (-f $libperl || -f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',$libperl))) { print STDOUT "Warning: $libperl not found\n"; undef $libperl; } } unless ($libperl) { if (defined $self->{PERL_SRC}) { - $libperl = File::Spec->catfile($self->{PERL_SRC},"libperl$self->{LIB_EXT}"); - } elsif (-f ($libperl = File::Spec->catfile($Config{'installarchlib'},'CORE',"libperl$self->{LIB_EXT}")) ) { + $libperl = $self->catfile($self->{PERL_SRC},"libperl$self->{LIB_EXT}"); + } elsif (-f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',"libperl$self->{LIB_EXT}")) ) { } else { print STDOUT "Warning: $libperl not found If you're going to build a static perl binary, make sure perl is installed @@ -2127,41 +1932,44 @@ MAP_LIBPERL = ",$self->fixpath($libperl,0),' '; - push @m,"\n${tmp}Makeaperl.Opt : \$(MAP_EXTRA)\n"; + push @m,"\n${tmpdir}Makeaperl.Opt : \$(MAP_EXTRA)\n"; foreach (@optlibs) { push @m,' $(NOECHO) $(PERL) -e "print q{',$_,'}" >>$(MMS$TARGET)',"\n"; } - push @m,"\n${tmp}PerlShr.Opt :\n\t"; + push @m,"\n${tmpdir}PerlShr.Opt :\n\t"; push @m,'$(NOECHO) $(PERL) -e "print q{$(MAP_SHRTARGET)}" >$(MMS$TARGET)',"\n"; -push @m,' + push @m,' $(MAP_SHRTARGET) : $(MAP_LIBPERL) Makeaperl.Opt ',"${libperldir}Perlshr_Attr.Opt",' $(MAP_LINKCMD)/Shareable=$(MMS$TARGET) $(MAP_LIBPERL), Makeaperl.Opt/Option ',"${libperldir}Perlshr_Attr.Opt/Option",' -$(MAP_TARGET) : $(MAP_SHRTARGET) ',"${tmp}perlmain\$(OBJ_EXT) ${tmp}PerlShr.Opt",' - $(MAP_LINKCMD) ',"${tmp}perlmain\$(OBJ_EXT)",', PerlShr.Opt/Option - $(NOECHO) $(SAY) "To install the new ""$(MAP_TARGET)"" binary, say" - $(NOECHO) $(SAY) " $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKEFILE) inst_perl $(USEMACROS)MAP_TARGET=$(MAP_TARGET)$(ENDMACRO)" - $(NOECHO) $(SAY) "To remove the intermediate files, say - $(NOECHO) $(SAY) " $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKEFILE) map_clean" +$(MAP_TARGET) : $(MAP_SHRTARGET) ',"${tmpdir}perlmain\$(OBJ_EXT) ${tmpdir}PerlShr.Opt",' + $(MAP_LINKCMD) ',"${tmpdir}perlmain\$(OBJ_EXT)",', PerlShr.Opt/Option + $(NOECHO) $(ECHO) "To install the new ""$(MAP_TARGET)"" binary, say" + $(NOECHO) $(ECHO) " $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(FIRST_MAKEFILE) inst_perl $(USEMACROS)MAP_TARGET=$(MAP_TARGET)$(ENDMACRO)" + $(NOECHO) $(ECHO) "To remove the intermediate files, say + $(NOECHO) $(ECHO) " $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(FIRST_MAKEFILE) map_clean" '; - push @m,"\n${tmp}perlmain.c : \$(MAKEFILE)\n\t\$(NOECHO) \$(PERL) -e 1 >${tmp}Writemain.tmp\n"; + push @m,"\n${tmpdir}perlmain.c : \$(FIRST_MAKEFILE)\n\t\$(NOECHO) \$(PERL) -e 1 >${tmpdir}Writemain.tmp\n"; push @m, "# More from the 255-char line length limit\n"; foreach (@staticpkgs) { - push @m,' $(NOECHO) $(PERL) -e "print q{',$_,qq[}" >>${tmp}Writemain.tmp\n]; + push @m,' $(NOECHO) $(PERL) -e "print q{',$_,qq[}" >>${tmpdir}Writemain.tmp\n]; } - push @m,' - $(NOECHO) $(PERL) $(MAP_PERLINC) -ane "use ExtUtils::Miniperl; writemain(@F)" ',$tmp,'Writemain.tmp >$(MMS$TARGET) - $(NOECHO) $(RM_F) ',"${tmp}Writemain.tmp\n"; + + push @m, sprintf <<'MAKE_FRAG', $tmpdir, $tmpdir; + $(NOECHO) $(PERL) $(MAP_PERLINC) -ane "use ExtUtils::Miniperl; writemain(@F)" %sWritemain.tmp >$(MMS$TARGET) + $(NOECHO) $(RM_F) %sWritemain.tmp +MAKE_FRAG push @m, q[ # Still more from the 255-char line length limit doc_inst_perl : - $(NOECHO) $(PERL) -e "print 'Perl binary $(MAP_TARGET)|'" >.MM_tmp - $(NOECHO) $(PERL) -e "print 'MAP_STATIC|$(MAP_STATIC)|'" >>.MM_tmp - $(NOECHO) $(PERL) -pl040 -e " " ].File::Spec->catfile('$(INST_ARCHAUTODIR)','extralibs.all'),q[ >>.MM_tmp - $(NOECHO) $(PERL) -e "print 'MAP_LIBPERL|$(MAP_LIBPERL)|'" >>.MM_tmp - $(DOC_INSTALL) <.MM_tmp >>].File::Spec->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[ - $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp; + $(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + $(NOECHO) $(ECHO) "Perl binary $(MAP_TARGET)|" >.MM_tmp + $(NOECHO) $(ECHO) "MAP_STATIC|$(MAP_STATIC)|" >>.MM_tmp + $(NOECHO) $(PERL) -pl040 -e " " ].$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'),q[ >>.MM_tmp + $(NOECHO) $(ECHO) -e "MAP_LIBPERL|$(MAP_LIBPERL)|" >>.MM_tmp + $(NOECHO) $(DOC_INSTALL) <.MM_tmp >>].$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q[ + $(NOECHO) $(RM_F) .MM_tmp ]; push @m, " @@ -2176,8 +1984,8 @@ clean :: map_clean \$(NOECHO) \$(NOOP) map_clean : - \$(RM_F) ${tmp}perlmain\$(OBJ_EXT) ${tmp}perlmain.c \$(MAKEFILE) - \$(RM_F) ${tmp}Makeaperl.Opt ${tmp}PerlShr.Opt \$(MAP_TARGET) + \$(RM_F) ${tmpdir}perlmain\$(OBJ_EXT) ${tmpdir}perlmain.c \$(FIRST_MAKEFILE) + \$(RM_F) ${tmpdir}Makeaperl.Opt ${tmpdir}PerlShr.Opt \$(MAP_TARGET) "; join '', @m; @@ -2219,12 +2027,19 @@ used instead. sub prefixify { my($self, $var, $sprefix, $rprefix, $default) = @_; + + # Translate $(PERLPREFIX) to a real path. + $rprefix = $self->eliminate_macros($rprefix); + $rprefix = VMS::Filespec::vmspath($rprefix) if $rprefix; + $sprefix = VMS::Filespec::vmspath($sprefix) if $sprefix; + $default = VMS::Filespec::vmsify($default) unless $default =~ /\[.*\]/; (my $var_no_install = $var) =~ s/^install//; - my $path = $self->{uc $var} || $Config{lc $var} || - $Config{lc $var_no_install}; + my $path = $self->{uc $var} || + $ExtUtils::MM_Unix::Config_Override{lc $var} || + $Config{lc $var} || $Config{lc $var_no_install}; if( !$path ) { print STDERR " no Config found for $var.\n" if $Verbose >= 2; @@ -2238,7 +2053,7 @@ sub prefixify { print STDERR " prefixify $var => $path\n" if $Verbose >= 2; print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2; - my($path_vol, $path_dirs) = File::Spec->splitpath( $path ); + my($path_vol, $path_dirs) = $self->splitpath( $path ); if( $path_vol eq $Config{vms_prefix}.':' ) { print STDERR " $Config{vms_prefix}: seen\n" if $Verbose >= 2; @@ -2275,19 +2090,247 @@ sub _prefixify_default { sub _catprefix { my($self, $rprefix, $default) = @_; - my($rvol, $rdirs) = File::Spec->splitpath($rprefix); + my($rvol, $rdirs) = $self->splitpath($rprefix); if( $rvol ) { - return File::Spec->catpath($rvol, - File::Spec->catdir($rdirs, $default), + return $self->catpath($rvol, + $self->catdir($rdirs, $default), '' ) } else { - return File::Spec->catdir($rdirs, $default); + return $self->catdir($rdirs, $default); } } +=item oneliner (o) + +=cut + +sub oneliner { + my($self, $cmd, $switches) = @_; + $switches = [] unless defined $switches; + + # Strip leading and trailing newlines + $cmd =~ s{^\n+}{}; + $cmd =~ s{\n+$}{}; + + $cmd = $self->quote_literal($cmd); + $cmd = $self->escape_newlines($cmd); + + # Switches must be quoted else they will be lowercased. + $switches = join ' ', map { qq{"$_"} } @$switches; + + return qq{\$(PERLRUN) $switches -e $cmd}; +} + + +=item B<echo> (o) + +perl trips up on "<foo>" thinking it's an input redirect. So we use the +native Write command instead. Besides, its faster. + +=cut + +sub echo { + my($self, $text, $file, $appending) = @_; + $appending ||= 0; + + my $opencmd = $appending ? 'Open/Append' : 'Open/Write'; + + my @cmds = ("\$(NOECHO) $opencmd MMECHOFILE $file "); + push @cmds, map { '$(NOECHO) Write MMECHOFILE '.$self->quote_literal($_) } + split /\n/, $text; + push @cmds, '$(NOECHO) Close MMECHOFILE'; + return @cmds; +} + + +=item quote_literal + +=cut + +sub quote_literal { + my($self, $text) = @_; + + # I believe this is all we should need. + $text =~ s{"}{""}g; + + return qq{"$text"}; +} + +=item escape_newlines + +=cut + +sub escape_newlines { + my($self, $text) = @_; + + $text =~ s{\n}{-\n}g; + + return $text; +} + +=item max_exec_len + +256 characters. + +=cut + +sub max_exec_len { + my $self = shift; + + return $self->{_MAX_EXEC_LEN} ||= 256; +} + +=item init_linker (o) + +=cut + +sub init_linker { + my $self = shift; + $self->{EXPORT_LIST} ||= '$(BASEEXT).opt'; + + my $shr = $Config{dbgprefix} . 'PERLSHR'; + if ($self->{PERL_SRC}) { + $self->{PERL_ARCHIVE} ||= + $self->catfile($self->{PERL_SRC}, "$shr.$Config{'dlext'}"); + } + else { + $self->{PERL_ARCHIVE} ||= + $ENV{$shr} ? $ENV{$shr} : "Sys\$Share:$shr.$Config{'dlext'}"; + } + + $self->{PERL_ARCHIVE_AFTER} ||= ''; +} + +=item eliminate_macros + +Expands MM[KS]/Make macros in a text string, using the contents of +identically named elements of C<%$self>, and returns the result +as a file specification in Unix syntax. + +NOTE: This is the canonical version of the method. The version in +File::Spec::VMS is deprecated. + +=cut + +sub eliminate_macros { + my($self,$path) = @_; + return '' unless $path; + $self = {} unless ref $self; + + if ($path =~ /\s/) { + return join ' ', map { $self->eliminate_macros($_) } split /\s+/, $path; + } + + my($npath) = unixify($path); + # sometimes unixify will return a string with an off-by-one trailing null + $npath =~ s{\0$}{}; + + my($complex) = 0; + my($head,$macro,$tail); + + # perform m##g in scalar context so it acts as an iterator + while ($npath =~ m#(.*?)\$\((\S+?)\)(.*)#gs) { + if (defined $self->{$2}) { + ($head,$macro,$tail) = ($1,$2,$3); + if (ref $self->{$macro}) { + if (ref $self->{$macro} eq 'ARRAY') { + $macro = join ' ', @{$self->{$macro}}; + } + else { + print "Note: can't expand macro \$($macro) containing ",ref($self->{$macro}), + "\n\t(using MMK-specific deferred substitutuon; MMS will break)\n"; + $macro = "\cB$macro\cB"; + $complex = 1; + } + } + else { ($macro = unixify($self->{$macro})) =~ s#/\Z(?!\n)##; } + $npath = "$head$macro$tail"; + } + } + if ($complex) { $npath =~ s#\cB(.*?)\cB#\${$1}#gs; } + $npath; +} + +=item fixpath + +Catchall routine to clean up problem MM[SK]/Make macros. Expands macros +in any directory specification, in order to avoid juxtaposing two +VMS-syntax directories when MM[SK] is run. Also expands expressions which +are all macro, so that we can tell how long the expansion is, and avoid +overrunning DCL's command buffer when MM[KS] is running. + +If optional second argument has a TRUE value, then the return string is +a VMS-syntax directory specification, if it is FALSE, the return string +is a VMS-syntax file specification, and if it is not specified, fixpath() +checks to see whether it matches the name of a directory in the current +default directory, and returns a directory or file specification accordingly. + +NOTE: This is the canonical version of the method. The version in +File::Spec::VMS is deprecated. + +=cut + +sub fixpath { + my($self,$path,$force_path) = @_; + return '' unless $path; + $self = bless {} unless ref $self; + my($fixedpath,$prefix,$name); + + if ($path =~ /\s/) { + return join ' ', + map { $self->fixpath($_,$force_path) } + split /\s+/, $path; + } + + if ($path =~ m#^\$\([^\)]+\)\Z(?!\n)#s || $path =~ m#[/:>\]]#) { + if ($force_path or $path =~ /(?:DIR\)|\])\Z(?!\n)/) { + $fixedpath = vmspath($self->eliminate_macros($path)); + } + else { + $fixedpath = vmsify($self->eliminate_macros($path)); + } + } + elsif ((($prefix,$name) = ($path =~ m#^\$\(([^\)]+)\)(.+)#s)) && $self->{$prefix}) { + my($vmspre) = $self->eliminate_macros("\$($prefix)"); + # is it a dir or just a name? + $vmspre = ($vmspre =~ m|/| or $prefix =~ /DIR\Z(?!\n)/) ? vmspath($vmspre) : ''; + $fixedpath = ($vmspre ? $vmspre : $self->{$prefix}) . $name; + $fixedpath = vmspath($fixedpath) if $force_path; + } + else { + $fixedpath = $path; + $fixedpath = vmspath($fixedpath) if $force_path; + } + # No hints, so we try to guess + if (!defined($force_path) and $fixedpath !~ /[:>(.\]]/) { + $fixedpath = vmspath($fixedpath) if -d $fixedpath; + } + + # Trim off root dirname if it's had other dirs inserted in front of it. + $fixedpath =~ s/\.000000([\]>])/$1/; + # Special case for VMS absolute directory specs: these will have had device + # prepended during trip through Unix syntax in eliminate_macros(), since + # Unix syntax has no way to express "absolute from the top of this device's + # directory tree". + if ($path =~ /^[\[>][^.\-]/) { $fixedpath =~ s/^[^\[<]+//; } + + return $fixedpath; +} + + +=item os_flavor + +VMS is VMS. + +=cut + +sub os_flavor { + return('VMS'); +} + =back =cut diff --git a/gnu/usr.bin/perl/lib/ExtUtils/MM_Win32.pm b/gnu/usr.bin/perl/lib/ExtUtils/MM_Win32.pm index 03af82e839f..8fe0b96d955 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/MM_Win32.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/MM_Win32.pm @@ -1,5 +1,7 @@ package ExtUtils::MM_Win32; +use strict; + =head1 NAME @@ -15,8 +17,6 @@ See ExtUtils::MM_Unix for a documentation of the methods provided there. This package overrides the implementation of these methods, not the semantics. -=over 4 - =cut use Config; @@ -24,12 +24,12 @@ use File::Basename; use File::Spec; use ExtUtils::MakeMaker qw( neatvalue ); -use vars qw(@ISA $VERSION $BORLAND $GCC $DMAKE $NMAKE $PERLMAKE); +use vars qw(@ISA $VERSION $BORLAND $GCC $DMAKE $NMAKE); require ExtUtils::MM_Any; require ExtUtils::MM_Unix; @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix ); -$VERSION = '1.05'; +$VERSION = '1.09'; $ENV{EMXSHELL} = 'sh'; # to run `commands` @@ -37,7 +37,15 @@ $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i; $GCC = 1 if $Config{'cc'} =~ /^gcc/i; $DMAKE = 1 if $Config{'make'} =~ /^dmake/i; $NMAKE = 1 if $Config{'make'} =~ /^nmake/i; -$PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i; + + +=head2 Overridden methods + +=over 4 + +=item B<dlsyms> + +=cut sub dlsyms { my($self,%attribs) = @_; @@ -47,7 +55,6 @@ sub dlsyms { my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || []; my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {}; my(@m); - (my $boot = $self->{NAME}) =~ s/:/_/g; if (not $self->{SKIPHASH}{'dynamic'}) { push(@m," @@ -69,12 +76,30 @@ $self->{BASEEXT}.def: Makefile.PL join('',@m); } +=item replace_manpage_separator + +Changes the path separator with . + +=cut + sub replace_manpage_separator { my($self,$man) = @_; $man =~ s,/+,.,g; $man; } + +=item B<maybe_command> + +Since Windows has nothing as simple as an executable bit, we check the +file extension. + +The PATHEXT env variable will be used to get a list of extensions that +might indicate a command, otherwise .com, .exe, .bat and .cmd will be +used by default. + +=cut + sub maybe_command { my($self,$file) = @_; my @e = exists($ENV{'PATHEXT'}) @@ -96,313 +121,185 @@ sub maybe_command { } -sub find_perl { - my($self, $ver, $names, $dirs, $trace) = @_; - $trace ||= 0; +=item B<find_tests> - my($name, $dir); - if ($trace >= 2){ - print "Looking for perl $ver by these names: -@$names -in these dirs: -@$dirs -"; - } - foreach $dir (@$dirs){ - next unless defined $dir; # $self->{PERL_SRC} may be undefined - foreach $name (@$names){ - my ($abs, $val); - if (File::Spec->file_name_is_absolute($name)) { # /foo/bar - $abs = $name; - } elsif (File::Spec->canonpath($name) eq - File::Spec->canonpath(basename($name))) # foo - { - $abs = File::Spec->catfile($dir, $name); - } else { # foo/bar - $abs = File::Spec->canonpath( - File::Spec->catfile(File::Spec->curdir, $name) - ); - } - print "Checking $abs\n" if ($trace >= 2); - next unless $self->maybe_command($abs); - print "Executing $abs\n" if ($trace >= 2); - (my($safe_abs) = $abs) =~ s{(\s)}{\\$1}g; - $val = `$safe_abs -e "require $ver;" 2>&1`; - if ($? == 0) { - print "Using PERL=$abs\n" if $trace; - return $abs; - } elsif ($trace >= 2) { - print "Result: `$val'\n"; - } - } - } - print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n"; - 0; # false and not empty -} +The Win9x shell does not expand globs and I'll play it safe and assume +other Windows variants don't either. +So we do it for them. + +=cut -# This code was taken out of MM_Unix to avoid loading File::Glob -# unless necessary. sub find_tests { return join(' ', <t\\*.t>); } -sub init_others -{ - my ($self) = @_; - $self->SUPER::init_others; - $self->{'TOUCH'} = '$(PERLRUN) -MExtUtils::Command -e touch'; - $self->{'CHMOD'} = '$(PERLRUN) -MExtUtils::Command -e chmod'; - $self->{'CP'} = '$(PERLRUN) -MExtUtils::Command -e cp'; - $self->{'RM_F'} = '$(PERLRUN) -MExtUtils::Command -e rm_f'; - $self->{'RM_RF'} = '$(PERLRUN) -MExtUtils::Command -e rm_rf'; - $self->{'MV'} = '$(PERLRUN) -MExtUtils::Command -e mv'; - $self->{'NOOP'} = 'rem'; - $self->{'TEST_F'} = '$(PERLRUN) -MExtUtils::Command -e test_f'; - $self->{'LD'} = $Config{'ld'} || 'link'; - $self->{'AR'} = $Config{'ar'} || 'lib'; - $self->{'LDLOADLIBS'} ||= $Config{'libs'}; - # -Lfoo must come first for Borland, so we put it in LDDLFLAGS - if ($BORLAND) { - my $libs = $self->{'LDLOADLIBS'}; - my $libpath = ''; - while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) { - $libpath .= ' ' if length $libpath; - $libpath .= $1; - } - $self->{'LDLOADLIBS'} = $libs; - $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'}; - $self->{'LDDLFLAGS'} .= " $libpath"; - } - $self->{'DEV_NULL'} = '> NUL'; +=item B<init_DIRFILESEP> + +Using \ for Windows. + +=cut + +sub init_DIRFILESEP { + my($self) = shift; + + # The ^ makes sure its not interpreted as an escape in nmake + $self->{DIRFILESEP} = $NMAKE ? '^\\' : + $DMAKE ? '\\\\' + : '\\'; } +=item B<init_others> + +Override some of the Unix specific commands with portable +ExtUtils::Command ones. -=item constants (o) +Also provide defaults for LD and AR in case the %Config values aren't +set. -Initializes lots of constants and .SUFFIXES and .PHONY +LDLOADLIBS's default is changed to $Config{libs}. + +Adjustments are made for Borland's quirks needing -L to come first. =cut -sub constants { - my($self) = @_; - my(@m,$tmp); - - for $tmp (qw/ - AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION - VERSION_SYM XS_VERSION - INST_BIN INST_LIB INST_ARCHLIB INST_SCRIPT - INSTALLDIRS - PREFIX SITEPREFIX VENDORPREFIX - INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB - INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH - INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN INSTALLSCRIPT - PERL_LIB PERL_ARCHLIB - SITELIBEXP SITEARCHEXP - LIBPERL_A MYEXTLIB - FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC - PERL_INC PERL FULLPERL PERLRUN FULLPERLRUN PERLRUNINST - FULLPERLRUNINST ABSPERL ABSPERLRUN ABSPERLRUNINST - FULL_AR PERL_CORE - - / ) { - next unless defined $self->{$tmp}; - push @m, "$tmp = $self->{$tmp}\n"; +sub init_others { + my ($self) = @_; + + # Used in favor of echo because echo won't strip quotes. :( + $self->{ECHO} ||= $self->oneliner('print qq{@ARGV}', ['-l']); + $self->{ECHO_N} ||= $self->oneliner('print qq{@ARGV}'); + + $self->{TOUCH} ||= '$(PERLRUN) -MExtUtils::Command -e touch'; + $self->{CHMOD} ||= '$(PERLRUN) -MExtUtils::Command -e chmod'; + $self->{CP} ||= '$(PERLRUN) -MExtUtils::Command -e cp'; + $self->{RM_F} ||= '$(PERLRUN) -MExtUtils::Command -e rm_f'; + $self->{RM_RF} ||= '$(PERLRUN) -MExtUtils::Command -e rm_rf'; + $self->{MV} ||= '$(PERLRUN) -MExtUtils::Command -e mv'; + $self->{NOOP} ||= 'rem'; + $self->{TEST_F} ||= '$(PERLRUN) -MExtUtils::Command -e test_f'; + $self->{DEV_NULL} ||= '> NUL'; + + $self->{LD} ||= $Config{ld} || 'link'; + $self->{AR} ||= $Config{ar} || 'lib'; + + $self->SUPER::init_others; + + # Setting SHELL from $Config{sh} can break dmake. Its ok without it. + delete $self->{SHELL}; + + $self->{LDLOADLIBS} ||= $Config{libs}; + # -Lfoo must come first for Borland, so we put it in LDDLFLAGS + if ($BORLAND) { + my $libs = $self->{LDLOADLIBS}; + my $libpath = ''; + while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) { + $libpath .= ' ' if length $libpath; + $libpath .= $1; + } + $self->{LDLOADLIBS} = $libs; + $self->{LDDLFLAGS} ||= $Config{lddlflags}; + $self->{LDDLFLAGS} .= " $libpath"; } - push @m, qq{ -VERSION_MACRO = VERSION -DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\" -XS_VERSION_MACRO = XS_VERSION -XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\" -}; + return 1; +} - push @m, qq{ -MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'} -MM_VERSION = $ExtUtils::MakeMaker::VERSION -}; - push @m, q{ -# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). -# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) -# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) -# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. -}; +=item init_platform (o) - for $tmp (qw/ - FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT - LDFROM LINKTYPE - / ) { - next unless defined $self->{$tmp}; - push @m, "$tmp = $self->{$tmp}\n"; - } +Add MM_Win32_VERSION. - push @m, " -# Handy lists of source code files: -XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})." -C_FILES = ".join(" \\\n\t", @{$self->{C}})." -O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})." -H_FILES = ".join(" \\\n\t", @{$self->{H}})." -MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})." -MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})." -"; - - for $tmp (qw/ - INST_MAN1DIR MAN1EXT - INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DIR - INST_MAN3DIR MAN3EXT - INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DIR - /) { - next unless defined $self->{$tmp}; - push @m, "$tmp = $self->{$tmp}\n"; - } +=item platform_constants (o) - push @m, qq{ -.USESHELL : -} if $DMAKE; +=cut - push @m, q{ -.NO_CONFIG_REC: Makefile -} if $ENV{CLEARCASE_ROOT}; +sub init_platform { + my($self) = shift; - # why not q{} ? -- emacs - push @m, qq{ -# work around a famous dec-osf make(1) feature(?): -makemakerdflt: all + $self->{MM_Win32_VERSION} = $VERSION; +} -.SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT) +sub platform_constants { + my($self) = shift; + my $make_frag = ''; -# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to -# recall, that some make implementations will delete the Makefile when we -# rebuild it. Because we call false(1) when we rebuild it. So make(1) is -# not completely wrong when it does so. Our milage may vary. -# .PRECIOUS: Makefile # seems to be not necessary anymore + foreach my $macro (qw(MM_Win32_VERSION)) + { + next unless defined $self->{$macro}; + $make_frag .= "$macro = $self->{$macro}\n"; + } -.PHONY: all config static dynamic test linkext manifest + return $make_frag; +} -# Where is the Config information that we are using/depend on -CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h -}; - my @parentdir = split(/::/, $self->{PARENT_NAME}); - push @m, q{ -# Where to put things: -INST_LIBDIR = }. File::Spec->catdir('$(INST_LIB)',@parentdir) .q{ -INST_ARCHLIBDIR = }. File::Spec->catdir('$(INST_ARCHLIB)',@parentdir) .q{ +=item special_targets (o) -INST_AUTODIR = }. File::Spec->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{ -INST_ARCHAUTODIR = }. File::Spec->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{ -}; +Add .USESHELL target for dmake. - if ($self->has_link_code()) { - push @m, ' -INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT) -INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT) -INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs -'; - } else { - push @m, ' -INST_STATIC = -INST_DYNAMIC = -INST_BOOT = -'; - } +=cut - $tmp = $self->export_list; - push @m, " -EXPORT_LIST = $tmp -"; - $tmp = $self->perl_archive; - push @m, " -PERL_ARCHIVE = $tmp -"; +sub special_targets { + my($self) = @_; - push @m, q{ -TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{ + my $make_frag = $self->SUPER::special_targets; -PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ -}; + $make_frag .= <<'MAKE_FRAG' if $DMAKE; +.USESHELL : +MAKE_FRAG - join('',@m); + return $make_frag; } =item static_lib (o) -Defines how to produce the *.a (or equivalent) files. +Changes how to run the linker. + +The rest is duplicate code from MM_Unix. Should move the linker code +to its own method. =cut sub static_lib { my($self) = @_; -# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC -# return '' unless $self->needs_linking(); #might be because of a subdir - return '' unless $self->has_link_code; my(@m); push(@m, <<'END'); -$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists +$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(RM_RF) $@ END + # If this extension has its own library (eg SDBM_File) # then copy that to $(INST_STATIC) and add $(OBJECT) into it. - push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB}; + push @m, <<'MAKE_FRAG' if $self->{MYEXTLIB}; + $(CP) $(MYEXTLIB) $@ +MAKE_FRAG push @m, q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")' : ($GCC ? '-ru $@ $(OBJECT)' : '-out:$@ $(OBJECT)')).q{ - }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld - $(CHMOD) 755 $@ + $(CHMOD) $(PERM_RWX) $@ + $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld }; -# Old mechanism - still available: - - push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n" - if $self->{PERL_SRC}; + # Old mechanism - still available: + push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS}; + $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs +MAKE_FRAG - push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); - join('', "\n",@m); + push @m, "\n", $self->dir_target('$(INST_ARCHAUTODIR)'); + join('', @m); } -=item dynamic_bs (o) - -Defines targets for bootstrap files. - -=cut - -sub dynamic_bs { - my($self, %attribs) = @_; - return ' -BOOTSTRAP = -' unless $self->has_link_code(); - - return ' -BOOTSTRAP = '."$self->{BASEEXT}.bs".' - -# As Mkbootstrap might not write a file (if none is required) -# we use touch to prevent make continually trying to remake it. -# The DynaLoader only reads a non-empty file. -$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)\.exists - '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" - '.$self->{NOECHO}.'$(PERLRUN) \ - -MExtUtils::Mkbootstrap \ - -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');" - '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP) - $(CHMOD) 644 $@ - -$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists - '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT) - -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT) - $(CHMOD) 644 $@ -'; -} =item dynamic_lib (o) -Defines how to produce the *.so (or equivalent) files. +Complicated stuff for Win32 that I don't understand. :( =cut @@ -434,7 +331,7 @@ sub dynamic_lib { OTHERLDFLAGS = '.$otherldflags.' INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' -$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) +$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) '); if ($GCC) { push(@m, @@ -456,13 +353,20 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)}); } push @m, ' - $(CHMOD) 755 $@ + $(CHMOD) $(PERM_RWX) $@ '; push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); join('',@m); } +=item clean + +Clean out some extra dll.{base,exp} files which might be generated by +gcc. Otherwise, take out all *.pdb files. + +=cut + sub clean { my ($self) = shift; @@ -476,309 +380,134 @@ END return $s; } +=item init_linker +=cut -sub perl_archive -{ - my ($self) = @_; - return '$(PERL_INC)\\'.$Config{'libperl'}; -} +sub init_linker { + my $self = shift; -sub export_list -{ - my ($self) = @_; - return "$self->{BASEEXT}.def"; + $self->{PERL_ARCHIVE} = "\$(PERL_INC)\\$Config{libperl}"; + $self->{PERL_ARCHIVE_AFTER} = ''; + $self->{EXPORT_LIST} = '$(BASEEXT).def'; } =item perl_script -Takes one argument, a file name, and returns the file name, if the -argument is likely to be a perl script. On MM_Unix this is true for -any ordinary, readable file. +Checks for the perl program under several common perl extensions. =cut sub perl_script { my($self,$file) = @_; return $file if -r $file && -f _; - return "$file.pl" if -r "$file.pl" && -f _; + return "$file.pl" if -r "$file.pl" && -f _; + return "$file.plx" if -r "$file.plx" && -f _; return "$file.bat" if -r "$file.bat" && -f _; return; } -=item pm_to_blib - -Defines target that copies all files in the hash PM to their -destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION> - -=cut -sub pm_to_blib { - my $self = shift; - my($autodir) = File::Spec->catdir('$(INST_LIB)','auto'); - return q{ -pm_to_blib: $(TO_INST_PM) - }.$self->{NOECHO}.q{$(PERLRUNINST) -MExtUtils::Install \ - -e "pm_to_blib(}. - ($NMAKE ? 'qw[ <<pmfiles.dat ],' - : $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],' - : '{ qw[$(PM_TO_BLIB)] },' - ).q{'}.$autodir.q{','$(PM_FILTER)')" -}. ($NMAKE ? q{ -$(PM_TO_BLIB) -<< - } : '') . "\t".$self->{NOECHO}.q{$(TOUCH) $@ -}; -} - - -=item tool_autosplit (override) +=item xs_o (o) -Use Win32 quoting on command line. +This target is stubbed out. Not sure why. =cut -sub tool_autosplit{ - my($self, %attribs) = @_; - my($asl) = ""; - $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN}; - q{ -# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(PERLRUN) -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);" -}; +sub xs_o { + return '' } -=item tools_other (o) -Win32 overrides. +=item pasthru (o) -Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in -the Makefile. Also defines the perl programs MKPATH, -WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL. +All we send is -nologo to nmake to prevent it from printing its damned +banner. =cut -sub tools_other { +sub pasthru { my($self) = shift; - my @m; - my $bin_sh = $Config{sh} || 'cmd /c'; - push @m, qq{ -SHELL = $bin_sh -} unless $DMAKE; # dmake determines its own shell - - for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) { - push @m, "$_ = $self->{$_}\n"; - } - - push @m, q{ -# The following is a portable way to say mkdir -p -# To see which directories are created, change the if 0 to if 1 -MKPATH = $(PERLRUN) -MExtUtils::Command -e mkpath - -# This helps us to minimize the effect of the .exists files A yet -# better solution would be to have a stable file in the perl -# distribution with a timestamp of zero. But this solution doesn't -# need any changes to the core distribution and works with older perls -EQUALIZE_TIMESTAMP = $(PERLRUN) -MExtUtils::Command -e eqtime -}; - - - return join "", @m if $self->{PARENT}; - - push @m, q{ -# Here we warn users that an old packlist file was found somewhere, -# and that they should call some uninstall routine -WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\ --e "print 'WARNING: I have found an old package in';" \\ --e "print ' ', $$ARGV[0], '.';" \\ --e "print 'Please make sure the two installations are not conflicting';" - -UNINST=0 -VERBINST=1 - -MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \ --e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');" - -DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \ --e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', $$arg=shift, '|', $$arg, '>';" \ --e "print '=over 4';" \ --e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \ --e "print '=back';" - -UNINSTALL = $(PERL) -MExtUtils::Install \ --e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \ --e "print \" packlist above carefully.\n There may be errors. Remove the\";" \ --e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\"" -}; - - return join "", @m; + return "PASTHRU = " . ($NMAKE ? "-nologo" : ""); } -=item xs_o (o) -Defines suffix rules to go from XS to object files directly. This is -only intended for broken make implementations. +=item oneliner (o) -=cut - -sub xs_o { # many makes are too dumb to use xs_c then c_o - my($self) = shift; - return '' -} - -=item top_targets (o) - -Defines the targets all, subdirs, config, and O_FILES +These are based on what command.com does on Win98. They may be wrong +for other Windows shells, I don't know. =cut -sub top_targets { -# --- Target Sections --- +sub oneliner { + my($self, $cmd, $switches) = @_; + $switches = [] unless defined $switches; - my($self) = shift; - my(@m); - - push @m, ' -all :: pure_all manifypods - '.$self->{NOECHO}.'$(NOOP) -' - unless $self->{SKIPHASH}{'all'}; - - push @m, ' -pure_all :: config pm_to_blib subdirs linkext - '.$self->{NOECHO}.'$(NOOP) + # Strip leading and trailing newlines + $cmd =~ s{^\n+}{}; + $cmd =~ s{\n+$}{}; -subdirs :: $(MYEXTLIB) - '.$self->{NOECHO}.'$(NOOP) + $cmd = $self->quote_literal($cmd); + $cmd = $self->escape_newlines($cmd); -config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)\.exists - '.$self->{NOECHO}.'$(NOOP) + $switches = join ' ', @$switches; -config :: $(INST_ARCHAUTODIR)\.exists - '.$self->{NOECHO}.'$(NOOP) + return qq{\$(PERLRUN) $switches -e $cmd}; +} -config :: $(INST_AUTODIR)\.exists - '.$self->{NOECHO}.'$(NOOP) -'; - push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); +sub quote_literal { + my($self, $text) = @_; - if (%{$self->{MAN1PODS}}) { - push @m, qq[ -config :: \$(INST_MAN1DIR)\\.exists - $self->{NOECHO}\$(NOOP) + # I don't know if this is correct, but it seems to work on + # Win98's command.com + $text =~ s{"}{\\"}g; -]; - push @m, $self->dir_target(qw[$(INST_MAN1DIR)]); + # dmake eats '{' inside double quotes and leaves alone { outside double + # quotes; however it transforms {{ into { either inside and outside double + # quotes. It also translates }} into }. The escaping below is not + # 100% correct. + if( $DMAKE ) { + $text =~ s/{/{{/g; + $text =~ s/}}/}}}/g; } - if (%{$self->{MAN3PODS}}) { - push @m, qq[ -config :: \$(INST_MAN3DIR)\\.exists - $self->{NOECHO}\$(NOOP) -]; - push @m, $self->dir_target(qw[$(INST_MAN3DIR)]); - } - - push @m, ' -$(O_FILES): $(H_FILES) -' if @{$self->{O_FILES} || []} && @{$self->{H} || []}; - - push @m, q{ -help: - perldoc ExtUtils::MakeMaker -}; - - join('',@m); + return qq{"$text"}; } -=item manifypods (o) -We don't want manpage process. +sub escape_newlines { + my($self, $text) = @_; -=cut + # Escape newlines + $text =~ s{\n}{\\\n}g; -sub manifypods { - my($self) = shift; - return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n"; + return $text; } -=item dist_ci (o) - -Same as MM_Unix version (changes command-line quoting). - -=cut - -sub dist_ci { - my($self) = shift; - my @m; - push @m, q{ -ci : - $(PERLRUN) -MExtUtils::Manifest=maniread \\ - -e "@all = keys %{ maniread() };" \\ - -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\ - -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");" -}; - join "", @m; -} -=item dist_core (o) +=item max_exec_len -Same as MM_Unix version (changes command-line quoting). +nmake 1.50 limits command length to 2048 characters. =cut -sub dist_core { - my($self) = shift; - my @m; - push @m, q{ -dist : $(DIST_DEFAULT) - }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \ - -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";" - -tardist : $(DISTVNAME).tar$(SUFFIX) - -zipdist : $(DISTVNAME).zip - -$(DISTVNAME).tar$(SUFFIX) : distdir - $(PREOP) - $(TO_UNIX) - $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) - $(RM_RF) $(DISTVNAME) - $(COMPRESS) $(DISTVNAME).tar - $(POSTOP) - -$(DISTVNAME).zip : distdir - $(PREOP) - $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) - $(RM_RF) $(DISTVNAME) - $(POSTOP) - -uutardist : $(DISTVNAME).tar$(SUFFIX) - uuencode $(DISTVNAME).tar$(SUFFIX) \\ - $(DISTVNAME).tar$(SUFFIX) > \\ - $(DISTVNAME).tar$(SUFFIX)_uu - -shdist : distdir - $(PREOP) - $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar - $(RM_RF) $(DISTVNAME) - $(POSTOP) -}; - join "", @m; +sub max_exec_len { + my $self = shift; + + return $self->{_MAX_EXEC_LEN} ||= 2 * 1024; } -=item pasthru (o) -Defines the string that is passed to recursive make calls in -subdirectories. +=item os_flavor + +Windows is Win32. =cut -sub pasthru { - my($self) = shift; - return "PASTHRU = " . ($NMAKE ? "-nologo" : ""); +sub os_flavor { + return('Win32'); } diff --git a/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker.pm b/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker.pm index 94267570b74..ad850de27eb 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker.pm @@ -2,21 +2,20 @@ package ExtUtils::MakeMaker; BEGIN {require 5.005_03;} -$VERSION = "6.03"; -$Version_OK = "5.49"; # Makefiles older than $Version_OK will die - # (Will be checked from MakeMaker version 4.13 onwards) -($Revision = substr(q$Revision: 1.6 $, 10)) =~ s/\s+$//; +$VERSION = '6.17'; +($Revision) = q$Revision: 1.7 $ =~ /Revision:\s+(\S+)/; require Exporter; use Config; use Carp (); +use File::Path; use vars qw( @ISA @EXPORT @EXPORT_OK - $ISA_TTY $Revision $VERSION $Verbose $Version_OK %Config - %Keep_after_flush %MM_Sections @Prepend_parent + $Revision $VERSION $Verbose %Config + @Prepend_parent @Parent %Recognized_Att_Keys @Get_from_Config @MM_Sections @Overridable - @Parent $PACKNAME + $Filename ); use strict; @@ -29,6 +28,10 @@ use strict; 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 @@ -57,109 +60,31 @@ sub WriteMakefile { # Basic signatures of the attributes WriteMakefile takes. Each is the # reference type. Empty value indicate it takes a non-reference # scalar. -my %Att_Sigs = -( - ABSTRACT => '', - ABSTRACT_FROM => '', - AUTHOR => '', - BINARY_LOCATION => '', +my %Att_Sigs; +my %Special_Sigs = ( C => 'array', - CCFLAGS => '', CONFIG => 'array', CONFIGURE => 'code', - DEFINE => '', DIR => 'array', - DISTNAME => '', DL_FUNCS => 'hash', DL_VARS => 'array', EXCLUDE_EXT => 'array', EXE_FILES => 'array', - FIRST_MAKEFILE => '', - FULLPERL => '', - FULLPERLRUN => '', - FULLPERLRUNINST => '', FUNCLIST => 'array', H => 'array', IMPORTS => 'hash', - INC => '', INCLUDE_EXT => 'array', - INSTALLARCHLIB => '', - INSTALLBIN => '', - INSTALLDIRS => '', - INSTALLMAN1DIR => '', - INSTALLMAN3DIR => '', - INSTALLPRIVLIB => '', - INSTALLSCRIPT => '', - INSTALLSITEARCH => '', - INSTALLSITEBIN => '', - INSTALLSITELIB => '', - INSTALLSITEMAN1DIR => '', - INSTALLSITEMAN3DIR => '', - INSTALLVENDORARCH => '', - INSTALLVENDORBIN => '', - INSTALLVENDORLIB => '', - INSTALLVENDORMAN1DIR => '', - INSTALLVENDORMAN3DIR => '', - INST_ARCHLIB => '', - INST_BIN => '', - INST_LIB => '', - INST_MAN1DIR => '', - INST_MAN3DIR => '', - INST_SCRIPT => '', - _KEEP_AFTER_FLUSH => '', - LDDLFLAGS => '', - LDFROM => '', - LIB => '', - LIBPERL_A => '', LIBS => ['array',''], - LINKTYPE => '', - MAKEAPERL => '', - MAKEFILE => '', MAN1PODS => 'hash', MAN3PODS => 'hash', - MAP_TARGET => '', - MYEXTLIB => '', - NAME => '', - NEEDS_LINKING => '', - NOECHO => '', - NORECURS => '', - NO_VC => '', - OBJECT => '', - OPTIMIZE => '', - PERL => '', - PERL_CORE => '', - PERLMAINCC => '', - PERL_ARCHLIB => '', - PERL_LIB => '', - PERL_MALLOC_OK => '', - PERLRUN => '', - PERLRUNINST => '', - PERL_SRC => '', - PERM_RW => '', - PERM_RWX => '', PL_FILES => 'hash', PM => 'hash', PMLIBDIRS => 'array', - PM_FILTER => '', - POLLUTE => '', - PPM_INSTALL_EXEC => '', - PPM_INSTALL_SCRIPT => '', - PREFIX => '', - PREREQ_FATAL => '', PREREQ_PM => 'hash', - PREREQ_PRINT => '', - PRINT_PREREQ => '', - SITEPREFIX => '', SKIP => 'array', TYPEMAPS => 'array', - VENDORPREFIX => '', - VERBINST => '', - VERSION => '', - VERSION_FROM => '', XS => 'hash', - XSOPT => '', - XSPROTOARG => '', - XS_VERSION => '', + _KEEP_AFTER_FLUSH => '', clean => 'hash', depend => 'hash', @@ -167,11 +92,15 @@ my %Att_Sigs = 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; +@Att_Sigs{keys %Special_Sigs} = values %Special_Sigs; + sub _verify_att { my($att) = @_; @@ -198,17 +127,24 @@ sub _verify_att { } sub prompt ($;$) { - my($mess,$def)=@_; - $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe? + my($mess, $def) = @_; Carp::confess("prompt function called without an argument") unless defined $mess; + + my $isa_tty = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; + my $dispdef = defined $def ? "[$def] " : " "; $def = defined $def ? $def : ""; - my $ans; + local $|=1; local $\; print "$mess $dispdef"; - if ($ISA_TTY && !$ENV{PERL_MM_USE_DEFAULT}) { + + my $ans; + if ($ENV{PERL_MM_USE_DEFAULT} || (!$isa_tty && eof STDIN)) { + print "$def\n"; + } + else { $ans = <STDIN>; if( defined $ans ) { chomp $ans; @@ -217,9 +153,7 @@ sub prompt ($;$) { print "\n"; } } - else { - print "$def\n"; - } + return (!defined $ans || $ans eq '') ? $def : $ans; } @@ -256,22 +190,25 @@ sub eval_in_x { } } + +# package name for the classes into which the first object will be blessed +my $PACKNAME = 'PACK000'; + sub full_setup { $Verbose ||= 0; - # package name for the classes into which the first object will be blessed - $PACKNAME = "PACK000"; - my @attrib_help = qw/ AUTHOR ABSTRACT ABSTRACT_FROM BINARY_LOCATION C CAPI CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DL_FUNCS DL_VARS - EXCLUDE_EXT EXE_FILES FIRST_MAKEFILE + EXCLUDE_EXT EXE_FILES FIRST_MAKEFILE FULLPERL FULLPERLRUN FULLPERLRUNINST FUNCLIST H IMPORTS + INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB INST_MAN1DIR INST_MAN3DIR INSTALLDIRS - PREFIX SITEPREFIX VENDORPREFIX + DESTDIR PREFIX + PERLPREFIX SITEPREFIX VENDORPREFIX INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN @@ -281,17 +218,18 @@ sub full_setup { INSTALLSCRIPT PERL_LIB PERL_ARCHLIB SITELIBEXP SITEARCHEXP + INC INCLUDE_EXT LDFROM LIB LIBPERL_A LIBS - LINKTYPE MAKEAPERL MAKEFILE MAN1PODS MAN3PODS MAP_TARGET MYEXTLIB - PERL_MALLOC_OK - NAME NEEDS_LINKING NOECHO NORECURS NO_VC OBJECT OPTIMIZE PERL PERLMAINCC - PERLRUN PERLRUNINST PERL_CORE + LINKTYPE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET + 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 PL_FILES PM PM_FILTER PMLIBDIRS POLLUTE PPM_INSTALL_EXEC PPM_INSTALL_SCRIPT PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ SKIP 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 MACLIBS_ALL_68K MACLIBS_ALL_PPC MACLIBS_SHARED /; @@ -310,16 +248,24 @@ sub full_setup { @MM_Sections = qw( - post_initialize const_config constants tool_autosplit tool_xsubpp - tools_other dist macro depend cflags const_loadlibs const_cccmd + post_initialize const_config constants platform_constants + tool_autosplit tool_xsubpp tools_other + + makemakerdflt + + dist macro depend cflags const_loadlibs const_cccmd post_constants pasthru - c_o xs_c xs_o top_targets linkext dlsyms dynamic dynamic_bs + special_targets + c_o xs_c xs_o + top_targets linkext dlsyms dynamic dynamic_bs dynamic_lib static static_lib manifypods processPL installbin subdirs - clean realclean dist_basics dist_core dist_dir dist_test dist_ci + clean_subdirs clean realclean_subdirs realclean + metafile metafile_addtomanifest + dist_basics dist_core distdir dist_test dist_ci install force perldepend makefile staticmake test ppd ); # loses section ordering @@ -352,6 +298,9 @@ sub full_setup { exe_ext full_ar ); + # 5.5.3 doesn't have any concept of vendor libs + push @Get_from_Config, qw( vendorarchexp vendorlibexp ) if $] >= 5.006; + foreach my $item (@attrib_help){ $Recognized_Att_Keys{$item} = 1; } @@ -371,11 +320,6 @@ sub full_setup { MAP_TARGET INST_MAN1DIR INST_MAN3DIR PERL_SRC PERL FULLPERL ); - - my @keep = qw/ - NEEDS_LINKING HAS_LINK_CODE - /; - @Keep_after_flush{@keep} = (1) x @keep; } sub writeMakefile { @@ -402,14 +346,21 @@ sub new { my($class,$self) = @_; my($key); + # Store the original args passed to WriteMakefile() + foreach my $k (keys %$self) { + $self->{ARGS}{$k} = $self->{$k}; + } + if ("@ARGV" =~ /\bPREREQ_PRINT\b/) { require Data::Dumper; print Data::Dumper->Dump([$self->{PREREQ_PM}], [qw(PREREQ_PM)]); + exit 0; } # PRINT_PREREQ is RedHatism. if ("@ARGV" =~ /\bPRINT_PREREQ\b/) { - print join(" ", map { "perl($_)>=$self->{PREREQ_PM}->{$_} " } sort keys %{$self->{PREREQ_PM}}), "\n"; + print join(" ", map { "perl($_)>=$self->{PREREQ_PM}->{$_} " } + sort keys %{$self->{PREREQ_PM}}), "\n"; exit 0; } @@ -427,10 +378,15 @@ sub new { my(%unsatisfied) = (); foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) { - eval "require $prereq"; + # 5.8.0 has a bug with require Foo::Bar alone in an eval, so an + # extra statement is a workaround. + eval "require $prereq; 0"; my $pr_version = $prereq->VERSION || 0; + # convert X.Y_Z alpha version #s to X.YZ for easier comparisons + $pr_version =~ s/(\d+)\.(\d+)_(\d+)/$1.$2$3/; + if ($@) { warn sprintf "Warning: prerequisite %s %s not found.\n", $prereq, $self->{PREREQ_PM}{$prereq} @@ -483,8 +439,14 @@ sub new { my $key; for $key (@Prepend_parent) { next unless defined $self->{PARENT}{$key}; + + # Don't stomp on WriteMakefile() args. + next if defined $self->{ARGS}{$key} and + $self->{ARGS}{$key} eq $self->{$key}; + $self->{$key} = $self->{PARENT}{$key}; - unless ($^O eq 'VMS' && $key =~ /PERL$/) { + + unless ($Is_VMS && $key =~ /PERL$/) { $self->{$key} = $self->catdir("..",$self->{$key}) unless $self->file_name_is_absolute($self->{$key}); } else { @@ -520,7 +482,17 @@ sub new { ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g; - $self->init_main(); + $self->init_main; + $self->init_VERSION; + $self->init_dist; + $self->init_INST; + $self->init_INSTALL; + $self->init_DEST; + $self->init_dirscan; + $self->init_xs; + $self->init_PERL; + $self->init_DIRFILESEP; + $self->init_linker; if (! $self->{PERL_SRC} ) { require VMS::Filespec if $Is_VMS; @@ -547,8 +519,8 @@ END } } - $self->init_dirscan(); $self->init_others(); + $self->init_platform(); $self->init_PERM(); my($argv) = neatvalue(\@ARGV); $argv =~ s/^\[/(/; @@ -569,6 +541,8 @@ END END foreach my $key (sort keys %initial_att){ + next if $key eq 'ARGS'; + my($v) = neatvalue($initial_att{$key}); $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/; $v =~ tr/\n/ /s; @@ -583,6 +557,7 @@ END END if (scalar(keys %configure_att) > 0) { foreach my $key (sort keys %configure_att){ + next if $key eq 'ARGS'; my($v) = neatvalue($configure_att{$key}); $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/; $v =~ tr/\n/ /s; @@ -604,7 +579,7 @@ END delete $self->{SKIP}; # free memory if ($self->{PARENT}) { - for (qw/install dist dist_basics dist_core dist_dir dist_test dist_ci/) { + for (qw/install dist dist_basics dist_core distdir dist_test dist_ci/) { $self->{SKIPHASH}{$_} = 1; } } @@ -616,6 +591,10 @@ END } foreach my $section ( @MM_Sections ){ + # Support for new foo_target() methods. + my $method = $section; + $method .= '_target' unless $self->can($method); + print "Processing Makefile '$section' section\n" if ($Verbose >= 2); my($skipit) = $self->skipcheck($section); if ($skipit){ @@ -624,7 +603,7 @@ 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->$section( %a )); + push @{$self->{RESULT}}, $self->nicetext($self->$method( %a )); } } @@ -638,13 +617,14 @@ sub WriteEmptyMakefile { my %att = @_; my $self = MM->new(\%att); - if (-f "$self->{MAKEFILE}.old") { - chmod 0666, "$self->{MAKEFILE}.old"; - unlink "$self->{MAKEFILE}.old" or warn "unlink $self->{MAKEFILE}.old: $!"; + if (-f $self->{MAKEFILE_OLD}) { + _unlink($self->{MAKEFILE_OLD}) or + warn "unlink $self->{MAKEFILE_OLD}: $!"; + } + if ( -f $self->{MAKEFILE} ) { + _rename($self->{MAKEFILE}, $self->{MAKEFILE_OLD}) or + warn "rename $self->{MAKEFILE} => $self->{MAKEFILE_OLD}: $!" } - rename $self->{MAKEFILE}, "$self->{MAKEFILE}.old" - or warn "rename $self->{MAKEFILE} $self->{MAKEFILE}.old: $!" - if -f $self->{MAKEFILE}; open MF, '>'.$self->{MAKEFILE} or die "open $self->{MAKEFILE} for write: $!"; print MF <<'EOP'; all: @@ -681,7 +661,6 @@ sub parse_args{ my($self, @args) = @_; foreach (@args) { unless (m/(.*?)=(.*)/) { - help(),exit 1 if m/^help$/; ++$Verbose if m/^verb/; next; } @@ -693,7 +672,9 @@ sub parse_args{ (getpwuid($>))[7] ]ex; } - $self->{uc($name)} = $value; + + # Remember the original args passed it. It will be useful later. + $self->{ARGS}{uc $name} = $self->{uc $name} = $value; } # catch old-style 'potential_libs' and inform user how to 'upgrade' @@ -738,6 +719,7 @@ sub parse_args{ } foreach my $mmkey (sort keys %$self){ + next if $mmkey eq 'ARGS'; print STDOUT " $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose; print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n" unless exists $Recognized_Att_Keys{$mmkey}; @@ -749,7 +731,11 @@ sub check_hints { my($self) = @_; # We allow extension-specific hints files. - return unless -d "hints"; + require File::Spec; + my $curdir = File::Spec->curdir; + + my $hint_dir = File::Spec->catdir($curdir, "hints"); + return unless -d $hint_dir; # First we look for the best hintsfile we have my($hint)="${^O}_$Config{osvers}"; @@ -759,11 +745,11 @@ sub check_hints { # Also try without trailing minor version numbers. while (1) { - last if -f "hints/$hint.pl"; # found + last if -f File::Spec->catfile($hint_dir, "$hint.pl"); # found } continue { last unless $hint =~ s/_[^_]*$//; # nothing to cut off } - my $hint_file = "hints/$hint.pl"; + my $hint_file = File::Spec->catfile($hint_dir, "$hint.pl"); return unless -f $hint_file; # really there @@ -775,11 +761,16 @@ sub _run_hintfile { local($self) = shift; # make $self available to the hint file. my($hint_file) = shift; - local $@; + local($@, $!); print STDERR "Processing hints file $hint_file\n"; - my $ret = do "./$hint_file"; - unless( defined $ret ) { - print STDERR $@ if $@; + + # Just in case the ./ isn't on the hint file, which File::Spec can + # often strip off, we bung the curdir into @INC + local @INC = (File::Spec->curdir, @INC); + my $ret = do $hint_file; + if( !defined $ret ) { + my $error = $@ || $!; + print STDERR $error; } } @@ -883,18 +874,38 @@ sub flush { close FH; my($finalname) = $self->{MAKEFILE}; - rename("MakeMaker.tmp", $finalname); + _rename("MakeMaker.tmp", $finalname) or + warn "rename MakeMaker.tmp => $finalname: $!"; chmod 0644, $finalname unless $Is_VMS; + my %keep = map { ($_ => 1) } qw(NEEDS_LINKING HAS_LINK_CODE); + if ($self->{PARENT} && !$self->{_KEEP_AFTER_FLUSH}) { foreach (keys %$self) { # safe memory - delete $self->{$_} unless $Keep_after_flush{$_}; + delete $self->{$_} unless $keep{$_}; } } system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":"; } + +# This is a rename for OS's where the target must be unlinked first. +sub _rename { + my($src, $dest) = @_; + chmod 0666, $dest; + unlink $dest; + return rename $src, $dest; +} + +# This is an unlink for OS's where the target must be writable first. +sub _unlink { + my @files = @_; + chmod 0666, @files; + return unlink @files; +} + + # The following mkbootstrap() is only for installations that are calling # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker # writes Makefiles, that use ExtUtils::Mkbootstrap directly. @@ -961,7 +972,7 @@ __END__ =head1 NAME -ExtUtils::MakeMaker - create an extension Makefile +ExtUtils::MakeMaker - Create a module Makefile =head1 SYNOPSIS @@ -986,24 +997,7 @@ Makefiles with a single invocation of WriteMakefile(). =head2 How To Write A Makefile.PL -The short answer is: Don't. - - Always begin with h2xs. - Always begin with h2xs! - ALWAYS BEGIN WITH H2XS! - -even if you're not building around a header file, and even if you -don't have an XS component. - -Run h2xs(1) before you start thinking about writing a module. For so -called pm-only modules that consist of C<*.pm> files only, h2xs has -the C<-X> switch. This will generate dummy files of all kinds that are -useful for the module developer. - -The medium answer is: - - use ExtUtils::MakeMaker; - WriteMakefile( NAME => "Foo::Bar" ); +See ExtUtils::MakeMaker::Tutorial. The long answer is the rest of the manpage :-) @@ -1077,7 +1071,7 @@ INSTALLDIRS according to the following table: INSTALLDIRS set to perl site vendor - PREFIX SITEPREFIX VENDORPREFIX + PERLPREFIX SITEPREFIX VENDORPREFIX INST_ARCHLIB INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH INST_LIB INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB INST_BIN INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN @@ -1357,6 +1351,18 @@ be determined by some evaluation method. Something like C<"-DHAVE_UNISTD_H"> +=item DESTDIR + +This is the root directory into which the code will be installed. It +I<prepends itself to the normal prefix>. For example, if your code +would normally go into /usr/local/lib/perl you could set DESTDIR=/tmp/ +and installation would go into /tmp/usr/local/lib/perl. + +This is primarily of use for people who repackage Perl modules. + +NOTE: Due to the nature of make, it is important that you put the trailing +slash on your DESTDIR. "/tmp/" not "/tmp". + =item DIR Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm' @@ -1364,8 +1370,24 @@ Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm' =item DISTNAME -Your name for distributing the package (by tar file). This defaults to -NAME above. +A safe filename for the package. + +Defaults to NAME above but with :: replaced with -. + +For example, Foo::Bar becomes Foo-Bar. + +=item DISTVNAME + +Your name for distributing the package with the version number +included. This is used by 'make dist' to name the resulting archive +file. + +Defaults to DISTNAME-VERSION. + +For example, version 1.04 of Foo::Bar becomes Foo-Bar-1.04. + +On some OS's where . has special meaning VERSION_SYM may be used in +place of VERSION. =item DL_FUNCS @@ -1407,11 +1429,20 @@ Ref to array of executable files. The files will be copied to the INST_SCRIPT directory. Make realclean will delete them from there again. +If your executables start with something like #!perl or +#!/usr/bin/perl MakeMaker will change this to the path of the perl +'Makefile.PL' was invoked with so the programs will be sure to run +properly even if perl is not in /usr/bin/perl. + =item FIRST_MAKEFILE -The name of the Makefile to be produced. Defaults to the contents of -MAKEFILE, but can be overridden. This is used for the second Makefile -that will be produced for the MAP_TARGET. +The name of the Makefile to be produced. This is used for the second +Makefile that will be produced for the MAP_TARGET. + +Defaults to 'Makefile' or 'Descrip.MMS' on VMS. + +(Note: we couldn't use MAKEFILE because dmake uses this for something +else). =item FULLPERL @@ -1576,6 +1607,12 @@ Directory, where executable files should be installed during testing. make install will copy the files in INST_SCRIPT to INSTALLSCRIPT. +=item LD + +Program to be used to link libraries for dynamic loading. + +Defaults to $Config{ld}. + =item LDDLFLAGS Any special flags that might need to be passed to ld to create a @@ -1636,9 +1673,12 @@ Boolean which tells MakeMaker, that it should include the rules to make a perl. This is handled automatically as a switch by MakeMaker. The user normally does not need it. -=item MAKEFILE +=item MAKEFILE_OLD + +When 'make clean' or similar is run, the $(FIRST_MAKEFILE) will be +backed up at this location. -The name of the Makefile to be produced. +Defaults to $(FIRST_MAKEFILE).old or $(FIRST_MAKEFILE)_old on VMS. =item MAN1PODS @@ -1680,14 +1720,24 @@ this boolean variable yourself. =item NOECHO -Defaults to C<@>. By setting it to an empty string you can generate a -Makefile that echos all commands. Mainly used in debugging MakeMaker -itself. +Command so make does not print the literal commands its running. + +By setting it to an empty string you can generate a Makefile that +prints all commands. Mainly used in debugging MakeMaker itself. + +Defaults to C<@>. =item NORECURS Boolean. Attribute to inhibit descending into subdirectories. +=item NO_META + +When true, suppresses the generation and addition to the MANIFEST of +the META.yml module meta-data file during 'make distdir'. + +Defaults to false. + =item NO_VC In general, any generated Makefile checks for the current version of @@ -1766,6 +1816,16 @@ nullifies many advantages of Perl's malloc(), such as better usage of system resources, error detection, memory usage reporting, catchable failure of memory allocations, etc. +=item PERLPREFIX + +Directory under which core modules are to be installed. + +Defaults to $Config{installprefixexp} falling back to +$Config{installprefix}, $Config{prefixexp} or $Config{prefix} should +$Config{installprefixexp} not exist. + +Overridden by PREFIX. + =item PERLRUN Use this instead of $(PERL) when you wish to run perl. It will set up @@ -1882,8 +1942,6 @@ which should be sensible for your platform. If you specify LIB or any INSTALL* variables they will not be effected by the PREFIX. -Defaults to $Config{installprefixexp}. - =item PREREQ_FATAL Bool. If this parameter is true, failing to have the required modules @@ -1908,7 +1966,8 @@ only check if any version is installed already. =item PREREQ_PRINT Bool. If this parameter is true, the prerequisites will be printed to -stdout and MakeMaker will exit. The output format is +stdout and MakeMaker will exit. The output format is an evalable hash +ref. $PREREQ_PM = { 'A::B' => Vers1, @@ -1924,11 +1983,13 @@ RedHatism for C<PREREQ_PRINT>. The output format is different, though: =item SITEPREFIX -Like PREFIX, but only for the site install locations. +Like PERLPREFIX, but only for the site install locations. + +Defaults to $Config{siteprefixexp}. Perls prior to 5.6.0 didn't have +an explicit siteprefix in the Config. In those cases +$Config{installprefix} will be used. -Defaults to PREFIX (if set) or $Config{siteprefixexp}. Perls prior to -5.6.0 didn't have an explicit siteprefix in the Config. In those -cases $Config{installprefix} will be used. +Overridable by PREFIX =item SKIP @@ -1948,9 +2009,11 @@ typemap has lowest precedence. =item VENDORPREFIX -Like PREFIX, but only for the vendor install locations. +Like PERLPREFIX, but only for the vendor install locations. + +Defaults to $Config{vendorprefixexp}. -Defaults to PREFIX (if set) or $Config{vendorprefixexp} +Overridable by PREFIX =item VERBINST @@ -1977,7 +2040,7 @@ MakeMaker object. The following lines will be parsed o.k.: $VERSION = '1.00'; *VERSION = \'1.01'; - ( $VERSION ) = '$Revision: 1.6 $ ' =~ /\$Revision:\s+([^\s]+)/; + $VERSION = sprintf "%d.%03d", q$Revision: 1.7 $ =~ /(\d+)/g; $FOO::VERSION = '1.10'; *FOO::VERSION = \'1.11'; our $VERSION = 1.2.3; # new for perl5.6.0 @@ -2001,6 +2064,11 @@ would have to do something like See attribute C<depend> below. +=item VERSION_SYM + +A sanitized VERSION with . replaced by _. For places where . has +special meaning (some filesystems, RCS labels, etc...) + =item XS Hashref of .xs files. MakeMaker will default this. e.g. @@ -2032,7 +2100,8 @@ to the value of the VERSION attribute. =head2 Additional lowercase attributes can be used to pass parameters to the methods which implement that -part of the Makefile. +part of the Makefile. Parameters are specified as a hash ref but are +passed to the method as a hash. =over 2 @@ -2079,6 +2148,10 @@ be linked. {ANY_MACRO => ANY_VALUE, ...} +=item postamble + +Anything put here will be passed to MY::postamble() if you have one. + =item realclean {FILES => '$(INST_ARCHAUTODIR)/*.xyz'} @@ -2212,6 +2285,10 @@ Copies all the files that are in the MANIFEST file to a newly created 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 and add +this to your MANFIEST. You can shut this behavior off with the NO_META +flag. + =item make disttest Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and @@ -2276,6 +2353,28 @@ An example: WriteMakefile( 'dist' => { COMPRESS=>"bzip2", SUFFIX=>".bz2" }) + +=head2 Module Meta-Data + +Long plaguing users of MakeMaker based modules has been the problem of +getting basic information about the module out of the sources +I<without> running the F<Makefile.PL> and doing a bunch of messy +heuristics on the resulting F<Makefile>. To this end a simple module +meta-data file has been introduced, F<META.yml>. + +F<META.yml> is a YAML document (see http://www.yaml.org) containing +basic information about the module (name, version, prerequisites...) +in an easy to read format. The format is developed and defined by the +Module::Build developers (see +http://module-build.sourceforge.net/META-spec.html) + +MakeMaker will automatically generate a F<META.yml> file for you and +add it to your F<MANIFEST> as part of the 'distdir' target (and thus +the 'dist' target). This is intended to seamlessly and rapidly +populate CPAN with module meta-data. If you wish to shut this feature +off, set the C<NO_META> C<WriteMakefile()> flag to true. + + =head2 Disabling an extension If some events detected in F<Makefile.PL> imply that there is no way @@ -2293,9 +2392,33 @@ in a subdirectory of some other distribution, or is listed as a dependency in a CPAN::Bundle, but the functionality is supported by different means on the current architecture). +=head2 Other Handy Functions + +=over 4 + +=item prompt + + my $value = prompt($message); + my $value = prompt($message, $default); + +The C<prompt()> function provides an easy way to request user input +used to write a makefile. It displays the $message as a prompt for +input. If a $default is provided it will be used as a default. The +function returns the $value selected by the user. + +If C<prompt()> detects that it is not running interactively and there +is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable +is set to true, the $default will be used without prompting. This +prevents automated processes from blocking on user input. + +If no $default is provided an empty string will be used instead. + +=back + + =head1 ENVIRONMENT -=over 8 +=over 4 =item PERL_MM_OPT @@ -2331,4 +2454,12 @@ generated Makefile along with your report. For more up-to-date information, see http://www.makemaker.org. +=head1 LICENSE + +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +See F<http://www.perl.com/perl/misc/Artistic.html> + + =cut diff --git a/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker/FAQ.pod b/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker/FAQ.pod index df4313dfce5..df109192a1f 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker/FAQ.pod +++ b/gnu/usr.bin/perl/lib/ExtUtils/MakeMaker/FAQ.pod @@ -1,6 +1,6 @@ package ExtUtils::MakeMaker::FAQ; -(our $VERSION) = sprintf "%03d", q$Revision: 1.1 $ =~ /Revision:\s+(\S+)/; +(our $VERSION) = sprintf "%03d", q$Revision: 1.2 $ =~ /Revision:\s+(\S+)/; 1; __END__ @@ -75,7 +75,7 @@ system's revision number (you are using version control, right?). In CVS and RCS you use $Z<>Revision$ writing it like so: - $VERSION = sprintf "%d.%03d", q$Revision: 1.1 $ =~ /(\d+)/g; + $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)/g; Every time the file is checked in the $Z<>Revision$ will be updated, updating your $VERSION. @@ -88,7 +88,7 @@ If branches are involved (ie. $Z<>Revision: 1.5.3.4) its a little more complicated. # must be all on one line or MakeMaker will get confused. - $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; + $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; =item What's this F<META.yml> thing and how did it get in my F<MANIFEST>?! diff --git a/gnu/usr.bin/perl/lib/ExtUtils/Manifest.pm b/gnu/usr.bin/perl/lib/ExtUtils/Manifest.pm index 7ca5bdd3726..f6dea291d91 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/Manifest.pm +++ b/gnu/usr.bin/perl/lib/ExtUtils/Manifest.pm @@ -12,23 +12,83 @@ use vars qw($VERSION @ISA @EXPORT_OK $Is_MacOS $Is_VMS $Debug $Verbose $Quiet $MANIFEST $DEFAULT_MSKIP); -$VERSION = 1.38; +$VERSION = 1.42; @ISA=('Exporter'); -@EXPORT_OK = ('mkmanifest', 'manicheck', 'fullcheck', 'filecheck', - 'skipcheck', 'maniread', 'manicopy'); +@EXPORT_OK = qw(mkmanifest + manicheck filecheck fullcheck skipcheck + manifind maniread manicopy maniadd + ); $Is_MacOS = $^O eq 'MacOS'; -$Is_VMS = $^O eq 'VMS'; +$Is_VMS = $^O eq 'VMS'; require VMS::Filespec if $Is_VMS; -$Debug = $ENV{PERL_MM_MANIFEST_DEBUG} || 0; +$Debug = $ENV{PERL_MM_MANIFEST_DEBUG} || 0; $Verbose = defined $ENV{PERL_MM_MANIFEST_VERBOSE} ? $ENV{PERL_MM_MANIFEST_VERBOSE} : 1; $Quiet = 0; $MANIFEST = 'MANIFEST'; -$DEFAULT_MSKIP = (File::Spec->splitpath($INC{"ExtUtils/Manifest.pm"}))[1]. + +my $Filename = __FILE__; +$DEFAULT_MSKIP = (File::Spec->splitpath($Filename))[1]. "$MANIFEST.SKIP"; + +=head1 NAME + +ExtUtils::Manifest - utilities to write and check a MANIFEST file + +=head1 SYNOPSIS + + use ExtUtils::Manifest qw(...funcs to import...); + + mkmanifest(); + + my @missing_files = manicheck; + my @skipped = skipcheck; + my @extra_files = filecheck; + my($missing, $extra) = fullcheck; + + my $found = manifind(); + + my $manifest = maniread(); + + manicopy($read,$target); + + maniadd({$file => $comment, ...}); + + +=head1 DESCRIPTION + +=head2 Functions + +ExtUtils::Manifest exports no functions by default. The following are +exported on request + +=over 4 + +=item mkmanifest + + mkmanifest(); + +Writes all files in and below the current directory to your F<MANIFEST>. +It works similar to + + find . > MANIFEST + +All files that match any regular expression in a file F<MANIFEST.SKIP> +(if it exists) are ignored. + +Any existing F<MANIFEST> file will be saved as F<MANIFEST.bak>. Lines +from the old F<MANIFEST> file is preserved, including any comments +that are found in the existing F<MANIFEST> file in the new one. + +=cut + +sub _sort { + return sort { lc $a cmp lc $b } @_; +} + sub mkmanifest { my $manimiss = 0; my $read = (-r 'MANIFEST' && maniread()) or $manimiss++; @@ -42,7 +102,7 @@ sub mkmanifest { %all = (%$found, %$read); $all{$MANIFEST} = ($Is_VMS ? "$MANIFEST\t\t" : '') . 'This list of files' if $manimiss; # add new MANIFEST to known file list - foreach $file (sort keys %all) { + foreach $file (_sort keys %all) { if ($skip->($file)) { # Policy: only remove files if they're listed in MANIFEST.SKIP. # Don't remove files just because they don't exist. @@ -72,6 +132,16 @@ sub clean_up_filename { return $filename; } + +=item manifind + + my $found = manifind(); + +returns a hash reference. The keys of the hash are the files found +below the current directory. + +=cut + sub manifind { my $p = shift || {}; my $found = {}; @@ -98,25 +168,73 @@ sub manifind { return $found; } -sub fullcheck { - return [_check_files()], [_check_manifest()]; -} + +=item manicheck + + my @missing_files = manicheck(); + +checks if all the files within a C<MANIFEST> in the current directory +really do exist. If C<MANIFEST> and the tree below the current +directory are in sync it silently returns an empty list. +Otherwise it returns a list of files which are listed in the +C<MANIFEST> but missing from the directory, and by default also +outputs these names to STDERR. + +=cut sub manicheck { return _check_files(); } + +=item filecheck + + my @extra_files = filecheck(); + +finds files below the current directory that are not mentioned in the +C<MANIFEST> file. An optional file C<MANIFEST.SKIP> will be +consulted. Any file matching a regular expression in such a file will +not be reported as missing in the C<MANIFEST> file. The list of any +extraneous files found is returned, and by default also reported to +STDERR. + +=cut + sub filecheck { return _check_manifest(); } + +=item fullcheck + + my($missing, $extra) = fullcheck(); + +does both a manicheck() and a filecheck(), returning then as two array +refs. + +=cut + +sub fullcheck { + return [_check_files()], [_check_manifest()]; +} + + +=item skipcheck + + my @skipped = skipcheck(); + +lists all the files that are skipped due to your C<MANIFEST.SKIP> +file. + +=cut + sub skipcheck { my($p) = @_; my $found = manifind(); my $matches = _maniskip(); my @skipped = (); - foreach my $file (sort keys %$found){ + foreach my $file (_sort keys %$found){ if (&$matches($file)){ warn "Skipping $file\n"; push @skipped, $file; @@ -135,7 +253,7 @@ sub _check_files { my $found = manifind($p); my(@missfile) = (); - foreach my $file (sort keys %$read){ + foreach my $file (_sort keys %$read){ warn "Debug: manicheck checking from $MANIFEST $file\n" if $Debug; if ($dosnames){ $file = lc $file; @@ -159,7 +277,7 @@ sub _check_manifest { my $skip = _maniskip(); my @missentry = (); - foreach my $file (sort keys %$found){ + foreach my $file (_sort keys %$found){ next if $skip->($file); warn "Debug: manicheck checking from disk $file\n" if $Debug; unless ( exists $read->{$file} ) { @@ -173,38 +291,51 @@ sub _check_manifest { } +=item maniread + + my $manifest = maniread(); + my $manifest = maniread($manifest_file); + +reads a named C<MANIFEST> file (defaults to C<MANIFEST> in the current +directory) and returns a HASH reference with files being the keys and +comments being the values of the HASH. Blank lines and lines which +start with C<#> in the C<MANIFEST> file are discarded. + +=cut + sub maniread { my ($mfile) = @_; $mfile ||= $MANIFEST; my $read = {}; local *M; unless (open M, $mfile){ - warn "$mfile: $!"; - return $read; + warn "$mfile: $!"; + return $read; } + local $_; while (<M>){ - chomp; - next if /^#/; + chomp; + next if /^\s*#/; my($file, $comment) = /^(\S+)\s*(.*)/; next unless $file; - if ($Is_MacOS) { - $file = _macify($file); - $file =~ s/\\([0-3][0-7][0-7])/sprintf("%c", oct($1))/ge; - } - elsif ($Is_VMS) { - require File::Basename; - my($base,$dir) = File::Basename::fileparse($file); - # Resolve illegal file specifications in the same way as tar - $dir =~ tr/./_/; - my(@pieces) = split(/\./,$base); - if (@pieces > 2) { $base = shift(@pieces) . '.' . join('_',@pieces); } - my $okfile = "$dir$base"; - warn "Debug: Illegal name $file changed to $okfile\n" if $Debug; + if ($Is_MacOS) { + $file = _macify($file); + $file =~ s/\\([0-3][0-7][0-7])/sprintf("%c", oct($1))/ge; + } + elsif ($Is_VMS) { + require File::Basename; + my($base,$dir) = File::Basename::fileparse($file); + # Resolve illegal file specifications in the same way as tar + $dir =~ tr/./_/; + my(@pieces) = split(/\./,$base); + if (@pieces > 2) { $base = shift(@pieces) . '.' . join('_',@pieces); } + my $okfile = "$dir$base"; + warn "Debug: Illegal name $file changed to $okfile\n" if $Debug; $file = $okfile; $file = lc($file) unless $file =~ /^MANIFEST(\.SKIP)?$/; - } + } $read->{$file} = $comment; } @@ -216,7 +347,7 @@ sub maniread { sub _maniskip { my @skip ; my $mfile = "$MANIFEST.SKIP"; - local *M; + local(*M,$_); open M, $mfile or open M, $DEFAULT_MSKIP or return sub {0}; while (<M>){ chomp; @@ -234,6 +365,23 @@ sub _maniskip { return sub { $_[0] =~ qr{$opts$regex} }; } +=item manicopy + + manicopy($src, $dest_dir); + manicopy($src, $dest_dir, $how); + +copies the files that are the keys in the HASH I<%$src> to the +$dest_dir. The HASH reference $read is typically returned by the +maniread() function. This function is useful for producing a directory +tree identical to the intended distribution tree. The third parameter +$how can be used to specify a different methods of "copying". Valid +values are C<cp>, which actually copies the files, C<ln> which creates +hard links, and C<best> which mostly links the files but copies any +symbolic link to make a tree without any symbolic link. Best is the +default. + +=cut + sub manicopy { my($read,$target,$how)=@_; croak "manicopy() called without target argument" unless defined $target; @@ -270,6 +418,7 @@ sub cp_if_diff { local(*F,*T); open(F,"< $from\0") or die "Can't read $from: $!\n"; if (open(T,"< $to\0")) { + local $_; while (<F>) { $diff++,last if $_ ne <T>; } $diff++ unless eof(T); close T; @@ -372,90 +521,75 @@ sub _unmacify { $file; } -1; -__END__ +=item maniadd -=head1 NAME + maniadd({ $file => $comment, ...}); -ExtUtils::Manifest - utilities to write and check a MANIFEST file +Adds an entry to an existing F<MANIFEST> unless its already there. -=head1 SYNOPSIS +$file will be normalized (ie. Unixified). B<UNIMPLEMENTED> - require ExtUtils::Manifest; +=cut - ExtUtils::Manifest::mkmanifest; +sub maniadd { + my($additions) = shift; - ExtUtils::Manifest::manicheck; + _normalize($additions); + _fix_manifest($MANIFEST); - ExtUtils::Manifest::filecheck; + my $manifest = maniread(); + my @needed = grep { !exists $manifest->{$_} } keys %$additions; + return 1 unless @needed; - ExtUtils::Manifest::fullcheck; + open(MANIFEST, ">>$MANIFEST") or + die "maniadd() could not open $MANIFEST: $!"; - ExtUtils::Manifest::skipcheck; + foreach my $file (_sort @needed) { + my $comment = $additions->{$file} || ''; + printf MANIFEST "%-40s %s\n", $file, $comment; + } + close MANIFEST or die "Error closing $MANIFEST: $!"; - ExtUtils::Manifest::manifind(); + return 1; +} - ExtUtils::Manifest::maniread($file); - ExtUtils::Manifest::manicopy($read,$target,$how); +# Sometimes MANIFESTs are missing a trailing newline. Fix this. +sub _fix_manifest { + my $manifest_file = shift; -=head1 DESCRIPTION + open MANIFEST, $MANIFEST or die "Could not open $MANIFEST: $!"; -mkmanifest() writes all files in and below the current directory to a -file named in the global variable $ExtUtils::Manifest::MANIFEST (which -defaults to C<MANIFEST>) in the current directory. It works similar to - - find . -print - -but in doing so checks each line in an existing C<MANIFEST> file and -includes any comments that are found in the existing C<MANIFEST> file -in the new one. Anything between white space and an end of line within -a C<MANIFEST> file is considered to be a comment. Filenames and -comments are separated by one or more TAB characters in the -output. All files that match any regular expression in a file -C<MANIFEST.SKIP> (if such a file exists) are ignored. - -manicheck() checks if all the files within a C<MANIFEST> in the current -directory really do exist. If C<MANIFEST> and the tree below the current -directory are in sync it exits silently, returning an empty list. Otherwise -it returns a list of files which are listed in the C<MANIFEST> but missing -from the directory, and by default also outputs these names to STDERR. - -filecheck() finds files below the current directory that are not -mentioned in the C<MANIFEST> file. An optional file C<MANIFEST.SKIP> -will be consulted. Any file matching a regular expression in such a -file will not be reported as missing in the C<MANIFEST> file. The list of -any extraneous files found is returned, and by default also reported to -STDERR. + # Yes, we should be using seek(), but I'd like to avoid loading POSIX + # to get SEEK_* + my @manifest = <MANIFEST>; + close MANIFEST; -fullcheck() does both a manicheck() and a filecheck(), returning references -to two arrays, the first for files manicheck() found to be missing, the -seond for unexpeced files found by filecheck(). + unless( $manifest[-1] =~ /\n\z/ ) { + open MANIFEST, ">>$MANIFEST" or die "Could not open $MANIFEST: $!"; + print MANIFEST "\n"; + close MANIFEST; + } +} + -skipcheck() lists all the files that are skipped due to your -C<MANIFEST.SKIP> file. +# UNIMPLEMENTED +sub _normalize { + return; +} + + +=back -manifind() returns a hash reference. The keys of the hash are the -files found below the current directory. +=head2 MANIFEST -maniread($file) reads a named C<MANIFEST> file (defaults to -C<MANIFEST> in the current directory) and returns a HASH reference -with files being the keys and comments being the values of the HASH. -Blank lines and lines which start with C<#> in the C<MANIFEST> file -are discarded. +Anything between white space and an end of line within a C<MANIFEST> +file is considered to be a comment. Filenames and comments are +separated by one or more TAB characters in the output. -C<manicopy($read,$target,$how)> copies the files that are the keys in -the HASH I<%$read> to the named target directory. The HASH reference -$read is typically returned by the maniread() function. This -function is useful for producing a directory tree identical to the -intended distribution tree. The third parameter $how can be used to -specify a different methods of "copying". Valid values are C<cp>, -which actually copies the files, C<ln> which creates hard links, and -C<best> which mostly links the files but copies any symbolic link to -make a tree without any symbolic link. Best is the default. -=head1 MANIFEST.SKIP +=head2 MANIFEST.SKIP The file MANIFEST.SKIP may contain regular expressions of files that should be ignored by mkmanifest() and filecheck(). The regular @@ -467,6 +601,7 @@ expression to start with a sharp character. A typical example: \bRCS\b \bCVS\b ,v$ + \B\.svn\b # Makemaker generated files and dirs. ^MANIFEST\. @@ -485,12 +620,12 @@ used, similar to the example above. If you want nothing skipped, simply make an empty MANIFEST.SKIP file. -=head1 EXPORT_OK +=head2 EXPORT_OK C<&mkmanifest>, C<&manicheck>, C<&filecheck>, C<&fullcheck>, C<&maniread>, and C<&manicopy> are exportable. -=head1 GLOBAL VARIABLES +=head2 GLOBAL VARIABLES C<$ExtUtils::Manifest::MANIFEST> defaults to C<MANIFEST>. Changing it results in both a different C<MANIFEST> and a different @@ -554,3 +689,5 @@ L<ExtUtils::MakeMaker> which has handy targets for most of the functionality. Andreas Koenig <F<andreas.koenig@anima.de>> =cut + +1; diff --git a/gnu/usr.bin/perl/lib/ExtUtils/typemap b/gnu/usr.bin/perl/lib/ExtUtils/typemap index 1124eb64838..2a53b62abf8 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/typemap +++ b/gnu/usr.bin/perl/lib/ExtUtils/typemap @@ -14,6 +14,7 @@ const char * T_PV caddr_t T_PV wchar_t * T_PV wchar_t T_IV +# bool_t is defined in <rpc/rpc.h> bool_t T_IV size_t T_UV ssize_t T_IV diff --git a/gnu/usr.bin/perl/lib/ExtUtils/xsubpp b/gnu/usr.bin/perl/lib/ExtUtils/xsubpp index b5dfa610c02..7ae8020e25b 100644 --- a/gnu/usr.bin/perl/lib/ExtUtils/xsubpp +++ b/gnu/usr.bin/perl/lib/ExtUtils/xsubpp @@ -137,6 +137,7 @@ $ProtoUsed = 0 ; $WantLineNumbers = 1 ; $WantOptimize = 1 ; $Overload = 0; +$Fallback = 'PL_sv_undef'; my $process_inout = 1; my $process_argtypes = 1; @@ -293,7 +294,7 @@ $END = "!End!\n\n"; # "impossible" keyword (multiple newline) $BLOCK_re= '\s*(' . join('|', qw( REQUIRE BOOT CASE PREINIT INPUT INIT CODE PPCODE OUTPUT CLEANUP ALIAS ATTRS PROTOTYPES PROTOTYPE VERSIONCHECK INCLUDE - SCOPE INTERFACE INTERFACE_MACRO C_ARGS POSTCALL OVERLOAD + SCOPE INTERFACE INTERFACE_MACRO C_ARGS POSTCALL OVERLOAD FALLBACK )) . "|$END)\\s*:"; # Input: ($_, @line) == unparsed input. @@ -617,6 +618,24 @@ sub OVERLOAD_handler() } +sub FALLBACK_handler() +{ + # the rest of the current line should contain either TRUE, + # FALSE or UNDEF + + TrimWhitespace($_) ; + my %map = ( + TRUE => "PL_sv_yes", 1 => "PL_sv_yes", + FALSE => "PL_sv_no", 0 => "PL_sv_no", + UNDEF => "PL_sv_undef", + ) ; + + # check for valid FALLBACK value + death ("Error: FALLBACK: TRUE/FALSE/UNDEF") unless exists $map{uc $_} ; + + $Fallback = $map{uc $_} ; +} + sub REQUIRE_handler () { # the rest of the current line should contain a version number @@ -888,7 +907,19 @@ while (<$FH>) { my $podstartline = $.; do { if (/^=cut\s*$/) { - print("/* Skipped embedded POD. */\n"); + # We can't just write out a /* */ comment, as our embedded + # POD might itself be in a comment. We can't put a /**/ + # comment inside #if 0, as the C standard says that the source + # file is decomposed into preprocessing characters in the stage + # before preprocessing commands are executed. + # I don't want to leave the text as barewords, because the spec + # isn't clear whether macros are expanded before or after + # preprocessing commands are executed, and someone pathological + # may just have defined one of the 3 words as a macro that does + # something strange. Multiline strings are illegal in C, so + # the "" we write must be a string literal. And they aren't + # concatenated until 2 steps later, so we are safe. + print("#if 0\n \"Skipped embedded POD.\"\n#endif\n"); printf("#line %d \"$filename\"\n", $. + 1) if $WantLineNumbers; next firstmodule @@ -1053,7 +1084,7 @@ while (fetch_para()) { $xsreturn = 0; $_ = shift(@line); - while ($kwd = check_keyword("REQUIRE|PROTOTYPES|VERSIONCHECK|INCLUDE")) { + while ($kwd = check_keyword("REQUIRE|PROTOTYPES|FALLBACK|VERSIONCHECK|INCLUDE")) { &{"${kwd}_handler"}() ; next PARAGRAPH unless @line ; $_ = shift(@line); @@ -1422,7 +1453,11 @@ EOF $xsreturn = 1 if $ret_type ne "void"; my $num = $xsreturn; my $c = @outlist; - print "\tXSprePUSH;" if $c and not $prepush_done; + # (PP)CODE set different values of SP; reset to PPCODE's with 0 output + print "\tXSprePUSH;" if $c and not $prepush_done; + # Take into account stuff already put on stack + print "\t++SP;" if $c and not $prepush_done and $xsreturn; + # Now SP corresponds to ST($xsreturn), so one can combine PUSH and ST() print "\tEXTEND(SP,$c);\n" if $c; $xsreturn += $c; generate_output($var_types{$_}, $num++, $_, 0, 1) for @outlist; @@ -1542,6 +1577,25 @@ EOF } } +if ($Overload) # make it findable with fetchmethod +{ + + print Q<<"EOF"; +#XS(XS_${Packid}_nil); /* prototype to pass -Wmissing-prototypes */ +#XS(XS_${Packid}_nil) +#{ +# XSRETURN_EMPTY; +#} +# +EOF + unshift(@InitFileCode, <<"MAKE_FETCHMETHOD_WORK"); + /* Making a sub named "${Package}::()" allows the package */ + /* to be findable via fetchmethod(), and causes */ + /* overload::Overloaded("${Package}") to return true. */ + newXS("${Package}::()", XS_${Packid}_nil, file$proto); +MAKE_FETCHMETHOD_WORK +} + # print initialization routine print Q<<"EOF"; @@ -1580,15 +1634,15 @@ print Q<<"EOF" if defined $XsubAliases or defined $Interfaces ; EOF print Q<<"EOF" if ($Overload); -# { -# /* create the package stash */ -# HV *hv = get_hv(\"$Package\::OVERLOAD\",TRUE); -# SV *sv = *hv_fetch(hv,"register",8,1); -# sv_inc(sv); -# SvSETMAGIC(sv); -# /* Make it findable via fetchmethod */ -# newXS(\"$Package\::()\", NULL, file); -# } +# /* register the overloading (type 'A') magic */ +# PL_amagic_generation++; +# /* The magic for overload gets a GV* via gv_fetchmeth as */ +# /* mentioned above, and looks in the SV* slot of it for */ +# /* the "fallback" status. */ +# sv_setsv( +# get_sv( "${Package}::()", TRUE ), +# $Fallback +# ); EOF print @InitFileCode; |