This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Configure regen to pick up the new installation directories
[perl5.git] / installperl
1 #!./perl
2
3 BEGIN {
4     require 5.004;
5     chdir '..' if !-d 'lib' and -d '..\lib';
6     @INC = 'lib';
7     $ENV{PERL5LIB} = 'lib';
8 }
9
10 use strict;
11 use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $nonono $versiononly $depth);
12
13 BEGIN {
14     $Is_VMS = $^O eq 'VMS';
15     $Is_W32 = $^O eq 'MSWin32';
16     $Is_OS2 = $^O eq 'os2';
17     $Is_Cygwin = $^O =~ /cygwin/i;
18     if ($Is_VMS) { eval 'use VMS::Filespec;' }
19 }
20
21 my $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : '');
22
23 use File::Find;
24 use File::Compare;
25 use File::Copy ();
26 use File::Path ();
27 use ExtUtils::Packlist;
28 use Config;
29 use subs qw(unlink link chmod);
30 use vars qw($packlist);
31
32 # override the ones in the rest of the script
33 sub mkpath {
34     File::Path::mkpath(@_) unless $nonono;
35 }
36
37 my $mainperldir = "/usr/bin";
38 my $exe_ext = $Config{exe_ext};
39
40 # Allow ``make install PERLNAME=something_besides_perl'':
41 my $perl = defined($ENV{PERLNAME}) ? $ENV{PERLNAME} : 'perl';
42
43 # This is the base used for versioned names, like "perl5.005".
44 # It's separate because a common use of $PERLNAME is to install
45 # perl as "perl5", if that's used as base for versioned files you
46 # get "perl55.005".
47 my $perl_verbase = defined($ENV{PERLNAME_VERBASE})
48                     ? $ENV{PERLNAME_VERBASE}
49                     : $perl;
50
51 while (@ARGV) {
52     $nonono = 1 if $ARGV[0] eq '-n';
53     $versiononly = 1 if $ARGV[0] eq '-v';
54     shift;
55 }
56
57 umask 022 unless $Is_VMS;
58
59 my @scripts = qw(utils/c2ph utils/h2ph utils/h2xs utils/perlbug utils/perldoc
60                 utils/pl2pm utils/splain utils/perlcc utils/dprofpp
61                 x2p/s2p x2p/find2perl 
62                 pod/pod2man pod/pod2html pod/pod2latex pod/pod2text
63                 pod/pod2usage pod/podchecker pod/podselect);
64
65 if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; }
66
67 my @pods = (<pod/*.pod>);
68
69 # Specify here any .pm files that are actually architecture-dependent.
70 # (Those included with XS extensions under ext/ are automatically
71 # added later.)
72 # Now that the default privlib has the full perl version number included,
73 # we no longer have to play the trick of sticking version-specific .pm 
74 # files under the archlib directory.
75 my %archpms = (
76     Config => 1, 
77 );
78
79 if ($^O eq 'dos') {
80     push(@scripts,'djgpp/fixpmain');
81     $archpms{config} = $archpms{filehand} = 1;
82 }
83
84 if ((-e "testcompile") && (defined($ENV{'COMPILE'})))
85 {
86         push(@scripts, map("$_.exe", @scripts));
87 }
88
89 find(sub {
90         if ("$File::Find::dir/$_" =~ m{^ext/[^/]+/(.*)\.pm$}) {
91             (my $pm = $1) =~ s{^lib/}{};
92             $archpms{$pm} = 1;
93         }
94     }, 'ext');
95
96 my $ver = $];
97 my $release = substr($ver,0,3);   # Not used presently.
98 my $patchlevel = substr($ver,3,2);
99 die "Patchlevel of perl ($patchlevel)",
100     "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n"
101         if $patchlevel != $Config{'PERL_VERSION'};
102
103 # Fetch some frequently-used items from %Config
104 my $installbin = $Config{installbin};
105 my $installscript = $Config{installscript};
106 my $installprivlib = $Config{installprivlib};
107 my $installarchlib = $Config{installarchlib};
108 my $installsitelib = $Config{installsitelib};
109 my $installsitearch = $Config{installsitearch};
110 my $installman1dir = $Config{installman1dir};
111 my $man1ext = $Config{man1ext};
112 my $libperl = $Config{libperl};
113 # Shared library and dynamic loading suffixes.
114 my $so = $Config{so};
115 my $dlext = $Config{dlext};
116 my $dlsrc = $Config{dlsrc};
117
118 my $d_dosuid = $Config{d_dosuid};
119 my $binexp = $Config{binexp};
120
121 if ($Is_VMS) {  # Hang in there until File::Spec hits the big time
122     foreach ( \$installbin,     \$installscript,  \$installprivlib,
123               \$installarchlib, \$installsitelib, \$installsitearch,
124               \$installman1dir ) {
125       $$_ = unixify($$_);  $$_ =~ s:/$::;
126     }
127 }
128
129 # Do some quick sanity checks.
130
131 if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
132
133    $installbin          || die "No installbin directory in config.sh\n";
134 -d $installbin          || mkpath($installbin, 1, 0777);
135 -d $installbin          || $nonono || die "$installbin is not a directory\n";
136 -w $installbin          || $nonono || die "$installbin is not writable by you\n"
137         unless $installbin =~ m#^/afs/# || $nonono;
138
139 -x 'perl' . $exe_ext    || die "perl isn't executable!\n";
140 -x 'suidperl' . $exe_ext|| die "suidperl isn't executable!\n" if $d_dosuid;
141
142 -x 't/TEST'             || $Is_W32
143                         || warn "WARNING: You've never run 'make test'!!!",
144                                 "  (Installing anyway.)\n";
145
146 if ($Is_W32 or $Is_Cygwin) {
147   my $perldll;
148
149 if ($Is_Cygwin) {
150   $perldll = $libperl;
151   $perldll =~ s/(\..*)?$/.$dlext/;
152   if ($Config{useshrplib} eq 'true') {
153     # install ld2 and perlld as well
154     foreach ('ld2', 'perlld') {
155       safe_unlink("$installbin/$_");
156       copy("$_", "$installbin/$_");
157       chmod(0755, "$installbin/$_");
158     };
159   };
160 } else {
161   $perldll = 'perl.' . $dlext;
162   $perldll = 'perl56.' . $dlext if $Config{'ccflags'} =~ /PERL_OBJECT/i;
163 }
164
165    if ($dlsrc != "dl_none.xs") {
166       -f $perldll || die "No perl DLL built\n";
167
168 # Install the DLL
169
170       safe_unlink("$installbin/$perldll");
171       copy("$perldll", "$installbin/$perldll");
172       chmod(0755, "$installbin/$perldll");
173    }
174 } # if ($Is_W32 or $Is_Cygwin)
175
176 # This will be used to store the packlist
177 my $packlist = ExtUtils::Packlist->new("$installarchlib/.packlist");
178
179 # First we install the version-numbered executables.
180
181 if ($Is_VMS) {
182     safe_unlink("$installbin/$perl$exe_ext");
183     copy("perl$exe_ext", "$installbin/$perl$exe_ext");
184     chmod(0755, "$installbin/$perl$exe_ext");
185     safe_unlink("$installbin/${perl}shr$exe_ext");
186     copy("perlshr$exe_ext", "$installbin/${perl}shr$exe_ext");
187     chmod(0755, "$installbin/${perl}shr$exe_ext");
188 }
189 elsif ($^O eq 'mpeix') {
190     # MPE lacks hard links and requires that executables with special
191     # capabilities reside in the MPE namespace.
192     safe_unlink("$installbin/perl$ver$exe_ext", $Config{perlpath});
193     # Install the primary executable into the MPE namespace as perlpath.
194     copy("perl$exe_ext", $Config{perlpath});
195     chmod(0755, $Config{perlpath});
196     # Create a backup copy with the version number.
197     link($Config{perlpath}, "$installbin/perl$ver$exe_ext");
198 }
199 elsif ($^O ne 'dos') {
200     safe_unlink("$installbin/$perl_verbase$ver$exe_ext");
201     copy("perl$exe_ext", "$installbin/$perl_verbase$ver$exe_ext");
202     strip("$installbin/$perl_verbase$ver$exe_ext") if $^O =~ /^(rhapsody)$/;
203     chmod(0755, "$installbin/$perl_verbase$ver$exe_ext");
204 }
205 else {
206     safe_unlink("$installbin/$perl.exe");
207     copy("perl.exe", "$installbin/$perl.exe");
208 }
209
210 safe_unlink("$installbin/s$perl_verbase$ver$exe_ext");
211 if ($d_dosuid) {
212     copy("suidperl$exe_ext", "$installbin/s$perl_verbase$ver$exe_ext");
213     chmod(04711, "$installbin/s$perl_verbase$ver$exe_ext");
214 }
215
216 # Install library files.
217
218 my ($do_installarchlib, $do_installprivlib) = (0, 0);
219     
220 mkpath($installprivlib, 1, 0777);
221 mkpath($installarchlib, 1, 0777);
222 mkpath($installsitelib, 1, 0777) if ($installsitelib);
223 mkpath($installsitearch, 1, 0777) if ($installsitearch);
224
225 if (chdir "lib") {
226     $do_installarchlib = ! samepath($installarchlib, '.');
227     $do_installprivlib = ! samepath($installprivlib, '.');
228     $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$]/);
229
230     if ($do_installarchlib || $do_installprivlib) {
231         find(\&installlib, '.');
232     }
233     chdir ".." || die "Can't cd back to source directory: $!\n";
234 }
235 else {
236     warn "Can't cd to lib to install lib files: $!\n";
237 }
238
239 # Install header files and libraries.
240 mkpath("$installarchlib/CORE", 1, 0777);
241 my @corefiles;
242 if ($Is_VMS) {  # We did core file selection during build
243     my $coredir = "lib/$Config{'arch'}/$]";
244     $coredir =~ tr/./_/;
245     @corefiles = <$coredir/*.*>;
246 }
247 else {
248     # [als] hard-coded 'libperl' name... not good!
249     @corefiles = <*.h libperl*.*>;
250
251     # AIX needs perl.exp installed as well.
252     push(@corefiles,'perl.exp') if $^O eq 'aix';
253     if ($^O eq 'mpeix') {
254         # MPE needs mpeixish.h installed as well.
255         mkpath("$installarchlib/CORE/mpeix", 1, 0777);
256         push(@corefiles,'mpeix/mpeixish.h');
257     }
258     # If they have built sperl.o...
259     push(@corefiles,'sperl.o') if -f 'sperl.o';
260 }
261 foreach my $file (@corefiles) {
262     # HP-UX (at least) needs to maintain execute permissions
263     # on dynamically-loadable libraries. So we do it for all.
264     if (copy_if_diff($file,"$installarchlib/CORE/$file")) {
265         if ($file =~ /\.(so|\Q$dlext\E)$/) {
266             chmod(0555, "$installarchlib/CORE/$file");
267             strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody)$/;
268         } else {
269             chmod(0444, "$installarchlib/CORE/$file");
270         }
271     }
272 }
273
274 # Install main perl executables
275 # Make links to ordinary names if installbin directory isn't current directory.
276
277 if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) {
278     safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext");
279     if ($^O eq 'mpeix') {
280         # MPE doesn't support hard links, so use a symlink.
281         # We don't want another cloned copy.
282         symlink($Config{perlpath}, "$installbin/perl$exe_ext");
283     } else {
284         link("$installbin/$perl_verbase$ver$exe_ext",
285                 "$installbin/$perl$exe_ext");
286     }
287     link("$installbin/s$perl_verbase$ver$exe_ext",
288             "$installbin/suid$perl$exe_ext") 
289       if $d_dosuid;
290 }
291
292 # Offer to install perl in a "standard" location
293
294 my $mainperl_is_instperl = 0;
295
296 if ($Config{installusrbinperl} eq 'define' &&
297     !$versiononly && !$nonono && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR
298         && -w $mainperldir && ! samepath($mainperldir, $installbin)) {
299     my($usrbinperl)     = "$mainperldir/$perl$exe_ext";
300     my($instperl)       = "$installbin/$perl$exe_ext";
301     my($expinstperl)    = "$binexp/$perl$exe_ext";
302
303     # First make sure $usrbinperl is not already the same as the perl we
304     # just installed.
305     if (-x $usrbinperl) {
306         # Try to be clever about mainperl being a symbolic link
307         # to binexp/perl if binexp and installbin are different.
308         $mainperl_is_instperl =
309             samepath($usrbinperl, $instperl) ||
310             samepath($usrbinperl, $expinstperl) ||
311              (($binexp ne $installbin) &&
312               (-l $usrbinperl) &&
313               ((readlink $usrbinperl) eq $expinstperl));
314     }
315     if ((! $mainperl_is_instperl) &&
316         (yn("Many scripts expect perl to be installed as $usrbinperl.\n" . 
317              "Do you wish to have $usrbinperl be the same as\n" .
318              "$expinstperl? [y] ")))
319     {
320         unlink($usrbinperl);
321         ( $Config{'d_link'} eq 'define' &&
322           eval { CORE::link $instperl, $usrbinperl } )  ||
323         eval { symlink $expinstperl, $usrbinperl }      ||
324         copy($instperl, $usrbinperl);
325
326         $mainperl_is_instperl = 1;
327     }
328 }
329
330 # Make links to ordinary names if installbin directory isn't current directory.
331
332 if (!$versiononly && ! samepath($installbin, 'x2p')) {
333     safe_unlink("$installbin/a2p$exe_ext");
334     copy("x2p/a2p$exe_ext", "$installbin/a2p$exe_ext");
335     chmod(0755, "$installbin/a2p$exe_ext");
336 }
337
338 # cppstdin is just a script, but it is architecture-dependent, so
339 # it can't safely be shared.  Place it in $installbin.
340 # Note that Configure doesn't build cppstin if it isn't needed, so
341 # we skip this if cppstdin doesn't exist.
342 if (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) {
343     safe_unlink("$installbin/cppstdin");
344     copy("cppstdin", "$installbin/cppstdin");
345     chmod(0755, "$installbin/cppstdin");
346 }
347
348 # Install scripts.
349
350 mkpath($installscript, 1, 0777);
351
352 if (! $versiononly) {
353     for (@scripts) {
354         (my $base = $_) =~ s#.*/##;
355         copy($_, "$installscript/$base");
356         chmod(0755, "$installscript/$base");
357     }
358 }
359
360 # pstruct should be a link to c2ph
361
362 if (! $versiononly) {
363     safe_unlink("$installscript/pstruct$scr_ext");
364     if ($^O eq 'dos' or $Is_VMS) {
365         copy("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext"); 
366     } else {
367         link("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext");
368     }
369 }
370
371 # Install pod pages.  Where? I guess in $installprivlib/pod
372 # ($installprivlib/pods for cygwin).
373
374 my $pod = $Is_Cygwin ? 'pods' : 'pod';
375 unless ( $versiononly && !($installprivlib =~ m/\Q$]/)) {
376     mkpath("${installprivlib}/$pod", 1, 0777);
377
378     # If Perl 5.003's perldiag.pod is there, rename it.
379     if (open POD, "${installprivlib}/$pod/perldiag.pod") {
380         read POD, $_, 4000;
381         close POD;
382         # Some of Perl 5.003's diagnostic messages ended with periods.
383         if (/^=.*\.$/m) {
384             my ($from, $to) = ("${installprivlib}/$pod/perldiag.pod",
385                                "${installprivlib}/$pod/perldiag-5.003.pod");
386             print "  rename $from $to";
387             rename($from, $to)
388                 or warn "Couldn't rename $from to $to: $!\n"
389                 unless $nonono;
390         }
391     }
392
393     for (@pods) {
394         # $_ is a name like  pod/perl.pod
395         (my $base = $_) =~ s#.*/##;
396         copy_if_diff($_, "${installprivlib}/$pod/${base}");
397     }
398
399 }
400
401 # Check to make sure there aren't other perls around in installer's
402 # path.  This is probably UNIX-specific.  Check all absolute directories
403 # in the path except for where public executables are supposed to live.
404 # Also skip $mainperl if the user opted to have it be a link to the
405 # installed perl.
406
407 if (!$versiononly) {
408         my ($path, @path);
409     my $dirsep = ($Is_OS2 || $Is_W32) ? ';' : ':' ;
410     ($path = $ENV{"PATH"}) =~ s:\\:/:g ;
411     @path = split(/$dirsep/, $path);
412     if ($Is_VMS) {
413         my $i = 0;
414         while (exists $ENV{'DCL$PATH' . $i}) {
415             my $dir = unixpath($ENV{'DCL$PATH' . $i});  $dir =~ s-/$--;
416             push(@path,$dir);
417         }
418     }
419     my @otherperls;
420     my %otherperls;
421     for (@path) {
422         next unless m,^/,;
423         # Use &samepath here because some systems have other dirs linked
424         # to $mainperldir (like SunOS)
425         next if samepath($_, $binexp);
426         next if ($mainperl_is_instperl && samepath($_, $mainperldir));
427         my $otherperl = "$_/$perl$exe_ext";
428         next if $otherperls{$otherperl}++;
429         push(@otherperls, $otherperl)
430             if (-x $otherperl && ! -d $otherperl);
431     }
432     if (@otherperls) {
433         print STDERR "\nWarning: $perl appears in your path in the following " .
434             "locations beyond where\nwe just installed it:\n";
435         for (@otherperls) {
436             print STDERR "    ", $_, "\n";
437         }
438         print STDERR "\n";
439     }
440
441 }
442
443 $packlist->write() unless $nonono;
444 print "  Installation complete\n";
445
446 exit 0;
447
448 ###############################################################################
449
450 sub yn {
451     my($prompt) = @_;
452     my($answer);
453     my($default) = $prompt =~ m/\[([yn])\]\s*$/i;
454     print $prompt;
455     chop($answer = <STDIN>);
456     $answer = $default if $answer =~ m/^\s*$/;
457     ($answer =~ m/^[yY]/);
458 }
459
460 sub unlink {
461     my(@names) = @_;
462     my($cnt) = 0;
463
464     return scalar(@names) if $Is_VMS;
465
466     foreach my $name (@names) {
467         next unless -e $name;
468         chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_Cygwin);
469         print "  unlink $name\n";
470         ( CORE::unlink($name) and ++$cnt 
471           or warn "Couldn't unlink $name: $!\n" ) unless $nonono;
472     }
473     return $cnt;
474 }
475
476 sub safe_unlink {
477     return if $nonono or $Is_VMS;
478     my @names = @_;
479     foreach my $name (@names) {
480         next unless -e $name;
481         chmod 0777, $name if ($Is_OS2 || $Is_W32);
482         print "  unlink $name\n";
483         next if CORE::unlink($name);
484         warn "Couldn't unlink $name: $!\n";
485         if ($! =~ /busy/i) {
486             print "  mv $name $name.old\n";
487             safe_rename($name, "$name.old")
488                 or warn "Couldn't rename $name: $!\n";
489         }
490     }
491 }
492
493 sub safe_rename {
494     my($from,$to) = @_;
495     if (-f $to and not unlink($to)) {
496         my($i);
497         for ($i = 1; $i < 50; $i++) {
498             last if rename($to, "$to.$i");
499         }
500         warn("Cannot rename to `$to.$i': $!"), return 0 
501            if $i >= 50; # Give up!
502     }
503     link($from,$to) || return 0;
504     unlink($from);
505 }
506
507 sub link {
508     my($from,$to) = @_;
509     my($success) = 0;
510
511     print "  ln $from $to\n";
512     eval {
513         CORE::link($from, $to)
514             ? $success++
515             : ($from =~ m#^/afs/# || $to =~ m#^/afs/#)
516               ? die "AFS"  # okay inside eval {}
517               : warn "Couldn't link $from to $to: $!\n"
518           unless $nonono;
519         $packlist->{$to} = { from => $from, type => 'link' };
520     };
521     if ($@) {
522         print "  creating new version of $to\n" if $Is_VMS and -e $to;
523         File::Copy::copy($from, $to)
524             ? $success++
525             : warn "Couldn't copy $from to $to: $!\n"
526           unless $nonono;
527         $packlist->{$to} = { type => 'file' };
528     }
529     $success;
530 }
531
532 sub chmod {
533     my($mode,$name) = @_;
534
535     return if ($^O eq 'dos');
536     printf "  chmod %o %s\n", $mode, $name;
537     CORE::chmod($mode,$name)
538         || warn sprintf("Couldn't chmod %o %s: $!\n", $mode, $name)
539       unless $nonono;
540 }
541
542 sub copy {
543     my($from,$to) = @_;
544
545     print "  cp $from $to\n";
546     print "  creating new version of $to\n" if $Is_VMS and -e $to;
547     File::Copy::copy($from, $to)
548         || warn "Couldn't copy $from to $to: $!\n"
549       unless $nonono;
550     $packlist->{$to} = { type => 'file' };
551 }
552
553 sub samepath {
554     my($p1, $p2) = @_;
555
556     return (lc($p1) eq lc($p2)) if $Is_W32;
557
558     if ($p1 ne $p2) {
559         my($dev1, $ino1, $dev2, $ino2);
560         ($dev1, $ino1) = stat($p1);
561         ($dev2, $ino2) = stat($p2);
562         ($dev1 == $dev2 && $ino1 == $ino2);
563     }
564     else {
565         1;
566     }
567 }
568
569 sub installlib {
570     my $dir = $File::Find::dir;
571     $dir =~ s#^\.(?![^/])/?##;
572     local($depth) = $dir ? "lib/$dir" : "lib";
573
574     my $name = $_;
575
576     # Ignore RCS and CVS directories.
577     if (($name eq 'CVS' or $name eq 'RCS') and -d $name) {
578         $File::Find::prune = 1;
579         return;
580     }
581     
582     # ignore patch backups, RCS files, emacs backup & temp files and the
583     # .exists files.
584     return if $name =~ m{\.orig$|~$|^#.+#$|,v$|^\.exists};
585
586     $name = "$dir/$name" if $dir ne '';
587
588     my $installlib = $installprivlib;
589     if ($dir =~ /^auto/ ||
590           ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) ||
591           ($name =~ /^(.*)\.(?:h|lib)$/i && $Is_W32)
592        ) {
593         $installlib = $installarchlib;
594         return unless $do_installarchlib;
595     } else {
596         return unless $do_installprivlib;
597     }
598
599     if (-f $_) {
600         if (/\.(?:al|ix)$/ && !($dir =~ m[^auto/(.*)$] && $archpms{$1})) {
601             $installlib = $installprivlib;
602             #We're installing *.al and *.ix files into $installprivlib,
603             #but we have to delete old *.al and *.ix files from the 5.000
604             #distribution:
605             #This might not work because $archname might have changed.
606             unlink("$installarchlib/$name");
607         }
608         $packlist->{"$installlib/$name"} = { type => 'file' };
609         if (compare($_, "$installlib/$name") || $nonono) {
610             unlink("$installlib/$name");
611             mkpath("$installlib/$dir", 1, 0777);
612             # HP-UX (at least) needs to maintain execute permissions
613             # on dynamically-loaded libraries.
614             copy_if_diff($_, "$installlib/$name")
615                 and chmod($name =~ /\.(so|$dlext)$/o ? 0555 : 0444,
616                            "$installlib/$name");
617         }
618     }
619 }
620
621 # Copy $from to $to, only if $from is different than $to.
622 # Also preserve modification times for .a libraries.
623 # On some systems, if you do
624 #   ranlib libperl.a
625 #   cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a
626 # and then try to link against the installed libperl.a, you might
627 # get an error message to the effect that the symbol table is older
628 # than the library.
629 # Return true if copying occurred.
630
631 sub copy_if_diff {
632     my($from,$to)=@_;
633     return 1 if (($^O eq 'VMS') && (-d $from));
634     -f $from || die "$0: $from not found";
635     $packlist->{$to} = { type => 'file' };
636     if (compare($from, $to) || $nonono) {
637         safe_unlink($to);   # In case we don't have write permissions.
638         if ($nonono) {
639             $from = $depth . "/" . $from if $depth;
640         }
641         copy($from, $to);
642         # Restore timestamps if it's a .a library or for OS/2.
643         if (!$nonono && ($Is_OS2 || $to =~ /\.a$/)) {
644             my ($atime, $mtime) = (stat $from)[8,9];
645             utime $atime, $mtime, $to;
646         }
647         1;
648     }
649 }
650
651 sub strip
652 {
653     my(@args) = @_;
654
655     my @opts;
656     while (@args && $args[0] =~ /^(-\w+)$/) {
657         push @opts, shift @args;
658     }
659
660     foreach my $file (@args) {
661         if (-f $file) {
662             print "  strip $file\n";
663             system("strip", @opts, $file);
664         } else {
665             print "# file '$file' skipped\n";
666         }
667     }
668 }
669