2 BEGIN { @INC=('./lib', '../lib') }
6 $mainperldir = "/usr/bin";
9 $nonono = 1 if $ARGV[0] eq '-n';
10 $versiononly = 1 if $ARGV[0] eq '-v';
16 @scripts = ('cppstdin', 'c2ph', 'pstruct', 'x2p/s2p', 'x2p/find2perl');
17 @manpages = (<pod/*.man>, 'x2p/a2p.man', 'x2p/s2p.man');
19 # Read in the config file.
21 open(CONFIG, "config.sh") || die "You haven't run Configure yet!\n";
23 if (s/^(\w+=)/\$$1/) {
24 $accum =~ s/'undef'/undef/g;
32 open(PERL_C, "perl.c");
40 $ver = sprintf("%5.3f", $major + $PATCHLEVEL / 1000);
41 $release = substr($ver,0,3);
42 $patchlevel = substr($ver,3,2);
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";
59 # First we install the version-numbered executables.
61 &unlink("$installbin/perl$ver");
62 &cmd("cp perl $installbin/perl$ver");
64 &unlink("$installbin/sperl$ver");
66 &cmd("cp suidperl $installbin/sperl$ver");
67 &chmod(04711, "$installbin/sperl$ver");
70 exit 0 if $versiononly;
72 # Make links to ordinary names if installbin directory isn't current directory.
74 ($bdev,$bino) = stat($installbin);
75 ($ddev,$dino) = stat('.');
77 if ($bdev != $ddev || $bino != $dino) {
78 &unlink("$installbin/perl", "$installbin/suidperl");
79 &link("$installbin/perl$ver", "$installbin/perl");
80 &link("$installbin/sperl$ver", "$installbin/suidperl") if $d_dosuid;
83 ($bdev,$bino) = stat($installbin);
84 ($ddev,$dino) = stat('x2p');
86 if ($bdev != $ddev || $bino != $dino) {
87 &unlink("$installbin/a2p");
88 &cmd("cp x2p/a2p $installbin/a2p");
89 &chmod(0755, "$installbin/a2p");
94 &makedir($installscript);
97 if (-f $_) { # cppstdin might not exist on this system.
98 &cmd("cp $_ $installscript");
99 s#.*/##; &chmod(0755, "$installscript/$_");
105 if ($installmansrc ne '') {
106 &makedir($installmansrc);
108 ($mdev,$mino) = stat($installmansrc);
109 if ($mdev != $ddev || $mino != $dino) {
111 ($new = $_) =~ s/man$/$manext/;
113 print STDERR " Installing $installmansrc/$new\n";
115 open(MI,$_) || warn "Can't open $_: $!\n";
116 open(MO,">$installmansrc/$new") || warn "Can't install $installmansrc/$new: $!\n";
117 print MO ".ds RP Release $release Patchlevel $patchlevel\n";
127 # Install library files.
129 $do_installarchlib = $do_installprivlib = 0;
131 &makedir($installprivlib);
132 &makedir($installarchlib);
134 ($pdev,$pino) = stat($installarchlib);
135 ($ldev,$lino) = stat('.');
136 $do_installarchlib = ($pdev != $ldev || $pino != $lino);
138 ($pdev,$pino) = stat($installprivlib);
139 ($ldev,$lino) = stat('.');
140 $do_installprivlib = ($pdev != $ldev || $pino != $lino);
142 if ($do_installarchlib || $do_installprivlib) {
143 find(\&installlib, '.');
145 chdir ".." || die "Can't cd back to source directory: $!\n";
148 warn "Can't cd to lib to install lib files: $!\n";
151 # Install header files
152 makedir("$installarchlib/CORE");
153 foreach $file (<*.h libperl*.a>) {
154 cp_if_diff($file,"$installarchlib/CORE/$file");
157 # Offer to install perl in a "standard" location
159 ($udev,$uino) = stat($mainperldir);
161 $mainperl_is_instperl = 0;
163 if (-w _ && ($udev != $bdev || $uino != $bino) && !$nonono) {
164 # First make sure $mainperldir/perl is not already the same as
165 # the perl we just installed
166 if (-x "$mainperldir/perl") {
167 # Use stat so we detect symbolic links transparently
168 ($mpdev, $mpino) = stat("$mainperldir/perl");
169 ($ipdev, $ipino) = stat("$installbin/perl");
170 # Try to be clever about mainperl being a symbolic link
171 # to binexp/perl if binexp and installbin are different.
172 $mainperl_is_instperl =
173 (($mpdev == $ipdev && $mpino == $ipino) ||
174 (($binexp ne $installbin) &&
175 (-l "$mainperldir/perl") &&
176 ((readlink "$mainperldir/perl") eq "$binexp/perl")));
178 if ((! $mainperl_is_instperl) &&
179 (&yn("Many scripts expect perl to be installed as " .
180 "$mainperldir/perl.\n" .
181 "Do you wish to have $mainperldir/perl be the same as\n" .
182 "$binexp/perl? [y] ")))
184 unlink("$mainperldir/perl");
185 eval 'link("$installbin/perl", "$mainperldir/perl")' ||
186 eval 'symlink("$binexp/perl", "$mainperldir/perl")' ||
187 &cmd("cp $installbin/perl $mainperldir");
188 $mainperl_is_instperl = 1;
192 # Check to make sure there aren't other perls around in installer's
193 # path. This is probably UNIX-specific. Check all absolute directories
194 # in the path except for where public executables are supposed to live.
195 # Also skip $mainperl if the user opted to have it be a link to the
198 @path = split(/:/, $ENV{"PATH"});
202 next if ($_ eq $binexp);
203 # Use &samepath here because some systems have other dirs linked
204 # to $mainperldir (like SunOS)
205 next if ($mainperl_is_instperl && &samepath($_, $mainperldir));
206 push(@otherperls, "$_/perl") if (-x "$_/perl" && ! -d "$_/perl");
209 print STDERR "\nWarning: perl appears in your path in the following " .
210 "locations beyond where\nwe just installed it:\n";
212 print STDERR " ", $_, "\n";
217 print STDERR " Installation complete\n";
221 ###############################################################################
226 local($default) = $prompt =~ m/\[([yn])\]\s*$/i;
227 print STDERR $prompt;
228 chop($answer = <STDIN>);
229 $answer = $default if $answer =~ m/^\s*$/;
230 ($answer =~ m/^[yY]/);
236 foreach $name (@names) {
237 next unless -e $name;
238 print STDERR " unlink $name\n";
239 unlink($name) || warn "Couldn't unlink $name: $!\n" unless $nonono;
245 print STDERR " $cmd\n";
248 warn "Command failed!!!\n" if $?;
253 local($from,$to) = @_;
255 print STDERR " ln $from $to\n";
256 link($from,$to) || warn "Couldn't link $from to $to: $!\n" unless $nonono;
260 local($mode,$name) = @_;
262 printf STDERR " chmod %o %s\n", $mode, $name;
263 chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name)
270 local($shortdir) = $dir;
272 $shortdir =~ s#(.*)/.*#$1#;
275 print STDERR " mkdir $dir\n";
276 mkdir($dir, 0777) || warn "Couldn't create $dir: $!\n" unless $nonono;
281 local($p1, $p2) = @_;
282 local($dev1, $ino1, $dev2, $ino2);
285 ($dev1, $ino1) = stat($p1);
286 ($dev2, $ino2) = stat($p2);
287 ($dev1 == $dev2 && $ino1 == $ino2);
295 my $dir = $File::Find::dir;
296 $dir =~ s#^\.(?![^/])/?##;
299 $name = "$dir/$name" if $dir ne '';
301 my $installlib = $installprivlib;
302 if ((substr($dir, 0, 4) eq 'auto') || ($name eq 'Config.pm')) {
303 $installlib = $installarchlib;
304 return unless $do_installarchlib;
306 return unless $do_installprivlib;
310 if (/\.al$/ || /\.ix$/) {
311 $installlib = $installprivlib;
312 #We're installing *.al and *.ix files into $installprivlib,
313 #but we have to delete old *.al and *.ix files from the 5.000
315 &unlink("$installarchlib/$name");
317 system "cmp", "-s", $_, "$installlib/$name";
319 &unlink("$installlib/$name");
320 &makedir("$installlib/$dir");
321 &cmd("cp $_ $installlib/$dir");
322 &chmod(0644, "$installlib/$name");
325 &makedir("$installlib/$name");
331 -f $from || die "$0: $from not found";
332 system "cmp", "-s", $from, $to;