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 $ver = sprintf("%5.3f", $] + 0);
33 $release = substr($ver,0,3);
34 $patchlevel = substr($ver,3,2);
36 # Do some quick sanity checks.
38 if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
40 $installbin || die "No installbin directory in config.sh\n";
41 -d $installbin || die "$installbin is not a directory\n";
42 -w $installbin || die "$installbin is not writable by you\n"
43 unless $installbin =~ m#^/afs/# || $nonono;
45 -x 'perl' || die "perl isn't executable!\n";
46 -x 'suidperl' || die "suidperl isn't executable!\n" if $d_dosuid;
48 -x 't/TEST' || warn "WARNING: You've never run 'make test'!!!",
49 " (Installing anyway.)\n";
52 if (!<libperl*.$so*>) {
53 warn "WARNING: Can't find libperl*.$so* to install into $shrpdir.",
54 " (Installing other things anyway.)\n";
57 -w $shrpdir || die "$shrpdir is not writable by you\n";
58 &cmd("cp libperl*.$so* $shrpdir");
62 # First we install the version-numbered executables.
64 &unlink("$installbin/perl$ver");
65 &cmd("cp perl $installbin/perl$ver");
67 &unlink("$installbin/sperl$ver");
69 &cmd("cp suidperl $installbin/sperl$ver");
70 &chmod(04711, "$installbin/sperl$ver");
73 exit 0 if $versiononly;
75 # Make links to ordinary names if installbin directory isn't current directory.
77 if (! &samepath($installbin, '.')) {
78 &unlink("$installbin/perl", "$installbin/suidperl");
79 &link("$installbin/perl$ver", "$installbin/perl");
80 &link("$installbin/sperl$ver", "$installbin/suidperl") if $d_dosuid;
83 if (! &samepath($installbin, 'x2p')) {
84 &unlink("$installbin/a2p");
85 &cmd("cp x2p/a2p $installbin/a2p");
86 &chmod(0755, "$installbin/a2p");
91 &makedir($installscript);
94 if (-f $_) { # cppstdin might not exist on this system.
95 &cmd("cp $_ $installscript");
96 s#.*/##; &chmod(0755, "$installscript/$_");
102 if ($installmansrc ne '') {
103 &makedir($installmansrc);
105 if (! &samepath($installmansrc, '.')) {
107 ($new = $_) =~ s/man$/$manext/;
109 print STDERR " Installing $installmansrc/$new\n";
111 open(MI,$_) || warn "Can't open $_: $!\n";
112 open(MO,">$installmansrc/$new") || warn "Can't install $installmansrc/$new: $!\n";
113 print MO ".ds RP Release $release Patchlevel $patchlevel\n";
123 # Install library files.
125 $do_installarchlib = $do_installprivlib = 0;
127 &makedir($installprivlib);
128 &makedir($installarchlib);
130 $do_installarchlib = ! &samepath($installarchlib, '.');
131 $do_installprivlib = ! &samepath($installprivlib, '.');
133 if ($do_installarchlib || $do_installprivlib) {
134 find(\&installlib, '.');
136 chdir ".." || die "Can't cd back to source directory: $!\n";
139 warn "Can't cd to lib to install lib files: $!\n";
142 # Install header files
143 makedir("$installarchlib/CORE");
144 foreach $file (<*.h libperl*.a>) {
145 cp_if_diff($file,"$installarchlib/CORE/$file");
148 # Offer to install perl in a "standard" location
150 $mainperl_is_instperl = 0;
152 if (-w $mainperldir && ! &samepath($mainperldir, $installbin) && !$nonono) {
153 # First make sure $mainperldir/perl is not already the same as
154 # the perl we just installed
155 if (-x "$mainperldir/perl") {
156 # Try to be clever about mainperl being a symbolic link
157 # to binexp/perl if binexp and installbin are different.
158 $mainperl_is_instperl =
159 &samepath("$mainperldir/perl", "$installbin/perl") ||
160 (($binexp ne $installbin) &&
161 (-l "$mainperldir/perl") &&
162 ((readlink "$mainperldir/perl") eq "$binexp/perl"));
164 if ((! $mainperl_is_instperl) &&
165 (&yn("Many scripts expect perl to be installed as " .
166 "$mainperldir/perl.\n" .
167 "Do you wish to have $mainperldir/perl be the same as\n" .
168 "$binexp/perl? [y] ")))
170 unlink("$mainperldir/perl");
171 eval 'link("$installbin/perl", "$mainperldir/perl")' ||
172 eval 'symlink("$binexp/perl", "$mainperldir/perl")' ||
173 &cmd("cp $installbin/perl $mainperldir");
174 $mainperl_is_instperl = 1;
178 # Check to make sure there aren't other perls around in installer's
179 # path. This is probably UNIX-specific. Check all absolute directories
180 # in the path except for where public executables are supposed to live.
181 # Also skip $mainperl if the user opted to have it be a link to the
184 @path = split(/:/, $ENV{"PATH"});
188 next if ($_ eq $binexp);
189 # Use &samepath here because some systems have other dirs linked
190 # to $mainperldir (like SunOS)
191 next if ($mainperl_is_instperl && &samepath($_, $mainperldir));
192 push(@otherperls, "$_/perl") if (-x "$_/perl" && ! -d "$_/perl");
195 print STDERR "\nWarning: perl appears in your path in the following " .
196 "locations beyond where\nwe just installed it:\n";
198 print STDERR " ", $_, "\n";
203 print STDERR " Installation complete\n";
207 ###############################################################################
212 local($default) = $prompt =~ m/\[([yn])\]\s*$/i;
213 print STDERR $prompt;
214 chop($answer = <STDIN>);
215 $answer = $default if $answer =~ m/^\s*$/;
216 ($answer =~ m/^[yY]/);
222 foreach $name (@names) {
223 next unless -e $name;
224 print STDERR " unlink $name\n";
225 unlink($name) || warn "Couldn't unlink $name: $!\n" unless $nonono;
231 print STDERR " $cmd\n";
234 warn "Command failed!!!\n" if $?;
239 local($from,$to) = @_;
241 print STDERR " ln $from $to\n";
242 link($from,$to) || warn "Couldn't link $from to $to: $!\n" unless $nonono;
246 local($mode,$name) = @_;
248 printf STDERR " chmod %o %s\n", $mode, $name;
249 chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name)
256 local($shortdir) = $dir;
258 $shortdir =~ s#(.*)/.*#$1#;
261 print STDERR " mkdir $dir\n";
262 mkdir($dir, 0777) || warn "Couldn't create $dir: $!\n" unless $nonono;
267 local($p1, $p2) = @_;
268 local($dev1, $ino1, $dev2, $ino2);
271 ($dev1, $ino1) = stat($p1);
272 ($dev2, $ino2) = stat($p2);
273 ($dev1 == $dev2 && $ino1 == $ino2);
281 my $dir = $File::Find::dir;
282 $dir =~ s#^\.(?![^/])/?##;
285 $name = "$dir/$name" if $dir ne '';
287 my $installlib = $installprivlib;
288 if ((substr($dir, 0, 4) eq 'auto') || ($name eq 'Config.pm')) {
289 $installlib = $installarchlib;
290 return unless $do_installarchlib;
292 return unless $do_installprivlib;
296 if (/\.al$/ || /\.ix$/) {
297 $installlib = $installprivlib;
298 #We're installing *.al and *.ix files into $installprivlib,
299 #but we have to delete old *.al and *.ix files from the 5.000
301 &unlink("$installarchlib/$name");
303 system "cmp", "-s", $_, "$installlib/$name";
305 &unlink("$installlib/$name");
306 &makedir("$installlib/$dir");
307 &cmd("cp $_ $installlib/$dir");
308 &chmod(0644, "$installlib/$name");
311 &makedir("$installlib/$name");
317 -f $from || die "$0: $from not found";
318 system "cmp", "-s", $from, $to;