added patch for -i'foo*bar', made code somewhat simpler, tweaked doc
[p5sagit/p5-mst-13.2.git] / installperl
index a8bcd35..44e5d1b 100755 (executable)
@@ -6,9 +6,13 @@ BEGIN {
     @INC = 'lib';
     $ENV{PERL5LIB} = 'lib';
     $Is_VMS = $^O eq 'VMS';
+    $Is_W32 = $^O eq 'MSWin32';
+    $Is_OS2 = $^O eq 'os2';
     if ($Is_VMS) { eval 'use VMS::Filespec;' }
 }
 
+$scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : '');
+
 use File::Find;
 use File::Compare;
 use File::Copy ();
@@ -37,16 +41,18 @@ while (@ARGV) {
 
 umask 022 unless $Is_VMS;
 
-@scripts = qw( utils/c2ph utils/h2ph utils/h2xs
-               utils/perlbug utils/perldoc utils/pl2pm utils/splain utils/perlcc
+@scripts = qw( utils/c2ph utils/h2ph utils/h2xs utils/perlbug utils/perldoc
+               utils/pl2pm utils/splain utils/perlcc
                x2p/s2p x2p/find2perl 
                pod/pod2man pod/pod2html pod/pod2latex pod/pod2text);
 
-if ($Is_VMS) { @scripts = map { "$_.Com" } @scripts; }
+if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; }
 
 @pods = (<pod/*.pod>);
 
-%archpms = (Config => 1, FileHandle => 1, overload => 1);
+%archpms = (
+    Config => 1, FileHandle => 1, overload => 1,
+);
 
 if ($^O eq 'dos') {
     push(@scripts,'djgpp/fixpmain');
@@ -110,19 +116,22 @@ if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
 -x 'perl' . $exe_ext   || die "perl isn't executable!\n";
 -x 'suidperl' . $exe_ext|| die "suidperl isn't executable!\n" if $d_dosuid;
 
--x 't/TEST'            || $^O eq 'MSWin32'
+-x 't/TEST'            || $Is_W32
                        || warn "WARNING: You've never run 'make test'!!!",
                                "  (Installing anyway.)\n";
 
-if ($^O eq 'MSWin32') {
+if ($Is_W32) {
+
+$perldll = 'perl.' . $dlext;
+$perldll = 'perlcore.' . $dlext if $Config{'ccflags'} =~ /PERL_OBJECT/i;
 
--f 'perl.' . $dlext || die "No perl DLL built\n";
+-f $perldll || die "No perl DLL built\n";
 
 # Install the DLL
 
-safe_unlink("$installbin/$perl.$dlext");
-copy("perl.$dlext", "$installbin/$perl.$dlext");
-chmod(0755, "$installbin/$perl.$dlext");
+safe_unlink("$installbin/$perldll");
+copy("$perldll", "$installbin/$perldll");
+chmod(0755, "$installbin/$perldll");
 }
 
 # This will be used to store the packlist
@@ -212,7 +221,7 @@ if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VM
 
 $mainperl_is_instperl = 0;
 
-if (!$versiononly && !$nonono && $^O ne 'MSWin32' && !$Is_VMS && -t STDIN && -t STDERR
+if (!$versiononly && !$nonono && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR
        && -w $mainperldir && ! samepath($mainperldir, $installbin)) {
     local($usrbinperl) = "$mainperldir/$perl$exe_ext";
     local($instperl)   = "$installbin/$perl$exe_ext";
@@ -276,12 +285,11 @@ if (! $versiononly) {
 # pstruct should be a link to c2ph
 
 if (! $versiononly) {
-    safe_unlink("$installscript/pstruct" . ($Is_VMS ? '.Com' : ''));
+    safe_unlink("$installscript/pstruct$scr_ext");
     if ($^O eq 'dos' or $Is_VMS) {
-        copy("$installscript/c2ph" . ($Is_VMS ? '.Com' : ''),
-             "$installscript/pstruct" . ($Is_VMS ? '.Com' : '')); 
+        copy("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext"); 
     } else {
-        link("$installscript/c2ph","$installscript/pstruct");
+        link("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext");
     }
 }
 
@@ -329,7 +337,7 @@ if (! $versiononly || !($installprivlib =~ m/\Q$]/)) {
 
 if (!$versiononly) {
 
-    $dirsep = ($^O eq 'os2' || $^O eq 'MSWin32') ? ';' : ':' ;
+    $dirsep = ($Is_OS2 || $Is_W32) ? ';' : ':' ;
     ($path = $ENV{"PATH"}) =~ s:\\:/:g ;
     @path = split(/$dirsep/, $path);
     if ($Is_VMS) {
@@ -385,7 +393,7 @@ sub unlink {
 
     foreach $name (@names) {
        next unless -e $name;
-       chmod 0777, $name if ($^O eq 'os2' || $^O eq 'MSWin32');
+       chmod 0777, $name if ($Is_OS2 || $Is_W32);
        print STDERR "  unlink $name\n";
        ( CORE::unlink($name) and ++$cnt 
          or warn "Couldn't unlink $name: $!\n" ) unless $nonono;
@@ -398,7 +406,7 @@ sub safe_unlink {
     local @names = @_;
     foreach $name (@names) {
        next unless -e $name;
-       chmod 0777, $name if ($^O eq 'os2' || $^O eq 'MSWin32');
+       chmod 0777, $name if ($Is_OS2 || $Is_W32);
        print STDERR "  unlink $name\n";
        next if CORE::unlink($name);
        warn "Couldn't unlink $name: $!\n";
@@ -473,7 +481,7 @@ sub copy {
 sub samepath {
     local($p1, $p2) = @_;
 
-    return (lc($p1) eq lc($p2)) if ($^O eq 'MSWin32');
+    return (lc($p1) eq lc($p2)) if $Is_W32;
 
     if ($p1 ne $p2) {
        local($dev1, $ino1, $dev2, $ino2);
@@ -506,7 +514,7 @@ sub installlib {
     my $installlib = $installprivlib;
     if ($dir =~ /^auto/ ||
          ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) ||
-         ($name =~ /^(.*)\.(?:h|lib)$/i && $^O eq 'MSWin32')
+         ($name =~ /^(.*)\.(?:h|lib)$/i && $Is_W32)
        ) {
         $installlib = $installarchlib;
        return unless $do_installarchlib;
@@ -550,6 +558,7 @@ sub installlib {
 
 sub copy_if_diff {
     my($from,$to)=@_;
+    return 1 if (($^O eq 'VMS') && (-d $from));
     -f $from || die "$0: $from not found";
     $packlist->{$to} = { type => 'file' };
     if (compare($from, $to) || $nonono) {
@@ -559,7 +568,7 @@ sub copy_if_diff {
         }
        copy($from, $to);
        # Restore timestamps if it's a .a library or for OS/2.
-       if (!$nonono && ($^O eq 'os2' || $to =~ /\.a$/)) {
+       if (!$nonono && ($Is_OS2 || $to =~ /\.a$/)) {
            my ($atime, $mtime) = (stat $from)[8,9];
            utime $atime, $mtime, $to;
        }