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