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