home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / lib / perl5 / ExtUtils / MakeMaker.pm < prev    next >
Text File  |  1997-03-29  |  92KB  |  2,844 lines

  1. package ExtUtils::MakeMaker;
  2.  
  3. $Version = 4.16; # Last edited $Date: 1995/06/18 16:04:00 $ by Tim Bunce
  4.  
  5. $Version_OK = 4.13;    # Makefiles older than $Version_OK will die
  6.             # (Will be checked from MakeMaker version 4.13 onwards)
  7.  
  8. # $Id: MakeMaker.pm,v 1.21 1995/06/06 06:14:16 k Exp k $
  9.  
  10. use Config;
  11. use Carp;
  12. use Cwd;
  13.  
  14. require Exporter;
  15. @ISA = qw(Exporter);
  16. @EXPORT = qw(&WriteMakefile $Verbose &prompt);
  17. @EXPORT_OK = qw($Version &Version_check %att %skip %Recognized_Att_Keys
  18.     @MM_Sections %MM_Sections
  19.     &help &neatvalue &mkbootstrap &mksymlists);
  20.  
  21. $Is_VMS = $Config{'osname'} eq 'VMS';
  22. require ExtUtils::MM_VMS if $Is_VMS;
  23.  
  24. use strict qw(refs);
  25.  
  26. $Version = $Version;# avoid typo warning
  27. $Verbose = 0;
  28. $^W=1;
  29.  
  30. sub prompt {
  31.     my($mess,$def)=@_;
  32.     local $\="";
  33.     local $/="\n";
  34.     local $|=1;
  35.     die "prompt function called without an argument" unless defined $mess;
  36.     $def = "" unless defined $def;
  37.     my $dispdef = "[$def] ";
  38.     print "$mess $dispdef";
  39.     chop(my $ans = <STDIN>);
  40.     $ans || $def;
  41. }
  42.  
  43. sub check_hints {
  44.     # We allow extension-specific hints files.
  45.  
  46.     # First we look for the best hintsfile we have
  47.     my(@goodhints);
  48.     my($hint)="$Config{'osname'}_$Config{'osvers'}";
  49.     $hint =~ s/\./_/g;
  50.     $hint =~ s/_$//;
  51.     local(*DIR);
  52.     opendir DIR, "hints";
  53.     while (defined ($_ = readdir DIR)) {
  54.     next if /^\./;
  55.     next unless s/\.pl$//;
  56.     next unless /^$Config{'osname'}/;
  57.     # Don't trust a hintfile for a later OS version:
  58.     next if $_ gt $hint;
  59.     push @goodhints, $_;
  60.     if ($_ eq $hint){
  61.         @goodhints=$_;
  62.         last;
  63.     }
  64.     }
  65.     closedir DIR;
  66.     return unless @goodhints; # There was no hintsfile
  67.     # the last one in lexical ordering is our choice:
  68.     $hint=(sort @goodhints)[-1];
  69.  
  70.     # execute the hintsfile:
  71.     open HINTS, "hints/$hint.pl";
  72.     @goodhints = <HINTS>;
  73.     close HINTS;
  74.     print STDOUT "Processing hints file hints/$hint.pl";
  75.     eval join('',@goodhints);
  76.     print STDOUT $@ if $@;
  77. }
  78.  
  79. # Setup dummy package:
  80. # MY exists for overriding methods to be defined within
  81. unshift(@MY::ISA, qw(MM));
  82.  
  83. # Dummy package MM inherits actual methods from OS-specific
  84. # default packages.  We use this intermediate package so
  85. # MY->func() can call MM->func() and get the proper
  86. # default routine without having to know under what OS
  87. # it's running.
  88. unshift(@MM::ISA, $Is_VMS ? qw(ExtUtils::MM_VMS MM_Unix) : qw(MM_Unix));
  89.  
  90. $Attrib_Help = <<'END';
  91.  NAME:        Perl module name for this extension (DBD::Oracle)
  92.         This will default to the directory name but should
  93.         be explicitly defined in the Makefile.PL.
  94.  
  95.  DISTNAME:    Your name for distributing the package (by tar file)
  96.         This defaults to NAME above.
  97.  
  98.  VERSION:    Your version number for distributing the package.
  99.         This defaults to 0.1.
  100.  
  101.  INST_LIB:    Perl library directory to directly install
  102.         into during 'make'.
  103.  
  104.  INSTALLPRIVLIB:Used by 'make install', which sets INST_LIB to this value.
  105.  
  106.  INST_ARCHLIB:    Perl architecture-dependent library to directly install
  107.         into during 'make'.
  108.  
  109.  INSTALLARCHLIB:Used by 'make install', which sets INST_ARCHLIB to this value.
  110.  
  111.  INST_EXE:    Directory, where executable scripts should be installed during
  112.         'make'. Defaults to "./blib", just to have a dummy location
  113.         during testing. C<make install> will set INST_EXE to INSTALLBIN.
  114.  
  115.  INSTALLBIN:    Used by 'make install' which sets INST_EXE to this value.
  116.  
  117.  PERL_LIB:    Directory containing the Perl library to use.
  118.  
  119.  PERL_ARCHLIB:    Architectur dependent directory containing the Perl library to use.
  120.  
  121.  PERL_SRC:    Directory containing the Perl source code
  122.         (use of this should be avoided, it may be undefined)
  123.  
  124.  INC:        Include file dirs eg: '-I/usr/5include -I/path/to/inc'
  125.  
  126.  DEFINE:    something like "-DHAVE_UNISTD_H"
  127.  
  128.  OBJECT:    List of object files, defaults to '$(BASEEXT).o',
  129.         but can be a long string containing all object files,
  130.             e.g. "tkpBind.o tkpButton.o tkpCanvas.o"
  131.  
  132.  MYEXTLIB:    If the extension links to a library that it builds
  133.         set this to the name of the library (see SDBM_File)
  134.  
  135.  LIBS:        An anonymous array of alternative library specifications
  136.         to be searched for (in order) until at least one library
  137.         is found.
  138.           'LIBS' => [ "-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs" ]
  139.         Mind, that any element of the array contains a complete
  140.         set of arguments for the ld command. So do not specify
  141.           'LIBS' => ["-ltcl", "-ltk", "-lX11" ], #wrong
  142.         See ODBM_File/Makefile.PL for an example, where an
  143.         array is needed. If you specify a scalar as in
  144.           'LIBS' => "-ltcl -ltk -lX11"
  145.         MakeMaker will turn it into an array with one element.
  146.  
  147.  LDFROM:    defaults to "$(OBJECT)" and is used in the ld command
  148.         to specify what files to link/load from
  149.         (also see dynamic_lib below for how to specify ld flags)
  150.  
  151.  DIR:        Ref to array of subdirectories containing Makefile.PLs
  152.         e.g. [ 'sdbm' ] in ext/SDBM_File
  153.  
  154.  PMLIBDIRS:    Ref to array of subdirectories containing library files.
  155.         Defaults to [ 'lib', $(BASEEXT) ]. The directories will
  156.         be scanned and any files they contain will
  157.         be installed in the corresponding location in the library.
  158.         A MY::libscan() function can be used to alter the behaviour.
  159.         Defining PM in the Makefile.PL will override PMLIBDIRS.
  160.  
  161.  PM:        Hashref of .pm files and *.pl files to be installed.
  162.         e.g. { 'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm' }
  163.         By default this will include *.pm and *.pl. If a lib directory
  164.         exists and is not listed in DIR (above) then any *.pm and
  165.         *.pl files it contains will also be included by default.
  166.         Defining PM in the Makefile.PL will override PMLIBDIRS.
  167.  
  168.  XS:        Hashref of .xs files. MakeMaker will default this.
  169.         e.g. { 'name_of_file.xs' => 'name_of_file.c' }
  170.         The .c files will automatically be included in the list
  171.         of files deleted by a make clean.
  172.  
  173.  C:        Ref to array of *.c file names. Initialised from a directory scan
  174.         and the values portion of the XS attribute hash. This is not
  175.         currently used by MakeMaker but may be handy in Makefile.PLs.
  176.  
  177.  H:        Ref to array of *.h file names. Similar to C: above.
  178.  
  179.  PL_FILES:      Ref to hash of files to be processed as perl programs. MakeMaker
  180.         will default to any found C<*.PL> file (except C<Makefile.PL>) being
  181.         keys and the basename of the file being the value. E.g.
  182.         C<{ 'foobar.PL' => 'foobar' }>. The C<*.PL> files are expected to
  183.         produce output to the target files themselves.
  184.  
  185.  EXE_FILES:    Ref to array of executable files. The files will be copied to 
  186.         the INST_EXE directory. Make realclean will delete them from
  187.         there again.
  188.  
  189.  LINKTYPE:    =>'static' or 'dynamic' (default unless usedl=undef in config.sh)
  190.         Should only be used to force static linking (also see linkext below).
  191.  
  192.  DL_FUNCS:    Hashref of symbol names for routines to be made available as
  193.         universal symbols.  Each key/value pair consists of the package
  194.         name and an array of routine names in that package.  Used only
  195.         under AIX (export lists) and VMS (linker options) at present.
  196.         The routine names supplied will be expanded in the same way
  197.         as XSUB names are expanded by the XS() macro.
  198.         Defaults to { "$(NAME)" => [ "boot_$(NAME)" ] }.
  199.         (e.g. { "RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
  200.                 "NetconfigPtr" => [ 'DESTROY'] } )
  201.  
  202.  DL_VARS:    Array of symbol names for variables to be made available as
  203.         universal symbols.  Used only under AIX (export lists) and VMS
  204.         (linker options) at present.  Defaults to [].
  205.         (e.g. [ qw( Foo_version Foo_numstreams Foo_tree ) ])
  206.  
  207.  CONFIG:    =>[qw(archname manext)] defines ARCHNAME & MANEXT from config.sh
  208.  
  209.  SKIP:      =>[qw(name1 name2)] skip (do not write) sections of the Makefile
  210.  
  211.  MAP_TARGET:    If it is intended, that a new perl binary be produced, this variable
  212.         may hold a name for that binary. Defaults to C<perl>
  213.  
  214.  LIBPERL_A:     The filename of the perllibrary that will be used together
  215.         with this extension. Defaults to C<libperl.a>.
  216.  
  217.  PERL:
  218.  FULLPERL:
  219.  
  220. Additional lowercase attributes can be used to pass parameters to the
  221. methods which implement that part of the Makefile. These are not
  222. normally required:
  223.  
  224.  macro:        {ANY_MACRO => ANY_VALUE, ...}
  225.  installpm:    {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
  226.  linkext:    {LINKTYPE => 'static', 'dynamic' or ''}
  227.  dynamic_lib:    {ARMAYBE => 'ar', OTHERLDFLAGS => '...'}
  228.  clean:        {FILES => "*.xyz foo"}
  229.  realclean:    {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
  230.  dist:        {TARFLAGS=>'cvfF', COMPRESS=>'gzip', SUFFIX=>'gz', SHAR=>'shar -m'}
  231.  tool_autosplit:    {MAXLEN => 8}
  232. END
  233.  
  234. sub help {print $Attrib_Help;}
  235.  
  236. @MM_Sections_spec = (
  237.     'post_initialize'    => {},
  238.     'const_config'    => {},
  239.     'constants'        => {},
  240.     'const_loadlibs'    => {},
  241.     'const_cccmd'    => {},
  242.     'tool_autosplit'    => {},
  243.     'tool_xsubpp'    => {},
  244.     'tools_other'    => {},
  245.     'macro'        => {},
  246.     'post_constants'    => {},
  247.     'pasthru'        => {},
  248.     'c_o'        => {},
  249.     'xs_c'        => {},
  250.     'xs_o'        => {},
  251.     'top_targets'    => {},
  252.     'linkext'        => {},
  253.     'dlsyms'        => {},
  254.     'dynamic'        => {},
  255.     'dynamic_bs'    => {},
  256.     'dynamic_lib'    => {},
  257.     'static'        => {},
  258.     'static_lib'    => {},
  259.     'installpm'        => {},
  260.     'processPL'        => {},
  261.     'installbin'    => {},
  262.     'subdirs'        => {},
  263.     'clean'        => {},
  264.     'realclean'        => {},
  265.     'dist'        => {},
  266.     'install'        => {},
  267.     'force'        => {},
  268.     'perldepend'    => {},
  269.     'makefile'        => {},
  270.     'staticmake'    => {},    # Sadly this defines more macros
  271.     'test'        => {},
  272.     'postamble'        => {},    # should always be last
  273. );
  274. %MM_Sections = @MM_Sections_spec; # looses section ordering
  275. @MM_Sections = grep(!ref, @MM_Sections_spec); # keeps order
  276.  
  277. %Recognized_Att_Keys = %MM_Sections; # All sections are valid keys.
  278. foreach(split(/\n/,$Attrib_Help)){
  279.     chomp;
  280.     next unless m/^\s*(\w+):\s*(.*)/;
  281.     $Recognized_Att_Keys{$1} = $2;
  282.     print "Attribute '$1' => '$2'\n" if ($Verbose >= 2);
  283. }
  284.  
  285. %att  = ();
  286. %skip = ();
  287.  
  288. sub skipcheck{
  289.     my($section) = @_;
  290.     if ($section eq 'dynamic') {
  291.     print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets "
  292.       . "in skipped section 'dynamic_bs'\n"
  293.             if $skip{'dynamic_bs'} && $Verbose;
  294.         print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets "
  295.       . "in skipped section 'dynamic_lib'\n"
  296.             if $skip{'dynamic_lib'} && $Verbose;
  297.     }
  298.     if ($section eq 'dynamic_lib') {
  299.         print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on "
  300.       . "targets in skipped section 'dynamic_bs'\n"
  301.             if $skip{'dynamic_bs'} && $Verbose;
  302.     }
  303.     if ($section eq 'static') {
  304.         print STDOUT "Warning (non-fatal): Target 'static' depends on targets "
  305.       . "in skipped section 'static_lib'\n"
  306.             if $skip{'static_lib'} && $Verbose;
  307.     }
  308.     return 'skipped' if $skip{$section};
  309.     return '';
  310. }
  311.  
  312.  
  313. sub WriteMakefile {
  314.     %att = @_;
  315.     local($\)="\n";
  316.  
  317.     print STDOUT "MakeMaker (v$Version)" if $Verbose;
  318.  
  319.     if ( Carp::longmess("") =~ "runsubdirpl" ){
  320.     $Correct_relativ_directories++;
  321.     } else {
  322.     $Correct_relativ_directories=0;
  323.     }
  324.  
  325.     if (-f "MANIFEST"){
  326.     eval {require ExtUtils::Manifest};
  327.     if ($@){
  328.         print STDOUT "Warning: you have not installed the ExtUtils::Manifest
  329.          module -- skipping check of the MANIFEST file";
  330.     } else {
  331.         print STDOUT "Checking if your kit is complete...";
  332.         $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
  333.         my(@missed)=ExtUtils::Manifest::manicheck();
  334.         if (@missed){
  335.         print STDOUT "Warning: the following files are missing in your kit:";
  336.         print "\t", join "\n\t", @missed;
  337.         print STDOUT "Please inform the author.\n";
  338.         } else {
  339.         print STDOUT "Looks good";
  340.         }
  341.     }
  342.     }
  343.  
  344.     parse_args(\%att, @ARGV);
  345.     my(%initial_att) = %att; # record initial attributes
  346.  
  347.     check_hints();
  348.  
  349.     my($key);
  350.  
  351.     MY->init_main();
  352.  
  353.     print STDOUT "Writing Makefile for $att{NAME}";
  354.  
  355.     if (! $att{PERL_SRC} && 
  356.     $INC{'Config.pm'} ne "$Config{'archlib'}/Config.pm"){
  357.     (my $pthinks = $INC{'Config.pm'}) =~ s!/Config\.pm$!!;
  358.     $pthinks =~ s!.*/!!;
  359.     print STDOUT <<END;
  360. Your perl and your Config.pm seem to have different ideas about the architecture
  361. they are running on.
  362. Perl thinks: $pthinks
  363. Config says: $Config{"archname"}
  364. This may or may not cause problems. Please check your installation of perl if you
  365. have problems building this extension.
  366. END
  367.     }
  368.  
  369.     MY->init_dirscan();
  370.     MY->init_others();
  371.  
  372.     unlink("Makefile", "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
  373.     open MAKE, ">MakeMaker.tmp" or die "Unable to open MakeMaker.tmp: $!";
  374.     select MAKE; $|=1; select STDOUT;
  375.  
  376.     print MAKE "# This Makefile is for the $att{NAME} extension to perl.\n#";
  377.     print MAKE "# It was generated automatically by MakeMaker version $Version from the contents";
  378.     print MAKE "# of Makefile.PL. Don't edit this file, edit Makefile.PL instead.";
  379.     print MAKE "#\n#    ANY CHANGES MADE HERE WILL BE LOST! \n#";
  380.     print MAKE "#   MakeMaker Parameters: ";
  381.     foreach $key (sort keys %initial_att){
  382.     my($v) = neatvalue($initial_att{$key});
  383.     $v =~ tr/\n/ /s;
  384.     print MAKE "#    $key => $v";
  385.     }
  386.  
  387.     # build hash for SKIP to make testing easy
  388.     %skip = map( ($_,1), @{$att{'SKIP'} || []});
  389.  
  390.     my $section;
  391.     foreach $section ( @MM_Sections ){
  392.     print "Processing Makefile '$section' section" if ($Verbose >= 2);
  393.     my($skipit) = skipcheck($section);
  394.     if ($skipit){
  395.         print MAKE "\n# --- MakeMaker $section section $skipit.";
  396.     } else {
  397.         my(%a) = %{$att{$section} || {}};
  398.         print MAKE "\n# --- MakeMaker $section section:";
  399.         print MAKE "# ", join ", ", %a if $Verbose;
  400.         print(MAKE MY->nicetext(MY->$section( %a )));
  401.     }
  402.     }
  403.  
  404.     if ($Verbose){
  405.     print MAKE "\n# Full list of MakeMaker attribute values:";
  406.     foreach $key (sort keys %att){
  407.         my($v) = neatvalue($att{$key});
  408.         $v =~ tr/\n/ /s;
  409.         print MAKE "#    $key => $v";
  410.     }
  411.     }
  412.  
  413.     print MAKE "\n# End.";
  414.     close MAKE;
  415.     my($finalname) = $Is_VMS ? "Descrip.MMS" : "Makefile";
  416.     rename("MakeMaker.tmp", $finalname);
  417.  
  418.     chmod 0644, $finalname;
  419.     system("$Config{'eunicefix'} $finalname") unless $Config{'eunicefix'} eq ":";
  420.  
  421.     1;
  422. }
  423.  
  424. sub Version_check {
  425.     my($checkversion) = @_;
  426.     die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
  427. Current Version is $Version. There have been considerable changes in the meantime.
  428. Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n" if $checkversion < $Version_OK;
  429.     print STDOUT "Makefile built with ExtUtils::MakeMaker v $checkversion. Current Version is $Version." unless $checkversion == $Version;
  430. }
  431.  
  432. sub mksymlists{
  433.     %att = @_;
  434.     parse_args(\%att, @ARGV);
  435.     MY->mksymlists(@_);
  436. }
  437.  
  438. # The following mkbootstrap() is only for installations that are calling
  439. # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
  440. # write Makefiles, that use ExtUtils::Mkbootstrap directly.
  441. sub mkbootstrap{
  442.     parse_args(\%att, @ARGV);
  443.     MY->init_main() unless defined $att{BASEEXT};
  444.     eval {require ExtUtils::Mkbootstrap};
  445.     if ($@){
  446.     # Very difficult to arrive here, I suppose
  447.     carp "Error: $@\nVersion mismatch: This MakeMaker (v$Version) needs the ExtUtils::Mkbootstrap package. Please check your installation.";
  448.     }
  449.     ExtUtils::Mkbootstrap::Mkbootstrap($att{BASEEXT},@_);
  450. }
  451.  
  452. sub parse_args{
  453.     my($attr, @args) = @_;
  454.     foreach (@args){
  455.     unless (m/(.*?)=(.*)/){
  456.         help(),exit 1 if m/^help$/;
  457.         ++$Verbose if m/^verb/;
  458.         next;
  459.     }
  460.     my($name, $value) = ($1, $2);
  461.     if ($value =~ m/^~(\w+)?/){ # tilde with optional username
  462.         $value =~ s [^~(\w*)]
  463.         [$1 ? 
  464.          ((getpwnam($1))[7] || "~$1") : 
  465.          (getpwuid($>))[7]
  466.          ]ex;
  467.     }
  468.     if ($Correct_relativ_directories){
  469.         # This is experimental, so we don't care for efficiency
  470.         my @dirs = qw(INST_LIB INST_ARCHLIB INST_EXE);
  471.         my %dirs;
  472.         @dirs{@dirs}=@dirs;
  473.         if ($dirs{$name} && $value !~ m!^/!){ # a relativ directory
  474.         $value = "../$value";
  475.         }
  476.     }
  477.  
  478.     $$attr{$name} = $value;
  479.     }
  480.     # catch old-style 'potential_libs' and inform user how to 'upgrade'
  481.     if (defined $$attr{'potential_libs'}){
  482.     my($msg)="'potential_libs' => '$$attr{potential_libs}' should be";
  483.     if ($$attr{'potential_libs'}){
  484.         print STDOUT "$msg changed to:\n\t'LIBS' => ['$$attr{potential_libs}']\n";
  485.     } else {
  486.         print STDOUT "$msg deleted.\n";
  487.     }
  488.     $$attr{LIBS} = [$$attr{'potential_libs'}];
  489.     delete $$attr{'potential_libs'};
  490.     }
  491.     # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
  492.     if (defined $$attr{'ARMAYBE'}){
  493.     my($armaybe) = $$attr{'ARMAYBE'};
  494.     print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
  495.             "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
  496.     my(%dl) = %{$$attr{'dynamic_lib'} || {}};
  497.     $$attr{'dynamic_lib'} = { %dl, ARMAYBE => $armaybe};
  498.     delete $$attr{'ARMAYBE'};
  499.     }
  500.     if (defined $$attr{'LDTARGET'}){
  501.     print STDOUT "LDTARGET should be changed to LDFROM\n";
  502.     $$attr{'LDFROM'} = $$attr{'LDTARGET'};
  503.     delete $$attr{'LDTARGET'};
  504.     }
  505.     foreach(sort keys %{$attr}){
  506.     print STDOUT "    $_ => ".neatvalue($$attr{$_}) if ($Verbose);
  507.     print STDOUT "'$_' is not a known MakeMaker parameter name.\n"
  508.         unless exists $Recognized_Att_Keys{$_};
  509.     }
  510. }
  511.  
  512.  
  513. sub neatvalue{
  514.     my($v) = @_;
  515.     return "undef" unless defined $v;
  516.     my($t) = ref $v;
  517.     return "'$v'" unless $t;
  518.     return "[ ".join(', ',map("'$_'",@$v))." ]" if ($t eq 'ARRAY');
  519.     return "$v" unless $t eq 'HASH';
  520.     my(@m, $key, $val);
  521.     push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
  522.     return "{ ".join(', ',@m)." }";
  523. }
  524.  
  525. # ------ Define the MakeMaker default methods in package MM_Unix ------
  526.  
  527. package MM_Unix;
  528.  
  529. use Config;
  530. use Cwd;
  531. use File::Basename;
  532. require Exporter;
  533.  
  534. Exporter::import('ExtUtils::MakeMaker',
  535.     qw(%att %skip %Recognized_Att_Keys $Verbose));
  536.  
  537. # These attributes cannot be overridden externally
  538. @Other_Att_Keys{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)} = (1) x 3;
  539.  
  540. if ($Is_VMS = $Config{'osname'} eq 'VMS') {
  541.     require VMS::Filespec;
  542.     import VMS::Filespec 'vmsify';
  543. }
  544.  
  545.  
  546. sub init_main {
  547.     my($self) = @_;
  548.  
  549.     # Find out directory name.  This may contain the extension name.
  550.     my($pwd) = fastcwd(); # from Cwd.pm
  551.     # --- Initialize Module Name and Paths
  552.  
  553.     # NAME    = The perl module name for this extension (eg DBD::Oracle).
  554.     # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
  555.     # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  556.     # ROOTEXT = Directory part of FULLEXT with leading /.
  557.     unless($att{NAME}){ # we have to guess our name
  558.     my($name) = $pwd;
  559.     if ($Is_VMS) {
  560.       $name =~ s:.*?([^.\]]+)\]:$1: unless ($name =~ s:.*[.\[]ext\.(.*)\]:$1:i);
  561.       ($att{NAME}=$name) =~ s#[.\]]#::#g;
  562.     } else {
  563.       $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
  564.       ($att{NAME} =$name) =~ s#/#::#g;
  565.     }
  566.     }
  567.     ($att{FULLEXT} =$att{NAME}) =~ s#::#/#g ;        #eg. BSD/Foo/Socket
  568.     ($att{BASEEXT} =$att{NAME}) =~ s#.*::##;        #eg. Socket
  569.     ($att{ROOTEXT} =$att{FULLEXT}) =~ s#/?\Q$att{BASEEXT}\E$## ; # eg. /BSD/Foo
  570.     $att{ROOTEXT} = ($Is_VMS ? '' : '/') . $att{ROOTEXT} if $att{ROOTEXT};
  571.  
  572.  
  573.     # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
  574.  
  575.     # *Real* information: where did we get these two from? ...
  576.     my $inc_config_dir = dirname($INC{'Config.pm'});
  577.     my $inc_carp_dir   = dirname($INC{'Carp.pm'});
  578.  
  579.     # Typically PERL_* and INST_* will be identical but that need
  580.     # not be the case (e.g., installing into project libraries etc).
  581.  
  582.     # Perl Macro:    With source    No source
  583.     # PERL_LIB       ../../lib      /usr/local/lib/perl5
  584.     # PERL_ARCHLIB   ../../lib      /usr/local/lib/perl5/sun4-sunos
  585.     # PERL_SRC       ../..          (undefined)
  586.  
  587.     # INST Macro:    For standard   for any other
  588.     #                modules        module
  589.     # INST_LIB       ../../lib      ./blib
  590.     # INST_ARCHLIB   ../../lib      ./blib
  591.  
  592.     unless ($att{PERL_SRC}){
  593.     foreach (qw(../.. ../../.. ../../../..)){
  594.         if ( -f "$_/config.sh" 
  595.         && -f "$_/perl.h" 
  596.         && -f "$_/lib/Exporter.pm") {
  597.         $att{PERL_SRC}=$_ ;
  598.         last;
  599.         }
  600.     }
  601.     }
  602.     unless ($att{PERL_SRC}){
  603.     # we should also consider $ENV{PERL5LIB} here
  604.     $att{PERL_LIB}     = $Config{'privlib'} unless $att{PERL_LIB};
  605.     $att{PERL_ARCHLIB} = $Config{'archlib'} unless $att{PERL_ARCHLIB};
  606.     $att{PERL_INC}     = "$att{PERL_ARCHLIB}/CORE"; # wild guess for now
  607.     die <<EOM unless (-f "$att{PERL_INC}/perl.h");
  608. Error: Unable to locate installed Perl libraries or Perl source code.
  609.  
  610. It is recommended that you install perl in a standard location before
  611. building extensions. You can say:
  612.  
  613.     $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory
  614.  
  615. if you have not yet installed perl but still want to build this
  616. extension now.
  617. EOM
  618.  
  619.     print STDOUT "Using header files found in $att{PERL_INC}" if $Verbose && $self->needs_linking;
  620.  
  621.     } else { # PERL_SRC is defined here...
  622.  
  623.     $att{PERL_LIB}     = "$att{PERL_SRC}/lib" unless $att{PERL_LIB};
  624.     $att{PERL_ARCHLIB} = $att{PERL_LIB};
  625.     $att{PERL_INC}     = $att{PERL_SRC};
  626.     # catch an situation that has occurred a few times in the past:
  627.     warn <<EOM unless -s "$att{PERL_SRC}/cflags";
  628. You cannot build extensions below the perl source tree after executing
  629. a 'make clean' in the perl source tree.
  630.  
  631. To rebuild extensions distributed with the perl source you should
  632. simply Configure (to include those extensions) and then build perl as
  633. normal. After installing perl the source tree can be deleted. It is not
  634. needed for building extensions.
  635.  
  636. It is recommended that you unpack and build additional extensions away
  637. from the perl source tree.
  638. EOM
  639.     }
  640.  
  641.     # INST_LIB typically pre-set if building an extension after
  642.     # perl has been built and installed. Setting INST_LIB allows
  643.     # you to build directly into, say $Config{'privlib'}.
  644.     unless ($att{INST_LIB}){
  645.     if (defined $att{PERL_SRC}) {
  646. #        require ExtUtils::Manifest;
  647. #        my $file;
  648.         my $standard = 0;
  649. #        my $mani = ExtUtils::Manifest::maniread("$att{PERL_SRC}/MANIFEST");
  650. #        foreach $file (keys %$mani){
  651. #        if ($file =~ m!^ext/\Q$att{FULLEXT}!){
  652. #            $standard++;
  653. #            last;
  654. #        }
  655. #        }
  656.  
  657. #### Temporary solution for perl5.001f:
  658. $standard = 1;
  659. #### This is just the same as was MakeMaker 4.094, but everything's prepared to
  660. #### switch to a different behaviour after 5.001f
  661.  
  662.         if ($standard){
  663.         $att{INST_LIB} = $att{PERL_LIB};
  664.         } else {
  665.         $att{INST_LIB} = "./blib";
  666.         print STDOUT <<END;
  667. Warning: The $att{NAME} extension will not be installed by 'make install' in the
  668. perl source directory. Please install it with 'make install' from the
  669.     $pwd
  670. directory.
  671. END
  672.         }
  673.     } else {
  674.         $att{INST_LIB} = "./blib";
  675.     }
  676.     }
  677.     # Try to work out what INST_ARCHLIB should be if not set:
  678.     unless ($att{INST_ARCHLIB}){
  679.     my(%archmap) = (
  680.         "./blib"        => "./blib", # our private build lib
  681.         $att{PERL_LIB}    => $att{PERL_ARCHLIB},
  682.         $Config{'privlib'}    => $Config{'archlib'},
  683.         $inc_carp_dir    => $inc_config_dir,
  684.     );
  685.     $att{INST_ARCHLIB} = $archmap{$att{INST_LIB}};
  686.     unless($att{INST_ARCHLIB}){
  687.         # Oh dear, we'll have to default it and warn the user
  688.         my($archname) = $Config{'archname'};
  689.         if (-d "$att{INST_LIB}/$archname"){
  690.         $att{INST_ARCHLIB} = "$att{INST_LIB}/$archname";
  691.         print STDOUT "Defaulting INST_ARCHLIB to INST_LIB/$archname\n";
  692.         } else {
  693.         $att{INST_ARCHLIB} = $att{INST_LIB};
  694.         print STDOUT "Warning: Defaulting INST_ARCHLIB to INST_LIB ",
  695.             "(not architecture independent).\n";
  696.         }
  697.     }
  698.     }
  699.     $att{INST_EXE} = "./blib" unless $att{INST_EXE};
  700.  
  701.     if( $att{INSTALLPRIVLIB} && ! $att{INSTALLARCHLIB} ){
  702.     my($archname) = $Config{'archname'};
  703.     if (-d "$att{INSTALLPRIVLIB}/$archname"){
  704.         $att{INSTALLARCHLIB} = "$att{INSTALLPRIVLIB}/$archname";
  705.         print STDOUT "Defaulting INSTALLARCHLIB to INSTALLPRIVLIB/$archname\n";
  706.     } else {
  707.         $att{INSTALLARCHLIB} = $att{INSTALLPRIVLIB};
  708.         print STDOUT "Warning: Defaulting INSTALLARCHLIB to INSTALLPRIVLIB ",
  709.         "(not architecture independent).\n";
  710.     }
  711.     }
  712.     $att{INSTALLPRIVLIB} ||= $Config{'installprivlib'};
  713.     $att{INSTALLARCHLIB} ||= $Config{'installarchlib'};
  714.     $att{INSTALLBIN}     ||= $Config{'installbin'};
  715.  
  716.     $att{MAP_TARGET} = "perl" unless $att{MAP_TARGET};
  717.     $att{LIBPERL_A} = $Is_VMS ? 'libperl.olb' : 'libperl.a'
  718.     unless $att{LIBPERL_A};
  719.  
  720.     # make a few simple checks
  721.     warn "Warning: PERL_LIB ($att{PERL_LIB}) seems not to be a perl library directory
  722.         (Exporter.pm not found)"
  723.     unless (-f "$att{PERL_LIB}/Exporter.pm");
  724.  
  725.     ($att{DISTNAME}=$att{NAME}) =~ s#(::)#-#g unless $att{DISTNAME};
  726.     $att{VERSION} = "0.1" unless $att{VERSION};
  727.     ($att{VERSION_SYM} = $att{VERSION}) =~ s/\W/_/g;
  728.  
  729.  
  730.     # --- Initialize Perl Binary Locations
  731.  
  732.     # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
  733.     # will be working versions of perl 5. miniperl has priority over perl
  734.     # for PERL to ensure that $(PERL) is usable while building ./ext/*
  735.     $att{'PERL'} =
  736.       MY->find_perl(5.0, ['miniperl','perl','perl5',"perl$]" ],
  737.             [ grep defined $_, $att{PERL_SRC}, split(":", $ENV{PATH}),
  738.              $Config{'bin'} ], $Verbose )
  739.     unless ($att{'PERL'});    # don't check, if perl is executable, maybe they
  740.                 # they have decided to supply switches with perl
  741.  
  742.     # Define 'FULLPERL' to be a non-miniperl (used in test: target)
  743.     ($att{'FULLPERL'} = $att{'PERL'}) =~ s/miniperl/perl/
  744.     unless ($att{'FULLPERL'} && -x $att{'FULLPERL'});
  745.  
  746.     if ($Is_VMS) {
  747.     $att{'PERL'} = 'MCR ' . vmsify($att{'PERL'});
  748.     $att{'FULLPERL'} = 'MCR ' . vmsify($att{'FULLPERL'});
  749.     }
  750. }
  751.  
  752.  
  753. sub init_dirscan {    # --- File and Directory Lists (.xs .pm .pod etc)
  754.  
  755.     my($name, %dir, %xs, %c, %h, %ignore, %pl_files);
  756.     local(%pm); #the sub in find() has to see this hash
  757.     $ignore{'test.pl'} = 1;
  758.     $ignore{'makefile.pl'} = 1 if $Is_VMS;
  759.     foreach $name (lsdir(".")){
  760.     next if ($name =~ /^\./ or $ignore{$name});
  761.     if (-d $name){
  762.         $dir{$name} = $name if (-f "$name/Makefile.PL");
  763.     } elsif ($name =~ /\.xs$/){
  764.         my($c); ($c = $name) =~ s/\.xs$/.c/;
  765.         $xs{$name} = $c;
  766.         $c{$c} = 1;
  767.     } elsif ($name =~ /\.c$/){
  768.         $c{$name} = 1
  769.         unless $name =~ m/perlmain\.c/; # See MAP_TARGET
  770.     } elsif ($name =~ /\.h$/){
  771.         $h{$name} = 1;
  772.     } elsif ($name =~ /\.(p[ml]|pod)$/){
  773.         $pm{$name} = "\$(INST_LIBDIR)/$name";
  774.     } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
  775.         ($pl_files{$name} = $name) =~ s/\.PL$// ;
  776.     }
  777.     }
  778.  
  779.     # Some larger extensions often wish to install a number of *.pm/pl
  780.     # files into the library in various locations.
  781.  
  782.     # The attribute PMLIBDIRS holds an array reference which lists
  783.     # subdirectories which we should search for library files to
  784.     # install. PMLIBDIRS defaults to [ 'lib', $att{BASEEXT} ].
  785.     # We recursively search through the named directories (skipping
  786.     # any which don't exist or contain Makefile.PL files).
  787.  
  788.     # For each *.pm or *.pl file found MY->libscan() is called with
  789.     # the default installation path in $_. The return value of libscan
  790.     # defines the actual installation location.
  791.     # The default libscan function simply returns $_.
  792.     # The file is skipped if libscan returns false.
  793.  
  794.     # The default installation location passed to libscan in $_ is:
  795.     #
  796.     #  ./*.pm        => $(INST_LIBDIR)/*.pm
  797.     #  ./xyz/...    => $(INST_LIBDIR)/xyz/...
  798.     #  ./lib/...    => $(INST_LIB)/...
  799.     #
  800.     # In this way the 'lib' directory is seen as the root of the actual
  801.     # perl library whereas the others are relative to INST_LIBDIR
  802.     # (which includes ROOTEXT). This is a subtle distinction but one
  803.     # that's important for nested modules.
  804.  
  805.     $att{PMLIBDIRS} = [ 'lib', $att{BASEEXT} ] unless $att{PMLIBDIRS};
  806.  
  807.     #only existing directories that aren't in $dir are allowed
  808.     @{$att{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$att{PMLIBDIRS}};
  809.  
  810.     if (@{$att{PMLIBDIRS}}){
  811.     print "Searching PMLIBDIRS: @{$att{PMLIBDIRS}}"
  812.         if ($Verbose >= 2);
  813.     use File::Find;        # try changing to require !
  814.     File::Find::find(sub {
  815. # We now allow any file in PMLIBDIRS to be installed. nTk needs that, and
  816. # we should allow it.
  817. #               return unless m/\.p[ml]$/;
  818.             return if -d $_; # anything else that Can't be copied?
  819.         my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
  820.         my $striplibpath;
  821.         $prefix =  '$(INST_LIB)' if (($striplibpath = $path) =~ s:^lib/::);
  822.         local($_) = "$prefix/$striplibpath";
  823.         my($inst) = MY->libscan();
  824.         print "libscan($path) => '$inst'" if ($Verbose >= 2);
  825.         return unless $inst;
  826.         $pm{$path} = $inst;
  827.          }, @{$att{PMLIBDIRS}});
  828.     }
  829.  
  830.     $att{DIR} = [sort keys %dir] unless $att{DIRS};
  831.     $att{XS}  = \%xs             unless $att{XS};
  832.     $att{PM}  = \%pm             unless $att{PM};
  833.     $att{C}   = [sort keys %c]   unless $att{C};
  834.     my(@o_files) = @{$att{C}};
  835.     my($sufx) = $Is_VMS ? '.obj' : '.o';
  836.     $att{O_FILES} = [grep s/\.c$/$sufx/, @o_files] ;
  837.     $att{H}   = [sort keys %h]   unless $att{H};
  838.     $att{PL_FILES} = \%pl_files unless $att{PL_FILES};
  839. }
  840.  
  841.  
  842. sub libscan {
  843.     return '' if m:/RCS/: ; # return undef triggered warnings with $Verbose>=2
  844.     $_;
  845. }
  846.  
  847. sub init_others {    # --- Initialize Other Attributes
  848.     my($key);
  849.     for $key (keys(%Recognized_Att_Keys), keys(%Other_Att_Keys)){
  850.     # avoid warnings for uninitialized vars
  851.     next if exists $att{$key};
  852.     $att{$key} = "";
  853.     }
  854.  
  855.     # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $att{'LIBS'}
  856.     # Lets look at $att{LIBS} carefully: It may be an anon array, a string or
  857.     # undefined. In any case we turn it into an anon array:
  858.     $att{LIBS}=[] unless $att{LIBS};
  859.     $att{LIBS}=[$att{LIBS}] if ref \$att{LIBS} eq SCALAR;
  860.     $att{LD_RUN_PATH} = "";
  861.     foreach ( @{$att{'LIBS'}} ){
  862.     s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
  863.     my(@libs) = MY->extliblist($_);
  864.     if ($libs[0] or $libs[1] or $libs[2]){
  865.         @att{EXTRALIBS, BSLOADLIBS, LDLOADLIBS} = @libs;
  866.         if ($libs[2]) {
  867.         $att{LD_RUN_PATH} = join(":",grep($_=~s/^-L//,split(" ", $libs[2])));
  868.         }
  869.         last;
  870.     }
  871.     }
  872.  
  873.     print STDOUT "CONFIG must be an array ref\n"
  874.     if ($att{CONFIG} and ref $att{CONFIG} ne 'ARRAY');
  875.     $att{CONFIG} = [] unless (ref $att{CONFIG});
  876.     push(@{$att{CONFIG}},
  877.     qw(cc libc mab ldflags lddlflags ccdlflags cccdlflags
  878.        ranlib so dlext dlsrc
  879.     ));
  880.     push(@{$att{CONFIG}}, 'shellflags') if $Config{'shellflags'};
  881.  
  882.     if ($Is_VMS) {
  883.       $att{OBJECT} = '$(BASEEXT).obj' unless $att{OBJECT};
  884.       $att{OBJECT} =~ s/[^,\s]\s+/, /g;
  885.       $att{OBJECT} =~ s/\n+/, /g;
  886.       $att{OBJECT} =~ s#\.o,#\.obj,#;
  887.     } else {
  888.       $att{OBJECT} = '$(BASEEXT).o' unless $att{OBJECT};
  889.       $att{OBJECT} =~ s/\n+/ \\\n\t/g;
  890.     }
  891.     $att{BOOTDEP}  = (-f "$att{BASEEXT}_BS") ? "$att{BASEEXT}_BS" : "";
  892.     $att{LD}       = ($Config{'ld'} || 'ld') unless $att{LD};
  893.     $att{LDFROM} = '$(OBJECT)' unless $att{LDFROM};
  894.     # Sanity check: don't define LINKTYPE = dynamic if we're skipping
  895.     # the 'dynamic' section of MM.  We don't have this problem with
  896.     # 'static', since we either must use it (%Config says we can't
  897.     # use dynamic loading) or the caller asked for it explicitly.
  898.     if (!$att{LINKTYPE}) {
  899.        $att{LINKTYPE} = grep(/dynamic/,@{$att{SKIP} || []})
  900.                         ? 'static'
  901.                         : ($Config{'usedl'} ? 'dynamic' : 'static');
  902.     };
  903.  
  904.     # These get overridden for VMS and maybe some other systems
  905.     $att{NOOP}  = "";
  906.     $att{MAKEFILE} = "Makefile";
  907.     $att{RM_F}  = "rm -f";
  908.     $att{RM_RF} = "rm -rf";
  909.     $att{TOUCH} = "touch";
  910.     $att{CP} = "cp";
  911.     $att{MV} = "mv";
  912.     $att{CHMOD} = "chmod";
  913. }
  914.  
  915.  
  916. sub lsdir{
  917.     my($dir, $regex) = @_;
  918.     local(*DIR, @ls);
  919.     opendir(DIR, $_[0] || ".") or die "opendir: $!";
  920.     @ls = readdir(DIR);
  921.     closedir(DIR);
  922.     @ls = grep(/$regex/, @ls) if $regex;
  923.     @ls;
  924. }
  925.  
  926.  
  927. sub find_perl{
  928.     my($self, $ver, $names, $dirs, $trace) = @_;
  929.     my($name, $dir);
  930.     if ($trace >= 2){
  931.     print "Looking for perl $ver by these names: ";
  932.     print "@$names, ";
  933.     print "in these dirs:";
  934.     print "@$dirs";
  935.     }
  936.     foreach $dir (@$dirs){
  937.     next unless defined $dir; # $att{PERL_SRC} may be undefined
  938.     foreach $name (@$names){
  939.         print "Checking $dir/$name " if ($trace >= 2);
  940.         if ($Is_VMS) {
  941.           $name .= ".exe" unless -x "$dir/$name";
  942.         }
  943.         next unless -x "$dir/$name";
  944.         print "Executing $dir/$name" if ($trace >= 2);
  945.         my($out);
  946.         if ($Is_VMS) {
  947.           my($vmscmd) = 'MCR ' . vmsify("$dir/$name");
  948.           $out = `$vmscmd -e "require $ver; print ""VER_OK\n"""`;
  949.         } else {
  950.           $out = `$dir/$name -e 'require $ver; print "VER_OK\n" ' 2>&1`;
  951.         }
  952.         if ($out =~ /VER_OK/) {
  953.         print "Using PERL=$dir/$name" if $trace;
  954.         return "$dir/$name";
  955.         }
  956.     }
  957.     }
  958.     print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
  959.     0; # false and not empty
  960. }
  961.  
  962.  
  963. sub post_initialize{
  964.     "";
  965. }
  966.  
  967. sub needs_linking {    # Does this module need linking?
  968.     return 1 if $att{OBJECT} or @{$att{C} || []} or $att{MYEXTLIB};
  969.     return 0;
  970. }
  971.  
  972. sub constants {
  973.     my($self) = @_;
  974.     my(@m);
  975.  
  976.     push @m, "
  977. NAME = $att{NAME}
  978. DISTNAME = $att{DISTNAME}
  979. VERSION = $att{VERSION}
  980. VERSION_SYM = $att{VERSION_SYM}
  981.  
  982. # In which directory should we put this extension during 'make'?
  983. # This is typically ./blib.
  984. # (also see INST_LIBDIR and relationship to ROOTEXT)
  985. INST_LIB = $att{INST_LIB}
  986. INST_ARCHLIB = $att{INST_ARCHLIB}
  987. INST_EXE = $att{INST_EXE}
  988.  
  989. # AFS users will want to set the installation directories for
  990. # the final 'make install' early without setting INST_LIB,
  991. # INST_ARCHLIB, and INST_EXE for the testing phase
  992. INSTALLPRIVLIB = $att{INSTALLPRIVLIB}
  993. INSTALLARCHLIB = $att{INSTALLARCHLIB}
  994. INSTALLBIN = $att{INSTALLBIN}
  995.  
  996. # Perl library to use when building the extension
  997. PERL_LIB = $att{PERL_LIB}
  998. PERL_ARCHLIB = $att{PERL_ARCHLIB}
  999. LIBPERL_A = $att{LIBPERL_A}
  1000.  
  1001. MAKEMAKER = \$(PERL_LIB)/ExtUtils/MakeMaker.pm
  1002. MM_VERSION = $ExtUtils::MakeMaker::Version
  1003. ";
  1004.  
  1005.     # Define I_PERL_LIBS to include the required -Ipaths
  1006.     # To be cute we only include PERL_ARCHLIB if different
  1007.  
  1008.     #### Deprecated from Version 4.11: We want to avoid different
  1009.     #### behavior for variables with make(1) and perl(1)
  1010.  
  1011.     # To be portable we add quotes for VMS
  1012.     my(@i_perl_libs) = qw{-I$(PERL_ARCHLIB) -I$(PERL_LIB)};
  1013.     shift(@i_perl_libs) if ($att{PERL_ARCHLIB} eq $att{PERL_LIB});
  1014.     if ($Is_VMS){
  1015.     push @m, "I_PERL_LIBS = \"".join('" "',@i_perl_libs)."\"\n";
  1016.     } else {
  1017.     push @m, "I_PERL_LIBS = ".join(' ',@i_perl_libs)."\n";
  1018.     }
  1019.  
  1020.     push @m, "
  1021. # Where is the perl source code located?
  1022. PERL_SRC = $att{PERL_SRC}\n" if $att{PERL_SRC};
  1023.  
  1024.     push @m, "
  1025. # Perl header files (will eventually be under PERL_LIB)
  1026. PERL_INC = $att{PERL_INC}
  1027. # Perl binaries
  1028. PERL = $att{'PERL'}
  1029. FULLPERL = $att{'FULLPERL'}
  1030. ";
  1031.     push @m, "
  1032. # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
  1033. # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  1034. # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
  1035. FULLEXT = $att{FULLEXT}
  1036. BASEEXT = $att{BASEEXT}
  1037. ROOTEXT = $att{ROOTEXT}
  1038. ";
  1039.     push @m, "
  1040. INC = $att{INC}
  1041. DEFINE = $att{DEFINE}
  1042. OBJECT = $att{OBJECT}
  1043. LDFROM = $att{LDFROM}
  1044. LINKTYPE = $att{LINKTYPE}
  1045.  
  1046. # Handy lists of source code files:
  1047. XS_FILES= ".join(" \\\n\t", sort keys %{$att{XS}})."
  1048. C_FILES = ".join(" \\\n\t", @{$att{C}})."
  1049. O_FILES = ".join(" \\\n\t", @{$att{O_FILES}})."
  1050. H_FILES = ".join(" \\\n\t", @{$att{H}})."
  1051.  
  1052. .SUFFIXES: .xs
  1053.  
  1054. .PRECIOUS: Makefile
  1055.  
  1056. .NO_PARALLEL:
  1057.  
  1058. .PHONY: all config static dynamic test linkext
  1059.  
  1060. # This extension may link to it's own library (see SDBM_File)
  1061. MYEXTLIB = $att{MYEXTLIB}
  1062.  
  1063. # Where is the Config information that we are using/depend on
  1064. CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h
  1065. ";
  1066.  
  1067.     push @m, '
  1068. # Where to put things:
  1069. INST_LIBDIR     = $(INST_LIB)$(ROOTEXT)
  1070. INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
  1071.  
  1072. INST_AUTODIR      = $(INST_LIB)/auto/$(FULLEXT)
  1073. INST_ARCHAUTODIR  = $(INST_ARCHLIB)/auto/$(FULLEXT)
  1074. ';
  1075.  
  1076.     if ($self->needs_linking) {
  1077.     push @m, '
  1078. INST_STATIC  = $(INST_ARCHAUTODIR)/$(BASEEXT).a
  1079. INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(BASEEXT).$(DLEXT)
  1080. INST_BOOT    = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
  1081. ';
  1082.     } else {
  1083.     push @m, '
  1084. INST_STATIC  =
  1085. INST_DYNAMIC =
  1086. INST_BOOT    =
  1087. ';
  1088.     }
  1089.  
  1090.     push @m, '
  1091. INST_PM = '.join(" \\\n\t", sort values %{$att{PM}}).'
  1092. ';
  1093.  
  1094.     join('',@m);
  1095. }
  1096.  
  1097. $Const_cccmd=0; # package global
  1098.  
  1099. sub const_cccmd{
  1100.     my($self,$libperl)=@_;
  1101.     $libperl or $libperl = $att{LIBPERL_A} || "libperl.a" ;
  1102.     # This is implemented in the same manner as extliblist,
  1103.     # e.g., do both and compare results during the transition period.
  1104.     my($cc,$ccflags,$optimize,$large,$split, $shflags)
  1105.     = @Config{qw(cc ccflags optimize large split shellflags)};
  1106.     $shflags = '' unless $shflags;
  1107.     my($prog, $old, $uc, $perltype);
  1108.  
  1109.     unless ($Const_cccmd++){
  1110.     chop($old = `cd $att{PERL_SRC}; sh $shflags ./cflags $libperl $att{BASEEXT}.c`)
  1111.       if $att{PERL_SRC};
  1112.     $Const_cccmd++; # shut up typo warning
  1113.     }
  1114.  
  1115.     my(%map) =  (
  1116.         D =>   '-DDEBUGGING',
  1117.         E =>   '-DEMBED',
  1118.         DE =>  '-DDEBUGGING -DEMBED',
  1119.         M =>   '-DEMBED -DMULTIPLICITY',
  1120.         DM =>  '-DDEBUGGING -DEMBED -DMULTIPLICITY',
  1121.         );
  1122.  
  1123.     if ($libperl =~ /libperl(\w*)\.a/){
  1124.     $uc = uc($1);
  1125.     } else {
  1126.     $uc = ""; # avoid warning
  1127.     }
  1128.     $perltype = $map{$uc} ? $map{$uc} : "";
  1129.  
  1130.     if ($uc =~ /^D/) {
  1131.     $optdebug = "-g";
  1132.     }
  1133.  
  1134.  
  1135.     my($name);
  1136.     ( $name = $att{NAME} . "_cflags" ) =~ s/:/_/g ;
  1137.     if ($prog = $Config{$name}) {
  1138.     # Expand hints for this extension via the shell
  1139.     print STDOUT "Processing $name hint:\n" if $Verbose;
  1140.     my(@o)=`cc=\"$cc\"
  1141.       ccflags=\"$ccflags\"
  1142.       optimize=\"$optimize\"
  1143.       perltype=\"$perltype\"
  1144.       optdebug=\"$optdebug\"
  1145.       large=\"$large\"
  1146.       split=\"$split\"
  1147.       eval '$prog'
  1148.       echo cc=\$cc
  1149.       echo ccflags=\$ccflags
  1150.       echo optimize=\$optimize
  1151.       echo perltype=\$perltype
  1152.       echo optdebug=\$optdebug
  1153.       echo large=\$large
  1154.       `;
  1155.     my(%cflags,$line);
  1156.     foreach $line (@o){
  1157.         chomp $line;
  1158.         if ($line =~ /(.*?)=\s*(.*)\s*$/){
  1159.         $cflags{$1} = $2;
  1160.         print STDOUT "    $1 = $2" if $Verbose;
  1161.         } else {
  1162.         print STDOUT "Unrecognised result from hint: '$line'\n";
  1163.         }
  1164.     }
  1165.     (    $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split)=@cflags{
  1166.           qw( cc  ccflags  perltype  optdebug  optimize  large  split )};
  1167.     }
  1168.  
  1169.     if ($optdebug) {
  1170.     $optimize = $optdebug;
  1171.     }
  1172.  
  1173.     my($new) = "$cc -c $ccflags $optimize $perltype $large $split";
  1174.     $new =~ s/^\s+//; $new =~ s/\s+/ /g; $new =~ s/\s+$//;
  1175.     if (defined($old)){
  1176.     $old =~ s/^\s+//; $old =~ s/\s+/ /g; $old =~ s/\s+$//;
  1177.     if ($new ne $old) {
  1178.         print STDOUT "Warning (non-fatal): cflags evaluation in "
  1179.           ."MakeMaker ($ExtUtils::MakeMaker::Version) "
  1180.           ."differs from shell output\n"
  1181.           ."   package: $att{NAME}\n"
  1182.           ."   old: $old\n"
  1183.           ."   new: $new\n"
  1184.           ."   Using 'old' set.\n"
  1185.           . Config::myconfig()
  1186.           ."\nPlease send these details to perl5-porters\@nicoh.com\n";
  1187.     }
  1188.     }
  1189.     my($cccmd)=($old) ? $old : $new;
  1190.     $cccmd =~ s/^\s*\Q$Config{'cc'}\E\s/\$(CC) /;
  1191.     "CCCMD = $cccmd\n";
  1192. }
  1193.  
  1194.  
  1195. # --- Constants Sections ---
  1196.  
  1197. sub const_config{
  1198.     my(@m,$m);
  1199.     push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
  1200.     my(%once_only);
  1201.     foreach $m (@{$att{'CONFIG'}}){
  1202.     next if $once_only{$m};
  1203.     print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
  1204.         unless exists $Config{$m};
  1205.     push @m, "\U$m\E = $Config{$m}\n";
  1206.     $once_only{$m} = 1;
  1207.     }
  1208.     join('', @m);
  1209. }
  1210.  
  1211.  
  1212. sub const_loadlibs{
  1213.     "
  1214. # $att{NAME} might depend on some other libraries:
  1215. # (These comments may need revising:)
  1216. #
  1217. # Dependent libraries can be linked in one of three ways:
  1218. #
  1219. #  1.  (For static extensions) by the ld command when the perl binary
  1220. #      is linked with the extension library. See EXTRALIBS below.
  1221. #
  1222. #  2.  (For dynamic extensions) by the ld command when the shared
  1223. #      object is built/linked. See LDLOADLIBS below.
  1224. #
  1225. #  3.  (For dynamic extensions) by the DynaLoader when the shared
  1226. #      object is loaded. See BSLOADLIBS below.
  1227. #
  1228. # EXTRALIBS =    List of libraries that need to be linked with when
  1229. #        linking a perl binary which includes this extension
  1230. #        Only those libraries that actually exist are included.
  1231. #        These are written to a file and used when linking perl.
  1232. #
  1233. # LDLOADLIBS =    List of those libraries which can or must be linked into
  1234. #        the shared library when created using ld. These may be
  1235. #        static or dynamic libraries.
  1236. #        LD_RUN_PATH is a colon separated list of the directories
  1237. #        in LDLOADLIBS. It is passed as an environment variable to
  1238. #        the process that links the shared library.
  1239. #
  1240. # BSLOADLIBS =    List of those libraries that are needed but can be
  1241. #        linked in dynamically at run time on this platform.
  1242. #        SunOS/Solaris does not need this because ld records
  1243. #        the information (from LDLOADLIBS) into the object file.
  1244. #        This list is used to create a .bs (bootstrap) file.
  1245. #
  1246. EXTRALIBS  = $att{'EXTRALIBS'}
  1247. LDLOADLIBS = $att{'LDLOADLIBS'}
  1248. BSLOADLIBS = $att{'BSLOADLIBS'}
  1249. LD_RUN_PATH= $att{'LD_RUN_PATH'}
  1250. ";
  1251. }
  1252.  
  1253.  
  1254. # --- Tool Sections ---
  1255.  
  1256. sub tool_autosplit{
  1257.     my($self, %attribs) = @_;
  1258.     my($asl) = "";
  1259.     $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
  1260.     q{
  1261. # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
  1262. AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
  1263. };
  1264. }
  1265.  
  1266.  
  1267. sub tool_xsubpp{
  1268.     my($xsdir)  = '$(PERL_LIB)/ExtUtils';
  1269.     # drop back to old location if xsubpp is not in new location yet
  1270.     $xsdir = '$(PERL_SRC)/ext' unless (-f "$att{PERL_LIB}/ExtUtils/xsubpp");
  1271.     my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
  1272.     push(@tmdeps, "typemap") if -f "typemap";
  1273.     my(@tmargs) = map("-typemap $_", @tmdeps);
  1274.     "
  1275. XSUBPPDIR = $xsdir
  1276. XSUBPP = \$(XSUBPPDIR)/xsubpp
  1277. XSUBPPDEPS = @tmdeps
  1278. XSUBPPARGS = @tmargs
  1279. ";
  1280. };
  1281.  
  1282.  
  1283. sub tools_other{
  1284.     "
  1285. SHELL = /bin/sh
  1286. LD = $att{LD}
  1287. TOUCH = $att{TOUCH}
  1288. CP = $att{CP}
  1289. MV = $att{MV}
  1290. RM_F  = $att{RM_F}
  1291. RM_RF = $att{RM_RF}
  1292. CHMOD = $att{CHMOD}
  1293. ".q{
  1294. # The following is a portable way to say mkdir -p
  1295. MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){ next if -d $$p; my(@p); foreach(split(/\//,$$p)){ push(@p,$$_); next if -d "@p/"; print "mkdir @p"; mkdir("@p",0777)||die $$! }} exit 0;'
  1296. };
  1297. }
  1298.  
  1299.  
  1300. sub post_constants{
  1301.     "";
  1302. }
  1303.  
  1304. sub macro {
  1305.     my($self,%attribs) = @_;
  1306.     my(@m,$key,$val);
  1307.     while (($key,$val) = each %attribs){
  1308.     push @m, "$key = $val\n";
  1309.     }
  1310.     join "", @m;
  1311. }
  1312.  
  1313. sub pasthru {
  1314.     my(@m,$key);
  1315.     # It has to be considered carefully, which variables are apt 
  1316.     # to be passed through, e.g. ALL RELATIV DIRECTORIES are
  1317.     # not suited for PASTHRU to subdirectories.
  1318.     # Moreover: No directories at all have a chance, because we
  1319.     # don't know yet, if the directories are absolute or relativ
  1320.  
  1321.     # PASTHRU2 is a conservative approach, that hardly changed
  1322.     # MakeMaker between version 4.086 and 4.09.
  1323.  
  1324.     # PASTHRU1 is a revolutionary approach :), it cares for having
  1325.     # a prepended "../" whenever runsubdirpl is called, but only
  1326.     # for the three crucial INST_* directories.
  1327.  
  1328.     my(@pasthru1,@pasthru2); # 1 for runsubdirpl, 2 for the rest
  1329.  
  1330.     foreach $key (qw(INST_LIB INST_ARCHLIB INST_EXE)){
  1331.     push @pasthru1, "$key=\"\$($key)\"";
  1332.     }
  1333.  
  1334.     foreach $key (qw(INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN LIBPERL_A LINKTYPE)){
  1335.     push @pasthru1, "$key=\"\$($key)\"";
  1336.     push @pasthru2, "$key=\"\$($key)\"";
  1337.     }
  1338.  
  1339.     push @m, "\nPASTHRU1 = ", join ("\\\n\t", @pasthru1), "\n";
  1340.     push @m, "\nPASTHRU2 = ", join ("\\\n\t", @pasthru2), "\n";
  1341.     join "", @m;
  1342. }
  1343.  
  1344. # --- Translation Sections ---
  1345.  
  1346. sub c_o {
  1347.     my(@m);
  1348.     push @m, '
  1349. .c.o:
  1350.     $(CCCMD) $(MAB) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
  1351. ';
  1352.     join "", @m;
  1353. }
  1354.  
  1355. sub xs_c {
  1356.     '
  1357. .xs.c:
  1358.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
  1359. ';
  1360. }
  1361.  
  1362. sub xs_o {    # many makes are too dumb to use xs_c then c_o
  1363.     '
  1364. .xs.o:
  1365.     $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
  1366.     $(CCCMD) $(MAB) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
  1367. ';
  1368. }
  1369.  
  1370.  
  1371. # --- Target Sections ---
  1372.  
  1373. sub top_targets{
  1374.     my(@m);
  1375.     push @m, '
  1376. all ::    config linkext $(INST_PM)
  1377. '.$att{NOOP}.'
  1378.  
  1379. config :: '.$att{MAKEFILE}.' $(INST_LIBDIR)/.exists $(INST_ARCHAUTODIR)/.exists Version_check
  1380. ';
  1381.  
  1382.     push @m, MM->dir_target('$(INST_LIBDIR)', '$(INST_ARCHAUTODIR)', '$(INST_EXE)');
  1383.  
  1384.     push @m, '
  1385. $(O_FILES): $(H_FILES)
  1386. ' if @{$att{O_FILES} || []} && @{$att{H} || []};
  1387.  
  1388.     push @m, q{
  1389. help:
  1390.     $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::MakeMaker "&help"; &help;'
  1391. };
  1392.  
  1393.     push @m, q{
  1394. Version_check:
  1395.     @$(PERL) -I$(PERL_LIB) -e 'use ExtUtils::MakeMaker qw($$Version &Version_check);' \
  1396.         -e '&Version_check($(MM_VERSION))'
  1397. };
  1398.  
  1399.     join('',@m);
  1400. }
  1401.  
  1402. sub linkext {
  1403.     my($self, %attribs) = @_;
  1404.     # LINKTYPE => static or dynamic or ''
  1405.     my($linktype) = defined $attribs{LINKTYPE} ? 
  1406.       $attribs{LINKTYPE} : '$(LINKTYPE)';
  1407.     "
  1408. linkext :: $linktype
  1409. $att{NOOP}
  1410. ";
  1411. }
  1412.  
  1413. sub dlsyms {
  1414.     my($self,%attribs) = @_;
  1415.  
  1416.     return '' if ($Config{'osname'} ne 'aix');
  1417.  
  1418.     my($funcs) = $attribs{DL_FUNCS} || $att{DL_FUNCS} || {};
  1419.     my($vars)  = $attribs{DL_VARS} || $att{DL_VARS} || [];
  1420.     my(@m);
  1421.  
  1422.     push(@m,"
  1423. dynamic :: $att{BASEEXT}.exp
  1424.  
  1425. ") unless $skip{'dynamic'};
  1426.  
  1427.     push(@m,"
  1428. static :: $att{BASEEXT}.exp
  1429.  
  1430. ") unless $skip{'static'};
  1431.  
  1432.     push(@m,"
  1433. $att{BASEEXT}.exp: Makefile.PL
  1434. ",'    $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::MakeMaker qw(&mksymlists); \\
  1435.     &mksymlists(DL_FUNCS => ',
  1436.     %$funcs ? neatvalue($funcs) : '""',', DL_VARS => ',
  1437.     @$vars  ? neatvalue($vars)  : '""', ", NAME => \"$att{NAME}\")'
  1438. ");
  1439.  
  1440.     join('',@m);
  1441. }
  1442.  
  1443. # --- Dynamic Loading Sections ---
  1444.  
  1445. sub dynamic {
  1446.     '
  1447. # $(INST_PM) has been moved to the all: target.
  1448. # It remains here for awhile to allow for old usage: "make dynamic"
  1449. dynamic :: '.$att{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
  1450. '.$att{NOOP}.'
  1451. ';
  1452. }
  1453.  
  1454. sub dynamic_bs {
  1455.     my($self, %attribs) = @_;
  1456.     return '' unless $self->needs_linking;
  1457.     '
  1458. BOOTSTRAP = '."$att{BASEEXT}.bs".'
  1459.  
  1460. # As Mkbootstrap might not write a file (if none is required)
  1461. # we use touch to prevent make continually trying to remake it.
  1462. # The DynaLoader only reads a non-empty file.
  1463. $(BOOTSTRAP): '."$att{MAKEFILE} $att{BOOTDEP}".'
  1464.     @ echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
  1465.     @ $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
  1466.         -e \'use ExtUtils::Mkbootstrap;\' \
  1467.         -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\'
  1468.     @ $(TOUCH) $(BOOTSTRAP)
  1469.     $(CHMOD) 644 $@
  1470.     @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
  1471.  
  1472. $(INST_BOOT): $(BOOTSTRAP)
  1473.     @ '.$att{RM_RF}.' $(INST_BOOT)
  1474.     -'.$att{CP}.' $(BOOTSTRAP) $(INST_BOOT)
  1475.     $(CHMOD) 644 $@
  1476.     @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
  1477. ';
  1478. }
  1479.  
  1480.  
  1481. sub dynamic_lib {
  1482.     my($self, %attribs) = @_;
  1483.     my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
  1484.     my($armaybe) = $attribs{ARMAYBE} || $att{ARMAYBE} || ":";
  1485.     my($ldfrom) = '$(LDFROM)';
  1486.     return '' unless $self->needs_linking;
  1487.     my($osname) = $Config{'osname'};
  1488.     $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':');
  1489.     my(@m);
  1490.     push(@m,'
  1491. # This section creates the dynamically loadable $(INST_DYNAMIC)
  1492. # from $(OBJECT) and possibly $(MYEXTLIB).
  1493. ARMAYBE = '.$armaybe.'
  1494. OTHERLDFLAGS = '.$otherldflags.'
  1495.  
  1496. $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
  1497. ');
  1498.     if ($armaybe ne ':'){
  1499.     $ldfrom = "tmp.a";
  1500.     push(@m,'    $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
  1501.     push(@m,'    $(RANLIB) '."$ldfrom\n");
  1502.     }
  1503.     $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf');
  1504.     push(@m,'    LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
  1505.             ' $(OTHERLDFLAGS) $(MAB) $(MYEXTLIB) $(LDLOADLIBS)');
  1506.     push @m, '
  1507.     $(CHMOD) 755 $@
  1508.     @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
  1509. ';
  1510.  
  1511.     push @m, MM->dir_target('$(INST_ARCHAUTODIR)');
  1512.     join('',@m);
  1513. }
  1514.  
  1515.  
  1516. # --- Static Loading Sections ---
  1517.  
  1518. sub static {
  1519.     '
  1520. # $(INST_PM) has been moved to the all: target.
  1521. # It remains here for awhile to allow for old usage: "make static"
  1522. static :: '.$att{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
  1523. '.$att{NOOP}.'
  1524. ';
  1525. }
  1526.  
  1527. sub static_lib{
  1528.     my($self) = @_;
  1529.     return '' unless $self->needs_linking;
  1530.     my(@m);
  1531.     push(@m, <<'END');
  1532. $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
  1533. END
  1534.     # If this extension has it's own library (eg SDBM_File)
  1535.     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
  1536.     push(@m, "    $att{CP} \$(MYEXTLIB) \$\@\n") if $att{MYEXTLIB};
  1537.  
  1538.     push(@m, <<'END');
  1539.     ar cr $@ $(OBJECT) && $(RANLIB) $@
  1540.     @echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
  1541.     $(CHMOD) 755 $@
  1542.     @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
  1543. END
  1544.  
  1545. # Old mechanism - still available:
  1546.  
  1547.     push(@m, <<'END') if $att{PERL_SRC};
  1548.     @ echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
  1549. END
  1550.  
  1551.     push @m, MM->dir_target('$(INST_ARCHAUTODIR)');
  1552.     join('', "\n",@m);
  1553. }
  1554.  
  1555.  
  1556. sub installpm {
  1557.     my($self, %attribs) = @_;
  1558.     # By default .pm files are split into the architecture independent
  1559.     # library. This is a good thing. If a specific module requires that
  1560.     # it's .pm files are split into the architecture specific library
  1561.     # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
  1562.     # Note that installperl currently interferes with this (Config.pm)
  1563.     # User can disable split by saying: installpm => {SPLITLIB=>''}
  1564.     my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
  1565.     $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
  1566.     my(@m, $dist);
  1567.     foreach $dist (sort keys %{$att{PM}}){
  1568.     my($inst) = $att{PM}->{$dist};
  1569.     push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
  1570.     push(@m, MY->installpm_x($dist, $inst, $splitlib));
  1571.     push(@m, "\n");
  1572.     }
  1573.     join('', @m);
  1574. }
  1575.  
  1576. sub installpm_x { # called by installpm per file
  1577.     my($self, $dist, $inst, $splitlib) = @_;
  1578.     warn "Warning: Most probably 'make' will have problems processing this file: $inst\n"
  1579.     if $inst =~ m![:#]!;
  1580.     my($instdir) = $inst =~ m|(.*)/|;
  1581.     my(@m);
  1582.     push(@m,"
  1583. $inst: $dist $att{MAKEFILE} $instdir/.exists
  1584. ".'    @ '.$att{RM_F}.' $@
  1585.     '."$att{CP} $dist".' $@
  1586.     $(CHMOD) 644 $@
  1587.     @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
  1588. ');
  1589.     push(@m, "\t\@\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
  1590.     if ($splitlib and $inst =~ m/\.pm$/);
  1591.  
  1592.     push @m, MM->dir_target($instdir);
  1593.     join('', @m);
  1594. }
  1595.  
  1596. sub processPL {
  1597.     return "" unless $att{PL_FILES};
  1598.     my(@m, $plfile);
  1599.     foreach $plfile (sort keys %{$att{PL_FILES}}) {
  1600.     push @m, "
  1601. all :: $att{PL_FILES}->{$plfile}
  1602.  
  1603. $att{PL_FILES}->{$plfile} :: $plfile
  1604.     \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
  1605. ";
  1606.     }
  1607.     join "", @m;
  1608. }
  1609.  
  1610. sub installbin {
  1611.     return "" unless $att{EXE_FILES} && ref $att{EXE_FILES} eq "ARRAY";
  1612.     my(@m, $from, $to, %fromto, @to);
  1613.     for $from (@{$att{EXE_FILES}}) {
  1614.     local($_)= '$(INST_EXE)/' . basename($from);
  1615.     $to = MY->exescan();
  1616.     print "exescan($from) => '$to'" if ($Verbose >=2);
  1617.     $fromto{$from}=$to;
  1618.     }
  1619.     @to   = values %fromto;
  1620.     push(@m, "
  1621. EXE_FILES = @{$att{EXE_FILES}}
  1622.  
  1623. all :: @to
  1624.  
  1625. realclean ::
  1626.     $att{RM_F} @to
  1627. ");
  1628.  
  1629.     while (($from,$to) = each %fromto) {
  1630.     my $todir = dirname($to);
  1631.     push @m, "
  1632. $to: $from $att{MAKEFILE} $todir/.exists
  1633.     $att{CP} $from $to
  1634. ";
  1635.     }
  1636.     join "", @m;
  1637. }
  1638.  
  1639. sub exescan {
  1640.     $_;
  1641. }
  1642. # --- Sub-directory Sections ---
  1643.  
  1644. sub subdirs {
  1645.     my(@m);
  1646.     # This method provides a mechanism to automatically deal with
  1647.     # subdirectories containing further Makefile.PL scripts.
  1648.     # It calls the subdir_x() method for each subdirectory.
  1649.     foreach(grep -d, &lsdir()){
  1650.     next if /^\./;
  1651.     next unless -f "$_/Makefile\.PL" ;
  1652.     print "Including $_ subdirectory" if ($Verbose);
  1653.     push(@m, MY->subdir_x($_));
  1654.     }
  1655.     if (@m){
  1656.     unshift(@m, "
  1657. # The default clean, realclean and test targets in this Makefile
  1658. # have automatically been given entries for each subdir.
  1659.  
  1660. all :: subdirs
  1661. ");
  1662.     } else {
  1663.     push(@m, "\n# none")
  1664.     }
  1665.     join('',@m);
  1666. }
  1667.  
  1668. sub runsubdirpl{    # Experimental! See subdir_x section
  1669.     my($self,$subdir) = @_;
  1670.     chdir($subdir) or die "chdir($subdir): $!";
  1671.     ExtUtils::MakeMaker::check_hints();
  1672.     package main;
  1673.     require "Makefile.PL";
  1674. }
  1675.  
  1676. sub subdir_x {
  1677.     my($self, $subdir) = @_;
  1678.     my(@m);
  1679.     # The intention is that the calling Makefile.PL should define the
  1680.     # $(SUBDIR_MAKEFILE_PL_ARGS) make macro to contain whatever
  1681.     # information needs to be passed down to the other Makefile.PL scripts.
  1682.     # If this does not suit your needs you'll need to write your own
  1683.     # MY::subdir_x() method to override this one.
  1684.     qq{
  1685. config :: $subdir/$att{MAKEFILE}
  1686.     cd $subdir && \$(MAKE) config \$(PASTHRU2) \$(SUBDIR_MAKEFILE_PL_ARGS)
  1687.  
  1688. $subdir/$att{MAKEFILE}: $subdir/Makefile.PL \$(CONFIGDEP)
  1689. }.'    @echo "Rebuilding $@ ..."
  1690.     @$(PERL) -I"$(PERL_ARCHLIB)" -I"$(PERL_LIB)" \\
  1691.         -e "use ExtUtils::MakeMaker; MM->runsubdirpl(qw('.$subdir.'))" \\
  1692.         $(PASTHRU1) $(SUBDIR_MAKEFILE_PL_ARGS)
  1693.     @echo "Rebuild of $@ complete."
  1694. '.qq{
  1695.  
  1696. subdirs ::
  1697.     cd $subdir && \$(MAKE) all \$(PASTHRU2)
  1698.  
  1699. };
  1700. }
  1701.  
  1702.  
  1703. # --- Cleanup and Distribution Sections ---
  1704.  
  1705. sub clean {
  1706.     my($self, %attribs) = @_;
  1707.     my(@m);
  1708.     push(@m, '
  1709. # Delete temporary files but do not touch installed files. We don\'t delete
  1710. # the Makefile here so a later make realclean still has a makefile to use.
  1711.  
  1712. clean ::
  1713. ');
  1714.     # clean subdirectories first
  1715.     push(@m, map("\t-cd $_ && test -f $att{MAKEFILE} && \$(MAKE) clean\n",@{$att{DIR}}));
  1716.     my(@otherfiles) = values %{$att{XS}}; # .c files from *.xs files
  1717.     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
  1718.     push(@otherfiles, "./blib");
  1719.     push(@m, "    -$att{RM_RF} *~ t/*~ *.o *.a mon.out core so_locations "
  1720.             ."\$(BOOTSTRAP) \$(BASEEXT).bso \$(BASEEXT).exp @otherfiles\n");
  1721.     # See realclean and ext/utils/make_ext for usage of Makefile.old
  1722.     push(@m, "    -$att{MV} $att{MAKEFILE} $att{MAKEFILE}.old 2>/dev/null\n");
  1723.     push(@m, "    $attribs{POSTOP}\n")   if $attribs{POSTOP};
  1724.     join("", @m);
  1725. }
  1726.  
  1727. sub realclean {
  1728.     my($self, %attribs) = @_;
  1729.     my(@m);
  1730.     push(@m,'
  1731. # Delete temporary files (via clean) and also delete installed files
  1732. realclean purge ::  clean
  1733. ');
  1734.     # realclean subdirectories first (already cleaned)
  1735.     my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
  1736.     foreach(@{$att{DIR}}){
  1737.     push(@m, sprintf($sub,$_,"$att{MAKEFILE}.old","-f $att{MAKEFILE}.old"));
  1738.     push(@m, sprintf($sub,$_,"$att{MAKEFILE}",''));
  1739.     }
  1740.     push(@m, "    $att{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
  1741.     push(@m, "    $att{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
  1742.     push(@m, "    $att{RM_F} \$(INST_STATIC) \$(INST_PM)\n");
  1743.     my(@otherfiles) = ($att{MAKEFILE}, 
  1744.                "$att{MAKEFILE}.old"); # Makefiles last
  1745.     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
  1746.     push(@m, "    $att{RM_RF} @otherfiles\n") if @otherfiles;
  1747.     push(@m, "    $attribs{POSTOP}\n")       if $attribs{POSTOP};
  1748.     join("", @m);
  1749. }
  1750.  
  1751.  
  1752. sub dist {
  1753.     my($self, %attribs) = @_;
  1754.     my(@m);
  1755.     # VERSION should be sanitised before use as a file name
  1756.     if ($attribs{TARNAME}){
  1757.     print STDOUT "Error (fatal): Attribute TARNAME for target dist is deprecated
  1758. Please use DISTNAME and VERSION";
  1759.     }
  1760.     my($name)     = $attribs{NAME}     || '$(DISTNAME)-$(VERSION)';            
  1761.     my($tar)      = $attribs{TAR}      || 'tar';        # eg /usr/bin/gnutar   
  1762.     my($tarflags) = $attribs{TARFLAGS} || 'cvf';                               
  1763.     my($compress) = $attribs{COMPRESS} || 'compress';   # eg gzip              
  1764.     my($suffix)   = $attribs{SUFFIX}   || 'Z';          # eg gz                
  1765.     my($shar)     = $attribs{SHAR}     || 'shar';       # eg "shar --gzip"     
  1766.     my($preop)    = $attribs{PREOP}    || '@ :';         # eg update MANIFEST   
  1767.     my($postop)   = $attribs{POSTOP}   || '@ :';         # eg remove the distdir
  1768.     my($ci)       = $attribs{CI}       || 'ci -u';
  1769.     my($rcs)      = $attribs{RCS}      || 'rcs -Nv$(VERSION_SYM):';
  1770.     my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
  1771.  
  1772.     push @m, "
  1773. TAR  = $tar
  1774. TARFLAGS = $tarflags
  1775. COMPRESS = $compress
  1776. SUFFIX = $suffix
  1777. SHAR = $shar
  1778. PREOP = $preop
  1779. POSTOP = $postop
  1780. CI = $ci
  1781. RCS = $rcs
  1782. DIST_DEFAULT = $dist_default
  1783. ";
  1784.  
  1785.     push @m, q{
  1786. distclean :: realclean distcheck
  1787.  
  1788. distcheck :
  1789.     $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\
  1790.         -e 'fullcheck();'
  1791.  
  1792. manifest :
  1793.     $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\
  1794.         -e 'mkmanifest();'
  1795.  
  1796. dist : $(DIST_DEFAULT)
  1797.  
  1798. tardist : $(DISTNAME)-$(VERSION).tar.$(SUFFIX)
  1799.  
  1800. $(DISTNAME)-$(VERSION).tar.$(SUFFIX) : distdir
  1801.     $(PREOP)
  1802.     $(TAR) $(TARFLAGS) $(DISTNAME)-$(VERSION).tar $(DISTNAME)-$(VERSION)
  1803.     $(COMPRESS) $(DISTNAME)-$(VERSION).tar
  1804.     $(RM_RF) $(DISTNAME)-$(VERSION)
  1805.     $(POSTOP)
  1806.  
  1807. uutardist : $(DISTNAME)-$(VERSION).tar.$(SUFFIX)
  1808.     uuencode $(DISTNAME)-$(VERSION).tar.$(SUFFIX) \\
  1809.         $(DISTNAME)-$(VERSION).tar.$(SUFFIX) > \\
  1810.         $(DISTNAME)-$(VERSION).tar.$(SUFFIX).uu
  1811.  
  1812. shdist : distdir
  1813.     $(PREOP)
  1814.     $(SHAR) $(DISTNAME)-$(VERSION) > $(DISTNAME)-$(VERSION).shar
  1815.     $(RM_RF) $(DISTNAME)-$(VERSION)
  1816.     $(POSTOP)
  1817.  
  1818. distdir :
  1819.     $(RM_RF) $(DISTNAME)-$(VERSION)
  1820.     $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "/mani/";' \\
  1821.         -e 'manicopy(maniread(),"$(DISTNAME)-$(VERSION)");'
  1822.  
  1823.  
  1824. ci :
  1825.     $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\
  1826.         -e '@all = keys %{maniread()};' \\
  1827.         -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
  1828.         -e 'print("Executing $(RCS) ...\n"); system("$(RCS) @all");'
  1829.  
  1830. };
  1831.     join "", @m;
  1832. }
  1833.  
  1834.  
  1835. # --- Test and Installation Sections ---
  1836.  
  1837. sub test {
  1838.     my($self, %attribs) = @_;
  1839.     my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
  1840.     my(@m);
  1841.     push(@m,"
  1842. TEST_VERBOSE=0
  1843. TEST_TYPE=test_$att{LINKTYPE}
  1844.  
  1845. test :: \$(TEST_TYPE)
  1846. ");
  1847.     push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) test \$(PASTHRU2)\n",
  1848.          @{$att{DIR}}));
  1849.     push(@m, "\t\@echo 'No tests defined for \$(NAME) extension.'\n")
  1850.     unless $tests or -f "test.pl" or @{$att{DIR}};
  1851.     push(@m, "\n");
  1852.  
  1853.     push(@m, "test_dynamic :: all\n");
  1854.     push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
  1855.     push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
  1856.     push(@m, "\n");
  1857.  
  1858.     push(@m, "test_static :: all \$(MAP_TARGET)\n");
  1859.     push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
  1860.     push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
  1861.     push(@m, "\n");
  1862.  
  1863.     join("", @m);
  1864. }
  1865.  
  1866. sub test_via_harness {
  1867.     my($self, $perl, $tests) = @_;
  1868.     "\t$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";
  1869. }
  1870.  
  1871. sub test_via_script {
  1872.     my($self, $perl, $script) = @_;
  1873.     "\t$perl".' -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
  1874. ';
  1875. }
  1876.  
  1877.  
  1878. sub install {
  1879.     my($self, %attribs) = @_;
  1880.     my(@m);
  1881.     push @m, q{
  1882. doc_install ::
  1883.     @ echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
  1884.     @ $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB)  \\
  1885.         -e "use ExtUtils::MakeMaker; MM->writedoc('Module', '$(NAME)', \\
  1886.         'LINKTYPE=$(LINKTYPE)', 'VERSION=$(VERSION)', \\
  1887.         'EXE_FILES=$(EXE_FILES)')" >> $(INSTALLARCHLIB)/perllocal.pod
  1888. };
  1889.  
  1890.     push(@m, "
  1891. install :: pure_install doc_install
  1892.  
  1893. pure_install ::
  1894. ");
  1895.     # install subdirectories first
  1896.     push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) install\n",
  1897.          @{$att{DIR}}));
  1898.  
  1899.     push(@m, "\t\@\$(PERL) -e 'foreach (\@ARGV){die qq{You do not have permissions to install into \$\$_\\n} unless -w \$\$_}' \$(INSTALLPRIVLIB) \$(INSTALLARCHLIB)
  1900.     : perl5.000 and MM pre 3.8 autosplit into INST_ARCHLIB, we delete these old files here
  1901.     $att{RM_F} \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.al
  1902.     $att{RM_F} \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.ix
  1903.     \$(MAKE) INST_LIB=\$(INSTALLPRIVLIB) INST_ARCHLIB=\$(INSTALLARCHLIB) INST_EXE=\$(INSTALLBIN)
  1904.     \@\$(PERL) -i.bak -lne 'print unless \$\$seen{\$\$_}++' \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/.packlist
  1905. ");
  1906.  
  1907.     push @m, '
  1908. #### UNINSTALL IS STILL EXPERIMENTAL ####
  1909. uninstall ::
  1910. ';
  1911.  
  1912.     push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) uninstall\n",
  1913.          @{$att{DIR}}));
  1914.     push @m, "\t".'$(RM_RF) `cat $(INSTALLARCHLIB)/auto/$(FULLEXT)/.packlist`
  1915. ';
  1916.  
  1917.     join("",@m);
  1918. }
  1919.  
  1920. sub force {
  1921.     '# Phony target to force checking subdirectories.
  1922. FORCE:
  1923. ';
  1924. }
  1925.  
  1926.  
  1927. sub perldepend {
  1928.     my(@m);
  1929.     push(@m,'
  1930. PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
  1931.     $(PERL_INC)/XSUB.h    $(PERL_INC)/av.h    $(PERL_INC)/cop.h \
  1932.     $(PERL_INC)/cv.h    $(PERL_INC)/dosish.h    $(PERL_INC)/embed.h \
  1933.     $(PERL_INC)/form.h    $(PERL_INC)/gv.h    $(PERL_INC)/handy.h \
  1934.     $(PERL_INC)/hv.h    $(PERL_INC)/keywords.h    $(PERL_INC)/mg.h \
  1935.     $(PERL_INC)/op.h    $(PERL_INC)/opcode.h    $(PERL_INC)/patchlevel.h \
  1936.     $(PERL_INC)/perl.h    $(PERL_INC)/perly.h    $(PERL_INC)/pp.h \
  1937.     $(PERL_INC)/proto.h    $(PERL_INC)/regcomp.h    $(PERL_INC)/regexp.h \
  1938.     $(PERL_INC)/scope.h    $(PERL_INC)/sv.h    $(PERL_INC)/unixish.h \
  1939.     $(PERL_INC)/util.h    $(PERL_INC)/config.h
  1940.  
  1941. ');
  1942.  
  1943.     push @m, '
  1944. $(OBJECT) : $(PERL_HDRS)
  1945. ' if $att{OBJECT};
  1946.  
  1947.     push(@m,'
  1948. # Check for unpropogated config.sh changes. Should never happen.
  1949. # We do NOT just update config.h because that is not sufficient.
  1950. # An out of date config.h is not fatal but complains loudly!
  1951. $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
  1952.     -@echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
  1953.  
  1954. $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
  1955.     @echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
  1956.     cd $(PERL_SRC) && $(MAKE) lib/Config.pm
  1957. ') if $att{PERL_SRC};
  1958.  
  1959.     push(@m, join(" ", values %{$att{XS}})." : \$(XSUBPPDEPS)\n")
  1960.     if %{$att{XS}};
  1961.     join("\n",@m);
  1962. }
  1963.  
  1964.  
  1965. sub makefile {
  1966.     my @m;
  1967.     # We do not know what target was originally specified so we
  1968.     # must force a manual rerun to be sure. But as it should only
  1969.     # happen very rarely it is not a significant problem.
  1970.     push @m, '
  1971. $(OBJECT) : '.$att{MAKEFILE}.'
  1972.  
  1973. # We take a very conservative approach here, but it\'s worth it.
  1974. # We move Makefile to Makefile.old here to avoid gnu make looping.
  1975. '.$att{MAKEFILE}.' :    Makefile.PL $(CONFIGDEP)
  1976.     @echo "Makefile out-of-date with respect to $?"
  1977.     @echo "Cleaning current config before rebuilding Makefile..."
  1978.     -@mv '."$att{MAKEFILE} $att{MAKEFILE}.old".'
  1979.     -$(MAKE) -f '.$att{MAKEFILE}.'.old clean >/dev/null 2>&1 || true
  1980.     $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL '."@ARGV".'
  1981.     @echo "Now you must rerun make."; false
  1982. ';
  1983.  
  1984.     join "", @m;
  1985. }
  1986.  
  1987. sub postamble{
  1988.     "";
  1989. }
  1990.  
  1991. # --- Make-Directories section (internal method) ---
  1992. # dir_target(@array) returns a Makefile entry for the file .exists in each
  1993. # named directory. Returns nothing, if the entry has already been processed.
  1994. # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
  1995. # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the 
  1996. # prerequisite, because there has to be one, something that doesn't change 
  1997. # too often :)
  1998. %Dir_Target = (); # package global
  1999.  
  2000. sub dir_target {
  2001.     my($self,@dirs) = @_;
  2002.     my(@m,$dir);
  2003.     foreach $dir (@dirs) {
  2004.     next if $Dir_Target{$dir};
  2005.     push @m, "
  2006. $dir/.exists :: \$(PERL)
  2007.     \@ \$(MKPATH) $dir
  2008.     \@ \$(TOUCH) $dir/.exists
  2009. ";
  2010.     $Dir_Target{$dir}++;
  2011.     }
  2012.     join "", @m;
  2013. }
  2014.  
  2015. # --- Make-A-Perl section ---
  2016.  
  2017. sub staticmake {
  2018.     my($self, %attribs) = @_;
  2019.  
  2020.     my(%searchdirs)=($att{PERL_ARCHLIB} => 1,  $att{INST_ARCHLIB} => 1);
  2021.     my(@searchdirs)=keys %searchdirs;
  2022.     # And as it's not yet built, we add the current extension
  2023.     my(@static)="$att{INST_ARCHLIB}/auto/$att{FULLEXT}/$att{BASEEXT}.a";
  2024.     my(@perlinc) = ($att{INST_ARCHLIB}, $att{INST_LIB}, $att{PERL_ARCHLIB}, $att{PERL_LIB});
  2025.     MY->makeaperl('MAKE' => $att{MAKEFILE}, 
  2026.                  'DIRS' => \@searchdirs, 
  2027.                  'STAT' => \@static, 
  2028.                  'INCL' => \@perlinc,
  2029.                  'TARGET' => $att{MAP_TARGET},
  2030.                  'TMP' => "",
  2031.                  'LIBPERL' => $att{LIBPERL_A}
  2032.                  );
  2033. }
  2034.  
  2035. sub makeaperl {
  2036.     my($self, %attribs) = @_;
  2037.     my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = 
  2038.       @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
  2039.     my(@m);
  2040.     my($cccmd, $linkcmd);
  2041.  
  2042.     # This emulates cflags to get the compiler invocation...
  2043.     $cccmd = MY->const_cccmd($libperl);
  2044.     $cccmd =~ s/^CCCMD\s*=\s*//;
  2045.     chomp $cccmd;
  2046.     $cccmd =~ s/\s/ -I$att{PERL_INC} /;
  2047.     $cccmd .= " $Config{'cccdlflags'}" if ($Config{'d_shrplib'});
  2048.  
  2049.     # The front matter of the linkcommand...
  2050.     $linkcmd = join ' ', "\$(CC)",
  2051.         grep($_, @Config{qw(large split ldflags ccdlflags)});
  2052.     $linkcmd =~ s/\s+/ /g;
  2053.  
  2054.     # Which *.a files could we make use of...
  2055.     local(%static);
  2056.     File::Find::find(sub {
  2057.     return unless m/\.a$/;
  2058.     return if m/^libperl/;
  2059.     # don't include the installed version of this extension
  2060.     return if $File::Find::name =~ m:auto/$att{FULLEXT}/$att{BASEEXT}.a$:;
  2061.     $static{fastcwd() . "/" . $_}++;
  2062.     }, grep( -d $_, @{$searchdirs || []}) );
  2063.  
  2064.     # We trust that what has been handed in as argument, will be buildable
  2065.     $static = [] unless $static;
  2066.     @static{@{$static}} = (1) x @{$static};
  2067.  
  2068.     $extra = [] unless $extra && ref $extra eq 'ARRAY';
  2069.     for (sort keys %static) {
  2070.     next unless /\.a$/;
  2071.     $_ = dirname($_) . "/extralibs.ld";
  2072.     push @$extra, $_;
  2073.     }
  2074.  
  2075.     grep(s/^/-I/, @$perlinc);
  2076.  
  2077.     $target = "perl" unless $target;
  2078.     $tmp = "." unless $tmp;
  2079.  
  2080.     push @m, "
  2081. # --- MakeMaker makeaperl section ---
  2082. MAP_TARGET    = $target
  2083. FULLPERL      = $att{'FULLPERL'}
  2084. MAP_LINKCMD   = $linkcmd
  2085. MAP_PERLINC   = @{$perlinc}
  2086. MAP_STATIC    = ",
  2087. join(" ", sort keys %static), "
  2088. MAP_PRELIBS   = $Config{'libs'} $Config{'cryptlib'}
  2089. ";
  2090.  
  2091.     unless ($libperl && -f $libperl) {
  2092.     my $dir = $att{PERL_SRC} || "$att{PERL_ARCHLIB}/CORE";
  2093.     $libperl ||= "libperl.a";
  2094.     $libperl = "$dir/$libperl";
  2095.     print STDOUT "Warning: $libperl not found"
  2096.         unless (-f $libperl || defined($att{PERL_SRC}));
  2097.     }
  2098.  
  2099.     push @m, "
  2100. MAP_LIBPERL = $libperl
  2101. ";
  2102.  
  2103.     push @m, "
  2104. extralibs.ld: @$extra
  2105.     \@ $att{RM_F} \$\@
  2106.     \@ \$(TOUCH) \$\@
  2107. ";
  2108.  
  2109.     foreach (@$extra){
  2110.     push @m, "\tcat $_ >> \$\@\n";
  2111.     }
  2112.  
  2113.     push @m, "
  2114. \$(MAP_TARGET): $tmp/perlmain.o \$(MAP_LIBPERL) \$(MAP_STATIC) extralibs.ld
  2115.     \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain.o \$(MAP_LIBPERL) \$(MAP_STATIC) `cat extralibs.ld` \$(MAP_PRELIBS)
  2116.     @ echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
  2117.     @ echo '    make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
  2118.     @ echo 'To remove the intermediate files say'
  2119.     @ echo '    make -f $makefilename map_clean'
  2120.  
  2121. $tmp/perlmain.o: $tmp/perlmain.c
  2122. ";
  2123.     push @m, "\tcd $tmp && $cccmd perlmain.c\n";
  2124.  
  2125.     push @m, qq{
  2126. $tmp/perlmain.c: $makefilename}, q{
  2127.     @ echo Writing $@
  2128.     @ $(FULLPERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
  2129.         writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@
  2130.  
  2131. };
  2132.  
  2133. # We write EXTRA outside the perl program to have it eval'd by the shell
  2134.     push @m, q{
  2135. doc_inst_perl:
  2136.     @ echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
  2137.     @ $(FULLPERL) -e 'use ExtUtils::MakeMaker; MM->writedoc("Perl binary",' \\
  2138.         -e '"$(MAP_TARGET)", "MAP_STATIC=$(MAP_STATIC)",' \\
  2139.         -e '"MAP_EXTRA=@ARGV", "MAP_LIBPERL=$(MAP_LIBPERL)")' \\
  2140.         -- `cat extralibs.ld` >> $(INSTALLARCHLIB)/perllocal.pod
  2141. };
  2142.  
  2143.     push @m, qq{
  2144. inst_perl: pure_inst_perl doc_inst_perl
  2145.  
  2146. pure_inst_perl: \$(MAP_TARGET)
  2147.     $att{CP} \$(MAP_TARGET) \$(INSTALLBIN)/\$(MAP_TARGET)
  2148.  
  2149. clean :: map_clean
  2150.  
  2151. map_clean :
  2152.     $att{RM_F} $tmp/perlmain.o $tmp/perlmain.c \$(MAP_TARGET) extralibs.ld
  2153. };
  2154.  
  2155.     join '', @m;
  2156. }
  2157.  
  2158. sub extliblist {
  2159.     my($self,$libs) = @_;
  2160.     require ExtUtils::Liblist;
  2161.     ExtUtils::Liblist::ext($libs, $Verbose);
  2162. }
  2163.  
  2164. sub mksymlists {
  2165.     my($self) = shift;
  2166.     my($pkg);
  2167.  
  2168.     # only AIX requires a symbol list at this point
  2169.     # (so does VMS, but that's handled by the MM_VMS package)
  2170.     return '' unless $Config{'osname'} eq 'aix';
  2171.  
  2172.     init_main(@ARGV) unless defined $att{'BASEEXT'};
  2173.     if (! $att{DL_FUNCS}) {
  2174.     my($bootfunc);
  2175.     ($bootfunc = $att{NAME}) =~ s/\W/_/g;
  2176.     $att{DL_FUNCS} = {$att{BASEEXT} => ["boot_$bootfunc"]};
  2177.     }
  2178.     rename "$att{BASEEXT}.exp", "$att{BASEEXT}.exp_old";
  2179.  
  2180.     open(EXP,">$att{BASEEXT}.exp") or die $!;
  2181.     print EXP join("\n",@{$att{DL_VARS}}) if $att{DL_VARS};
  2182.     foreach $pkg (keys %{$att{DL_FUNCS}}) {
  2183.         (my($prefix) = $pkg) =~ s/\W/_/g;
  2184.     my $func;
  2185.         foreach $func (@{$att{DL_FUNCS}->{$pkg}}) {
  2186.             $func = "XS_${prefix}_$func" unless $func =~ /^boot_/;
  2187.             print EXP "$func\n";
  2188.         }
  2189.     }
  2190.     close EXP;
  2191. }
  2192.  
  2193. # --- Output postprocessing section ---
  2194. #nicetext is included to make VMS support easier
  2195. sub nicetext { # Just return the input - no action needed
  2196.     my($self,$text) = @_;
  2197.     $text;
  2198. }
  2199.  
  2200. # --- perllocal.pod section ---
  2201. sub writedoc {
  2202.     my($self,$what,$name,@attribs)=@_;
  2203. # the following would have to move to a ExtUtils::Perllocal.pm, if we want it
  2204. # it's dangerous wrt AFS, and it's against the philosophy that MakeMaker
  2205. # should never write to files. We write to stdout and append to the file
  2206. # during make install, but we cannot rely on '-f $Config{"installarchlib"},
  2207. # as there is a time window between the WriteMakefile and the make.
  2208. #    -w $Config{'installarchlib'} or die "No write permission to $Config{'installarchlib'}";
  2209. #    my($localpod) = "$Config{'installarchlib'}/perllocal.pod";
  2210.     my($time);
  2211. #    if (-f $localpod) {
  2212. #    print "Appending installation info to $localpod\n";
  2213. #    open POD, ">>$localpod" or die "Couldn't open $localpod";
  2214. #    } else {
  2215. #    print "Writing new file $localpod\n";
  2216. #    open POD, ">$localpod" or die "Couldn't open $localpod";
  2217. #    print POD "=head1 NAME
  2218. #
  2219. #perllocal - locally installed modules and perl binaries
  2220. #\n=head1 HISTORY OF LOCAL INSTALLATIONS
  2221. #
  2222. #";
  2223. #    }
  2224.     require "ctime.pl";
  2225.     chop($time = ctime(time));
  2226.     print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
  2227.     print join "\n\n=item *\n\n", map("C<$_>",@attribs);
  2228.     print "\n\n=back\n\n";
  2229. #    close POD;
  2230. }
  2231.  
  2232.  
  2233.  
  2234. # the following keeps AutoSplit happy
  2235. package ExtUtils::MakeMaker;
  2236. 1;
  2237.  
  2238. __END__
  2239.  
  2240. =head1 NAME
  2241.  
  2242. ExtUtils::MakeMaker - create an extension Makefile
  2243.  
  2244. =head1 SYNOPSIS
  2245.  
  2246. C<use ExtUtils::MakeMaker;>
  2247.  
  2248. C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
  2249.  
  2250. =head1 DESCRIPTION
  2251.  
  2252. This utility is designed to write a Makefile for an extension module
  2253. from a Makefile.PL. It is based on the Makefile.SH model provided by
  2254. Andy Dougherty and the perl5-porters.
  2255.  
  2256. It splits the task of generating the Makefile into several subroutines
  2257. that can be individually overridden.  Each subroutine returns the text
  2258. it wishes to have written to the Makefile.
  2259.  
  2260. MakeMaker.pm uses the architecture specific information from
  2261. Config.pm. In addition the extension may contribute to the C<%Config>
  2262. hash table of Config.pm by supplying hints files in a C<hints/>
  2263. directory. The hints files are expected to be named like their
  2264. counterparts in C<PERL_SRC/hints>, but with an C<.pl> file name
  2265. extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by MakeMaker
  2266. within the WriteMakefile() subroutine, and can be used to execute
  2267. commands as well as to include special variables. If there is no
  2268. hintsfile for the actual system, but for some previous releases of the
  2269. same operating system, the latest one of those is used.
  2270.  
  2271. =head2 Default Makefile Behaviour
  2272.  
  2273. The automatically generated Makefile enables the user of the extension
  2274. to invoke
  2275.  
  2276.   perl Makefile.PL # optionally "perl Makefile.PL verbose"
  2277.   make
  2278.   make test # optionally set TEST_VERBOSE=1
  2279.   make install # See below
  2280.  
  2281. The Makefile to be produced may be altered by adding arguments of the
  2282. form C<KEY=VALUE>. If the user wants to work with a different perl
  2283. than the default, this is achieved by specifying
  2284.  
  2285.   perl Makefile.PL PERL=/tmp/myperl5
  2286.  
  2287. Other interesting targets in the generated Makefile are
  2288.  
  2289.   make config     # to check if the Makefile is up-to-date
  2290.   make clean      # delete local temporary files (Makefile gets renamed)
  2291.   make realclean  # delete all derived files (including installed files)
  2292.   make dist       # see below the Distribution Support section
  2293.  
  2294. =head2 Special case C<make install>
  2295.  
  2296. C<make> alone puts all relevant files into directories that are named
  2297. by the macros INST_LIB, INST_ARCHLIB, and INST_EXE. All three default
  2298. to ./blib if you are I<not> building below the perl source directory. If
  2299. you I<are> building below the perl source, INST_LIB and INST_ARCHLIB
  2300. default to ../../lib, and INST_EXE is not defined.
  2301.  
  2302. The I<install> target of the generated Makefile is a recursive call to
  2303. make which sets
  2304.  
  2305.     INST_LIB     to INSTALLPRIVLIB
  2306.     INST_ARCHLIB to INSTALLARCHLIB
  2307.     INST_EXE     to INSTALLBIN
  2308.  
  2309. The three INSTALL... macros in turn default to
  2310. $Config{installprivlib}, $Config{installarchlib}, and
  2311. $Config{installbin} respectively.
  2312.  
  2313. The recommended way to proceed is to set only the INSTALL* macros, not
  2314. the INST_* targets. In doing so, you give room to the compilation
  2315. process without affecting important directories. Usually a 'make test'
  2316. will succeed after the make, and a 'make install' can finish the game.
  2317.  
  2318. MakeMaker gives you much more freedom than needed to configure
  2319. internal variables and get different results. It is worth to mention,
  2320. that make(1) also lets you configure most of the variables that are
  2321. used in the Makefile. But in the majority of situations this will not
  2322. be necessary, and should only be done, if the author of a package
  2323. recommends it.
  2324.  
  2325. The usual relationship between INSTALLPRIVLIB and INSTALLARCHLIB is
  2326. that the latter is a subdirectory of the former with the name
  2327. C<$Config{'archname'}>, MakeMaker supports the user who sets
  2328. INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then
  2329. MakeMaker defaults the latter to be INSTALLPRIVLIB/ARCHNAME if that
  2330. directory exists, otherwise it defaults to INSTALLPRIVLIB.
  2331.  
  2332. Previous versions of MakeMaker suggested to use the INST_* macros. For
  2333. backwards compatibility, these are still supported but deprecated in
  2334. favor of the INSTALL* macros.
  2335.  
  2336. Here is the description, what they are used for: If the user specifies
  2337. the final destination for the INST_... macros, then there is no need
  2338. to call 'make install', because 'make' will already put all files in
  2339. place.
  2340.  
  2341. If there is a need to first build everything in the C<./blib>
  2342. directory and test the product, then it's appropriate to use the
  2343. INSTALL... macros. So the users have the choice to either say
  2344.  
  2345.     # case: trust the module
  2346.     perl Makefile.PL INST_LIB=~/perllib INST_EXE=~/bin
  2347.     make
  2348.     make test
  2349.  
  2350. or
  2351.  
  2352.     perl Makefile.PL INSTALLPRIVLIB=~/foo \
  2353.             INSTALLARCHLIB=~/foo/bar  INSTALLBIN=~/bin
  2354.     make
  2355.     make test
  2356.     make install
  2357.  
  2358. Note, that the tilde expansion is done by MakeMaker, not by perl by
  2359. default, nor by make. So be careful to use the tilde only with the
  2360. C<perl Makefile.PL> call.
  2361.  
  2362. It is important to know, that the INSTALL* macros should be absolute
  2363. paths, never relativ ones. Packages with multiple Makefile.PLs in
  2364. different directories get the contents of the INSTALL* macros
  2365. propagated verbatim. (The INST_* macros will be corrected, if they are
  2366. relativ paths, but not the INSTALL* macros.)
  2367.  
  2368. If the user has superuser privileges, and is not working on AFS
  2369. (Andrew File System) or relatives, then the defaults for
  2370. INSTALLPRIVLIB, INSTALLARCHLIB, and INSTALLBIN will be appropriate,
  2371. and this incantation will be the best:
  2372.  
  2373.     perl Makefile.PL; make; make test
  2374.     make install
  2375.  
  2376. (I<make test> is not necessarily supported for all modules.)
  2377.  
  2378. C<make install> per default writes some documentation of what has been
  2379. done into the file C<$Config{'installarchlib'}/perllocal.pod>. This is
  2380. an experimental feature. It can be bypassed by calling C<make
  2381. pure_install>.
  2382.  
  2383. =head2 Support to Link a new Perl Binary (eg dynamic loading not available)
  2384.  
  2385. An extension that is built with the above steps is ready to use on
  2386. systems supporting dynamic loading. On systems that do not support
  2387. dynamic loading, any newly created extension has to be linked together
  2388. with the available resources. MakeMaker supports the linking process
  2389. by creating appropriate targets in the Makefile whenever an extension
  2390. is built. You can invoke the corresponding section of the makefile with
  2391.  
  2392.     make perl
  2393.  
  2394. That produces a new perl binary in the current directory with all
  2395. extensions linked in that can be found in INST_ARCHLIB (usually
  2396. C<./blib>) and PERL_ARCHLIB.
  2397.  
  2398. The binary can be installed into the directory where perl normally
  2399. resides on your machine with
  2400.  
  2401.     make inst_perl
  2402.  
  2403. To produce a perl binary with a different name than C<perl>, either say
  2404.  
  2405.     perl Makefile.PL MAP_TARGET=myperl
  2406.     make myperl
  2407.     make inst_perl
  2408.  
  2409. or say
  2410.  
  2411.     perl Makefile.PL
  2412.     make myperl MAP_TARGET=myperl
  2413.     make inst_perl MAP_TARGET=myperl
  2414.  
  2415. In any case you will be prompted with the correct invocation of the
  2416. C<inst_perl> target that installs the new binary into INSTALLBIN.
  2417.  
  2418. Note, that there is a C<makeaperl> scipt in the perl distribution,
  2419. that supports the linking of a new perl binary in a similar fashion,
  2420. but with more options.
  2421.  
  2422. C<make inst_perl> per default writes some documentation of what has been
  2423. done into the file C<$Config{'installarchlib'}/perllocal.pod>. This
  2424. can be bypassed by calling C<make pure_inst_perl>.
  2425.  
  2426. Warning: the inst_perl: target is rather mighty and will probably
  2427. overwrite your existing perl binary. Use with care!
  2428.  
  2429. =head2 Determination of Perl Library and Installation Locations
  2430.  
  2431. MakeMaker needs to know, or to guess, where certain things are
  2432. located.  Especially INST_LIB and INST_ARCHLIB (where to install files
  2433. into), PERL_LIB and PERL_ARCHLIB (where to read existing modules
  2434. from), and PERL_INC (header files and C<libperl*.*>).
  2435.  
  2436. Extensions may be built either using the contents of the perl source
  2437. directory tree or from an installed copy of the perl library.
  2438.  
  2439. If an extension is being built below the C<ext/> directory of the perl
  2440. source then MakeMaker will set PERL_SRC automatically (e.g., C<../..>).
  2441. If PERL_SRC is defined then other variables default to the following:
  2442.  
  2443.   PERL_INC     = PERL_SRC
  2444.   PERL_LIB     = PERL_SRC/lib
  2445.   PERL_ARCHLIB = PERL_SRC/lib
  2446.   INST_LIB     = PERL_LIB
  2447.   INST_ARCHLIB = PERL_ARCHLIB
  2448.  
  2449. If an extension is being built away from the perl source then MakeMaker
  2450. will leave PERL_SRC undefined and default to using the installed copy
  2451. of the perl library. The other variables default to the following:
  2452.  
  2453.   PERL_INC     = $archlib/CORE
  2454.   PERL_LIB     = $privlib
  2455.   PERL_ARCHLIB = $archlib
  2456.   INST_LIB     = ./blib
  2457.   INST_ARCHLIB = ./blib
  2458.  
  2459. If perl has not yet been installed then PERL_SRC can be defined on the
  2460. command line as shown in the previous section.
  2461.  
  2462. =head2 Useful Default Makefile Macros
  2463.  
  2464. FULLEXT = Pathname for extension directory (eg DBD/Oracle).
  2465.  
  2466. BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  2467.  
  2468. ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
  2469.  
  2470. PERL_LIB = Directory where we read the perl library files
  2471.  
  2472. PERL_ARCHLIB = Same as above for architecture dependent files
  2473.  
  2474. INST_LIB = Directory where we put library files of this extension
  2475. while building it. If we are building below PERL_SRC/ext
  2476. we default to PERL_SRC/lib, else we default to ./blib.
  2477.  
  2478. INST_ARCHLIB = Same as above for architecture dependent files
  2479.  
  2480. INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)>
  2481.  
  2482. INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)>
  2483.  
  2484. INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)>
  2485.  
  2486. =head2 Customizing The Generated Makefile
  2487.  
  2488. If the Makefile generated does not fit your purpose you can change it
  2489. using the mechanisms described below.
  2490.  
  2491. =head2 Using Attributes (and Parameters)
  2492.  
  2493. The following attributes can be specified as arguments to WriteMakefile()
  2494. or as NAME=VALUE pairs on the command line:
  2495.  
  2496. This description is not yet documented; you can get at the description
  2497. with one of the commands
  2498.  
  2499. =over 4
  2500.  
  2501. =item C<perl Makefile.PL help>
  2502. (if you already have a basic Makefile.PL)
  2503.  
  2504. =item C<make help>
  2505. (if you already have a Makefile)
  2506.  
  2507. =item C<perl -e 'use ExtUtils::MakeMaker "&help"; &help;'>
  2508. (if you have neither nor)
  2509.  
  2510. =back
  2511.  
  2512. =head2 Overriding MakeMaker Methods
  2513.  
  2514. If you cannot achieve the desired Makefile behaviour by specifying
  2515. attributes you may define private subroutines in the Makefile.PL.
  2516. Each subroutines returns the text it wishes to have written to
  2517. the Makefile. To override a section of the Makefile you can
  2518. either say:
  2519.  
  2520.     sub MY::c_o { "new literal text" }
  2521.  
  2522. or you can edit the default by saying something like:
  2523.  
  2524.     sub MY::c_o { $_=MM->c_o; s/old text/new text/; $_ }
  2525.  
  2526. If you still need a different solution, try to develop another
  2527. subroutine, that fits your needs and submit the diffs to
  2528. F<perl5-porters@nicoh.com> or F<comp.lang.perl> as appropriate.
  2529.  
  2530. =head2 Distribution Support
  2531.  
  2532. For authors of extensions MakeMaker provides several Makefile
  2533. targets. Most of the support comes from the ExtUtils::Manifest module,
  2534. where additional documentation can be found.
  2535.  
  2536. =over 4
  2537.  
  2538. =item    make distcheck
  2539. reports which files are below the build directory but not in the
  2540. MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
  2541. details)
  2542.  
  2543. =item    make distclean
  2544. does a realclean first and then the distcheck. Note that this is not
  2545. needed to build a new distribution as long as you are sure, that the
  2546. MANIFEST file is ok.
  2547.  
  2548. =item    make manifest
  2549. rewrites the MANIFEST file, adding all remaining files found (See
  2550. ExtUtils::Manifest::mkmanifest() for details)
  2551.  
  2552. =item    make distdir
  2553. Copies all the files that are in the MANIFEST file to a newly created
  2554. directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
  2555. exists, it will be removed first.
  2556.  
  2557. =item    make tardist
  2558. First does a command $(PREOP) which defaults to a null command. Does a
  2559. distdir next and runs C<tar> on that directory into a tarfile. Then
  2560. deletes the distdir. Finishes with a command $(POSTOP) which defaults
  2561. to a null command.
  2562.  
  2563. =item    make dist
  2564. Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
  2565.  
  2566. =item    make uutardist
  2567. Runs a tardist first and uuencodes the tarfile.
  2568.  
  2569. =item    make shdist
  2570. First does a command $(PREOP) which defaults to a null command. Does a
  2571. distdir next and runs C<shar> on that directory into a sharfile. Then
  2572. deletes the distdir. Finishes with a command $(POSTOP) which defaults
  2573. to a null command.  Note: For shdist to work properly a C<shar>
  2574. program that can handle directories is mandatory.
  2575.  
  2576. =item    make ci
  2577. Does a $(CI) (defaults to C<ci -u>) and a $(RCS) (C<rcs -q
  2578. -Nv$(VERSION_SYM):>) on all files in the MANIFEST file
  2579.  
  2580. Customization of the dist targets can be done by specifying a hash
  2581. reference to the dist attribute of the WriteMakefile call. The
  2582. following parameters are recognized:
  2583.  
  2584.     TAR          ('tar')
  2585.     TARFLAGS     ('cvf')
  2586.     COMPRESS     ('compress')
  2587.     SUFFIX       ('Z')
  2588.     SHAR         ('shar')
  2589.     PREOP        ('@ :')
  2590.     POSTOP       ('@ :')
  2591.  
  2592. An example:
  2593.  
  2594.     WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" })
  2595.  
  2596. =back
  2597.  
  2598. =head1 AUTHORS
  2599.  
  2600. Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas
  2601. Koenig F<E<lt>k@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce
  2602. F<E<lt>Tim.Bunce@ig.co.ukE<gt>>.  VMS support by Charles Bailey
  2603. F<E<lt>bailey@HMIVAX.HUMGEN.UPENN.EDUE<gt>>. Contact the makemaker
  2604. mailing list L<mailto:makemaker@franz.ww.tu-berlin.de>, if you have any
  2605. questions.
  2606.  
  2607. =head1 MODIFICATION HISTORY
  2608.  
  2609. v1, August 1994; by Andreas Koenig. Based on Andy Dougherty's Makefile.SH.
  2610. v2, September 1994 by Tim Bunce.
  2611. v3.0 October  1994 by Tim Bunce.
  2612. v3.1 November 11th 1994 by Tim Bunce.
  2613. v3.2 November 18th 1994 by Tim Bunce.
  2614. v3.3 November 27th 1994 by Andreas Koenig.
  2615. v3.4 December  7th 1994 by Andreas Koenig and Tim Bunce.
  2616. v3.5 December 15th 1994 by Tim Bunce.
  2617. v3.6 December 15th 1994 by Tim Bunce.
  2618. v3.7 December 30th 1994 By Tim Bunce
  2619. v3.8 January  17th 1995 By Andreas Koenig and Tim Bunce
  2620. v3.9 January 19th 1995 By Tim Bunce
  2621. v3.10 January 23rd 1995 By Tim Bunce
  2622. v3.11 January 24th 1995 By Andreas Koenig
  2623. v4.00 January 24th 1995 By Tim Bunce
  2624. v4.01 January 25th 1995 By Tim Bunce
  2625. v4.02 January 29th 1995 By Andreas Koenig
  2626. v4.03 January 30th 1995 By Andreas Koenig
  2627. v4.04 Februeary 5th 1995 By Andreas Koenig
  2628. v4.05 February 8th 1995 By Andreas Koenig
  2629. v4.06 February 10th 1995 By Andreas Koenig
  2630. v4.061 February 12th 1995 By Andreas Koenig
  2631. v4.08 - 4.085  February 14th-21st 1995 by Andreas Koenig
  2632. v4.086 March 9 1995 by Andy Dougherty
  2633. v4.09 March 31 1995 by Andreas Koenig
  2634. v4.091 April 3 1995 by Andy Dougherty
  2635. v4.092 April 11 1995 by Andreas Koenig
  2636. v4.093 April 12 1995 by Andy Dougherty
  2637. v4.094 April 12 1995 by Andy Dougherty
  2638.  
  2639. v4.100 May 10 1995 by Andreas Koenig
  2640.  
  2641. Broken out Mkbootstrap to make the file smaller and easier to manage,
  2642. and to speed up the build process.
  2643.  
  2644. Added ExtUtils::Manifest as an extra module that is used to streamline
  2645. distributions. (See pod section I<distribution support>).
  2646.  
  2647. Added a VERSION_SYM macro, that is derived from VERSION but all C<\W>
  2648. characters replaced by an underscore.
  2649.  
  2650. Moved the whole documentation below __END__ for easier maintanance.
  2651.  
  2652. linkext =E<gt> { LINKTYPE =E<gt> '' } should work now as expected.
  2653.  
  2654. Rechecked the use of INST_LIB, INST_ARCHLIB, and INST_EXE from the
  2655. perspective of an AFS user (thanks to Rudolph T Maceyko for the
  2656. hint). With full backward compatiblity it is now possible, to set
  2657. INSTALLPRIVLIB, INSTALLARCHLIB, and INSTALLBIN either with 'perl
  2658. Makefile.PL' or with 'make install'. A bare 'make' ignores these
  2659. settings.  The effect of this change is that it is no longer
  2660. recommended to set the INST_* attributes directly, although it doesn't
  2661. hurt, if they do so. The PASTHRU variables (now PASTHRU1 and PASTHRU2)
  2662. are fully aware of their duty: the INST_* attributes are only
  2663. propagated to runsubdirpl, not to 'cd subdir && make config' and 'cd
  2664. subdir && make all'.
  2665.  
  2666. Included Tim's "Unable to locate Perl library" patch.
  2667.  
  2668. Eliminated any excess of spaces in the $old/$new comparison in
  2669. const_cccmd().
  2670.  
  2671. Added a prompt function with usage $answer = prompt $message, $default.
  2672.  
  2673. Included Tim's patch that searches for perl5 and perl$] as well as
  2674. perl and miniperl.
  2675.  
  2676. Added .NO_PARALLEL for the time until I have a multiple cpu machine
  2677. myself :)
  2678.  
  2679. Introduced a macro() subroutine. WriteMakefile("macro" =E<gt> { FOO
  2680. =E<gt> BAR }) defines the macro FOO = BAR in the generated Makefile.
  2681.  
  2682. Rolled in Tim's patch for needs_linking.
  2683.  
  2684. writedoc now tries to be less clever. It was trying to determine, if a
  2685. perllocal.pod had to be created or appended to. As we have now the
  2686. possibility, that INSTALLARCHLIB is determined at make's runtime, we
  2687. cannot do this anymore. We append to that file in any case.
  2688.  
  2689. Added Kenneth's pod installation patch.
  2690.  
  2691. v4.110 May 19 1995 by Andreas Koenig
  2692.  
  2693. =head1 NEW in 4.11
  2694.  
  2695. MANIFEST.SKIP now contains only regular expressions. RCS directories
  2696. are no longer skipped by default, as this may be configured in the
  2697. SKIP file.
  2698.  
  2699. The manifest target now does no realclean anymore.
  2700.  
  2701. I_PERL_LIBS depreciated (no longer used). (unless you speak up, of
  2702. course)
  2703.  
  2704. I could not justify that we rebuild the Makefile when MakeMaker has
  2705. changed (as Kenneth suggested). If this is really a strong desire,
  2706. please convince me. But a minor change of the MakeMaker should not
  2707. trigger a 60 minutes rebuild of Tk, IMO.
  2708.  
  2709. Broken out extliblist into the new module ExtUtils::Liblist. Should
  2710. help extension writers for their own Configure scripts. The breaking
  2711. into pieces should be done now, I suppose.
  2712.  
  2713. Added an (experimenta!!) uninstall target that works with a
  2714. packlist. AutoSplit files are not yet in the packlist. This needs a
  2715. patch to AutoSplit, doesn't it? The packlist file is installed in
  2716. INST_ARCHAUTODIR/.packlist. It doesn't have means to decide, if a file
  2717. is architecture dependent or not, we just collect as much as we can
  2718. get. make -n recommended before actually executing. (I leave this
  2719. target undocumented in the pod section). Suggestions welcome!
  2720.  
  2721. Added basic chmod support. Nothing spectacular. *.so and *.a files get
  2722. permission 755, because I seem to recall, that some systems need
  2723. execute permissions in some weird constellations. The rest becomes
  2724. 644. What else do we need to make this flexible?
  2725.  
  2726. Then I took Tim's word serious: no bloat. No turning all packages into
  2727. perl scripts. Leaving shar, tar, uu be what they are... Sorry,
  2728. Kenneth, we still have to convince Larry that a growing MakeMaker
  2729. makes sense :)
  2730.  
  2731. Added an extra check whenever they install below the perl source tree:
  2732. is this extension a standard extension? If it is, everything behaves
  2733. as we are used to. If it is not, the three INST_ macros are set to
  2734. ./blib, and they get a warning that this extension has to be
  2735. installed manually with 'make install'.
  2736.  
  2737. Added a warning for targets that have a colon or a hashmark within
  2738. their names, because most make(1)s will not be able to process them.
  2739.  
  2740. Applied Hallvard's patch to ~user evaluation for cases where user does
  2741. not exist.
  2742.  
  2743. Added a ci target that checks in all files from the MANIFEST into rcs.
  2744.  
  2745. =head1 new in 4.12/4.13
  2746.  
  2747. "Please notify perl5-porters" message is now accompanied by
  2748. Config::myconfig().
  2749.  
  2750. (Manifest.pm) Change delimiter for the evaluation of the regexes from
  2751. MANIFEST.SKIP to from "!" to "/". I had overlooked the fact, that ! no
  2752. has a meaning in regular expressions.
  2753.  
  2754. Disabled the new logic that prevents non-standard extensions from
  2755. writing to PERL_SRC/lib to give Andy room for 5.001f.
  2756.  
  2757. Added a Version_check target that calls MakeMaker for a simple Version
  2758. control function on every invocation of 'make' in the future. Doesn't
  2759. have an effect currently.
  2760.  
  2761. Target dist is still defaulting to tardist, but the level of
  2762. indirection has changed. The Makefile macro DIST_DEFAULT takes it's
  2763. place. This allows me to make dist dependent from whatever I intend as
  2764. my standard distribution.
  2765.  
  2766. Made sure that INST_EXE is created for extensions that need it.
  2767.  
  2768. 4.13 is just a cleanup/documentation patch. And it adds a MakeMaker FAQ :)
  2769.  
  2770. =head v4.14 June 5, 1995, by Andreas Koenig
  2771.  
  2772. Reintroduces the LD_RUN_PATH macro. LD_RUN_PATH is passed as an
  2773. environment variable to the ld run. It is needed on Sun OS, and does
  2774. no harm on other systems. It is a colon seperated list of the
  2775. directories in LDLOADLIBS.
  2776.  
  2777. =head v4.15 June 6, 1995, by Andreas Koenig
  2778.  
  2779. Add -I$(PERL_ARCHLIB) -I$(PERL_LIB) to calls to xsubpp.
  2780.  
  2781. =head v4.16 June 18, 1995, by Tim Bunce
  2782.  
  2783. Split test: target into test_static: and test_dynamic: with automatic
  2784. selection based on LINKTYPE. The test_static: target automatically
  2785. builds a local ./perl binary containing the extension and executes the
  2786. tests using that binary. This fixes problems that users were having
  2787. dealing with building and testing static extensions. It also simplifies
  2788. the process down to the standard: make + make test.
  2789.  
  2790. MakeMaker no longer incorrectly considers a perlmain.c file to be part
  2791. of an extensions source files. The map_clean target is now invoked by
  2792. clean not realclean and now deletes MAP_TARGET but does not delete
  2793. Makefile (since that's done properly elsewhere).
  2794.  
  2795. Since the staticmake section defines macros that the test target now
  2796. needs the test section is written into the makefile after the
  2797. staticmake section.  The postamble section has been made last again, as
  2798. it should be.
  2799.  
  2800. =head1 TODO
  2801.  
  2802. Needs more complete documentation.
  2803.  
  2804. Add a C<html:> target when there has been found a general solution to
  2805. installing html files.
  2806.  
  2807. Add a FLAVOR variable that makes it easier to build debugging,
  2808. embedded or multiplicity perls. Currently the easiest way to produce a
  2809. debugging perl seems to be (after haveing built perl):
  2810.     make clobber
  2811.     ./Configure -D"archname=IP22-irix-d" -des
  2812.     make perllib=libperld.a
  2813.     make test perllib=libperld.a
  2814.     mv /usr/local/bin/perl /usr/local/bin/perl/O_perl5.001e
  2815.     make install perllib=libperld.a
  2816.     cp /usr/local/bin/perl/O_perl5.001e /usr/local/bin/perl
  2817. It would be nice, if the Configure step could be dropped. Also nice, but 
  2818. maybe expensive, if 'make clobber' wouldn't be needed.
  2819.  
  2820. The uninstall target has to be completed, it's just a sketch.
  2821.  
  2822. Reconsider Makefile macros. The output of macro() should be the last
  2823. before PASTHRU and none should come after that -- tough work.
  2824.  
  2825. Think about Nick's desire, that the pTk subdirectory needs a special
  2826. treatment.
  2827.  
  2828. Find a way to have multiple MYEXTLIB archive files combined into
  2829. one. Actually I need some scenario, where this problem can be
  2830. illustrated. I currently don't see the problem.
  2831.  
  2832. Test if .NOPARALLEL can be omitted.
  2833.  
  2834. Don't let extensions write to PERL_SRC/lib anymore, build perl from
  2835. the extensions found below ext, run 'make test' and 'make install' on
  2836. each extension (giving room for letting them fail). Move some of the
  2837. tests from t/lib/* to the libraries.
  2838.  
  2839. Streamline the production of a new perl binary on systems that DO have
  2840. dynamic loading (especially make test needs further support, as test
  2841. most probably needs the new binary).
  2842.  
  2843. =cut
  2844.