home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / ExtUtils / MM_MacOS.pm < prev    next >
Text File  |  1998-04-07  |  23KB  |  871 lines

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