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