2 BEGIN { @INC=('./lib', '../lib') }
5 $mainperldir = "/usr/bin";
8 $nonono = 1 if $ARGV[0] eq '-n';
9 $versiononly = 1 if $ARGV[0] eq '-v';
15 @scripts = ('cppstdin', 'c2ph', 'h2xs', 'pstruct', 'x2p/s2p', 'x2p/find2perl',
16 'perldoc', 'pod/pod2man', 'pod/pod2html', 'pod/pod2latex' );
18 # pod documentation now handled by separate installman script.
19 # These two are archaic leftovers.
20 @manpages = ('x2p/a2p.man', 'x2p/s2p.man');
22 @pods = (<pod/*.pod>);
24 # Read in the config file.
26 open(CONFIG, "config.sh") || die "You haven't run Configure yet!\n";
28 if (s/^(\w+=)/\$$1/) {
29 $accum =~ s/'undef'/undef/g;
38 $release = substr($ver,0,3);
39 $patchlevel = substr($ver,3,2);
40 die "Patchlevel of perl ($patchlevel)",
41 "and patchlevel of config.sh ($PATCHLEVEL) don't match\n"
42 if $patchlevel != $PATCHLEVEL;
44 # Do some quick sanity checks.
46 if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
48 $installbin || die "No installbin directory in config.sh\n";
49 -d $installbin || die "$installbin is not a directory\n";
50 -w $installbin || die "$installbin is not writable by you\n"
51 unless $installbin =~ m#^/afs/# || $nonono;
53 -x 'perl' || die "perl isn't executable!\n";
54 -x 'suidperl' || die "suidperl isn't executable!\n" if $d_dosuid;
56 -x 't/TEST' || warn "WARNING: You've never run 'make test'!!!",
57 " (Installing anyway.)\n";
60 if (!<libperl*.$so*>) {
61 warn "WARNING: Can't find libperl*.$so* to install into $shrpdir.",
62 " (Installing other things anyway.)\n";
65 -w $shrpdir || die "$shrpdir is not writable by you\n";
66 &cmd("cp libperl*.$so* $shrpdir");
70 # First we install the version-numbered executables.
72 &safe_unlink("$installbin/perl$ver");
73 &cmd("cp perl $installbin/perl$ver");
75 &safe_unlink("$installbin/sperl$ver");
77 &cmd("cp suidperl $installbin/sperl$ver");
78 &chmod(04711, "$installbin/sperl$ver");
81 exit 0 if $versiononly;
83 # Make links to ordinary names if installbin directory isn't current directory.
85 if (! &samepath($installbin, '.')) {
86 &safe_unlink("$installbin/perl", "$installbin/suidperl");
87 &link("$installbin/perl$ver", "$installbin/perl");
88 &link("$installbin/sperl$ver", "$installbin/suidperl") if $d_dosuid;
91 if (! &samepath($installbin, 'x2p')) {
92 &safe_unlink("$installbin/a2p");
93 &cmd("cp x2p/a2p $installbin/a2p");
94 &chmod(0755, "$installbin/a2p");
99 &makedir($installscript);
102 if (-f $_) { # cppstdin might not exist on this system.
103 &cmd("cp $_ $installscript");
104 s#.*/##; &chmod(0755, "$installscript/$_");
108 # Install pod pages. Where? I guess in $installprivlib/pod.
109 &makedir("${installprivlib}/pod");
110 foreach $file (@pods) {
111 # $file is a name like pod/perl.pod
112 cp_if_diff($file, "${installprivlib}/${file}");
115 # Install old man pages.
117 if ($installman1dir ne '') {
118 &makedir($installman1dir);
120 if (! &samepath($installman1dir, '.')) {
122 ($new = $_) =~ s/man$/$man1ext/;
124 print STDERR " Installing $installman1dir/$new\n";
126 open(MI,$_) || warn "Can't open $_: $!\n";
127 open(MO,">$installman1dir/$new") ||
128 warn "Can't install $installman1dir/$new: $!\n";
129 print MO ".ds RP Release $release Patchlevel $patchlevel\n";
139 # Install library files.
141 $do_installarchlib = $do_installprivlib = 0;
143 &makedir($installprivlib);
144 &makedir($installarchlib);
146 $do_installarchlib = ! &samepath($installarchlib, '.');
147 $do_installprivlib = ! &samepath($installprivlib, '.');
149 if ($do_installarchlib || $do_installprivlib) {
150 find(\&installlib, '.');
152 chdir ".." || die "Can't cd back to source directory: $!\n";
155 warn "Can't cd to lib to install lib files: $!\n";
158 # Install header files and libraries.
159 makedir("$installarchlib/CORE");
160 foreach $file (<*.h libperl*.*>) {
161 cp_if_diff($file,"$installarchlib/CORE/$file");
163 # AIX needs perl.exp installed as well.
164 cp_if_diff("perl.exp" ,"$installarchlib/CORE/perl.exp") if ($osname eq 'aix');
166 # If they have built sperl.o...
167 cp_if_diff("sperl.o" ,"$installarchlib/CORE/sperl.o") if (-f 'sperl.o');
170 # Offer to install perl in a "standard" location
172 $mainperl_is_instperl = 0;
174 if (-w $mainperldir && ! &samepath($mainperldir, $installbin) && !$nonono) {
175 # First make sure $mainperldir/perl is not already the same as
176 # the perl we just installed
177 if (-x "$mainperldir/perl") {
178 # Try to be clever about mainperl being a symbolic link
179 # to binexp/perl if binexp and installbin are different.
180 $mainperl_is_instperl =
181 &samepath("$mainperldir/perl", "$installbin/perl") ||
182 (($binexp ne $installbin) &&
183 (-l "$mainperldir/perl") &&
184 ((readlink "$mainperldir/perl") eq "$binexp/perl"));
186 if ((! $mainperl_is_instperl) &&
187 (&yn("Many scripts expect perl to be installed as " .
188 "$mainperldir/perl.\n" .
189 "Do you wish to have $mainperldir/perl be the same as\n" .
190 "$binexp/perl? [y] ")))
192 unlink("$mainperldir/perl");
193 eval 'link("$installbin/perl", "$mainperldir/perl")' ||
194 eval 'symlink("$binexp/perl", "$mainperldir/perl")' ||
195 &cmd("cp $installbin/perl $mainperldir");
196 $mainperl_is_instperl = 1;
200 # Check to make sure there aren't other perls around in installer's
201 # path. This is probably UNIX-specific. Check all absolute directories
202 # in the path except for where public executables are supposed to live.
203 # Also skip $mainperl if the user opted to have it be a link to the
206 @path = split(/:/, $ENV{"PATH"});
210 next if ($_ eq $binexp);
211 # Use &samepath here because some systems have other dirs linked
212 # to $mainperldir (like SunOS)
213 next if ($mainperl_is_instperl && &samepath($_, $mainperldir));
214 push(@otherperls, "$_/perl") if (-x "$_/perl" && ! -d "$_/perl");
217 print STDERR "\nWarning: perl appears in your path in the following " .
218 "locations beyond where\nwe just installed it:\n";
220 print STDERR " ", $_, "\n";
225 print STDERR " Installation complete\n";
229 ###############################################################################
234 local($default) = $prompt =~ m/\[([yn])\]\s*$/i;
235 print STDERR $prompt;
236 chop($answer = <STDIN>);
237 $answer = $default if $answer =~ m/^\s*$/;
238 ($answer =~ m/^[yY]/);
244 foreach $name (@names) {
245 next unless -e $name;
246 print STDERR " unlink $name\n";
247 unlink($name) || warn "Couldn't unlink $name: $!\n" unless $nonono;
254 foreach $name (@names) {
255 next unless -e $name;
256 print STDERR " unlink $name\n";
258 next if unlink($name);
259 warn "Couldn't unlink $name: $!\n";
261 print STDERR " mv $name $name.old\n";
262 &rename($name, "$name.old") || warn "Couldn't rename $name: $!\n";
269 print STDERR " $cmd\n";
272 warn "Command failed!!!\n" if $?;
277 local($from,$to) = @_;
278 unless (unlink($to)) {
280 for ($i = 1; $i < 50; $i++) {
281 last if rename($to, "$to.$i");
283 return 0 if $i >= 50; # Give up!
285 link($from,$to) || return 0;
290 local($from,$to) = @_;
292 print STDERR " ln $from $to\n";
293 link($from,$to) || warn "Couldn't link $from to $to: $!\n" unless $nonono;
297 local($mode,$name) = @_;
299 printf STDERR " chmod %o %s\n", $mode, $name;
300 chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name)
307 local($shortdir) = $dir;
309 $shortdir =~ s#(.*)/.*#$1#;
312 print STDERR " mkdir $dir\n";
313 mkdir($dir, 0777) || warn "Couldn't create $dir: $!\n" unless $nonono;
318 local($p1, $p2) = @_;
319 local($dev1, $ino1, $dev2, $ino2);
322 ($dev1, $ino1) = stat($p1);
323 ($dev2, $ino2) = stat($p2);
324 ($dev1 == $dev2 && $ino1 == $ino2);
332 my $dir = $File::Find::dir;
333 $dir =~ s#^\.(?![^/])/?##;
337 # ignore patch backups and the .exists files.
338 return if $name =~ m{\.orig$|~$|^\.exists};
340 $name = "$dir/$name" if $dir ne '';
342 my $installlib = $installprivlib;
343 if ((substr($dir, 0, 4) eq 'auto') || ($name eq 'Config.pm')) {
344 $installlib = $installarchlib;
345 return unless $do_installarchlib;
347 return unless $do_installprivlib;
351 if (/\.al$/ || /\.ix$/) {
352 $installlib = $installprivlib;
353 #We're installing *.al and *.ix files into $installprivlib,
354 #but we have to delete old *.al and *.ix files from the 5.000
356 #This might not work because $archname might have changed.
357 &unlink("$installarchlib/$name");
359 system "cmp", "-s", $_, "$installlib/$name";
361 &unlink("$installlib/$name");
362 &makedir("$installlib/$dir");
363 cp_if_diff("$_", "$installlib/$dir/$_");
364 # HP-UX (at least) needs to maintain execute permissions
365 # on dynamically-loaded libraries.
366 if ($name =~ /\.(so|$dlext)$/o) {
367 &chmod(0555, "$installlib/$name");
370 &chmod(0444, "$installlib/$name");
374 &makedir("$installlib/$name");
378 # Copy $from to $to, only if $from is different than $to.
379 # Also preserve modification times for .a libraries.
380 # On some systems, if you do
382 # cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a
383 # and then try to link against the installed libperl.a, you might
384 # get an error message to the effect that the symbol table is older
388 -f $from || die "$0: $from not found";
389 system "cmp", "-s", $from, $to;
392 unlink($to); # In case we don't have write permissions.
394 # Restore timestamps if it's a .a library.
396 ($atime, $mtime) = (stat $from)[8,9];
397 utime $atime, $mtime, $to;