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'; |
a29d2910 |
8 | } |
9 | |
10 | use strict; |
5f675712 |
11 | my ($Is_VMS, $Is_W32, $Is_OS2, $Is_Cygwin, $nonono, $dostrip, |
94b11c62 |
12 | $versiononly, $silent, $verbose, $otherperls); |
5f675712 |
13 | use vars qw /$depth/; |
a29d2910 |
14 | |
15 | BEGIN { |
17f28c40 |
16 | $Is_VMS = $^O eq 'VMS'; |
4a71ed0c |
17 | $Is_W32 = $^O eq 'MSWin32'; |
18 | $Is_OS2 = $^O eq 'os2'; |
146174a9 |
19 | $Is_Cygwin = $^O eq 'cygwin'; |
17f28c40 |
20 | if ($Is_VMS) { eval 'use VMS::Filespec;' } |
68dc0745 |
21 | } |
22 | |
c2cd2081 |
23 | my $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : ''); |
4a71ed0c |
24 | |
a0d0e21e |
25 | use File::Find; |
5f05dabc |
26 | use File::Compare; |
68dc0745 |
27 | use File::Copy (); |
0ecb046b |
28 | use File::Path (); |
354f3b56 |
29 | use ExtUtils::Packlist; |
4633a7c4 |
30 | use Config; |
91a06757 |
31 | use subs qw(unlink link chmod); |
c623bd54 |
32 | |
0ecb046b |
33 | # override the ones in the rest of the script |
68dc0745 |
34 | sub mkpath { |
35 | File::Path::mkpath(@_) unless $nonono; |
0ecb046b |
36 | } |
37 | |
c2cd2081 |
38 | my $mainperldir = "/usr/bin"; |
39 | my $exe_ext = $Config{exe_ext}; |
bee1dbe2 |
40 | |
6ee623d5 |
41 | # Allow ``make install PERLNAME=something_besides_perl'': |
c2cd2081 |
42 | my $perl = defined($ENV{PERLNAME}) ? $ENV{PERLNAME} : 'perl'; |
6ee623d5 |
43 | |
146174a9 |
44 | # This is the base used for versioned names, like "perl5.6.0". |
beb13193 |
45 | # It's separate because a common use of $PERLNAME is to install |
46 | # perl as "perl5", if that's used as base for versioned files you |
146174a9 |
47 | # get "perl55.6.0". |
beb13193 |
48 | my $perl_verbase = defined($ENV{PERLNAME_VERBASE}) |
49 | ? $ENV{PERLNAME_VERBASE} |
50 | : $perl; |
51 | |
5f675712 |
52 | $otherperls = 1; |
c623bd54 |
53 | while (@ARGV) { |
54 | $nonono = 1 if $ARGV[0] eq '-n'; |
f556e5b9 |
55 | $dostrip = 1 if $ARGV[0] eq '-s'; |
c623bd54 |
56 | $versiononly = 1 if $ARGV[0] eq '-v'; |
5f675712 |
57 | $silent = 1 if $ARGV[0] eq '-S'; |
58 | $otherperls = 0 if $ARGV[0] eq '-o'; |
4ad019ef |
59 | $verbose = 1 if $ARGV[0] eq '-V' || $ARGV [0] eq '-n'; |
c623bd54 |
60 | shift; |
61 | } |
62 | |
d56c5707 |
63 | $versiononly = 1 if $Config{versiononly}; |
64 | |
c2cd2081 |
65 | my @scripts = qw(utils/c2ph utils/h2ph utils/h2xs utils/perlbug utils/perldoc |
95667ae4 |
66 | utils/pl2pm utils/splain utils/perlcc utils/dprofpp |
6ee623d5 |
67 | x2p/s2p x2p/find2perl |
360aca43 |
68 | pod/pod2man pod/pod2html pod/pod2latex pod/pod2text |
69 | pod/pod2usage pod/podchecker pod/podselect); |
16d20bd9 |
70 | |
4a71ed0c |
71 | if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; } |
17f28c40 |
72 | |
c2cd2081 |
73 | my @pods = (<pod/*.pod>); |
c623bd54 |
74 | |
e8ea6127 |
75 | # Specify here any .pm files that are actually architecture-dependent. |
76 | # (Those included with XS extensions under ext/ are automatically |
77 | # added later.) |
78 | # Now that the default privlib has the full perl version number included, |
79 | # we no longer have to play the trick of sticking version-specific .pm |
80 | # files under the archlib directory. |
c2cd2081 |
81 | my %archpms = ( |
e8ea6127 |
82 | Config => 1, |
a8efb694 |
83 | lib => 1, |
38b8243a |
84 | ); |
39e571d4 |
85 | |
86 | if ($^O eq 'dos') { |
87 | push(@scripts,'djgpp/fixpmain'); |
88 | $archpms{config} = $archpms{filehand} = 1; |
89 | } |
90 | |
6ee623d5 |
91 | if ((-e "testcompile") && (defined($ENV{'COMPILE'}))) |
92 | { |
93 | push(@scripts, map("$_.exe", @scripts)); |
94 | } |
95 | |
1dd15ed4 |
96 | find(sub { |
68c887af |
97 | if ("$File::Find::dir/$_" =~ m{^ext\b(.*)/([^/]+)\.pm$}) { |
98 | my($path, $modname) = ($1,$2); |
99 | |
100 | # strip trailing component first |
101 | $path =~ s{/[^/]*$}{}; |
102 | |
103 | # strip optional "/lib"; |
104 | $path =~ s{/lib\b}{}; |
105 | |
106 | # strip any leading / |
107 | $path =~ s{^/}{}; |
108 | |
109 | # reconstitute canonical module name |
110 | $modname = "$path/$modname" if length $path; |
111 | |
112 | # remember it |
113 | $archpms{$modname} = 1; |
1dd15ed4 |
114 | } |
115 | }, 'ext'); |
116 | |
68c887af |
117 | # print "[$_]\n" for sort keys %archpms; |
118 | |
146174a9 |
119 | my $ver = $Config{version}; |
f2766b05 |
120 | my $release = substr($],0,3); # Not used currently. |
03284eb6 |
121 | my $patchlevel = substr($],3,2); |
748a9306 |
122 | die "Patchlevel of perl ($patchlevel)", |
cceca5ed |
123 | "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n" |
124 | if $patchlevel != $Config{'PERL_VERSION'}; |
4633a7c4 |
125 | |
126 | # Fetch some frequently-used items from %Config |
c2cd2081 |
127 | my $installbin = $Config{installbin}; |
128 | my $installscript = $Config{installscript}; |
129 | my $installprivlib = $Config{installprivlib}; |
130 | my $installarchlib = $Config{installarchlib}; |
131 | my $installsitelib = $Config{installsitelib}; |
132 | my $installsitearch = $Config{installsitearch}; |
133 | my $installman1dir = $Config{installman1dir}; |
134 | my $man1ext = $Config{man1ext}; |
135 | my $libperl = $Config{libperl}; |
4633a7c4 |
136 | # Shared library and dynamic loading suffixes. |
c2cd2081 |
137 | my $so = $Config{so}; |
138 | my $dlext = $Config{dlext}; |
146174a9 |
139 | my $dlsrc = $Config{dlsrc}; |
f2766b05 |
140 | if ($^O eq 'os390') { |
141 | my $pwd; |
142 | chomp($pwd=`pwd`); |
143 | my $archlibexp = $Config{archlibexp}; |
144 | my $usedl = $Config{usedl}; |
145 | if ($usedl eq 'define') { |
146 | `./$^X -pibak -e 's{$pwd\/libperl.x}{$archlibexp/CORE/libperl.x}' lib/Config.pm`; |
147 | } |
148 | } |
4633a7c4 |
149 | |
c2cd2081 |
150 | my $d_dosuid = $Config{d_dosuid}; |
151 | my $binexp = $Config{binexp}; |
c623bd54 |
152 | |
17f28c40 |
153 | if ($Is_VMS) { # Hang in there until File::Spec hits the big time |
154 | foreach ( \$installbin, \$installscript, \$installprivlib, |
155 | \$installarchlib, \$installsitelib, \$installsitearch, |
156 | \$installman1dir ) { |
157 | $$_ = unixify($$_); $$_ =~ s:/$::; |
158 | } |
159 | } |
160 | |
c623bd54 |
161 | # Do some quick sanity checks. |
162 | |
163 | if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; } |
164 | |
fe14fcc3 |
165 | $installbin || die "No installbin directory in config.sh\n"; |
7e7af249 |
166 | -d $installbin || mkpath($installbin, $verbose, 0777); |
0ecb046b |
167 | -d $installbin || $nonono || die "$installbin is not a directory\n"; |
168 | -w $installbin || $nonono || die "$installbin is not writable by you\n" |
3edbfbe5 |
169 | unless $installbin =~ m#^/afs/# || $nonono; |
c623bd54 |
170 | |
39add537 |
171 | -x 'perl' . $exe_ext || die "perl isn't executable!\n"; |
172 | -x 'suidperl' . $exe_ext|| die "suidperl isn't executable!\n" if $d_dosuid; |
c623bd54 |
173 | |
9fba8746 |
174 | -f 't/rantests' || $Is_W32 |
1af49140 |
175 | || warn "WARNING: You've never run 'make test' or", |
176 | " some tests failed! (Installing anyway.)\n"; |
c623bd54 |
177 | |
8736538c |
178 | if ($Is_W32 or $Is_Cygwin) { |
179 | my $perldll; |
180 | |
5f675712 |
181 | if ($Is_Cygwin) { |
182 | $perldll = $libperl; |
183 | $perldll =~ s/(\..*)?$/.$dlext/; |
184 | if ($Config{useshrplib} eq 'true') { |
185 | # install ld2 and perlld as well |
186 | foreach ('ld2', 'perlld') { |
187 | safe_unlink("$installbin/$_"); |
188 | copy("$_", "$installbin/$_"); |
189 | chmod(0755, "$installbin/$_"); |
190 | }; |
8736538c |
191 | }; |
5f675712 |
192 | } else { |
193 | $perldll = 'perl56.' . $dlext; |
194 | } |
195 | |
196 | if ($dlsrc ne "dl_none.xs") { |
197 | -f $perldll || die "No perl DLL built\n"; |
198 | } |
199 | # Install the DLL |
200 | |
201 | safe_unlink("$installbin/$perldll"); |
202 | copy("$perldll", "$installbin/$perldll"); |
203 | chmod(0755, "$installbin/$perldll"); |
146174a9 |
204 | |
205 | } # if ($Is_W32 or $Is_Cygwin) |
eef1cf2a |
206 | |
354f3b56 |
207 | # This will be used to store the packlist |
c2cd2081 |
208 | my $packlist = ExtUtils::Packlist->new("$installarchlib/.packlist"); |
354f3b56 |
209 | |
c623bd54 |
210 | # First we install the version-numbered executables. |
211 | |
17f28c40 |
212 | if ($Is_VMS) { |
6ee623d5 |
213 | safe_unlink("$installbin/$perl$exe_ext"); |
214 | copy("perl$exe_ext", "$installbin/$perl$exe_ext"); |
215 | chmod(0755, "$installbin/$perl$exe_ext"); |
216 | safe_unlink("$installbin/${perl}shr$exe_ext"); |
217 | copy("perlshr$exe_ext", "$installbin/${perl}shr$exe_ext"); |
218 | chmod(0755, "$installbin/${perl}shr$exe_ext"); |
17f28c40 |
219 | } |
1d84e8df |
220 | elsif ($^O eq 'mpeix') { |
221 | # MPE lacks hard links and requires that executables with special |
222 | # capabilities reside in the MPE namespace. |
223 | safe_unlink("$installbin/perl$ver$exe_ext", $Config{perlpath}); |
224 | # Install the primary executable into the MPE namespace as perlpath. |
225 | copy("perl$exe_ext", $Config{perlpath}); |
226 | chmod(0755, $Config{perlpath}); |
227 | # Create a backup copy with the version number. |
228 | link($Config{perlpath}, "$installbin/perl$ver$exe_ext"); |
229 | } |
3f5ee302 |
230 | elsif ($^O ne 'dos') { |
beb13193 |
231 | safe_unlink("$installbin/$perl_verbase$ver$exe_ext"); |
232 | copy("perl$exe_ext", "$installbin/$perl_verbase$ver$exe_ext"); |
f556e5b9 |
233 | strip("$installbin/$perl_verbase$ver$exe_ext"); |
beb13193 |
234 | chmod(0755, "$installbin/$perl_verbase$ver$exe_ext"); |
3f5ee302 |
235 | } |
1d84e8df |
236 | else { |
6ee623d5 |
237 | safe_unlink("$installbin/$perl.exe"); |
238 | copy("perl.exe", "$installbin/$perl.exe"); |
39e571d4 |
239 | } |
c623bd54 |
240 | |
beb13193 |
241 | safe_unlink("$installbin/s$perl_verbase$ver$exe_ext"); |
c623bd54 |
242 | if ($d_dosuid) { |
beb13193 |
243 | copy("suidperl$exe_ext", "$installbin/s$perl_verbase$ver$exe_ext"); |
244 | chmod(04711, "$installbin/s$perl_verbase$ver$exe_ext"); |
c623bd54 |
245 | } |
246 | |
45d8adaa |
247 | # Install library files. |
248 | |
c2cd2081 |
249 | my ($do_installarchlib, $do_installprivlib) = (0, 0); |
a0d0e21e |
250 | |
7e7af249 |
251 | mkpath($installprivlib, $verbose, 0777); |
252 | mkpath($installarchlib, $verbose, 0777); |
253 | mkpath($installsitelib, $verbose, 0777) if ($installsitelib); |
254 | mkpath($installsitearch, $verbose, 0777) if ($installsitearch); |
4633a7c4 |
255 | |
45d8adaa |
256 | if (chdir "lib") { |
68dc0745 |
257 | $do_installarchlib = ! samepath($installarchlib, '.'); |
258 | $do_installprivlib = ! samepath($installprivlib, '.'); |
146174a9 |
259 | $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$ver/); |
45d8adaa |
260 | |
a0d0e21e |
261 | if ($do_installarchlib || $do_installprivlib) { |
262 | find(\&installlib, '.'); |
45d8adaa |
263 | } |
264 | chdir ".." || die "Can't cd back to source directory: $!\n"; |
265 | } |
266 | else { |
267 | warn "Can't cd to lib to install lib files: $!\n"; |
268 | } |
269 | |
1aef975c |
270 | # Install header files and libraries. |
7e7af249 |
271 | mkpath("$installarchlib/CORE", $verbose, 0777); |
c2cd2081 |
272 | my @corefiles; |
17f28c40 |
273 | if ($Is_VMS) { # We did core file selection during build |
0185066f |
274 | my $coredir = "lib/$Config{archname}/$ver/CORE"; |
17f28c40 |
275 | $coredir =~ tr/./_/; |
0185066f |
276 | map { s|^$coredir/||i; } @corefiles = <$coredir/*.*>; |
17f28c40 |
277 | } |
278 | else { |
8736538c |
279 | # [als] hard-coded 'libperl' name... not good! |
17f28c40 |
280 | @corefiles = <*.h libperl*.*>; |
8736538c |
281 | |
17f28c40 |
282 | # AIX needs perl.exp installed as well. |
283 | push(@corefiles,'perl.exp') if $^O eq 'aix'; |
9d7f10f2 |
284 | if ($^O eq 'mpeix') { |
285 | # MPE needs mpeixish.h installed as well. |
7e7af249 |
286 | mkpath("$installarchlib/CORE/mpeix", $verbose, 0777); |
9d7f10f2 |
287 | push(@corefiles,'mpeix/mpeixish.h'); |
288 | } |
17f28c40 |
289 | # If they have built sperl.o... |
290 | push(@corefiles,'sperl.o') if -f 'sperl.o'; |
291 | } |
c2cd2081 |
292 | foreach my $file (@corefiles) { |
aa3cf465 |
293 | # HP-UX (at least) needs to maintain execute permissions |
efc5ad56 |
294 | # on dynamically-loadable libraries. So we do it for all. |
8f1f23e8 |
295 | if (copy_if_diff($file,"$installarchlib/CORE/$file")) { |
f556e5b9 |
296 | if ($file =~ /\.(\Q$so\E|\Q$dlext\E)$/) { |
8f1f23e8 |
297 | chmod(0555, "$installarchlib/CORE/$file"); |
f556e5b9 |
298 | strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody|darwin)$/; |
8f1f23e8 |
299 | } else { |
300 | chmod(0444, "$installarchlib/CORE/$file"); |
301 | } |
302 | } |
340f689c |
303 | } |
3edbfbe5 |
304 | |
156620fa |
305 | # Install main perl executables |
306 | # Make links to ordinary names if installbin directory isn't current directory. |
307 | |
17f28c40 |
308 | if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) { |
6ee623d5 |
309 | safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext"); |
1d84e8df |
310 | if ($^O eq 'mpeix') { |
311 | # MPE doesn't support hard links, so use a symlink. |
312 | # We don't want another cloned copy. |
313 | symlink($Config{perlpath}, "$installbin/perl$exe_ext"); |
314 | } else { |
beb13193 |
315 | link("$installbin/$perl_verbase$ver$exe_ext", |
316 | "$installbin/$perl$exe_ext"); |
1d84e8df |
317 | } |
beb13193 |
318 | link("$installbin/s$perl_verbase$ver$exe_ext", |
319 | "$installbin/suid$perl$exe_ext") |
156620fa |
320 | if $d_dosuid; |
321 | } |
322 | |
a0d0e21e |
323 | # Offer to install perl in a "standard" location |
324 | |
c2cd2081 |
325 | my $mainperl_is_instperl = 0; |
a0d0e21e |
326 | |
a3ed4895 |
327 | if ($Config{installusrbinperl} && $Config{installusrbinperl} eq 'define' && |
472a4973 |
328 | !$versiononly && !$nonono && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR |
68dc0745 |
329 | && -w $mainperldir && ! samepath($mainperldir, $installbin)) { |
c2cd2081 |
330 | my($usrbinperl) = "$mainperldir/$perl$exe_ext"; |
331 | my($instperl) = "$installbin/$perl$exe_ext"; |
332 | my($expinstperl) = "$binexp/$perl$exe_ext"; |
55497cff |
333 | |
334 | # First make sure $usrbinperl is not already the same as the perl we |
335 | # just installed. |
336 | if (-x $usrbinperl) { |
a0d0e21e |
337 | # Try to be clever about mainperl being a symbolic link |
338 | # to binexp/perl if binexp and installbin are different. |
339 | $mainperl_is_instperl = |
68dc0745 |
340 | samepath($usrbinperl, $instperl) || |
341 | samepath($usrbinperl, $expinstperl) || |
a0d0e21e |
342 | (($binexp ne $installbin) && |
55497cff |
343 | (-l $usrbinperl) && |
344 | ((readlink $usrbinperl) eq $expinstperl)); |
a0d0e21e |
345 | } |
346 | if ((! $mainperl_is_instperl) && |
68dc0745 |
347 | (yn("Many scripts expect perl to be installed as $usrbinperl.\n" . |
55497cff |
348 | "Do you wish to have $usrbinperl be the same as\n" . |
349 | "$expinstperl? [y] "))) |
1d84e8df |
350 | { |
55497cff |
351 | unlink($usrbinperl); |
1d84e8df |
352 | ( $Config{'d_link'} eq 'define' && |
353 | eval { CORE::link $instperl, $usrbinperl } ) || |
354 | eval { symlink $expinstperl, $usrbinperl } || |
355 | copy($instperl, $usrbinperl); |
356 | |
a0d0e21e |
357 | $mainperl_is_instperl = 1; |
358 | } |
359 | } |
360 | |
b971f6e4 |
361 | # Make links to ordinary names if installbin directory isn't current directory. |
362 | |
68dc0745 |
363 | if (!$versiononly && ! samepath($installbin, 'x2p')) { |
364 | safe_unlink("$installbin/a2p$exe_ext"); |
365 | copy("x2p/a2p$exe_ext", "$installbin/a2p$exe_ext"); |
366 | chmod(0755, "$installbin/a2p$exe_ext"); |
b971f6e4 |
367 | } |
368 | |
369 | # cppstdin is just a script, but it is architecture-dependent, so |
370 | # it can't safely be shared. Place it in $installbin. |
371 | # Note that Configure doesn't build cppstin if it isn't needed, so |
372 | # we skip this if cppstdin doesn't exist. |
68dc0745 |
373 | if (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) { |
374 | safe_unlink("$installbin/cppstdin"); |
375 | copy("cppstdin", "$installbin/cppstdin"); |
376 | chmod(0755, "$installbin/cppstdin"); |
b971f6e4 |
377 | } |
378 | |
d56c5707 |
379 | if (! $versiononly) { |
380 | # Install scripts. |
b971f6e4 |
381 | |
d56c5707 |
382 | mkpath($installscript, $verbose, 0777); |
b971f6e4 |
383 | |
22e77942 |
384 | for (@scripts) { |
385 | (my $base = $_) =~ s#.*/##; |
386 | copy($_, "$installscript/$base"); |
387 | chmod(0755, "$installscript/$base"); |
b971f6e4 |
388 | } |
22e77942 |
389 | |
d56c5707 |
390 | # pstruct should be a link to c2ph |
22e77942 |
391 | safe_unlink("$installscript/pstruct$scr_ext"); |
392 | if ($^O eq 'dos' or $Is_VMS or $^O eq 'transit') { |
d56c5707 |
393 | copy("$installscript/c2ph$scr_ext", |
394 | "$installscript/pstruct$scr_ext"); |
22e77942 |
395 | } else { |
d56c5707 |
396 | link("$installscript/c2ph$scr_ext", |
397 | "$installscript/pstruct$scr_ext"); |
39e571d4 |
398 | } |
b971f6e4 |
399 | } |
400 | |
146174a9 |
401 | # Install pod pages. Where? I guess in $installprivlib/pod |
402 | # ($installprivlib/pods for cygwin). |
b971f6e4 |
403 | |
146174a9 |
404 | my $pod = $Is_Cygwin ? 'pods' : 'pod'; |
d56c5707 |
405 | if ( !$versiononly || ($installprivlib =~ m/\Q$ver/)) { |
7e7af249 |
406 | mkpath("${installprivlib}/$pod", $verbose, 0777); |
91a06757 |
407 | |
408 | # If Perl 5.003's perldiag.pod is there, rename it. |
146174a9 |
409 | if (open POD, "${installprivlib}/$pod/perldiag.pod") { |
91a06757 |
410 | read POD, $_, 4000; |
411 | close POD; |
412 | # Some of Perl 5.003's diagnostic messages ended with periods. |
413 | if (/^=.*\.$/m) { |
146174a9 |
414 | my ($from, $to) = ("${installprivlib}/$pod/perldiag.pod", |
415 | "${installprivlib}/$pod/perldiag-5.003.pod"); |
f311e742 |
416 | print " rename $from $to"; |
91a06757 |
417 | rename($from, $to) |
418 | or warn "Couldn't rename $from to $to: $!\n" |
419 | unless $nonono; |
420 | } |
421 | } |
422 | |
146174a9 |
423 | for (@pods) { |
424 | # $_ is a name like pod/perl.pod |
425 | (my $base = $_) =~ s#.*/##; |
426 | copy_if_diff($_, "${installprivlib}/$pod/${base}"); |
b971f6e4 |
427 | } |
91a06757 |
428 | |
b971f6e4 |
429 | } |
430 | |
a0d0e21e |
431 | # Check to make sure there aren't other perls around in installer's |
432 | # path. This is probably UNIX-specific. Check all absolute directories |
433 | # in the path except for where public executables are supposed to live. |
434 | # Also skip $mainperl if the user opted to have it be a link to the |
435 | # installed perl. |
436 | |
5f675712 |
437 | if (!$versiononly && $otherperls) { |
146174a9 |
438 | my ($path, @path); |
c2cd2081 |
439 | my $dirsep = ($Is_OS2 || $Is_W32) ? ';' : ':' ; |
b971f6e4 |
440 | ($path = $ENV{"PATH"}) =~ s:\\:/:g ; |
441 | @path = split(/$dirsep/, $path); |
17f28c40 |
442 | if ($Is_VMS) { |
443 | my $i = 0; |
444 | while (exists $ENV{'DCL$PATH' . $i}) { |
c2cd2081 |
445 | my $dir = unixpath($ENV{'DCL$PATH' . $i}); $dir =~ s-/$--; |
17f28c40 |
446 | push(@path,$dir); |
447 | } |
448 | } |
c2cd2081 |
449 | my @otherperls; |
160a7e37 |
450 | my %otherperls; |
b971f6e4 |
451 | for (@path) { |
452 | next unless m,^/,; |
453 | # Use &samepath here because some systems have other dirs linked |
454 | # to $mainperldir (like SunOS) |
68dc0745 |
455 | next if samepath($_, $binexp); |
456 | next if ($mainperl_is_instperl && samepath($_, $mainperldir)); |
160a7e37 |
457 | my $otherperl = "$_/$perl$exe_ext"; |
458 | next if $otherperls{$otherperl}++; |
459 | push(@otherperls, $otherperl) |
460 | if (-x $otherperl && ! -d $otherperl); |
b971f6e4 |
461 | } |
462 | if (@otherperls) { |
5f675712 |
463 | warn "\nWarning: $perl appears in your path in the following " . |
b971f6e4 |
464 | "locations beyond where\nwe just installed it:\n"; |
465 | for (@otherperls) { |
5f675712 |
466 | warn " ", $_, "\n"; |
b971f6e4 |
467 | } |
5f675712 |
468 | warn "\n"; |
a0d0e21e |
469 | } |
b971f6e4 |
470 | |
a0d0e21e |
471 | } |
472 | |
3f9aafa0 |
473 | $packlist->write() unless $nonono; |
94b11c62 |
474 | print " Installation complete\n" if $verbose; |
c623bd54 |
475 | |
476 | exit 0; |
477 | |
478 | ############################################################################### |
479 | |
a0d0e21e |
480 | sub yn { |
c2cd2081 |
481 | my($prompt) = @_; |
482 | my($answer); |
483 | my($default) = $prompt =~ m/\[([yn])\]\s*$/i; |
5f675712 |
484 | warn $prompt; |
a0d0e21e |
485 | chop($answer = <STDIN>); |
486 | $answer = $default if $answer =~ m/^\s*$/; |
487 | ($answer =~ m/^[yY]/); |
488 | } |
489 | |
c623bd54 |
490 | sub unlink { |
c2cd2081 |
491 | my(@names) = @_; |
39add537 |
492 | my($cnt) = 0; |
c623bd54 |
493 | |
17f28c40 |
494 | return scalar(@names) if $Is_VMS; |
495 | |
c2cd2081 |
496 | foreach my $name (@names) { |
c623bd54 |
497 | next unless -e $name; |
8736538c |
498 | chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_Cygwin); |
94b11c62 |
499 | print " unlink $name\n" if $verbose; |
39add537 |
500 | ( CORE::unlink($name) and ++$cnt |
501 | or warn "Couldn't unlink $name: $!\n" ) unless $nonono; |
c623bd54 |
502 | } |
39add537 |
503 | return $cnt; |
c623bd54 |
504 | } |
505 | |
e50aee73 |
506 | sub safe_unlink { |
17f28c40 |
507 | return if $nonono or $Is_VMS; |
c2cd2081 |
508 | my @names = @_; |
509 | foreach my $name (@names) { |
e50aee73 |
510 | next unless -e $name; |
4a71ed0c |
511 | chmod 0777, $name if ($Is_OS2 || $Is_W32); |
94b11c62 |
512 | print " unlink $name\n" if $verbose; |
39add537 |
513 | next if CORE::unlink($name); |
e50aee73 |
514 | warn "Couldn't unlink $name: $!\n"; |
515 | if ($! =~ /busy/i) { |
94b11c62 |
516 | print " mv $name $name.old\n" if $verbose; |
68dc0745 |
517 | safe_rename($name, "$name.old") |
518 | or warn "Couldn't rename $name: $!\n"; |
e50aee73 |
519 | } |
520 | } |
521 | } |
522 | |
68dc0745 |
523 | sub safe_rename { |
c2cd2081 |
524 | my($from,$to) = @_; |
55a105fd |
525 | if (-f $to and not unlink($to)) { |
e50aee73 |
526 | my($i); |
527 | for ($i = 1; $i < 50; $i++) { |
91a06757 |
528 | last if rename($to, "$to.$i"); |
e50aee73 |
529 | } |
39add537 |
530 | warn("Cannot rename to `$to.$i': $!"), return 0 |
531 | if $i >= 50; # Give up! |
e50aee73 |
532 | } |
533 | link($from,$to) || return 0; |
55a105fd |
534 | unlink($from); |
e50aee73 |
535 | } |
536 | |
c623bd54 |
537 | sub link { |
15792f64 |
538 | my($from,$to) = @_; |
539 | my($success) = 0; |
c623bd54 |
540 | |
94b11c62 |
541 | print $verbose ? " ln $from $to\n" : " $to\n" unless $silent; |
39add537 |
542 | eval { |
68dc0745 |
543 | CORE::link($from, $to) |
544 | ? $success++ |
7bac28a0 |
545 | : ($from =~ m#^/afs/# || $to =~ m#^/afs/#) |
546 | ? die "AFS" # okay inside eval {} |
146174a9 |
547 | : die "Couldn't link $from to $to: $!\n" |
68dc0745 |
548 | unless $nonono; |
354f3b56 |
549 | $packlist->{$to} = { from => $from, type => 'link' }; |
39add537 |
550 | }; |
551 | if ($@) { |
146174a9 |
552 | warn $@; |
94b11c62 |
553 | print $verbose ? " cp $from $to\n" : " $to\n" unless $silent; |
5f675712 |
554 | print " creating new version of $to\n" |
555 | if $Is_VMS and -e $to and !$silent; |
68dc0745 |
556 | File::Copy::copy($from, $to) |
557 | ? $success++ |
558 | : warn "Couldn't copy $from to $to: $!\n" |
559 | unless $nonono; |
354f3b56 |
560 | $packlist->{$to} = { type => 'file' }; |
39add537 |
561 | } |
15792f64 |
562 | $success; |
c623bd54 |
563 | } |
564 | |
565 | sub chmod { |
c2cd2081 |
566 | my($mode,$name) = @_; |
c623bd54 |
567 | |
39e571d4 |
568 | return if ($^O eq 'dos'); |
94b11c62 |
569 | printf " chmod %o %s\n", $mode, $name if $verbose; |
68dc0745 |
570 | CORE::chmod($mode,$name) |
571 | || warn sprintf("Couldn't chmod %o %s: $!\n", $mode, $name) |
572 | unless $nonono; |
573 | } |
574 | |
575 | sub copy { |
576 | my($from,$to) = @_; |
577 | |
94b11c62 |
578 | print $verbose ? " cp $from $to\n" : " $to\n" unless $silent; |
5f675712 |
579 | print " creating new version of $to\n" if $Is_VMS and -e $to and !$silent; |
68dc0745 |
580 | File::Copy::copy($from, $to) |
581 | || warn "Couldn't copy $from to $to: $!\n" |
582 | unless $nonono; |
354f3b56 |
583 | $packlist->{$to} = { type => 'file' }; |
c623bd54 |
584 | } |
585 | |
a0d0e21e |
586 | sub samepath { |
c2cd2081 |
587 | my($p1, $p2) = @_; |
eef1cf2a |
588 | |
4a71ed0c |
589 | return (lc($p1) eq lc($p2)) if $Is_W32; |
a0d0e21e |
590 | |
75f92628 |
591 | if ($p1 ne $p2) { |
c2cd2081 |
592 | my($dev1, $ino1, $dev2, $ino2); |
a0d0e21e |
593 | ($dev1, $ino1) = stat($p1); |
594 | ($dev2, $ino2) = stat($p2); |
595 | ($dev1 == $dev2 && $ino1 == $ino2); |
596 | } |
597 | else { |
598 | 1; |
599 | } |
600 | } |
601 | |
602 | sub installlib { |
603 | my $dir = $File::Find::dir; |
604 | $dir =~ s#^\.(?![^/])/?##; |
0ecb046b |
605 | local($depth) = $dir ? "lib/$dir" : "lib"; |
a0d0e21e |
606 | |
607 | my $name = $_; |
efc5ad56 |
608 | |
146174a9 |
609 | # Ignore RCS and CVS directories. |
610 | if (($name eq 'CVS' or $name eq 'RCS') and -d $name) { |
efc5ad56 |
611 | $File::Find::prune = 1; |
612 | return; |
613 | } |
e50aee73 |
614 | |
146174a9 |
615 | # ignore patch backups, RCS files, emacs backup & temp files and the |
a8efb694 |
616 | # .exists files, and .PL files. |
617 | return if $name =~ m{\.orig$|~$|^#.+#$|,v$|^\.exists|\.PL$}; |
e50aee73 |
618 | |
a0d0e21e |
619 | $name = "$dir/$name" if $dir ne ''; |
620 | |
621 | my $installlib = $installprivlib; |
1dd15ed4 |
622 | if ($dir =~ /^auto/ || |
eef1cf2a |
623 | ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) || |
4a71ed0c |
624 | ($name =~ /^(.*)\.(?:h|lib)$/i && $Is_W32) |
eef1cf2a |
625 | ) { |
a0d0e21e |
626 | $installlib = $installarchlib; |
627 | return unless $do_installarchlib; |
628 | } else { |
629 | return unless $do_installprivlib; |
630 | } |
631 | |
a0d0e21e |
632 | if (-f $_) { |
5cc330c8 |
633 | if (/\.(?:al|ix)$/ && !($dir =~ m[^auto/(.*)$] && $archpms{$1})) { |
3edbfbe5 |
634 | $installlib = $installprivlib; |
635 | #We're installing *.al and *.ix files into $installprivlib, |
636 | #but we have to delete old *.al and *.ix files from the 5.000 |
637 | #distribution: |
75f92628 |
638 | #This might not work because $archname might have changed. |
55a105fd |
639 | unlink("$installarchlib/$name"); |
3edbfbe5 |
640 | } |
354f3b56 |
641 | $packlist->{"$installlib/$name"} = { type => 'file' }; |
5f05dabc |
642 | if (compare($_, "$installlib/$name") || $nonono) { |
55a105fd |
643 | unlink("$installlib/$name"); |
7e7af249 |
644 | mkpath("$installlib/$dir", $verbose, 0777); |
75f92628 |
645 | # HP-UX (at least) needs to maintain execute permissions |
646 | # on dynamically-loaded libraries. |
68dc0745 |
647 | copy_if_diff($_, "$installlib/$name") |
55a105fd |
648 | and chmod($name =~ /\.(so|$dlext)$/o ? 0555 : 0444, |
aa3cf465 |
649 | "$installlib/$name"); |
a0d0e21e |
650 | } |
a0d0e21e |
651 | } |
652 | } |
3edbfbe5 |
653 | |
16d20bd9 |
654 | # Copy $from to $to, only if $from is different than $to. |
655 | # Also preserve modification times for .a libraries. |
656 | # On some systems, if you do |
657 | # ranlib libperl.a |
658 | # cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a |
659 | # and then try to link against the installed libperl.a, you might |
660 | # get an error message to the effect that the symbol table is older |
661 | # than the library. |
aa3cf465 |
662 | # Return true if copying occurred. |
68dc0745 |
663 | |
664 | sub copy_if_diff { |
3edbfbe5 |
665 | my($from,$to)=@_; |
8530e788 |
666 | return 1 if (($^O eq 'VMS') && (-d $from)); |
f0963acb |
667 | -f $from || warn "$0: $from not found"; |
354f3b56 |
668 | $packlist->{$to} = { type => 'file' }; |
5f05dabc |
669 | if (compare($from, $to) || $nonono) { |
68dc0745 |
670 | safe_unlink($to); # In case we don't have write permissions. |
0ecb046b |
671 | if ($nonono) { |
672 | $from = $depth . "/" . $from if $depth; |
673 | } |
68dc0745 |
674 | copy($from, $to); |
675 | # Restore timestamps if it's a .a library or for OS/2. |
4a71ed0c |
676 | if (!$nonono && ($Is_OS2 || $to =~ /\.a$/)) { |
68dc0745 |
677 | my ($atime, $mtime) = (stat $from)[8,9]; |
16d20bd9 |
678 | utime $atime, $mtime, $to; |
679 | } |
aa3cf465 |
680 | 1; |
3edbfbe5 |
681 | } |
682 | } |
8f1f23e8 |
683 | |
684 | sub strip |
685 | { |
686 | my(@args) = @_; |
687 | |
f556e5b9 |
688 | return unless $dostrip; |
689 | |
8f1f23e8 |
690 | my @opts; |
691 | while (@args && $args[0] =~ /^(-\w+)$/) { |
692 | push @opts, shift @args; |
693 | } |
694 | |
695 | foreach my $file (@args) { |
696 | if (-f $file) { |
94b11c62 |
697 | print " strip $file\n" if $verbose; |
8f1f23e8 |
698 | system("strip", @opts, $file); |
699 | } else { |
94b11c62 |
700 | print "# file '$file' skipped\n" if $verbose; |
8f1f23e8 |
701 | } |
702 | } |
703 | } |
704 | |