# 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
}
mkdir("Obj", 0777) unless -d "Obj";
-
+
$self = {} unless (defined $self);
+ check_hints($self);
+
my(%initial_att) = %$self; # record initial attributes
if (defined $self->{CONFIGURE}) {
}
}
- $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';
+ }
+
+ $ExtUtils::MakeMaker::Recognized_Att_Keys{$_} = 1
+ for map { $_ . 'Optimize' } qw(MWC MWCPPC MWC68K MPW MRC MRC SC);
+
+ 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
installbin subdirs dist_basics dist_core
dist_dir dist_test dist_ci install force perldepend makefile
- staticmake test pm_to_blib selfdocument cflags
+ staticmake test pm_to_blib selfdocument
const_loadlibs const_cccmd
/)
{
}
push @ExtUtils::MakeMaker::MM_Sections, "rulez"
unless grep /rulez/, @ExtUtils::MakeMaker::MM_Sections;
-
+
if ($self->{PARENT}) {
for (qw/install dist dist_basics dist_core dist_dir dist_test dist_ci/) {
$self->{SKIPHASH}{$_} = 1;
=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 cflags {
+ my($self,$libperl) = @_;
+ my $optimize;
+
+ for (map { $_ . "Optimize" } qw(MWC MWCPPC MWC68K MPW MRC MRC SC)) {
+ $optimize .= "$_ = $self->{$_}" if exists $self->{$_};
+ }
+
+ return $self->{CFLAGS} = $optimize;
+}
+
+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);
+ }
+}
+
+# yes, these are just copies of the same routines in
+# MakeMaker.pm, but with paths changed.
+sub check_hints {
+ my($self) = @_;
+ # We allow extension-specific hints files.
+
+ return unless -d ":hints";
+
+ # First we look for the best hintsfile we have
+ my($hint)="${^O}_$Config{osvers}";
+ $hint =~ s/\./_/g;
+ $hint =~ s/_$//;
+ return unless $hint;
+
+ # Also try without trailing minor version numbers.
+ while (1) {
+ last if -f ":hints:$hint.pl"; # found
+ } continue {
+ last unless $hint =~ s/_[^_]*$//; # nothing to cut off
+ }
+ my $hint_file = ":hints:$hint.pl";
+
+ return unless -f $hint_file; # really there
+
+ _run_hintfile($self, $hint_file);
+}
+
+sub _run_hintfile {
+ no strict 'vars';
+ local($self) = shift; # make $self available to the hint file.
+ my($hint_file) = shift;
+
+ local $@;
+ print STDERR "Processing hints file $hint_file\n";
+ my $ret = do $hint_file;
+ unless( defined $ret ) {
+ print STDERR $@ if $@;
+ }
+}
1;
__END__