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