Updated for MakeMaker 5.21.
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MakeMaker.pm
1 package ExtUtils::MakeMaker::TieAtt;
2 # this package will go away again, when we don't have modules around
3 # anymore that import %att It ties an empty %att and records in which
4 # object this %att was tied. FETCH and STORE return/store-to the
5 # appropriate value from %$self
6
7 # the warndirectuse method warns if somebody calls MM->something. It
8 # has nothing to do with the tie'd %att.
9
10 $Enough_limit = 5;
11
12 sub TIEHASH {
13     bless { SECRETHASH => $_[1]};
14 }
15
16 sub FETCH {
17     print "Warning (non-fatal): Importing of %att is deprecated [$_[1]]
18         use \$self instead\n" unless ++$Enough>$Enough_limit;
19     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
20     $_[0]->{SECRETHASH}->{$_[1]};
21 }
22
23 sub STORE {
24     print "Warning (non-fatal): Importing of %att is deprecated [$_[1]][$_[2]]
25         use \$self instead\n" unless ++$Enough>$Enough_limit;
26     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
27     $_[0]->{SECRETHASH}->{$_[1]} = $_[2];
28 }
29
30 sub FIRSTKEY {
31     print "Warning (non-fatal): Importing of %att is deprecated [FIRSTKEY]
32         use \$self instead\n" unless ++$Enough>$Enough_limit;
33     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
34     each %{$_[0]->{SECRETHASH}};
35 }
36
37 sub NEXTKEY {
38     each %{$_[0]->{SECRETHASH}};
39 }
40
41 sub DESTROY {
42 }
43
44 sub warndirectuse {
45     my($caller) = @_;
46     return if $Enough>$Enough_limit;
47     print STDOUT "Warning (non-fatal): Direct use of class methods deprecated; use\n";
48     my($method) = $caller =~ /.*:(\w+)$/;
49     print STDOUT
50 '               my $self = shift;
51                 $self->MM::', $method, "();
52         instead\n";
53     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n"
54         if ++$Enough==$Enough_limit;
55 }
56
57 package ExtUtils::MakeMaker;
58
59 # Last edited $Date: 1996/01/28 11:33:38 $ by Andreas Koenig
60 # $Id: MakeMaker.pm,v 1.141 1996/01/28 11:33:38 k Exp $
61
62 $Version = $VERSION = "5.18";
63
64 $ExtUtils::MakeMaker::Version_OK = "5.05";      # Makefiles older than $Version_OK will die
65                         # (Will be checked from MakeMaker version 4.13 onwards)
66
67 use Config;
68 use Carp;
69 use Cwd;
70 require Exporter;
71 require ExtUtils::Manifest;
72 require ExtUtils::Liblist;
73 #use strict qw(refs);
74
75 eval {require DynaLoader;};     # Get mod2fname, if defined. Will fail
76                                 # with miniperl.
77
78 # print join "**\n**", "", %INC, "";
79 %NORMAL_INC = %INC;
80
81
82
83 @ISA = qw(Exporter);
84 @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
85 @EXPORT_OK = qw($Version $VERSION &Version_check
86                 &help &neatvalue &mkbootstrap &mksymlists
87                 %att  ## Import of %att is deprecated, please use OO features!
88 );
89
90 if ($Is_VMS = ($Config::Config{osname} eq 'VMS')) {
91     require ExtUtils::MM_VMS;
92     require VMS::Filespec;
93     import VMS::Filespec '&vmsify';
94 }
95 $Is_OS2 = $Config::Config{osname} =~ m|^os/?2$|i ;
96 $ENV{EMXSHELL} = 'sh' if $Is_OS2; # to run `commands`
97
98 $ExtUtils::MakeMaker::Verbose = 0 unless defined $ExtUtils::MakeMaker::Verbose;
99 $^W=1;
100 #$SIG{__DIE__} = sub { print @_, Carp::longmess(); die; };
101 ####$SIG{__WARN__} = sub { print Carp::longmess(); warn @_; };
102 $SIG{__WARN__} = sub {
103     $_[0] =~ /^Use of uninitialized value/ && return;
104     $_[0] =~ /used only once/ && return;
105     $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
106     warn @_;
107 };
108
109 # Setup dummy package:
110 # MY exists for overriding methods to be defined within
111 unshift(@MY::ISA, qw(MM));
112
113 # Dummy package MM inherits actual methods from OS-specific
114 # default packages.  We use this intermediate package so
115 # MY::XYZ->func() can call MM->func() and get the proper
116 # default routine without having to know under what OS
117 # it's running.
118
119 @MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::MakeMaker];
120 unshift @MM::ISA, 'ExtUtils::MM_VMS' if $Is_VMS;
121 unshift @MM::ISA, 'ExtUtils::MM_OS2' if $Is_OS2;
122
123
124 @ExtUtils::MakeMaker::MM_Sections_spec = (
125     post_initialize     => {},
126     const_config        => {},
127     constants           => {},
128     const_loadlibs      => {},
129     const_cccmd         => {}, # the last but one addition here (CONST_CCCMD)
130     tool_autosplit      => {},
131     tool_xsubpp         => {},
132     tools_other         => {},
133     dist                => {},
134     macro               => {},
135     depend              => {},
136     post_constants      => {},
137     pasthru             => {},
138     c_o                 => {},
139     xs_c                => {},
140     xs_o                => {},
141     top_targets         => {}, # currently the last section that adds a key to $self (DIR_TARGET)
142     linkext             => {},
143     dlsyms              => {},
144     dynamic             => {},
145     dynamic_bs          => {},
146     dynamic_lib         => {},
147     static              => {},
148     static_lib          => {},
149     installpm           => {},
150     manifypods          => {},
151     processPL           => {},
152     installbin          => {},
153     subdirs             => {},
154     clean               => {},
155     realclean           => {},
156     dist_basics         => {},
157     dist_core           => {},
158     dist_dir            => {},
159     dist_test           => {},
160     dist_ci             => {},
161     install             => {},
162     force               => {},
163     perldepend          => {},
164     makefile            => {},
165     staticmake          => {},  # Sadly this defines more macros
166     test                => {},
167     postamble           => {},  # should always be last the user has hands on
168     selfdocument        => {},  # well, he may override it, but he won't do it
169 );
170 # loses section ordering
171 %ExtUtils::MakeMaker::MM_Sections = @ExtUtils::MakeMaker::MM_Sections_spec;
172 # keeps order
173 @ExtUtils::MakeMaker::MM_Sections = grep(!ref, @ExtUtils::MakeMaker::MM_Sections_spec);
174
175 %ExtUtils::MakeMaker::Recognized_Att_Keys = %ExtUtils::MakeMaker::MM_Sections; # All sections are valid keys.
176
177 @ExtUtils::MakeMaker::Get_from_Config = qw(
178 ar
179 cc
180 cccdlflags
181 ccdlflags
182 dlext
183 dlsrc
184 ld
185 lddlflags
186 ldflags
187 libc
188 lib_ext
189 obj_ext
190 ranlib
191 so
192 );
193
194 my $item;
195 foreach $item (split(/\n/,attrib_help())){
196     next unless $item =~ m/^=item\s+(\w+)\s*$/;
197     $ExtUtils::MakeMaker::Recognized_Att_Keys{$1} = $2;
198     print "Attribute '$1' => '$2'\n" if ($ExtUtils::MakeMaker::Verbose >= 2);
199 }
200 foreach $item (@ExtUtils::MakeMaker::Get_from_Config) {
201     next unless $Config::Config{$item};
202     $ExtUtils::MakeMaker::Recognized_Att_Keys{uc $item} = $Config::Config{$item};
203     print "Attribute '\U$item\E' => '$Config::Config{$item}'\n"
204         if ($ExtUtils::MakeMaker::Verbose >= 2);
205 }
206
207 %ExtUtils::MakeMaker::Prepend_dot_dot = qw(
208 INST_LIB 1 INST_ARCHLIB 1 INST_EXE 1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1
209 PERL_SRC 1 PERL 1 FULLPERL 1
210 );
211 $PACKNAME = "PACK000";
212
213 sub writeMakefile {
214     die <<END;
215
216 The extension you are trying to build apparently is rather old and
217 most probably outdated. We detect that from the fact, that a
218 subroutine "writeMakefile" is called, and this subroutine is not
219 supported anymore since about October 1994.
220
221 Please contact the author or look into CPAN (details about CPAN can be
222 found in the FAQ and at http:/www.perl.com) for a more recent version
223 of the extension. If you're really desperate, you can try to change
224 the subroutine name from writeMakefile to WriteMakefile and rerun
225 'perl Makefile.PL', but you're most probably left alone, when you do
226 so.
227
228 The MakeMaker team
229
230 END
231 }
232
233 sub WriteMakefile {
234     Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
235     my %att = @_;
236     MM->new(\%att)->flush;
237 }
238
239 sub new {
240     my($class,$self) = @_;
241     my($key);
242
243     print STDOUT "MakeMaker (v$ExtUtils::MakeMaker::VERSION)\n" if $ExtUtils::MakeMaker::Verbose;
244     if (-f "MANIFEST" && ! -f "Makefile"){
245         check_manifest();
246     }
247
248     $self = {} unless (defined $self);
249
250     check_hints($self);
251
252     my(%initial_att) = %$self; # record initial attributes
253
254     if (defined $self->{CONFIGURE}) {
255         if (ref $self->{CONFIGURE} eq 'CODE') {
256             $self = { %$self, %{&{$self->{CONFIGURE}}}};
257         } else {
258             croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
259         }
260     }
261
262     # This is for old Makefiles written pre 5.00, will go away
263     if ( Carp::longmess("") =~ /runsubdirpl/s ){
264         $self->{Correct_relativ_directories}++;
265     } else {
266         $self->{Correct_relativ_directories}=0;
267     }
268
269     my $class = ++$PACKNAME;
270     {
271 #       no strict;
272         print "Blessing Object into class [$class]\n" if $ExtUtils::MakeMaker::Verbose;
273         mv_all_methods("MY",$class);
274         bless $self, $class;
275 ########        tie %::att, ExtUtils::MakeMaker::TieAtt, $self;
276         push @ExtUtils::MakeMaker::Parent, $self;
277         @{"$class\:\:ISA"} = 'MM';
278     }
279
280     if (defined $ExtUtils::MakeMaker::Parent[-2]){
281         $self->{PARENT} = $ExtUtils::MakeMaker::Parent[-2];
282         my $key;
283         for $key (keys %ExtUtils::MakeMaker::Prepend_dot_dot) {
284             next unless defined $self->{PARENT}{$key};
285             $self->{$key} = $self->{PARENT}{$key};
286             $self->{$key} = $self->catdir("..",$self->{$key})
287                 unless $self->{$key} =~ m!^/!;
288         }
289         $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT};
290     } else {
291         parse_args($self,@ARGV);
292     }
293
294     $self->{NAME} ||= $self->guess_name;
295
296     ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
297
298     $self->init_main();
299
300     if (! $self->{PERL_SRC} ) {
301         my($pthinks) = $INC{'Config.pm'};
302         $pthinks = vmsify($pthinks) if $Is_VMS;
303         if ($pthinks ne $self->catfile($Config::Config{archlibexp},'Config.pm')){
304             $pthinks =~ s!/Config\.pm$!!;
305             $pthinks =~ s!.*/!!;
306             print STDOUT <<END;
307 Your perl and your Config.pm seem to have different ideas about the architecture
308 they are running on.
309 Perl thinks: [$pthinks]
310 Config says: [$Config::Config{archname}]
311 This may or may not cause problems. Please check your installation of perl if you
312 have problems building this extension.
313 END
314         }
315     }
316
317     $self->init_dirscan();
318     $self->init_others();
319
320     push @{$self->{RESULT}}, <<END;
321 # This Makefile is for the $self->{NAME} extension to perl.
322 #
323 # It was generated automatically by MakeMaker version $ExtUtils::MakeMaker::VERSION from the contents
324 # of Makefile.PL. Don't edit this file, edit Makefile.PL instead.
325 #
326 #       ANY CHANGES MADE HERE WILL BE LOST!
327 #
328 #   MakeMaker Parameters:
329 END
330
331     foreach $key (sort keys %initial_att){
332         my($v) = neatvalue($initial_att{$key});
333         $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
334         $v =~ tr/\n/ /s;
335         push @{$self->{RESULT}}, "#     $key => $v";
336     }
337
338     # turn the SKIP array into a SKIPHASH hash
339     my (%skip,$skip);
340     for $skip (@{$self->{SKIP} || []}) {
341         $self->{SKIPHASH}{$skip} = 1;
342     }
343
344     # We run all the subdirectories now. They don't have much to query
345     # from the parent, but the parent has to query them: if they need linking!
346     my($dir);
347     unless ($self->{NORECURS}) {
348         foreach $dir (@{$self->{DIR}}){
349             chdir $dir;
350             package main;
351             local *FH;
352             open FH, "Makefile.PL";
353             eval join "", <FH>;
354             close FH;
355             chdir "..";
356         }
357     }
358
359     tie %::att, ExtUtils::MakeMaker::TieAtt, $self;
360     my $section;
361     foreach $section ( @ExtUtils::MakeMaker::MM_Sections ){
362         print "Processing Makefile '$section' section\n" if ($ExtUtils::MakeMaker::Verbose >= 2);
363         my($skipit) = $self->skipcheck($section);
364         if ($skipit){
365             push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
366         } else {
367             my(%a) = %{$self->{$section} || {}};
368             push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
369             push @{$self->{RESULT}}, "# " . join ", ", %a if $ExtUtils::MakeMaker::Verbose && %a;
370             push @{$self->{RESULT}}, $self->nicetext($self->$section( %a ));
371         }
372     }
373
374     push @{$self->{RESULT}}, "\n# End.";
375 ########    untie %::att;
376     pop @ExtUtils::MakeMaker::Parent;
377
378     $self;
379 }
380
381 sub check_manifest {
382     eval {require ExtUtils::Manifest};
383     if ($@){
384         print STDOUT "Warning: you have not installed the ExtUtils::Manifest
385          module -- skipping check of the MANIFEST file\n";
386     } else {
387         print STDOUT "Checking if your kit is complete...\n";
388         $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
389         my(@missed)=ExtUtils::Manifest::manicheck();
390         if (@missed){
391             print STDOUT "Warning: the following files are missing in your kit:\n";
392             print "\t", join "\n\t", @missed;
393             print STDOUT "\n";
394             print STDOUT "Please inform the author.\n";
395         } else {
396             print STDOUT "Looks good\n";
397         }
398     }
399 }
400
401 sub parse_args{
402     my($self, @args) = @_;
403     foreach (@args){
404         unless (m/(.*?)=(.*)/){
405             help(),exit 1 if m/^help$/;
406             ++$ExtUtils::MakeMaker::Verbose if m/^verb/;
407             next;
408         }
409         my($name, $value) = ($1, $2);
410         if ($value =~ m/^~(\w+)?/){ # tilde with optional username
411             $value =~ s [^~(\w*)]
412                 [$1 ?
413                  ((getpwnam($1))[7] || "~$1") :
414                  (getpwuid($>))[7]
415                  ]ex;
416         }
417         # This may go away, in mid 1996
418         if ($self->{Correct_relativ_directories}){
419             $value = $self->catdir("..",$value)
420                 if $ExtUtils::MakeMaker::Prepend_dot_dot{$name} && ! $value =~ m!^/!;
421         }
422         $self->{$name} = $value;
423     }
424     # This may go away, in mid 1996
425     delete $self->{Correct_relativ_directories};
426
427     # catch old-style 'potential_libs' and inform user how to 'upgrade'
428     if (defined $self->{potential_libs}){
429         my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
430         if ($self->{potential_libs}){
431             print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
432         } else {
433             print STDOUT "$msg deleted.\n";
434         }
435         $self->{LIBS} = [$self->{potential_libs}];
436         delete $self->{potential_libs};
437     }
438     # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
439     if (defined $self->{ARMAYBE}){
440         my($armaybe) = $self->{ARMAYBE};
441         print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
442                         "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
443         my(%dl) = %{$self->{dynamic_lib} || {}};
444         $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
445         delete $self->{ARMAYBE};
446     }
447     if (defined $self->{LDTARGET}){
448         print STDOUT "LDTARGET should be changed to LDFROM\n";
449         $self->{LDFROM} = $self->{LDTARGET};
450         delete $self->{LDTARGET};
451     }
452     # Turn a DIR argument on the command line into an array
453     if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
454         # So they can choose from the command line, which extensions they want
455         # the grep enables them to have some colons too much in case they
456         # have to build a list with the shell
457         $self->{DIR} = [grep $_, split ":", $self->{DIR}];
458     }
459     my $mmkey;
460     foreach $mmkey (sort keys %$self){
461         print STDOUT "  $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $ExtUtils::MakeMaker::Verbose;
462         print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n"
463             unless exists $ExtUtils::MakeMaker::Recognized_Att_Keys{$mmkey};
464     }
465 }
466
467 sub check_hints {
468     my($self) = @_;
469     # We allow extension-specific hints files.
470
471     return unless -d "hints";
472
473     # First we look for the best hintsfile we have
474     my(@goodhints);
475     my($hint)="$Config::Config{osname}_$Config::Config{osvers}";
476     $hint =~ s/\./_/g;
477     $hint =~ s/_$//;
478     return unless $hint;
479
480     # Also try without trailing minor version numbers.
481     while (1) {
482         last if -f "hints/$hint.pl";      # found
483     } continue {
484         last unless $hint =~ s/_[^_]*$//; # nothing to cut off
485     }
486     return unless -f "hints/$hint.pl";    # really there
487
488     # execute the hintsfile:
489     local *HINTS;
490     open HINTS, "hints/$hint.pl";
491     @goodhints = <HINTS>;
492     close HINTS;
493     print STDOUT "Processing hints file hints/$hint.pl\n";
494     eval join('',@goodhints);
495     print STDOUT $@ if $@;
496 }
497
498 sub mv_all_methods {
499     my($from,$to) = @_;
500     my($method);
501     my($symtab) = \%{"${from}::"};
502 #    no strict;
503
504     # Here you see the *current* list of methods that are overridable
505     # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm
506     # still trying to reduce the list to some reasonable minimum --
507     # because I want to make it easier for the user. A.K.
508
509     foreach $method (@ExtUtils::MakeMaker::MM_Sections, qw[ dir_target
510 exescan fileparse fileparse_set_fstype installpm_x libscan makeaperl
511 mksymlists needs_linking runsubdirpl subdir_x test_via_harness
512 test_via_script writedoc ]) {
513
514         # We cannot say "next" here. Nick might call MY->makeaperl
515         # which isn't defined right now
516
517         # next unless defined &{"${from}::$method"};
518
519         *{"${to}::$method"} = \&{"${from}::$method"};
520
521         # delete would do, if we were sure, nobody ever called
522         # MY->makeaperl directly
523
524         # delete $symtab->{$method};
525
526         # If we delete a method, then it will be undefined and cannot
527         # be called.  But as long as we have Makefile.PLs that rely on
528         # %MY:: being intact, we have to fill the hole with an
529         # inheriting method:
530
531         eval "package MY; sub $method {local *$method; shift->MY::$method(\@_); }";
532
533     }
534
535     # We have to clean out %INC also, because the current directory is
536     # changed frequently and Graham Barr prefers to get his version
537     # out of a History.pl file which is "required" so woudn't get
538     # loaded again in another extension requiring a History.pl
539
540     my $inc;
541     foreach $inc (keys %INC) {
542         next if $ExtUtils::MakeMaker::NORMAL_INC{$inc};
543         #warn "***$inc*** deleted";
544         delete $INC{$inc};
545     }
546
547 }
548
549 sub prompt {
550     my($mess,$def)=@_;
551     BEGIN { $ISA_TTY = -t STDIN && -t STDOUT }
552     Carp::confess("prompt function called without an argument") unless defined $mess;
553     $def = "" unless defined $def;
554     my $dispdef = "[$def] ";
555     my $ans;
556     if ($ISA_TTY) {
557         local $|=1;
558         print "$mess $dispdef";
559         chop($ans = <STDIN>);
560     }
561     return $ans if defined $ans;
562     return $def;
563 }
564
565 sub attrib_help {
566     return $Attrib_Help if $Attrib_Help;
567     my $switch = 0;
568     my $help;
569     my $line;
570     local *POD;
571 ####    local $/ = ""; # bug in 5.001m
572     open POD, $INC{"ExtUtils/MakeMaker.pm"}
573     or die "Open $INC{'ExtUtils/MakeMaker.pm'}: $!";
574     while ($line = <POD>) {
575         $switch ||= $line =~ /^=item C\s*$/;
576         next unless $switch;
577         last if $line =~ /^=cut/;
578         $help .= $line;
579     }
580     close POD;
581     $Attrib_Help = $help;
582 }
583
584 sub help {print &attrib_help, "\n";}
585
586 sub skipcheck{
587     my($self) = shift;
588     my($section) = @_;
589     if ($section eq 'dynamic') {
590         print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
591         "in skipped section 'dynamic_bs'\n"
592             if $self->{SKIPHASH}{dynamic_bs} && $ExtUtils::MakeMaker::Verbose;
593         print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
594         "in skipped section 'dynamic_lib'\n"
595             if $self->{SKIPHASH}{dynamic_lib} && $ExtUtils::MakeMaker::Verbose;
596     }
597     if ($section eq 'dynamic_lib') {
598         print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
599         "targets in skipped section 'dynamic_bs'\n"
600             if $self->{SKIPHASH}{dynamic_bs} && $ExtUtils::MakeMaker::Verbose;
601     }
602     if ($section eq 'static') {
603         print STDOUT "Warning (non-fatal): Target 'static' depends on targets ",
604         "in skipped section 'static_lib'\n"
605             if $self->{SKIPHASH}{static_lib} && $ExtUtils::MakeMaker::Verbose;
606     }
607     return 'skipped' if $self->{SKIPHASH}{$section};
608     return '';
609 }
610
611 sub flush {
612     my $self = shift;
613     my($chunk);
614     local *MAKE;
615     print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n";
616
617     unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
618     open MAKE, ">MakeMaker.tmp" or die "Unable to open MakeMaker.tmp: $!";
619
620     for $chunk (@{$self->{RESULT}}) {
621         print MAKE "$chunk\n";
622     }
623
624     close MAKE;
625     my($finalname) = $self->{MAKEFILE};
626     rename("MakeMaker.tmp", $finalname);
627     chmod 0644, $finalname unless $Is_VMS;
628     system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":";
629 }
630
631 sub Version_check {
632     my($checkversion) = @_;
633     die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
634 Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
635 changes in the meantime.
636 Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
637     if $checkversion lt $ExtUtils::MakeMaker::Version_OK;
638     printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
639     $checkversion, "Current Version is", $ExtUtils::MakeMaker::VERSION
640         unless $checkversion == $ExtUtils::MakeMaker::VERSION;
641 }
642
643 # The following mkbootstrap() is only for installations that are calling
644 # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
645 # writes Makefiles, that use ExtUtils::Mkbootstrap directly.
646 sub mkbootstrap {
647     die <<END;
648 !!! Your Makefile has been built such a long time ago, !!!
649 !!! that is unlikely to work with current MakeMaker.   !!!
650 !!! Please rebuild your Makefile                       !!!
651 END
652 }
653
654 # Ditto for mksymlists() as of MakeMaker 5.17
655 sub mksymlists {
656     die <<END;
657 !!! Your Makefile has been built such a long time ago, !!!
658 !!! that is unlikely to work with current MakeMaker.   !!!
659 !!! Please rebuild your Makefile                       !!!
660 END
661 }
662
663 sub neatvalue {
664     my($v) = @_;
665     return "undef" unless defined $v;
666     my($t) = ref $v;
667     return "'$v'" unless $t;
668     if ($t eq 'ARRAY') {
669         my(@m, $elem, @neat);
670         push @m, "[";
671         foreach $elem (@$v) {
672             push @neat, "'$elem'";
673         }
674         push @m, join ", ", @neat;
675         push @m, "]";
676         return join "", @m;
677     }
678     return "$v" unless $t eq 'HASH';
679     my(@m, $key, $val);
680     push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
681     return "{ ".join(', ',@m)." }";
682 }
683
684 sub selfdocument {
685     my($self) = @_;
686     my(@m);
687     if ($ExtUtils::MakeMaker::Verbose){
688         push @m, "\n# Full list of MakeMaker attribute values:";
689         foreach $key (sort keys %$self){
690             next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
691             my($v) = neatvalue($self->{$key});
692             $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
693             $v =~ tr/\n/ /s;
694             push @m, "# $key => $v";
695         }
696     }
697     join "\n", @m;
698 }
699
700
701  #     # #     #         #     #
702  ##   ## ##   ##         #     #  #    #     #    #    #
703  # # # # # # # #         #     #  ##   #     #     #  #
704  #  #  # #  #  #         #     #  # #  #     #      ##
705  #     # #     #         #     #  #  # #     #      ##
706  #     # #     #         #     #  #   ##     #     #  #
707  #     # #     # #######  #####   #    #     #    #    #
708
709 package ExtUtils::MM_Unix;
710
711 use Config;
712 use Cwd;
713 use File::Basename;
714 require Exporter;
715
716 Exporter::import('ExtUtils::MakeMaker',
717         qw( $Verbose &neatvalue));
718
719 # These attributes cannot be overridden externally
720 @Other_Att_Keys{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)} = (1) x 3;
721
722 if ($Is_VMS = $Config::Config{osname} eq 'VMS') {
723     require VMS::Filespec;
724     import VMS::Filespec qw( &vmsify );
725 }
726
727 $Is_OS2 = $ExtUtils::MakeMaker::Is_OS2;
728
729 sub guess_name {
730     my($self) = @_;
731     my $name = fastcwd();
732     $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
733     $name =~ s#/#::#g;
734     $name =~  s#[\-_][\d.\-]+$##;  # this is new with MM 5.00
735     $name;
736 }
737
738 sub init_main {
739     my($self) = @_;
740     unless (ref $self){
741         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
742         $self = $ExtUtils::MakeMaker::Parent[-1];
743     }
744
745     # --- Initialize Module Name and Paths
746
747     # NAME    = The perl module name for this extension (eg DBD::Oracle).
748     # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
749     # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
750     # ROOTEXT = Directory part of FULLEXT with leading /.
751     ($self->{FULLEXT} =
752      $self->{NAME}) =~ s!::!/!g ;                            #eg. BSD/Foo/Socket
753
754     # Copied from DynaLoader:
755
756     my(@modparts) = split(/::/,$self->{NAME});
757     my($modfname) = $modparts[-1];
758
759     # Some systems have restrictions on files names for DLL's etc.
760     # mod2fname returns appropriate file base name (typically truncated)
761     # It may also edit @modparts if required.
762     if (defined &DynaLoader::mod2fname) {
763         $modfname = &DynaLoader::mod2fname(\@modparts);
764     } elsif ($Is_OS2) {                # Need manual correction if run with miniperl:-(
765         $modfname = substr($modfname, 0, 7) . '_';
766     }
767
768
769     ($self->{BASEEXT} =
770      $self->{NAME}) =~ s!.*::!! ;                            #eg. Socket
771
772     if (defined &DynaLoader::mod2fname or $Is_OS2) {
773         # As of 5.001m, dl_os2 appends '_'
774         $self->{DLBASE} = $modfname;                    #eg. Socket_
775     } else {
776         $self->{DLBASE} = '$(BASEEXT)';
777     }
778
779     ($self->{ROOTEXT} =
780      $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ;      #eg. /BSD/Foo
781
782     $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};
783
784
785     # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
786
787     # *Real* information: where did we get these two from? ...
788     my $inc_config_dir = dirname($INC{'Config.pm'});
789     my $inc_carp_dir   = dirname($INC{'Carp.pm'});
790
791     # Typically PERL_* and INST_* will be identical but that need
792     # not be the case (e.g., installing into project libraries etc).
793
794     # Perl Macro:    With source    No source
795     # PERL_SRC       ../..          (undefined)
796     # PERL_LIB       PERL_SRC/lib   $Config{privlibexp}
797     # PERL_ARCHLIB   PERL_SRC/lib   $Config{archlibexp}
798
799     # INST Macro:    For standard   for any other
800     #                modules        module
801     # INST_LIB       PERL_SRC/lib   ./blib
802     # INST_ARCHLIB   PERL_SRC/lib   ./blib/<archname>
803
804     unless ($self->{PERL_SRC}){
805         my($dir);
806         foreach $dir (qw(.. ../.. ../../..)){
807             if ( -f "$dir/config.sh"
808                 && -f "$dir/perl.h"
809                 && -f "$dir/lib/Exporter.pm") {
810                 $self->{PERL_SRC}=$dir ;
811                 last;
812             }
813         }
814     }
815     if ($self->{PERL_SRC}){
816         $self->{PERL_LIB}     ||= $self->catdir("$self->{PERL_SRC}","lib");
817         $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
818         $self->{PERL_INC}     = $self->{PERL_SRC};
819         # catch a situation that has occurred a few times in the past:
820         warn <<EOM unless -s "$self->{PERL_SRC}/cflags";
821 You cannot build extensions below the perl source tree after executing
822 a 'make clean' in the perl source tree.
823
824 To rebuild extensions distributed with the perl source you should
825 simply Configure (to include those extensions) and then build perl as
826 normal. After installing perl the source tree can be deleted. It is not
827 needed for building extensions.
828
829 It is recommended that you unpack and build additional extensions away
830 from the perl source tree.
831 EOM
832     } else {
833         # we should also consider $ENV{PERL5LIB} here
834         $self->{PERL_LIB}     = $Config::Config{privlibexp} unless $self->{PERL_LIB};
835         $self->{PERL_ARCHLIB} = $Config::Config{archlibexp} unless $self->{PERL_ARCHLIB};
836         $self->{PERL_INC}     = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
837         my $perl_h;
838         die <<EOM unless (-f ($perl_h = $self->catfile("$self->{PERL_INC}","perl.h")));
839 Error: Unable to locate installed Perl libraries or Perl source code.
840
841 It is recommended that you install perl in a standard location before
842 building extensions. You can say:
843
844     $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory
845
846 if you have not yet installed perl but still want to build this
847 extension now.
848 (You get this message, because MakeMaker could not find "$perl_h")
849 EOM
850
851 #        print STDOUT "Using header files found in $self->{PERL_INC}\n"
852 #            if $Verbose && $self->needs_linking();
853
854     }
855
856     # INST_LIB typically pre-set if building an extension after
857     # perl has been built and installed. Setting INST_LIB allows
858     # you to build directly into, say $Config::Config{privlibexp}.
859     unless ($self->{INST_LIB}){
860
861
862         ##### XXXXX We have to change this nonsense
863
864         if (defined $self->{PERL_SRC}) {
865             $self->{INST_LIB} = $self->{PERL_LIB};
866         } else {
867             $self->{INST_LIB} = $self->catdir(".","blib");
868         }
869     }
870     # Try to work out what INST_ARCHLIB should be if not set:
871     unless ($self->{INST_ARCHLIB}){
872         my(%archmap) = (
873                         # our private build lib
874             $self->catdir(".","blib")   =>
875                         $self->catdir(".","blib",$Config::Config{archname}),
876             $self->{PERL_LIB}   => $self->{PERL_ARCHLIB},
877             $Config::Config{privlibexp} => $Config::Config{archlibexp},
878             $inc_carp_dir       => $inc_config_dir,
879         );
880         $self->{INST_ARCHLIB} = $archmap{$self->{INST_LIB}};
881         unless($self->{INST_ARCHLIB}){
882             # Oh dear, we'll have to default it and warn the user
883             my($archname) = $Config::Config{archname};
884             if (-d "$self->{INST_LIB}/$archname"){
885                 $self->{INST_ARCHLIB} = $self->catdir("$self->{INST_LIB}","$archname");
886                 print STDOUT "Defaulting INST_ARCHLIB to $self->{INST_ARCHLIB}\n";
887             } else {
888                 $self->{INST_ARCHLIB} = $self->{INST_LIB};
889             }
890         }
891     }
892     $self->{INST_EXE} ||= $self->catdir('.','blib',$Config::Config{archname});
893
894     my($prefix) = $Config{'prefix'};
895     $prefix = VMS::Filespec::unixify($prefix) if $Is_VMS;
896     unless ($self->{PREFIX}){
897         $self->{PREFIX} = $prefix;
898     }
899 # With perl5.002 it turns out, that we hardcoded some assumptions in here:
900 #       $self->{INSTALLPRIVLIB} = $self->catdir($self->{PREFIX},"lib","perl5");
901 #       $self->{INSTALLBIN} = $self->catdir($self->{PREFIX},"bin");
902 #       $self->{INSTALLMAN3DIR} = $self->catdir($self->{PREFIX},"perl5","man","man3")
903 #           unless defined $self->{INSTALLMAN3DIR};
904
905     # we have to look at the relation between $Config{prefix} and
906     # the requested values
907     $self->{INSTALLPRIVLIB} = $Config{installprivlib};
908     $self->{INSTALLPRIVLIB} = VMS::Filespec::unixpath($self->{INSTALLPRIVLIB})
909       if $Is_VMS;
910     $self->{INSTALLPRIVLIB} =~ s/\Q$prefix\E/\$(PREFIX)/;
911     $self->{INSTALLBIN} = $Config{installbin};
912     $self->{INSTALLBIN} = VMS::Filespec::unixpath($self->{INSTALLBIN})
913       if $Is_VMS;
914     $self->{INSTALLBIN} =~ s/\Q$prefix\E/\$(PREFIX)/;
915     $self->{INSTALLMAN1DIR} = $Config{installman1dir};
916     $self->{INSTALLMAN1DIR} = VMS::Filespec::unixpath($self->{INSTALLMAN1DIR})
917       if $Is_VMS;
918     $self->{INSTALLMAN1DIR} =~ s/\Q$prefix\E/\$(PREFIX)/;
919     $self->{INSTALLMAN3DIR} = $Config{installman3dir};
920     $self->{INSTALLMAN3DIR} = VMS::Filespec::unixpath($self->{INSTALLMAN3DIR})
921       if $Is_VMS;
922     $self->{INSTALLMAN3DIR} =~ s/\Q$prefix\E/\$(PREFIX)/;
923
924     if( $self->{INSTALLPRIVLIB} && ! $self->{INSTALLARCHLIB} ){
925 # Same as above here. With the unresolved versioned directory issue, we have to
926 # be more careful to follow Configure
927 #       my($archname) = $Config::Config{archname};
928 #       if (-d $self->catdir($self->{INSTALLPRIVLIB},$archname)){
929 #           $self->{INSTALLARCHLIB} = $self->catdir($self->{INSTALLPRIVLIB},$archname);
930 #           print STDOUT "Defaulting INSTALLARCHLIB to $self->{INSTALLARCHLIB}\n";
931 #       } else {
932 #           $self->{INSTALLARCHLIB} = $self->{INSTALLPRIVLIB};
933 #       }
934         my($installprivlib) = $Config{'installprivlib'};
935         $installprivlib = VMS::Filespec::unixify($installprivlib) if $Is_VMS;
936         $self->{INSTALLARCHLIB} = $Config{installarchlib};
937         $self->{INSTALLARCHLIB} = VMS::Filespec::unixpath($self->{INSTALLARCHLIB})
938            if $Is_VMS;
939         $self->{INSTALLARCHLIB} =~ s/\Q$installprivlib\E/$self->{INSTALLPRIVLIB}/;
940
941         # It's a pain to be so friendly to the user. I wish we wouldn't have been so nice.
942         # Now we have '$(PREFIX)' in the string, and the directory won't exist
943         my($installarchlib);
944         ($installarchlib = $self->{INSTALLARCHLIB}) =~ s/\$\(PREFIX\)/$self->{PREFIX}/;
945         if (-d $installarchlib) {
946         } else {
947             print STDOUT "Directory $self->{INSTALLARCHLIB} not found, thusly\n" if $Verbose;
948             $self->{INSTALLARCHLIB} = $self->{INSTALLPRIVLIB};
949         }
950         print STDOUT "Defaulting INSTALLARCHLIB to $self->{INSTALLARCHLIB}\n" if $Verbose;
951     }
952
953     $self->{INSTALLPRIVLIB} ||= $Config::Config{installprivlib};
954     $self->{INSTALLARCHLIB} ||= $Config::Config{installarchlib};
955     $self->{INSTALLBIN}     ||= $Config::Config{installbin};
956
957     $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir}
958         unless defined $self->{INSTALLMAN1DIR};
959     unless (defined $self->{INST_MAN1DIR}){
960         if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){
961             $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR};
962         } else {
963             $self->{INST_MAN1DIR} = $self->catdir('.','blib','man','man1');
964         }
965     }
966     $self->{MAN1EXT} ||= $Config::Config{man1ext};
967
968     $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir}
969         unless defined $self->{INSTALLMAN3DIR};
970     unless (defined $self->{INST_MAN3DIR}){
971         if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){
972             $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR};
973         } else {
974             $self->{INST_MAN3DIR} = $self->catdir('.','blib','man','man3');
975         }
976     }
977     $self->{MAN3EXT} ||= $Config::Config{man3ext};
978
979     print STDOUT "CONFIG must be an array ref\n"
980         if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
981     $self->{CONFIG} = [] unless (ref $self->{CONFIG});
982     push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
983     push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags};
984     my(%once_only,$m);
985     foreach $m (@{$self->{CONFIG}}){
986         next if $once_only{$m};
987         print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
988                 unless exists $Config::Config{$m};
989         $self->{uc $m} ||= $Config::Config{$m};
990         $once_only{$m} = 1;
991     }
992
993     # These should never be needed
994     $self->{LD} ||= 'ld';
995     $self->{OBJ_EXT} ||= '.o';
996     $self->{LIB_EXT} ||= '.a';
997
998     $self->{MAP_TARGET} ||= "perl";
999
1000     unless ($self->{LIBPERL_A}){
1001         $self->{LIBPERL_A} = "libperl$self->{LIB_EXT}";
1002     }
1003
1004     # make a few simple checks
1005     warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1006         (Exporter.pm not found)"
1007         unless (-f $self->catfile("$self->{PERL_LIB}","Exporter.pm"));
1008
1009     ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME};
1010     if ($self->{VERSION_FROM}){
1011         local *PM;
1012         open PM, $self->{VERSION_FROM} or die "Could not open '$self->{VERSION_FROM}' (attribute VERSION_FROM): $!";
1013         while (<PM>) {
1014             chop;
1015             next unless /\$([\w:]*\bVERSION)\b.*=/;
1016             local $ExtUtils::MakeMaker::module_version_variable = $1;
1017             my($eval) = "$_;";
1018             eval $eval;
1019             die "Could not eval '$eval': $@" if $@;
1020             if ($self->{VERSION} = $$ExtUtils::MakeMaker::module_version_variable){
1021                 print "Setting VERSION to $self->{VERSION}\n" if $Verbose;
1022             } else {
1023                 print "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n";
1024             }
1025             last;
1026         }
1027         close PM;
1028     }
1029     $self->{VERSION} = "0.10" unless $self->{VERSION};
1030     ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
1031
1032     # Graham Barr and Paul Marquess had some ideas how to ensure
1033     # version compatibility between the *.pm file and the
1034     # corresponding *.xs file. The bottomline was, that we need an
1035     # XS_VERSION macro that defaults to VERSION:
1036     $self->{XS_VERSION} ||= $self->{VERSION};
1037
1038     # --- Initialize Perl Binary Locations
1039
1040     # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
1041     # will be working versions of perl 5. miniperl has priority over perl
1042     # for PERL to ensure that $(PERL) is usable while building ./ext/*
1043     my ($component,@defpath);
1044     foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
1045         push @defpath, $component if defined $component;
1046     }
1047     $self->{PERL} =
1048         $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ],
1049             \@defpath, $ExtUtils::MakeMaker::Verbose ) unless ($self->{PERL});
1050 # don't check, if perl is executable, maybe they
1051 # have decided to supply switches with perl
1052
1053     # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1054     ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
1055         unless ($self->{FULLPERL});
1056 }
1057
1058 # Ilya's suggestion, will have to go into ExtUtils::MM_OS2 and MM_VMS
1059 sub path {
1060     my($self) = @_;
1061     my $path_sep = $Is_OS2 ? ";" : $Is_VMS ? "/" : ":";
1062     my $path = $ENV{PATH};
1063     $path =~ s:\\:/:g if $Is_OS2;
1064     my @path = split $path_sep, $path;
1065 }
1066
1067 sub init_dirscan {      # --- File and Directory Lists (.xs .pm .pod etc)
1068     my($self) = @_;
1069     unless (ref $self){
1070         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1071         $self = $ExtUtils::MakeMaker::Parent[-1];
1072     }
1073     my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
1074     local(%pm); #the sub in find() has to see this hash
1075     $ignore{'test.pl'} = 1;
1076     $ignore{'makefile.pl'} = 1 if $Is_VMS;
1077     foreach $name ($self->lsdir(".")){
1078         next if ($name =~ /^\./ or $ignore{$name});
1079         if (-d $name){
1080             $dir{$name} = $name if (-f "$name/Makefile.PL");
1081         } elsif ($name =~ /\.xs$/){
1082             my($c); ($c = $name) =~ s/\.xs$/.c/;
1083             $xs{$name} = $c;
1084             $c{$c} = 1;
1085         } elsif ($name =~ /\.c$/i){
1086             $c{$name} = 1
1087                 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1088         } elsif ($name =~ /\.h$/i){
1089             $h{$name} = 1;
1090         } elsif ($name =~ /\.(p[ml]|pod)$/){
1091             $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);
1092         } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
1093             ($pl_files{$name} = $name) =~ s/\.PL$// ;
1094         } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' &&
1095                  $name ne 'test.pl') {  # case-insensitive filesystem
1096             ($pl_files{$name} = $name) =~ s/\.pl$// ;
1097         }
1098     }
1099
1100     # Some larger extensions often wish to install a number of *.pm/pl
1101     # files into the library in various locations.
1102
1103     # The attribute PMLIBDIRS holds an array reference which lists
1104     # subdirectories which we should search for library files to
1105     # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ].  We
1106     # recursively search through the named directories (skipping any
1107     # which don't exist or contain Makefile.PL files).
1108
1109     # For each *.pm or *.pl file found $self->libscan() is called with
1110     # the default installation path in $_[1]. The return value of
1111     # libscan defines the actual installation location.  The default
1112     # libscan function simply returns the path.  The file is skipped
1113     # if libscan returns false.
1114
1115     # The default installation location passed to libscan in $_[1] is:
1116     #
1117     #  ./*.pm           => $(INST_LIBDIR)/*.pm
1118     #  ./xyz/...        => $(INST_LIBDIR)/xyz/...
1119     #  ./lib/...        => $(INST_LIB)/...
1120     #
1121     # In this way the 'lib' directory is seen as the root of the actual
1122     # perl library whereas the others are relative to INST_LIBDIR
1123     # (which includes ROOTEXT). This is a subtle distinction but one
1124     # that's important for nested modules.
1125
1126     $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]
1127         unless $self->{PMLIBDIRS};
1128
1129     #only existing directories that aren't in $dir are allowed
1130
1131     # Avoid $_ wherever possible:
1132     # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1133     my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1134     my ($pmlibdir);
1135     @{$self->{PMLIBDIRS}} = ();
1136     foreach $pmlibdir (@pmlibdirs) {
1137         -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1138     }
1139
1140     if (@{$self->{PMLIBDIRS}}){
1141         print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1142             if ($ExtUtils::MakeMaker::Verbose >= 2);
1143         use File::Find;         # try changing to require !
1144         File::Find::find(sub {
1145             if (-d $_){
1146                 if ($_ eq "CVS" || $_ eq "RCS"){
1147                     $File::Find::prune = 1;
1148                 }
1149                 return;
1150             }
1151             my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
1152             my($striplibpath,$striplibname);
1153             $prefix =  '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:);
1154             ($striplibname,$striplibpath) = fileparse($striplibpath);
1155             my($inst) = $self->catfile($prefix,$striplibpath,$striplibname);
1156             local($_) = $inst; # for backwards compatibility
1157             $inst = $self->libscan($inst);
1158             print "libscan($path) => '$inst'\n" if ($ExtUtils::MakeMaker::Verbose >= 2);
1159             return unless $inst;
1160             $pm{$path} = $inst;
1161         }, @{$self->{PMLIBDIRS}});
1162     }
1163
1164     $self->{DIR} = [sort keys %dir] unless $self->{DIR};
1165     $self->{XS}  = \%xs             unless $self->{XS};
1166     $self->{PM}  = \%pm             unless $self->{PM};
1167     $self->{C}   = [sort keys %c]   unless $self->{C};
1168     my(@o_files) = @{$self->{C}};
1169     $self->{O_FILES} = [grep s/\.c$/$self->{OBJ_EXT}/i, @o_files] ;
1170     $self->{H}   = [sort keys %h]   unless $self->{H};
1171     $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
1172
1173     # Set up names of manual pages to generate from pods
1174     if ($self->{MAN1PODS}) {
1175     } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) {
1176         $self->{MAN1PODS} = {};
1177     } else {
1178         my %manifypods = ();
1179         if ( exists $self->{EXE_FILES} ) {
1180             foreach $name (@{$self->{EXE_FILES}}) {
1181                 local(*TESTPOD);
1182                 my($ispod)=0;
1183                 # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?)
1184                 if (open(TESTPOD,"<$name")) {
1185                     my $testpodline;
1186                     while ($testpodline = <TESTPOD>) {
1187                         if($testpodline =~ /^=head1\s+\w+/) {
1188                             $ispod=1;
1189                             last;
1190                         }
1191                     }
1192                     close(TESTPOD);
1193                 } else {
1194                     # If it doesn't exist yet, we assume, it has pods in it
1195                     $ispod = 1;
1196                 }
1197                 if( $ispod ) {
1198                     $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)');
1199                 }
1200             }
1201         }
1202         $self->{MAN1PODS} = \%manifypods;
1203     }
1204     if ($self->{MAN3PODS}) {
1205     } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) {
1206         $self->{MAN3PODS} = {};
1207     } else {
1208         my %manifypods = (); # we collect the keys first, i.e. the files
1209                              # we have to convert to pod
1210         foreach $name (keys %{$self->{PM}}) {
1211             if ($name =~ /\.pod$/ ) {
1212                 $manifypods{$name} = $self->{PM}{$name};
1213             } elsif ($name =~ /\.p[ml]$/ ) {
1214                 local(*TESTPOD);
1215                 my($ispod)=0;
1216                 open(TESTPOD,"<$name");
1217                 my $testpodline;
1218                 while ($testpodline = <TESTPOD>) {
1219                     if($testpodline =~ /^=head/) {
1220                         $ispod=1;
1221                         last;
1222                     }
1223                     #Speculation on the future (K.A., not A.K. :)
1224                     #if(/^=don't\S+install/) { $ispod=0; last}
1225                 }
1226                 close(TESTPOD);
1227
1228                 if( $ispod ) {
1229                     $manifypods{$name} = $self->{PM}{$name};
1230                 }
1231             }
1232         }
1233
1234         # Remove "Configure.pm" and similar, if it's not the only pod listed
1235         # To force inclusion, just name it "Configure.pod", or override MAN3PODS
1236         foreach $name (keys %manifypods) {
1237             if ($name =~ /(config|install|setup).*\.pm/i) {
1238                 delete $manifypods{$name};
1239                 next;
1240             }
1241             my($manpagename) = $name;
1242             unless ($manpagename =~ s!^(\W*)lib\W!$1!) {
1243                 $manpagename = $self->catfile($self->{ROOTEXT},$manpagename);
1244             }
1245             $manpagename =~ s/\.p(od|m|l)$//;
1246             # Strip leading slashes
1247             $manpagename =~ s!^/+!!;
1248             # Turn other slashes into colons
1249 #           $manpagename =~ s,/+,::,g;
1250             $manpagename = $self->replace_manpage_separator($manpagename);
1251             $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)");
1252         }
1253         $self->{MAN3PODS} = \%manifypods;
1254     }
1255 }
1256
1257 sub lsdir {
1258     my($self) = shift;
1259     my($dir, $regex) = @_;
1260     local(*DIR, @ls);
1261     opendir(DIR, $dir || ".") or return ();
1262     @ls = readdir(DIR);
1263     closedir(DIR);
1264     @ls = grep(/$regex/, @ls) if $regex;
1265     @ls;
1266 }
1267
1268 sub replace_manpage_separator {
1269     my($self,$man) = @_;
1270     $man =~ s,/+,::,g;
1271     $man;
1272 }
1273
1274 sub libscan {
1275     my($self,$path) = @_;
1276     return '' if $path =~ m:/(RCS|SCCS)/: ;
1277     $path;
1278 }
1279
1280 sub init_others {       # --- Initialize Other Attributes
1281     my($self) = shift;
1282     unless (ref $self){
1283         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1284         $self = $ExtUtils::MakeMaker::Parent[-1];
1285     }
1286
1287     # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1288     # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1289     # undefined. In any case we turn it into an anon array:
1290
1291     # May check $Config{libs} too, thus not empty.
1292     $self->{LIBS}=[''] unless $self->{LIBS}; 
1293
1294     $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq SCALAR;
1295     $self->{LD_RUN_PATH} = "";
1296     my($libs);
1297     foreach $libs ( @{$self->{LIBS}} ){
1298         $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1299         my(@libs) = $self->extliblist($libs);
1300         if ($libs[0] or $libs[1] or $libs[2]){
1301             # LD_RUN_PATH now computed by ExtUtils::Liblist
1302             ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1303             last;
1304         }
1305     }
1306
1307     unless ( $self->{OBJECT} ){
1308         # init_dirscan should have found out, if we have C files
1309         $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1310     }
1311     $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1312     $self->{BOOTDEP}  = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1313     $self->{PERLMAINCC} ||= '$(CC)';
1314     $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1315
1316     # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1317     # the 'dynamic' section of MM.  We don't have this problem with
1318     # 'static', since we either must use it (%Config says we can't
1319     # use dynamic loading) or the caller asked for it explicitly.
1320     if (!$self->{LINKTYPE}) {
1321        $self->{LINKTYPE} = grep(/dynamic/,@{$self->{SKIP} || []})
1322                         ? 'static'
1323                         : ($Config::Config{usedl} ? 'dynamic' : 'static');
1324     };
1325
1326     # These get overridden for VMS and maybe some other systems
1327     $self->{NOOP}  ||= "";
1328     $self->{FIRST_MAKEFILE} ||= "Makefile";
1329     $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1330     $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
1331     $self->{NOECHO} ||= '@';
1332     $self->{RM_F}  ||= "rm -f";
1333     $self->{RM_RF} ||= "rm -rf";
1334     $self->{TOUCH} ||= "touch";
1335     $self->{CP} ||= "cp";
1336     $self->{MV} ||= "mv";
1337     $self->{CHMOD} ||= "chmod";
1338     $self->{UMASK_NULL} ||= "umask 0";
1339 }
1340
1341 sub find_perl {
1342     my($self, $ver, $names, $dirs, $trace) = @_;
1343     unless (ref $self){
1344         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1345         $self = $ExtUtils::MakeMaker::Parent[-1];
1346     }
1347     my($name, $dir);
1348     if ($trace >= 2){
1349         print "Looking for perl $ver by these names:
1350 @$names
1351 in these dirs:
1352 @$dirs
1353 ";
1354     }
1355     foreach $dir (@$dirs){
1356         next unless defined $dir; # $self->{PERL_SRC} may be undefined
1357         foreach $name (@$names){
1358             my $abs;
1359             if ($self->file_name_is_absolute($name)) {
1360                 $abs = $name;
1361             } elsif (($name =~ m|/|) && ($name !~ m|^\.{1,2}/|)) {
1362                 # name is a path that does not begin with dot or dotdot
1363                 $abs = $self->catfile(".", $name);
1364             } else {
1365                 $abs = $self->catfile($dir, $name);
1366             }
1367             print "Checking $abs\n" if ($trace >= 2);
1368             next unless $self->maybe_command($abs);
1369             print "Executing $abs\n" if ($trace >= 2);
1370             if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
1371                 print "Using PERL=$abs\n" if $trace;
1372                 return $abs;
1373             }
1374         }
1375     }
1376     print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1377     0; # false and not empty
1378 }
1379
1380
1381 # Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here
1382 sub maybe_command_in_dirs {     # $ver is optional argument if looking for perl
1383     my($self, $names, $dirs, $trace, $ver) = @_;
1384     my($name, $dir);
1385     foreach $dir (@$dirs){
1386         next unless defined $dir; # $self->{PERL_SRC} may be undefined
1387         foreach $name (@$names){
1388             my($abs,$tryabs);
1389             if ($self->file_name_is_absolute($name)) {
1390                 $abs = $name;
1391             } elsif ($name =~ m|/|) {
1392                 $abs = $self->catfile(".", $name); # not absolute
1393             } else {
1394                 $abs = $self->catfile($dir, $name);
1395             }
1396             print "Checking $abs for $name\n" if ($trace >= 2);
1397             next unless $tryabs = $self->maybe_command($abs);
1398             print "Substituting $tryabs instead of $abs\n" 
1399                 if ($trace >= 2 and $tryabs ne $abs);
1400             $abs = $tryabs;
1401             if (defined $ver) {
1402                 print "Executing $abs\n" if ($trace >= 2);
1403                 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
1404                     print "Using PERL=$abs\n" if $trace;
1405                     return $abs;
1406                 }
1407             } else { # Do not look for perl
1408                 return $abs;
1409             }
1410         }
1411     }
1412 }
1413
1414 sub maybe_command {
1415     my($self,$file) = @_;
1416     return $file if -x $file && ! -d $file;
1417     return;
1418 }
1419
1420 sub perl_script {
1421     my($self,$file) = @_;
1422     return 1 if -r $file && ! -d $file;
1423     return;
1424 }
1425
1426 # Ilya's suggestion, not yet used
1427 sub file_name_is_absolute {
1428     my($self,$file) = @_;
1429     $file =~ m:^/: ;
1430 }
1431
1432 sub post_initialize {
1433     my($self) = shift;
1434     unless (ref $self){
1435         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1436         $self = $ExtUtils::MakeMaker::Parent[-1];
1437     }
1438     "";
1439 }
1440
1441 # --- Constants Sections ---
1442
1443 sub const_config {
1444     my($self) = shift;
1445     unless (ref $self){
1446         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1447         $self = $ExtUtils::MakeMaker::Parent[-1];
1448     }
1449     my(@m,$m);
1450     push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
1451     push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
1452     my(%once_only);
1453     foreach $m (@{$self->{CONFIG}}){
1454         next if $once_only{$m};
1455         push @m, "\U$m\E = ".$self->{uc $m}."\n";
1456         $once_only{$m} = 1;
1457     }
1458     join('', @m);
1459 }
1460
1461 sub constants {
1462     my($self) = @_;
1463     unless (ref $self){
1464         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1465         $self = $ExtUtils::MakeMaker::Parent[-1];
1466     }
1467     my(@m,$tmp);
1468
1469     push @m, "
1470 NAME = $self->{NAME}
1471 DISTNAME = $self->{DISTNAME}
1472 NAME_SYM = $self->{NAME_SYM}
1473 VERSION = $self->{VERSION}
1474 VERSION_SYM = $self->{VERSION_SYM}
1475 VERSION_MACRO = VERSION
1476 DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
1477 XS_VERSION = $self->{XS_VERSION}
1478 XS_VERSION_MACRO = XS_VERSION
1479 XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
1480
1481 # In which directory should we put this extension during 'make'?
1482 # This is typically ./blib.
1483 # (also see INST_LIBDIR and relationship to ROOTEXT)
1484 INST_LIB = $self->{INST_LIB}
1485 INST_ARCHLIB = $self->{INST_ARCHLIB}
1486 INST_EXE = $self->{INST_EXE}
1487
1488 PREFIX = $self->{PREFIX}
1489
1490 # AFS users will want to set the installation directories for
1491 # the final 'make install' early without setting INST_LIB,
1492 # INST_ARCHLIB, and INST_EXE for the testing phase
1493 INSTALLPRIVLIB = $self->{INSTALLPRIVLIB}
1494 INSTALLARCHLIB = $self->{INSTALLARCHLIB}
1495 INSTALLBIN = $self->{INSTALLBIN}
1496
1497 # Perl library to use when building the extension
1498 PERL_LIB = $self->{PERL_LIB}
1499 PERL_ARCHLIB = $self->{PERL_ARCHLIB}
1500 LIBPERL_A = $self->{LIBPERL_A}
1501
1502 MAKEMAKER = \$(PERL_LIB)/ExtUtils/MakeMaker.pm
1503 MM_VERSION = $ExtUtils::MakeMaker::VERSION
1504 FIRST_MAKEFILE  = $self->{FIRST_MAKEFILE}
1505 MAKE_APERL_FILE = $self->{MAKE_APERL_FILE}
1506
1507 PERLMAINCC = $self->{PERLMAINCC}
1508 ";
1509
1510     push @m, "
1511 # Where is the perl source code located?
1512 PERL_SRC = $self->{PERL_SRC}\n" if $self->{PERL_SRC};
1513
1514     push @m, "
1515 # Perl header files (will eventually be under PERL_LIB)
1516 PERL_INC = $self->{PERL_INC}
1517 # Perl binaries
1518 PERL = $self->{PERL}
1519 FULLPERL = $self->{FULLPERL}
1520 ";
1521     push @m, "
1522 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
1523 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
1524 # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
1525 # DLBASE  = Basename part of dynamic library. May be just equal BASEEXT.
1526 FULLEXT = $self->{FULLEXT}
1527 BASEEXT = $self->{BASEEXT}
1528 ROOTEXT = $self->{ROOTEXT}
1529 DLBASE  = $self->{DLBASE}
1530 ";
1531
1532     push @m, "
1533 VERSION_FROM = $self->{VERSION_FROM}
1534 " if defined $self->{VERSION_FROM};
1535
1536     push @m, "
1537 INC = $self->{INC}
1538 DEFINE = $self->{DEFINE}
1539 OBJECT = $self->{OBJECT}
1540 LDFROM = $self->{LDFROM}
1541 LINKTYPE = $self->{LINKTYPE}
1542
1543 # Handy lists of source code files:
1544 XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
1545 C_FILES = ".join(" \\\n\t", @{$self->{C}})."
1546 O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
1547 H_FILES = ".join(" \\\n\t", @{$self->{H}})."
1548 MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
1549 MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
1550
1551 # Man installation stuff:
1552 INST_MAN1DIR    = $self->{INST_MAN1DIR}
1553 INSTALLMAN1DIR  = $self->{INSTALLMAN1DIR}
1554 MAN1EXT = $self->{MAN1EXT}
1555
1556 INST_MAN3DIR    = $self->{INST_MAN3DIR}
1557 INSTALLMAN3DIR  = $self->{INSTALLMAN3DIR}
1558 MAN3EXT = $self->{MAN3EXT}
1559
1560
1561 # work around a famous dec-osf make(1) feature(?):
1562 makemakerdflt: all
1563
1564 .SUFFIXES: .xs .c .C \$(OBJ_EXT)
1565
1566 # .PRECIOUS: Makefile    # seems to be not necessary anymore
1567
1568 .PHONY: all config static dynamic test linkext
1569
1570 # This extension may link to it's own library (see SDBM_File)
1571 MYEXTLIB = $self->{MYEXTLIB}
1572
1573 # Where is the Config information that we are using/depend on
1574 CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h \$(VERSION_FROM)
1575 ";
1576
1577     push @m, '
1578 # Where to put things:
1579 INST_LIBDIR     = $(INST_LIB)$(ROOTEXT)
1580 INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
1581
1582 INST_AUTODIR      = $(INST_LIB)/auto/$(FULLEXT)
1583 INST_ARCHAUTODIR  = $(INST_ARCHLIB)/auto/$(FULLEXT)
1584 ';
1585
1586     if ($self->has_link_code()) {
1587         push @m, '
1588 INST_STATIC  = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
1589 INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
1590 INST_BOOT    = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
1591 ';
1592     } else {
1593         push @m, '
1594 INST_STATIC  =
1595 INST_DYNAMIC =
1596 INST_BOOT    =
1597 ';
1598     }
1599
1600     if ($Is_OS2) {
1601         $tmp = "$self->{BASEEXT}.def";
1602     } else {
1603         $tmp = "";
1604     }
1605     push @m, "
1606 EXPORT_LIST = $tmp
1607 ";
1608
1609     if ($Is_OS2) {
1610         $tmp = "\$(PERL_INC)/libperl.lib";
1611     } else {
1612         $tmp = "";
1613     }
1614     push @m, "
1615 PERL_ARCHIVE = $tmp
1616 ";
1617
1618     push @m, '
1619 INST_PM = '.join(" \\\n\t", sort values %{$self->{PM}}).'
1620 ';
1621
1622     join('',@m);
1623 }
1624
1625 sub const_loadlibs {
1626     my($self) = shift;
1627     unless (ref $self){
1628         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1629         $self = $ExtUtils::MakeMaker::Parent[-1];
1630     }
1631     return "" unless $self->needs_linking;
1632     # This description can be deleted after ExtUtils::Liblist is in
1633     # the perl dist with pods
1634     "
1635 # $self->{NAME} might depend on some other libraries:
1636 # (These comments may need revising:)
1637 #
1638 # Dependent libraries can be linked in one of three ways:
1639 #
1640 #  1.  (For static extensions) by the ld command when the perl binary
1641 #      is linked with the extension library. See EXTRALIBS below.
1642 #
1643 #  2.  (For dynamic extensions) by the ld command when the shared
1644 #      object is built/linked. See LDLOADLIBS below.
1645 #
1646 #  3.  (For dynamic extensions) by the DynaLoader when the shared
1647 #      object is loaded. See BSLOADLIBS below.
1648 #
1649 # EXTRALIBS =   List of libraries that need to be linked with when
1650 #               linking a perl binary which includes this extension
1651 #               Only those libraries that actually exist are included.
1652 #               These are written to a file and used when linking perl.
1653 #
1654 # LDLOADLIBS =  List of those libraries which can or must be linked into
1655 #               the shared library when created using ld. These may be
1656 #               static or dynamic libraries.
1657 #               LD_RUN_PATH is a colon separated list of the directories
1658 #               in LDLOADLIBS. It is passed as an environment variable to
1659 #               the process that links the shared library.
1660 #
1661 # BSLOADLIBS =  List of those libraries that are needed but can be
1662 #               linked in dynamically at run time on this platform.
1663 #               SunOS/Solaris does not need this because ld records
1664 #               the information (from LDLOADLIBS) into the object file.
1665 #               This list is used to create a .bs (bootstrap) file.
1666 #
1667 EXTRALIBS  = $self->{EXTRALIBS}
1668 LDLOADLIBS = $self->{LDLOADLIBS}
1669 BSLOADLIBS = $self->{BSLOADLIBS}
1670 LD_RUN_PATH= $self->{LD_RUN_PATH}
1671 ";
1672 }
1673
1674 sub const_cccmd {
1675     my($self,$libperl)=@_;
1676     unless (ref $self){
1677         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1678         $self = $ExtUtils::MakeMaker::Parent[-1];
1679     }
1680     return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
1681     return '' unless $self->needs_linking();
1682     $libperl or $libperl = $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
1683     $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
1684     # This is implemented in the same manner as extliblist,
1685     # e.g., do both and compare results during the transition period.
1686     my($cc,$ccflags,$optimize,$large,$split, $shflags)
1687         = @Config{qw(cc ccflags optimize large split shellflags)};
1688     my($optdebug) = "";
1689
1690     $shflags = '' unless $shflags;
1691     my($prog, $uc, $perltype);
1692
1693     my(%map) =  (
1694                 D =>   '-DDEBUGGING',
1695                 E =>   '-DEMBED',
1696                 DE =>  '-DDEBUGGING -DEMBED',
1697                 M =>   '-DEMBED -DMULTIPLICITY',
1698                 DM =>  '-DDEBUGGING -DEMBED -DMULTIPLICITY',
1699                 );
1700
1701     if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
1702         $uc = uc($1);
1703     } else {
1704         $uc = ""; # avoid warning
1705     }
1706     $perltype = $map{$uc} ? $map{$uc} : "";
1707
1708     if ($uc =~ /^D/) {
1709         $optdebug = "-g";
1710     }
1711
1712
1713     my($name);
1714     ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
1715     if ($prog = $Config::Config{$name}) {
1716         # Expand hints for this extension via the shell
1717         print STDOUT "Processing $name hint:\n" if $ExtUtils::MakeMaker::Verbose;
1718         my(@o)=`cc=\"$cc\"
1719           ccflags=\"$ccflags\"
1720           optimize=\"$optimize\"
1721           perltype=\"$perltype\"
1722           optdebug=\"$optdebug\"
1723           large=\"$large\"
1724           split=\"$split\"
1725           eval '$prog'
1726           echo cc=\$cc
1727           echo ccflags=\$ccflags
1728           echo optimize=\$optimize
1729           echo perltype=\$perltype
1730           echo optdebug=\$optdebug
1731           echo large=\$large
1732           echo split=\$split
1733           `;
1734         my(%cflags,$line);
1735         foreach $line (@o){
1736             chomp $line;
1737             if ($line =~ /(.*?)=\s*(.*)\s*$/){
1738                 $cflags{$1} = $2;
1739                 print STDOUT "  $1 = $2\n" if $ExtUtils::MakeMaker::Verbose;
1740             } else {
1741                 print STDOUT "Unrecognised result from hint: '$line'\n";
1742             }
1743         }
1744         (    $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split )=@cflags{
1745           qw( cc  ccflags  perltype  optdebug  optimize  large  split)};
1746     }
1747
1748     if ($optdebug) {
1749         $optimize = $optdebug;
1750     }
1751
1752     my($new) = "$cc -c \$(INC) $ccflags $optimize $perltype $large $split";
1753     $new =~ s/^\s+//; $new =~ s/\s+/ /g; $new =~ s/\s+$//;
1754
1755     my($cccmd) = $new;
1756     $cccmd =~ s/^\s*\Q$Config::Config{cc}\E\s/\$(CC) /;
1757     $cccmd .= " \$(DEFINE_VERSION) \$(XS_DEFINE_VERSION)";
1758     $self->{CONST_CCCMD} = "CCCMD = $cccmd\n";
1759 }
1760
1761 # --- Tool Sections ---
1762
1763 sub tool_autosplit {
1764     my($self, %attribs) = @_;
1765     unless (ref $self){
1766         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1767         $self = $ExtUtils::MakeMaker::Parent[-1];
1768     }
1769     my($asl) = "";
1770     $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
1771     q{
1772 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
1773 AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
1774 };
1775 }
1776
1777 sub tool_xsubpp {
1778     my($self) = shift;
1779     unless (ref $self){
1780         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1781         $self = $ExtUtils::MakeMaker::Parent[-1];
1782     }
1783     my($xsdir)  = "$self->{PERL_LIB}/ExtUtils";
1784     # drop back to old location if xsubpp is not in new location yet
1785     $xsdir = "$self->{PERL_SRC}/ext" unless (-f "$self->{PERL_LIB}/ExtUtils/xsubpp");
1786     my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
1787     if( $self->{TYPEMAPS} ){
1788         my $typemap;
1789         foreach $typemap (@{$self->{TYPEMAPS}}){
1790                 if( ! -f  $typemap ){
1791                         warn "Typemap $typemap not found.\n";
1792                 }
1793                 else{
1794                         push(@tmdeps,  $typemap);
1795                 }
1796         }
1797     }
1798     push(@tmdeps, "typemap") if -f "typemap";
1799     my(@tmargs) = map("-typemap $_", @tmdeps);
1800     if( exists $self->{XSOPT} ){
1801         unshift( @tmargs, $self->{XSOPT} );
1802     }
1803
1804     my $xsubpp_version = $self->xsubpp_version("$xsdir/xsubpp");
1805
1806     # What are the correct thresholds for version 1 && 2 Paul?
1807     if ( $xsubpp_version > 1.923 ){
1808         $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
1809     } else {
1810         if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
1811             print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
1812         Your version of xsubpp is $xsubpp_version and cannot handle this.
1813         Please upgrade to a more recent version of xsubpp.
1814 };
1815         } else {
1816             $self->{XSPROTOARG} = "";
1817         }
1818     }
1819
1820     "
1821 XSUBPPDIR = $xsdir
1822 XSUBPP = \$(XSUBPPDIR)/xsubpp
1823 XSPROTOARG = $self->{XSPROTOARG}
1824 XSUBPPDEPS = @tmdeps
1825 XSUBPPARGS = @tmargs
1826 ";
1827 };
1828
1829 sub xsubpp_version
1830 {
1831     my($self,$xsubpp) = @_;
1832     my ($version) ;
1833
1834     # try to figure out the version number of the xsubpp on the system
1835
1836     # first try the -v flag, introduced in 1.921 & 2.000a2
1837
1838     my $command = "$self->{PERL} $xsubpp -v 2>&1";
1839     print "Running: $command\n" if $Verbose;
1840     $version = `$command` ;
1841     warn "Running '$command' exits with status " . ($?>>8) if $?;
1842     chop $version ;
1843
1844     return $1 if $version =~ /^xsubpp version (.*)/ ;
1845
1846     # nope, then try something else
1847
1848     my $counter = '000';
1849     my ($file) = 'temp' ;
1850     $counter++ while -e "$file$counter"; # don't overwrite anything
1851     $file .= $counter;
1852
1853     open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
1854     print F <<EOM ;
1855 MODULE = fred PACKAGE = fred
1856
1857 int
1858 fred(a)
1859         int     a;
1860 EOM
1861
1862     close F ;
1863
1864     $command = "$self->{PERL} $xsubpp $file 2>&1";
1865     print "Running: $command\n" if $Verbose;
1866     my $text = `$command` ;
1867     warn "Running '$command' exits with status " . ($?>>8) if $?;
1868     unlink $file ;
1869
1870     # gets 1.2 -> 1.92 and 2.000a1
1871     return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/  ;
1872
1873     # it is either 1.0 or 1.1
1874     return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
1875
1876     # none of the above, so 1.0
1877     return "1.0" ;
1878 }
1879
1880 sub tools_other {
1881     my($self) = shift;
1882     unless (ref $self){
1883         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1884         $self = $ExtUtils::MakeMaker::Parent[-1];
1885     }
1886     "
1887 SHELL = /bin/sh
1888 LD = $self->{LD}
1889 TOUCH = $self->{TOUCH}
1890 CP = $self->{CP}
1891 MV = $self->{MV}
1892 RM_F  = $self->{RM_F}
1893 RM_RF = $self->{RM_RF}
1894 CHMOD = $self->{CHMOD}
1895 UMASK_NULL = $self->{UMASK_NULL}
1896 ".q{
1897 # The following is a portable way to say mkdir -p
1898 # To see which directories are created, change the if 0 to if 1
1899 MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){' \\
1900 -e 'next if -d $$p; my(@p); foreach(split(/\//,$$p)){' \\
1901 -e 'push(@p,$$_); next if -d "@p/"; print "mkdir @p" if 0;' \\
1902 -e 'mkdir("@p",0777)||die $$! } } exit 0;'
1903
1904 # This helps us to minimize the effect of the .exists files A yet
1905 # better solution would be to have a stable file in the perl
1906 # distribution with a timestamp of zero. But this solution doesn't
1907 # need any changes to the core distribution and works with older perls
1908 EQUALIZE_TIMESTAMP = $(PERL) -we 'open F, ">$$ARGV[1]"; close F;' \\
1909 -e 'utime ((stat("$$ARGV[0]"))[8,9], $$ARGV[1])'
1910 };
1911 }
1912
1913 sub dist {
1914     my($self, %attribs) = @_;
1915     unless (ref $self){
1916         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1917         $self = $ExtUtils::MakeMaker::Parent[-1];
1918     }
1919     my(@m);
1920     # VERSION should be sanitised before use as a file name
1921     my($name)     = $attribs{NAME}     || '$(DISTVNAME)';
1922     my($tar)      = $attribs{TAR}      || 'tar';        # eg /usr/bin/gnutar
1923     my($tarflags) = $attribs{TARFLAGS} || 'cvf';
1924     my($compress) = $attribs{COMPRESS} || 'compress';   # eg gzip
1925     my($suffix)   = $attribs{SUFFIX}   || 'Z';          # eg gz
1926     my($shar)     = $attribs{SHAR}     || 'shar';       # eg "shar --gzip"
1927     my($preop)    = $attribs{PREOP}    || "$self->{NOECHO}true"; # eg update MANIFEST
1928     my($postop)   = $attribs{POSTOP}   || "$self->{NOECHO}true"; # eg remove the distdir
1929     my($ci)       = $attribs{CI}       || 'ci -u';
1930     my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q';
1931     my($dist_cp)  = $attribs{DIST_CP}  || 'best';
1932     my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
1933
1934     push @m, "
1935 DISTVNAME = \$(DISTNAME)-\$(VERSION)
1936 TAR  = $tar
1937 TARFLAGS = $tarflags
1938 COMPRESS = $compress
1939 SUFFIX = $suffix
1940 SHAR = $shar
1941 PREOP = $preop
1942 POSTOP = $postop
1943 CI = $ci
1944 RCS_LABEL = $rcs_label
1945 DIST_CP = $dist_cp
1946 DIST_DEFAULT = $dist_default
1947 ";
1948     join "", @m;
1949 }
1950
1951 sub macro {
1952     my($self,%attribs) = @_;
1953     unless (ref $self){
1954         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1955         $self = $ExtUtils::MakeMaker::Parent[-1];
1956     }
1957     my(@m,$key,$val);
1958     while (($key,$val) = each %attribs){
1959         push @m, "$key = $val\n";
1960     }
1961     join "", @m;
1962 }
1963
1964 sub depend {
1965     my($self,%attribs) = @_;
1966     unless (ref $self){
1967         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1968         $self = $ExtUtils::MakeMaker::Parent[-1];
1969     }
1970     my(@m,$key,$val);
1971     while (($key,$val) = each %attribs){
1972         push @m, "$key: $val\n";
1973     }
1974     join "", @m;
1975 }
1976
1977 sub post_constants{
1978     my($self) = shift;
1979     unless (ref $self){
1980         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1981         $self = $ExtUtils::MakeMaker::Parent[-1];
1982     }
1983     "";
1984 }
1985
1986 sub pasthru {
1987     my($self) = shift;
1988     unless (ref $self){
1989         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1990         $self = $ExtUtils::MakeMaker::Parent[-1];
1991     }
1992     my(@m,$key);
1993
1994     my(@pasthru);
1995
1996     foreach $key (qw(INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN
1997                      INSTALLMAN1DIR INSTALLMAN3DIR LIBPERL_A
1998                      LINKTYPE PREFIX)){
1999         push @pasthru, "$key=\"\$($key)\"";
2000     }
2001
2002     push @m, "\nPASTHRU = ", join ("\\\n\t", @pasthru), "\n";
2003     join "", @m;
2004 }
2005
2006 # --- Translation Sections ---
2007
2008 sub c_o {
2009     my($self) = shift;
2010     unless (ref $self){
2011         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2012         $self = $ExtUtils::MakeMaker::Parent[-1];
2013     }
2014     return '' unless $self->needs_linking();
2015     my(@m);
2016     push @m, '
2017 .c$(OBJ_EXT):
2018         $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
2019
2020 .C$(OBJ_EXT):
2021         $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
2022 ';
2023     join "", @m;
2024 }
2025
2026 sub xs_c {
2027     my($self) = shift;
2028     unless (ref $self){
2029         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2030         $self = $ExtUtils::MakeMaker::Parent[-1];
2031     }
2032     return '' unless $self->needs_linking();
2033     '
2034 .xs.c:
2035         $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
2036 ';
2037 }
2038
2039 sub xs_o {      # many makes are too dumb to use xs_c then c_o
2040     my($self) = shift;
2041     unless (ref $self){
2042         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2043         $self = $ExtUtils::MakeMaker::Parent[-1];
2044     }
2045     return '' unless $self->needs_linking();
2046     '
2047 .xs$(OBJ_EXT):
2048         $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
2049         $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
2050 ';
2051 }
2052
2053 # --- Target Sections ---
2054
2055 sub top_targets {
2056     my($self) = shift;
2057     unless (ref $self){
2058         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2059         $self = $ExtUtils::MakeMaker::Parent[-1];
2060     }
2061     my(@m);
2062     push @m, '
2063 all ::  config $(INST_PM) subdirs linkext manifypods reorg_packlist
2064
2065 subdirs :: $(MYEXTLIB)
2066
2067 '.$self->{NOOP}.'
2068
2069 config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists
2070
2071 config :: $(INST_ARCHAUTODIR)/.exists Version_check
2072
2073 config :: $(INST_AUTODIR)/.exists
2074 ';
2075
2076     push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
2077
2078     if (%{$self->{MAN1PODS}}) {
2079         push @m, q[
2080 config :: $(INST_MAN1DIR)/.exists
2081
2082 ];
2083         push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
2084     }
2085     if (%{$self->{MAN3PODS}}) {
2086         push @m, q[
2087 config :: $(INST_MAN3DIR)/.exists
2088
2089 ];
2090         push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
2091     }
2092
2093     push @m, '
2094 $(O_FILES): $(H_FILES)
2095 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
2096
2097     push @m, q{
2098 help:
2099         perldoc ExtUtils::MakeMaker
2100 };
2101
2102     push @m, q{
2103 Version_check:
2104         }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
2105                 -e 'use ExtUtils::MakeMaker qw($$Version &Version_check);' \
2106                 -e '&Version_check("$(MM_VERSION)")'
2107 };
2108
2109     join('',@m);
2110 }
2111
2112 sub linkext {
2113     my($self, %attribs) = @_;
2114     unless (ref $self){
2115         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2116         $self = $ExtUtils::MakeMaker::Parent[-1];
2117     }
2118     # LINKTYPE => static or dynamic or ''
2119     my($linktype) = defined $attribs{LINKTYPE} ?
2120       $attribs{LINKTYPE} : '$(LINKTYPE)';
2121     "
2122 linkext :: $linktype
2123 $self->{NOOP}
2124 ";
2125 }
2126
2127 sub dlsyms {
2128     my($self,%attribs) = @_;
2129     unless (ref $self){
2130         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2131         $self = $ExtUtils::MakeMaker::Parent[-1];
2132     }
2133
2134     return '' unless ($Config::Config{osname} eq 'aix' && $self->needs_linking() );
2135
2136     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
2137     my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
2138     my(@m);
2139
2140     push(@m,"
2141 dynamic :: $self->{BASEEXT}.exp
2142
2143 ") unless $self->{SKIPHASH}{dynamic};
2144
2145     push(@m,"
2146 static :: $self->{BASEEXT}.exp
2147
2148 ") unless $self->{SKIPHASH}{static};
2149
2150     push(@m,"
2151 $self->{BASEEXT}.exp: Makefile.PL
2152 ",'     $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
2153         Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
2154         neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
2155 ');
2156
2157     join('',@m);
2158 }
2159
2160 # --- Dynamic Loading Sections ---
2161
2162 sub dynamic {
2163     my($self) = shift;
2164     unless (ref $self){
2165         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2166         $self = $ExtUtils::MakeMaker::Parent[-1];
2167     }
2168     '
2169 # $(INST_PM) has been moved to the all: target.
2170 # It remains here for awhile to allow for old usage: "make dynamic"
2171 dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
2172 '.$self->{NOOP}.'
2173 ';
2174 }
2175
2176 sub dynamic_bs {
2177     my($self, %attribs) = @_;
2178     unless (ref $self){
2179         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2180         $self = $ExtUtils::MakeMaker::Parent[-1];
2181     }
2182     return '
2183 BOOTSTRAP =
2184 ' unless $self->has_link_code();
2185
2186     return '
2187 BOOTSTRAP = '."$self->{BASEEXT}.bs".'
2188
2189 # As Mkbootstrap might not write a file (if none is required)
2190 # we use touch to prevent make continually trying to remake it.
2191 # The DynaLoader only reads a non-empty file.
2192 $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists
2193         '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
2194         '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
2195                 -e \'use ExtUtils::Mkbootstrap;\' \
2196                 -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\'
2197         '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
2198         $(CHMOD) 644 $@
2199         '.$self->{NOECHO}.'echo $@ >> $(INST_ARCHAUTODIR)/.packlist
2200
2201 $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
2202         '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
2203         -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
2204         $(CHMOD) 644 $@
2205         '.$self->{NOECHO}.'echo $@ >> $(INST_ARCHAUTODIR)/.packlist
2206 ';
2207 }
2208
2209 sub dynamic_lib {
2210     my($self, %attribs) = @_;
2211     unless (ref $self){
2212         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2213         $self = $ExtUtils::MakeMaker::Parent[-1];
2214     }
2215     return '' unless $self->needs_linking(); #might be because of a subdir
2216
2217     return '' unless $self->has_link_code;
2218
2219     my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
2220     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
2221     my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
2222     my($ldfrom) = '$(LDFROM)';
2223     my($osname) = $Config::Config{osname};
2224     $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':');
2225     my(@m);
2226     push(@m,'
2227 # This section creates the dynamically loadable $(INST_DYNAMIC)
2228 # from $(OBJECT) and possibly $(MYEXTLIB).
2229 ARMAYBE = '.$armaybe.'
2230 OTHERLDFLAGS = '.$otherldflags.'
2231 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
2232
2233 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
2234 ');
2235     if ($armaybe ne ':'){
2236         $ldfrom = 'tmp$(LIB_EXT)';
2237         push(@m,'       $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
2238         push(@m,'       $(RANLIB) '."$ldfrom\n");
2239     }
2240     $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf');
2241     push(@m,'   LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
2242                 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS) $(EXPORT_LIST) $(PERL_ARCHIVE)');
2243     push @m, '
2244         $(CHMOD) 755 $@
2245         '.$self->{NOECHO}.'echo $@ >> $(INST_ARCHAUTODIR)/.packlist
2246 ';
2247
2248     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
2249     join('',@m);
2250 }
2251
2252 # --- Static Loading Sections ---
2253
2254 sub static {
2255     my($self) = shift;
2256     unless (ref $self){
2257         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2258         $self = $ExtUtils::MakeMaker::Parent[-1];
2259     }
2260     '
2261 # $(INST_PM) has been moved to the all: target.
2262 # It remains here for awhile to allow for old usage: "make static"
2263 static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
2264 '.$self->{NOOP}.'
2265 ';
2266 }
2267
2268 sub static_lib {
2269     my($self) = @_;
2270     unless (ref $self){
2271         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2272         $self = $ExtUtils::MakeMaker::Parent[-1];
2273     }
2274 # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
2275 #    return '' unless $self->needs_linking(); #might be because of a subdir
2276
2277     return '' unless $self->has_link_code;
2278
2279     my(@m);
2280     push(@m, <<'END');
2281 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
2282 END
2283     # If this extension has it's own library (eg SDBM_File)
2284     # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
2285     push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
2286
2287     push @m, 
2288 q{      $(AR) cr $@ $(OBJECT) && $(RANLIB) $@
2289         }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
2290         $(CHMOD) 755 $@
2291         }.$self->{NOECHO}.q{echo $@ >> $(INST_ARCHAUTODIR)/.packlist
2292 };
2293
2294 # Old mechanism - still available:
2295
2296     push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs}."\n\n"
2297         if $self->{PERL_SRC};
2298
2299     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
2300     join('', "\n",@m);
2301 }
2302
2303 sub installpm {
2304     my($self, %attribs) = @_;
2305     unless (ref $self){
2306         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2307         $self = $ExtUtils::MakeMaker::Parent[-1];
2308     }
2309     # By default .pm files are split into the architecture independent
2310     # library. This is a good thing. If a specific module requires that
2311     # it's .pm files are split into the architecture specific library
2312     # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
2313     # Note that installperl currently interferes with this (Config.pm)
2314     # User can disable split by saying: installpm => {SPLITLIB=>''}
2315     my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
2316     $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
2317     my(@m, $dist);
2318     push @m, "inst_pm :: \$(INST_PM)\n\n";
2319     foreach $dist (sort keys %{$self->{PM}}){
2320         my($inst) = $self->{PM}->{$dist};
2321         push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
2322         push(@m, $self->installpm_x($dist, $inst, $splitlib));
2323         push(@m, "\n");
2324     }
2325     join('', @m);
2326 }
2327
2328 sub installpm_x { # called by installpm per file
2329     my($self, $dist, $inst, $splitlib) = @_;
2330     unless (ref $self){
2331         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2332         $self = $ExtUtils::MakeMaker::Parent[-1];
2333     }
2334     if ($inst =~ m,[:\#],){
2335         warn "Warning: 'make' would have problems processing this file: '$inst', SKIPPED\n";
2336         return '';
2337     }
2338     my($instdir) = $inst =~ m|(.*)/|;
2339     my(@m);
2340     push(@m,"
2341 $inst: $dist $self->{MAKEFILE} $instdir/.exists \$(INST_ARCHAUTODIR)/.exists
2342         $self->{NOECHO}$self->{RM_F}".' $@
2343         $(UMASK_NULL) && '."$self->{CP} $dist \$\@
2344         $self->{NOECHO}echo ".'$@ >> $(INST_ARCHAUTODIR)/.packlist
2345 ');
2346     push(@m, "\t$self->{NOECHO}\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
2347         if ($splitlib and $inst =~ m/\.pm$/);
2348
2349     push @m, $self->dir_target($instdir);
2350     join('', @m);
2351 }
2352
2353 sub manifypods {
2354     my($self, %attribs) = @_;
2355     unless (ref $self){
2356         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2357         $self = $ExtUtils::MakeMaker::Parent[-1];
2358     }
2359     return "\nmanifypods :\n" unless %{$self->{MAN3PODS}};
2360     my($dist);
2361     my($pod2man_exe);
2362     if (defined $self->{PERL_SRC}) {
2363         $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
2364     } else {
2365         $pod2man_exe = $self->catfile($Config{bin},'pod2man');
2366     }
2367     unless ($self->perl_script($pod2man_exe)) {
2368         # No pod2man but some MAN3PODS to be installed
2369         print <<END;
2370
2371 Warning: I could not locate your pod2man program. Please make sure,
2372          your pod2man program is in your PATH before you execute 'make'
2373
2374 END
2375         $pod2man_exe = "-S pod2man";
2376     }
2377     my(@m);
2378     push @m,
2379 qq[POD2MAN_EXE = $pod2man_exe\n],
2380 q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\
2381 -e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\
2382 -e 'print "Installing $$m{$$_}\n";' \\
2383 -e 'system("$$^X \\"-I$(PERL_ARCHLIB)\\" \\"-I$(PERL_LIB)\\" $(POD2MAN_EXE) $$_>$$m{$$_}")==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
2384 -e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}'
2385 ];
2386     push @m, "\nmanifypods : ";
2387     push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
2388
2389     push(@m,"\n");
2390     if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
2391         push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
2392         push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
2393     }
2394     join('', @m);
2395 }
2396
2397 sub processPL {
2398     my($self) = shift;
2399     unless (ref $self){
2400         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2401         $self = $ExtUtils::MakeMaker::Parent[-1];
2402     }
2403     return "" unless $self->{PL_FILES};
2404     my(@m, $plfile);
2405     foreach $plfile (sort keys %{$self->{PL_FILES}}) {
2406         push @m, "
2407 all :: $self->{PL_FILES}->{$plfile}
2408
2409 $self->{PL_FILES}->{$plfile} :: $plfile
2410         \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
2411 ";
2412     }
2413     join "", @m;
2414 }
2415
2416 sub installbin {
2417     my($self) = shift;
2418     return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2419     return "" unless @{$self->{EXE_FILES}};
2420     my(@m, $from, $to, %fromto, @to);
2421     push @m, $self->dir_target(qw[$(INST_EXE)]);
2422     for $from (@{$self->{EXE_FILES}}) {
2423         my($path)= '$(INST_EXE)/' . basename($from);
2424         local($_) = $path; # for backwards compatibility
2425         $to = $self->exescan($path);
2426         print "exescan($from) => '$to'\n" if ($ExtUtils::MakeMaker::Verbose >=2);
2427         $fromto{$from}=$to;
2428     }
2429     @to   = values %fromto;
2430     push(@m, "
2431 EXE_FILES = @{$self->{EXE_FILES}}
2432
2433 all :: @to
2434
2435 realclean ::
2436         $self->{RM_F} @to
2437 ");
2438
2439     while (($from,$to) = each %fromto) {
2440         my $todir = dirname($to);
2441         push @m, "
2442 $to: $from $self->{MAKEFILE} $todir/.exists
2443         $self->{CP} $from $to
2444 ";
2445     }
2446     join "", @m;
2447 }
2448
2449 sub exescan {
2450     my($self,$path) = @_;
2451     $path;
2452 }
2453 # --- Sub-directory Sections ---
2454
2455 sub subdirs {
2456     my($self) = shift;
2457     unless (ref $self){
2458         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2459         $self = $ExtUtils::MakeMaker::Parent[-1];
2460     }
2461     my(@m,$dir);
2462     # This method provides a mechanism to automatically deal with
2463     # subdirectories containing further Makefile.PL scripts.
2464     # It calls the subdir_x() method for each subdirectory.
2465     foreach $dir (@{$self->{DIR}}){
2466         push(@m, $self->subdir_x($dir));
2467 ####    print "Including $dir subdirectory\n";
2468     }
2469     if (@m){
2470         unshift(@m, "
2471 # The default clean, realclean and test targets in this Makefile
2472 # have automatically been given entries for each subdir.
2473
2474 ");
2475     } else {
2476         push(@m, "\n# none")
2477     }
2478     join('',@m);
2479 }
2480
2481 sub runsubdirpl{        # Experimental! See subdir_x section
2482     my($self,$subdir) = @_;
2483     unless (ref $self){
2484         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2485         $self = $ExtUtils::MakeMaker::Parent[-1];
2486     }
2487     chdir($subdir) or die "chdir($subdir): $!";
2488     package main;
2489     require "Makefile.PL";
2490 }
2491
2492 sub subdir_x {
2493     my($self, $subdir) = @_;
2494     unless (ref $self){
2495         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2496         $self = $ExtUtils::MakeMaker::Parent[-1];
2497     }
2498     my(@m);
2499     qq{
2500
2501 subdirs ::
2502         $self->{NOECHO}-cd $subdir && \$(MAKE) all \$(PASTHRU)
2503
2504 };
2505 }
2506
2507 # --- Cleanup and Distribution Sections ---
2508
2509 sub clean {
2510     my($self, %attribs) = @_;
2511     unless (ref $self){
2512         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2513         $self = $ExtUtils::MakeMaker::Parent[-1];
2514     }
2515     my(@m,$dir);
2516     push(@m, '
2517 # Delete temporary files but do not touch installed files. We don\'t delete
2518 # the Makefile here so a later make realclean still has a makefile to use.
2519
2520 clean ::
2521 ');
2522     # clean subdirectories first
2523     for $dir (@{$self->{DIR}}) {
2524         push @m, "\t-cd $dir && test -f $self->{MAKEFILE} && \$(MAKE) clean\n";
2525     }
2526
2527     my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
2528     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
2529     push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all
2530                          perlmain.c mon.out core so_locations
2531                          *~ */*~ */*/*~
2532                          *$(OBJ_EXT) *$(LIB_EXT)
2533                          perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp
2534                         ]);
2535     push @m, "\t-$self->{RM_RF} @otherfiles\n";
2536     # See realclean and ext/utils/make_ext for usage of Makefile.old
2537     push(@m,
2538          "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old 2>/dev/null\n");
2539     push(@m,
2540          "\t$attribs{POSTOP}\n")   if $attribs{POSTOP};
2541     join("", @m);
2542 }
2543
2544 sub realclean {
2545     my($self, %attribs) = @_;
2546     unless (ref $self){
2547         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2548         $self = $ExtUtils::MakeMaker::Parent[-1];
2549     }
2550     my(@m);
2551     push(@m,'
2552 # Delete temporary files (via clean) and also delete installed files
2553 realclean purge ::  clean
2554 ');
2555     # realclean subdirectories first (already cleaned)
2556     my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
2557     foreach(@{$self->{DIR}}){
2558         push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
2559         push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
2560     }
2561     push(@m, "  $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
2562     push(@m, "  $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
2563     push(@m, "  $self->{RM_F} \$(INST_STATIC) \$(INST_PM)\n");
2564     my(@otherfiles) = ($self->{MAKEFILE},
2565                        "$self->{MAKEFILE}.old"); # Makefiles last
2566     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
2567     push(@m, "  $self->{RM_RF} @otherfiles\n") if @otherfiles;
2568     push(@m, "  $attribs{POSTOP}\n")       if $attribs{POSTOP};
2569     join("", @m);
2570 }
2571
2572 sub dist_basics {
2573     my($self) = shift;
2574     unless (ref $self){
2575         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2576         $self = $ExtUtils::MakeMaker::Parent[-1];
2577     }
2578     my @m;
2579     push @m, q{
2580 distclean :: realclean distcheck
2581 };
2582
2583     push @m, q{
2584 distcheck :
2585         $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\
2586                 -e 'fullcheck();'
2587 };
2588
2589     push @m, q{
2590 skipcheck :
2591         $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&skipcheck";' \\
2592                 -e 'skipcheck();'
2593 };
2594
2595     push @m, q{
2596 manifest :
2597         $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\
2598                 -e 'mkmanifest();'
2599 };
2600     join "", @m;
2601 }
2602
2603 sub dist_core {
2604     my($self) = shift;
2605     unless (ref $self){
2606         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2607         $self = $ExtUtils::MakeMaker::Parent[-1];
2608     }
2609     my @m;
2610     push @m, q{
2611 dist : $(DIST_DEFAULT)
2612
2613 tardist : $(DISTVNAME).tar.$(SUFFIX)
2614
2615 $(DISTVNAME).tar.$(SUFFIX) : distdir
2616         $(PREOP)
2617         $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
2618         $(RM_RF) $(DISTVNAME)
2619         $(COMPRESS) $(DISTVNAME).tar
2620         $(POSTOP)
2621
2622 uutardist : $(DISTVNAME).tar.$(SUFFIX)
2623         uuencode $(DISTVNAME).tar.$(SUFFIX) \\
2624                 $(DISTVNAME).tar.$(SUFFIX) > \\
2625                 $(DISTVNAME).tar.$(SUFFIX).uu
2626
2627 shdist : distdir
2628         $(PREOP)
2629         $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
2630         $(RM_RF) $(DISTVNAME)
2631         $(POSTOP)
2632 };
2633     join "", @m;
2634 }
2635
2636 sub dist_dir {
2637     my($self) = shift;
2638     unless (ref $self){
2639         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2640         $self = $ExtUtils::MakeMaker::Parent[-1];
2641     }
2642     my @m;
2643     push @m, q{
2644 distdir :
2645         $(RM_RF) $(DISTVNAME)
2646         $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "/mani/";' \\
2647                 -e 'manicopy(maniread(),"$(DISTVNAME)", "$(DIST_CP)");'
2648 };
2649     join "", @m;
2650 }
2651
2652 sub dist_test {
2653     my($self) = shift;
2654     unless (ref $self){
2655         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2656         $self = $ExtUtils::MakeMaker::Parent[-1];
2657     }
2658     my @m;
2659     push @m, q{
2660 disttest : distdir
2661         cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
2662         cd $(DISTVNAME) && $(MAKE)
2663         cd $(DISTVNAME) && $(MAKE) test
2664 };
2665     join "", @m;
2666 }
2667
2668 sub dist_ci {
2669     my($self) = shift;
2670     unless (ref $self){
2671         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2672         $self = $ExtUtils::MakeMaker::Parent[-1];
2673     }
2674     my @m;
2675     push @m, q{
2676 ci :
2677         $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\
2678                 -e '@all = keys %{ maniread() };' \\
2679                 -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
2680                 -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
2681 };
2682     join "", @m;
2683 }
2684
2685 sub install {
2686     my($self, %attribs) = @_;
2687     unless (ref $self){
2688         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2689         $self = $ExtUtils::MakeMaker::Parent[-1];
2690     }
2691     my(@m);
2692     push @m, q{
2693 doc_install ::
2694         }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
2695         }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB)  \\
2696                 -e "use ExtUtils::MakeMaker; MY->new({})->writedoc('Module', '$(NAME)', \\
2697                 'LINKTYPE=$(LINKTYPE)', 'VERSION=$(VERSION)', 'XS_VERSION=$(XS_VERSION)', \\
2698                 'EXE_FILES=$(EXE_FILES)')" >> $(INSTALLARCHLIB)/perllocal.pod
2699 };
2700
2701     push(@m, "
2702 install :: pure_install doc_install
2703
2704 pure_install ::
2705 ");
2706     # install subdirectories first
2707     push(@m, map("\tcd $_ && test -f $self->{MAKEFILE} && \$(MAKE) install\n",
2708                  @{$self->{DIR}}));
2709
2710     push(@m, "\t$self->{NOECHO}".q{$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'require File::Path;' \
2711         -e '$$message = q[ You do not have permissions to install into];' \
2712         -e 'File::Path::mkpath(@ARGV);' \
2713         -e 'foreach (@ARGV){ die qq{ $$message $$_\\n} unless -w $$_}' \
2714             $(INSTALLPRIVLIB) $(INSTALLARCHLIB)
2715         $(MAKE) INST_LIB=$(INSTALLPRIVLIB) INST_ARCHLIB=$(INSTALLARCHLIB) \
2716             INST_EXE=$(INSTALLBIN) INST_MAN1DIR=$(INSTALLMAN1DIR) \
2717             INST_MAN3DIR=$(INSTALLMAN3DIR) all
2718
2719 reorg_packlist:
2720         }.$self->{NOECHO}.q{$(PERL) -ne 'BEGIN{die "Need 2 arguments to reorg .packlist" unless @ARGV==2;' \
2721             -e '$$out=$$ARGV[1]; shift @ARGV while @ARGV && ! -f $$ARGV[0]; exit unless @ARGV;}' \
2722             -e 'push @lines, $$_ unless $$seen{$$_}++;' \
2723             -e 'END{open STDOUT, ">$$out" or die "Cannot write to $$out: $$!";' \
2724             -e 'print @lines;}' $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \
2725                 $(INST_ARCHAUTODIR)/.packlist
2726 });
2727
2728 # From MM 5.16:
2729
2730     push @m, q[
2731 # Comment on .packlist rewrite above:
2732 # Read both .packlist files: the old one in PERL_ARCHLIB/auto/FULLEXT, and the new one
2733 # in INSTARCHAUTODIR. Don't croak if they are missing. Write to the one
2734 # in INSTARCHAUTODIR. 
2735
2736 #### UNINSTALL IS STILL EXPERIMENTAL ####
2737 uninstall ::
2738 ];
2739
2740     push(@m, map("\tcd $_ && test -f $self->{MAKEFILE} && \$(MAKE) uninstall\n",
2741                  @{$self->{DIR}}));
2742     push @m, "\t".'$(RM_RF) `cat $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist`
2743 ';
2744
2745     join("",@m);
2746 }
2747
2748
2749 sub force {
2750     my($self) = shift;
2751     unless (ref $self){
2752         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2753         $self = $ExtUtils::MakeMaker::Parent[-1];
2754     }
2755     '# Phony target to force checking subdirectories.
2756 FORCE:
2757 ';
2758 }
2759
2760
2761 sub perldepend {
2762     my($self) = shift;
2763     unless (ref $self){
2764         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2765         $self = $ExtUtils::MakeMaker::Parent[-1];
2766     }
2767     my(@m);
2768     push(@m,'
2769 PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
2770     $(PERL_INC)/XSUB.h  $(PERL_INC)/av.h        $(PERL_INC)/cop.h \
2771     $(PERL_INC)/cv.h    $(PERL_INC)/dosish.h    $(PERL_INC)/embed.h \
2772     $(PERL_INC)/form.h  $(PERL_INC)/gv.h        $(PERL_INC)/handy.h \
2773     $(PERL_INC)/hv.h    $(PERL_INC)/keywords.h  $(PERL_INC)/mg.h \
2774     $(PERL_INC)/op.h    $(PERL_INC)/opcode.h    $(PERL_INC)/patchlevel.h \
2775     $(PERL_INC)/perl.h  $(PERL_INC)/perly.h     $(PERL_INC)/pp.h \
2776     $(PERL_INC)/proto.h $(PERL_INC)/regcomp.h   $(PERL_INC)/regexp.h \
2777     $(PERL_INC)/scope.h $(PERL_INC)/sv.h        $(PERL_INC)/unixish.h \
2778     $(PERL_INC)/util.h  $(PERL_INC)/config.h
2779
2780 ');
2781
2782     push @m, '
2783 $(OBJECT) : $(PERL_HDRS)
2784 ' if $self->{OBJECT};
2785
2786     push(@m,'
2787 # Check for unpropogated config.sh changes. Should never happen.
2788 # We do NOT just update config.h because that is not sufficient.
2789 # An out of date config.h is not fatal but complains loudly!
2790 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2791         -'.$self->{NOECHO}.'echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2792
2793 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2794         '.$self->{NOECHO}.'echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2795         cd $(PERL_SRC) && $(MAKE) lib/Config.pm
2796 ') if $self->{PERL_SRC};
2797
2798     push(@m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n")
2799         if %{$self->{XS}};
2800     join("\n",@m);
2801 }
2802
2803 sub makefile {
2804     my($self) = shift;
2805     unless (ref $self){
2806         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2807         $self = $ExtUtils::MakeMaker::Parent[-1];
2808     }
2809     my @m;
2810     # We do not know what target was originally specified so we
2811     # must force a manual rerun to be sure. But as it should only
2812     # happen very rarely it is not a significant problem.
2813     push @m, '
2814 $(OBJECT) : $(FIRST_MAKEFILE)
2815 ' if $self->{OBJECT};
2816
2817     push @m, '
2818 # We take a very conservative approach here, but it\'s worth it.
2819 # We move Makefile to Makefile.old here to avoid gnu make looping.
2820 '.$self->{MAKEFILE}.' : Makefile.PL $(CONFIGDEP)
2821         '.$self->{NOECHO}.'echo "Makefile out-of-date with respect to $?"
2822         '.$self->{NOECHO}.'echo "Cleaning current config before rebuilding Makefile..."
2823         -'.$self->{NOECHO}.'mv '."$self->{MAKEFILE} $self->{MAKEFILE}.old".'
2824         -$(MAKE) -f '.$self->{MAKEFILE}.'.old clean >/dev/null 2>&1 || true
2825         $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL '."@ARGV".'
2826         '.$self->{NOECHO}.'echo ">>> Your Makefile has been rebuilt. <<<"
2827         '.$self->{NOECHO}.'echo ">>> Please rerun the make command.  <<<"; false
2828 ';
2829
2830     join "", @m;
2831 }
2832
2833 sub staticmake {
2834     my($self, %attribs) = @_;
2835     unless (ref $self){
2836         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2837         $self = $ExtUtils::MakeMaker::Parent[-1];
2838     }
2839     my(@static);
2840
2841     my(%searchdirs)=($self->{PERL_ARCHLIB} => 1,  $self->{INST_ARCHLIB} => 1);
2842     my(@searchdirs)=keys %searchdirs;
2843
2844     # And as it's not yet built, we add the current extension
2845     # but only if it has some C code (or XS code, which implies C code)
2846     if (@{$self->{C}}) {
2847         @static="$self->{INST_ARCHLIB}/auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}";
2848     }
2849
2850     # Either we determine now, which libraries we will produce in the
2851     # subdirectories or we do it at runtime of the make.
2852
2853     # We could ask all subdir objects, but I cannot imagine, why it
2854     # would be necessary.
2855
2856     # Instead we determine all libraries for the new perl at
2857     # runtime.
2858     my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
2859
2860     $self->makeaperl(MAKE       => $self->{MAKEFILE},
2861                      DIRS       => \@searchdirs,
2862                      STAT       => \@static,
2863                      INCL       => \@perlinc,
2864                      TARGET     => $self->{MAP_TARGET},
2865                      TMP        => "",
2866                      LIBPERL    => $self->{LIBPERL_A}
2867                     );
2868 }
2869
2870 # --- Test and Installation Sections ---
2871
2872 sub test {
2873     my($self, %attribs) = @_;
2874     unless (ref $self){
2875         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2876         $self = $ExtUtils::MakeMaker::Parent[-1];
2877     }
2878     my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
2879     my(@m);
2880     push(@m,"
2881 TEST_VERBOSE=0
2882 TEST_TYPE=test_\$(LINKTYPE)
2883
2884 test :: \$(TEST_TYPE)
2885 ");
2886     push(@m, map("\t$self->{NOECHO}cd $_ && test -f $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
2887                  @{$self->{DIR}}));
2888     push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n")
2889         unless $tests or -f "test.pl" or @{$self->{DIR}};
2890     push(@m, "\n");
2891
2892     push(@m, "test_dynamic :: all\n");
2893     push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
2894     push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
2895     push(@m, "\n");
2896
2897     # Occasionally we may face this degenerate target:
2898     push @m, "test_ : test_dynamic\n\n";
2899
2900     if ($self->needs_linking()) {
2901         push(@m, "test_static :: all \$(MAP_TARGET)\n");
2902         push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
2903         push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
2904         push(@m, "\n");
2905     } else {
2906         push @m, "test_static :: test_dynamic\n";
2907     }
2908     join("", @m);
2909 }
2910
2911 sub test_via_harness {
2912     my($self, $perl, $tests) = @_;
2913     unless (ref $self){
2914         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2915         $self = $ExtUtils::MakeMaker::Parent[-1];
2916     }
2917     "\tPERL_DL_NONLAZY=1 $perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
2918 }
2919
2920 sub test_via_script {
2921     my($self, $perl, $script) = @_;
2922     unless (ref $self){
2923         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2924         $self = $ExtUtils::MakeMaker::Parent[-1];
2925     }
2926     "\tPERL_DL_NONLAZY=1 $perl".' -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
2927 ';
2928 }
2929
2930
2931 sub postamble {
2932     my($self) = shift;
2933     unless (ref $self){
2934         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2935         $self = $ExtUtils::MakeMaker::Parent[-1];
2936     }
2937     "";
2938 }
2939
2940 sub makeaperl {
2941     my($self, %attribs) = @_;
2942     unless (ref $self){
2943         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2944         $self = $ExtUtils::MakeMaker::Parent[-1];
2945     }
2946     my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2947         @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2948     my(@m);
2949     push @m, "
2950 # --- MakeMaker makeaperl section ---
2951 MAP_TARGET    = $target
2952 FULLPERL      = $self->{FULLPERL}
2953 ";
2954     return join '', @m if $self->{PARENT};
2955
2956     my($dir) = join ":", @{$self->{DIR}};
2957
2958     unless ($self->{MAKEAPERL}) {
2959         push @m, q{
2960 $(MAP_TARGET) :: $(MAKE_APERL_FILE)
2961         $(MAKE) -f $(MAKE_APERL_FILE) static $@
2962
2963 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2964         }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2965         }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
2966                 Makefile.PL DIR=}, $dir, q{ \
2967                 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2968                 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2969
2970         push @m, map( " \\\n\t\t$_", @ARGV );
2971         push @m, "\n";
2972
2973         return join '', @m;
2974     }
2975
2976
2977
2978     my($cccmd, $linkcmd, $lperl);
2979
2980
2981     $cccmd = $self->const_cccmd($libperl);
2982     $cccmd =~ s/^CCCMD\s*=\s*//;
2983     $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /;
2984     $cccmd .= " $Config::Config{cccdlflags}" if ($Config::Config{d_shrplib});
2985     $cccmd =~ s/\n/ /g; # yes I've seen "\n", don't ask me where it came from. A.K.
2986     $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2987
2988     # The front matter of the linkcommand...
2989     $linkcmd = join ' ', "\$(CC)",
2990             grep($_, @Config{qw(large split ldflags ccdlflags)});
2991     $linkcmd =~ s/\s+/ /g;
2992
2993     # Which *.a files could we make use of...
2994     local(%static);
2995     File::Find::find(sub {
2996         return unless m/\Q$self->{LIB_EXT}\E$/;
2997         return if m/^libperl/;
2998         # don't include the installed version of this extension. I
2999         # leave this line here, although it is not necessary anymore:
3000         # I patched minimod.PL instead, so that Miniperl.pm won't
3001         # enclude duplicates
3002
3003         # Once the patch to minimod.PL is in the distribution, I can
3004         # drop it
3005         return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:;
3006         $static{fastcwd() . "/" . $_}++;
3007     }, grep( -d $_, @{$searchdirs || []}) );
3008
3009     # We trust that what has been handed in as argument, will be buildable
3010     $static = [] unless $static;
3011     @static{@{$static}} = (1) x @{$static};
3012
3013     $extra = [] unless $extra && ref $extra eq 'ARRAY';
3014     for (sort keys %static) {
3015         next unless /\Q$self->{LIB_EXT}\E$/;
3016         $_ = dirname($_) . "/extralibs.ld";
3017         push @$extra, $_;
3018     }
3019
3020     grep(s/^/-I/, @{$perlinc || []});
3021
3022     $target = "perl" unless $target;
3023     $tmp = "." unless $tmp;
3024
3025 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
3026 # regenerate the Makefiles, MAP_STATIC and the dependencies for
3027 # extralibs.all are computed correctly
3028     push @m, "
3029 MAP_LINKCMD   = $linkcmd
3030 MAP_PERLINC   = @{$perlinc || []}
3031 MAP_STATIC    = ",
3032 join(" \\\n\t", reverse sort keys %static), "
3033
3034 MAP_PRELIBS   = $Config::Config{libs} $Config::Config{cryptlib}
3035 ";
3036
3037     if (defined $libperl) {
3038         ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
3039     }
3040     unless ($libperl && -f $lperl) { # Could quite follow your idea her, Ilya
3041         my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
3042         $libperl ||= "libperl$self->{LIB_EXT}";
3043         $libperl   = "$dir/$libperl";
3044         $lperl   ||= "libperl$self->{LIB_EXT}";
3045         $lperl     = "$dir/$lperl";
3046         print STDOUT "Warning: $libperl not found
3047     If you're going to build a static perl binary, make sure perl is installed
3048     otherwise ignore this warning\n"
3049                 unless (-f $lperl || defined($self->{PERL_SRC}));
3050     }
3051
3052     push @m, "
3053 MAP_LIBPERL = $libperl
3054 ";
3055
3056     push @m, "
3057 \$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)."
3058         $self->{NOECHO}$self->{RM_F} \$\@
3059         $self->{NOECHO}\$(TOUCH) \$\@
3060 ";
3061
3062     my $catfile;
3063     foreach $catfile (@$extra){
3064         push @m, "\tcat $catfile >> \$\@\n";
3065     }
3066
3067     push @m, "
3068 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
3069         \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
3070         $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
3071         $self->{NOECHO}echo '    make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
3072         $self->{NOECHO}echo 'To remove the intermediate files say'
3073         $self->{NOECHO}echo '    make -f $makefilename map_clean'
3074
3075 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
3076 ";
3077     push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n";
3078
3079     push @m, qq{
3080 $tmp/perlmain.c: $makefilename}, q{
3081         }.$self->{NOECHO}.q{echo Writing $@
3082         }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
3083                 writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@
3084
3085 };
3086
3087 # We write EXTRA outside the perl program to have it eval'd by the shell
3088     push @m, q{
3089 doc_inst_perl:
3090         }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
3091         }.$self->{NOECHO}.q{$(FULLPERL) -e 'use ExtUtils::MakeMaker; MY->new->writedoc("Perl binary",' \\
3092                 -e '"$(MAP_TARGET)", "MAP_STATIC=$(MAP_STATIC)",' \\
3093                 -e '"MAP_EXTRA=@ARGV", "MAP_LIBPERL=$(MAP_LIBPERL)")' \\
3094                 -- `cat $(INST_ARCHAUTODIR)/extralibs.all` >> $(INSTALLARCHLIB)/perllocal.pod
3095 };
3096
3097     push @m, qq{
3098 inst_perl: pure_inst_perl doc_inst_perl
3099
3100 pure_inst_perl: \$(MAP_TARGET)
3101         $self->{CP} \$(MAP_TARGET) \$(INSTALLBIN)/\$(MAP_TARGET)
3102
3103 clean :: map_clean
3104
3105 map_clean :
3106         $self->{RM_F} $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
3107 };
3108
3109     join '', @m;
3110 }
3111
3112 sub extliblist {
3113     my($self,$libs) = @_;
3114     unless (ref $self){
3115         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3116         $self = $ExtUtils::MakeMaker::Parent[-1];
3117     }
3118     require ExtUtils::Liblist;
3119     ExtUtils::Liblist::ext($libs, $ExtUtils::MakeMaker::Verbose);
3120 }
3121
3122 # --- Make-Directories section (internal method) ---
3123 # dir_target(@array) returns a Makefile entry for the file .exists in each
3124 # named directory. Returns nothing, if the entry has already been processed.
3125 # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
3126 # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
3127 # prerequisite, because there has to be one, something that doesn't change
3128 # too often :)
3129
3130 sub dir_target {
3131     my($self,@dirs) = @_;
3132     unless (ref $self){
3133         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3134         $self = $ExtUtils::MakeMaker::Parent[-1];
3135     }
3136     my(@m,$dir);
3137     foreach $dir (@dirs) {
3138         next if $self->{DIR_TARGET}{$self}{$dir}++;
3139         push @m, "
3140 $dir/.exists :: \$(PERL)
3141         $self->{NOECHO}\$(MKPATH) $dir
3142         $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) \$(PERL) $dir/.exists
3143         $self->{NOECHO}-\$(CHMOD) 755 $dir
3144 ";
3145     }
3146     join "", @m;
3147 }
3148
3149 # --- Output postprocessing section ---
3150 # nicetext is included to make VMS support easier
3151 sub nicetext { # Just return the input - no action needed
3152     my($self,$text) = @_;
3153     unless (ref $self){
3154         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3155         $self = $ExtUtils::MakeMaker::Parent[-1];
3156     }
3157     $text;
3158 }
3159
3160 sub needs_linking { # Does this module need linking? Looks into
3161                     # subdirectory objects (see also has_link_code()
3162     my($self) = shift;
3163     my($child,$caller);
3164     $caller = (caller(0))[3];
3165     unless (ref $self){
3166         ExtUtils::MakeMaker::TieAtt::warndirectuse($caller);
3167         $self = $ExtUtils::MakeMaker::Parent[-1];
3168     }
3169     Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/;
3170     return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
3171 #    print "DEBUG:\n";
3172 #    print Carp::longmess();
3173 #    print "EO_DEBUG\n";
3174     if ($self->has_link_code or $self->{MAKEAPERL}){
3175         $self->{NEEDS_LINKING} = 1;
3176         return 1;
3177     }
3178     foreach $child (keys %{$self->{CHILDREN}}) {
3179         if ($self->{CHILDREN}->{$child}->needs_linking) {
3180             $self->{NEEDS_LINKING} = 1;
3181             return 1;
3182         }
3183     }
3184     return $self->{NEEDS_LINKING} = 0;
3185 }
3186
3187 sub has_link_code {
3188     my($self) = shift;
3189     return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
3190     if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
3191         $self->{HAS_LINK_CODE} = 1;
3192         return 1;
3193     }
3194     return $self->{HAS_LINK_CODE} = 0;
3195 }
3196
3197 # --- perllocal.pod section ---
3198 sub writedoc {
3199     my($self,$what,$name,@attribs)=@_;
3200     unless (ref $self){
3201         ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3202         $self = $ExtUtils::MakeMaker::Parent[-1];
3203     }
3204     my($time) = localtime;
3205     print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3206     print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3207     print "\n\n=back\n\n";
3208 }
3209
3210 sub catdir  { shift; my $result = join('/',@_); $result =~ s:/+:/:g; $result; }
3211 sub catfile { shift; my $result = join('/',@_); $result =~ s:/+:/:g; $result; }
3212
3213 package ExtUtils::MM_OS2;
3214
3215 #use Config;
3216 #use Cwd;
3217 #use File::Basename;
3218 require Exporter;
3219
3220 Exporter::import('ExtUtils::MakeMaker',
3221        qw( $Verbose &neatvalue));
3222
3223 sub dlsyms {
3224     my($self,%attribs) = @_;
3225
3226     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
3227     my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
3228     my(@m);
3229     (my $boot = $self->{NAME}) =~ s/:/_/g;
3230
3231     if (not $self->{SKIPHASH}{'dynamic'}) {
3232         push(@m,"
3233 $self->{BASEEXT}.def: Makefile.PL
3234 ",'     $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
3235         Mksymlists("NAME" => "',$self->{NAME},'", "DLBASE" => "',$self->{DLBASE},
3236         '", "DL_FUNCS" => ',neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
3237 ');
3238     }
3239     join('',@m);
3240 }
3241
3242 sub replace_manpage_separator {
3243     my($self,$man) = @_;
3244     $man =~ s,/+,.,g;
3245     $man;
3246 }
3247
3248 sub maybe_command {
3249     my($self,$file) = @_;
3250     return $file if -x $file && ! -d _;
3251     return "$file.exe" if -x "$file.exe" && ! -d _;
3252     return "$file.cmd" if -x "$file.cmd" && ! -d _;
3253     return;
3254 }
3255
3256 sub file_name_is_absolute {
3257     my($self,$file) = @_;
3258     $file =~ m{^([a-z]:)?[\\/]}i ;
3259 }
3260
3261
3262 # the following keeps AutoSplit happy
3263 package ExtUtils::MakeMaker;
3264 1;
3265
3266 __END__
3267
3268 =head1 NAME
3269
3270 ExtUtils::MakeMaker - create an extension Makefile
3271
3272 =head1 SYNOPSIS
3273
3274 C<use ExtUtils::MakeMaker;>
3275
3276 C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
3277
3278 which is really
3279
3280 C<MM-E<gt>new(\%att)-E<gt>flush;>
3281
3282 =head1 DESCRIPTION
3283
3284 This utility is designed to write a Makefile for an extension module
3285 from a Makefile.PL. It is based on the Makefile.SH model provided by
3286 Andy Dougherty and the perl5-porters.
3287
3288 It splits the task of generating the Makefile into several subroutines
3289 that can be individually overridden.  Each subroutine returns the text
3290 it wishes to have written to the Makefile.
3291
3292 =head2 Hintsfile support
3293
3294 MakeMaker.pm uses the architecture specific information from
3295 Config.pm. In addition it evaluates architecture specific hints files
3296 in a C<hints/> directory. The hints files are expected to be named
3297 like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
3298 name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
3299 MakeMaker within the WriteMakefile() subroutine, and can be used to
3300 execute commands as well as to include special variables. The rules
3301 which hintsfile is chosen are the same as in Configure.
3302
3303 The hintsfile is eval()ed immediately after the arguments given to
3304 WriteMakefile are stuffed into a hash reference $self but before this
3305 reference becomes blessed. So if you want to do the equivalent to
3306 override or create an attribute you would say something like
3307
3308     $self->{LIBS} = ['-ldbm -lucb -lc'];
3309
3310 =head2 What's new in version 5 of MakeMaker
3311
3312 MakeMaker 5 is pure object oriented. This allows us to write an
3313 unlimited number of Makefiles with a single perl process. 'perl
3314 Makefile.PL' with MakeMaker 5 goes through all subdirectories
3315 immediately and evaluates any Makefile.PL found in the next level
3316 subdirectories. The benefit of this approach comes in useful for both
3317 single and multi directories extensions.
3318
3319 Multi directory extensions have an immediately visible speed
3320 advantage, because there's no startup penalty for any single
3321 subdirectory Makefile.
3322
3323 Single directory packages benefit from the much improved
3324 needs_linking() method. As the main Makefile knows everything about
3325 the subdirectories, a needs_linking() method can now query all
3326 subdirectories if there is any linking involved down in the tree. The
3327 speedup for PM-only Makefiles seems to be around 1 second on my
3328 Indy 100 MHz.
3329
3330 =head2 Incompatibilities between MakeMaker 5.00 and 4.23
3331
3332 There are no incompatibilities in the short term, as all changes are
3333 accompanied by short-term workarounds that guarantee full backwards
3334 compatibility.
3335
3336 You are likely to face a few warnings that expose deprecations which
3337 will result in incompatibilities in the long run:
3338
3339 You should not use %att directly anymore. Instead any subroutine you
3340 override in the MY package will be called by the object method, so you
3341 can access all object attributes directly via the object in $_[0].
3342
3343 You should not call the class methos MM->something anymore. Instead
3344 you should call the superclass. Something like
3345
3346     sub MY::constants {
3347         my $self = shift;
3348         $self->MM::constants();
3349     }
3350
3351 Especially the libscan() and exescan() methods should be altered
3352 towards OO programming, that means do not expect that $_ to contain
3353 the path but rather $_[1].
3354
3355 You should program with more care. Watch out for any MakeMaker
3356 variables. Do not try to alter them, somebody else might depend on
3357 them. E.g. do not overwrite the ExtUtils::MakeMaker::VERSION variable
3358 (this happens if you import it and then set it to the version number
3359 of your package), do not expect that the INST_LIB variable will be
3360 ./blib (do not 'unshift @INC, "./blib" and do not use
3361 "blib/FindBin.pm"). Do not croak in your Makefile.PL, let it fail with
3362 a warning instead.
3363
3364 Try to build several extensions simultanously to debug your
3365 Makefile.PL. You can unpack a bunch of distributed packages, so your
3366 directory looks like
3367
3368     Alias-1.00/         Net-FTP-1.01a/      Set-Scalar-0.001/
3369     ExtUtils-Peek-0.4/  Net-Ping-1.00/      SetDualVar-1.0/
3370     Filter-1.06/        NetTools-1.01a/     Storable-0.1/
3371     GD-1.00/            Religion-1.04/      Sys-Domain-1.05/
3372     MailTools-1.03/     SNMP-1.5b/          Term-ReadLine-0.7/
3373
3374 and write a dummy Makefile.PL that contains nothing but
3375
3376     use ExtUtils::MakeMaker;
3377     WriteMakefile();
3378
3379 That's actually fun to watch :)
3380
3381 Final suggestion: Try to delete all of your MY:: subroutines and
3382 watch, if you really still need them. MakeMaker might already do what
3383 you want without them. That's all about it.
3384
3385
3386 =head2 Default Makefile Behaviour
3387
3388 The automatically generated Makefile enables the user of the extension
3389 to invoke
3390
3391   perl Makefile.PL # optionally "perl Makefile.PL verbose"
3392   make
3393   make test        # optionally set TEST_VERBOSE=1
3394   make install     # See below
3395
3396 The Makefile to be produced may be altered by adding arguments of the
3397 form C<KEY=VALUE>. If the user wants to work with a different perl
3398 than the default, this can be achieved with
3399
3400   perl Makefile.PL PERL=/tmp/myperl5
3401
3402 Other interesting targets in the generated Makefile are
3403
3404   make config     # to check if the Makefile is up-to-date
3405   make clean      # delete local temp files (Makefile gets renamed)
3406   make realclean  # delete derived files (including ./blib)
3407   make dist       # see below the Distribution Support section
3408
3409 =head2 Special case make install
3410
3411 make alone puts all relevant files into directories that are named by
3412 the macros INST_LIB, INST_ARCHLIB, INST_EXE, INST_MAN1DIR, and
3413 INST_MAN3DIR. All these default to ./blib or something below blib if
3414 you are I<not> building below the perl source directory. If you I<are>
3415 building below the perl source, INST_LIB and INST_ARCHLIB default to
3416  ../../lib, and INST_EXE is not defined.
3417
3418 The I<install> target of the generated Makefile is a recursive call to
3419 make which sets
3420
3421     INST_LIB     to INSTALLPRIVLIB
3422     INST_ARCHLIB to INSTALLARCHLIB
3423     INST_EXE     to INSTALLBIN
3424     INST_MAN1DIR to INSTALLMAN1DIR
3425     INST_MAN3DIR to INSTALLMAN3DIR
3426
3427 The INSTALL... macros in turn default to their %Config
3428 ($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
3429
3430 The recommended way to proceed is to set only the INSTALL* macros, not
3431 the INST_* targets. In doing so, you give room to the compilation
3432 process without affecting important directories. Usually a make
3433 test will succeed after the make, and a make install can finish
3434 the game.
3435
3436 MakeMaker gives you much more freedom than needed to configure
3437 internal variables and get different results. It is worth to mention,
3438 that make(1) also lets you configure most of the variables that are
3439 used in the Makefile. But in the majority of situations this will not
3440 be necessary, and should only be done, if the author of a package
3441 recommends it.
3442
3443 The usual relationship between INSTALLPRIVLIB and INSTALLARCHLIB is
3444 that the latter is a subdirectory of the former with the name
3445 C<$Config{archname}>, MakeMaker supports the user who sets
3446 INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then
3447 MakeMaker defaults the latter to be INSTALLPRIVLIB/ARCHNAME if that
3448 directory exists, otherwise it defaults to INSTALLPRIVLIB.
3449
3450
3451 =head2 PREFIX attribute
3452
3453 The PREFIX attribute can be used to set the INSTALL* attributes in one
3454 go. The quickest way to install a module in a non-standard place
3455
3456     perl Makefile.PL PREFIX=~
3457
3458 This will replace the string specified by $Config{prefix} in all
3459 $Config{install*} values.
3460
3461 Note, that the tilde expansion is done by MakeMaker, not by perl by
3462 default, nor by make.
3463
3464 It is important to know, that the INSTALL* macros should be absolute
3465 paths, never relativ ones. Packages with multiple Makefile.PLs in
3466 different directories get the contents of the INSTALL* macros
3467 propagated verbatim. (The INST_* macros will be corrected, if they are
3468 relativ paths, but not the INSTALL* macros.)
3469
3470 If the user has superuser privileges, and is not working on AFS
3471 (Andrew File System) or relatives, then the defaults for
3472 INSTALLPRIVLIB, INSTALLARCHLIB, INSTALLBIN, etc. will be appropriate,
3473 and this incantation will be the best:
3474
3475     perl Makefile.PL; make; make test
3476     make install
3477
3478 make install per default writes some documentation of what has been
3479 done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This is
3480 an experimental feature. It can be bypassed by calling make
3481 pure_install.
3482
3483 =head2 AFS users
3484
3485 will have to specify the installation directories as these most
3486 probably have changed since perl itself has been installed. They will
3487 have to do this by calling
3488
3489     perl Makefile.PL INSTALLPRIVLIB=/afs/here/today \
3490         INSTALLBIN=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
3491     make
3492
3493 In nested extensions with many subdirectories, the INSTALL* arguments
3494 will get propagated to the subdirectories. Be careful to repeat this
3495 procedure every time you recompile an extension, unless you are sure
3496 the AFS istallation directories are still valid.
3497
3498 =head2 Static Linking of a new Perl Binary
3499
3500 An extension that is built with the above steps is ready to use on
3501 systems supporting dynamic loading. On systems that do not support
3502 dynamic loading, any newly created extension has to be linked together
3503 with the available resources. MakeMaker supports the linking process
3504 by creating appropriate targets in the Makefile whenever an extension
3505 is built. You can invoke the corresponding section of the makefile with
3506
3507     make perl
3508
3509 That produces a new perl binary in the current directory with all
3510 extensions linked in that can be found in INST_ARCHLIB (which usually
3511 is C<./blib>) and PERL_ARCHLIB. To do that, MakeMaker writes a new
3512 Makefile, on UNIX, this is called Makefile.aperl (may be system
3513 dependent). If you want to force the creation of a new perl, it is
3514 recommended, that you delete this Makefile.aperl, so INST_ARCHLIB and
3515 PERL_ARCHLIB are searched-through for linkable libraries again.
3516
3517 The binary can be installed into the directory where perl normally
3518 resides on your machine with
3519
3520     make inst_perl
3521
3522 To produce a perl binary with a different name than C<perl>, either say
3523
3524     perl Makefile.PL MAP_TARGET=myperl
3525     make myperl
3526     make inst_perl
3527
3528 or say
3529
3530     perl Makefile.PL
3531     make myperl MAP_TARGET=myperl
3532     make inst_perl MAP_TARGET=myperl
3533
3534 In any case you will be prompted with the correct invocation of the
3535 C<inst_perl> target that installs the new binary into INSTALLBIN.
3536
3537 Note, that there is a C<makeaperl> scipt in the perl distribution,
3538 that supports the linking of a new perl binary in a similar fashion,
3539 but with more options.
3540
3541 make inst_perl per default writes some documentation of what has been
3542 done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
3543 can be bypassed by calling make pure_inst_perl.
3544
3545 Warning: the inst_perl: target is rather mighty and will probably
3546 overwrite your existing perl binary. Use with care!
3547
3548 Sometimes you might want to build a statically linked perl although
3549 your system supports dynamic loading. In this case you may explicitly
3550 set the linktype with the invocation of the Makefile.PL or make:
3551
3552     perl Makefile.PL LINKTYPE=static    # recommended
3553
3554 or
3555
3556     make LINKTYPE=static                # works on most systems
3557
3558 =head2 Determination of Perl Library and Installation Locations
3559
3560 MakeMaker needs to know, or to guess, where certain things are
3561 located.  Especially INST_LIB and INST_ARCHLIB (where to install files
3562 into), PERL_LIB and PERL_ARCHLIB (where to read existing modules
3563 from), and PERL_INC (header files and C<libperl*.*>).
3564
3565 Extensions may be built either using the contents of the perl source
3566 directory tree or from an installed copy of the perl library. The
3567 recommended way is to build extensions after you have run 'make
3568 install' on perl itself. Do that in a directory that is not below the
3569 perl source tree. The support for extensions below the ext directory
3570 of the perl distribution is only good for the standard extensions that
3571 come with perl.
3572
3573 If an extension is being built below the C<ext/> directory of the perl
3574 source then MakeMaker will set PERL_SRC automatically (e.g., C<../..>).
3575 If PERL_SRC is defined then other variables default to the following:
3576
3577   PERL_INC     = PERL_SRC
3578   PERL_LIB     = PERL_SRC/lib
3579   PERL_ARCHLIB = PERL_SRC/lib
3580   INST_LIB     = PERL_LIB
3581   INST_ARCHLIB = PERL_ARCHLIB
3582
3583 If an extension is being built away from the perl source then MakeMaker
3584 will leave PERL_SRC undefined and default to using the installed copy
3585 of the perl library. The other variables default to the following:
3586
3587   PERL_INC     = $archlib/CORE
3588   PERL_LIB     = $privlib
3589   PERL_ARCHLIB = $archlib
3590   INST_LIB     = ./blib
3591   INST_ARCHLIB = ./blib/<archname>
3592
3593 If perl has not yet been installed then PERL_SRC can be defined on the
3594 command line as shown in the previous section.
3595
3596 =head2 Useful Default Makefile Macros
3597
3598 FULLEXT = Pathname for extension directory (eg DBD/Oracle).
3599
3600 BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
3601
3602 ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
3603
3604 INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)>
3605
3606 INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)>
3607
3608 INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)>
3609
3610 =head2 Using Attributes (and Parameters)
3611
3612 The following attributes can be specified as arguments to WriteMakefile()
3613 or as NAME=VALUE pairs on the command line:
3614
3615 =cut
3616
3617 # The following "=item C" is used by the attrib_help routine
3618 # likewise the "=back" below. So be careful when changing it!
3619
3620 =over 2
3621
3622 =item C
3623
3624 Ref to array of *.c file names. Initialised from a directory scan
3625 and the values portion of the XS attribute hash. This is not
3626 currently used by MakeMaker but may be handy in Makefile.PLs.
3627
3628 =item CONFIG
3629
3630 Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
3631 config.sh. MakeMaker will add to CONFIG the following values anyway:
3632 ar
3633 cc
3634 cccdlflags
3635 ccdlflags
3636 dlext
3637 dlsrc
3638 ld
3639 lddlflags
3640 ldflags
3641 libc
3642 lib_ext
3643 obj_ext
3644 ranlib
3645 so
3646
3647 =item CONFIGURE
3648
3649 CODE reference. Extension writers are requested to do all their
3650 initializing within that subroutine. The subroutine
3651 should return a hash reference. The hash may contain
3652 further attributes, e.g. {LIBS => ...}, that have to
3653 be determined by some evaluation method.
3654
3655 =item DEFINE
3656
3657 Something like C<"-DHAVE_UNISTD_H">
3658
3659 =item DIR
3660
3661 Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm'
3662 ] in ext/SDBM_File
3663
3664 =item DISTNAME
3665
3666 Your name for distributing the package (by tar file) This defaults to
3667 NAME above.
3668
3669 =item DL_FUNCS
3670
3671 Hashref of symbol names for routines to be made available as
3672 universal symbols.  Each key/value pair consists of the package name
3673 and an array of routine names in that package.  Used only under AIX
3674 (export lists) and VMS (linker options) at present.  The routine
3675 names supplied will be expanded in the same way as XSUB names are
3676 expanded by the XS() macro.  Defaults to
3677
3678   {"$(NAME)" => ["boot_$(NAME)" ] }
3679
3680 e.g.
3681
3682   {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
3683    "NetconfigPtr" => [ 'DESTROY'] }
3684
3685 =item DL_VARS
3686
3687 Array of symbol names for variables to be made available as
3688 universal symbols.  Used only under AIX (export lists) and VMS
3689 (linker options) at present.  Defaults to [].  (e.g. [ qw(
3690 Foo_version Foo_numstreams Foo_tree ) ])
3691
3692 =item EXE_FILES
3693
3694 Ref to array of executable files. The files will be copied to the
3695 INST_EXE directory. Make realclean will delete them from there
3696 again.
3697
3698 =item FIRST_MAKEFILE
3699
3700 The name of the Makefile to be produced. Defaults to the contents of
3701 MAKEFILE, but can be overridden. This is used for the second Makefile
3702 that will be produced for the MAP_TARGET.
3703
3704 =item FULLPERL
3705
3706 Perl binary able to run this extension.
3707
3708 =item H
3709
3710 Ref to array of *.h file names. Similar to C.
3711
3712 =item INC
3713
3714 Include file dirs eg: C<"-I/usr/5include -I/path/to/inc">
3715
3716 =item INSTALLARCHLIB
3717
3718 Used by 'make install', which sets INST_ARCHLIB to this value.
3719
3720 =item INSTALLBIN
3721
3722 Used by 'make install' which sets INST_EXE to this value.
3723
3724 =item INSTALLMAN1DIR
3725
3726 This directory gets the man pages at 'make install' time. Defaults to
3727 $Config{installman1dir}.
3728
3729 =item INSTALLMAN3DIR
3730
3731 This directory gets the man pages at 'make install' time. Defaults to
3732 $Config{installman3dir}.
3733
3734 =item INSTALLPRIVLIB
3735
3736 Used by 'make install', which sets INST_LIB to this value.
3737
3738 =item INST_ARCHLIB
3739
3740 Same as INST_LIB for architecture dependent files.
3741
3742 =item INST_EXE
3743
3744 Directory, where executable scripts should be installed during
3745 'make'. Defaults to "./blib/ARCHNAME", just to have a dummy
3746 location during testing. make install will set
3747 INST_EXE to INSTALLBIN.
3748
3749 =item INST_LIB
3750
3751 Directory where we put library files of this extension while building
3752 it.
3753
3754 =item INST_MAN1DIR
3755
3756 Directory to hold the man pages at 'make' time
3757
3758 =item INST_MAN3DIR
3759
3760 Directory to hold the man pages at 'make' time
3761
3762 =item LDFROM
3763
3764 defaults to "$(OBJECT)" and is used in the ld command to specify
3765 what files to link/load from (also see dynamic_lib below for how to
3766 specify ld flags)
3767
3768 =item LIBPERL_A
3769
3770 The filename of the perllibrary that will be used together with this
3771 extension. Defaults to libperl.a.
3772
3773 =item LIBS
3774
3775 An anonymous array of alternative library
3776 specifications to be searched for (in order) until
3777 at least one library is found. E.g.
3778
3779   'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
3780
3781 Mind, that any element of the array
3782 contains a complete set of arguments for the ld
3783 command. So do not specify
3784
3785   'LIBS' => ["-ltcl", "-ltk", "-lX11"]
3786
3787 See ODBM_File/Makefile.PL for an example, where an array is needed. If
3788 you specify a scalar as in
3789
3790   'LIBS' => "-ltcl -ltk -lX11"
3791
3792 MakeMaker will turn it into an array with one element.
3793
3794 =item LINKTYPE
3795
3796 'static' or 'dynamic' (default unless usedl=undef in config.sh) Should
3797 only be used to force static linking (also see
3798 linkext below).
3799
3800 =item MAKEAPERL
3801
3802 Boolean which tells MakeMaker, that it should include the rules to
3803 make a perl. This is handled automatically as a switch by
3804 MakeMaker. The user normally does not need it.
3805
3806 =item MAKEFILE
3807
3808 The name of the Makefile to be produced.
3809
3810 =item MAN1PODS
3811
3812 Hashref of pod-containing files. MakeMaker will default this to all
3813 EXE_FILES files that include POD directives. The files listed
3814 here will be converted to man pages and installed as was requested
3815 at Configure time.
3816
3817 =item MAN3PODS
3818
3819 Hashref of .pm and .pod files. MakeMaker will default this to all
3820  .pod and any .pm files that include POD directives. The files listed
3821 here will be converted to man pages and installed as was requested
3822 at Configure time.
3823
3824 =item MAP_TARGET
3825
3826 If it is intended, that a new perl binary be produced, this variable
3827 may hold a name for that binary. Defaults to perl
3828
3829 =item MYEXTLIB
3830
3831 If the extension links to a library that it builds set this to the
3832 name of the library (see SDBM_File)
3833
3834 =item NAME
3835
3836 Perl module name for this extension (DBD::Oracle). This will default
3837 to the directory name but should be explicitly defined in the
3838 Makefile.PL.
3839
3840 =item NEEDS_LINKING
3841
3842 MakeMaker will figure out, if an extension contains linkable code
3843 anywhere down the directory tree, and will set this variable
3844 accordingly, but you can speed it up a very little bit, if you define
3845 this boolean variable yourself.
3846
3847 =item NORECURS
3848
3849 Boolean. Experimental attribute to inhibit descending into
3850 subdirectories.
3851
3852 =item OBJECT
3853
3854 List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
3855 string containing all object files, e.g. "tkpBind.o
3856 tkpButton.o tkpCanvas.o"
3857
3858 =item PERL
3859
3860 Perl binary for tasks that can be done by miniperl
3861
3862 =item PERLMAINCC
3863
3864 The call to the program that is able to compile perlmain.c. Defaults
3865 to $(CC).
3866
3867 =item PERL_ARCHLIB
3868
3869 Same as above for architecture dependent files
3870
3871 =item PERL_LIB
3872
3873 Directory containing the Perl library to use.
3874
3875 =item PERL_SRC
3876
3877 Directory containing the Perl source code (use of this should be
3878 avoided, it may be undefined)
3879
3880 =item PL_FILES
3881
3882 Ref to hash of files to be processed as perl programs. MakeMaker
3883 will default to any found *.PL file (except Makefile.PL) being keys
3884 and the basename of the file being the value. E.g.
3885
3886   {'foobar.PL' => 'foobar'}
3887
3888 The *.PL files are expected to produce output to the target files
3889 themselves.
3890
3891 =item PM
3892
3893 Hashref of .pm files and *.pl files to be installed.  e.g.
3894
3895   {'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm'}
3896
3897 By default this will include *.pm and *.pl. If a lib directory
3898 exists and is not listed in DIR (above) then any *.pm and *.pl files
3899 it contains will also be included by default.  Defining PM in the
3900 Makefile.PL will override PMLIBDIRS.
3901
3902 =item PMLIBDIRS
3903
3904 Ref to array of subdirectories containing library files.  Defaults to
3905 [ 'lib', $(BASEEXT) ]. The directories will be scanned and any files
3906 they contain will be installed in the corresponding location in the
3907 library.  A libscan() method can be used to alter the behaviour.
3908 Defining PM in the Makefile.PL will override PMLIBDIRS.
3909
3910 =item PREFIX
3911
3912 Can be used to set the three INSTALL* attributes in one go (except for
3913 INSTALLMAN1DIR).  They will have PREFIX as a common directory node and
3914 will branch from that node into lib/, lib/ARCHNAME, and bin/ unless
3915 you override one of them.
3916
3917 =item PREREQ
3918
3919 Placeholder, not yet implemented. Will eventually be a hashref: Names
3920 of modules that need to be available to run this extension (e.g. Fcntl
3921 for SDBM_File) are the keys of the hash and the desired version is the
3922 value. Needs further evaluation, should probably allow to define
3923 prerequisites among header files, libraries, perl version, etc.
3924
3925 =item SKIP
3926
3927 Arryref. E.g. [qw(name1 name2)] skip (do not write) sections of the
3928 Makefile
3929
3930 =item TYPEMAPS
3931
3932 Ref to array of typemap file names.  Use this when the typemaps are
3933 in some directory other than the current directory or when they are
3934 not named B<typemap>.  The last typemap in the list takes
3935 precedence.  A typemap in the current directory has highest
3936 precedence, even if it isn't listed in TYPEMAPS.  The default system
3937 typemap has lowest precedence.
3938
3939 =item VERSION
3940
3941 Your version number for distributing the package.  This defaults to
3942 0.1.
3943
3944 =item VERSION_FROM
3945
3946 Instead of specifying the VERSION in the Makefile.PL you can let
3947 MakeMaker parse a file to determine the version number. The parsing
3948 routine requires that the file named by VERSION_FROM contains one
3949 single line to compute the version number. The first line in the file
3950 that contains the regular expression
3951
3952     /(\$[\w:]*\bVERSION)\b.*=/
3953
3954 will be evaluated with eval() and the value of the named variable
3955 B<after> the eval() will be assigned to the VERSION attribute of the
3956 MakeMaker object. The following lines will be parsed o.k.:
3957
3958     $VERSION = '1.00';
3959     ( $VERSION ) = '$Revision: 1.141 $ ' =~ /\$Revision:\s+([^\s]+)/;
3960     $FOO::VERSION = '1.10';
3961
3962 but these will fail:
3963
3964     my $VERSION = '1.01';
3965     local $VERSION = '1.02';
3966     local $FOO::VERSION = '1.30';
3967
3968 The file named in VERSION_FROM is added as a dependency to Makefile to
3969 guarantee, that the Makefile contains the correct VERSION macro after
3970 a change of the file.
3971
3972 =item XS
3973
3974 Hashref of .xs files. MakeMaker will default this.  e.g.
3975
3976   {'name_of_file.xs' => 'name_of_file.c'}
3977
3978 The .c files will automatically be included in the list of files
3979 deleted by a make clean.
3980
3981 =item XSOPT
3982
3983 String of options to pass to xsubpp.  This might include C<-C++> or
3984 C<-extern>.  Do not include typemaps here; the TYPEMAP parameter exists for
3985 that purpose.
3986
3987 =item XSPROTOARG
3988
3989 May be set to an empty string, which is identical to C<-prototypes>, or
3990 C<-noprototypes>. See the xsubpp documentation for details. MakeMaker
3991 defaults to the empty string.
3992
3993 =item XS_VERSION
3994
3995 Your version number for the .xs file of this package.  This defaults
3996 to the value of the VERSION attribute.
3997
3998 =back
3999
4000 =head2 Additional lowercase attributes
4001
4002 can be used to pass parameters to the methods which implement that
4003 part of the Makefile. These are not normally required:
4004
4005 =over 2
4006
4007 =item clean
4008
4009   {FILES => "*.xyz foo"}
4010
4011 =item depend
4012
4013   {ANY_TARGET => ANY_DEPENDECY, ...}
4014
4015 =item dist
4016
4017   {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => 'gz',
4018   SHAR => 'shar -m', DIST_CP => 'ln'}
4019
4020 If you specify COMPRESS, then SUFFIX should also be altered, as it is
4021 needed to tell make the target file of the compression. Setting
4022 DIST_CP to ln can be useful, if you need to preserve the timestamps on
4023 your files. DIST_CP can take the values 'cp', which copies the file,
4024 'ln', which links the file, and 'best' which copies symbolic links and
4025 links the rest. Default is 'best'.
4026
4027 =item dynamic_lib
4028
4029   {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
4030
4031 =item installpm
4032
4033   {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
4034
4035 =item linkext
4036
4037   {LINKTYPE => 'static', 'dynamic' or ''}
4038
4039 NB: Extensions that have nothing but *.pm files had to say
4040
4041   {LINKTYPE => ''}
4042
4043 with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
4044 can be deleted safely. MakeMaker recognizes, when there's nothing to
4045 be linked.
4046
4047 =item macro
4048
4049   {ANY_MACRO => ANY_VALUE, ...}
4050
4051 =item realclean
4052
4053   {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
4054
4055 =item tool_autosplit
4056
4057   {MAXLEN =E<gt> 8}
4058
4059 =back
4060
4061 =cut
4062
4063 # bug in pod2html, so leave the =back
4064
4065 # Don't delete this cut, MM depends on it!
4066
4067 =head2 Overriding MakeMaker Methods
4068
4069 If you cannot achieve the desired Makefile behaviour by specifying
4070 attributes you may define private subroutines in the Makefile.PL.
4071 Each subroutines returns the text it wishes to have written to
4072 the Makefile. To override a section of the Makefile you can
4073 either say:
4074
4075         sub MY::c_o { "new literal text" }
4076
4077 or you can edit the default by saying something like:
4078
4079         sub MY::c_o {
4080             my $self = shift;
4081             local *c_o;
4082             $_=$self->MM::c_o;
4083             s/old text/new text/;
4084             $_;
4085         }
4086
4087 Both methods above are available for backwards compatibility with
4088 older Makefile.PLs.
4089
4090 If you still need a different solution, try to develop another
4091 subroutine, that fits your needs and submit the diffs to
4092 F<perl5-porters@nicoh.com> or F<comp.lang.perl.misc> as appropriate.
4093
4094 =head2 Distribution Support
4095
4096 For authors of extensions MakeMaker provides several Makefile
4097 targets. Most of the support comes from the ExtUtils::Manifest module,
4098 where additional documentation can be found.
4099
4100 =over 4
4101
4102 =item    make distcheck
4103
4104 reports which files are below the build directory but not in the
4105 MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
4106 details)
4107
4108 =item    make skipcheck
4109
4110 reports which files are skipped due to the entries in the
4111 C<MANIFEST.SKIP> file (See ExtUtils::Manifest::skipcheck() for
4112 details)
4113
4114 =item    make distclean
4115
4116 does a realclean first and then the distcheck. Note that this is not
4117 needed to build a new distribution as long as you are sure, that the
4118 MANIFEST file is ok.
4119
4120 =item    make manifest
4121
4122 rewrites the MANIFEST file, adding all remaining files found (See
4123 ExtUtils::Manifest::mkmanifest() for details)
4124
4125 =item    make distdir
4126
4127 Copies all the files that are in the MANIFEST file to a newly created
4128 directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
4129 exists, it will be removed first.
4130
4131 =item   make disttest
4132
4133 Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and
4134 a make test in that directory.
4135
4136 =item    make tardist
4137
4138 First does a command $(PREOP) which defaults to a null command. Does a
4139 distdir next and runs C<tar> on that directory into a tarfile. Then
4140 deletes the distdir. Finishes with a command $(POSTOP) which defaults
4141 to a null command.
4142
4143 =item    make dist
4144
4145 Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
4146
4147 =item    make uutardist
4148
4149 Runs a tardist first and uuencodes the tarfile.
4150
4151 =item    make shdist
4152
4153 First does a command $(PREOP) which defaults to a null command. Does a
4154 distdir next and runs C<shar> on that directory into a sharfile. Then
4155 deletes the distdir. Finishes with a command $(POSTOP) which defaults
4156 to a null command.  Note: For shdist to work properly a C<shar>
4157 program that can handle directories is mandatory.
4158
4159 =item    make ci
4160
4161 Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
4162
4163 =back
4164
4165 Customization of the dist targets can be done by specifying a hash
4166 reference to the dist attribute of the WriteMakefile call. The
4167 following parameters are recognized:
4168
4169     CI           ('ci -u')
4170     COMPRESS     ('compress')
4171     POSTOP       ('@ :')
4172     PREOP        ('@ :')
4173     RCS_LABEL    ('rcs -q -Nv$(VERSION_SYM):')
4174     SHAR         ('shar')
4175     SUFFIX       ('Z')
4176     TAR          ('tar')
4177     TARFLAGS     ('cvf')
4178
4179 An example:
4180
4181     WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" })
4182
4183
4184 =head1 AUTHORS 
4185
4186 Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas
4187 KE<ouml>nig F<E<lt>A.Koenig@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce
4188 F<E<lt>Tim.Bunce@ig.co.ukE<gt>>.  VMS support by Charles Bailey
4189 F<E<lt>bailey@HMIVAX.HUMGEN.UPENN.EDUE<gt>>. Contact the makemaker
4190 mailing list C<mailto:makemaker@franz.ww.tu-berlin.de>, if you have any
4191 questions.
4192
4193 =head1 MODIFICATION HISTORY
4194
4195 For a more complete documentation see the file Changes in the
4196 MakeMaker distribution package.
4197
4198 =head1 TODO
4199
4200 See the file Todo in the MakeMaker distribution package.
4201
4202 =cut