10Sstevel@tonic-gate# 20Sstevel@tonic-gate# This is a version of the 5.8.4 installperl script that has been modified to 30Sstevel@tonic-gate# work correctly as part of the ON build process. The changes are as follows: 4*1410Salanbur# * 'use filetest' added so the build works across mismatched NFSv4 domains 50Sstevel@tonic-gate# * umask set to 022 60Sstevel@tonic-gate# * install locations modified to be relative to $ROOT 70Sstevel@tonic-gate# * check for 'make test' being run before install removed 80Sstevel@tonic-gate# * executables installed with mode 0555 90Sstevel@tonic-gate# * executables only overwritten if different from last build 100Sstevel@tonic-gate# * check for other versions of perl in $PATH removed 110Sstevel@tonic-gate# * .packlist entries cleaned of $ROOT prefix 120Sstevel@tonic-gate# * SCCS directories and .tstamp files ignored on install 130Sstevel@tonic-gate# * The contents of the additional contrib_bin directory are installed 140Sstevel@tonic-gate# 150Sstevel@tonic-gate 160Sstevel@tonic-gateBEGIN { 170Sstevel@tonic-gate require 5.004; 180Sstevel@tonic-gate chdir '..' if !-d 'lib' and -d '../lib'; 190Sstevel@tonic-gate @INC = 'lib'; 200Sstevel@tonic-gate $ENV{PERL5LIB} = 'lib'; 210Sstevel@tonic-gate} 220Sstevel@tonic-gate 230Sstevel@tonic-gateuse strict; 24*1410Salanburuse filetest qw(access); 250Sstevel@tonic-gatemy ($Is_VMS, $Is_W32, $Is_OS2, $Is_Cygwin, $Is_Darwin, 260Sstevel@tonic-gate $nonono, $dostrip, $versiononly, $silent, $verbose, $force, 270Sstevel@tonic-gate $otherperls, $archname, $Is_NetWare, $nwinstall, $nopods); 280Sstevel@tonic-gateuse vars qw /$depth/; 290Sstevel@tonic-gate 300Sstevel@tonic-gateBEGIN { 310Sstevel@tonic-gate $Is_VMS = $^O eq 'VMS'; 320Sstevel@tonic-gate $Is_W32 = $^O eq 'MSWin32'; 330Sstevel@tonic-gate $Is_OS2 = $^O eq 'os2'; 340Sstevel@tonic-gate $Is_Cygwin = $^O eq 'cygwin'; 350Sstevel@tonic-gate $Is_Darwin = $^O eq 'darwin'; 360Sstevel@tonic-gate if ($Is_VMS) { eval 'use VMS::Filespec;' } 370Sstevel@tonic-gate} 380Sstevel@tonic-gate 390Sstevel@tonic-gatemy $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : ''); 400Sstevel@tonic-gate 410Sstevel@tonic-gateuse File::Find; 420Sstevel@tonic-gateuse File::Compare; 430Sstevel@tonic-gateuse File::Copy (); 440Sstevel@tonic-gateuse File::Path (); 450Sstevel@tonic-gateuse ExtUtils::Packlist; 460Sstevel@tonic-gateuse Config; 470Sstevel@tonic-gateuse subs qw(unlink link chmod); 480Sstevel@tonic-gate 490Sstevel@tonic-gateif ($Config{d_umask}) { 500Sstevel@tonic-gate umask(022); # umasks like 077 aren't that useful for installations 510Sstevel@tonic-gate} 520Sstevel@tonic-gate 530Sstevel@tonic-gate$Is_NetWare = $Config{osname} eq 'NetWare'; 540Sstevel@tonic-gateif ($Is_NetWare) { 550Sstevel@tonic-gate $Is_W32 = 0; 560Sstevel@tonic-gate $scr_ext = '.pl'; 570Sstevel@tonic-gate} 580Sstevel@tonic-gate 590Sstevel@tonic-gate# override the ones in the rest of the script 600Sstevel@tonic-gatesub mkpath { 610Sstevel@tonic-gate File::Path::mkpath(@_) unless $nonono; 620Sstevel@tonic-gate} 630Sstevel@tonic-gate 640Sstevel@tonic-gatemy $mainperldir = "/usr/bin"; 650Sstevel@tonic-gatemy $exe_ext = $Config{exe_ext}; 660Sstevel@tonic-gate 670Sstevel@tonic-gate# Allow ``make install PERLNAME=something_besides_perl'': 680Sstevel@tonic-gatemy $perl = defined($ENV{PERLNAME}) ? $ENV{PERLNAME} : 'perl'; 690Sstevel@tonic-gate 700Sstevel@tonic-gate# This is the base used for versioned names, like "perl5.6.0". 710Sstevel@tonic-gate# It's separate because a common use of $PERLNAME is to install 720Sstevel@tonic-gate# perl as "perl5", if that's used as base for versioned files you 730Sstevel@tonic-gate# get "perl55.6.0". 740Sstevel@tonic-gatemy $perl_verbase = defined($ENV{PERLNAME_VERBASE}) 750Sstevel@tonic-gate ? $ENV{PERLNAME_VERBASE} 760Sstevel@tonic-gate : $perl; 770Sstevel@tonic-gatemy $dbg = ''; 780Sstevel@tonic-gatemy $ndbg = ''; 790Sstevel@tonic-gateif ( $Is_VMS ) { 800Sstevel@tonic-gate if ( defined $Config{usevmsdebug} ) { 810Sstevel@tonic-gate if ( $Config{usevmsdebug} eq 'define' ) { 820Sstevel@tonic-gate $dbg = 'dbg'; 830Sstevel@tonic-gate $ndbg = 'ndbg'; 840Sstevel@tonic-gate } 850Sstevel@tonic-gate } 860Sstevel@tonic-gate} 870Sstevel@tonic-gate 880Sstevel@tonic-gate$otherperls = 1; 890Sstevel@tonic-gatemy $destdir = ''; 900Sstevel@tonic-gatewhile (@ARGV) { 910Sstevel@tonic-gate $nonono = 1 if $ARGV[0] eq '-n'; 920Sstevel@tonic-gate $dostrip = 1 if $ARGV[0] eq '-s'; 930Sstevel@tonic-gate $versiononly = 1 if $ARGV[0] eq '-v'; 940Sstevel@tonic-gate $versiononly = 0 if $ARGV[0] eq '+v'; 950Sstevel@tonic-gate $silent = 1 if $ARGV[0] eq '-S'; 960Sstevel@tonic-gate $otherperls = 0 if $ARGV[0] eq '-o'; 970Sstevel@tonic-gate $force = 1 if $ARGV[0] eq '-f'; 980Sstevel@tonic-gate $verbose = 1 if $ARGV[0] eq '-V' || $ARGV [0] eq '-n'; 990Sstevel@tonic-gate $archname = 1 if $ARGV[0] eq '-A'; 1000Sstevel@tonic-gate $nwinstall = 1 if $ARGV[0] eq '-netware'; 1010Sstevel@tonic-gate $nopods = 1 if $ARGV[0] eq '-p'; 1020Sstevel@tonic-gate $destdir = $1 if $ARGV[0] =~ /^-?-destdir=(.*)$/; 1030Sstevel@tonic-gate if ($ARGV[0] eq '-?' or $ARGV[0] =~ /^-?-h/) { 1040Sstevel@tonic-gate print <<"EOT"; 1050Sstevel@tonic-gateUsage $0: [switches] 1060Sstevel@tonic-gate -n Don't actually run any commands; just print them. 1070Sstevel@tonic-gate -s Run strip on installed binaries. 1080Sstevel@tonic-gate -v Only install perl as a binary with the version number in the name. 1090Sstevel@tonic-gate (Override whatever config.sh says) 1100Sstevel@tonic-gate +v Install perl as "perl" and as a binary with the version number in 1110Sstevel@tonic-gate the name. (Override whatever config.sh says) 1120Sstevel@tonic-gate -S Silent mode. 1130Sstevel@tonic-gate -f Force installation (don't check if same version is there) 1140Sstevel@tonic-gate -o Skip checking for other copies of perl in your PATH. 1150Sstevel@tonic-gate -V Verbose mode. 1160Sstevel@tonic-gate -A Also install perl with the architecture's name in the perl binary's 1170Sstevel@tonic-gate name. 1180Sstevel@tonic-gate -p Don't install the pod files. [This will break use diagnostics;] 1190Sstevel@tonic-gate -netware Install correctly on a Netware server. 1200Sstevel@tonic-gate -destdir Prefix installation directories by this string. 1210Sstevel@tonic-gateEOT 1220Sstevel@tonic-gate exit; 1230Sstevel@tonic-gate } 1240Sstevel@tonic-gate shift; 1250Sstevel@tonic-gate} 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate$versiononly = 1 if $Config{versiononly} && !defined $versiononly; 1280Sstevel@tonic-gatemy (@scripts, @tolink); 1290Sstevel@tonic-gateopen SCRIPTS, "utils.lst" or die "Can't open utils.lst: $!"; 1300Sstevel@tonic-gatewhile (<SCRIPTS>) { 1310Sstevel@tonic-gate next if /^#/; 1320Sstevel@tonic-gate s/\s*#\s*pod\s*=.*//; # install script regardless of pod location 1330Sstevel@tonic-gate next if /a2p/; # a2p is binary, to be installed separately 1340Sstevel@tonic-gate chomp; 1350Sstevel@tonic-gate if (/(\S*)\s*#\s*link\s*=\s*(\S*)/) { 1360Sstevel@tonic-gate push @scripts, $1; 1370Sstevel@tonic-gate push @tolink, [$1, $2]; 1380Sstevel@tonic-gate } else { 1390Sstevel@tonic-gate push @scripts, $_; 1400Sstevel@tonic-gate } 1410Sstevel@tonic-gate} 1420Sstevel@tonic-gateclose SCRIPTS; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate# Added for ON - install the scripts (if any) from contrib_bin. 1450Sstevel@tonic-gatemy $dh; 1460Sstevel@tonic-gateif (opendir($dh, 'contrib_bin')) { 1470Sstevel@tonic-gate push(@scripts, 1480Sstevel@tonic-gate map("contrib_bin/$_", grep($_ !~ /^\./, readdir($dh)))); 1490Sstevel@tonic-gate closedir($dh); 1500Sstevel@tonic-gate} 1510Sstevel@tonic-gate 1520Sstevel@tonic-gateif ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; } 1530Sstevel@tonic-gate 1540Sstevel@tonic-gatemy @pods = $nopods ? () : (<pod/*.pod>, 'x2p/a2p.pod'); 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate# Specify here any .pm files that are actually architecture-dependent. 1570Sstevel@tonic-gate# (Those included with XS extensions under ext/ are automatically 1580Sstevel@tonic-gate# added later.) 1590Sstevel@tonic-gate# Now that the default privlib has the full perl version number included, 1600Sstevel@tonic-gate# we no longer have to play the trick of sticking version-specific .pm 1610Sstevel@tonic-gate# files under the archlib directory. 1620Sstevel@tonic-gatemy %archpms = ( 1630Sstevel@tonic-gate Config => 1, 1640Sstevel@tonic-gate lib => 1, 1650Sstevel@tonic-gate Cwd => 1, 1660Sstevel@tonic-gate); 1670Sstevel@tonic-gate 1680Sstevel@tonic-gateif ($^O eq 'dos') { 1690Sstevel@tonic-gate push(@scripts,'djgpp/fixpmain'); 1700Sstevel@tonic-gate $archpms{config} = $archpms{filehand} = 1; 1710Sstevel@tonic-gate} 1720Sstevel@tonic-gate 1730Sstevel@tonic-gateif ((-e "testcompile") && (defined($ENV{'COMPILE'}))) { 1740Sstevel@tonic-gate push(@scripts, map("$_.exe", @scripts)); 1750Sstevel@tonic-gate} 1760Sstevel@tonic-gate 1770Sstevel@tonic-gatefind(sub { 1780Sstevel@tonic-gate if ("$File::Find::dir/$_" =~ m{^ext\b(.*)/([^/]+)\.pm$}) { 1790Sstevel@tonic-gate my($path, $modname) = ($1,$2); 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate # strip trailing component first 1820Sstevel@tonic-gate $path =~ s{/[^/]*$}{}; 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate # strip optional "/lib"; 1850Sstevel@tonic-gate $path =~ s{/lib\b}{}; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate # strip any leading / 1880Sstevel@tonic-gate $path =~ s{^/}{}; 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate # reconstitute canonical module name 1910Sstevel@tonic-gate $modname = "$path/$modname" if length $path; 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate # remember it 1940Sstevel@tonic-gate $archpms{$modname} = 1; 1950Sstevel@tonic-gate } 1960Sstevel@tonic-gate}, 'ext'); 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate# print "[$_]\n" for sort keys %archpms; 1990Sstevel@tonic-gate 2000Sstevel@tonic-gatemy $ver = $Config{version}; 2010Sstevel@tonic-gatemy $release = substr($],0,3); # Not used currently. 2020Sstevel@tonic-gatemy $patchlevel = substr($],3,2); 2030Sstevel@tonic-gatedie "Patchlevel of perl ($patchlevel)", 2040Sstevel@tonic-gate "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n" 2050Sstevel@tonic-gate if $patchlevel != $Config{'PERL_VERSION'}; 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate# Fetch some frequently-used items from %Config 2080Sstevel@tonic-gatemy $installbin = "$destdir$Config{installbin}"; 2090Sstevel@tonic-gatemy $installscript = "$destdir$Config{installscript}"; 2100Sstevel@tonic-gatemy $installprivlib = "$destdir$Config{installprivlib}"; 2110Sstevel@tonic-gatemy $installarchlib = "$destdir$Config{installarchlib}"; 2120Sstevel@tonic-gatemy $installsitelib = "$destdir$Config{installsitelib}"; 2130Sstevel@tonic-gatemy $installsitearch = "$destdir$Config{installsitearch}"; 2140Sstevel@tonic-gatemy $installman1dir = "$destdir$Config{installman1dir}"; 2150Sstevel@tonic-gatemy $man1ext = $Config{man1ext}; 2160Sstevel@tonic-gatemy $libperl = "$destdir$Config{libperl}"; 2170Sstevel@tonic-gate# Shared library and dynamic loading suffixes. 2180Sstevel@tonic-gatemy $so = $Config{so}; 2190Sstevel@tonic-gatemy $dlext = $Config{dlext}; 2200Sstevel@tonic-gatemy $dlsrc = $Config{dlsrc}; 2210Sstevel@tonic-gateif ($^O eq 'os390') { 2220Sstevel@tonic-gate my $pwd; 2230Sstevel@tonic-gate chomp($pwd=`pwd`); 2240Sstevel@tonic-gate my $archlibexp = $Config{archlibexp}; 2250Sstevel@tonic-gate my $usedl = $Config{usedl}; 2260Sstevel@tonic-gate if ($usedl eq 'define') { 2270Sstevel@tonic-gate `./$^X -pibak -e 's{$pwd\/libperl.x}{$archlibexp/CORE/libperl.x}' lib/Config.pm`; 2280Sstevel@tonic-gate } 2290Sstevel@tonic-gate} 2300Sstevel@tonic-gate 2310Sstevel@tonic-gateif ($nwinstall) { 2320Sstevel@tonic-gate # This is required only if we are installing on a NetWare server 2330Sstevel@tonic-gate $installscript = $Config{installnwscripts}; 2340Sstevel@tonic-gate $installprivlib = $Config{installnwlib}; 2350Sstevel@tonic-gate $installarchlib = $Config{installnwlib}; 2360Sstevel@tonic-gate $installsitelib = $Config{installnwlib}; 2370Sstevel@tonic-gate} 2380Sstevel@tonic-gate 2390Sstevel@tonic-gatemy $d_dosuid = $Config{d_dosuid}; 2400Sstevel@tonic-gatemy $binexp = $Config{binexp}; 2410Sstevel@tonic-gate 2420Sstevel@tonic-gateif ($Is_VMS) { # Hang in there until File::Spec hits the big time 2430Sstevel@tonic-gate foreach ( \$installbin, \$installscript, \$installprivlib, 2440Sstevel@tonic-gate \$installarchlib, \$installsitelib, \$installsitearch, 2450Sstevel@tonic-gate \$installman1dir ) { 2460Sstevel@tonic-gate $$_ = unixify($$_); $$_ =~ s:/$::; 2470Sstevel@tonic-gate } 2480Sstevel@tonic-gate} 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate# Do some quick sanity checks. 2510Sstevel@tonic-gate 2520Sstevel@tonic-gateif (!$nonono && $d_dosuid && $>) { die "You must run as root to install suidperl\n"; } 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate $installbin || die "No installbin directory in config.sh\n"; 2550Sstevel@tonic-gate-d $installbin || mkpath($installbin, $verbose, 0777); 2560Sstevel@tonic-gate-d $installbin || $nonono || die "$installbin is not a directory\n"; 2570Sstevel@tonic-gate-w $installbin || $nonono || die "$installbin is not writable by you\n" 2580Sstevel@tonic-gate unless $installbin =~ m#^/afs/# || $nonono; 2590Sstevel@tonic-gate 2600Sstevel@tonic-gateif (!$Is_NetWare) { 2610Sstevel@tonic-gateif (!$Is_VMS) { 2620Sstevel@tonic-gate-x 'perl' . $exe_ext || die "perl isn't executable!\n"; 2630Sstevel@tonic-gate} 2640Sstevel@tonic-gateelse { 2650Sstevel@tonic-gate-x $ndbg . 'perl' . $exe_ext || die "${ndbg}perl$exe_ext isn't executable!\n"; 2660Sstevel@tonic-gate if ($dbg) { 2670Sstevel@tonic-gate -x $dbg . 'perl' . $exe_ext || die "${dbg}perl$exe_ext isn't executable!\n"; 2680Sstevel@tonic-gate } 2690Sstevel@tonic-gate} 2700Sstevel@tonic-gate-x 'suidperl' . $exe_ext|| die "suidperl isn't executable!\n" if $d_dosuid; 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate# Removed for ON 2730Sstevel@tonic-gate#-f 't/rantests' || $Is_W32 2740Sstevel@tonic-gate# || warn "WARNING: You've never run 'make test' or", 2750Sstevel@tonic-gate# " some tests failed! (Installing anyway.)\n"; 2760Sstevel@tonic-gate} #if (!$Is_NetWare) 2770Sstevel@tonic-gate 2780Sstevel@tonic-gateif (($Is_W32 and ! $Is_NetWare) or $Is_Cygwin) { 2790Sstevel@tonic-gate my $perldll; 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate if ($Is_Cygwin) { 2820Sstevel@tonic-gate $perldll = $libperl; 2830Sstevel@tonic-gate my $v_e_r_s = $ver; $v_e_r_s =~ tr/./_/; 2840Sstevel@tonic-gate $perldll =~ s/(\..*)?$/$v_e_r_s.$dlext/; 2850Sstevel@tonic-gate $perldll =~ s/^lib/cyg/; 2860Sstevel@tonic-gate if ($Config{useshrplib} eq 'true') { 2870Sstevel@tonic-gate # install ld2 and perlld as well 2880Sstevel@tonic-gate foreach ('ld2', 'perlld') { 2890Sstevel@tonic-gate safe_unlink("$installbin/$_"); 2900Sstevel@tonic-gate copy("$_", "$installbin/$_"); 2910Sstevel@tonic-gate chmod(0755, "$installbin/$_"); 2920Sstevel@tonic-gate }; 2930Sstevel@tonic-gate open (LD2, ">$installbin/ld2"); 2940Sstevel@tonic-gate print LD2 <<SHELL; 2950Sstevel@tonic-gate#!/bin/sh 2960Sstevel@tonic-gate# 2970Sstevel@tonic-gate# ld wrapper, passes all args to perlld; 2980Sstevel@tonic-gate# 2990Sstevel@tonic-gatefor trythis in $installbin/perl 3000Sstevel@tonic-gatedo 3010Sstevel@tonic-gate if [ -x \$trythis ] 3020Sstevel@tonic-gate then 3030Sstevel@tonic-gate \$trythis $installbin/perlld "\$\@" 3040Sstevel@tonic-gate exit \$? 3050Sstevel@tonic-gate fi 3060Sstevel@tonic-gatedone 3070Sstevel@tonic-gate# hard luck! 3080Sstevel@tonic-gateecho I see no perl executable around there 3090Sstevel@tonic-gateecho perl is required to build dynamic libraries 3100Sstevel@tonic-gateecho look if the path to perl in /bin/ld2 is correct 3110Sstevel@tonic-gateexit 1 3120Sstevel@tonic-gateSHELL 3130Sstevel@tonic-gate close LD2; 3140Sstevel@tonic-gate chmod(0755, "$installbin/ld2"); 3150Sstevel@tonic-gate }; 3160Sstevel@tonic-gate } else { 3170Sstevel@tonic-gate $perldll = 'perl58.' . $dlext; 3180Sstevel@tonic-gate } 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate if ($dlsrc ne "dl_none.xs") { 3210Sstevel@tonic-gate -f $perldll || die "No perl DLL built\n"; 3220Sstevel@tonic-gate } 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate # Install the DLL 3250Sstevel@tonic-gate safe_unlink("$installbin/$perldll"); 3260Sstevel@tonic-gate copy("$perldll", "$installbin/$perldll"); 3270Sstevel@tonic-gate chmod(0755, "$installbin/$perldll"); 3280Sstevel@tonic-gate} # if (($Is_W32 and ! $Is_NetWare) or $Is_Cygwin) 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate# This will be used to store the packlist 3310Sstevel@tonic-gatemy $packlist = ExtUtils::Packlist->new("$installarchlib/.packlist"); 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate# First we install the version-numbered executables. 3340Sstevel@tonic-gate 3350Sstevel@tonic-gateif ($Is_VMS) { 3360Sstevel@tonic-gate safe_unlink("$installbin/perl_setup.com"); 3370Sstevel@tonic-gate copy("perl_setup.com", "$installbin/perl_setup.com"); 3380Sstevel@tonic-gate chmod(0755, "$installbin/perl_setup.com"); 3390Sstevel@tonic-gate safe_unlink("$installbin/$dbg$perl$exe_ext"); 3400Sstevel@tonic-gate copy("$dbg$perl$exe_ext", "$installbin/$dbg$perl$exe_ext"); 3410Sstevel@tonic-gate chmod(0755, "$installbin/$dbg$perl$exe_ext"); 3420Sstevel@tonic-gate safe_unlink("$installbin/$dbg${perl}shr$exe_ext"); 3430Sstevel@tonic-gate copy("$dbg${perl}shr$exe_ext", "$installbin/$dbg${perl}shr$exe_ext"); 3440Sstevel@tonic-gate chmod(0755, "$installbin/$dbg${perl}shr$exe_ext"); 3450Sstevel@tonic-gate if ($ndbg) { 3460Sstevel@tonic-gate safe_unlink("$installbin/$ndbg$perl$exe_ext"); 3470Sstevel@tonic-gate copy("$ndbg$perl$exe_ext", "$installbin/$ndbg$perl$exe_ext"); 3480Sstevel@tonic-gate chmod(0755, "$installbin/$ndbg$perl$exe_ext"); 3490Sstevel@tonic-gate safe_unlink("$installbin/${dbg}a2p$exe_ext"); 3500Sstevel@tonic-gate copy("x2p/${dbg}a2p$exe_ext", "$installbin/${dbg}a2p$exe_ext"); 3510Sstevel@tonic-gate chmod(0755, "$installbin/${dbg}a2p$exe_ext"); 3520Sstevel@tonic-gate } 3530Sstevel@tonic-gate} 3540Sstevel@tonic-gateelsif ($^O eq 'mpeix') { 3550Sstevel@tonic-gate # MPE lacks hard links and requires that executables with special 3560Sstevel@tonic-gate # capabilities reside in the MPE namespace. 3570Sstevel@tonic-gate safe_unlink("$installbin/perl$ver$exe_ext", $Config{perlpath}); 3580Sstevel@tonic-gate # Install the primary executable into the MPE namespace as perlpath. 3590Sstevel@tonic-gate copy("perl$exe_ext", $Config{perlpath}); 3600Sstevel@tonic-gate chmod(0755, $Config{perlpath}); 3610Sstevel@tonic-gate # Create a backup copy with the version number. 3620Sstevel@tonic-gate link($Config{perlpath}, "$installbin/perl$ver$exe_ext"); 3630Sstevel@tonic-gate} 3640Sstevel@tonic-gateelsif ($^O ne 'dos') { 3650Sstevel@tonic-gate if (!$Is_NetWare) { 3660Sstevel@tonic-gate if (copy_if_diff("perl$exe_ext", 3670Sstevel@tonic-gate "$installbin/$perl_verbase$ver$exe_ext")) { 3680Sstevel@tonic-gate strip("$installbin/$perl_verbase$ver$exe_ext"); 3690Sstevel@tonic-gate chmod(0555, "$installbin/$perl_verbase$ver$exe_ext"); 3700Sstevel@tonic-gate } 3710Sstevel@tonic-gate } 3720Sstevel@tonic-gate else { 3730Sstevel@tonic-gate # If installing onto a NetWare server 3740Sstevel@tonic-gate if ($nwinstall) { 3750Sstevel@tonic-gate # Copy perl.nlm, echo.nlm, type.nlm, a2p.nlm & cgi2perl.nlm 3760Sstevel@tonic-gate mkpath($Config{installnwsystem}, 1, 0777); 3770Sstevel@tonic-gate copy("netware\\".$ENV{'MAKE_TYPE'}."\\perl.nlm", $Config{installnwsystem}); 3780Sstevel@tonic-gate copy("netware\\testnlm\\echo\\echo.nlm", $Config{installnwsystem}); 3790Sstevel@tonic-gate copy("netware\\testnlm\\type\\type.nlm", $Config{installnwsystem}); 3800Sstevel@tonic-gate copy("x2p\\a2p.nlm", $Config{installnwsystem}); 3810Sstevel@tonic-gate chmod(0755, "$Config{installnwsystem}\\perl.nlm"); 3820Sstevel@tonic-gate mkpath($Config{installnwlcgi}, 1, 0777); 3830Sstevel@tonic-gate copy("lib\\auto\\cgi2perl\\cgi2perl.nlm", $Config{installnwlcgi}); 3840Sstevel@tonic-gate } 3850Sstevel@tonic-gate } #if (!$Is_NetWare) 3860Sstevel@tonic-gate} 3870Sstevel@tonic-gateelse { 3880Sstevel@tonic-gate safe_unlink("$installbin/$perl.exe"); 3890Sstevel@tonic-gate copy("perl.exe", "$installbin/$perl.exe"); 3900Sstevel@tonic-gate} 3910Sstevel@tonic-gate 3920Sstevel@tonic-gatesafe_unlink("$installbin/s$perl_verbase$ver$exe_ext"); 3930Sstevel@tonic-gateif ($d_dosuid) { 3940Sstevel@tonic-gate copy("suidperl$exe_ext", "$installbin/s$perl_verbase$ver$exe_ext"); 3950Sstevel@tonic-gate chmod(04711, "$installbin/s$perl_verbase$ver$exe_ext"); 3960Sstevel@tonic-gate} 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate# Install library files. 3990Sstevel@tonic-gate 4000Sstevel@tonic-gatemy ($do_installarchlib, $do_installprivlib) = (0, 0); 4010Sstevel@tonic-gate 4020Sstevel@tonic-gatemkpath($installprivlib, $verbose, 0777); 4030Sstevel@tonic-gatemkpath($installarchlib, $verbose, 0777); 4040Sstevel@tonic-gatemkpath($installsitelib, $verbose, 0777) if ($installsitelib); 4050Sstevel@tonic-gatemkpath($installsitearch, $verbose, 0777) if ($installsitearch); 4060Sstevel@tonic-gate 4070Sstevel@tonic-gateif (chdir "lib") { 4080Sstevel@tonic-gate $do_installarchlib = ! samepath($installarchlib, '.'); 4090Sstevel@tonic-gate $do_installprivlib = ! samepath($installprivlib, '.'); 4100Sstevel@tonic-gate $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$ver/); 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate if ($do_installarchlib || $do_installprivlib) { 4130Sstevel@tonic-gate find(\&installlib, '.'); 4140Sstevel@tonic-gate } 4150Sstevel@tonic-gate chdir ".." || die "Can't cd back to source directory: $!\n"; 4160Sstevel@tonic-gate} 4170Sstevel@tonic-gateelse { 4180Sstevel@tonic-gate warn "Can't cd to lib to install lib files: $!\n"; 4190Sstevel@tonic-gate} 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate# Install header files and libraries. 4220Sstevel@tonic-gatemkpath("$installarchlib/CORE", $verbose, 0777); 4230Sstevel@tonic-gatemy @corefiles; 4240Sstevel@tonic-gateif ($Is_VMS) { # We did core file selection during build 4250Sstevel@tonic-gate my $coredir = "lib/$Config{archname}/$ver/CORE"; 4260Sstevel@tonic-gate $coredir =~ tr/./_/; 4270Sstevel@tonic-gate map { s|^$coredir/||i; } @corefiles = <$coredir/*.*>; 4280Sstevel@tonic-gate} 4290Sstevel@tonic-gateelse { 4300Sstevel@tonic-gate # [als] hard-coded 'libperl' name... not good! 4310Sstevel@tonic-gate @corefiles = <*.h *.inc libperl*.* perl*$Config{lib_ext}>; 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate # AIX needs perl.exp installed as well. 4340Sstevel@tonic-gate push(@corefiles,'perl.exp') if $^O eq 'aix'; 4350Sstevel@tonic-gate if ($^O eq 'mpeix') { 4360Sstevel@tonic-gate # MPE needs mpeixish.h installed as well. 4370Sstevel@tonic-gate mkpath("$installarchlib/CORE/mpeix", $verbose, 0777); 4380Sstevel@tonic-gate push(@corefiles,'mpeix/mpeixish.h'); 4390Sstevel@tonic-gate } 4400Sstevel@tonic-gate # If they have built sperl.o... 4410Sstevel@tonic-gate push(@corefiles,'sperl.o') if -f 'sperl.o'; 4420Sstevel@tonic-gate} 4430Sstevel@tonic-gateforeach my $file (@corefiles) { 4440Sstevel@tonic-gate # HP-UX (at least) needs to maintain execute permissions 4450Sstevel@tonic-gate # on dynamically-loadable libraries. So we do it for all. 4460Sstevel@tonic-gate if (copy_if_diff($file,"$installarchlib/CORE/$file")) { 4470Sstevel@tonic-gate if ($file =~ /\.(\Q$so\E|\Q$dlext\E)$/) { 4480Sstevel@tonic-gate strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody|darwin)$/; 4490Sstevel@tonic-gate chmod(0555, "$installarchlib/CORE/$file"); 4500Sstevel@tonic-gate } else { 4510Sstevel@tonic-gate chmod(0444, "$installarchlib/CORE/$file"); 4520Sstevel@tonic-gate } 4530Sstevel@tonic-gate } 4540Sstevel@tonic-gate} 4550Sstevel@tonic-gate 4560Sstevel@tonic-gate# Switch in the 5.005-threads versions of he threadsafe queue and semaphore 4570Sstevel@tonic-gate# modules if so needed. 4580Sstevel@tonic-gateif ($Config{use5005threads}) { 4590Sstevel@tonic-gate for my $m (qw(Queue Semaphore)) { 4600Sstevel@tonic-gate my $t = "$installprivlib/Thread/$m.pm"; 4610Sstevel@tonic-gate unlink $t; 4620Sstevel@tonic-gate copy("ext/Thread/$m.pmx", $t); 4630Sstevel@tonic-gate chmod(0444, $t); 4640Sstevel@tonic-gate } 4650Sstevel@tonic-gate} 4660Sstevel@tonic-gate 4670Sstevel@tonic-gate# Install main perl executables 4680Sstevel@tonic-gate# Make links to ordinary names if installbin directory isn't current directory. 4690Sstevel@tonic-gate 4700Sstevel@tonic-gateif (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS && ! $Is_NetWare) { 4710Sstevel@tonic-gate safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext"); 4720Sstevel@tonic-gate if ($^O eq 'mpeix') { 4730Sstevel@tonic-gate # MPE doesn't support hard links, so use a symlink. 4740Sstevel@tonic-gate # We don't want another cloned copy. 4750Sstevel@tonic-gate symlink($Config{perlpath}, "$installbin/perl$exe_ext"); 4760Sstevel@tonic-gate } elsif ($^O eq 'vos') { 4770Sstevel@tonic-gate # VOS doesn't support hard links, so use a symlink. 4780Sstevel@tonic-gate symlink("$installbin/$perl_verbase$ver$exe_ext", 4790Sstevel@tonic-gate "$installbin/$perl$exe_ext"); 4800Sstevel@tonic-gate } else { 4810Sstevel@tonic-gate link("$installbin/$perl_verbase$ver$exe_ext", 4820Sstevel@tonic-gate "$installbin/$perl$exe_ext"); 4830Sstevel@tonic-gate } 4840Sstevel@tonic-gate link("$installbin/$perl_verbase$ver$exe_ext", 4850Sstevel@tonic-gate "$installbin/suid$perl$exe_ext") 4860Sstevel@tonic-gate if $d_dosuid; 4870Sstevel@tonic-gate} 4880Sstevel@tonic-gate 4890Sstevel@tonic-gate# For development purposes it can be very useful to have multiple perls 4900Sstevel@tonic-gate# build for different "architectures" (eg threading or not) simultaneously. 4910Sstevel@tonic-gateif ($archname && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) { 4920Sstevel@tonic-gate my $archperl = "$perl_verbase$ver-$Config{archname}$exe_ext"; 4930Sstevel@tonic-gate safe_unlink("$installbin/$archperl"); 4940Sstevel@tonic-gate if ($^O eq 'mpeix') { 4950Sstevel@tonic-gate # MPE doesn't support hard links, so use a symlink. 4960Sstevel@tonic-gate # We don't want another cloned copy. 4970Sstevel@tonic-gate symlink($Config{perlpath}, "$installbin/$archperl"); 4980Sstevel@tonic-gate } elsif ($^O eq 'vos') { 4990Sstevel@tonic-gate # VOS doesn't support hard links, so use a symlink. 5000Sstevel@tonic-gate symlink("$installbin/$perl_verbase$ver$exe_ext", 5010Sstevel@tonic-gate "$installbin/$archperl"); 5020Sstevel@tonic-gate } else { 5030Sstevel@tonic-gate link("$installbin/$perl_verbase$ver$exe_ext", "$installbin/$archperl"); 5040Sstevel@tonic-gate } 5050Sstevel@tonic-gate} 5060Sstevel@tonic-gate 5070Sstevel@tonic-gate# Offer to install perl in a "standard" location 5080Sstevel@tonic-gate 5090Sstevel@tonic-gatemy $mainperl_is_instperl = 0; 5100Sstevel@tonic-gate 5110Sstevel@tonic-gateif ($Config{installusrbinperl} && $Config{installusrbinperl} eq 'define' && 5120Sstevel@tonic-gate !$versiononly && !$nonono && !$Is_W32 && !$Is_NetWare && !$Is_VMS && -t STDIN && -t STDERR 5130Sstevel@tonic-gate && -w $mainperldir && ! samepath($mainperldir, $installbin)) { 5140Sstevel@tonic-gate my($usrbinperl) = "$mainperldir/$perl$exe_ext"; 5150Sstevel@tonic-gate my($instperl) = "$installbin/$perl$exe_ext"; 5160Sstevel@tonic-gate my($expinstperl) = "$binexp/$perl$exe_ext"; 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate # First make sure $usrbinperl is not already the same as the perl we 5190Sstevel@tonic-gate # just installed. 5200Sstevel@tonic-gate if (-x $usrbinperl) { 5210Sstevel@tonic-gate # Try to be clever about mainperl being a symbolic link 5220Sstevel@tonic-gate # to binexp/perl if binexp and installbin are different. 5230Sstevel@tonic-gate $mainperl_is_instperl = 5240Sstevel@tonic-gate samepath($usrbinperl, $instperl) || 5250Sstevel@tonic-gate samepath($usrbinperl, $expinstperl) || 5260Sstevel@tonic-gate (($binexp ne $installbin) && 5270Sstevel@tonic-gate (-l $usrbinperl) && 5280Sstevel@tonic-gate ((readlink $usrbinperl) eq $expinstperl)); 5290Sstevel@tonic-gate } 5300Sstevel@tonic-gate if (! $mainperl_is_instperl) { 5310Sstevel@tonic-gate unlink($usrbinperl); 5320Sstevel@tonic-gate ( $Config{'d_link'} eq 'define' && 5330Sstevel@tonic-gate eval { CORE::link $instperl, $usrbinperl } ) || 5340Sstevel@tonic-gate eval { symlink $expinstperl, $usrbinperl } || 5350Sstevel@tonic-gate copy($instperl, $usrbinperl); 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate $mainperl_is_instperl = 1; 5380Sstevel@tonic-gate } 5390Sstevel@tonic-gate} 5400Sstevel@tonic-gate 5410Sstevel@tonic-gate# Make links to ordinary names if installbin directory isn't current directory. 5420Sstevel@tonic-gateif (!$Is_NetWare && $dbg eq '') { 5430Sstevel@tonic-gate if (! samepath($installbin, 'x2p')) { 5440Sstevel@tonic-gate my $base = 'a2p'; 5450Sstevel@tonic-gate $base .= $ver if $versiononly; 5460Sstevel@tonic-gate copy_if_diff("x2p/a2p$exe_ext", "$installbin/$base$exe_ext"); 5470Sstevel@tonic-gate strip("$installbin/$base$exe_ext"); 5480Sstevel@tonic-gate chmod(0555, "$installbin/$base$exe_ext"); 5490Sstevel@tonic-gate } 5500Sstevel@tonic-gate} 5510Sstevel@tonic-gate 5520Sstevel@tonic-gate# cppstdin is just a script, but it is architecture-dependent, so 5530Sstevel@tonic-gate# it can't safely be shared. Place it in $installbin. 5540Sstevel@tonic-gate# Note that Configure doesn't build cppstin if it isn't needed, so 5550Sstevel@tonic-gate# we skip this if cppstdin doesn't exist. 5560Sstevel@tonic-gateif (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) { 5570Sstevel@tonic-gate safe_unlink("$installbin/cppstdin"); 5580Sstevel@tonic-gate copy("cppstdin", "$installbin/cppstdin"); 5590Sstevel@tonic-gate chmod(0555, "$installbin/cppstdin"); 5600Sstevel@tonic-gate} 5610Sstevel@tonic-gate 5620Sstevel@tonic-gatesub script_alias { 5630Sstevel@tonic-gate my ($installscript, $orig, $alias, $scr_ext) = @_; 5640Sstevel@tonic-gate 5650Sstevel@tonic-gate safe_unlink("$installscript/$alias$scr_ext"); 5660Sstevel@tonic-gate if ($^O eq 'dos' or $Is_VMS or $^O eq 'transit') { 5670Sstevel@tonic-gate copy("$installscript/$orig$scr_ext", 5680Sstevel@tonic-gate "$installscript/$alias$scr_ext"); 5690Sstevel@tonic-gate } elsif ($^O eq 'vos') { 5700Sstevel@tonic-gate symlink("$installscript/$orig$scr_ext", 5710Sstevel@tonic-gate "$installscript/$alias$scr_ext"); 5720Sstevel@tonic-gate } else { 5730Sstevel@tonic-gate link("$installscript/$orig$scr_ext", 5740Sstevel@tonic-gate "$installscript/$alias$scr_ext"); 5750Sstevel@tonic-gate } 5760Sstevel@tonic-gate} 5770Sstevel@tonic-gate 5780Sstevel@tonic-gate# Install scripts. 5790Sstevel@tonic-gatemkpath($installscript, $verbose, 0777); 5800Sstevel@tonic-gateif ($versiononly) { 5810Sstevel@tonic-gate for (@scripts) { 5820Sstevel@tonic-gate (my $base = $_) =~ s#.*/##; 5830Sstevel@tonic-gate $base .= $ver; 5840Sstevel@tonic-gate if (copy_if_diff($_, "$installscript/$base")) { 5850Sstevel@tonic-gate chmod(0555, "$installscript/$base"); 5860Sstevel@tonic-gate } 5870Sstevel@tonic-gate } 5880Sstevel@tonic-gate 5890Sstevel@tonic-gate for (@tolink) { 5900Sstevel@tonic-gate my ($from, $to) = map { "$_$ver" } @$_; 5910Sstevel@tonic-gate (my $frbase = $from) =~ s#.*/##; 5920Sstevel@tonic-gate (my $tobase = $to) =~ s#.*/##; 5930Sstevel@tonic-gate script_alias($installscript, $frbase, $tobase, $scr_ext); 5940Sstevel@tonic-gate } 5950Sstevel@tonic-gate} else { 5960Sstevel@tonic-gate for (@scripts) { 5970Sstevel@tonic-gate (my $base = $_) =~ s#.*/##; 5980Sstevel@tonic-gate copy_if_diff($_, "$installscript/$base"); 5990Sstevel@tonic-gate chmod(0555, "$installscript/$base"); 6000Sstevel@tonic-gate } 6010Sstevel@tonic-gate 6020Sstevel@tonic-gate for (@tolink) { 6030Sstevel@tonic-gate my ($from, $to) = @$_; 6040Sstevel@tonic-gate (my $frbase = $from) =~ s#.*/##; 6050Sstevel@tonic-gate (my $tobase = $to) =~ s#.*/##; 6060Sstevel@tonic-gate script_alias($installscript, $frbase, $tobase, $scr_ext); 6070Sstevel@tonic-gate } 6080Sstevel@tonic-gate} 6090Sstevel@tonic-gate 6100Sstevel@tonic-gate# Install pod pages. Where? I guess in $installprivlib/pod 6110Sstevel@tonic-gate# ($installprivlib/pods for cygwin). 6120Sstevel@tonic-gate 6130Sstevel@tonic-gatemy $pod = ($Is_Cygwin || $Is_Darwin) ? 'pods' : 'pod'; 6140Sstevel@tonic-gateif ( !$versiononly || ($installprivlib =~ m/\Q$ver/)) { 6150Sstevel@tonic-gate mkpath("${installprivlib}/$pod", $verbose, 0777); 6160Sstevel@tonic-gate 6170Sstevel@tonic-gate # If Perl 5.003's perldiag.pod is there, rename it. 6180Sstevel@tonic-gate if (open POD, "${installprivlib}/$pod/perldiag.pod") { 6190Sstevel@tonic-gate read POD, $_, 4000; 6200Sstevel@tonic-gate close POD; 6210Sstevel@tonic-gate # Some of Perl 5.003's diagnostic messages ended with periods. 6220Sstevel@tonic-gate if (/^=.*\.$/m) { 6230Sstevel@tonic-gate my ($from, $to) = ("${installprivlib}/$pod/perldiag.pod", 6240Sstevel@tonic-gate "${installprivlib}/$pod/perldiag-5.003.pod"); 6250Sstevel@tonic-gate print " rename $from $to"; 6260Sstevel@tonic-gate rename($from, $to) 6270Sstevel@tonic-gate or warn "Couldn't rename $from to $to: $!\n" 6280Sstevel@tonic-gate unless $nonono; 6290Sstevel@tonic-gate } 6300Sstevel@tonic-gate } 6310Sstevel@tonic-gate 6320Sstevel@tonic-gate for (@pods) { 6330Sstevel@tonic-gate # $_ is a name like pod/perl.pod 6340Sstevel@tonic-gate (my $base = $_) =~ s#.*/##; 6350Sstevel@tonic-gate if (copy_if_diff($_, "${installprivlib}/$pod/${base}")) { 6360Sstevel@tonic-gate chmod(0444, "${installprivlib}/$pod/${base}"); 6370Sstevel@tonic-gate } 6380Sstevel@tonic-gate } 6390Sstevel@tonic-gate 6400Sstevel@tonic-gate} 6410Sstevel@tonic-gate 6420Sstevel@tonic-gate# Check to make sure there aren't other perls around in installer's 6430Sstevel@tonic-gate# path. This is probably UNIX-specific. Check all absolute directories 6440Sstevel@tonic-gate# in the path except for where public executables are supposed to live. 6450Sstevel@tonic-gate# Also skip $mainperl if the user opted to have it be a link to the 6460Sstevel@tonic-gate# installed perl. 6470Sstevel@tonic-gate 6480Sstevel@tonic-gate# Note: Removed for ON. 6490Sstevel@tonic-gate 6500Sstevel@tonic-gate#if (!$versiononly && $otherperls) { 6510Sstevel@tonic-gate# my ($path, @path); 6520Sstevel@tonic-gate# my $dirsep = ($Is_OS2 || $Is_W32 || $Is_NetWare) ? ';' : ':' ; 6530Sstevel@tonic-gate# ($path = $ENV{"PATH"}) =~ s:\\:/:g ; 6540Sstevel@tonic-gate# @path = split(/$dirsep/, $path); 6550Sstevel@tonic-gate# if ($Is_VMS) { 6560Sstevel@tonic-gate# my $i = 0; 6570Sstevel@tonic-gate# while (exists $ENV{'DCL$PATH' . $i}) { 6580Sstevel@tonic-gate# my $dir = unixpath($ENV{'DCL$PATH' . $i}); $dir =~ s-/$--; 6590Sstevel@tonic-gate# push(@path,$dir); 6600Sstevel@tonic-gate# } 6610Sstevel@tonic-gate# } 6620Sstevel@tonic-gate# my @otherperls; 6630Sstevel@tonic-gate# my %otherperls; 6640Sstevel@tonic-gate# for (@path) { 6650Sstevel@tonic-gate# next unless m,^/,; 6660Sstevel@tonic-gate# # Use &samepath here because some systems have other dirs linked 6670Sstevel@tonic-gate# # to $mainperldir (like SunOS) 6680Sstevel@tonic-gate# next if samepath($_, $binexp); 6690Sstevel@tonic-gate# next if ($mainperl_is_instperl && samepath($_, $mainperldir)); 6700Sstevel@tonic-gate# my $otherperl = "$_/$perl$exe_ext"; 6710Sstevel@tonic-gate# next if $otherperls{$otherperl}++; 6720Sstevel@tonic-gate# push(@otherperls, $otherperl) 6730Sstevel@tonic-gate# if (-x $otherperl && ! -d $otherperl); 6740Sstevel@tonic-gate# } 6750Sstevel@tonic-gate# if (@otherperls) { 6760Sstevel@tonic-gate# warn "\nWarning: $perl appears in your path in the following " . 6770Sstevel@tonic-gate# "locations beyond where\nwe just installed it:\n"; 6780Sstevel@tonic-gate# for (@otherperls) { 6790Sstevel@tonic-gate# warn " ", $_, "\n"; 6800Sstevel@tonic-gate# } 6810Sstevel@tonic-gate# warn "\n"; 6820Sstevel@tonic-gate# } 6830Sstevel@tonic-gate#} 6840Sstevel@tonic-gate 6850Sstevel@tonic-gate# Added for ON - remove $ROOT prefix from the packlist entries. 6860Sstevel@tonic-gatemy $pat = qr{^$destdir}; 6870Sstevel@tonic-gatewhile (my ($k, $v) = each(%{$packlist})) { 6880Sstevel@tonic-gate delete($packlist->{$k}); 6890Sstevel@tonic-gate $k =~ s/$pat//; 6900Sstevel@tonic-gate if ($v->{type} eq 'link') { 6910Sstevel@tonic-gate my $l = delete($v->{from}); 6920Sstevel@tonic-gate $l =~ s/$pat//; 6930Sstevel@tonic-gate $v->{from} = $l; 6940Sstevel@tonic-gate } 6950Sstevel@tonic-gate $packlist->{$k} = $v; 6960Sstevel@tonic-gate} 6970Sstevel@tonic-gateif (! $nonono) { 6980Sstevel@tonic-gate $packlist->write("$installarchlib/.packlist.tmp"); 6990Sstevel@tonic-gate if (copy_if_diff("$installarchlib/.packlist.tmp", 7000Sstevel@tonic-gate "$installarchlib/.packlist")) { 7010Sstevel@tonic-gate chmod(0444, "$installarchlib/.packlist"); 7020Sstevel@tonic-gate } 7030Sstevel@tonic-gate safe_unlink("$installarchlib/.packlist.tmp"); 7040Sstevel@tonic-gate} 7050Sstevel@tonic-gate 7060Sstevel@tonic-gateprint " Installation complete\n" if $verbose; 7070Sstevel@tonic-gate 7080Sstevel@tonic-gateexit 0; 7090Sstevel@tonic-gate 7100Sstevel@tonic-gate############################################################################### 7110Sstevel@tonic-gate 7120Sstevel@tonic-gatesub yn { 7130Sstevel@tonic-gate my($prompt) = @_; 7140Sstevel@tonic-gate my($answer); 7150Sstevel@tonic-gate my($default) = $prompt =~ m/\[([yn])\]\s*$/i; 7160Sstevel@tonic-gate print STDERR $prompt; 7170Sstevel@tonic-gate chop($answer = <STDIN>); 7180Sstevel@tonic-gate $answer = $default if $answer =~ m/^\s*$/; 7190Sstevel@tonic-gate ($answer =~ m/^[yY]/); 7200Sstevel@tonic-gate} 7210Sstevel@tonic-gate 7220Sstevel@tonic-gatesub unlink { 7230Sstevel@tonic-gate my(@names) = @_; 7240Sstevel@tonic-gate my($cnt) = 0; 7250Sstevel@tonic-gate 7260Sstevel@tonic-gate return scalar(@names) if $Is_VMS; 7270Sstevel@tonic-gate 7280Sstevel@tonic-gate foreach my $name (@names) { 7290Sstevel@tonic-gate next unless -e $name; 7300Sstevel@tonic-gate chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_Cygwin || $Is_NetWare); 7310Sstevel@tonic-gate print " unlink $name\n" if $verbose; 7320Sstevel@tonic-gate ( CORE::unlink($name) and ++$cnt 7330Sstevel@tonic-gate or warn "Couldn't unlink $name: $!\n" ) unless $nonono; 7340Sstevel@tonic-gate } 7350Sstevel@tonic-gate return $cnt; 7360Sstevel@tonic-gate} 7370Sstevel@tonic-gate 7380Sstevel@tonic-gatesub safe_unlink { 7390Sstevel@tonic-gate return if $nonono or $Is_VMS; 7400Sstevel@tonic-gate my @names = @_; 7410Sstevel@tonic-gate foreach my $name (@names) { 7420Sstevel@tonic-gate next unless -e $name; 7430Sstevel@tonic-gate chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_NetWare); 7440Sstevel@tonic-gate print " unlink $name\n" if $verbose; 7450Sstevel@tonic-gate next if CORE::unlink($name); 7460Sstevel@tonic-gate warn "Couldn't unlink $name: $!\n"; 7470Sstevel@tonic-gate if ($! =~ /busy/i) { 7480Sstevel@tonic-gate print " mv $name $name.old\n" if $verbose; 7490Sstevel@tonic-gate safe_rename($name, "$name.old") 7500Sstevel@tonic-gate or warn "Couldn't rename $name: $!\n"; 7510Sstevel@tonic-gate } 7520Sstevel@tonic-gate } 7530Sstevel@tonic-gate} 7540Sstevel@tonic-gate 7550Sstevel@tonic-gatesub safe_rename { 7560Sstevel@tonic-gate my($from,$to) = @_; 7570Sstevel@tonic-gate if (-f $to and not unlink($to)) { 7580Sstevel@tonic-gate my($i); 7590Sstevel@tonic-gate for ($i = 1; $i < 50; $i++) { 7600Sstevel@tonic-gate last if rename($to, "$to.$i"); 7610Sstevel@tonic-gate } 7620Sstevel@tonic-gate warn("Cannot rename to `$to.$i': $!"), return 0 7630Sstevel@tonic-gate if $i >= 50; # Give up! 7640Sstevel@tonic-gate } 7650Sstevel@tonic-gate link($from,$to) || return 0; 7660Sstevel@tonic-gate unlink($from); 7670Sstevel@tonic-gate} 7680Sstevel@tonic-gate 7690Sstevel@tonic-gatesub link { 7700Sstevel@tonic-gate my($from,$to) = @_; 7710Sstevel@tonic-gate my($success) = 0; 7720Sstevel@tonic-gate 7730Sstevel@tonic-gate my $xfrom = $from; 7740Sstevel@tonic-gate $xfrom =~ s/^\Q$destdir\E// if $destdir; 7750Sstevel@tonic-gate my $xto = $to; 7760Sstevel@tonic-gate $xto =~ s/^\Q$destdir\E// if $destdir; 7770Sstevel@tonic-gate print $verbose ? " ln $xfrom $xto\n" : " $xto\n" unless $silent; 7780Sstevel@tonic-gate eval { 7790Sstevel@tonic-gate CORE::link($from, $to) 7800Sstevel@tonic-gate ? $success++ 7810Sstevel@tonic-gate : ($from =~ m#^/afs/# || $to =~ m#^/afs/#) 7820Sstevel@tonic-gate ? die "AFS" # okay inside eval {} 7830Sstevel@tonic-gate : die "Couldn't link $from to $to: $!\n" 7840Sstevel@tonic-gate unless $nonono; 7850Sstevel@tonic-gate $packlist->{$xto} = { from => $xfrom, type => 'link' }; 7860Sstevel@tonic-gate }; 7870Sstevel@tonic-gate if ($@) { 7880Sstevel@tonic-gate warn "Replacing link() with File::Copy::copy(): $@"; 7890Sstevel@tonic-gate print $verbose ? " cp $from $xto\n" : " $xto\n" unless $silent; 7900Sstevel@tonic-gate print " creating new version of $xto\n" 7910Sstevel@tonic-gate if $Is_VMS and -e $to and !$silent; 7920Sstevel@tonic-gate unless ($nonono or File::Copy::copy($from, $to) and ++$success) { 7930Sstevel@tonic-gate # Might have been that F::C::c can't overwrite the target 7940Sstevel@tonic-gate warn "Couldn't copy $from to $to: $!\n" 7950Sstevel@tonic-gate unless -f $to and (chmod(0666, $to), unlink $to) 7960Sstevel@tonic-gate and File::Copy::copy($from, $to) and ++$success; 7970Sstevel@tonic-gate } 7980Sstevel@tonic-gate $packlist->{$xto} = { type => 'file' }; 7990Sstevel@tonic-gate } 8000Sstevel@tonic-gate $success; 8010Sstevel@tonic-gate} 8020Sstevel@tonic-gate 8030Sstevel@tonic-gatesub chmod { 8040Sstevel@tonic-gate my($mode,$name) = @_; 8050Sstevel@tonic-gate 8060Sstevel@tonic-gate return if ($^O eq 'dos'); 8070Sstevel@tonic-gate printf " chmod %o %s\n", $mode, $name if $verbose; 8080Sstevel@tonic-gate CORE::chmod($mode,$name) 8090Sstevel@tonic-gate || warn sprintf("Couldn't chmod %o %s: $!\n", $mode, $name) 8100Sstevel@tonic-gate unless $nonono; 8110Sstevel@tonic-gate} 8120Sstevel@tonic-gate 8130Sstevel@tonic-gatesub copy { 8140Sstevel@tonic-gate my($from,$to) = @_; 8150Sstevel@tonic-gate 8160Sstevel@tonic-gate my $xto = $to; 8170Sstevel@tonic-gate $xto =~ s/^\Q$destdir\E// if $destdir; 8180Sstevel@tonic-gate print $verbose ? " cp $from $xto\n" : " $xto\n" unless $silent; 8190Sstevel@tonic-gate print " creating new version of $xto\n" if $Is_VMS and -e $to and !$silent; 8200Sstevel@tonic-gate unless ($nonono or File::Copy::copy($from, $to)) { 8210Sstevel@tonic-gate # Might have been that F::C::c can't overwrite the target 8220Sstevel@tonic-gate warn "Couldn't copy $from to $to: $!\n" 8230Sstevel@tonic-gate unless -f $to and (chmod(0666, $to), unlink $to) 8240Sstevel@tonic-gate and File::Copy::copy($from, $to); 8250Sstevel@tonic-gate } 8260Sstevel@tonic-gate $packlist->{$xto} = { type => 'file' }; 8270Sstevel@tonic-gate} 8280Sstevel@tonic-gate 8290Sstevel@tonic-gatesub samepath { 8300Sstevel@tonic-gate my($p1, $p2) = @_; 8310Sstevel@tonic-gate 8320Sstevel@tonic-gate return (lc($p1) eq lc($p2)) if ($Is_W32 || $Is_NetWare); 8330Sstevel@tonic-gate 8340Sstevel@tonic-gate if ($p1 ne $p2) { 8350Sstevel@tonic-gate my($dev1, $ino1, $dev2, $ino2); 8360Sstevel@tonic-gate ($dev1, $ino1) = stat($p1); 8370Sstevel@tonic-gate ($dev2, $ino2) = stat($p2); 8380Sstevel@tonic-gate ($dev1 == $dev2 && $ino1 == $ino2); 8390Sstevel@tonic-gate } 8400Sstevel@tonic-gate else { 8410Sstevel@tonic-gate 1; 8420Sstevel@tonic-gate } 8430Sstevel@tonic-gate} 8440Sstevel@tonic-gate 8450Sstevel@tonic-gatesub installlib { 8460Sstevel@tonic-gate my $dir = $File::Find::dir; 8470Sstevel@tonic-gate $dir =~ s#^\.(?![^/])/?##; 8480Sstevel@tonic-gate local($depth) = $dir ? "lib/$dir" : "lib"; 8490Sstevel@tonic-gate 8500Sstevel@tonic-gate my $name = $_; 8510Sstevel@tonic-gate 8520Sstevel@tonic-gate # Ignore version control directories and ON artifacts. 8530Sstevel@tonic-gate if (($name =~ /^(?:CVS|RCS|SCCS|\.svn)\z/ and -d $name) 8540Sstevel@tonic-gate or ($name eq '.tstamp' and -f $name)) { 8550Sstevel@tonic-gate $File::Find::prune = 1; 8560Sstevel@tonic-gate return; 8570Sstevel@tonic-gate } 8580Sstevel@tonic-gate 8590Sstevel@tonic-gate # ignore patch backups, RCS files, emacs backup & temp files and the 8600Sstevel@tonic-gate # .exists files, .PL files, and test files. 8610Sstevel@tonic-gate return if $name =~ m{\.orig$|\.rej$|~$|^#.+#$|,v$|^\.exists|\.PL$|\.plc$|\.t$|^test\.pl$} || 8620Sstevel@tonic-gate $dir =~ m{/t(?:/|$)}; 8630Sstevel@tonic-gate 8640Sstevel@tonic-gate # XXX xsubpp back out of the list. prove now integrated. Out of order, so 8650Sstevel@tonic-gate # p4 will conflict on the next update to the following lines: 8660Sstevel@tonic-gate 8670Sstevel@tonic-gate # ignore the cpan script in lib/CPAN/bin, the instmodsh and xsubpp 8680Sstevel@tonic-gate # scripts in lib/ExtUtils, and the prove script in lib/Test/Harness 8690Sstevel@tonic-gate # (they're installed later with other utils) 8700Sstevel@tonic-gate return if $name =~ /^(?:cpan|instmodsh|prove)\z/; 8710Sstevel@tonic-gate 8720Sstevel@tonic-gate # ignore the Makefiles 8730Sstevel@tonic-gate return if $name =~ /^makefile$/i; 8740Sstevel@tonic-gate # ignore the test extensions 8750Sstevel@tonic-gate return if $dir =~ m{ext/XS/(?:APItest|Typemap)/}; 8760Sstevel@tonic-gate 8770Sstevel@tonic-gate $name = "$dir/$name" if $dir ne ''; 8780Sstevel@tonic-gate 8790Sstevel@tonic-gate my $installlib = $installprivlib; 8800Sstevel@tonic-gate if ($dir =~ /^auto/ || 8810Sstevel@tonic-gate ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) || 8820Sstevel@tonic-gate ($name =~ /^(.*)\.(?:h|lib)$/i && ($Is_W32 || $Is_NetWare)) 8830Sstevel@tonic-gate ) { 8840Sstevel@tonic-gate $installlib = $installarchlib; 8850Sstevel@tonic-gate return unless $do_installarchlib; 8860Sstevel@tonic-gate } else { 8870Sstevel@tonic-gate return unless $do_installprivlib; 8880Sstevel@tonic-gate } 8890Sstevel@tonic-gate 8900Sstevel@tonic-gate if (-f $_) { 8910Sstevel@tonic-gate if (/\.(?:al|ix)$/ && !($dir =~ m[^auto/(.*)$] && $archpms{$1})) { 8920Sstevel@tonic-gate $installlib = $installprivlib; 8930Sstevel@tonic-gate #We're installing *.al and *.ix files into $installprivlib, 8940Sstevel@tonic-gate #but we have to delete old *.al and *.ix files from the 5.000 8950Sstevel@tonic-gate #distribution: 8960Sstevel@tonic-gate #This might not work because $archname might have changed. 8970Sstevel@tonic-gate unlink("$installarchlib/$name"); 8980Sstevel@tonic-gate } 8990Sstevel@tonic-gate my $xname = "$installlib/$name"; 9000Sstevel@tonic-gate $xname =~ s/^\Q$destdir\E// if $destdir; 9010Sstevel@tonic-gate $packlist->{$xname} = { type => 'file' }; 9020Sstevel@tonic-gate if ($force || compare($_, "$installlib/$name") || $nonono) { 9030Sstevel@tonic-gate unlink("$installlib/$name"); 9040Sstevel@tonic-gate mkpath("$installlib/$dir", $verbose, 0777); 9050Sstevel@tonic-gate # HP-UX (at least) needs to maintain execute permissions 9060Sstevel@tonic-gate # on dynamically-loaded libraries. 9070Sstevel@tonic-gate if ($Is_NetWare && !$nwinstall) { 9080Sstevel@tonic-gate # Don't copy .nlp,.nlm files, doesn't make sense on Windows and also 9090Sstevel@tonic-gate # if copied will give problems when building new extensions. 9100Sstevel@tonic-gate # Has to be copied if we are installing on a NetWare server and hence 9110Sstevel@tonic-gate # the check !$nwinstall 9120Sstevel@tonic-gate if (!(/\.(?:nlp|nlm|bs)$/)) { 9130Sstevel@tonic-gate copy_if_diff($_, "$installlib/$name") 9140Sstevel@tonic-gate and chmod($name =~ /\.(so|$dlext)$/o ? 0555 : 0444, 9150Sstevel@tonic-gate "$installlib/$name"); 9160Sstevel@tonic-gate } 9170Sstevel@tonic-gate } else { 9180Sstevel@tonic-gate if (copy_if_diff($_, "$installlib/$name")) { 9190Sstevel@tonic-gate if ($name =~ /\.(so|$dlext)$/o) { 9200Sstevel@tonic-gate strip("-S", "$installlib/$name") if $^O =~ /^(rhapsody|darwin)$/; 9210Sstevel@tonic-gate chmod(0555, "$installlib/$name"); 9220Sstevel@tonic-gate } else { 9230Sstevel@tonic-gate strip("-S", "$installlib/$name") 9240Sstevel@tonic-gate if ($name =~ /\.a$/o and $^O =~ /^(rhapsody|darwin)$/); 9250Sstevel@tonic-gate chmod(0444, "$installlib/$name"); 9260Sstevel@tonic-gate } 9270Sstevel@tonic-gate } 9280Sstevel@tonic-gate } #if ($Is_NetWare) 9290Sstevel@tonic-gate } 9300Sstevel@tonic-gate } 9310Sstevel@tonic-gate} 9320Sstevel@tonic-gate 9330Sstevel@tonic-gate# Copy $from to $to, only if $from is different than $to. 9340Sstevel@tonic-gate# Also preserve modification times for .a libraries. 9350Sstevel@tonic-gate# On some systems, if you do 9360Sstevel@tonic-gate# ranlib libperl.a 9370Sstevel@tonic-gate# cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a 9380Sstevel@tonic-gate# and then try to link against the installed libperl.a, you might 9390Sstevel@tonic-gate# get an error message to the effect that the symbol table is older 9400Sstevel@tonic-gate# than the library. 9410Sstevel@tonic-gate# Return true if copying occurred. 9420Sstevel@tonic-gate 9430Sstevel@tonic-gatesub copy_if_diff { 9440Sstevel@tonic-gate my($from,$to)=@_; 9450Sstevel@tonic-gate return 1 if (($^O eq 'VMS') && (-d $from)); 9460Sstevel@tonic-gate my $xto = $to; 9470Sstevel@tonic-gate $xto =~ s/^\Q$destdir\E// if $destdir; 9480Sstevel@tonic-gate my $perlpodbadsymlink; 9490Sstevel@tonic-gate if ($from =~ m!^pod/perl[\w-]+\.pod$! && 9500Sstevel@tonic-gate -l $from && 9510Sstevel@tonic-gate ! -e $from) { 9520Sstevel@tonic-gate # Some Linux implementations have problems traversing over 9530Sstevel@tonic-gate # multiple symlinks (when going over NFS?) and fail to read 9540Sstevel@tonic-gate # the symlink target. Combine this with the fact that some 9550Sstevel@tonic-gate # of the pod files (the perl$OS.pod) are symlinks (to ../README.$OS), 9560Sstevel@tonic-gate # and you end up with those pods not getting installed. 9570Sstevel@tonic-gate $perlpodbadsymlink = 1; 9580Sstevel@tonic-gate } 9590Sstevel@tonic-gate -f $from || $perlpodbadsymlink || warn "$0: $from not found"; 9600Sstevel@tonic-gate $packlist->{$xto} = { type => 'file' }; 9610Sstevel@tonic-gate if ($force || compare($from, $to) || $nonono) { 9620Sstevel@tonic-gate safe_unlink($to); # In case we don't have write permissions. 9630Sstevel@tonic-gate if ($nonono) { 9640Sstevel@tonic-gate $from = $depth . "/" . $from if $depth; 9650Sstevel@tonic-gate } 9660Sstevel@tonic-gate if ($perlpodbadsymlink && $from =~ m!^pod/perl(.+)\.pod$!) { 9670Sstevel@tonic-gate $from = "README.$1"; 9680Sstevel@tonic-gate } 9690Sstevel@tonic-gate copy($from, $to); 9700Sstevel@tonic-gate # Restore timestamps if it's a .a library or for OS/2. 9710Sstevel@tonic-gate if (!$nonono && ($Is_OS2 || $to =~ /\.a$/)) { 9720Sstevel@tonic-gate my ($atime, $mtime) = (stat $from)[8,9]; 9730Sstevel@tonic-gate utime $atime, $mtime, $to; 9740Sstevel@tonic-gate } 9750Sstevel@tonic-gate 1; 9760Sstevel@tonic-gate } 9770Sstevel@tonic-gate} 9780Sstevel@tonic-gate 9790Sstevel@tonic-gatesub strip 9800Sstevel@tonic-gate{ 9810Sstevel@tonic-gate my(@args) = @_; 9820Sstevel@tonic-gate 9830Sstevel@tonic-gate return unless $dostrip; 9840Sstevel@tonic-gate 9850Sstevel@tonic-gate my @opts; 9860Sstevel@tonic-gate while (@args && $args[0] =~ /^(-\w+)$/) { 9870Sstevel@tonic-gate push @opts, shift @args; 9880Sstevel@tonic-gate } 9890Sstevel@tonic-gate 9900Sstevel@tonic-gate foreach my $file (@args) { 9910Sstevel@tonic-gate if (-f $file) { 9920Sstevel@tonic-gate if ($verbose) { 9930Sstevel@tonic-gate print " strip " . join(' ', @opts); 9940Sstevel@tonic-gate print " " if (@opts); 9950Sstevel@tonic-gate print "$file\n"; 9960Sstevel@tonic-gate } 9970Sstevel@tonic-gate system("strip", @opts, $file); 9980Sstevel@tonic-gate } else { 9990Sstevel@tonic-gate print "# file '$file' skipped\n" if $verbose; 10000Sstevel@tonic-gate } 10010Sstevel@tonic-gate } 10020Sstevel@tonic-gate} 1003