This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Quick integration of mainline changes to date
[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 eq 'cygwin';
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.6.0".
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.6.0".
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 my @scripts = qw(utils/c2ph utils/h2ph utils/h2xs utils/perlbug utils/perldoc
58                 utils/pl2pm utils/splain utils/perlcc utils/dprofpp
59                 x2p/s2p x2p/find2perl 
60                 pod/pod2man pod/pod2html pod/pod2latex pod/pod2text
61                 pod/pod2usage pod/podchecker pod/podselect);
62
63 if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; }
64
65 my @pods = (<pod/*.pod>);
66
67 # Specify here any .pm files that are actually architecture-dependent.
68 # (Those included with XS extensions under ext/ are automatically
69 # added later.)
70 # Now that the default privlib has the full perl version number included,
71 # we no longer have to play the trick of sticking version-specific .pm 
72 # files under the archlib directory.
73 my %archpms = (
74     Config => 1, 
75 );
76
77 if ($^O eq 'dos') {
78     push(@scripts,'djgpp/fixpmain');
79     $archpms{config} = $archpms{filehand} = 1;
80 }
81
82 if ((-e "testcompile") && (defined($ENV{'COMPILE'})))
83 {
84         push(@scripts, map("$_.exe", @scripts));
85 }
86
87 find(sub {
88         if ("$File::Find::dir/$_" =~ m{^ext/[^/]+/(.*)\.pm$}) {
89             (my $pm = $1) =~ s{^lib/}{};
90             $archpms{$pm} = 1;
91         }
92     }, 'ext');
93
94 my $ver = $Config{version};
95 my $release = substr($],0,3);   # Not used presently.
96 my $patchlevel = substr($],3,2);
97 die "Patchlevel of perl ($patchlevel)",
98     "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n"
99         if $patchlevel != $Config{'PERL_VERSION'};
100
101 # Fetch some frequently-used items from %Config
102 my $installbin = $Config{installbin};
103 my $installscript = $Config{installscript};
104 my $installprivlib = $Config{installprivlib};
105 my $installarchlib = $Config{installarchlib};
106 my $installsitelib = $Config{installsitelib};
107 my $installsitearch = $Config{installsitearch};
108 my $installman1dir = $Config{installman1dir};
109 my $man1ext = $Config{man1ext};
110 my $libperl = $Config{libperl};
111 # Shared library and dynamic loading suffixes.
112 my $so = $Config{so};
113 my $dlext = $Config{dlext};
114 my $dlsrc = $Config{dlsrc};
115
116 my $d_dosuid = $Config{d_dosuid};
117 my $binexp = $Config{binexp};
118
119 if ($Is_VMS) {  # Hang in there until File::Spec hits the big time
120     foreach ( \$installbin,     \$installscript,  \$installprivlib,
121               \$installarchlib, \$installsitelib, \$installsitearch,
122               \$installman1dir ) {
123       $$_ = unixify($$_);  $$_ =~ s:/$::;
124     }
125 }
126
127 # Do some quick sanity checks.
128
129 if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
130
131    $installbin          || die "No installbin directory in config.sh\n";
132 -d $installbin          || mkpath($installbin, 1, 0777);
133 -d $installbin          || $nonono || die "$installbin is not a directory\n";
134 -w $installbin          || $nonono || die "$installbin is not writable by you\n"
135         unless $installbin =~ m#^/afs/# || $nonono;
136
137 -x 'perl' . $exe_ext    || die "perl isn't executable!\n";
138 -x 'suidperl' . $exe_ext|| die "suidperl isn't executable!\n" if $d_dosuid;
139
140 -x 't/TEST'             || $Is_W32
141                         || warn "WARNING: You've never run 'make test'!!!",
142                                 "  (Installing anyway.)\n";
143
144 if ($Is_W32 or $Is_Cygwin) {
145   my $perldll;
146
147 if ($Is_Cygwin) {
148   $perldll = $libperl;
149   $perldll =~ s/(\..*)?$/.$dlext/;
150   if ($Config{useshrplib} eq 'true') {
151     # install ld2 and perlld as well
152     foreach ('ld2', 'perlld') {
153       safe_unlink("$installbin/$_");
154       copy("$_", "$installbin/$_");
155       chmod(0755, "$installbin/$_");
156     };
157   };
158 } else {
159   $perldll = 'perl.' . $dlext;
160   $perldll = 'perl56.' . $dlext if $Config{'ccflags'} =~ /PERL_OBJECT/i;
161 }
162
163    if ($dlsrc ne "dl_none.xs") {
164       -f $perldll || die "No perl DLL built\n";
165    }
166 # Install the DLL
167
168    safe_unlink("$installbin/$perldll");
169    copy("$perldll", "$installbin/$perldll");
170    chmod(0755, "$installbin/$perldll");
171    
172 } # if ($Is_W32 or $Is_Cygwin)
173
174 # This will be used to store the packlist
175 my $packlist = ExtUtils::Packlist->new("$installarchlib/.packlist");
176
177 # First we install the version-numbered executables.
178
179 if ($Is_VMS) {
180     safe_unlink("$installbin/$perl$exe_ext");
181     copy("perl$exe_ext", "$installbin/$perl$exe_ext");
182     chmod(0755, "$installbin/$perl$exe_ext");
183     safe_unlink("$installbin/${perl}shr$exe_ext");
184     copy("perlshr$exe_ext", "$installbin/${perl}shr$exe_ext");
185     chmod(0755, "$installbin/${perl}shr$exe_ext");
186 }
187 elsif ($^O eq 'mpeix') {
188     # MPE lacks hard links and requires that executables with special
189     # capabilities reside in the MPE namespace.
190     safe_unlink("$installbin/perl$ver$exe_ext", $Config{perlpath});
191     # Install the primary executable into the MPE namespace as perlpath.
192     copy("perl$exe_ext", $Config{perlpath});
193     chmod(0755, $Config{perlpath});
194     # Create a backup copy with the version number.
195     link($Config{perlpath}, "$installbin/perl$ver$exe_ext");
196 }
197 elsif ($^O ne 'dos') {
198     safe_unlink("$installbin/$perl_verbase$ver$exe_ext");
199     copy("perl$exe_ext", "$installbin/$perl_verbase$ver$exe_ext");
200     strip("$installbin/$perl_verbase$ver$exe_ext") if $^O =~ /^(rhapsody)$/;
201     chmod(0755, "$installbin/$perl_verbase$ver$exe_ext");
202 }
203 else {
204     safe_unlink("$installbin/$perl.exe");
205     copy("perl.exe", "$installbin/$perl.exe");
206 }
207
208 safe_unlink("$installbin/s$perl_verbase$ver$exe_ext");
209 if ($d_dosuid) {
210     copy("suidperl$exe_ext", "$installbin/s$perl_verbase$ver$exe_ext");
211     chmod(04711, "$installbin/s$perl_verbase$ver$exe_ext");
212 }
213
214 # Install library files.
215
216 my ($do_installarchlib, $do_installprivlib) = (0, 0);
217     
218 mkpath($installprivlib, 1, 0777);
219 mkpath($installarchlib, 1, 0777);
220 mkpath($installsitelib, 1, 0777) if ($installsitelib);
221 mkpath($installsitearch, 1, 0777) if ($installsitearch);
222
223 if (chdir "lib") {
224     $do_installarchlib = ! samepath($installarchlib, '.');
225     $do_installprivlib = ! samepath($installprivlib, '.');
226     $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$ver/);
227
228     if ($do_installarchlib || $do_installprivlib) {
229         find(\&installlib, '.');
230     }
231     chdir ".." || die "Can't cd back to source directory: $!\n";
232 }
233 else {
234     warn "Can't cd to lib to install lib files: $!\n";
235 }
236
237 # Install header files and libraries.
238 mkpath("$installarchlib/CORE", 1, 0777);
239 my @corefiles;
240 if ($Is_VMS) {  # We did core file selection during build
241     my $coredir = "lib/$Config{'arch'}/$ver";
242     $coredir =~ tr/./_/;
243     @corefiles = <$coredir/*.*>;
244 }
245 else {
246     # [als] hard-coded 'libperl' name... not good!
247     @corefiles = <*.h libperl*.*>;
248
249     # AIX needs perl.exp installed as well.
250     push(@corefiles,'perl.exp') if $^O eq 'aix';
251     if ($^O eq 'mpeix') {
252         # MPE needs mpeixish.h installed as well.
253         mkpath("$installarchlib/CORE/mpeix", 1, 0777);
254         push(@corefiles,'mpeix/mpeixish.h');
255     }
256     # If they have built sperl.o...
257     push(@corefiles,'sperl.o') if -f 'sperl.o';
258 }
259 foreach my $file (@corefiles) {
260     # HP-UX (at least) needs to maintain execute permissions
261     # on dynamically-loadable libraries. So we do it for all.
262     if (copy_if_diff($file,"$installarchlib/CORE/$file")) {
263         if ($file =~ /\.(so|\Q$dlext\E)$/) {
264             chmod(0555, "$installarchlib/CORE/$file");
265             strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody)$/;
266         } else {
267             chmod(0444, "$installarchlib/CORE/$file");
268         }
269     }
270 }
271
272 # Install main perl executables
273 # Make links to ordinary names if installbin directory isn't current directory.
274
275 if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) {
276     safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext");
277     if ($^O eq 'mpeix') {
278         # MPE doesn't support hard links, so use a symlink.
279         # We don't want another cloned copy.
280         symlink($Config{perlpath}, "$installbin/perl$exe_ext");
281     } else {
282         link("$installbin/$perl_verbase$ver$exe_ext",
283                 "$installbin/$perl$exe_ext");
284     }
285     link("$installbin/s$perl_verbase$ver$exe_ext",
286             "$installbin/suid$perl$exe_ext") 
287       if $d_dosuid;
288 }
289
290 # Offer to install perl in a "standard" location
291
292 my $mainperl_is_instperl = 0;
293
294 if ($Config{installusrbinperl} eq 'define' &&
295     !$versiononly && !$nonono && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR
296         && -w $mainperldir && ! samepath($mainperldir, $installbin)) {
297     my($usrbinperl)     = "$mainperldir/$perl$exe_ext";
298     my($instperl)       = "$installbin/$perl$exe_ext";
299     my($expinstperl)    = "$binexp/$perl$exe_ext";
300
301     # First make sure $usrbinperl is not already the same as the perl we
302     # just installed.
303     if (-x $usrbinperl) {
304         # Try to be clever about mainperl being a symbolic link
305         # to binexp/perl if binexp and installbin are different.
306         $mainperl_is_instperl =
307             samepath($usrbinperl, $instperl) ||
308             samepath($usrbinperl, $expinstperl) ||
309              (($binexp ne $installbin) &&
310               (-l $usrbinperl) &&
311               ((readlink $usrbinperl) eq $expinstperl));
312     }
313     if ((! $mainperl_is_instperl) &&
314         (yn("Many scripts expect perl to be installed as $usrbinperl.\n" . 
315              "Do you wish to have $usrbinperl be the same as\n" .
316              "$expinstperl? [y] ")))
317     {
318         unlink($usrbinperl);
319         ( $Config{'d_link'} eq 'define' &&
320           eval { CORE::link $instperl, $usrbinperl } )  ||
321         eval { symlink $expinstperl, $usrbinperl }      ||
322         copy($instperl, $usrbinperl);
323
324         $mainperl_is_instperl = 1;
325     }
326 }
327
328 # Make links to ordinary names if installbin directory isn't current directory.
329
330 if (!$versiononly && ! samepath($installbin, 'x2p')) {
331     safe_unlink("$installbin/a2p$exe_ext");
332     copy("x2p/a2p$exe_ext", "$installbin/a2p$exe_ext");
333     chmod(0755, "$installbin/a2p$exe_ext");
334 }
335
336 # cppstdin is just a script, but it is architecture-dependent, so
337 # it can't safely be shared.  Place it in $installbin.
338 # Note that Configure doesn't build cppstin if it isn't needed, so
339 # we skip this if cppstdin doesn't exist.
340 if (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) {
341     safe_unlink("$installbin/cppstdin");
342     copy("cppstdin", "$installbin/cppstdin");
343     chmod(0755, "$installbin/cppstdin");
344 }
345
346 # Install scripts.
347
348 mkpath($installscript, 1, 0777);
349
350 if (! $versiononly) {
351     for (@scripts) {
352         (my $base = $_) =~ s#.*/##;
353         copy($_, "$installscript/$base");
354         chmod(0755, "$installscript/$base");
355     }
356 }
357
358 # pstruct should be a link to c2ph
359
360 if (! $versiononly) {
361     safe_unlink("$installscript/pstruct$scr_ext");
362     if ($^O eq 'dos' or $Is_VMS) {
363         copy("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext"); 
364     } else {
365         link("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext");
366     }
367 }
368
369 # Install pod pages.  Where? I guess in $installprivlib/pod
370 # ($installprivlib/pods for cygwin).
371
372 my $pod = $Is_Cygwin ? 'pods' : 'pod';
373 unless ( $versiononly && !($installprivlib =~ m/\Q$ver/)) {
374     mkpath("${installprivlib}/$pod", 1, 0777);
375
376     # If Perl 5.003's perldiag.pod is there, rename it.
377     if (open POD, "${installprivlib}/$pod/perldiag.pod") {
378         read POD, $_, 4000;
379         close POD;
380         # Some of Perl 5.003's diagnostic messages ended with periods.
381         if (/^=.*\.$/m) {
382             my ($from, $to) = ("${installprivlib}/$pod/perldiag.pod",
383                                "${installprivlib}/$pod/perldiag-5.003.pod");
384             print "  rename $from $to";
385             rename($from, $to)
386                 or warn "Couldn't rename $from to $to: $!\n"
387                 unless $nonono;
388         }
389     }
390
391     for (@pods) {
392         # $_ is a name like  pod/perl.pod
393         (my $base = $_) =~ s#.*/##;
394         copy_if_diff($_, "${installprivlib}/$pod/${base}");
395     }
396
397 }
398
399 # Check to make sure there aren't other perls around in installer's
400 # path.  This is probably UNIX-specific.  Check all absolute directories
401 # in the path except for where public executables are supposed to live.
402 # Also skip $mainperl if the user opted to have it be a link to the
403 # installed perl.
404
405 if (!$versiononly) {
406     my ($path, @path);
407     my $dirsep = ($Is_OS2 || $Is_W32) ? ';' : ':' ;
408     ($path = $ENV{"PATH"}) =~ s:\\:/:g ;
409     @path = split(/$dirsep/, $path);
410     if ($Is_VMS) {
411         my $i = 0;
412         while (exists $ENV{'DCL$PATH' . $i}) {
413             my $dir = unixpath($ENV{'DCL$PATH' . $i});  $dir =~ s-/$--;
414             push(@path,$dir);
415         }
416     }
417     my @otherperls;
418     my %otherperls;
419     for (@path) {
420         next unless m,^/,;
421         # Use &samepath here because some systems have other dirs linked
422         # to $mainperldir (like SunOS)
423         next if samepath($_, $binexp);
424         next if ($mainperl_is_instperl && samepath($_, $mainperldir));
425         my $otherperl = "$_/$perl$exe_ext";
426         next if $otherperls{$otherperl}++;
427         push(@otherperls, $otherperl)
428             if (-x $otherperl && ! -d $otherperl);
429     }
430     if (@otherperls) {
431         print STDERR "\nWarning: $perl appears in your path in the following " .
432             "locations beyond where\nwe just installed it:\n";
433         for (@otherperls) {
434             print STDERR "    ", $_, "\n";
435         }
436         print STDERR "\n";
437     }
438
439 }
440
441 $packlist->write() unless $nonono;
442 print "  Installation complete\n";
443
444 exit 0;
445
446 ###############################################################################
447
448 sub yn {
449     my($prompt) = @_;
450     my($answer);
451     my($default) = $prompt =~ m/\[([yn])\]\s*$/i;
452     print $prompt;
453     chop($answer = <STDIN>);
454     $answer = $default if $answer =~ m/^\s*$/;
455     ($answer =~ m/^[yY]/);
456 }
457
458 sub unlink {
459     my(@names) = @_;
460     my($cnt) = 0;
461
462     return scalar(@names) if $Is_VMS;
463
464     foreach my $name (@names) {
465         next unless -e $name;
466         chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_Cygwin);
467         print "  unlink $name\n";
468         ( CORE::unlink($name) and ++$cnt 
469           or warn "Couldn't unlink $name: $!\n" ) unless $nonono;
470     }
471     return $cnt;
472 }
473
474 sub safe_unlink {
475     return if $nonono or $Is_VMS;
476     my @names = @_;
477     foreach my $name (@names) {
478         next unless -e $name;
479         chmod 0777, $name if ($Is_OS2 || $Is_W32);
480         print "  unlink $name\n";
481         next if CORE::unlink($name);
482         warn "Couldn't unlink $name: $!\n";
483         if ($! =~ /busy/i) {
484             print "  mv $name $name.old\n";
485             safe_rename($name, "$name.old")
486                 or warn "Couldn't rename $name: $!\n";
487         }
488     }
489 }
490
491 sub safe_rename {
492     my($from,$to) = @_;
493     if (-f $to and not unlink($to)) {
494         my($i);
495         for ($i = 1; $i < 50; $i++) {
496             last if rename($to, "$to.$i");
497         }
498         warn("Cannot rename to `$to.$i': $!"), return 0 
499            if $i >= 50; # Give up!
500     }
501     link($from,$to) || return 0;
502     unlink($from);
503 }
504
505 sub link {
506     my($from,$to) = @_;
507     my($success) = 0;
508
509     print "  ln $from $to\n";
510     eval {
511         CORE::link($from, $to)
512             ? $success++
513             : ($from =~ m#^/afs/# || $to =~ m#^/afs/#)
514               ? die "AFS"  # okay inside eval {}
515               : die "Couldn't link $from to $to: $!\n"
516           unless $nonono;
517         $packlist->{$to} = { from => $from, type => 'link' };
518     };
519     if ($@) {
520         warn $@;
521         print "  cp $from $to\n";
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