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 @manpages = (<pod/*.man>, 'x2p/a2p.man', 'x2p/s2p.man');
18 # Read in the config file.
20 open(CONFIG, "config.sh") || die "You haven't run Configure yet!\n";
22 if (s/^(\w+=)/\$$1/) {
23 $accum =~ s/'undef'/undef/g;
32 $release = substr($ver,0,3);
33 $patchlevel = substr($ver,3,2);
34 die "Patchlevel of perl ($patchlevel)",
35 "and patchlevel of config.sh ($PATCHLEVEL) don't match\n"
36 if $patchlevel != $PATCHLEVEL;
38 # Do some quick sanity checks.
40 if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
42 $installbin || die "No installbin directory in config.sh\n";
43 -d $installbin || die "$installbin is not a directory\n";
44 -w $installbin || die "$installbin is not writable by you\n"
45 unless $installbin =~ m#^/afs/# || $nonono;
47 -x 'perl' || die "perl isn't executable!\n";
48 -x 'suidperl' || die "suidperl isn't executable!\n" if $d_dosuid;
50 -x 't/TEST' || warn "WARNING: You've never run 'make test'!!!",
51 " (Installing anyway.)\n";
54 if (!<libperl*.$so*>) {
55 warn "WARNING: Can't find libperl*.$so* to install into $shrpdir.",
56 " (Installing other things anyway.)\n";
59 -w $shrpdir || die "$shrpdir is not writable by you\n";
60 &cmd("cp libperl*.$so* $shrpdir");
64 # First we install the version-numbered executables.
66 &unlink("$installbin/perl$ver");
67 &cmd("cp perl $installbin/perl$ver");
69 &unlink("$installbin/sperl$ver");
71 &cmd("cp suidperl $installbin/sperl$ver");
72 &chmod(04711, "$installbin/sperl$ver");
75 exit 0 if $versiononly;
77 # Make links to ordinary names if installbin directory isn't current directory.
79 if (! &samepath($installbin, '.')) {
80 &unlink("$installbin/perl", "$installbin/suidperl");
81 &link("$installbin/perl$ver", "$installbin/perl");
82 &link("$installbin/sperl$ver", "$installbin/suidperl") if $d_dosuid;
85 if (! &samepath($installbin, 'x2p')) {
86 &unlink("$installbin/a2p");
87 &cmd("cp x2p/a2p $installbin/a2p");
88 &chmod(0755, "$installbin/a2p");
93 &makedir($installscript);
96 if (-f $_) { # cppstdin might not exist on this system.
97 &cmd("cp $_ $installscript");
98 s#.*/##; &chmod(0755, "$installscript/$_");
104 if ($installmansrc ne '') {
105 &makedir($installmansrc);
107 if (! &samepath($installmansrc, '.')) {
109 ($new = $_) =~ s/man$/$manext/;
111 print STDERR " Installing $installmansrc/$new\n";
113 open(MI,$_) || warn "Can't open $_: $!\n";
114 open(MO,">$installmansrc/$new") || warn "Can't install $installmansrc/$new: $!\n";
115 print MO ".ds RP Release $release Patchlevel $patchlevel\n";
125 # Install library files.
127 $do_installarchlib = $do_installprivlib = 0;
129 &makedir($installprivlib);
130 &makedir($installarchlib);
132 $do_installarchlib = ! &samepath($installarchlib, '.');
133 $do_installprivlib = ! &samepath($installprivlib, '.');
135 if ($do_installarchlib || $do_installprivlib) {
136 find(\&installlib, '.');
138 chdir ".." || die "Can't cd back to source directory: $!\n";
141 warn "Can't cd to lib to install lib files: $!\n";
144 # Install header files and libraries.
145 makedir("$installarchlib/CORE");
146 foreach $file (<*.h libperl*.*>) {
147 cp_if_diff($file,"$installarchlib/CORE/$file");
148 if ($file =~ /\.a$/ && $osname eq 'next') {
149 #on NeXTs we have to rerun ranlib after copying libraries
150 &cmd("$ranlib $installarchlib/CORE/$file");
153 # AIX needs perl.exp installed as well.
154 cp_if_diff("perl.exp" ,"$installarchlib/CORE/perl.exp") if ($osname eq 'aix');
156 # If they have built sperl.o...
157 cp_if_diff("sperl.o" ,"$installarchlib/CORE/sperl.o") if (-f 'sperl.o');
160 # Offer to install perl in a "standard" location
162 $mainperl_is_instperl = 0;
164 if (-w $mainperldir && ! &samepath($mainperldir, $installbin) && !$nonono) {
165 # First make sure $mainperldir/perl is not already the same as
166 # the perl we just installed
167 if (-x "$mainperldir/perl") {
168 # Try to be clever about mainperl being a symbolic link
169 # to binexp/perl if binexp and installbin are different.
170 $mainperl_is_instperl =
171 &samepath("$mainperldir/perl", "$installbin/perl") ||
172 (($binexp ne $installbin) &&
173 (-l "$mainperldir/perl") &&
174 ((readlink "$mainperldir/perl") eq "$binexp/perl"));
176 if ((! $mainperl_is_instperl) &&
177 (&yn("Many scripts expect perl to be installed as " .
178 "$mainperldir/perl.\n" .
179 "Do you wish to have $mainperldir/perl be the same as\n" .
180 "$binexp/perl? [y] ")))
182 unlink("$mainperldir/perl");
183 eval 'link("$installbin/perl", "$mainperldir/perl")' ||
184 eval 'symlink("$binexp/perl", "$mainperldir/perl")' ||
185 &cmd("cp $installbin/perl $mainperldir");
186 $mainperl_is_instperl = 1;
190 # Check to make sure there aren't other perls around in installer's
191 # path. This is probably UNIX-specific. Check all absolute directories
192 # in the path except for where public executables are supposed to live.
193 # Also skip $mainperl if the user opted to have it be a link to the
196 @path = split(/:/, $ENV{"PATH"});
200 next if ($_ eq $binexp);
201 # Use &samepath here because some systems have other dirs linked
202 # to $mainperldir (like SunOS)
203 next if ($mainperl_is_instperl && &samepath($_, $mainperldir));
204 push(@otherperls, "$_/perl") if (-x "$_/perl" && ! -d "$_/perl");
207 print STDERR "\nWarning: perl appears in your path in the following " .
208 "locations beyond where\nwe just installed it:\n";
210 print STDERR " ", $_, "\n";
215 print STDERR " Installation complete\n";
219 ###############################################################################
224 local($default) = $prompt =~ m/\[([yn])\]\s*$/i;
225 print STDERR $prompt;
226 chop($answer = <STDIN>);
227 $answer = $default if $answer =~ m/^\s*$/;
228 ($answer =~ m/^[yY]/);
234 foreach $name (@names) {
235 next unless -e $name;
236 print STDERR " unlink $name\n";
237 unlink($name) || warn "Couldn't unlink $name: $!\n" unless $nonono;
243 print STDERR " $cmd\n";
246 warn "Command failed!!!\n" if $?;
251 local($from,$to) = @_;
253 print STDERR " ln $from $to\n";
254 link($from,$to) || warn "Couldn't link $from to $to: $!\n" unless $nonono;
258 local($mode,$name) = @_;
260 printf STDERR " chmod %o %s\n", $mode, $name;
261 chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name)
268 local($shortdir) = $dir;
270 $shortdir =~ s#(.*)/.*#$1#;
273 print STDERR " mkdir $dir\n";
274 mkdir($dir, 0777) || warn "Couldn't create $dir: $!\n" unless $nonono;
279 local($p1, $p2) = @_;
280 local($dev1, $ino1, $dev2, $ino2);
283 ($dev1, $ino1) = stat($p1);
284 ($dev2, $ino2) = stat($p2);
285 ($dev1 == $dev2 && $ino1 == $ino2);
293 my $dir = $File::Find::dir;
294 $dir =~ s#^\.(?![^/])/?##;
297 $name = "$dir/$name" if $dir ne '';
299 my $installlib = $installprivlib;
300 if ((substr($dir, 0, 4) eq 'auto') || ($name eq 'Config.pm')) {
301 $installlib = $installarchlib;
302 return unless $do_installarchlib;
304 return unless $do_installprivlib;
308 if (/\.al$/ || /\.ix$/) {
309 $installlib = $installprivlib;
310 #We're installing *.al and *.ix files into $installprivlib,
311 #but we have to delete old *.al and *.ix files from the 5.000
313 #This might not work because $archname might have changed.
314 &unlink("$installarchlib/$name");
316 system "cmp", "-s", $_, "$installlib/$name";
318 &unlink("$installlib/$name");
319 &makedir("$installlib/$dir");
320 &cmd("cp $_ $installlib/$dir");
321 if (/\.a$/ && $osname eq 'next') {
322 #on NeXTs we have to rerun ranlib after copying libraries
323 &cmd("$ranlib $installlib/$dir/$_");
325 # HP-UX (at least) needs to maintain execute permissions
326 # on dynamically-loaded libraries.
327 if ($name =~ /\.(so|$dlext)$/o) {
328 &chmod(0555, "$installlib/$name");
331 &chmod(0444, "$installlib/$name");
335 &makedir("$installlib/$name");
341 -f $from || die "$0: $from not found";
342 system "cmp", "-s", $from, $to;