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