home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / perl5 / perl5.002 / lib / extutils / mm_unix.pm < prev    next >
Encoding:
Perl POD Document  |  1996-03-12  |  83.3 KB  |  3,084 lines

  1. package ExtUtils::MM_Unix;
  2.  
  3. use Config;
  4. use File::Basename;
  5. use Cwd;
  6. use DirHandle;
  7. require File::Find;
  8. require Exporter;
  9. require ExtUtils::MakeMaker; # for $Is_OS2 and FileHandle
  10. require ExtUtils::Liblist;
  11. require File::Find;
  12.  
  13. Exporter::import('ExtUtils::MakeMaker',
  14.     qw( $Verbose &neatvalue));
  15.  
  16. if ($Is_VMS = $Config::Config{osname} eq 'VMS') {
  17.     require VMS::Filespec;
  18.     import VMS::Filespec qw( &vmsify );
  19. }
  20.  
  21. $Is_OS2 = $ExtUtils::MakeMaker::Is_OS2;
  22.  
  23. =head1 NAME
  24.  
  25. ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
  26.  
  27. =head1 SYNOPSIS
  28.  
  29. C<require ExtUtils::MM_Unix;>
  30.  
  31. =head1 DESCRIPTION
  32.  
  33. The methods provided by this package are designed to be used in
  34. conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
  35. Makefile, it creates one or more objects that inherit their methods
  36. from a package C<MM>. MM itself doesn't provide any methods, but it
  37. ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
  38. specific packages take the responsibility for all the methods provided
  39. by MM_Unix. We are trying to reduce the number of the necessary
  40. overrides by defining rather primitive operations within
  41. ExtUtils::MM_Unix.
  42.  
  43. If you are going to write a platform specific MM package, please try
  44. to limit the necessary overrides to primitiv methods, and if it is not
  45. possible to do so, let's work it out how to achieve that gain.
  46.  
  47. =head1 METHODS
  48.  
  49. The following description of methods is still under
  50. development. Please refer to the code for not suitably documented
  51. sections and complain loudly to the makemaker mailing list.
  52.  
  53. =head2 Preloaded methods
  54.  
  55. =over 2
  56.  
  57. =item catdir
  58.  
  59. Concatenate two or more directory names to form a complete path ending
  60. with a directory
  61.  
  62. =cut
  63.  
  64. # ';
  65.  
  66. sub catdir  {
  67.     shift;
  68.     my $result = join('/',@_);
  69.     $result =~ s:/\./:/:g;
  70.     $result =~ s:/+:/:g;
  71.     $result;
  72. }
  73.  
  74. =item catfile
  75.  
  76. Concatenate two or more directory names and a filename to form a
  77. complete path ending with a filename
  78.  
  79. =cut
  80.  
  81. sub catfile {
  82.     shift;
  83.     my $result = join('/',@_);
  84.     $result =~ s:/\./:/:g;
  85.     $result =~ s:/+:/:g;
  86.     $result;
  87. }
  88.  
  89. =item nicetext
  90.  
  91. misnamed method (will have to be changed). The MM_Unix method just
  92. returns the argument without further processing.
  93.  
  94. On VMS used to insure that colons marking targets are preceded by
  95. space - most Unix Makes don't need this, but it's necessary under VMS
  96. to distinguish the target delimiter from a colon appearing as part of
  97. a filespec. 
  98.  
  99. =cut
  100.  
  101. sub nicetext {
  102.     my($self,$text) = @_;
  103.     unless (ref $self){
  104.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  105.     $self = $ExtUtils::MakeMaker::Parent[-1];
  106.     }
  107.     $text;
  108. }
  109.  
  110. =item libscan
  111.  
  112. Takes a path to a file that is found by init_dirscan and returns false
  113. if we don't want to include this file in the library. Mainly used to
  114. exclude RCS, CVS, and SCCS directories from installation.
  115.  
  116. =cut
  117.  
  118. # ';
  119.  
  120. sub libscan {
  121.     my($self,$path) = @_;
  122.     return '' if $path =~ m:/(RCS|CVS|SCCS)/: ;
  123.     $path;
  124. }
  125.  
  126. =item exescan
  127.  
  128. Deprecated method. Use libscan instead.
  129.  
  130. =cut
  131.  
  132. sub exescan {
  133.     my($self,$path) = @_;
  134.     $path;
  135. }
  136.  
  137. =item lsdir
  138.  
  139. Takes as arguments a directory name and a regular expression. Returns
  140. all entries in the directory that match the regular expression.
  141.  
  142. =cut
  143.  
  144. sub lsdir {
  145.     my($self) = shift;
  146.     my($dir, $regex) = @_;
  147.     my(@ls);
  148.     my $dh = new DirHandle;
  149.     $dh->open($dir || ".") or return ();
  150.     @ls = $dh->read;
  151.     $dh->close;
  152.     @ls = grep(/$regex/, @ls) if $regex;
  153.     @ls;
  154. }
  155.  
  156. =item path
  157.  
  158. Takes no argument, returns the environment variable PATH as an array.
  159.  
  160. =cut
  161.  
  162. sub path {
  163.     my($self) = @_;
  164.     my $path_sep = $Is_OS2 ? ";" : $Is_VMS ? "/" : ":";
  165.     my $path = $ENV{PATH};
  166.     $path =~ s:\\:/:g if $Is_OS2;
  167.     my @path = split $path_sep, $path;
  168. }
  169.  
  170. =item replace_manpage_separator
  171.  
  172. Takes the name of a package, which may be a nested package, in the
  173. form Foo/Bar and replaces the slash with C<::>. Returns the replacement.
  174.  
  175. =cut
  176.  
  177. sub replace_manpage_separator {
  178.     my($self,$man) = @_;
  179.     $man =~ s,/+,::,g;
  180.     $man;
  181. }
  182.  
  183. =item file_name_is_absolute
  184.  
  185. Takes as argument a path and returns true, it it is an absolute path.
  186.  
  187. =cut
  188.  
  189. sub file_name_is_absolute {
  190.     my($self,$file) = @_;
  191.     $file =~ m:^/: ;
  192. }
  193.  
  194. =item prefixify
  195.  
  196. Check a path variable in $self from %Config, if it contains a prefix,
  197. and replace it with another one. 
  198.  
  199. Takes as arguments an attribute name, a search prefix and a
  200. replacement prefix. Changes the attribute in the object.
  201.  
  202. =cut
  203.  
  204. sub prefixify {
  205.     my($self,$var,$sprefix,$rprefix) = @_;
  206.     $self->{uc $var} ||= $Config{lc $var};
  207.     $self->{uc $var} = VMS::Filespec::unixpath($self->{uc $var}) if $Is_VMS;
  208.     $self->{uc $var} =~ s/\Q$sprefix\E/$rprefix/;
  209. }
  210.  
  211. =item maybe_command_in_dirs
  212.  
  213. method under development. Not yet used. Ask Ilya :-)
  214.  
  215. =cut
  216.  
  217. sub maybe_command_in_dirs {    # $ver is optional argument if looking for perl
  218. # Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here
  219.     my($self, $names, $dirs, $trace, $ver) = @_;
  220.     my($name, $dir);
  221.     foreach $dir (@$dirs){
  222.     next unless defined $dir; # $self->{PERL_SRC} may be undefined
  223.     foreach $name (@$names){
  224.         my($abs,$tryabs);
  225.         if ($self->file_name_is_absolute($name)) {
  226.         $abs = $name;
  227.         } elsif ($name =~ m|/|) {
  228.         $abs = $self->catfile(".", $name); # not absolute
  229.         } else {
  230.         $abs = $self->catfile($dir, $name);
  231.         }
  232.         print "Checking $abs for $name\n" if ($trace >= 2);
  233.         next unless $tryabs = $self->maybe_command($abs);
  234.         print "Substituting $tryabs instead of $abs\n"
  235.         if ($trace >= 2 and $tryabs ne $abs);
  236.         $abs = $tryabs;
  237.         if (defined $ver) {
  238.         print "Executing $abs\n" if ($trace >= 2);
  239.         if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
  240.             print "Using PERL=$abs\n" if $trace;
  241.             return $abs;
  242.         }
  243.         } else { # Do not look for perl
  244.         return $abs;
  245.         }
  246.     }
  247.     }
  248. }
  249.  
  250. =item maybe_command
  251.  
  252. Returns true, if the argument is likely to be a command.
  253.  
  254. =cut
  255.  
  256. sub maybe_command {
  257.     my($self,$file) = @_;
  258.     return $file if -x $file && ! -d $file;
  259.     return;
  260. }
  261.  
  262. =item perl_script
  263.  
  264. Returns true, if we the argument is likely to be a perl script. On
  265. MM_Unix this is true for any ordinary, readable file.
  266.  
  267. =cut
  268.  
  269. sub perl_script {
  270.     my($self,$file) = @_;
  271.     return 1 if -r $file && ! -d $file;
  272.     return;
  273. }
  274.  
  275. # use SelfLoader;
  276. # sub ExtUtils::MM_Unix::guess_name ;
  277. # sub ExtUtils::MM_Unix::init_main ;
  278. # sub ExtUtils::MM_Unix::init_dirscan ;
  279. # sub ExtUtils::MM_Unix::init_others ;
  280. # sub ExtUtils::MM_Unix::find_perl ;
  281. # sub ExtUtils::MM_Unix::post_initialize ;
  282. # sub ExtUtils::MM_Unix::const_config ;
  283. # sub ExtUtils::MM_Unix::constants ;
  284. # sub ExtUtils::MM_Unix::const_loadlibs ;
  285. # sub ExtUtils::MM_Unix::const_cccmd ;
  286. # sub ExtUtils::MM_Unix::tool_autosplit ;
  287. # sub ExtUtils::MM_Unix::tool_xsubpp ;
  288. # sub ExtUtils::MM_Unix::xsubpp_version ;
  289. # sub ExtUtils::MM_Unix::tools_other ;
  290. # sub ExtUtils::MM_Unix::dist ;
  291. # sub ExtUtils::MM_Unix::macro ;
  292. # sub ExtUtils::MM_Unix::depend ;
  293. # sub ExtUtils::MM_Unix::post_constants ;
  294. # sub ExtUtils::MM_Unix::pasthru ;
  295. # sub ExtUtils::MM_Unix::c_o ;
  296. # sub ExtUtils::MM_Unix::xs_c ;
  297. # sub ExtUtils::MM_Unix::xs_o ;
  298. # sub ExtUtils::MM_Unix::top_targets ;
  299. # sub ExtUtils::MM_Unix::linkext ;
  300. # sub ExtUtils::MM_Unix::dlsyms ;
  301. # sub ExtUtils::MM_Unix::dynamic ;
  302. # sub ExtUtils::MM_Unix::dynamic_bs ;
  303. # sub ExtUtils::MM_Unix::dynamic_lib ;
  304. # sub ExtUtils::MM_Unix::static ;
  305. # sub ExtUtils::MM_Unix::static_lib ;
  306. # sub ExtUtils::MM_Unix::installpm ;
  307. # sub ExtUtils::MM_Unix::installpm_x ;
  308. # sub ExtUtils::MM_Unix::manifypods ;
  309. # sub ExtUtils::MM_Unix::processPL ;
  310. # sub ExtUtils::MM_Unix::installbin ;
  311. # sub ExtUtils::MM_Unix::subdirs ;
  312. # sub ExtUtils::MM_Unix::subdir_x ;
  313. # sub ExtUtils::MM_Unix::clean ;
  314. # sub ExtUtils::MM_Unix::realclean ;
  315. # sub ExtUtils::MM_Unix::dist_basics ;
  316. # sub ExtUtils::MM_Unix::dist_core ;
  317. # sub ExtUtils::MM_Unix::dist_dir ;
  318. # sub ExtUtils::MM_Unix::dist_test ;
  319. # sub ExtUtils::MM_Unix::dist_ci ;
  320. # sub ExtUtils::MM_Unix::install ;
  321. # sub ExtUtils::MM_Unix::force ;
  322. # sub ExtUtils::MM_Unix::perldepend ;
  323. # sub ExtUtils::MM_Unix::makefile ;
  324. # sub ExtUtils::MM_Unix::staticmake ;
  325. # sub ExtUtils::MM_Unix::test ;
  326. # sub ExtUtils::MM_Unix::test_via_harness ;
  327. # sub ExtUtils::MM_Unix::test_via_script ;
  328. # sub ExtUtils::MM_Unix::postamble ;
  329. # sub ExtUtils::MM_Unix::makeaperl ;
  330. # sub ExtUtils::MM_Unix::extliblist ;
  331. # sub ExtUtils::MM_Unix::dir_target ;
  332. # sub ExtUtils::MM_Unix::needs_linking ;
  333. # sub ExtUtils::MM_Unix::has_link_code ;
  334. # sub ExtUtils::MM_Unix::writedoc ;
  335. # 1;
  336. # __DATA__
  337.  
  338. # Without SelfLoader we need
  339. 1;
  340.  
  341. =head2 SelfLoaded methods
  342.  
  343. =item guess_name
  344.  
  345. Guess the name of this package by examining the working directory's
  346. name. MakeMaker calls this only if the developer has not supplied a
  347. NAME attribute.
  348.  
  349. =cut
  350.  
  351. # ';
  352.  
  353. sub guess_name {
  354.     my($self) = @_;
  355.     my $name = fastcwd();
  356.     $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
  357.     $name =~ s#/#::#g;
  358.     $name =~  s#[\-_][\d.\-]+$##;  # this is new with MM 5.00
  359.     $name;
  360. }
  361.  
  362. =item init_main
  363.  
  364.  
  365.  
  366. =cut
  367.  
  368. sub init_main {
  369.     my($self) = @_;
  370.     unless (ref $self){
  371.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  372.     $self = $ExtUtils::MakeMaker::Parent[-1];
  373.     }
  374.  
  375.     # --- Initialize Module Name and Paths
  376.  
  377.     # NAME    = The perl module name for this extension (eg DBD::Oracle).
  378.     # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
  379.     # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  380.     # ROOTEXT = Directory part of FULLEXT with leading /.
  381.     ($self->{FULLEXT} =
  382.      $self->{NAME}) =~ s!::!/!g ;                     #eg. BSD/Foo/Socket
  383.  
  384.     # Copied from DynaLoader:
  385.  
  386.     my(@modparts) = split(/::/,$self->{NAME});
  387.     my($modfname) = $modparts[-1];
  388.  
  389.     # Some systems have restrictions on files names for DLL's etc.
  390.     # mod2fname returns appropriate file base name (typically truncated)
  391.     # It may also edit @modparts if required.
  392.     if (defined &DynaLoader::mod2fname) {
  393.         $modfname = &DynaLoader::mod2fname(\@modparts);
  394.     } elsif ($Is_OS2) {                # Need manual correction if run with miniperl:-(
  395.         $modfname = substr($modfname, 0, 7) . '_';
  396.     }
  397.  
  398.  
  399.     ($self->{BASEEXT} =
  400.      $self->{NAME}) =~ s!.*::!! ;                     #eg. Socket
  401.  
  402.     if (defined &DynaLoader::mod2fname or $Is_OS2) {
  403.     # As of 5.001m, dl_os2 appends '_'
  404.     $self->{DLBASE} = $modfname;                    #eg. Socket_
  405.     } else {
  406.     $self->{DLBASE} = '$(BASEEXT)';
  407.     }
  408.  
  409.     ($self->{ROOTEXT} =
  410.      $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ;      #eg. /BSD/Foo
  411.  
  412.     $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};
  413.  
  414.  
  415.     # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
  416.  
  417.     # *Real* information: where did we get these two from? ...
  418.     my $inc_config_dir = dirname($INC{'Config.pm'});
  419.     my $inc_carp_dir   = dirname($INC{'Carp.pm'});
  420.  
  421.     unless ($self->{PERL_SRC}){
  422.     my($dir);
  423.     foreach $dir (qw(.. ../.. ../../..)){
  424.         if ( -f "$dir/config.sh"
  425.         && -f "$dir/perl.h"
  426.         && -f "$dir/lib/Exporter.pm") {
  427.         $self->{PERL_SRC}=$dir ;
  428.         last;
  429.         }
  430.     }
  431.     }
  432.     if ($self->{PERL_SRC}){
  433.     $self->{PERL_LIB}     ||= $self->catdir("$self->{PERL_SRC}","lib");
  434.     $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
  435.     $self->{PERL_INC}     = $self->{PERL_SRC};
  436.     # catch a situation that has occurred a few times in the past:
  437.     warn <<EOM unless -s "$self->{PERL_SRC}/cflags";
  438. You cannot build extensions below the perl source tree after executing
  439. a 'make clean' in the perl source tree.
  440.  
  441. To rebuild extensions distributed with the perl source you should
  442. simply Configure (to include those extensions) and then build perl as
  443. normal. After installing perl the source tree can be deleted. It is
  444. not needed for building extensions by running 'perl Makefile.PL'
  445. usually without extra arguments.
  446.  
  447. It is recommended that you unpack and build additional extensions away
  448. from the perl source tree.
  449. EOM
  450.     } else {
  451.     # we should also consider $ENV{PERL5LIB} here
  452.     $self->{PERL_LIB}     ||= $Config::Config{privlibexp};
  453.     $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};
  454.     $self->{PERL_INC}     = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
  455.     my $perl_h;
  456.     die <<EOM unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h")));
  457. Error: Unable to locate installed Perl libraries or Perl source code.
  458.  
  459. It is recommended that you install perl in a standard location before
  460. building extensions. You can say:
  461.  
  462.     $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory
  463.  
  464. if you have not yet installed perl but still want to build this
  465. extension now.
  466. (You get this message, because MakeMaker could not find "$perl_h")
  467. EOM
  468.  
  469. #     print STDOUT "Using header files found in $self->{PERL_INC}\n"
  470. #         if $Verbose && $self->needs_linking();
  471.  
  472.     }
  473.  
  474.     # We get SITELIBEXP and SITEARCHEXP directly via
  475.     # Get_from_Config. When we are running standard modules, these
  476.     # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
  477.     # set it to "site". I prefer that INSTALLDIRS be set from outside
  478.     # MakeMaker.
  479.     $self->{INSTALLDIRS} ||= "site";
  480.  
  481.     # INST_LIB typically pre-set if building an extension after
  482.     # perl has been built and installed. Setting INST_LIB allows
  483.     # you to build directly into, say $Config::Config{privlibexp}.
  484.     unless ($self->{INST_LIB}){
  485.  
  486.  
  487.     ##### XXXXX We have to change this nonsense
  488.  
  489.     if (defined $self->{PERL_SRC} and $self->{INSTALLDIRS} eq "perl") {
  490.         $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
  491.     } else {
  492.         $self->{INST_LIB} = $self->catdir("..","../..","lib");
  493.     }
  494.     }
  495.     $self->{INST_ARCHLIB} ||= $self->catdir(".","blib","arch");
  496.     $self->{INST_EXE} ||= $self->catdir('.','blib','bin');
  497.  
  498.     # The user who requests an installation directory explicitly
  499.     # should not have to tell us a architecture installation directory
  500.     # as well We look if a directory exists that is named after the
  501.     # architecture. If not we take it as a sign that it should be the
  502.     # same as the requested installation directory. Otherwise we take
  503.     # the found one.
  504.     # We do the same thing twice: for privlib/archlib and for sitelib/sitearch
  505.     my($libpair);
  506.     for $libpair ({l=>"privlib", a=>"archlib"}, {l=>"sitelib", a=>"sitearch"}) {
  507.     my $lib = "install$libpair->{l}";
  508.     my $Lib = uc $lib;
  509.     my $Arch = uc "install$libpair->{a}";
  510.     if( $self->{$Lib} && ! $self->{$Arch} ){
  511.         my($ilib) = $Config{$lib};
  512.         $ilib = VMS::Filespec::unixify($ilib) if $Is_VMS;
  513.  
  514.         $self->prefixify($Arch,$ilib,$self->{$Lib});
  515.  
  516.         unless (-d $self->{$Arch}) {
  517.         print STDOUT "Directory $self->{$Arch} not found, thusly\n" if $Verbose;
  518.         $self->{$Arch} = $self->{$Lib};
  519.         }
  520.         print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
  521.     }
  522.     }
  523.  
  524.     # we have to look at the relation between $Config{prefix} and the
  525.     # requested values. We're going to set the $Config{prefix} part of
  526.     # all the installation path variables to literally $(PREFIX), so
  527.     # the user can still say make PREFIX=foo
  528.     my($prefix) = $Config{'prefix'};
  529.     $prefix = VMS::Filespec::unixify($prefix) if $Is_VMS;
  530.     unless ($self->{PREFIX}){
  531.     $self->{PREFIX} = $prefix;
  532.     }
  533.     my($install_variable);
  534.     for $install_variable (qw/INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN INSTALLMAN1DIR
  535.                INSTALLMAN3DIR INSTALLSITELIB INSTALLSITEARCH/) {
  536.     $self->prefixify($install_variable,$prefix,q[$(PREFIX)]);
  537.     }
  538.  
  539.  
  540.     # Now we head at the manpages. Maybe they DO NOT want manpages
  541.     # installed
  542.     $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir}
  543.     unless defined $self->{INSTALLMAN1DIR};
  544.     unless (defined $self->{INST_MAN1DIR}){
  545.     if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){
  546.         $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR};
  547.     } else {
  548.         $self->{INST_MAN1DIR} = $self->catdir('.','../..','man1');
  549.     }
  550.     }
  551.     $self->{MAN1EXT} ||= $Config::Config{man1ext};
  552.  
  553.     $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir}
  554.     unless defined $self->{INSTALLMAN3DIR};
  555.     unless (defined $self->{INST_MAN3DIR}){
  556.     if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){
  557.         $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR};
  558.     } else {
  559.         $self->{INST_MAN3DIR} = $self->catdir('.','../..','man3');
  560.     }
  561.     }
  562.     $self->{MAN3EXT} ||= $Config::Config{man3ext};
  563.  
  564.  
  565.     # Get some stuff out of %Config if we haven't yet done so
  566.     print STDOUT "CONFIG must be an array ref\n"
  567.     if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
  568.     $self->{CONFIG} = [] unless (ref $self->{CONFIG});
  569.     push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
  570.     push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags};
  571.     my(%once_only,$m);
  572.     foreach $m (@{$self->{CONFIG}}){
  573.     next if $once_only{$m};
  574.     print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
  575.         unless exists $Config::Config{$m};
  576.     $self->{uc $m} ||= $Config::Config{$m};
  577.     $once_only{$m} = 1;
  578.     }
  579.  
  580. # This is too dangerous:
  581. #    if ($Config{osname} eq "next") {
  582. #    $self->{AR} = "libtool";
  583. #    $self->{AR_STATIC_ARGS} = "-o";
  584. #    }
  585. # But I leave it as a placeholder
  586.  
  587.     $self->{AR_STATIC_ARGS} ||= "cr";
  588.  
  589.     # These should never be needed
  590.     $self->{LD} ||= 'ld';
  591.     $self->{OBJ_EXT} ||= '.o';
  592.     $self->{LIB_EXT} ||= '.a';
  593.  
  594.     $self->{MAP_TARGET} ||= "perl";
  595.  
  596.     $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
  597.  
  598.     # make a simple check if we find Exporter
  599.     warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
  600.         (Exporter.pm not found)"
  601.     unless (-f $self->catfile("$self->{PERL_LIB}","Exporter.pm"));
  602.  
  603.     # Determine VERSION and VERSION_FROM
  604.     ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME};
  605.     if ($self->{VERSION_FROM}){
  606.     my $fh = new FileHandle;
  607.     $fh->open($self->{VERSION_FROM}) or die "Could not open '$self->{VERSION_FROM}' (attribute VERSION_FROM): $!";
  608.     while (<$fh>) {
  609.         chop;
  610.         next unless /\$([\w:]*\bVERSION)\b.*=/;
  611.         local $ExtUtils::MakeMaker::module_version_variable = $1;
  612.         my($eval) = "$_;";
  613.         eval $eval;
  614.         die "Could not eval '$eval': $@" if $@;
  615.         if ($self->{VERSION} = $ {$ExtUtils::MakeMaker::module_version_variable}){
  616.         print "$self->{NAME} VERSION is $self->{VERSION} (from $self->{VERSION_FROM})\n" if $Verbose;
  617.         } else {
  618.         # XXX this should probably croak
  619.         print "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n";
  620.         }
  621.         last;
  622.     }
  623.     close $fh;
  624.     }
  625.  
  626.     # if your FOO.pm says
  627.     #    $VERSION = substr(q$Revision: 1.4 $, 10);
  628.     # then MM says something like
  629.     #    -DXS_VERSION=\"n.nn \"
  630.     if ($self->{VERSION}) {
  631.     $self->{VERSION} =~ s/^\s+//;
  632.     $self->{VERSION} =~ s/\s+$//;
  633.     }
  634.  
  635.     $self->{VERSION} = "0.10" unless $self->{VERSION};
  636.     ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
  637.  
  638.  
  639.     # Graham Barr and Paul Marquess had some ideas how to ensure
  640.     # version compatibility between the *.pm file and the
  641.     # corresponding *.xs file. The bottomline was, that we need an
  642.     # XS_VERSION macro that defaults to VERSION:
  643.     $self->{XS_VERSION} ||= $self->{VERSION};
  644.  
  645.     # --- Initialize Perl Binary Locations
  646.  
  647.     # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
  648.     # will be working versions of perl 5. miniperl has priority over perl
  649.     # for PERL to ensure that $(PERL) is usable while building ./ext/*
  650.     my ($component,@defpath);
  651.     foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
  652.     push @defpath, $component if defined $component;
  653.     }
  654.     $self->{PERL} =
  655.         $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ],
  656.         \@defpath, $Verbose ) unless ($self->{PERL});
  657.     # don't check if perl is executable, maybe they have decided to
  658.     # supply switches with perl
  659.  
  660.     # Define 'FULLPERL' to be a non-miniperl (used in test: target)
  661.     ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
  662.     unless ($self->{FULLPERL});
  663. }
  664.  
  665. =item init_dirscan
  666.  
  667.  
  668.  
  669. =cut
  670.  
  671. sub init_dirscan {    # --- File and Directory Lists (.xs .pm .pod etc)
  672.     my($self) = @_;
  673.     unless (ref $self){
  674.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  675.     $self = $ExtUtils::MakeMaker::Parent[-1];
  676.     }
  677.     my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
  678.     local(%pm); #the sub in find() has to see this hash
  679.     $ignore{'test.pl'} = 1;
  680.     $ignore{'makefile.pl'} = 1 if $Is_VMS;
  681.     foreach $name ($self->lsdir(".")){
  682.     next if ($name =~ /^\./ or $ignore{$name});
  683.     next unless $self->libscan($name);
  684.     if (-d $name){
  685.         $dir{$name} = $name if (-f "$name/Makefile.PL");
  686.     } elsif ($name =~ /\.xs$/){
  687.         my($c); ($c = $name) =~ s/\.xs$/.c/;
  688.         $xs{$name} = $c;
  689.         $c{$c} = 1;
  690.     } elsif ($name =~ /\.c(pp|xx|c)?$/i){  # .c .C .cpp .cxx .cc
  691.         $c{$name} = 1
  692.         unless $name =~ m/perlmain\.c/; # See MAP_TARGET
  693.     } elsif ($name =~ /\.h$/i){
  694.         $h{$name} = 1;
  695.     } elsif ($name =~ /\.(p[ml]|pod)$/){
  696.         $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);
  697.     } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
  698.         ($pl_files{$name} = $name) =~ s/\.PL$// ;
  699.     } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' &&
  700.              $name ne 'test.pl') {  # case-insensitive filesystem
  701.         ($pl_files{$name} = $name) =~ s/\.pl$// ;
  702.     }
  703.     }
  704.  
  705.     # Some larger extensions often wish to install a number of *.pm/pl
  706.     # files into the library in various locations.
  707.  
  708.     # The attribute PMLIBDIRS holds an array reference which lists
  709.     # subdirectories which we should search for library files to
  710.     # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ].  We
  711.     # recursively search through the named directories (skipping any
  712.     # which don't exist or contain Makefile.PL files).
  713.  
  714.     # For each *.pm or *.pl file found $self->libscan() is called with
  715.     # the default installation path in $_[1]. The return value of
  716.     # libscan defines the actual installation location.  The default
  717.     # libscan function simply returns the path.  The file is skipped
  718.     # if libscan returns false.
  719.  
  720.     # The default installation location passed to libscan in $_[1] is:
  721.     #
  722.     #  ./*.pm        => $(INST_LIBDIR)/*.pm
  723.     #  ./xyz/...    => $(INST_LIBDIR)/xyz/...
  724.     #  ./lib/...    => $(INST_LIB)/...
  725.     #
  726.     # In this way the 'lib' directory is seen as the root of the actual
  727.     # perl library whereas the others are relative to INST_LIBDIR
  728.     # (which includes ROOTEXT). This is a subtle distinction but one
  729.     # that's important for nested modules.
  730.  
  731.     $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]
  732.     unless $self->{PMLIBDIRS};
  733.  
  734.     #only existing directories that aren't in $dir are allowed
  735.  
  736.     # Avoid $_ wherever possible:
  737.     # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
  738.     my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
  739.     my ($pmlibdir);
  740.     @{$self->{PMLIBDIRS}} = ();
  741.     foreach $pmlibdir (@pmlibdirs) {
  742.     -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
  743.     }
  744.  
  745.     if (@{$self->{PMLIBDIRS}}){
  746.     print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
  747.         if ($Verbose >= 2);
  748.     File::Find::find(sub {
  749.         if (-d $_){
  750.         if ($_ eq "CVS" || $_ eq "RCS"){
  751.             $File::Find::prune = 1;
  752.         }
  753.         return;
  754.         }
  755.         my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
  756.         my($striplibpath,$striplibname);
  757.         $prefix =  '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:);
  758.         ($striplibname,$striplibpath) = fileparse($striplibpath);
  759.         my($inst) = $self->catfile($prefix,$striplibpath,$striplibname);
  760.         local($_) = $inst; # for backwards compatibility
  761.         $inst = $self->libscan($inst);
  762.         print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
  763.         return unless $inst;
  764.         $pm{$path} = $inst;
  765.     }, @{$self->{PMLIBDIRS}});
  766.     }
  767.  
  768.     $self->{DIR} = [sort keys %dir] unless $self->{DIR};
  769.     $self->{XS}  = \%xs             unless $self->{XS};
  770.     $self->{PM}  = \%pm             unless $self->{PM};
  771.     $self->{C}   = [sort keys %c]   unless $self->{C};
  772.     my(@o_files) = @{$self->{C}};
  773.     $self->{O_FILES} = [grep s/\.c(pp|xx|c)?$/$self->{OBJ_EXT}/i, @o_files] ;
  774.     $self->{H}   = [sort keys %h]   unless $self->{H};
  775.     $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
  776.  
  777.     # Set up names of manual pages to generate from pods
  778.     if ($self->{MAN1PODS}) {
  779.     } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) {
  780.         $self->{MAN1PODS} = {};
  781.     } else {
  782.     my %manifypods = ();
  783.     if ( exists $self->{EXE_FILES} ) {
  784.         foreach $name (@{$self->{EXE_FILES}}) {
  785.         my $fh = new FileHandle;
  786.         my($ispod)=0;
  787.         # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?)
  788.         if ($fh->open("<$name")) {
  789.             my $testpodline;
  790.             while ($testpodline = <$fh>) {
  791.             if($testpodline =~ /^=head1\s+\w+/) {
  792.                 $ispod=1;
  793.                 last;
  794.             }
  795.             }
  796.             $fh->close;
  797.         } else {
  798.             # If it doesn't exist yet, we assume, it has pods in it
  799.             $ispod = 1;
  800.         }
  801.         if( $ispod ) {
  802.             $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)');
  803.         }
  804.         }
  805.     }
  806.     $self->{MAN1PODS} = \%manifypods;
  807.     }
  808.     if ($self->{MAN3PODS}) {
  809.     } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) {
  810.         $self->{MAN3PODS} = {};
  811.     } else {
  812.     my %manifypods = (); # we collect the keys first, i.e. the files
  813.                  # we have to convert to pod
  814.     foreach $name (keys %{$self->{PM}}) {
  815.         if ($name =~ /\.pod$/ ) {
  816.         $manifypods{$name} = $self->{PM}{$name};
  817.         } elsif ($name =~ /\.p[ml]$/ ) {
  818.         my $fh = new FileHandle;
  819.         my($ispod)=0;
  820.         $fh->open("<$name");
  821.         my $testpodline;
  822.         while ($testpodline = <$fh>) {
  823.             if($testpodline =~ /^=head1\s+\w+/) {
  824.             $ispod=1;
  825.             last;
  826.             }
  827.             #Speculation on the future (K.A., not A.K. :)
  828.             #if(/^=don't\S+install/) { $ispod=0; last}
  829.         }
  830.         $fh->close;
  831.  
  832.         if( $ispod ) {
  833.             $manifypods{$name} = $self->{PM}{$name};
  834.         }
  835.         }
  836.     }
  837.  
  838.     # Remove "Configure.pm" and similar, if it's not the only pod listed
  839.     # To force inclusion, just name it "Configure.pod", or override MAN3PODS
  840.     foreach $name (keys %manifypods) {
  841.         if ($name =~ /(config|setup).*\.pm/i) {
  842.         delete $manifypods{$name};
  843.         next;
  844.         }
  845.         my($manpagename) = $name;
  846.         unless ($manpagename =~ s!^(\W*)lib\W!$1!) {
  847.         $manpagename = $self->catfile($self->{ROOTEXT},$manpagename);
  848.         }
  849.         $manpagename =~ s/\.p(od|m|l)$//;
  850.         # Strip leading slashes
  851.         $manpagename =~ s!^/+!!;
  852.         # Turn other slashes into colons
  853. #        $manpagename =~ s,/+,::,g;
  854.         $manpagename = $self->replace_manpage_separator($manpagename);
  855.         $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)");
  856.     }
  857.     $self->{MAN3PODS} = \%manifypods;
  858.     }
  859. }
  860.  
  861. =item init_others
  862.  
  863.  
  864.  
  865. =cut
  866.  
  867. sub init_others {    # --- Initialize Other Attributes
  868.     my($self) = shift;
  869.     unless (ref $self){
  870.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  871.     $self = $ExtUtils::MakeMaker::Parent[-1];
  872.     }
  873.  
  874.     # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
  875.     # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
  876.     # undefined. In any case we turn it into an anon array:
  877.  
  878.     # May check $Config{libs} too, thus not empty.
  879.     $self->{LIBS}=[''] unless $self->{LIBS};
  880.  
  881.     $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq SCALAR;
  882.     $self->{LD_RUN_PATH} = "";
  883.     my($libs);
  884.     foreach $libs ( @{$self->{LIBS}} ){
  885.     $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
  886.     my(@libs) = $self->extliblist($libs);
  887.     if ($libs[0] or $libs[1] or $libs[2]){
  888.         # LD_RUN_PATH now computed by ExtUtils::Liblist
  889.         ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
  890.         last;
  891.     }
  892.     }
  893.  
  894.     unless ( $self->{OBJECT} ){
  895.     # init_dirscan should have found out, if we have C files
  896.     $self->{OBJECT} = "";
  897.     $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
  898.     }
  899.     $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
  900.     $self->{BOOTDEP}  = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
  901.     $self->{PERLMAINCC} ||= '$(CC)';
  902.     $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
  903.  
  904.     # Sanity check: don't define LINKTYPE = dynamic if we're skipping
  905.     # the 'dynamic' section of MM.  We don't have this problem with
  906.     # 'static', since we either must use it (%Config says we can't
  907.     # use dynamic loading) or the caller asked for it explicitly.
  908.     if (!$self->{LINKTYPE}) {
  909.        $self->{LINKTYPE} = grep(/dynamic/,@{$self->{SKIP} || []})
  910.                         ? 'static'
  911.                         : ($Config::Config{usedl} ? 'dynamic' : 'static');
  912.     };
  913.  
  914.     # These get overridden for VMS and maybe some other systems
  915.     $self->{NOOP}  ||= "";
  916.     $self->{FIRST_MAKEFILE} ||= "Makefile";
  917.     $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
  918.     $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
  919.     $self->{NOECHO} = '@' unless defined $self->{NOECHO};
  920.     $self->{RM_F}  ||= "rm -f";
  921.     $self->{RM_RF} ||= "rm -rf";
  922.     $self->{TOUCH} ||= "touch";
  923.     $self->{CP} ||= "cp";
  924.     $self->{MV} ||= "mv";
  925.     $self->{CHMOD} ||= "chmod";
  926.     $self->{UMASK_NULL} ||= "umask 0";
  927. }
  928.  
  929. =item find_perl
  930.  
  931.  
  932.  
  933. =cut
  934.  
  935. sub find_perl {
  936.     my($self, $ver, $names, $dirs, $trace) = @_;
  937.     unless (ref $self){
  938.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  939.     $self = $ExtUtils::MakeMaker::Parent[-1];
  940.     }
  941.     my($name, $dir);
  942.     if ($trace >= 2){
  943.     print "Looking for perl $ver by these names:
  944. @$names
  945. in these dirs:
  946. @$dirs
  947. ";
  948.     }
  949.     foreach $dir (@$dirs){
  950.     next unless defined $dir; # $self->{PERL_SRC} may be undefined
  951.     foreach $name (@$names){
  952.         my $abs;
  953.         if ($self->file_name_is_absolute($name)) {
  954.         $abs = $name;
  955.         } elsif (($name =~ m|/|) && ($name !~ m|^\.{1,2}/|)) {
  956.         # name is a path that does not begin with dot or dotdot
  957.         $abs = $self->catfile(".", $name);
  958.         } else {
  959.         $abs = $self->catfile($dir, $name);
  960.         }
  961.         print "Checking $abs\n" if ($trace >= 2);
  962.         next unless $self->maybe_command($abs);
  963.         print "Executing $abs\n" if ($trace >= 2);
  964.     #    if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
  965.             print "Using PERL=$abs\n" if $trace;
  966.             return $abs;
  967.     #    }
  968.     }
  969.     }
  970.     print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
  971.     0; # false and not empty
  972. }
  973.  
  974. =head2 Methods to actually produce chunks of text for the Makefile
  975.  
  976. The methods here are called in the order specified by
  977. @ExtUtils::MakeMaker::MM_Sections. This manpage reflects the order as
  978. well as possible. Some methods call each other, so in doubt refer to
  979. the code.
  980.  
  981. =item post_initialize
  982.  
  983. Returns an ampty string per default. Used in Makefile.PLs to add some
  984. chunk of text to the Makefile after the object is initialized.
  985.  
  986. =cut
  987.  
  988. sub post_initialize {
  989.     my($self) = shift;
  990.     unless (ref $self){
  991.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  992.     $self = $ExtUtils::MakeMaker::Parent[-1];
  993.     }
  994.     "";
  995. }
  996.  
  997. =item const_config
  998.  
  999.  
  1000.  
  1001. =cut
  1002.  
  1003. sub const_config {
  1004. # --- Constants Sections ---
  1005.  
  1006.     my($self) = shift;
  1007.     unless (ref $self){
  1008.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1009.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1010.     }
  1011.     my(@m,$m);
  1012.     push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
  1013.     push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
  1014.     my(%once_only);
  1015.     foreach $m (@{$self->{CONFIG}}){
  1016.     # SITE*EXP macros are defined in &constants; avoid duplicates here
  1017.     next if $once_only{$m} or $m eq 'SITELIBEXP' or $m eq 'SITEARCHEXP';
  1018.     push @m, "\U$m\E = ".$self->{uc $m}."\n";
  1019.     $once_only{$m} = 1;
  1020.     }
  1021.     join('', @m);
  1022. }
  1023.  
  1024. =item constants
  1025.  
  1026.  
  1027.  
  1028. =cut
  1029.  
  1030. sub constants {
  1031.     my($self) = @_;
  1032.     unless (ref $self){
  1033.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1034.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1035.     }
  1036.     my(@m,$tmp);
  1037.  
  1038.     for $tmp (qw/
  1039.           AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION VERSION_SYM XS_VERSION
  1040.           INST_LIB INST_ARCHLIB INST_EXE PREFIX INSTALLDIRS INSTALLPRIVLIB
  1041.           INSTALLARCHLIB INSTALLSITELIB INSTALLSITEARCH INSTALLBIN PERL_LIB
  1042.           PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
  1043.           FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_INC PERL FULLPERL
  1044.           / ) {
  1045.     next unless defined $self->{$tmp};
  1046.     push @m, "$tmp = $self->{$tmp}\n";
  1047.     }
  1048.  
  1049.     push @m, qq{
  1050. VERSION_MACRO = VERSION
  1051. DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
  1052. XS_VERSION_MACRO = XS_VERSION
  1053. XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
  1054. };
  1055.  
  1056.     push @m, qq{
  1057. MAKEMAKER = \$(PERL_LIB)/ExtUtils/MakeMaker.pm
  1058. MM_VERSION = $ExtUtils::MakeMaker::VERSION
  1059. MM_REVISION = $Revision
  1060. };
  1061.  
  1062.     push @m, q{
  1063. # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
  1064. # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  1065. # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
  1066. # DLBASE  = Basename part of dynamic library. May be just equal BASEEXT.
  1067. };
  1068.  
  1069.     for $tmp (qw/
  1070.           FULLEXT BASEEXT ROOTEXT DLBASE VERSION_FROM INC DEFINE OBJECT OBJECT
  1071.           LDFROM LINKTYPE
  1072.           /    ) {
  1073.     next unless defined $self->{$tmp};
  1074.     push @m, "$tmp = $self->{$tmp}\n";
  1075.     }
  1076.  
  1077.     push @m, "
  1078. # Handy lists of source code files:
  1079. XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
  1080. C_FILES = ".join(" \\\n\t", @{$self->{C}})."
  1081. O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
  1082. H_FILES = ".join(" \\\n\t", @{$self->{H}})."
  1083. MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
  1084. MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
  1085. ";
  1086.  
  1087.     for $tmp (qw/
  1088.           INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
  1089.           /) {
  1090.     next unless defined $self->{$tmp};
  1091.     push @m, "$tmp = $self->{$tmp}\n";
  1092.     }
  1093.  
  1094.     push @m, "
  1095. # work around a famous dec-osf make(1) feature(?):
  1096. makemakerdflt: all
  1097.  
  1098. .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
  1099.  
  1100. # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
  1101. # some make implementations will delete the Makefile when we rebuild it. Because
  1102. # we call false(1) when we rebuild it. So make(1) is not completely wrong when it
  1103. # does so. Our milage may vary.
  1104. # .PRECIOUS: Makefile    # seems to be not necessary anymore
  1105.  
  1106. .PHONY: all config static dynamic test linkext manifest
  1107.  
  1108. # Where is the Config information that we are using/depend on
  1109. CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h \$(VERSION_FROM)
  1110. ";
  1111.  
  1112.     push @m, '
  1113. # Where to put things:
  1114. INST_LIBDIR     = $(INST_LIB)$(ROOTEXT)
  1115. INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
  1116.  
  1117. INST_AUTODIR      = $(INST_LIB)/auto/$(FULLEXT)
  1118. INST_ARCHAUTODIR  = $(INST_ARCHLIB)/auto/$(FULLEXT)
  1119. ';
  1120.  
  1121.     if ($self->has_link_code()) {
  1122.     push @m, '
  1123. INST_STATIC  = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
  1124. INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
  1125. INST_BOOT    = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
  1126. ';
  1127.     } else {
  1128.     push @m, '
  1129. INST_STATIC  =
  1130. INST_DYNAMIC =
  1131. INST_BOOT    =
  1132. ';
  1133.     }
  1134.  
  1135.     if ($Is_OS2) {
  1136.     $tmp = "$self->{BASEEXT}.def";
  1137.     } else {
  1138.     $tmp = "";
  1139.     }
  1140.     push @m, "
  1141. EXPORT_LIST = $tmp
  1142. ";
  1143.  
  1144.     if ($Is_OS2) {
  1145.     $tmp = "\$(PERL_INC)/libperl.lib";
  1146.     } else {
  1147.     $tmp = "";
  1148.     }
  1149.     push @m, "
  1150. PERL_ARCHIVE = $tmp
  1151. ";
  1152.  
  1153.     push @m, '
  1154. INST_PM = '.join(" \\\n\t", sort values %{$self->{PM}}).'
  1155. ';
  1156.  
  1157.     join('',@m);
  1158. }
  1159.  
  1160. =item const_loadlibs
  1161.  
  1162.  
  1163.  
  1164. =cut
  1165.  
  1166. sub const_loadlibs {
  1167.     my($self) = shift;
  1168.     unless (ref $self){
  1169.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1170.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1171.     }
  1172.     return "" unless $self->needs_linking;
  1173.     # This description can be deleted after ExtUtils::Liblist is in
  1174.     # the perl dist with pods
  1175.     "
  1176. # $self->{NAME} might depend on some other libraries:
  1177. # (These comments may need revising:)
  1178. #
  1179. # Dependent libraries can be linked in one of three ways:
  1180. #
  1181. #  1.  (For static extensions) by the ld command when the perl binary
  1182. #      is linked with the extension library. See EXTRALIBS below.
  1183. #
  1184. #  2.  (For dynamic extensions) by the ld command when the shared
  1185. #      object is built/linked. See LDLOADLIBS below.
  1186. #
  1187. #  3.  (For dynamic extensions) by the DynaLoader when the shared
  1188. #      object is loaded. See BSLOADLIBS below.
  1189. #
  1190. # EXTRALIBS =    List of libraries that need to be linked with when
  1191. #        linking a perl binary which includes this extension
  1192. #        Only those libraries that actually exist are included.
  1193. #        These are written to a file and used when linking perl.
  1194. #
  1195. # LDLOADLIBS =    List of those libraries which can or must be linked into
  1196. #        the shared library when created using ld. These may be
  1197. #        static or dynamic libraries.
  1198. #        LD_RUN_PATH is a colon separated list of the directories
  1199. #        in LDLOADLIBS. It is passed as an environment variable to
  1200. #        the process that links the shared library.
  1201. #
  1202. # BSLOADLIBS =    List of those libraries that are needed but can be
  1203. #        linked in dynamically at run time on this platform.
  1204. #        SunOS/Solaris does not need this because ld records
  1205. #        the information (from LDLOADLIBS) into the object file.
  1206. #        This list is used to create a .bs (bootstrap) file.
  1207. #
  1208. EXTRALIBS  = $self->{EXTRALIBS}
  1209. LDLOADLIBS = $self->{LDLOADLIBS}
  1210. BSLOADLIBS = $self->{BSLOADLIBS}
  1211. LD_RUN_PATH= $self->{LD_RUN_PATH}
  1212. ";
  1213. }
  1214.  
  1215. =item const_cccmd
  1216.  
  1217.  
  1218.  
  1219. =cut
  1220.  
  1221. sub const_cccmd {
  1222.     my($self,$libperl)=@_;
  1223.     unless (ref $self){
  1224.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1225.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1226.     }
  1227.     return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
  1228.     return '' unless $self->needs_linking();
  1229.     $libperl or $libperl = $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
  1230.     $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
  1231.     # This is implemented in the same manner as extliblist,
  1232.     # e.g., do both and compare results during the transition period.
  1233.     my($cc,$ccflags,$optimize,$large,$split, $shflags)
  1234.     = @Config{qw(cc ccflags optimize large split shellflags)};
  1235.     my($optdebug) = "";
  1236.  
  1237.     $shflags = '' unless $shflags;
  1238.     my($prog, $uc, $perltype);
  1239.  
  1240.     my(%map) =  (
  1241.         D =>   '-DDEBUGGING',
  1242.         E =>   '-DEMBED',
  1243.         DE =>  '-DDEBUGGING -DEMBED',
  1244.         M =>   '-DEMBED -DMULTIPLICITY',
  1245.         DM =>  '-DDEBUGGING -DEMBED -DMULTIPLICITY',
  1246.         );
  1247.  
  1248.     if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
  1249.     $uc = uc($1);
  1250.     } else {
  1251.     $uc = ""; # avoid warning
  1252.     }
  1253.     $perltype = $map{$uc} ? $map{$uc} : "";
  1254.  
  1255.     if ($uc =~ /^D/) {
  1256.     $optdebug = "-g";
  1257.     }
  1258.  
  1259.  
  1260.     my($name);
  1261.     ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
  1262.     if ($prog = $Config::Config{$name}) {
  1263.     # Expand hints for this extension via the shell
  1264.     print STDOUT "Processing $name hint:\n" if $Verbose;
  1265.     my(@o)=`cc=\"$cc\"
  1266.       ccflags=\"$ccflags\"
  1267.       optimize=\"$optimize\"
  1268.       perltype=\"$perltype\"
  1269.       optdebug=\"$optdebug\"
  1270.       large=\"$large\"
  1271.       split=\"$split\"
  1272.       eval '$prog'
  1273.       echo cc=\$cc
  1274.       echo ccflags=\$ccflags
  1275.       echo optimize=\$optimize
  1276.       echo perltype=\$perltype
  1277.       echo optdebug=\$optdebug
  1278.       echo large=\$large
  1279.       echo split=\$split
  1280.       `;
  1281.     my(%cflags,$line);
  1282.     foreach $line (@o){
  1283.         chomp $line;
  1284.         if ($line =~ /(.*?)=\s*(.*)\s*$/){
  1285.         $cflags{$1} = $2;
  1286.         print STDOUT "    $1 = $2\n" if $Verbose;
  1287.         } else {
  1288.         print STDOUT "Unrecognised result from hint: '$line'\n";
  1289.         }
  1290.     }
  1291.     (    $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split )=@cflags{
  1292.           qw( cc  ccflags  perltype  optdebug  optimize  large  split)};
  1293.     }
  1294.  
  1295.     if ($optdebug) {
  1296.     $optimize = $optdebug;
  1297.     }
  1298.  
  1299.     my($new) = "$cc -c \$(INC) $ccflags $optimize $perltype $large $split";
  1300.     $new =~ s/^\s+//; $new =~ s/\s+/ /g; $new =~ s/\s+$//;
  1301.  
  1302.     my($cccmd) = $new;
  1303.     $cccmd =~ s/^\s*\Q$Config::Config{cc}\E\s/\$(CC) /;
  1304.     $cccmd .= " \$(DEFINE_VERSION) \$(XS_DEFINE_VERSION)";
  1305.     $self->{CONST_CCCMD} = "CCCMD = $cccmd\n";
  1306. }
  1307.  
  1308. =item tool_autosplit
  1309.  
  1310.  
  1311.  
  1312. =cut
  1313.  
  1314. sub tool_autosplit {
  1315. # --- Tool Sections ---
  1316.  
  1317.     my($self, %attribs) = @_;
  1318.     unless (ref $self){
  1319.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1320.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1321.     }
  1322.     my($asl) = "";
  1323.     $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
  1324.     q{
  1325. # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
  1326. AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
  1327. };
  1328. }
  1329.  
  1330. =item tool_xsubpp
  1331.  
  1332.  
  1333.  
  1334. =cut
  1335.  
  1336. sub tool_xsubpp {
  1337.     my($self) = shift;
  1338.     unless (ref $self){
  1339.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1340.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1341.     }
  1342.     my($xsdir)  = "$self->{PERL_LIB}/ExtUtils";
  1343.     # drop back to old location if xsubpp is not in new location yet
  1344.     $xsdir = "$self->{PERL_SRC}/ext" unless (-f "$self->{PERL_LIB}/ExtUtils/xsubpp");
  1345.     my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
  1346.     if( $self->{TYPEMAPS} ){
  1347.     my $typemap;
  1348.     foreach $typemap (@{$self->{TYPEMAPS}}){
  1349.         if( ! -f  $typemap ){
  1350.             warn "Typemap $typemap not found.\n";
  1351.         }
  1352.         else{
  1353.             push(@tmdeps,  $typemap);
  1354.         }
  1355.     }
  1356.     }
  1357.     push(@tmdeps, "typemap") if -f "typemap";
  1358.     my(@tmargs) = map("-typemap $_", @tmdeps);
  1359.     if( exists $self->{XSOPT} ){
  1360.      unshift( @tmargs, $self->{XSOPT} );
  1361.     }
  1362.  
  1363.     my $xsubpp_version = $self->xsubpp_version("$xsdir/xsubpp");
  1364.  
  1365.     # What are the correct thresholds for version 1 && 2 Paul?
  1366.     if ( $xsubpp_version > 1.923 ){
  1367.     $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
  1368.     } else {
  1369.     if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
  1370.         print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
  1371.     Your version of xsubpp is $xsubpp_version and cannot handle this.
  1372.     Please upgrade to a more recent version of xsubpp.
  1373. };
  1374.     } else {
  1375.         $self->{XSPROTOARG} = "";
  1376.     }
  1377.     }
  1378.  
  1379.     "
  1380. XSUBPPDIR = $xsdir
  1381. XSUBPP = \$(XSUBPPDIR)/xsubpp
  1382. XSPROTOARG = $self->{XSPROTOARG}
  1383. XSUBPPDEPS = @tmdeps
  1384. XSUBPPARGS = @tmargs
  1385. ";
  1386. };
  1387.  
  1388. sub xsubpp_version
  1389. {
  1390.     my($self,$xsubpp) = @_;
  1391.     my ($version) ;
  1392.  
  1393.     # try to figure out the version number of the xsubpp on the system
  1394.  
  1395.     # first try the -v flag, introduced in 1.921 & 2.000a2
  1396.  
  1397.     my $command = "$self->{PERL} $xsubpp -v 2>&1";
  1398.     print "Running $command\n" if $Verbose >= 2;
  1399.     $version = `$command` ;
  1400.     warn "Running '$command' exits with status " . ($?>>8) if $?;
  1401.     chop $version ;
  1402.  
  1403.     return $1 if $version =~ /^xsubpp version (.*)/ ;
  1404.  
  1405.     # nope, then try something else
  1406.  
  1407.     my $counter = '000';
  1408.     my ($file) = 'temp' ;
  1409.     $counter++ while -e "$file$counter"; # don't overwrite anything
  1410.     $file .= $counter;
  1411.  
  1412.     open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
  1413.     print F <<EOM ;
  1414. MODULE = fred PACKAGE = fred
  1415.  
  1416. int
  1417. fred(a)
  1418.         int     a;
  1419. EOM
  1420.  
  1421.     close F ;
  1422.  
  1423.     $command = "$self->{PERL} $xsubpp $file 2>&1";
  1424.     print "Running $command\n" if $Verbose >= 2;
  1425.     my $text = `$command` ;
  1426.     warn "Running '$command' exits with status " . ($?>>8) if $?;
  1427.     unlink $file ;
  1428.  
  1429.     # gets 1.2 -> 1.92 and 2.000a1
  1430.     return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/  ;
  1431.  
  1432.     # it is either 1.0 or 1.1
  1433.     return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
  1434.  
  1435.     # none of the above, so 1.0
  1436.     return "1.0" ;
  1437. }
  1438.  
  1439. =item tools_other
  1440.  
  1441.  
  1442.  
  1443. =cut
  1444.  
  1445. sub tools_other {
  1446.     my($self) = shift;
  1447.     unless (ref $self){
  1448.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1449.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1450.     }
  1451.     "
  1452. SHELL = /bin/sh
  1453. LD = $self->{LD}
  1454. TOUCH = $self->{TOUCH}
  1455. CP = $self->{CP}
  1456. MV = $self->{MV}
  1457. RM_F  = $self->{RM_F}
  1458. RM_RF = $self->{RM_RF}
  1459. CHMOD = $self->{CHMOD}
  1460. UMASK_NULL = $self->{UMASK_NULL}
  1461. ".q{
  1462. # The following is a portable way to say mkdir -p
  1463. # To see which directories are created, change the if 0 to if 1
  1464. MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){' \\
  1465. -e 'next if -d $$p; my(@p); foreach(split(/\//,$$p)){' \\
  1466. -e 'push(@p,$$_); next if -d "@p/"; print "mkdir @p" if 0;' \\
  1467. -e 'mkdir("@p",0777)||die $$! } } exit 0;'
  1468.  
  1469. # This helps us to minimize the effect of the .exists files A yet
  1470. # better solution would be to have a stable file in the perl
  1471. # distribution with a timestamp of zero. But this solution doesn't
  1472. # need any changes to the core distribution and works with older perls
  1473. EQUALIZE_TIMESTAMP = $(PERL) -we 'open F, ">$$ARGV[1]"; close F;' \\
  1474. -e 'utime ((stat("$$ARGV[0]"))[8,9], $$ARGV[1])'
  1475.  
  1476. # Here we warn users that an old packlist file was found somewhere,
  1477. # and that they should call some uninstall routine
  1478. WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \\
  1479. -e 'print "WARNING: I have found an old package in\n";' \\
  1480. -e 'print "\t$$ARGV[0].\n";' \\
  1481. -e 'print "Please make sure the two installations are not conflicting\n";'
  1482.  
  1483. MOD_INSTALL = $(PERL) -I$(INST_LIB) -MExtUtils::Install \
  1484. -e 'install({@ARGV},1);'
  1485.  
  1486. DOC_INSTALL = $(PERL) -e '$$\="\n\n";print "=head3 ", scalar(localtime), ": C<", shift, ">";' \
  1487. -e 'print "=over 4";' \
  1488. -e 'while ($$key = shift and $$val = shift){print "=item *";print "C<$$key: $$val>";}' \
  1489. -e 'print "=back";'
  1490.  
  1491. UNINSTALL =   $(PERL) -MExtUtils::Install \
  1492. -e 'uninstall($$ARGV[0],1);'
  1493.  
  1494. };
  1495. }
  1496.  
  1497. =item dist
  1498.  
  1499.  
  1500.  
  1501. =cut
  1502.  
  1503. sub dist {
  1504.     my($self, %attribs) = @_;
  1505.     unless (ref $self){
  1506.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1507.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1508.     }
  1509.     my(@m);
  1510.     # VERSION should be sanitised before use as a file name
  1511.     my($name)     = $attribs{NAME}     || '$(DISTVNAME)';
  1512.     my($tar)      = $attribs{TAR}      || 'tar';        # eg /usr/bin/gnutar
  1513.     my($tarflags) = $attribs{TARFLAGS} || 'cvf';
  1514.     my($compress) = $attribs{COMPRESS} || 'compress';   # eg gzip
  1515.     my($suffix)   = $attribs{SUFFIX}   || 'Z';          # eg gz
  1516.     my($shar)     = $attribs{SHAR}     || 'shar';       # eg "shar --gzip"
  1517.     my($preop)    = $attribs{PREOP}    || "$self->{NOECHO}true"; # eg update MANIFEST
  1518.     my($postop)   = $attribs{POSTOP}   || "$self->{NOECHO}true"; # eg remove the distdir
  1519.     my($ci)       = $attribs{CI}       || 'ci -u';
  1520.     my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q';
  1521.     my($dist_cp)  = $attribs{DIST_CP}  || 'best';
  1522.     my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
  1523.  
  1524.     push @m, "
  1525. DISTVNAME = \$(DISTNAME)-\$(VERSION)
  1526. TAR  = $tar
  1527. TARFLAGS = $tarflags
  1528. COMPRESS = $compress
  1529. SUFFIX = $suffix
  1530. SHAR = $shar
  1531. PREOP = $preop
  1532. POSTOP = $postop
  1533. CI = $ci
  1534. RCS_LABEL = $rcs_label
  1535. DIST_CP = $dist_cp
  1536. DIST_DEFAULT = $dist_default
  1537. ";
  1538.     join "", @m;
  1539. }
  1540.  
  1541. =item macro
  1542.  
  1543.  
  1544.  
  1545. =cut
  1546.  
  1547. sub macro {
  1548.     my($self,%attribs) = @_;
  1549.     unless (ref $self){
  1550.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1551.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1552.     }
  1553.     my(@m,$key,$val);
  1554.     while (($key,$val) = each %attribs){
  1555.     push @m, "$key = $val\n";
  1556.     }
  1557.     join "", @m;
  1558. }
  1559.  
  1560. =item depend
  1561.  
  1562.  
  1563.  
  1564. =cut
  1565.  
  1566. sub depend {
  1567.     my($self,%attribs) = @_;
  1568.     unless (ref $self){
  1569.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1570.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1571.     }
  1572.     my(@m,$key,$val);
  1573.     while (($key,$val) = each %attribs){
  1574.     push @m, "$key: $val\n";
  1575.     }
  1576.     join "", @m;
  1577. }
  1578.  
  1579. =item post_constants
  1580.  
  1581.  
  1582.  
  1583. =cut
  1584.  
  1585. sub post_constants{
  1586.     my($self) = shift;
  1587.     unless (ref $self){
  1588.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1589.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1590.     }
  1591.     "";
  1592. }
  1593.  
  1594. =item pasthru
  1595.  
  1596.  
  1597.  
  1598. =cut
  1599.  
  1600. sub pasthru {
  1601.     my($self) = shift;
  1602.     unless (ref $self){
  1603.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1604.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1605.     }
  1606.     my(@m,$key);
  1607.  
  1608.     my(@pasthru);
  1609.  
  1610.     foreach $key (qw(INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN
  1611.              INSTALLMAN1DIR INSTALLMAN3DIR LIBPERL_A
  1612.              LINKTYPE PREFIX INSTALLSITELIB
  1613.              INSTALLSITEARCH INSTALLDIRS)){
  1614.     push @pasthru, "$key=\"\$($key)\"";
  1615.     }
  1616.  
  1617.     push @m, "\nPASTHRU = ", join ("\\\n\t", @pasthru), "\n";
  1618.     join "", @m;
  1619. }
  1620.  
  1621. =item c_o
  1622.  
  1623.  
  1624.  
  1625. =cut
  1626.  
  1627. sub c_o {
  1628. # --- Translation Sections ---
  1629.  
  1630.     my($self) = shift;
  1631.     unless (ref $self){
  1632.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1633.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1634.     }
  1635.     return '' unless $self->needs_linking();
  1636.     my(@m);
  1637.     push @m, '
  1638. .c$(OBJ_EXT):
  1639.     $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
  1640.  
  1641. .C$(OBJ_EXT):
  1642.     $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
  1643.  
  1644. .cpp$(OBJ_EXT):
  1645.     $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cpp
  1646.  
  1647. .cxx$(OBJ_EXT):
  1648.     $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cxx
  1649.  
  1650. .cc$(OBJ_EXT):
  1651.     $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cc
  1652. ';
  1653.     join "", @m;
  1654. }
  1655.  
  1656. =item xs_c
  1657.  
  1658.  
  1659.  
  1660. =cut
  1661.  
  1662. sub xs_c {
  1663.     my($self) = shift;
  1664.     unless (ref $self){
  1665.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1666.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1667.     }
  1668.     return '' unless $self->needs_linking();
  1669.     '
  1670. .xs.c:
  1671.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
  1672. ';
  1673. }
  1674.  
  1675. =item xs_o
  1676.  
  1677.  
  1678.  
  1679. =cut
  1680.  
  1681. sub xs_o {    # many makes are too dumb to use xs_c then c_o
  1682.     my($self) = shift;
  1683.     unless (ref $self){
  1684.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1685.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1686.     }
  1687.     return '' unless $self->needs_linking();
  1688.     '
  1689. .xs$(OBJ_EXT):
  1690.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
  1691.     $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
  1692. ';
  1693. }
  1694.  
  1695. =item top_targets
  1696.  
  1697.  
  1698.  
  1699. =cut
  1700.  
  1701. sub top_targets {
  1702. # --- Target Sections ---
  1703.  
  1704.     my($self) = shift;
  1705.     unless (ref $self){
  1706.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1707.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1708.     }
  1709.     my(@m);
  1710.     push @m, '
  1711. all ::    config $(INST_PM) subdirs linkext manifypods
  1712.  
  1713. subdirs :: $(MYEXTLIB)
  1714.  
  1715. '.$self->{NOOP}.'
  1716.  
  1717. config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists
  1718.  
  1719. config :: $(INST_ARCHAUTODIR)/.exists
  1720.  
  1721. config :: $(INST_AUTODIR)/.exists
  1722. ';
  1723.  
  1724.     push @m, q{
  1725. config :: Version_check
  1726.  
  1727. } unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl");
  1728.  
  1729.     push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
  1730.  
  1731.     if (%{$self->{MAN1PODS}}) {
  1732.     push @m, q[
  1733. config :: $(INST_MAN1DIR)/.exists
  1734.  
  1735. ];
  1736.     push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
  1737.     }
  1738.     if (%{$self->{MAN3PODS}}) {
  1739.     push @m, q[
  1740. config :: $(INST_MAN3DIR)/.exists
  1741.  
  1742. ];
  1743.     push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
  1744.     }
  1745.  
  1746.     push @m, '
  1747. $(O_FILES): $(H_FILES)
  1748. ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
  1749.  
  1750.     push @m, q{
  1751. help:
  1752.     perldoc ExtUtils::MakeMaker
  1753. };
  1754.  
  1755.     push @m, q{
  1756. Version_check:
  1757.     }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
  1758.         -MExtUtils::MakeMaker=Version_check \
  1759.         -e 'Version_check("$(MM_VERSION)")'
  1760. };
  1761.  
  1762.     join('',@m);
  1763. }
  1764.  
  1765. =item linkext
  1766.  
  1767.  
  1768.  
  1769. =cut
  1770.  
  1771. sub linkext {
  1772.     my($self, %attribs) = @_;
  1773.     unless (ref $self){
  1774.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1775.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1776.     }
  1777.     # LINKTYPE => static or dynamic or ''
  1778.     my($linktype) = defined $attribs{LINKTYPE} ?
  1779.       $attribs{LINKTYPE} : '$(LINKTYPE)';
  1780.     "
  1781. linkext :: $linktype
  1782. $self->{NOOP}
  1783. ";
  1784. }
  1785.  
  1786. =item dlsyms
  1787.  
  1788.  
  1789.  
  1790. =cut
  1791.  
  1792. sub dlsyms {
  1793.     my($self,%attribs) = @_;
  1794.     unless (ref $self){
  1795.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1796.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1797.     }
  1798.  
  1799.     return '' unless ($Config::Config{osname} eq 'aix' && $self->needs_linking() );
  1800.  
  1801.     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
  1802.     my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
  1803.     my(@m);
  1804.  
  1805.     push(@m,"
  1806. dynamic :: $self->{BASEEXT}.exp
  1807.  
  1808. ") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
  1809.  
  1810.     push(@m,"
  1811. static :: $self->{BASEEXT}.exp
  1812.  
  1813. ") unless $self->{SKIPHASH}{'static'};  # we avoid a warning if we tick them
  1814.  
  1815.     push(@m,"
  1816. $self->{BASEEXT}.exp: Makefile.PL
  1817. ",'    $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
  1818.     Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
  1819.     neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
  1820. ');
  1821.  
  1822.     join('',@m);
  1823. }
  1824.  
  1825. =item dynamic
  1826.  
  1827.  
  1828.  
  1829. =cut
  1830.  
  1831. sub dynamic {
  1832. # --- Dynamic Loading Sections ---
  1833.  
  1834.     my($self) = shift;
  1835.     unless (ref $self){
  1836.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1837.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1838.     }
  1839.     '
  1840. # $(INST_PM) has been moved to the all: target.
  1841. # It remains here for awhile to allow for old usage: "make dynamic"
  1842. dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
  1843. '.$self->{NOOP}.'
  1844. ';
  1845. }
  1846.  
  1847. =item dynamic_bs
  1848.  
  1849.  
  1850.  
  1851. =cut
  1852.  
  1853. sub dynamic_bs {
  1854.     my($self, %attribs) = @_;
  1855.     unless (ref $self){
  1856.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1857.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1858.     }
  1859.     return '
  1860. BOOTSTRAP =
  1861. ' unless $self->has_link_code();
  1862.  
  1863.     return '
  1864. BOOTSTRAP = '."$self->{BASEEXT}.bs".'
  1865.  
  1866. # As Mkbootstrap might not write a file (if none is required)
  1867. # we use touch to prevent make continually trying to remake it.
  1868. # The DynaLoader only reads a non-empty file.
  1869. $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists
  1870.     '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
  1871.     '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
  1872.         -e \'use ExtUtils::Mkbootstrap;\' \
  1873.         -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\'
  1874.     '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
  1875.     $(CHMOD) 644 $@
  1876.  
  1877. $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
  1878.     '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
  1879.     -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
  1880.     $(CHMOD) 644 $@
  1881. ';
  1882. }
  1883.  
  1884. =item dynamic_lib
  1885.  
  1886.  
  1887.  
  1888. =cut
  1889.  
  1890. sub dynamic_lib {
  1891.     my($self, %attribs) = @_;
  1892.     unless (ref $self){
  1893.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1894.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1895.     }
  1896.     return '' unless $self->needs_linking(); #might be because of a subdir
  1897.  
  1898.     return '' unless $self->has_link_code;
  1899.  
  1900.     my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
  1901.     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
  1902.     my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
  1903.     my($ldfrom) = '$(LDFROM)';
  1904.     my($osname) = $Config::Config{osname};
  1905.     $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':');
  1906.     my(@m);
  1907.     push(@m,'
  1908. # This section creates the dynamically loadable $(INST_DYNAMIC)
  1909. # from $(OBJECT) and possibly $(MYEXTLIB).
  1910. ARMAYBE = '.$armaybe.'
  1911. OTHERLDFLAGS = '.$otherldflags.'
  1912. INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
  1913.  
  1914. $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
  1915. ');
  1916.     if ($armaybe ne ':'){
  1917.     $ldfrom = 'tmp$(LIB_EXT)';
  1918.     push(@m,'    $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
  1919.     push(@m,'    $(RANLIB) '."$ldfrom\n");
  1920.     }
  1921.     $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf');
  1922.     push(@m,'    LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
  1923.         ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS) $(EXPORT_LIST) $(PERL_ARCHIVE)');
  1924.     push @m, '
  1925.     $(CHMOD) 755 $@
  1926. ';
  1927.  
  1928.     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  1929.     join('',@m);
  1930. }
  1931.  
  1932. =item static
  1933.  
  1934.  
  1935.  
  1936. =cut
  1937.  
  1938. sub static {
  1939. # --- Static Loading Sections ---
  1940.  
  1941.     my($self) = shift;
  1942.     unless (ref $self){
  1943.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1944.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1945.     }
  1946.     '
  1947. # $(INST_PM) has been moved to the all: target.
  1948. # It remains here for awhile to allow for old usage: "make static"
  1949. static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
  1950. '.$self->{NOOP}.'
  1951. ';
  1952. }
  1953.  
  1954. =item static_lib
  1955.  
  1956.  
  1957.  
  1958. =cut
  1959.  
  1960. sub static_lib {
  1961.     my($self) = @_;
  1962.     unless (ref $self){
  1963.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  1964.     $self = $ExtUtils::MakeMaker::Parent[-1];
  1965.     }
  1966. # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
  1967. #    return '' unless $self->needs_linking(); #might be because of a subdir
  1968.  
  1969.     return '' unless $self->has_link_code;
  1970.  
  1971.     my(@m);
  1972.     push(@m, <<'END');
  1973. $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
  1974. END
  1975.     # If this extension has it's own library (eg SDBM_File)
  1976.     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
  1977.     push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
  1978.  
  1979.     push @m,
  1980. q{    $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
  1981.     }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
  1982.     $(CHMOD) 755 $@
  1983. };
  1984.  
  1985. # Old mechanism - still available:
  1986.  
  1987.     push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs}."\n\n"
  1988.     if $self->{PERL_SRC};
  1989.  
  1990.     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  1991.     join('', "\n",@m);
  1992. }
  1993.  
  1994. =item installpm
  1995.  
  1996.  
  1997.  
  1998. =cut
  1999.  
  2000. sub installpm {
  2001.     my($self, %attribs) = @_;
  2002.     unless (ref $self){
  2003.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2004.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2005.     }
  2006.     # By default .pm files are split into the architecture independent
  2007.     # library. This is a good thing. If a specific module requires that
  2008.     # it's .pm files are split into the architecture specific library
  2009.     # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
  2010.     # Note that installperl currently interferes with this (Config.pm)
  2011.     # User can disable split by saying: installpm => {SPLITLIB=>''}
  2012.     my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
  2013.     $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
  2014.     my(@m, $dist);
  2015.     push @m, "inst_pm :: \$(INST_PM)\n\n";
  2016.     foreach $dist (sort keys %{$self->{PM}}){
  2017.     my($inst) = $self->{PM}->{$dist};
  2018.     push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
  2019.     push(@m, $self->installpm_x($dist, $inst, $splitlib));
  2020.     push(@m, "\n");
  2021.     }
  2022.     join('', @m);
  2023. }
  2024.  
  2025. =item installpm_x
  2026.  
  2027.  
  2028.  
  2029. =cut
  2030.  
  2031. sub installpm_x { # called by installpm per file
  2032.     my($self, $dist, $inst, $splitlib) = @_;
  2033.     unless (ref $self){
  2034.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2035.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2036.     }
  2037.     if ($inst =~ m,[:\#],){
  2038.     warn "Warning: 'make' would have problems processing this file: '$inst', SKIPPED\n";
  2039.     return '';
  2040.     }
  2041.     my($instdir) = $inst =~ m|(.*)/|;
  2042.     my(@m);
  2043.     push(@m,"
  2044. $inst: $dist $self->{MAKEFILE} $instdir/.exists \$(INST_ARCHAUTODIR)/.exists
  2045.     $self->{NOECHO}$self->{RM_F}".' $@
  2046.     $(UMASK_NULL) && '."$self->{CP} $dist".' $@
  2047. ');
  2048.     push(@m, "\t$self->{NOECHO}\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
  2049.     if ($splitlib and $inst =~ m/\.pm$/);
  2050.  
  2051.     push @m, $self->dir_target($instdir);
  2052.     join('', @m);
  2053. }
  2054.  
  2055. =item manifypods
  2056.  
  2057.  
  2058.  
  2059. =cut
  2060.  
  2061. sub manifypods {
  2062.     my($self, %attribs) = @_;
  2063.     unless (ref $self){
  2064.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2065.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2066.     }
  2067.     return "\nmanifypods :\n" unless %{$self->{MAN3PODS}};
  2068.     my($dist);
  2069.     my($pod2man_exe);
  2070.     if (defined $self->{PERL_SRC}) {
  2071.     $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
  2072.     } else {
  2073.     $pod2man_exe = $self->catfile($Config{bin},'pod2man');
  2074.     }
  2075.     unless ($self->perl_script($pod2man_exe)) {
  2076.     # No pod2man but some MAN3PODS to be installed
  2077.     print <<END;
  2078.  
  2079. Warning: I could not locate your pod2man program. Please make sure,
  2080.          your pod2man program is in your PATH before you execute 'make'
  2081.  
  2082. END
  2083.         $pod2man_exe = "-S pod2man";
  2084.     }
  2085.     my(@m);
  2086.     push @m,
  2087. qq[POD2MAN_EXE = $pod2man_exe\n],
  2088. q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\
  2089. -e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\
  2090. -e 'print "Manifying $$m{$$_}\n";' \\
  2091. -e 'system("$$^X \\"-I$(PERL_ARCHLIB)\\" \\"-I$(PERL_LIB)\\" $(POD2MAN_EXE) $$_>$$m{$$_}")==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
  2092. -e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}'
  2093. ];
  2094.     push @m, "\nmanifypods : ";
  2095.     push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
  2096.  
  2097.     push(@m,"\n");
  2098.     if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
  2099.     push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
  2100.     push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
  2101.     }
  2102.     join('', @m);
  2103. }
  2104.  
  2105. =item processPL
  2106.  
  2107.  
  2108.  
  2109. =cut
  2110.  
  2111. sub processPL {
  2112.     my($self) = shift;
  2113.     unless (ref $self){
  2114.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2115.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2116.     }
  2117.     return "" unless $self->{PL_FILES};
  2118.     my(@m, $plfile);
  2119.     foreach $plfile (sort keys %{$self->{PL_FILES}}) {
  2120.     push @m, "
  2121. all :: $self->{PL_FILES}->{$plfile}
  2122.  
  2123. $self->{PL_FILES}->{$plfile} :: $plfile
  2124.     \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
  2125. ";
  2126.     }
  2127.     join "", @m;
  2128. }
  2129.  
  2130. =item installbin
  2131.  
  2132.  
  2133.  
  2134. =cut
  2135.  
  2136. sub installbin {
  2137.     my($self) = shift;
  2138.     return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
  2139.     return "" unless @{$self->{EXE_FILES}};
  2140.     my(@m, $from, $to, %fromto, @to);
  2141.     push @m, $self->dir_target(qw[$(INST_EXE)]);
  2142.     for $from (@{$self->{EXE_FILES}}) {
  2143.     my($path)= '$(INST_EXE)/' . basename($from);
  2144.     local($_) = $path; # for backwards compatibility
  2145.     $to = $self->libscan($path);
  2146.     print "libscan($from) => '$to'\n" if ($Verbose >=2);
  2147.     $fromto{$from}=$to;
  2148.     }
  2149.     @to   = values %fromto;
  2150.     push(@m, "
  2151. EXE_FILES = @{$self->{EXE_FILES}}
  2152.  
  2153. all :: @to
  2154.  
  2155. realclean ::
  2156.     $self->{RM_F} @to
  2157. ");
  2158.  
  2159.     while (($from,$to) = each %fromto) {
  2160.     my $todir = dirname($to);
  2161.     push @m, "
  2162. $to: $from $self->{MAKEFILE} $todir/.exists
  2163.     $self->{CP} $from $to
  2164. ";
  2165.     }
  2166.     join "", @m;
  2167. }
  2168.  
  2169. =item subdirs
  2170.  
  2171.  
  2172.  
  2173. =cut
  2174.  
  2175. sub subdirs {
  2176. # --- Sub-directory Sections ---
  2177.     my($self) = shift;
  2178.     unless (ref $self){
  2179.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2180.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2181.     }
  2182.     my(@m,$dir);
  2183.     # This method provides a mechanism to automatically deal with
  2184.     # subdirectories containing further Makefile.PL scripts.
  2185.     # It calls the subdir_x() method for each subdirectory.
  2186.     foreach $dir (@{$self->{DIR}}){
  2187.     push(@m, $self->subdir_x($dir));
  2188. ####    print "Including $dir subdirectory\n";
  2189.     }
  2190.     if (@m){
  2191.     unshift(@m, "
  2192. # The default clean, realclean and test targets in this Makefile
  2193. # have automatically been given entries for each subdir.
  2194.  
  2195. ");
  2196.     } else {
  2197.     push(@m, "\n# none")
  2198.     }
  2199.     join('',@m);
  2200. }
  2201.  
  2202. =item subdir_x
  2203.  
  2204.  
  2205.  
  2206. =cut
  2207.  
  2208. sub subdir_x {
  2209.     my($self, $subdir) = @_;
  2210.     unless (ref $self){
  2211.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2212.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2213.     }
  2214.     my(@m);
  2215.     qq{
  2216.  
  2217. subdirs ::
  2218.     $self->{NOECHO}-cd $subdir && \$(MAKE) all \$(PASTHRU)
  2219.  
  2220. };
  2221. }
  2222.  
  2223. =item clean
  2224.  
  2225.  
  2226.  
  2227. =cut
  2228.  
  2229. sub clean {
  2230. # --- Cleanup and Distribution Sections ---
  2231.  
  2232.     my($self, %attribs) = @_;
  2233.     unless (ref $self){
  2234.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2235.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2236.     }
  2237.     my(@m,$dir);
  2238.     push(@m, '
  2239. # Delete temporary files but do not touch installed files. We don\'t delete
  2240. # the Makefile here so a later make realclean still has a makefile to use.
  2241.  
  2242. clean ::
  2243. ');
  2244.     # clean subdirectories first
  2245.     for $dir (@{$self->{DIR}}) {
  2246.     push @m, "\t-cd $dir && test -f $self->{MAKEFILE} && \$(MAKE) clean\n";
  2247.     }
  2248.  
  2249.     my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
  2250.     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
  2251.     push(@otherfiles, qw[./../.. $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all
  2252.              perlmain.c mon.out core so_locations
  2253.              *~ */*~ */*/*~
  2254.              *$(OBJ_EXT) *$(LIB_EXT)
  2255.              perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp
  2256.             ]);
  2257.     push @m, "\t-$self->{RM_RF} @otherfiles\n";
  2258.     # See realclean and ext/utils/make_ext for usage of Makefile.old
  2259.     push(@m,
  2260.      "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old 2>/dev/null\n");
  2261.     push(@m,
  2262.      "\t$attribs{POSTOP}\n")   if $attribs{POSTOP};
  2263.     join("", @m);
  2264. }
  2265.  
  2266. =item realclean
  2267.  
  2268.  
  2269.  
  2270. =cut
  2271.  
  2272. sub realclean {
  2273.     my($self, %attribs) = @_;
  2274.     unless (ref $self){
  2275.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2276.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2277.     }
  2278.     my(@m);
  2279.     push(@m,'
  2280. # Delete temporary files (via clean) and also delete installed files
  2281. realclean purge ::  clean
  2282. ');
  2283.     # realclean subdirectories first (already cleaned)
  2284.     my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
  2285.     foreach(@{$self->{DIR}}){
  2286.     push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
  2287.     push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
  2288.     }
  2289.     push(@m, "    $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
  2290.     push(@m, "    $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
  2291.     push(@m, "    $self->{RM_F} \$(INST_STATIC) \$(INST_PM)\n");
  2292.     my(@otherfiles) = ($self->{MAKEFILE},
  2293.                "$self->{MAKEFILE}.old"); # Makefiles last
  2294.     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
  2295.     push(@m, "    $self->{RM_RF} @otherfiles\n") if @otherfiles;
  2296.     push(@m, "    $attribs{POSTOP}\n")       if $attribs{POSTOP};
  2297.     join("", @m);
  2298. }
  2299.  
  2300. =item dist_basics
  2301.  
  2302.  
  2303.  
  2304. =cut
  2305.  
  2306. sub dist_basics {
  2307.     my($self) = shift;
  2308.     unless (ref $self){
  2309.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2310.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2311.     }
  2312.     my @m;
  2313.     push @m, q{
  2314. distclean :: realclean distcheck
  2315. };
  2316.  
  2317.     push @m, q{
  2318. distcheck :
  2319.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\
  2320.         -e 'fullcheck();'
  2321. };
  2322.  
  2323.     push @m, q{
  2324. skipcheck :
  2325.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&skipcheck";' \\
  2326.         -e 'skipcheck();'
  2327. };
  2328.  
  2329.     push @m, q{
  2330. manifest :
  2331.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\
  2332.         -e 'mkmanifest();'
  2333. };
  2334.     join "", @m;
  2335. }
  2336.  
  2337. =item dist_core
  2338.  
  2339.  
  2340.  
  2341. =cut
  2342.  
  2343. sub dist_core {
  2344.     my($self) = shift;
  2345.     unless (ref $self){
  2346.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2347.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2348.     }
  2349.     my @m;
  2350.     push @m, q{
  2351. dist : $(DIST_DEFAULT)
  2352.  
  2353. tardist : $(DISTVNAME).tar.$(SUFFIX)
  2354.  
  2355. $(DISTVNAME).tar.$(SUFFIX) : distdir
  2356.     $(PREOP)
  2357.     $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
  2358.     $(RM_RF) $(DISTVNAME)
  2359.     $(COMPRESS) $(DISTVNAME).tar
  2360.     $(POSTOP)
  2361.  
  2362. uutardist : $(DISTVNAME).tar.$(SUFFIX)
  2363.     uuencode $(DISTVNAME).tar.$(SUFFIX) \\
  2364.         $(DISTVNAME).tar.$(SUFFIX) > \\
  2365.         $(DISTVNAME).tar.$(SUFFIX).uu
  2366.  
  2367. shdist : distdir
  2368.     $(PREOP)
  2369.     $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
  2370.     $(RM_RF) $(DISTVNAME)
  2371.     $(POSTOP)
  2372. };
  2373.     join "", @m;
  2374. }
  2375.  
  2376. =item dist_dir
  2377.  
  2378.  
  2379.  
  2380. =cut
  2381.  
  2382. sub dist_dir {
  2383.     my($self) = shift;
  2384.     unless (ref $self){
  2385.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2386.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2387.     }
  2388.     my @m;
  2389.     push @m, q{
  2390. distdir :
  2391.     $(RM_RF) $(DISTVNAME)
  2392.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "/mani/";' \\
  2393.         -e 'manicopy(maniread(),"$(DISTVNAME)", "$(DIST_CP)");'
  2394. };
  2395.     join "", @m;
  2396. }
  2397.  
  2398. =item dist_test
  2399.  
  2400.  
  2401.  
  2402. =cut
  2403.  
  2404. sub dist_test {
  2405.     my($self) = shift;
  2406.     unless (ref $self){
  2407.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2408.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2409.     }
  2410.     my @m;
  2411.     push @m, q{
  2412. disttest : distdir
  2413.     cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
  2414.     cd $(DISTVNAME) && $(MAKE)
  2415.     cd $(DISTVNAME) && $(MAKE) test
  2416. };
  2417.     join "", @m;
  2418. }
  2419.  
  2420. =item dist_ci
  2421.  
  2422.  
  2423.  
  2424. =cut
  2425.  
  2426. sub dist_ci {
  2427.     my($self) = shift;
  2428.     unless (ref $self){
  2429.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2430.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2431.     }
  2432.     my @m;
  2433.     push @m, q{
  2434. ci :
  2435.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\
  2436.         -e '@all = keys %{ maniread() };' \\
  2437.         -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
  2438.         -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
  2439. };
  2440.     join "", @m;
  2441. }
  2442.  
  2443. =item install
  2444.  
  2445.  
  2446.  
  2447. =cut
  2448.  
  2449. sub install {
  2450.     my($self, %attribs) = @_;
  2451.     unless (ref $self){
  2452.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2453.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2454.     }
  2455.     my(@m);
  2456.  
  2457.     push @m, q{
  2458. install :: all pure_install doc_install
  2459.  
  2460. install_perl :: all pure_perl_install doc_perl_install
  2461.  
  2462. install_site :: all pure_site_install doc_site_install
  2463.  
  2464. install_ :: install_site
  2465.     @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
  2466.  
  2467. pure_install :: pure_$(INSTALLDIRS)_install
  2468.  
  2469. doc_install :: doc_$(INSTALLDIRS)_install
  2470.     }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
  2471.  
  2472. pure__install : pure_site_install
  2473.     @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
  2474.  
  2475. doc__install : doc_site_install
  2476.     @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
  2477.  
  2478. pure_perl_install ::
  2479.     }.$self->{NOECHO}.q{$(MOD_INSTALL) \
  2480.         read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
  2481.         write }.$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
  2482.         $(INST_LIB) $(INSTALLPRIVLIB) \
  2483.         $(INST_ARCHLIB) $(INSTALLARCHLIB) \
  2484.         $(INST_EXE) $(INSTALLBIN) \
  2485.         $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
  2486.         $(INST_MAN3DIR) $(INSTALLMAN3DIR)
  2487.     }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
  2488.         }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
  2489.  
  2490.  
  2491. pure_site_install ::
  2492.     }.$self->{NOECHO}.q{$(MOD_INSTALL) \
  2493.         read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
  2494.         write }.$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
  2495.         $(INST_LIB) $(INSTALLSITELIB) \
  2496.         $(INST_ARCHLIB) $(INSTALLSITEARCH) \
  2497.         $(INST_EXE) $(INSTALLBIN) \
  2498.         $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
  2499.         $(INST_MAN3DIR) $(INSTALLMAN3DIR)
  2500.     }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
  2501.         }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
  2502.  
  2503. doc_perl_install ::
  2504.     }.$self->{NOECHO}.q{$(DOC_INSTALL) \
  2505.         "$(NAME)" \
  2506.         "installed into" "$(INSTALLPRIVLIB)" \
  2507.         LINKTYPE "$(LINKTYPE)" \
  2508.         VERSION "$(VERSION)" \
  2509.         EXE_FILES "$(EXE_FILES)" \
  2510.         >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
  2511.  
  2512. doc_site_install ::
  2513.     }.$self->{NOECHO}.q{$(DOC_INSTALL) \
  2514.         "Module $(NAME)" \
  2515.         "installed into" "$(INSTALLSITELIB)" \
  2516.         LINKTYPE "$(LINKTYPE)" \
  2517.         VERSION "$(VERSION)" \
  2518.         EXE_FILES "$(EXE_FILES)" \
  2519.         >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
  2520.  
  2521. };
  2522.  
  2523.     push @m, q{
  2524. uninstall :: uninstall_from_$(INSTALLDIRS)dirs
  2525.  
  2526. uninstall_from_perldirs ::
  2527.     }.$self->{NOECHO}.
  2528.     q{$(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
  2529.  
  2530. uninstall_from_sitedirs ::
  2531.     }.$self->{NOECHO}.
  2532.     q{$(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
  2533. };
  2534.  
  2535.     join("",@m);
  2536. }
  2537.  
  2538. =item force
  2539.  
  2540.  
  2541.  
  2542. =cut
  2543.  
  2544. sub force {
  2545.     my($self) = shift;
  2546.     unless (ref $self){
  2547.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2548.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2549.     }
  2550.     '# Phony target to force checking subdirectories.
  2551. FORCE:
  2552. ';
  2553. }
  2554.  
  2555. =item perldepend
  2556.  
  2557.  
  2558.  
  2559. =cut
  2560.  
  2561. sub perldepend {
  2562.     my($self) = shift;
  2563.     unless (ref $self){
  2564.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2565.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2566.     }
  2567.     my(@m);
  2568.     push(@m,'
  2569. PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
  2570.     $(PERL_INC)/XSUB.h    $(PERL_INC)/av.h    $(PERL_INC)/cop.h \
  2571.     $(PERL_INC)/cv.h    $(PERL_INC)/dosish.h    $(PERL_INC)/embed.h \
  2572.     $(PERL_INC)/form.h    $(PERL_INC)/gv.h    $(PERL_INC)/handy.h \
  2573.     $(PERL_INC)/hv.h    $(PERL_INC)/keywords.h    $(PERL_INC)/mg.h \
  2574.     $(PERL_INC)/op.h    $(PERL_INC)/opcode.h    $(PERL_INC)/patchlevel.h \
  2575.     $(PERL_INC)/perl.h    $(PERL_INC)/perly.h    $(PERL_INC)/pp.h \
  2576.     $(PERL_INC)/proto.h    $(PERL_INC)/regcomp.h    $(PERL_INC)/regexp.h \
  2577.     $(PERL_INC)/scope.h    $(PERL_INC)/sv.h    $(PERL_INC)/unixish.h \
  2578.     $(PERL_INC)/util.h    $(PERL_INC)/config.h
  2579.  
  2580. ');
  2581.  
  2582.     push @m, '
  2583. $(OBJECT) : $(PERL_HDRS)
  2584. ' if $self->{OBJECT};
  2585.  
  2586.     push(@m,'
  2587. # Check for unpropogated config.sh changes. Should never happen.
  2588. # We do NOT just update config.h because that is not sufficient.
  2589. # An out of date config.h is not fatal but complains loudly!
  2590. $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
  2591.     -'.$self->{NOECHO}.'echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
  2592.  
  2593. $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
  2594.     '.$self->{NOECHO}.'echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
  2595.     cd $(PERL_SRC) && $(MAKE) lib/Config.pm
  2596. ') if $self->{PERL_SRC};
  2597.  
  2598.     push(@m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n")
  2599.     if %{$self->{XS}};
  2600.     join("\n",@m);
  2601. }
  2602.  
  2603. =item makefile
  2604.  
  2605.  
  2606.  
  2607. =cut
  2608.  
  2609. sub makefile {
  2610.     my($self) = shift;
  2611.     unless (ref $self){
  2612.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2613.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2614.     }
  2615.     my @m;
  2616.     # We do not know what target was originally specified so we
  2617.     # must force a manual rerun to be sure. But as it should only
  2618.     # happen very rarely it is not a significant problem.
  2619.     push @m, '
  2620. $(OBJECT) : $(FIRST_MAKEFILE)
  2621. ' if $self->{OBJECT};
  2622.  
  2623.     push @m, '
  2624. # We take a very conservative approach here, but it\'s worth it.
  2625. # We move Makefile to Makefile.old here to avoid gnu make looping.
  2626. '.$self->{MAKEFILE}.' :    Makefile.PL $(CONFIGDEP)
  2627.     '.$self->{NOECHO}.'echo "Makefile out-of-date with respect to $?"
  2628.     '.$self->{NOECHO}.'echo "Cleaning current config before rebuilding Makefile..."
  2629.     -'.$self->{NOECHO}.'mv '."$self->{MAKEFILE} $self->{MAKEFILE}.old".'
  2630.     -$(MAKE) -f '.$self->{MAKEFILE}.'.old clean >/dev/null 2>&1 || true
  2631.     $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL '.join(" ",map(qq["$_"],@ARGV)).'
  2632.     '.$self->{NOECHO}.'echo ">>> Your Makefile has been rebuilt. <<<"
  2633.     '.$self->{NOECHO}.'echo ">>> Please rerun the make command.  <<<"; false
  2634. ';
  2635.  
  2636.     join "", @m;
  2637. }
  2638.  
  2639. =item staticmake
  2640.  
  2641.  
  2642.  
  2643. =cut
  2644.  
  2645. sub staticmake {
  2646.     my($self, %attribs) = @_;
  2647.     unless (ref $self){
  2648.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2649.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2650.     }
  2651.     my(@static);
  2652.  
  2653.     my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP},  $self->{INST_ARCHLIB});
  2654.  
  2655.     # And as it's not yet built, we add the current extension
  2656.     # but only if it has some C code (or XS code, which implies C code)
  2657.     if (@{$self->{C}}) {
  2658.     @static="$self->{INST_ARCHLIB}/auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}";
  2659.     }
  2660.  
  2661.     # Either we determine now, which libraries we will produce in the
  2662.     # subdirectories or we do it at runtime of the make.
  2663.  
  2664.     # We could ask all subdir objects, but I cannot imagine, why it
  2665.     # would be necessary.
  2666.  
  2667.     # Instead we determine all libraries for the new perl at
  2668.     # runtime.
  2669.     my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
  2670.  
  2671.     $self->makeaperl(MAKE    => $self->{MAKEFILE},
  2672.              DIRS    => \@searchdirs,
  2673.              STAT    => \@static,
  2674.              INCL    => \@perlinc,
  2675.              TARGET    => $self->{MAP_TARGET},
  2676.              TMP    => "",
  2677.              LIBPERL    => $self->{LIBPERL_A}
  2678.             );
  2679. }
  2680.  
  2681. =item test
  2682.  
  2683.  
  2684.  
  2685. =cut
  2686.  
  2687. sub test {
  2688. # --- Test and Installation Sections ---
  2689.  
  2690.     my($self, %attribs) = @_;
  2691.     unless (ref $self){
  2692.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2693.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2694.     }
  2695.     my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
  2696.     my(@m);
  2697.     push(@m,"
  2698. TEST_VERBOSE=0
  2699. TEST_TYPE=test_\$(LINKTYPE)
  2700.  
  2701. test :: \$(TEST_TYPE)
  2702. ");
  2703.     push(@m, map("\t$self->{NOECHO}cd $_ && test -f $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
  2704.          @{$self->{DIR}}));
  2705.     push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n")
  2706.     unless $tests or -f "test.pl" or @{$self->{DIR}};
  2707.     push(@m, "\n");
  2708.  
  2709.     push(@m, "test_dynamic :: all\n");
  2710.     push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
  2711.     push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
  2712.     push(@m, "\n");
  2713.  
  2714.     # Occasionally we may face this degenerate target:
  2715.     push @m, "test_ : test_dynamic\n\n";
  2716.  
  2717.     if ($self->needs_linking()) {
  2718.     push(@m, "test_static :: all \$(MAP_TARGET)\n");
  2719.     push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
  2720.     push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
  2721.     push(@m, "\n");
  2722.     } else {
  2723.     push @m, "test_static :: test_dynamic\n";
  2724.     }
  2725.     join("", @m);
  2726. }
  2727.  
  2728. =item test_via_harness
  2729.  
  2730.  
  2731.  
  2732. =cut
  2733.  
  2734. sub test_via_harness {
  2735.     my($self, $perl, $tests) = @_;
  2736.     unless (ref $self){
  2737.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2738.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2739.     }
  2740.     "\tPERL_DL_NONLAZY=1 $perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
  2741. }
  2742.  
  2743. =item test_via_script
  2744.  
  2745.  
  2746.  
  2747. =cut
  2748.  
  2749. sub test_via_script {
  2750.     my($self, $perl, $script) = @_;
  2751.     unless (ref $self){
  2752.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2753.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2754.     }
  2755.     qq{\tPERL_DL_NONLAZY=1 $perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script
  2756. };
  2757. }
  2758.  
  2759. =item postamble
  2760.  
  2761. Returns an empty string. Can be used in Makefile.PLs to write some
  2762. text to the Makefile at the end.
  2763.  
  2764. =cut
  2765.  
  2766. sub postamble {
  2767.     my($self) = shift;
  2768.     unless (ref $self){
  2769.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2770.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2771.     }
  2772.     "";
  2773. }
  2774.  
  2775. =item makeaperl
  2776.  
  2777. Called by staticmake.
  2778.  
  2779. =cut
  2780.  
  2781. sub makeaperl {
  2782.     my($self, %attribs) = @_;
  2783.     unless (ref $self){
  2784.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2785.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2786.     }
  2787.     my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
  2788.     @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
  2789.     my(@m);
  2790.     push @m, "
  2791. # --- MakeMaker makeaperl section ---
  2792. MAP_TARGET    = $target
  2793. FULLPERL      = $self->{FULLPERL}
  2794. ";
  2795.     return join '', @m if $self->{PARENT};
  2796.  
  2797.     my($dir) = join ":", @{$self->{DIR}};
  2798.  
  2799.     unless ($self->{MAKEAPERL}) {
  2800.     push @m, q{
  2801. $(MAP_TARGET) :: $(MAKE_APERL_FILE)
  2802.     $(MAKE) -f $(MAKE_APERL_FILE) static $@
  2803.  
  2804. $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
  2805.     }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
  2806.     }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
  2807.         Makefile.PL DIR=}, $dir, q{ \
  2808.         MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
  2809.         MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
  2810.  
  2811.     push @m, map( " \\\n\t\t$_", @ARGV );
  2812.     push @m, "\n";
  2813.  
  2814.     return join '', @m;
  2815.     }
  2816.  
  2817.  
  2818.  
  2819.     my($cccmd, $linkcmd, $lperl);
  2820.  
  2821.  
  2822.     $cccmd = $self->const_cccmd($libperl);
  2823.     $cccmd =~ s/^CCCMD\s*=\s*//;
  2824.     $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /;
  2825.     $cccmd .= " $Config::Config{cccdlflags}" if ($Config::Config{d_shrplib});
  2826.     $cccmd =~ s/\n/ /g; # yes I've seen "\n", don't ask me where it came from. A.K.
  2827.     $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
  2828.  
  2829.     # The front matter of the linkcommand...
  2830.     $linkcmd = join ' ', "\$(CC)",
  2831.         grep($_, @Config{qw(large split ldflags ccdlflags)});
  2832.     $linkcmd =~ s/\s+/ /g;
  2833.  
  2834.     # Which *.a files could we make use of...
  2835.     local(%static);
  2836.     File::Find::find(sub {
  2837.     return unless m/\Q$self->{LIB_EXT}\E$/;
  2838.     return if m/^libperl/;
  2839.     # don't include the installed version of this extension. I
  2840.     # leave this line here, although it is not necessary anymore:
  2841.     # I patched minimod.PL instead, so that Miniperl.pm won't
  2842.     # enclude duplicates
  2843.  
  2844.     # Once the patch to minimod.PL is in the distribution, I can
  2845.     # drop it
  2846.     return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:;
  2847.     $static{fastcwd() . "/" . $_}++;
  2848.     }, grep( -d $_, @{$searchdirs || []}) );
  2849.  
  2850.     # We trust that what has been handed in as argument, will be buildable
  2851.     $static = [] unless $static;
  2852.     @static{@{$static}} = (1) x @{$static};
  2853.  
  2854.     $extra = [] unless $extra && ref $extra eq 'ARRAY';
  2855.     for (sort keys %static) {
  2856.     next unless /\Q$self->{LIB_EXT}\E$/;
  2857.     $_ = dirname($_) . "/extralibs.ld";
  2858.     push @$extra, $_;
  2859.     }
  2860.  
  2861.     grep(s/^/-I/, @{$perlinc || []});
  2862.  
  2863.     $target = "perl" unless $target;
  2864.     $tmp = "." unless $tmp;
  2865.  
  2866. # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
  2867. # regenerate the Makefiles, MAP_STATIC and the dependencies for
  2868. # extralibs.all are computed correctly
  2869.     push @m, "
  2870. MAP_LINKCMD   = $linkcmd
  2871. MAP_PERLINC   = @{$perlinc || []}
  2872. MAP_STATIC    = ",
  2873. join(" \\\n\t", reverse sort keys %static), "
  2874.  
  2875. MAP_PRELIBS   = $Config::Config{libs} $Config::Config{cryptlib}
  2876. ";
  2877.  
  2878.     if (defined $libperl) {
  2879.     ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
  2880.     }
  2881.     unless ($libperl && -f $lperl) { # Ilya's code...
  2882.     my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
  2883.     $libperl ||= "libperl$self->{LIB_EXT}";
  2884.     $libperl   = "$dir/$libperl";
  2885.     $lperl   ||= "libperl$self->{LIB_EXT}";
  2886.     $lperl     = "$dir/$lperl";
  2887.     print STDOUT "Warning: $libperl not found
  2888.     If you're going to build a static perl binary, make sure perl is installed
  2889.     otherwise ignore this warning\n"
  2890.         unless (-f $lperl || defined($self->{PERL_SRC}));
  2891.     }
  2892.  
  2893.     push @m, "
  2894. MAP_LIBPERL = $libperl
  2895. ";
  2896.  
  2897.     push @m, "
  2898. \$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)."
  2899.     $self->{NOECHO}$self->{RM_F} \$\@
  2900.     $self->{NOECHO}\$(TOUCH) \$\@
  2901. ";
  2902.  
  2903.     my $catfile;
  2904.     foreach $catfile (@$extra){
  2905.     push @m, "\tcat $catfile >> \$\@\n";
  2906.     }
  2907.  
  2908.     push @m, "
  2909. \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
  2910.     \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
  2911.     $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
  2912.     $self->{NOECHO}echo '    make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
  2913.     $self->{NOECHO}echo 'To remove the intermediate files say'
  2914.     $self->{NOECHO}echo '    make -f $makefilename map_clean'
  2915.  
  2916. $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
  2917. ";
  2918.     push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n";
  2919.  
  2920.     push @m, qq{
  2921. $tmp/perlmain.c: $makefilename}, q{
  2922.     }.$self->{NOECHO}.q{echo Writing $@
  2923.     }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
  2924.         writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@
  2925.  
  2926. };
  2927.  
  2928.     push @m, q{
  2929. doc_inst_perl:
  2930.     }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
  2931.     }.$self->{NOECHO}.q{$(DOC_INSTALL) \
  2932.         "Perl binary $(MAP_TARGET)" \
  2933.         MAP_STATIC "$(MAP_STATIC)" \
  2934.         MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
  2935.         MAP_LIBPERL "$(MAP_LIBPERL)" \
  2936.         >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
  2937.  
  2938. };
  2939.  
  2940.     push @m, qq{
  2941. inst_perl: pure_inst_perl doc_inst_perl
  2942.  
  2943. pure_inst_perl: \$(MAP_TARGET)
  2944.     $self->{CP} \$(MAP_TARGET) \$(INSTALLBIN)/\$(MAP_TARGET)
  2945.  
  2946. clean :: map_clean
  2947.  
  2948. map_clean :
  2949.     $self->{RM_F} $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
  2950. };
  2951.  
  2952.     join '', @m;
  2953. }
  2954.  
  2955. =item extliblist
  2956.  
  2957. Called by init_others.
  2958.  
  2959. =cut
  2960.  
  2961. sub extliblist {
  2962.     my($self,$libs) = @_;
  2963.     unless (ref $self){
  2964.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2965.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2966.     }
  2967.     $self->ext($libs, $Verbose);
  2968. }
  2969.  
  2970. =item dir_target
  2971.  
  2972. Takes an array of directories that need to exist and returns a
  2973. Makefile entry for a .exists file in these directories. Returns
  2974. nothing, if the entry has already been processed. We're helpless
  2975. though, if the same directory comes as $(FOO) _and_ as "bar". Both of
  2976. them get an entry, that's why we use "::".
  2977.  
  2978. =cut
  2979.  
  2980. sub dir_target {
  2981. # --- Make-Directories section (internal method) ---
  2982. # dir_target(@array) returns a Makefile entry for the file .exists in each
  2983. # named directory. Returns nothing, if the entry has already been processed.
  2984. # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
  2985. # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
  2986. # prerequisite, because there has to be one, something that doesn't change
  2987. # too often :)
  2988.  
  2989.     my($self,@dirs) = @_;
  2990.     unless (ref $self){
  2991.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  2992.     $self = $ExtUtils::MakeMaker::Parent[-1];
  2993.     }
  2994.     my(@m,$dir);
  2995.     foreach $dir (@dirs) {
  2996.     next if $self->{DIR_TARGET}{$self}{$dir}++;
  2997.     push @m, qq{
  2998. $dir/.exists :: }.$self->catfile($self->{PERL_INC},"perl.h").qq{
  2999.     $self->{NOECHO}\$(MKPATH) $dir
  3000.     $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) \$(PERL) $dir/.exists
  3001.     -$self->{NOECHO}\$(CHMOD) 755 $dir
  3002. };
  3003.     }
  3004.     join "", @m;
  3005. }
  3006.  
  3007. =item needs_linking
  3008.  
  3009. Does this module need linking? Looks into subdirectory objects (see
  3010. also has_link_code())
  3011.  
  3012. =cut
  3013.  
  3014. sub needs_linking {
  3015.     my($self) = shift;
  3016.     my($child,$caller);
  3017.     $caller = (caller(0))[3];
  3018.     unless (ref $self){
  3019.     ExtUtils::MakeMaker::TieAtt::warndirectuse($caller);
  3020.     $self = $ExtUtils::MakeMaker::Parent[-1];
  3021.     }
  3022.     Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/;
  3023.     return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
  3024.     if ($self->has_link_code or $self->{MAKEAPERL}){
  3025.     $self->{NEEDS_LINKING} = 1;
  3026.     return 1;
  3027.     }
  3028.     foreach $child (keys %{$self->{CHILDREN}}) {
  3029.     if ($self->{CHILDREN}->{$child}->needs_linking) {
  3030.         $self->{NEEDS_LINKING} = 1;
  3031.         return 1;
  3032.     }
  3033.     }
  3034.     return $self->{NEEDS_LINKING} = 0;
  3035. }
  3036.  
  3037. =item has_link_code
  3038.  
  3039. Returns true if C, XS, MYEXTLIB or similar objects exist within this
  3040. object that need a compiler. Does not descend into subdirectories as
  3041. needs_linking() does.
  3042.  
  3043. =cut
  3044.  
  3045. sub has_link_code {
  3046.     my($self) = shift;
  3047.     return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
  3048.     if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
  3049.     $self->{HAS_LINK_CODE} = 1;
  3050.     return 1;
  3051.     }
  3052.     return $self->{HAS_LINK_CODE} = 0;
  3053. }
  3054.  
  3055. =item writedoc
  3056.  
  3057. Obsolete, depecated method.
  3058.  
  3059. =cut
  3060.  
  3061. sub writedoc {
  3062. # --- perllocal.pod section ---
  3063.     my($self,$what,$name,@attribs)=@_;
  3064.     unless (ref $self){
  3065.     ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
  3066.     $self = $ExtUtils::MakeMaker::Parent[-1];
  3067.     }
  3068.     my $time = localtime;
  3069.     print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
  3070.     print join "\n\n=item *\n\n", map("C<$_>",@attribs);
  3071.     print "\n\n=back\n\n";
  3072. }
  3073.  
  3074. =head1 SEE ALSO
  3075.  
  3076. L<ExtUtils::MakeMaker>
  3077.  
  3078. =cut
  3079.  
  3080. 1;
  3081.  
  3082.