# built-in ExtUtils::MM_Unix methods if MakeMaker.pm is run under MacOS.
#
# Author: Matthias Neeracher <neeracher@mac.com>
+# Maintainer: Chris Nandor <pudge@pobox.com>
package ExtUtils::MM_MacOS;
require ExtUtils::MM_Any;
@ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
use vars qw($VERSION);
-$VERSION = '1.00';
+$VERSION = '1.03';
use Config;
use Cwd 'cwd';
use File::Spec;
use vars qw(%make_data);
+my $Mac_FS = eval { require Mac::FileSpec::Unixish };
+
use ExtUtils::MakeMaker qw($Verbose &neatvalue);
=head1 NAME
}
}
- $class = ++$ExtUtils::MakeMaker::PACKNAME;
+ my $newclass = ++$ExtUtils::MakeMaker::PACKNAME;
+ local @ExtUtils::MakeMaker::Parent = @ExtUtils::MakeMaker::Parent; # Protect against non-local exits
{
- print "Blessing Object into class [$class]\n" if $Verbose>=2;
- ExtUtils::MakeMaker::mv_all_methods("MY",$class);
- bless $self, $class;
- push @Parent, $self;
- @{"$class\:\:ISA"} = 'MM';
- }
-
- if (defined $Parent[-2]){
- $self->{PARENT} = $Parent[-2];
- my $key;
- for $key (keys %Prepend_dot_dot) {
- next unless defined $self->{PARENT}{$key};
- $self->{$key} = $self->{PARENT}{$key};
- $self->{$key} = File::Spec->catdir("::",$self->{$key})
- unless File::Spec->file_name_is_absolute($self->{$key});
- }
- $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT};
+ no strict 'refs';
+ print "Blessing Object into class [$newclass]\n" if $Verbose>=2;
+ ExtUtils::MakeMaker::mv_all_methods("MY",$newclass);
+ bless $self, $newclass;
+ push @Parent, $self;
+ require ExtUtils::MY;
+ @{"$newclass\:\:ISA"} = 'MM';
+ }
+
+ if (defined $ExtUtils::MakeMaker::Parent[-2]){
+ $self->{PARENT} = $ExtUtils::MakeMaker::Parent[-2];
+ my $key;
+ for $key (@ExtUtils::MakeMaker::Prepend_parent) {
+ next unless defined $self->{PARENT}{$key};
+ $self->{$key} = $self->{PARENT}{$key};
+ unless ($^O eq 'VMS' && $key =~ /PERL$/) {
+ $self->{$key} = $self->catdir("..",$self->{$key})
+ unless $self->file_name_is_absolute($self->{$key});
+ } else {
+ # PERL or FULLPERL will be a command verb or even a
+ # command with an argument instead of a full file
+ # specification under VMS. So, don't turn the command
+ # into a filespec, but do add a level to the path of
+ # the argument if not already absolute.
+ my @cmd = split /\s+/, $self->{$key};
+ $cmd[1] = $self->catfile('[-]',$cmd[1])
+ unless (@cmd < 2) || $self->file_name_is_absolute($cmd[1]);
+ $self->{$key} = join(' ', @cmd);
+ }
+ }
+ if ($self->{PARENT}) {
+ $self->{PARENT}->{CHILDREN}->{$newclass} = $self;
+ foreach my $opt (qw(POLLUTE PERL_CORE)) {
+ if (exists $self->{PARENT}->{$opt}
+ and not exists $self->{$opt})
+ {
+ # inherit, but only if already unspecified
+ $self->{$opt} = $self->{PARENT}->{$opt};
+ }
+ }
+ }
+ my @fm = grep /^FIRST_MAKEFILE=/, @ARGV;
+ $self->parse_args(@fm) if @fm;
} else {
- $self->parse_args(@ARGV);
+ $self->parse_args(split(' ', $ENV{PERL_MM_OPT} || ''),@ARGV);
}
$self->{NAME} ||= $self->guess_name;
delete $self->{SKIP}; # free memory
# We skip many sections for MacOS, but we don't say anything about it in the Makefile
- for (qw/post_initialize const_config tool_autosplit
+ for (qw/ const_config tool_autosplit
tool_xsubpp tools_other dist macro depend post_constants
pasthru c_o xs_c xs_o top_targets linkext
dynamic_bs dynamic_lib static_lib manifypods
=cut
sub macify {
- # mmm, better ... and this condition should always be satisified,
- # as the module is now distributed with MacPerl, but leave in anyway
- if (do 'Mac/FileSpec/Unixish.pm') {
- return Mac::FileSpec::Unixish::nativize($_[0]);
- }
-
my($unix) = @_;
my(@mac);
- $unix =~ s|^\./||;
-
foreach (split(/[ \t\n]+/, $unix)) {
if (m|/|) {
- $_ = ":$_";
- s|/|:|g;
- }
+ if ($Mac_FS) { # should always be true
+ $_ = Mac::FileSpec::Unixish::nativize($_);
+ } else {
+ s|^\./||;
+ s|/|:|g;
+ $_ = ":$_";
+ }
+ }
push(@mac, $_);
}
sub init_main {
my($self) = @_;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
# --- Initialize Module Name and Paths
sub init_others { # --- Initialize Other Attributes
my($self) = shift;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
if ( !$self->{OBJECT} ) {
# init_dirscan should have found out, if we have C files
sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
my($self) = @_;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
local(%pm); #the sub in find() has to see this hash
sub constants {
my($self) = @_;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
my(@m,$tmp);
for $tmp (qw/
XSPROTOARG MACLIBS_68K MACLIBS_PPC MACLIBS_SC MACLIBS_MRC MACLIBS_ALL_68K MACLIBS_ALL_PPC MACLIBS_SHARED SOURCE TYPEMAPS
/ ) {
next unless defined $self->{$tmp};
- push @m, "$tmp = $self->{$tmp}\n";
+ if ($tmp eq 'TYPEMAPS' && ref $self->{$tmp}) {
+ push @m, sprintf "$tmp = %s\n", join " ", @{$self->{$tmp}};
+ } else {
+ push @m, "$tmp = $self->{$tmp}\n";
+ }
}
push @m, q{
if ($self->{DEFINE}) {
$self->{DEFINE} =~ s/-D/-d /g; # Preprocessor definitions may be useful
- $self->{DEFINE} =~ s/-I\S+//g; # UN*X includes probably are not useful
+ $self->{DEFINE} =~ s/-I\S+/_include($1)/eg; # UN*X includes probably are not useful
}
if ($self->{INC}) {
- $self->{INC} =~ s/-I\S+//g; # UN*X includes probably are not useful
+ $self->{INC} =~ s/-I(\S+)/_include($1)/eg; # UN*X includes probably are not useful
}
for $tmp (qw/
FULLEXT BASEEXT ROOTEXT DEFINE INC
# --- Static Loading Sections ---
my($self) = shift;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
my($extlib) = $self->{MYEXTLIB} ? "\nstatic :: myextlib\n" : "";
'
all :: static
sub dlsyms {
my($self,%attribs) = @_;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
return '' unless !$self->{SKIPHASH}{'dynamic'};
# --- dynamic Loading Sections ---
my($self) = shift;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
'
all :: dynamic
# --- Cleanup and Distribution Sections ---
my($self, %attribs) = @_;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
my(@m,$dir);
push(@m, '
# Delete temporary files but do not touch installed files. We don\'t delete
sub realclean {
my($self, %attribs) = @_;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
my(@m);
push(@m,'
# Delete temporary files (via clean) and also delete installed files
sub rulez {
my($self) = shift;
- unless (ref $self){
- ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
- $self = $ExtUtils::MakeMaker::Parent[-1];
- }
qq'
install install_static install_dynamic ::
\t\$(MACPERL_SRC)PerlInstall -l \$(PERL_LIB)
join "", @m;
}
+sub _include { # for Unix-style includes, with -I instead of -i
+ my($inc) = @_;
+ require File::Spec::Unix;
+
+ # allow only relative paths
+ if (File::Spec::Unix->file_name_is_absolute($inc)) {
+ return '';
+ } else {
+ return '-i ' . macify($inc);
+ }
+}
+
1;
__END__