1*0Sstevel@tonic-gate# MM_MacOS.pm 2*0Sstevel@tonic-gate# MakeMaker default methods for MacOS 3*0Sstevel@tonic-gate# This package is inserted into @ISA of MakeMaker's MM before the 4*0Sstevel@tonic-gate# built-in ExtUtils::MM_Unix methods if MakeMaker.pm is run under MacOS. 5*0Sstevel@tonic-gate# 6*0Sstevel@tonic-gate# Author: Matthias Neeracher <neeracher@mac.com> 7*0Sstevel@tonic-gate# Maintainer: Chris Nandor <pudge@pobox.com> 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gatepackage ExtUtils::MM_MacOS; 10*0Sstevel@tonic-gaterequire ExtUtils::MM_Any; 11*0Sstevel@tonic-gaterequire ExtUtils::MM_Unix; 12*0Sstevel@tonic-gate@ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix ); 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gateuse vars qw($VERSION); 15*0Sstevel@tonic-gate$VERSION = '1.07'; 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gateuse Config; 18*0Sstevel@tonic-gateuse Cwd 'cwd'; 19*0Sstevel@tonic-gaterequire Exporter; 20*0Sstevel@tonic-gateuse File::Basename; 21*0Sstevel@tonic-gateuse vars qw(%make_data); 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gatemy $Mac_FS = eval { require Mac::FileSpec::Unixish }; 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gateuse ExtUtils::MakeMaker qw($Verbose &neatvalue); 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate=head1 NAME 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gateExtUtils::MM_MacOS - methods to override UN*X behaviour in ExtUtils::MakeMaker 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate=head1 SYNOPSIS 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate use ExtUtils::MM_MacOS; # Done internally by ExtUtils::MakeMaker if needed 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate=head1 DESCRIPTION 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gateMM_MacOS currently only produces an approximation to the correct Makefile. 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate=over 4 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate=cut 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gatesub new { 44*0Sstevel@tonic-gate my($class,$self) = @_; 45*0Sstevel@tonic-gate my($key); 46*0Sstevel@tonic-gate my($cwd) = cwd(); 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate print STDOUT "Mac MakeMaker (v$ExtUtils::MakeMaker::VERSION)\n" if $Verbose; 49*0Sstevel@tonic-gate if (-f "MANIFEST" && ! -f "Makefile.mk"){ 50*0Sstevel@tonic-gate ExtUtils::MakeMaker::check_manifest(); 51*0Sstevel@tonic-gate } 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate mkdir("Obj", 0777) unless -d "Obj"; 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate $self = {} unless defined $self; 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate check_hints($self); 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate my(%initial_att) = %$self; # record initial attributes 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate if (defined $self->{CONFIGURE}) { 62*0Sstevel@tonic-gate if (ref $self->{CONFIGURE} eq 'CODE') { 63*0Sstevel@tonic-gate $self = { %$self, %{&{$self->{CONFIGURE}}}}; 64*0Sstevel@tonic-gate } else { 65*0Sstevel@tonic-gate require Carp; 66*0Sstevel@tonic-gate Carp::croak("Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n"); 67*0Sstevel@tonic-gate } 68*0Sstevel@tonic-gate } 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate my $newclass = ++$ExtUtils::MakeMaker::PACKNAME; 71*0Sstevel@tonic-gate local @ExtUtils::MakeMaker::Parent = @ExtUtils::MakeMaker::Parent; # Protect against non-local exits 72*0Sstevel@tonic-gate { 73*0Sstevel@tonic-gate no strict 'refs'; 74*0Sstevel@tonic-gate print "Blessing Object into class [$newclass]\n" if $Verbose>=2; 75*0Sstevel@tonic-gate ExtUtils::MakeMaker::mv_all_methods("MY",$newclass); 76*0Sstevel@tonic-gate bless $self, $newclass; 77*0Sstevel@tonic-gate push @Parent, $self; 78*0Sstevel@tonic-gate require ExtUtils::MY; 79*0Sstevel@tonic-gate @{"$newclass\:\:ISA"} = 'MM'; 80*0Sstevel@tonic-gate } 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate $ExtUtils::MakeMaker::Recognized_Att_Keys{$_} = 1 83*0Sstevel@tonic-gate for map { $_ . 'Optimize' } qw(MWC MWCPPC MWC68K MPW MRC MRC SC); 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate if (defined $ExtUtils::MakeMaker::Parent[-2]){ 86*0Sstevel@tonic-gate $self->{PARENT} = $ExtUtils::MakeMaker::Parent[-2]; 87*0Sstevel@tonic-gate my $key; 88*0Sstevel@tonic-gate for $key (@ExtUtils::MakeMaker::Prepend_parent) { 89*0Sstevel@tonic-gate next unless defined $self->{PARENT}{$key}; 90*0Sstevel@tonic-gate $self->{$key} = $self->{PARENT}{$key}; 91*0Sstevel@tonic-gate if ($key !~ /PERL$/) { 92*0Sstevel@tonic-gate $self->{$key} = $self->catdir("..",$self->{$key}) 93*0Sstevel@tonic-gate unless $self->file_name_is_absolute($self->{$key}); 94*0Sstevel@tonic-gate } else { 95*0Sstevel@tonic-gate # PERL or FULLPERL will be a command verb or even a 96*0Sstevel@tonic-gate # command with an argument instead of a full file 97*0Sstevel@tonic-gate # specification under VMS. So, don't turn the command 98*0Sstevel@tonic-gate # into a filespec, but do add a level to the path of 99*0Sstevel@tonic-gate # the argument if not already absolute. 100*0Sstevel@tonic-gate my @cmd = split /\s+/, $self->{$key}; 101*0Sstevel@tonic-gate $cmd[1] = $self->catfile('[-]',$cmd[1]) 102*0Sstevel@tonic-gate unless (@cmd < 2) || $self->file_name_is_absolute($cmd[1]); 103*0Sstevel@tonic-gate $self->{$key} = join(' ', @cmd); 104*0Sstevel@tonic-gate } 105*0Sstevel@tonic-gate } 106*0Sstevel@tonic-gate if ($self->{PARENT}) { 107*0Sstevel@tonic-gate $self->{PARENT}->{CHILDREN}->{$newclass} = $self; 108*0Sstevel@tonic-gate foreach my $opt (qw(POLLUTE PERL_CORE)) { 109*0Sstevel@tonic-gate if (exists $self->{PARENT}->{$opt} 110*0Sstevel@tonic-gate and not exists $self->{$opt}) 111*0Sstevel@tonic-gate { 112*0Sstevel@tonic-gate # inherit, but only if already unspecified 113*0Sstevel@tonic-gate $self->{$opt} = $self->{PARENT}->{$opt}; 114*0Sstevel@tonic-gate } 115*0Sstevel@tonic-gate } 116*0Sstevel@tonic-gate } 117*0Sstevel@tonic-gate my @fm = grep /^FIRST_MAKEFILE=/, @ARGV; 118*0Sstevel@tonic-gate $self->parse_args(@fm) if @fm; 119*0Sstevel@tonic-gate } else { 120*0Sstevel@tonic-gate $self->parse_args(split(' ', $ENV{PERL_MM_OPT} || ''),@ARGV); 121*0Sstevel@tonic-gate } 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate $self->{NAME} ||= $self->guess_name; 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g; 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate $self->init_main(); 128*0Sstevel@tonic-gate $self->init_dirscan(); 129*0Sstevel@tonic-gate $self->init_others(); 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate push @{$self->{RESULT}}, <<END; 132*0Sstevel@tonic-gate# This Makefile is for the $self->{NAME} extension to perl. 133*0Sstevel@tonic-gate# 134*0Sstevel@tonic-gate# It was generated automatically by MakeMaker version 135*0Sstevel@tonic-gate# $ExtUtils::MakeMaker::VERSION (Revision: $ExtUtils::MakeMaker::Revision) from the contents of 136*0Sstevel@tonic-gate# Makefile.PL. Don't edit this file, edit Makefile.PL instead. 137*0Sstevel@tonic-gate# 138*0Sstevel@tonic-gate# ANY CHANGES MADE HERE WILL BE LOST! 139*0Sstevel@tonic-gate# 140*0Sstevel@tonic-gate# MakeMaker Parameters: 141*0Sstevel@tonic-gateEND 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate foreach $key (sort keys %initial_att){ 144*0Sstevel@tonic-gate my($v) = neatvalue($initial_att{$key}); 145*0Sstevel@tonic-gate $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/; 146*0Sstevel@tonic-gate $v =~ tr/\n/ /s; 147*0Sstevel@tonic-gate push @{$self->{RESULT}}, "# $key => $v"; 148*0Sstevel@tonic-gate } 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate # turn the SKIP array into a SKIPHASH hash 151*0Sstevel@tonic-gate my (%skip,$skip); 152*0Sstevel@tonic-gate for $skip (@{$self->{SKIP} || []}) { 153*0Sstevel@tonic-gate $self->{SKIPHASH}{$skip} = 1; 154*0Sstevel@tonic-gate } 155*0Sstevel@tonic-gate delete $self->{SKIP}; # free memory 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate # We skip many sections for MacOS, but we don't say anything about it in the Makefile 158*0Sstevel@tonic-gate for (qw/ const_config tool_autosplit 159*0Sstevel@tonic-gate tool_xsubpp tools_other dist macro depend post_constants 160*0Sstevel@tonic-gate pasthru c_o xs_c xs_o top_targets linkext 161*0Sstevel@tonic-gate dynamic_bs dynamic_lib static_lib manifypods 162*0Sstevel@tonic-gate installbin subdirs dist_basics dist_core 163*0Sstevel@tonic-gate distdir dist_test dist_ci install force perldepend makefile 164*0Sstevel@tonic-gate staticmake test pm_to_blib selfdocument 165*0Sstevel@tonic-gate const_loadlibs const_cccmd 166*0Sstevel@tonic-gate /) 167*0Sstevel@tonic-gate { 168*0Sstevel@tonic-gate $self->{SKIPHASH}{$_} = 2; 169*0Sstevel@tonic-gate } 170*0Sstevel@tonic-gate push @ExtUtils::MakeMaker::MM_Sections, "rulez" 171*0Sstevel@tonic-gate unless grep /rulez/, @ExtUtils::MakeMaker::MM_Sections; 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate if ($self->{PARENT}) { 174*0Sstevel@tonic-gate for (qw/install dist dist_basics dist_core distdir dist_test dist_ci/) { 175*0Sstevel@tonic-gate $self->{SKIPHASH}{$_} = 1; 176*0Sstevel@tonic-gate } 177*0Sstevel@tonic-gate } 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate # We run all the subdirectories now. They don't have much to query 180*0Sstevel@tonic-gate # from the parent, but the parent has to query them: if they need linking! 181*0Sstevel@tonic-gate unless ($self->{NORECURS}) { 182*0Sstevel@tonic-gate $self->eval_in_subdirs if @{$self->{DIR}}; 183*0Sstevel@tonic-gate } 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate my $section; 186*0Sstevel@tonic-gate foreach $section ( @ExtUtils::MakeMaker::MM_Sections ){ 187*0Sstevel@tonic-gate next if defined $self->{SKIPHASH}{$section} && 188*0Sstevel@tonic-gate $self->{SKIPHASH}{$section} == 2; 189*0Sstevel@tonic-gate print "Processing Makefile '$section' section\n" if ($Verbose >= 2); 190*0Sstevel@tonic-gate $self->{ABSTRACT_FROM} = macify($self->{ABSTRACT_FROM}) 191*0Sstevel@tonic-gate if $self->{ABSTRACT_FROM}; 192*0Sstevel@tonic-gate my($skipit) = $self->skipcheck($section); 193*0Sstevel@tonic-gate if ($skipit){ 194*0Sstevel@tonic-gate push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit."; 195*0Sstevel@tonic-gate } else { 196*0Sstevel@tonic-gate my(%a) = %{$self->{$section} || {}}; 197*0Sstevel@tonic-gate push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:"; 198*0Sstevel@tonic-gate push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a; 199*0Sstevel@tonic-gate push @{$self->{RESULT}}, $self->nicetext($self->$section( %a )); 200*0Sstevel@tonic-gate } 201*0Sstevel@tonic-gate } 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate push @{$self->{RESULT}}, "\n# End."; 204*0Sstevel@tonic-gate pop @Parent; 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate $ExtUtils::MM_MacOS::make_data{$cwd} = $self; 207*0Sstevel@tonic-gate $self; 208*0Sstevel@tonic-gate} 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gatesub skipcheck { 211*0Sstevel@tonic-gate my($self) = shift; 212*0Sstevel@tonic-gate my($section) = @_; 213*0Sstevel@tonic-gate return 'skipped' if $self->{SKIPHASH}{$section}; 214*0Sstevel@tonic-gate return ''; 215*0Sstevel@tonic-gate} 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate=item maybe_command 218*0Sstevel@tonic-gate 219*0Sstevel@tonic-gateReturns true, if the argument is likely to be a command. 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate=cut 222*0Sstevel@tonic-gate 223*0Sstevel@tonic-gatesub maybe_command { 224*0Sstevel@tonic-gate my($self,$file) = @_; 225*0Sstevel@tonic-gate return $file if ! -d $file; 226*0Sstevel@tonic-gate return; 227*0Sstevel@tonic-gate} 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate=item guess_name 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gateGuess the name of this package by examining the working directory's 232*0Sstevel@tonic-gatename. MakeMaker calls this only if the developer has not supplied a 233*0Sstevel@tonic-gateNAME attribute. 234*0Sstevel@tonic-gate 235*0Sstevel@tonic-gate=cut 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gatesub guess_name { 238*0Sstevel@tonic-gate my($self) = @_; 239*0Sstevel@tonic-gate my $name = cwd(); 240*0Sstevel@tonic-gate $name =~ s/.*:// unless ($name =~ s/^.*:ext://); 241*0Sstevel@tonic-gate $name =~ s#:#::#g; 242*0Sstevel@tonic-gate $name =~ s#[\-_][\d.\-]+$##; # this is new with MM 5.00 243*0Sstevel@tonic-gate $name; 244*0Sstevel@tonic-gate} 245*0Sstevel@tonic-gate 246*0Sstevel@tonic-gate=item macify 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gateTranslate relative Unix filepaths into Mac names. 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate=cut 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gatesub macify { 253*0Sstevel@tonic-gate my($unix) = @_; 254*0Sstevel@tonic-gate my(@mac); 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate foreach (split(/[ \t\n]+/, $unix)) { 257*0Sstevel@tonic-gate if (m|/|) { 258*0Sstevel@tonic-gate if ($Mac_FS) { # should always be true 259*0Sstevel@tonic-gate $_ = Mac::FileSpec::Unixish::nativize($_); 260*0Sstevel@tonic-gate } else { 261*0Sstevel@tonic-gate s|^\./||; 262*0Sstevel@tonic-gate s|/|:|g; 263*0Sstevel@tonic-gate $_ = ":$_"; 264*0Sstevel@tonic-gate } 265*0Sstevel@tonic-gate } 266*0Sstevel@tonic-gate push(@mac, $_); 267*0Sstevel@tonic-gate } 268*0Sstevel@tonic-gate 269*0Sstevel@tonic-gate return "@mac"; 270*0Sstevel@tonic-gate} 271*0Sstevel@tonic-gate 272*0Sstevel@tonic-gate=item patternify 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gateTranslate Unix filepaths and shell globs to Mac style. 275*0Sstevel@tonic-gate 276*0Sstevel@tonic-gate=cut 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gatesub patternify { 279*0Sstevel@tonic-gate my($unix) = @_; 280*0Sstevel@tonic-gate my(@mac); 281*0Sstevel@tonic-gate use ExtUtils::MakeMaker::bytes; # Non-UTF-8 high bytes below. 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate foreach (split(/[ \t\n]+/, $unix)) { 284*0Sstevel@tonic-gate if (m|/|) { 285*0Sstevel@tonic-gate $_ = ":$_"; 286*0Sstevel@tonic-gate s|/|:|g; 287*0Sstevel@tonic-gate s|\*|�|g; 288*0Sstevel@tonic-gate $_ = "'$_'" if /[?�]/; 289*0Sstevel@tonic-gate push(@mac, $_); 290*0Sstevel@tonic-gate } 291*0Sstevel@tonic-gate } 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate return "@mac"; 294*0Sstevel@tonic-gate} 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate=item init_main 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gateInitializes some of NAME, FULLEXT, BASEEXT, DLBASE, PERL_SRC, 299*0Sstevel@tonic-gatePERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*, 300*0Sstevel@tonic-gatePREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, MAP_TARGET, 301*0Sstevel@tonic-gateLIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM. 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gate=cut 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gatesub init_main { 306*0Sstevel@tonic-gate my($self) = @_; 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate # --- Initialize Module Name and Paths 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate # NAME = The perl module name for this extension (eg DBD::Oracle). 311*0Sstevel@tonic-gate # FULLEXT = Pathname for extension directory (eg DBD/Oracle). 312*0Sstevel@tonic-gate # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. 313*0Sstevel@tonic-gate ($self->{FULLEXT} = 314*0Sstevel@tonic-gate $self->{NAME}) =~ s!::!:!g ; #eg. BSD:Foo:Socket 315*0Sstevel@tonic-gate ($self->{BASEEXT} = 316*0Sstevel@tonic-gate $self->{NAME}) =~ s!.*::!! ; #eg. Socket 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate # --- Initialize PERL_LIB, INST_LIB, PERL_SRC 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate # *Real* information: where did we get these two from? ... 321*0Sstevel@tonic-gate my $inc_config_dir = dirname($INC{'Config.pm'}); 322*0Sstevel@tonic-gate my $inc_carp_dir = dirname($INC{'Carp.pm'}); 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate unless ($self->{PERL_SRC}){ 325*0Sstevel@tonic-gate my($dir); 326*0Sstevel@tonic-gate foreach $dir (qw(:: ::: :::: ::::: ::::::)){ 327*0Sstevel@tonic-gate if (-f "${dir}perl.h") { 328*0Sstevel@tonic-gate $self->{PERL_SRC}=$dir ; 329*0Sstevel@tonic-gate last; 330*0Sstevel@tonic-gate } 331*0Sstevel@tonic-gate } 332*0Sstevel@tonic-gate if (!$self->{PERL_SRC} && -f "$ENV{MACPERL}CORE:perl:perl.h") { 333*0Sstevel@tonic-gate # Mac pathnames may be very nasty, so we'll install symlinks 334*0Sstevel@tonic-gate unlink(":PerlCore", ":PerlLib"); 335*0Sstevel@tonic-gate symlink("$ENV{MACPERL}CORE:", "PerlCore"); 336*0Sstevel@tonic-gate symlink("$ENV{MACPERL}lib:", "PerlLib"); 337*0Sstevel@tonic-gate $self->{PERL_SRC} = ":PerlCore:perl:" ; 338*0Sstevel@tonic-gate $self->{PERL_LIB} = ":PerlLib:"; 339*0Sstevel@tonic-gate } 340*0Sstevel@tonic-gate } 341*0Sstevel@tonic-gate if ($self->{PERL_SRC}){ 342*0Sstevel@tonic-gate $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib"); 343*0Sstevel@tonic-gate $self->{PERL_ARCHLIB} = $self->{PERL_LIB}; 344*0Sstevel@tonic-gate $self->{PERL_INC} = $self->{PERL_SRC}; 345*0Sstevel@tonic-gate } else { 346*0Sstevel@tonic-gate# hmmmmmmm ... ? 347*0Sstevel@tonic-gate $self->{PERL_LIB} ||= "$ENV{MACPERL}site_perl"; 348*0Sstevel@tonic-gate $self->{PERL_ARCHLIB} = $self->{PERL_LIB}; 349*0Sstevel@tonic-gate $self->{PERL_INC} = $ENV{MACPERL}; 350*0Sstevel@tonic-gate $self->{PERL_SRC} = ''; 351*0Sstevel@tonic-gate } 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate $self->{INSTALLDIRS} = "perl"; 354*0Sstevel@tonic-gate $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB}; 355*0Sstevel@tonic-gate $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR} = "none"; 356*0Sstevel@tonic-gate $self->{MAN1EXT} ||= $Config::Config{man1ext}; 357*0Sstevel@tonic-gate $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR} = "none"; 358*0Sstevel@tonic-gate $self->{MAN3EXT} ||= $Config::Config{man3ext}; 359*0Sstevel@tonic-gate $self->{MAP_TARGET} ||= "perl"; 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate # make a simple check if we find Exporter 362*0Sstevel@tonic-gate # hm ... do we really care? at all? 363*0Sstevel@tonic-gate# warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory 364*0Sstevel@tonic-gate# (Exporter.pm not found)" 365*0Sstevel@tonic-gate# unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") || 366*0Sstevel@tonic-gate# $self->{NAME} eq "ExtUtils::MakeMaker"; 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gate # Determine VERSION and VERSION_FROM 369*0Sstevel@tonic-gate ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME}; 370*0Sstevel@tonic-gate if ($self->{VERSION_FROM}){ 371*0Sstevel@tonic-gate # XXX replace with parse_version() override 372*0Sstevel@tonic-gate local *FH; 373*0Sstevel@tonic-gate open(FH,macify($self->{VERSION_FROM})) or 374*0Sstevel@tonic-gate die "Could not open '$self->{VERSION_FROM}' (attribute VERSION_FROM): $!"; 375*0Sstevel@tonic-gate while (<FH>) { 376*0Sstevel@tonic-gate chop; 377*0Sstevel@tonic-gate next unless /\$([\w:]*\bVERSION)\b.*=/; 378*0Sstevel@tonic-gate local $ExtUtils::MakeMaker::module_version_variable = $1; 379*0Sstevel@tonic-gate my($eval) = "$_;"; 380*0Sstevel@tonic-gate eval $eval; 381*0Sstevel@tonic-gate die "Could not eval '$eval': $@" if $@; 382*0Sstevel@tonic-gate if ($self->{VERSION} = $ {$ExtUtils::MakeMaker::module_version_variable}){ 383*0Sstevel@tonic-gate print "$self->{NAME} VERSION is $self->{VERSION} (from $self->{VERSION_FROM})\n" if $Verbose; 384*0Sstevel@tonic-gate } else { 385*0Sstevel@tonic-gate # XXX this should probably croak 386*0Sstevel@tonic-gate print "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n"; 387*0Sstevel@tonic-gate } 388*0Sstevel@tonic-gate last; 389*0Sstevel@tonic-gate } 390*0Sstevel@tonic-gate close FH; 391*0Sstevel@tonic-gate } 392*0Sstevel@tonic-gate 393*0Sstevel@tonic-gate if ($self->{VERSION}) { 394*0Sstevel@tonic-gate $self->{VERSION} =~ s/^\s+//; 395*0Sstevel@tonic-gate $self->{VERSION} =~ s/\s+$//; 396*0Sstevel@tonic-gate } 397*0Sstevel@tonic-gate 398*0Sstevel@tonic-gate $self->{VERSION} = "0.10" unless $self->{VERSION}; 399*0Sstevel@tonic-gate ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g; 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gate 402*0Sstevel@tonic-gate # Graham Barr and Paul Marquess had some ideas how to ensure 403*0Sstevel@tonic-gate # version compatibility between the *.pm file and the 404*0Sstevel@tonic-gate # corresponding *.xs file. The bottomline was, that we need an 405*0Sstevel@tonic-gate # XS_VERSION macro that defaults to VERSION: 406*0Sstevel@tonic-gate $self->{XS_VERSION} ||= $self->{VERSION}; 407*0Sstevel@tonic-gate 408*0Sstevel@tonic-gate 409*0Sstevel@tonic-gate $self->{DEFINE} .= " \$(XS_DEFINE_VERSION) \$(DEFINE_VERSION)"; 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gate # Preprocessor definitions may be useful 412*0Sstevel@tonic-gate $self->{DEFINE} =~ s/-D/-d /g; 413*0Sstevel@tonic-gate 414*0Sstevel@tonic-gate # UN*X includes probably are not useful 415*0Sstevel@tonic-gate $self->{DEFINE} =~ s/-I\S+/_include($1)/eg; 416*0Sstevel@tonic-gate 417*0Sstevel@tonic-gate 418*0Sstevel@tonic-gate if ($self->{INC}) { 419*0Sstevel@tonic-gate # UN*X includes probably are not useful 420*0Sstevel@tonic-gate $self->{INC} =~ s/-I(\S+)/_include($1)/eg; 421*0Sstevel@tonic-gate } 422*0Sstevel@tonic-gate 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gate # --- Initialize Perl Binary Locations 425*0Sstevel@tonic-gate 426*0Sstevel@tonic-gate # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL' 427*0Sstevel@tonic-gate # will be working versions of perl 5. miniperl has priority over perl 428*0Sstevel@tonic-gate # for PERL to ensure that $(PERL) is usable while building ./ext/* 429*0Sstevel@tonic-gate my ($component,@defpath); 430*0Sstevel@tonic-gate foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) { 431*0Sstevel@tonic-gate push @defpath, $component if defined $component; 432*0Sstevel@tonic-gate } 433*0Sstevel@tonic-gate $self->{PERL} = "$self->{PERL_SRC}miniperl"; 434*0Sstevel@tonic-gate} 435*0Sstevel@tonic-gate 436*0Sstevel@tonic-gate=item init_others 437*0Sstevel@tonic-gate 438*0Sstevel@tonic-gateInitializes LDLOADLIBS, LIBS 439*0Sstevel@tonic-gate 440*0Sstevel@tonic-gate=cut 441*0Sstevel@tonic-gate 442*0Sstevel@tonic-gatesub init_others { # --- Initialize Other Attributes 443*0Sstevel@tonic-gate my($self) = shift; 444*0Sstevel@tonic-gate 445*0Sstevel@tonic-gate if ( !$self->{OBJECT} ) { 446*0Sstevel@tonic-gate # init_dirscan should have found out, if we have C files 447*0Sstevel@tonic-gate $self->{OBJECT} = ""; 448*0Sstevel@tonic-gate $self->{OBJECT} = "$self->{BASEEXT}.c" if @{$self->{C}||[]}; 449*0Sstevel@tonic-gate } else { 450*0Sstevel@tonic-gate $self->{OBJECT} =~ s/\$\(O_FILES\)/@{$self->{C}||[]}/; 451*0Sstevel@tonic-gate } 452*0Sstevel@tonic-gate my($src); 453*0Sstevel@tonic-gate foreach (split(/[ \t\n]+/, $self->{OBJECT})) { 454*0Sstevel@tonic-gate if (/^$self->{BASEEXT}\.o(bj)?$/) { 455*0Sstevel@tonic-gate $src .= " $self->{BASEEXT}.c"; 456*0Sstevel@tonic-gate } elsif (/^(.*\..*)\.o$/) { 457*0Sstevel@tonic-gate $src .= " $1"; 458*0Sstevel@tonic-gate } elsif (/^(.*)(\.o(bj)?|\$\(OBJ_EXT\))$/) { 459*0Sstevel@tonic-gate if (-f "$1.cp") { 460*0Sstevel@tonic-gate $src .= " $1.cp"; 461*0Sstevel@tonic-gate } else { 462*0Sstevel@tonic-gate $src .= " $1.c"; 463*0Sstevel@tonic-gate } 464*0Sstevel@tonic-gate } else { 465*0Sstevel@tonic-gate $src .= " $_"; 466*0Sstevel@tonic-gate } 467*0Sstevel@tonic-gate } 468*0Sstevel@tonic-gate $self->{SOURCE} = $src; 469*0Sstevel@tonic-gate $self->{FULLPERL} = "$self->{PERL_SRC}perl"; 470*0Sstevel@tonic-gate $self->{MAKEFILE} = "Makefile.mk"; 471*0Sstevel@tonic-gate $self->{FIRST_MAKEFILE} = $self->{MAKEFILE}; 472*0Sstevel@tonic-gate $self->{MAKEFILE_OLD} = $self->{MAKEFILE}.'.old'; 473*0Sstevel@tonic-gate 474*0Sstevel@tonic-gate $self->{'DEV_NULL'} ||= ' \xB3 Dev:Null'; 475*0Sstevel@tonic-gate 476*0Sstevel@tonic-gate return 1; 477*0Sstevel@tonic-gate} 478*0Sstevel@tonic-gate 479*0Sstevel@tonic-gate=item init_platform 480*0Sstevel@tonic-gate 481*0Sstevel@tonic-gateAdd MACPERL_SRC MACPERL_LIB 482*0Sstevel@tonic-gate 483*0Sstevel@tonic-gate=item platform_constants 484*0Sstevel@tonic-gate 485*0Sstevel@tonic-gateAdd MACPERL_SRC MACPERL_LIB MACLIBS_68K MACLIBS_PPC MACLIBS_SC MACLIBS_MRC 486*0Sstevel@tonic-gateMACLIBS_ALL_68K MACLIBS_ALL_PPC MACLIBS_SHARED 487*0Sstevel@tonic-gate 488*0Sstevel@tonic-gateXXX Few are initialized. How many of these are ever used? 489*0Sstevel@tonic-gate 490*0Sstevel@tonic-gate=cut 491*0Sstevel@tonic-gate 492*0Sstevel@tonic-gatesub init_platform { 493*0Sstevel@tonic-gate my $self = shift; 494*0Sstevel@tonic-gate 495*0Sstevel@tonic-gate $self->{MACPERL_SRC} = $self->catdir("$self->{PERL_SRC}","macos:"); 496*0Sstevel@tonic-gate $self->{MACPERL_LIB} ||= $self->catdir("$self->{MACPERL_SRC}","lib"); 497*0Sstevel@tonic-gate $self->{MACPERL_INC} = $self->{MACPERL_SRC}; 498*0Sstevel@tonic-gate} 499*0Sstevel@tonic-gate 500*0Sstevel@tonic-gate 501*0Sstevel@tonic-gate 502*0Sstevel@tonic-gatesub platform_constants { 503*0Sstevel@tonic-gate my $self = shift; 504*0Sstevel@tonic-gate 505*0Sstevel@tonic-gate foreach my $macro (qw(MACPERL_SRC MACPERL_LIB MACLIBS_68K MACLIBS_PPC 506*0Sstevel@tonic-gate MACLIBS_SC MACLIBS_MRC MACLIBS_ALL_68K 507*0Sstevel@tonic-gate MACLIBS_ALL_PPC MACLIBS_SHARED)) 508*0Sstevel@tonic-gate { 509*0Sstevel@tonic-gate next unless defined $self->{$macro}; 510*0Sstevel@tonic-gate $make_frag .= "$macro = $self->{$macro}\n"; 511*0Sstevel@tonic-gate } 512*0Sstevel@tonic-gate 513*0Sstevel@tonic-gate return $make_frag; 514*0Sstevel@tonic-gate} 515*0Sstevel@tonic-gate 516*0Sstevel@tonic-gate 517*0Sstevel@tonic-gate=item init_dirscan 518*0Sstevel@tonic-gate 519*0Sstevel@tonic-gateInitializes DIR, XS, PM, C, O_FILES, H, PL_FILES, MAN*PODS, EXE_FILES. 520*0Sstevel@tonic-gate 521*0Sstevel@tonic-gate=cut 522*0Sstevel@tonic-gate 523*0Sstevel@tonic-gatesub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) 524*0Sstevel@tonic-gate my($self) = @_; 525*0Sstevel@tonic-gate my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods); 526*0Sstevel@tonic-gate local(%pm); #the sub in find() has to see this hash 527*0Sstevel@tonic-gate 528*0Sstevel@tonic-gate # in case we don't find it below! 529*0Sstevel@tonic-gate if ($self->{VERSION_FROM}) { 530*0Sstevel@tonic-gate my $version_from = macify($self->{VERSION_FROM}); 531*0Sstevel@tonic-gate $pm{$version_from} = $self->catfile('$(INST_LIBDIR)', 532*0Sstevel@tonic-gate $version_from); 533*0Sstevel@tonic-gate } 534*0Sstevel@tonic-gate 535*0Sstevel@tonic-gate $ignore{'test.pl'} = 1; 536*0Sstevel@tonic-gate foreach $name ($self->lsdir(":")){ 537*0Sstevel@tonic-gate next if ($name =~ /^\./ or $ignore{$name}); 538*0Sstevel@tonic-gate next unless $self->libscan($name); 539*0Sstevel@tonic-gate if (-d $name){ 540*0Sstevel@tonic-gate next if $self->{NORECURS}; 541*0Sstevel@tonic-gate $dir{$name} = $name if (-f ":$name:Makefile.PL"); 542*0Sstevel@tonic-gate } elsif ($name =~ /\.xs$/){ 543*0Sstevel@tonic-gate my($c); ($c = $name) =~ s/\.xs$/.c/; 544*0Sstevel@tonic-gate $xs{$name} = $c; 545*0Sstevel@tonic-gate $c{$c} = 1; 546*0Sstevel@tonic-gate } elsif ($name =~ /\.c(p|pp|xx|c)?$/i){ # .c .C .cpp .cxx .cc .cp 547*0Sstevel@tonic-gate $c{$name} = 1 548*0Sstevel@tonic-gate unless $name =~ m/perlmain\.c/; # See MAP_TARGET 549*0Sstevel@tonic-gate } elsif ($name =~ /\.h$/i){ 550*0Sstevel@tonic-gate $h{$name} = 1; 551*0Sstevel@tonic-gate } elsif ($name =~ /\.(p[ml]|pod)$/){ 552*0Sstevel@tonic-gate $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name); 553*0Sstevel@tonic-gate } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") { 554*0Sstevel@tonic-gate ($pl_files{$name} = $name) =~ s/\.PL$// ; 555*0Sstevel@tonic-gate } 556*0Sstevel@tonic-gate } 557*0Sstevel@tonic-gate 558*0Sstevel@tonic-gate # Some larger extensions often wish to install a number of *.pm/pl 559*0Sstevel@tonic-gate # files into the library in various locations. 560*0Sstevel@tonic-gate 561*0Sstevel@tonic-gate # The attribute PMLIBDIRS holds an array reference which lists 562*0Sstevel@tonic-gate # subdirectories which we should search for library files to 563*0Sstevel@tonic-gate # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We 564*0Sstevel@tonic-gate # recursively search through the named directories (skipping any 565*0Sstevel@tonic-gate # which don't exist or contain Makefile.PL files). 566*0Sstevel@tonic-gate 567*0Sstevel@tonic-gate # For each *.pm or *.pl file found $self->libscan() is called with 568*0Sstevel@tonic-gate # the default installation path in $_[1]. The return value of 569*0Sstevel@tonic-gate # libscan defines the actual installation location. The default 570*0Sstevel@tonic-gate # libscan function simply returns the path. The file is skipped 571*0Sstevel@tonic-gate # if libscan returns false. 572*0Sstevel@tonic-gate 573*0Sstevel@tonic-gate # The default installation location passed to libscan in $_[1] is: 574*0Sstevel@tonic-gate # 575*0Sstevel@tonic-gate # ./*.pm => $(INST_LIBDIR)/*.pm 576*0Sstevel@tonic-gate # ./xyz/... => $(INST_LIBDIR)/xyz/... 577*0Sstevel@tonic-gate # ./lib/... => $(INST_LIB)/... 578*0Sstevel@tonic-gate # 579*0Sstevel@tonic-gate # In this way the 'lib' directory is seen as the root of the actual 580*0Sstevel@tonic-gate # perl library whereas the others are relative to INST_LIBDIR 581*0Sstevel@tonic-gate # This is a subtle distinction but one that's important for nested 582*0Sstevel@tonic-gate # modules. 583*0Sstevel@tonic-gate 584*0Sstevel@tonic-gate $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}] 585*0Sstevel@tonic-gate unless $self->{PMLIBDIRS}; 586*0Sstevel@tonic-gate 587*0Sstevel@tonic-gate #only existing directories that aren't in $dir are allowed 588*0Sstevel@tonic-gate 589*0Sstevel@tonic-gate my (@pmlibdirs) = map { macify ($_) } @{$self->{PMLIBDIRS}}; 590*0Sstevel@tonic-gate my ($pmlibdir); 591*0Sstevel@tonic-gate @{$self->{PMLIBDIRS}} = (); 592*0Sstevel@tonic-gate foreach $pmlibdir (@pmlibdirs) { 593*0Sstevel@tonic-gate -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir; 594*0Sstevel@tonic-gate } 595*0Sstevel@tonic-gate 596*0Sstevel@tonic-gate if (@{$self->{PMLIBDIRS}}){ 597*0Sstevel@tonic-gate print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n" 598*0Sstevel@tonic-gate if ($Verbose >= 2); 599*0Sstevel@tonic-gate require File::Find; 600*0Sstevel@tonic-gate File::Find::find(sub { 601*0Sstevel@tonic-gate if (-d $_){ 602*0Sstevel@tonic-gate unless ($self->libscan($_)){ 603*0Sstevel@tonic-gate $File::Find::prune = 1; 604*0Sstevel@tonic-gate } 605*0Sstevel@tonic-gate return; 606*0Sstevel@tonic-gate } 607*0Sstevel@tonic-gate my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)'); 608*0Sstevel@tonic-gate my($striplibpath,$striplibname); 609*0Sstevel@tonic-gate $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:); 610*0Sstevel@tonic-gate ($striplibname,$striplibpath) = fileparse($striplibpath); 611*0Sstevel@tonic-gate my($inst) = $self->catfile($prefix,$striplibpath,$striplibname); 612*0Sstevel@tonic-gate local($_) = $inst; # for backwards compatibility 613*0Sstevel@tonic-gate $inst = $self->libscan($inst); 614*0Sstevel@tonic-gate print "libscan($path) => '$inst'\n" if ($Verbose >= 2); 615*0Sstevel@tonic-gate return unless $inst; 616*0Sstevel@tonic-gate $pm{$path} = $inst; 617*0Sstevel@tonic-gate }, @{$self->{PMLIBDIRS}}); 618*0Sstevel@tonic-gate } 619*0Sstevel@tonic-gate 620*0Sstevel@tonic-gate $self->{DIR} = [sort keys %dir] unless $self->{DIR}; 621*0Sstevel@tonic-gate $self->{XS} = \%xs unless $self->{XS}; 622*0Sstevel@tonic-gate $self->{PM} = \%pm unless $self->{PM}; 623*0Sstevel@tonic-gate $self->{C} = [sort keys %c] unless $self->{C}; 624*0Sstevel@tonic-gate $self->{H} = [sort keys %h] unless $self->{H}; 625*0Sstevel@tonic-gate $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES}; 626*0Sstevel@tonic-gate 627*0Sstevel@tonic-gate # Set up names of manual pages to generate from pods 628*0Sstevel@tonic-gate unless ($self->{MAN1PODS}) { 629*0Sstevel@tonic-gate $self->{MAN1PODS} = {}; 630*0Sstevel@tonic-gate } 631*0Sstevel@tonic-gate unless ($self->{MAN3PODS}) { 632*0Sstevel@tonic-gate $self->{MAN3PODS} = {}; 633*0Sstevel@tonic-gate } 634*0Sstevel@tonic-gate} 635*0Sstevel@tonic-gate 636*0Sstevel@tonic-gate 637*0Sstevel@tonic-gate=item init_VERSION (o) 638*0Sstevel@tonic-gate 639*0Sstevel@tonic-gateChange DEFINE_VERSION and XS_DEFINE_VERSION 640*0Sstevel@tonic-gate 641*0Sstevel@tonic-gate=cut 642*0Sstevel@tonic-gate 643*0Sstevel@tonic-gatesub init_VERSION { 644*0Sstevel@tonic-gate my $self = shift; 645*0Sstevel@tonic-gate 646*0Sstevel@tonic-gate $self->SUPER::init_VERSION; 647*0Sstevel@tonic-gate 648*0Sstevel@tonic-gate $self->{DEFINE_VERSION} = '-d $(VERSION_MACRO)="�"$(VERSION)�""'; 649*0Sstevel@tonic-gate $self->{XS_DEFINE_VERSION} = '-d $(XS_VERSION_MACRO)="�"$(XS_VERSION)�""'; 650*0Sstevel@tonic-gate} 651*0Sstevel@tonic-gate 652*0Sstevel@tonic-gate 653*0Sstevel@tonic-gate=item special_targets (o) 654*0Sstevel@tonic-gate 655*0Sstevel@tonic-gateAdd .INCLUDE 656*0Sstevel@tonic-gate 657*0Sstevel@tonic-gate=cut 658*0Sstevel@tonic-gate 659*0Sstevel@tonic-gatesub special_targets { 660*0Sstevel@tonic-gate my $self = shift; 661*0Sstevel@tonic-gate 662*0Sstevel@tonic-gate my $make_frag = $self->SUPER::special_targets; 663*0Sstevel@tonic-gate 664*0Sstevel@tonic-gate return $make_frag . <<'MAKE_FRAG'; 665*0Sstevel@tonic-gate.INCLUDE : $(MACPERL_SRC)BuildRules.mk $(MACPERL_SRC)ExtBuildRules.mk 666*0Sstevel@tonic-gate 667*0Sstevel@tonic-gateMAKE_FRAG 668*0Sstevel@tonic-gate 669*0Sstevel@tonic-gate} 670*0Sstevel@tonic-gate 671*0Sstevel@tonic-gate=item static (o) 672*0Sstevel@tonic-gate 673*0Sstevel@tonic-gateDefines the static target. 674*0Sstevel@tonic-gate 675*0Sstevel@tonic-gate=cut 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gatesub static { 678*0Sstevel@tonic-gate# --- Static Loading Sections --- 679*0Sstevel@tonic-gate 680*0Sstevel@tonic-gate my($self) = shift; 681*0Sstevel@tonic-gate my($extlib) = $self->{MYEXTLIB} ? "\nstatic :: myextlib\n" : ""; 682*0Sstevel@tonic-gate ' 683*0Sstevel@tonic-gateall :: static 684*0Sstevel@tonic-gate 685*0Sstevel@tonic-gateinstall :: do_install_static 686*0Sstevel@tonic-gate 687*0Sstevel@tonic-gateinstall_static :: do_install_static 688*0Sstevel@tonic-gate' . $extlib; 689*0Sstevel@tonic-gate} 690*0Sstevel@tonic-gate 691*0Sstevel@tonic-gate=item dlsyms (o) 692*0Sstevel@tonic-gate 693*0Sstevel@tonic-gateUsed by MacOS to define DL_FUNCS and DL_VARS and write the *.exp 694*0Sstevel@tonic-gatefiles. 695*0Sstevel@tonic-gate 696*0Sstevel@tonic-gate=cut 697*0Sstevel@tonic-gate 698*0Sstevel@tonic-gatesub dlsyms { 699*0Sstevel@tonic-gate my($self,%attribs) = @_; 700*0Sstevel@tonic-gate 701*0Sstevel@tonic-gate return '' unless !$self->{SKIPHASH}{'dynamic'}; 702*0Sstevel@tonic-gate 703*0Sstevel@tonic-gate my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; 704*0Sstevel@tonic-gate my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; 705*0Sstevel@tonic-gate my(@m); 706*0Sstevel@tonic-gate 707*0Sstevel@tonic-gate push(@m," 708*0Sstevel@tonic-gatedynamic :: $self->{BASEEXT}.exp 709*0Sstevel@tonic-gate 710*0Sstevel@tonic-gate") unless $self->{SKIPHASH}{'dynamic'}; 711*0Sstevel@tonic-gate 712*0Sstevel@tonic-gate my($extlib) = $self->{MYEXTLIB} ? " myextlib" : ""; 713*0Sstevel@tonic-gate 714*0Sstevel@tonic-gate push(@m," 715*0Sstevel@tonic-gate$self->{BASEEXT}.exp: Makefile.PL$extlib 716*0Sstevel@tonic-gate", qq[\t\$(PERL) "-I\$(PERL_LIB)" -e 'use ExtUtils::Mksymlists; ], 717*0Sstevel@tonic-gate 'Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ', 718*0Sstevel@tonic-gate neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\' 719*0Sstevel@tonic-gate'); 720*0Sstevel@tonic-gate 721*0Sstevel@tonic-gate join('',@m); 722*0Sstevel@tonic-gate} 723*0Sstevel@tonic-gate 724*0Sstevel@tonic-gate=item dynamic (o) 725*0Sstevel@tonic-gate 726*0Sstevel@tonic-gateDefines the dynamic target. 727*0Sstevel@tonic-gate 728*0Sstevel@tonic-gate=cut 729*0Sstevel@tonic-gate 730*0Sstevel@tonic-gatesub dynamic { 731*0Sstevel@tonic-gate# --- dynamic Loading Sections --- 732*0Sstevel@tonic-gate 733*0Sstevel@tonic-gate my($self) = shift; 734*0Sstevel@tonic-gate ' 735*0Sstevel@tonic-gateall :: dynamic 736*0Sstevel@tonic-gate 737*0Sstevel@tonic-gateinstall :: do_install_dynamic 738*0Sstevel@tonic-gate 739*0Sstevel@tonic-gateinstall_dynamic :: do_install_dynamic 740*0Sstevel@tonic-gate'; 741*0Sstevel@tonic-gate} 742*0Sstevel@tonic-gate 743*0Sstevel@tonic-gate 744*0Sstevel@tonic-gate=item clean (o) 745*0Sstevel@tonic-gate 746*0Sstevel@tonic-gateDefines the clean target. 747*0Sstevel@tonic-gate 748*0Sstevel@tonic-gate=cut 749*0Sstevel@tonic-gate 750*0Sstevel@tonic-gatesub clean { 751*0Sstevel@tonic-gate# --- Cleanup and Distribution Sections --- 752*0Sstevel@tonic-gate 753*0Sstevel@tonic-gate my($self, %attribs) = @_; 754*0Sstevel@tonic-gate my(@m,$dir); 755*0Sstevel@tonic-gate push(@m, ' 756*0Sstevel@tonic-gate# Delete temporary files but do not touch installed files. We don\'t delete 757*0Sstevel@tonic-gate# the Makefile here so a later make realclean still has a makefile to use. 758*0Sstevel@tonic-gate 759*0Sstevel@tonic-gateclean :: clean_subdirs 760*0Sstevel@tonic-gate'); 761*0Sstevel@tonic-gate 762*0Sstevel@tonic-gate my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files 763*0Sstevel@tonic-gate push(@otherfiles, patternify($attribs{FILES})) if $attribs{FILES}; 764*0Sstevel@tonic-gate push @m, "\t\$(RM_RF) @otherfiles\n"; 765*0Sstevel@tonic-gate # See realclean and ext/utils/make_ext for usage of Makefile.old 766*0Sstevel@tonic-gate push(@m, 767*0Sstevel@tonic-gate "\t\$(MV) \$(FIRST_MAKEFILE) \$(MAKEFILE_OLD)\n"); 768*0Sstevel@tonic-gate push(@m, 769*0Sstevel@tonic-gate "\t$attribs{POSTOP}\n") if $attribs{POSTOP}; 770*0Sstevel@tonic-gate join("", @m); 771*0Sstevel@tonic-gate} 772*0Sstevel@tonic-gate 773*0Sstevel@tonic-gate=item clean_subdirs_target 774*0Sstevel@tonic-gate 775*0Sstevel@tonic-gateMacOS semantics for changing directories and checking for existence 776*0Sstevel@tonic-gatevery different than everyone else. 777*0Sstevel@tonic-gate 778*0Sstevel@tonic-gate=cut 779*0Sstevel@tonic-gate 780*0Sstevel@tonic-gatesub clean_subdirs_target { 781*0Sstevel@tonic-gate my($self) = shift; 782*0Sstevel@tonic-gate 783*0Sstevel@tonic-gate # No subdirectories, no cleaning. 784*0Sstevel@tonic-gate return <<'NOOP_FRAG' unless @{$self->{DIR}}; 785*0Sstevel@tonic-gateclean_subdirs : 786*0Sstevel@tonic-gate $(NOECHO)$(NOOP) 787*0Sstevel@tonic-gateNOOP_FRAG 788*0Sstevel@tonic-gate 789*0Sstevel@tonic-gate 790*0Sstevel@tonic-gate my $clean = "clean_subdirs :\n"; 791*0Sstevel@tonic-gate 792*0Sstevel@tonic-gate for my $dir (@{$self->{DIR}}) { 793*0Sstevel@tonic-gate $clean .= sprintf <<'MAKE_FRAG', $dir; 794*0Sstevel@tonic-gate Set OldEcho {Echo} 795*0Sstevel@tonic-gate Set Echo 0 796*0Sstevel@tonic-gate Directory %s 797*0Sstevel@tonic-gate If "`Exists -f $(FIRST_MAKEFILE)`" != "" 798*0Sstevel@tonic-gate $(MAKE) clean 799*0Sstevel@tonic-gate End 800*0Sstevel@tonic-gate Set Echo {OldEcho} 801*0Sstevel@tonic-gate 802*0Sstevel@tonic-gateMAKE_FRAG 803*0Sstevel@tonic-gate } 804*0Sstevel@tonic-gate 805*0Sstevel@tonic-gate return $clean; 806*0Sstevel@tonic-gate} 807*0Sstevel@tonic-gate 808*0Sstevel@tonic-gate 809*0Sstevel@tonic-gate=item realclean (o) 810*0Sstevel@tonic-gate 811*0Sstevel@tonic-gateDefines the realclean target. 812*0Sstevel@tonic-gate 813*0Sstevel@tonic-gate=cut 814*0Sstevel@tonic-gate 815*0Sstevel@tonic-gatesub realclean { 816*0Sstevel@tonic-gate my($self, %attribs) = @_; 817*0Sstevel@tonic-gate my(@m); 818*0Sstevel@tonic-gate push(@m,' 819*0Sstevel@tonic-gate# Delete temporary files (via clean) and also delete installed files 820*0Sstevel@tonic-gaterealclean purge :: clean 821*0Sstevel@tonic-gate'); 822*0Sstevel@tonic-gate 823*0Sstevel@tonic-gate my(@otherfiles) = ('$(FIRST_MAKEFILE)', '$(MAKEFILE_OLD)'); # Makefiles last 824*0Sstevel@tonic-gate push(@otherfiles, patternify($attribs{FILES})) if $attribs{FILES}; 825*0Sstevel@tonic-gate push(@m, "\t\$(RM_RF) @otherfiles\n") if @otherfiles; 826*0Sstevel@tonic-gate push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP}; 827*0Sstevel@tonic-gate join("", @m); 828*0Sstevel@tonic-gate} 829*0Sstevel@tonic-gate 830*0Sstevel@tonic-gate 831*0Sstevel@tonic-gate=item realclean_subdirs_target 832*0Sstevel@tonic-gate 833*0Sstevel@tonic-gateMacOS semantics for changing directories and checking for existence 834*0Sstevel@tonic-gatevery different than everyone else. 835*0Sstevel@tonic-gate 836*0Sstevel@tonic-gate=cut 837*0Sstevel@tonic-gate 838*0Sstevel@tonic-gatesub realclean_subdirs_target { 839*0Sstevel@tonic-gate my $self = shift; 840*0Sstevel@tonic-gate 841*0Sstevel@tonic-gate return <<'NOOP_FRAG' unless @{$self->{DIR}}; 842*0Sstevel@tonic-gaterealclean_subdirs : 843*0Sstevel@tonic-gate $(NOECHO)$(NOOP) 844*0Sstevel@tonic-gateNOOP_FRAG 845*0Sstevel@tonic-gate 846*0Sstevel@tonic-gate my $rclean = "realclean_subdirs :\n"; 847*0Sstevel@tonic-gate 848*0Sstevel@tonic-gate foreach my $dir (@{$self->{DIR}}){ 849*0Sstevel@tonic-gate $rclean .= sprintf <<'RCLEAN', $dir, 850*0Sstevel@tonic-gate Set OldEcho \{Echo\} 851*0Sstevel@tonic-gate Set Echo 0 852*0Sstevel@tonic-gate Directory %s 853*0Sstevel@tonic-gate If \"\`Exists -f $(FIRST_MAKEFILE)\`\" != \"\" 854*0Sstevel@tonic-gate \$(MAKE) realclean 855*0Sstevel@tonic-gate End 856*0Sstevel@tonic-gate Set Echo \{OldEcho\} 857*0Sstevel@tonic-gate 858*0Sstevel@tonic-gateRCLEAN 859*0Sstevel@tonic-gate 860*0Sstevel@tonic-gate } 861*0Sstevel@tonic-gate 862*0Sstevel@tonic-gate return $rclean; 863*0Sstevel@tonic-gate} 864*0Sstevel@tonic-gate 865*0Sstevel@tonic-gate 866*0Sstevel@tonic-gate=item rulez (o) 867*0Sstevel@tonic-gate 868*0Sstevel@tonic-gate=cut 869*0Sstevel@tonic-gate 870*0Sstevel@tonic-gatesub rulez { 871*0Sstevel@tonic-gate my($self) = shift; 872*0Sstevel@tonic-gate qq' 873*0Sstevel@tonic-gateinstall install_static install_dynamic :: 874*0Sstevel@tonic-gate\t\$(MACPERL_SRC)PerlInstall -l \$(PERL_LIB) 875*0Sstevel@tonic-gate 876*0Sstevel@tonic-gate.INCLUDE : \$(MACPERL_SRC)BulkBuildRules.mk 877*0Sstevel@tonic-gate'; 878*0Sstevel@tonic-gate} 879*0Sstevel@tonic-gate 880*0Sstevel@tonic-gate 881*0Sstevel@tonic-gate=item processPL (o) 882*0Sstevel@tonic-gate 883*0Sstevel@tonic-gateDefines targets to run *.PL files. 884*0Sstevel@tonic-gate 885*0Sstevel@tonic-gate=cut 886*0Sstevel@tonic-gate 887*0Sstevel@tonic-gatesub processPL { 888*0Sstevel@tonic-gate my($self) = shift; 889*0Sstevel@tonic-gate return "" unless $self->{PL_FILES}; 890*0Sstevel@tonic-gate my(@m, $plfile); 891*0Sstevel@tonic-gate foreach $plfile (sort keys %{$self->{PL_FILES}}) { 892*0Sstevel@tonic-gate my $list = ref($self->{PL_FILES}->{$plfile}) 893*0Sstevel@tonic-gate ? $self->{PL_FILES}->{$plfile} 894*0Sstevel@tonic-gate : [$self->{PL_FILES}->{$plfile}]; 895*0Sstevel@tonic-gate foreach $target (@$list) { 896*0Sstevel@tonic-gate push @m, " 897*0Sstevel@tonic-gateProcessPL :: $target 898*0Sstevel@tonic-gate\t$(NOECHO)\$(NOOP) 899*0Sstevel@tonic-gate 900*0Sstevel@tonic-gate$target :: $plfile 901*0Sstevel@tonic-gate\t\$(PERL) -I\$(MACPERL_LIB) -I\$(PERL_LIB) $plfile $target 902*0Sstevel@tonic-gate"; 903*0Sstevel@tonic-gate } 904*0Sstevel@tonic-gate } 905*0Sstevel@tonic-gate join "", @m; 906*0Sstevel@tonic-gate} 907*0Sstevel@tonic-gate 908*0Sstevel@tonic-gatesub cflags { 909*0Sstevel@tonic-gate my($self,$libperl) = @_; 910*0Sstevel@tonic-gate my $optimize = ''; 911*0Sstevel@tonic-gate 912*0Sstevel@tonic-gate for (map { $_ . "Optimize" } qw(MWC MWCPPC MWC68K MPW MRC MRC SC)) { 913*0Sstevel@tonic-gate $optimize .= "$_ = $self->{$_}" if exists $self->{$_}; 914*0Sstevel@tonic-gate } 915*0Sstevel@tonic-gate 916*0Sstevel@tonic-gate return $self->{CFLAGS} = $optimize; 917*0Sstevel@tonic-gate} 918*0Sstevel@tonic-gate 919*0Sstevel@tonic-gate 920*0Sstevel@tonic-gatesub _include { # for Unix-style includes, with -I instead of -i 921*0Sstevel@tonic-gate my($inc) = @_; 922*0Sstevel@tonic-gate require File::Spec::Unix; 923*0Sstevel@tonic-gate 924*0Sstevel@tonic-gate # allow only relative paths 925*0Sstevel@tonic-gate if (File::Spec::Unix->file_name_is_absolute($inc)) { 926*0Sstevel@tonic-gate return ''; 927*0Sstevel@tonic-gate } else { 928*0Sstevel@tonic-gate return '-i ' . macify($inc); 929*0Sstevel@tonic-gate } 930*0Sstevel@tonic-gate} 931*0Sstevel@tonic-gate 932*0Sstevel@tonic-gate=item os_flavor 933*0Sstevel@tonic-gate 934*0Sstevel@tonic-gateMacOS Classic is MacOS and MacOS Classic. 935*0Sstevel@tonic-gate 936*0Sstevel@tonic-gate=cut 937*0Sstevel@tonic-gate 938*0Sstevel@tonic-gatesub os_flavor { 939*0Sstevel@tonic-gate return('MacOS', 'MacOS Classic'); 940*0Sstevel@tonic-gate} 941*0Sstevel@tonic-gate 942*0Sstevel@tonic-gate=back 943*0Sstevel@tonic-gate 944*0Sstevel@tonic-gate=cut 945*0Sstevel@tonic-gate 946*0Sstevel@tonic-gate1; 947