Re: Debugger in beta3
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MakeMaker.pm
1 package main;
2 use vars qw(%att);
3
4 # $Id: MakeMaker.pm,v 1.174 1996/02/06 17:03:12 k Exp $
5
6 package ExtUtils::MakeMaker::TieAtt;
7 # this package will go away again, when we don't have modules around
8 # anymore that import %att It ties an empty %att and records in which
9 # object this %att was tied. FETCH and STORE return/store-to the
10 # appropriate value from %$self
11
12 # the warndirectuse method warns if somebody calls MM->something. It
13 # has nothing to do with the tie'd %att.
14
15 $Enough_limit = 5;
16
17 sub TIEHASH {
18     bless { SECRETHASH => $_[1]};
19 }
20
21 sub FETCH {
22     print "Warning (non-fatal): Importing of %att is deprecated [$_[1]]
23         use \$self instead\n" unless ++$Enough>$Enough_limit;
24     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
25     $_[0]->{SECRETHASH}->{$_[1]};
26 }
27
28 sub STORE {
29     print "Warning (non-fatal): Importing of %att is deprecated [$_[1]][$_[2]]
30         use \$self instead\n" unless ++$Enough>$Enough_limit;
31     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
32     $_[0]->{SECRETHASH}->{$_[1]} = $_[2];
33 }
34
35 sub FIRSTKEY {
36     print "Warning (non-fatal): Importing of %att is deprecated [FIRSTKEY]
37         use \$self instead\n" unless ++$Enough>$Enough_limit;
38     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
39     each %{$_[0]->{SECRETHASH}};
40 }
41
42 sub NEXTKEY {
43     each %{$_[0]->{SECRETHASH}};
44 }
45
46 sub DESTROY {
47 }
48
49 sub warndirectuse {
50     my($caller) = @_;
51     return if $Enough>$Enough_limit;
52     print STDOUT "Warning (non-fatal): Direct use of class methods deprecated; use\n";
53     my($method) = $caller =~ /.*:(\w+)$/;
54     print STDOUT
55 '               my $self = shift;
56                 $self->MM::', $method, "();
57         instead\n";
58     print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n"
59         if ++$Enough==$Enough_limit;
60 }
61
62
63
64
65
66
67 package ExtUtils::MakeMaker;
68
69 $Version = $VERSION = "5.21";
70 $Version_OK = "5.05";   # Makefiles older than $Version_OK will die
71                         # (Will be checked from MakeMaker version 4.13 onwards)
72 ($Revision = substr(q$Revision: 1.174 $, 10)) =~ s/\s+$//;
73
74
75
76 use Config;
77 use Carp;
78 use Cwd;
79 require Exporter;
80 require ExtUtils::Manifest;
81 {
82     # Current (5.21) FileHandle doesn't work with miniperl, so we roll our own
83     # that's all copy & paste code from FileHandle.pm, version of perl5.002b3
84     package FileHandle;
85     use Symbol;
86     sub new {
87         @_ >= 1 && @_ <= 3 or croak('usage: new FileHandle [FILENAME [,MODE]]');
88         my $class = shift;
89         my $fh = gensym;
90         if (@_) {
91             FileHandle::open($fh, @_)
92                 or return undef;
93         }
94         bless $fh, $class;
95     }
96     sub open {
97         @_ >= 2 && @_ <= 4 or croak('usage: $fh->open(FILENAME [,MODE [,PERMS]])');
98         my ($fh, $file) = @_;
99         if (@_ > 2) {
100             my ($mode, $perms) = @_[2, 3];
101             if ($mode =~ /^\d+$/) {
102                 defined $perms or $perms = 0666;
103                 return sysopen($fh, $file, $mode, $perms);
104             }
105             $file = "./" . $file unless $file =~ m#^/#;
106             $file = _open_mode_string($mode) . " $file\0";
107         }
108         open($fh, $file);
109     }
110     sub close {
111         @_ == 1 or croak('usage: $fh->close()');
112         close($_[0]);
113     }
114 }
115
116 use vars qw(
117             $VERSION $Version_OK $Revision
118             $Verbose %MM_Sections
119             @MM_Sections %Recognized_Att_Keys @Get_from_Config
120             %Prepend_dot_dot %Config @Parent %NORMAL_INC
121             $Setup_done
122            );
123 #use strict qw(refs);
124
125 eval {require DynaLoader;};     # Get mod2fname, if defined. Will fail
126                                 # with miniperl.
127
128 #
129 # Set up the inheritance before we pull in the MM_* packages, because they
130 # import variables and functions from here
131 #
132 @ISA = qw(Exporter);
133 @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
134 @EXPORT_OK = qw($VERSION &Version_check &help &neatvalue &mkbootstrap &mksymlists
135                 $Version %att);  ## Import of %att is deprecated, please use OO features!
136                 # $Version in mixed case will go away!
137
138 #
139 # Dummy package MM inherits actual methods from OS-specific
140 # default packages.  We use this intermediate package so
141 # MY::XYZ->func() can call MM->func() and get the proper
142 # default routine without having to know under what OS
143 # it's running.
144 #
145 @MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::Liblist ExtUtils::MakeMaker];
146
147 #
148 # Setup dummy package:
149 # MY exists for overriding methods to be defined within
150 #
151 {
152     package MY;
153     @ISA = qw(MM);
154 }
155
156 {
157     package MM;
158     # From somwhere they will want to inherit DESTROY
159     sub DESTROY {}
160 }
161
162 #
163 # No we can can pull in the friends
164 #
165 require ExtUtils::MM_Unix;
166 if ($Is_VMS = ($Config{osname} eq 'VMS')) {
167     require ExtUtils::MM_VMS;
168     require VMS::Filespec;
169     import VMS::Filespec '&vmsify';
170 }
171 if ($Is_OS2 = $Config{osname} =~ m|^os/?2$|i) {
172     require ExtUtils::MM_OS2;
173 }
174
175 %NORMAL_INC = %INC;
176 # package name for the classes into which the first object will be blessed
177 $PACKNAME = "PACK000";
178
179  #####
180 #     #  #    #  #####
181 #        #    #  #    #
182  #####   #    #  #####
183       #  #    #  #    #
184 #     #  #    #  #    #
185  #####    ####   #####
186
187
188 #
189 # MakeMaker serves currently (v 5.20) only for two purposes:
190 # Version_Check, and WriteMakefile. For WriteMakefile SelfLoader
191 # doesn't buy us anything. But for Version_Check we win with
192 # SelfLoader more than a second.
193 #
194 # The only subroutine we do not SelfLoad is Version_Check because it's
195 # called so often. Loading this minimum still requires 1.2 secs on my
196 # Indy :-(
197 #
198
199 sub Version_check {
200     my($checkversion) = @_;
201     die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
202 Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
203 changes in the meantime.
204 Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
205     if $checkversion < $Version_OK;
206     printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
207     $checkversion, "Current Version is", $VERSION
208         unless $checkversion == $VERSION;
209 }
210
211 # We don't selfload this, because chdir sometimes has problems
212 sub eval_in_subdirs {
213     my($self) = @_;
214     my($dir);
215 #    print "Starting to wade through directories:\n";
216 #    print join "\n", @{$self->{DIR}}, "\n";
217     my $pwd = cwd();
218
219     # As strange things happened twice in the history of MakeMaker to $self->{DIR},
220     # lets be careful, maybe it helps some:
221 #    my(@copy_of_DIR) = @{$self->{DIR}};
222 #    my %copy;
223 #    @copy{@copy_od_DIR} = (1) x @copy_of_DIR;
224
225     # with Tk-9.02 these give me as third directory "1":
226     # foreach $dir (@($self->{DIR}){
227     # foreach $dir (@copy_of_DIR){
228
229     # this gives mi as third directory a core dump:
230     # while ($dir = shift @copy_of_DIR){
231
232     # this finishes the loop immediately:
233 #     foreach $dir (keys %copy){
234 #         print "Next to come: $dir\n";
235 #         chdir $dir or die "Couldn't change to directory $dir: $!";
236 #         package main;
237 #         my $fh = new FileHandle;
238 #         $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir");
239 #         my $eval = join "", <$fh>;
240 #         $fh->close;
241 #         eval $eval;
242 #         warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@;
243 #         chdir $pwd or die "Couldn't change to directory $pwd: $!";
244 #     }
245
246
247     # So this did the trick (did it?)
248     foreach $dir (@{$self->{DIR}}){
249 #       print "Next to come: $dir\n";
250         my($abs) = $self->catdir($pwd,$dir);
251         $self->eval_in_x($abs);
252     }
253
254     chdir $pwd;
255
256 #    print "Proudly presenting you self->{DIR}:\n";
257 #    print join "\n", @{$self->{DIR}}, "\n";
258
259 }
260
261 sub eval_in_x {
262     my($self,$dir) = @_;
263     package main;
264     chdir $dir or carp("Couldn't change to directory $dir: $!");
265     my $fh = new FileHandle;
266     $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir");
267     my $eval = join "", <$fh>;
268     $fh->close;
269     eval $eval;
270     warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@;
271 }
272
273 # use SelfLoader;
274 # sub ExtUtils::MakeMaker::full_setup ;
275 # sub ExtUtils::MakeMaker::attrib_help ;
276 # sub ExtUtils::MakeMaker::writeMakefile ;
277 # sub ExtUtils::MakeMaker::WriteMakefile ;
278 # sub ExtUtils::MakeMaker::new ;
279 # sub ExtUtils::MakeMaker::check_manifest ;
280 # sub ExtUtils::MakeMaker::parse_args ;
281 # sub ExtUtils::MakeMaker::check_hints ;
282 # sub ExtUtils::MakeMaker::mv_all_methods ;
283 # sub ExtUtils::MakeMaker::prompt ;
284 # sub ExtUtils::MakeMaker::help ;
285 # sub ExtUtils::MakeMaker::skipcheck ;
286 # sub ExtUtils::MakeMaker::flush ;
287 # sub ExtUtils::MakeMaker::mkbootstrap ;
288 # sub ExtUtils::MakeMaker::mksymlists ;
289 # sub ExtUtils::MakeMaker::neatvalue ;
290 # sub ExtUtils::MakeMaker::selfdocument ;
291
292 # 1;
293
294 # __DATA__
295
296 #
297 # We're done with inheritance setup. As we have two frequently called
298 # things: Check_Version() and mod_install(), we want to reduce startup
299 # time. Only WriteMakefile needs all the power here. 
300 #
301
302 sub full_setup {
303     $Verbose ||= 0;
304     $^W=1;
305     $SIG{__WARN__} = sub {
306         $_[0] =~ /^Use of uninitialized value/ && return;
307         $_[0] =~ /used only once/ && return;
308         $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
309         warn @_;
310     };
311
312     @MM_Sections = 
313         qw(
314         post_initialize const_config constants const_loadlibs
315         const_cccmd tool_autosplit tool_xsubpp tools_other dist macro
316         depend post_constants pasthru c_o xs_c xs_o top_targets
317         linkext dlsyms dynamic dynamic_bs dynamic_lib static
318         static_lib installpm manifypods processPL installbin subdirs
319         clean realclean dist_basics dist_core dist_dir dist_test
320         dist_ci install force perldepend makefile staticmake test
321         postamble selfdocument
322           ); # loses section ordering
323
324     @MM_Sections{@MM_Sections} = {} x @MM_Sections;
325
326     # All sections are valid keys.
327     %Recognized_Att_Keys = %MM_Sections;
328
329     # we will use all these variables in the Makefile
330     @Get_from_Config = 
331         qw(
332            ar cc cccdlflags ccdlflags dlext dlsrc ld lddlflags ldflags libc
333            lib_ext obj_ext ranlib sitelibexp sitearchexp so
334           );
335
336     my $item;
337     foreach $item (split(/\n/,attrib_help())){
338         next unless $item =~ m/^=item\s+(\w+)\s*$/;
339         $Recognized_Att_Keys{$1} = $2;
340         print "Attribute '$1' => '$2'\n" if ($Verbose >= 2);
341     }
342     foreach $item (@Get_from_Config) {
343         $Recognized_Att_Keys{uc $item} = $Config{$item};
344         print "Attribute '\U$item\E' => '$Config{$item}'\n"
345             if ($Verbose >= 2);
346     }
347
348     #
349     # When we pass these through to a Makefile.PL in a subdirectory, we prepend
350     # "..", so that all files to be installed end up below ./blib
351     #
352     %Prepend_dot_dot = 
353         qw(
354            INST_LIB 1 INST_ARCHLIB 1 INST_EXE 1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1
355            PERL_SRC 1 PERL 1 FULLPERL 1
356           );
357
358 }
359
360 sub attrib_help {
361     return $Attrib_Help if $Attrib_Help;
362     my $switch = 0;
363     my $help = "";
364     my $line;
365     while ($line = <DATA>) {
366         $switch ||= $line =~ /^=item C\s*$/;
367         next unless $switch;
368         last if $line =~ /^=cut/;
369         $help .= $line;
370     }
371 #    close DATA;
372     $Attrib_Help = $help;
373 }
374
375 sub writeMakefile {
376     die <<END;
377
378 The extension you are trying to build apparently is rather old and
379 most probably outdated. We detect that from the fact, that a
380 subroutine "writeMakefile" is called, and this subroutine is not
381 supported anymore since about October 1994.
382
383 Please contact the author or look into CPAN (details about CPAN can be
384 found in the FAQ and at http:/www.perl.com) for a more recent version
385 of the extension. If you're really desperate, you can try to change
386 the subroutine name from writeMakefile to WriteMakefile and rerun
387 'perl Makefile.PL', but you're most probably left alone, when you do
388 so.
389
390 The MakeMaker team
391
392 END
393 }
394
395 sub WriteMakefile {
396     Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
397     my %att = @_;
398     MM->new(\%att)->flush;
399 }
400
401 sub new {
402     my($class,$self) = @_;
403     full_setup() unless $Setup_done++;
404
405     my($key);
406
407     print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose;
408     if (-f "MANIFEST" && ! -f "Makefile"){
409         check_manifest();
410     }
411
412     $self = {} unless (defined $self);
413
414     check_hints($self);
415
416     my(%initial_att) = %$self; # record initial attributes
417
418     if (defined $self->{CONFIGURE}) {
419         if (ref $self->{CONFIGURE} eq 'CODE') {
420             $self = { %$self, %{&{$self->{CONFIGURE}}}};
421         } else {
422             croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
423         }
424     }
425
426     # This is for old Makefiles written pre 5.00, will go away
427     if ( Carp::longmess("") =~ /runsubdirpl/s ){
428         #$self->{Correct_relativ_directories}++;
429         carp("WARNING: Please rerun 'perl Makefile.PL' to regenerate your Makefiles\n");
430     } else {
431         $self->{Correct_relativ_directories}=0;
432     }
433
434     my $class = ++$PACKNAME;
435     {
436 #       no strict;
437         print "Blessing Object into class [$class]\n" if $Verbose>=2;
438         mv_all_methods("MY",$class);
439         bless $self, $class;
440         push @Parent, $self;
441         @{"$class\:\:ISA"} = 'MM';
442     }
443
444     if (defined $Parent[-2]){
445         $self->{PARENT} = $Parent[-2];
446         my $key;
447         for $key (keys %Prepend_dot_dot) {
448             next unless defined $self->{PARENT}{$key};
449             $self->{$key} = $self->{PARENT}{$key};
450             $self->{$key} = $self->catdir("..",$self->{$key})
451                 unless $self->{$key} =~ m!^/!;
452         }
453         $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT};
454     } else {
455         parse_args($self,@ARGV);
456     }
457
458     $self->{NAME} ||= $self->guess_name;
459
460     ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
461
462     $self->init_main();
463
464     if (! $self->{PERL_SRC} ) {
465         my($pthinks) = $INC{'Config.pm'};
466         $pthinks = vmsify($pthinks) if $Is_VMS;
467         if ($pthinks ne $self->catfile($Config{archlibexp},'Config.pm')){
468             $pthinks =~ s!/Config\.pm$!!;
469             $pthinks =~ s!.*/!!;
470             print STDOUT <<END;
471 Your perl and your Config.pm seem to have different ideas about the architecture
472 they are running on.
473 Perl thinks: [$pthinks]
474 Config says: [$Config{archname}]
475 This may or may not cause problems. Please check your installation of perl if you
476 have problems building this extension.
477 END
478         }
479     }
480
481     $self->init_dirscan();
482     $self->init_others();
483
484     push @{$self->{RESULT}}, <<END;
485 # This Makefile is for the $self->{NAME} extension to perl.
486 #
487 # It was generated automatically by MakeMaker version
488 # $VERSION (Revision: $Revision) from the contents of
489 # Makefile.PL. Don't edit this file, edit Makefile.PL instead.
490 #
491 #       ANY CHANGES MADE HERE WILL BE LOST!
492 #
493 #   MakeMaker Parameters:
494 END
495
496     foreach $key (sort keys %initial_att){
497         my($v) = neatvalue($initial_att{$key});
498         $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
499         $v =~ tr/\n/ /s;
500         push @{$self->{RESULT}}, "#     $key => $v";
501     }
502
503     # turn the SKIP array into a SKIPHASH hash
504     my (%skip,$skip);
505     for $skip (@{$self->{SKIP} || []}) {
506         $self->{SKIPHASH}{$skip} = 1;
507     }
508
509     # We run all the subdirectories now. They don't have much to query
510     # from the parent, but the parent has to query them: if they need linking!
511     unless ($self->{NORECURS}) {
512         $self->eval_in_subdirs if @{$self->{DIR}};
513     }
514
515     tie %::att, ExtUtils::MakeMaker::TieAtt, $self;
516     my $section;
517     foreach $section ( @MM_Sections ){
518         print "Processing Makefile '$section' section\n" if ($Verbose >= 2);
519         my($skipit) = $self->skipcheck($section);
520         if ($skipit){
521             push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
522         } else {
523             my(%a) = %{$self->{$section} || {}};
524             push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
525             push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
526             push @{$self->{RESULT}}, $self->nicetext($self->$section( %a ));
527         }
528     }
529
530     push @{$self->{RESULT}}, "\n# End.";
531     pop @Parent;
532
533     $self;
534 }
535
536 sub check_manifest {
537     print STDOUT "Checking if your kit is complete...\n";
538     $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
539     my(@missed)=ExtUtils::Manifest::manicheck();
540     if (@missed){
541         print STDOUT "Warning: the following files are missing in your kit:\n";
542         print "\t", join "\n\t", @missed;
543         print STDOUT "\n";
544         print STDOUT "Please inform the author.\n";
545     } else {
546         print STDOUT "Looks good\n";
547     }
548 }
549
550 sub parse_args{
551     my($self, @args) = @_;
552     foreach (@args){
553         unless (m/(.*?)=(.*)/){
554             help(),exit 1 if m/^help$/;
555             ++$Verbose if m/^verb/;
556             next;
557         }
558         my($name, $value) = ($1, $2);
559         if ($value =~ m/^~(\w+)?/){ # tilde with optional username
560             $value =~ s [^~(\w*)]
561                 [$1 ?
562                  ((getpwnam($1))[7] || "~$1") :
563                  (getpwuid($>))[7]
564                  ]ex;
565         }
566         # This may go away, in mid 1996
567         if ($self->{Correct_relativ_directories}){
568             $value = $self->catdir("..",$value)
569                 if $Prepend_dot_dot{$name} && ! $value =~ m!^/!;
570         }
571         $self->{$name} = $value;
572     }
573     # This may go away, in mid 1996
574     delete $self->{Correct_relativ_directories};
575
576     # catch old-style 'potential_libs' and inform user how to 'upgrade'
577     if (defined $self->{potential_libs}){
578         my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
579         if ($self->{potential_libs}){
580             print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
581         } else {
582             print STDOUT "$msg deleted.\n";
583         }
584         $self->{LIBS} = [$self->{potential_libs}];
585         delete $self->{potential_libs};
586     }
587     # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
588     if (defined $self->{ARMAYBE}){
589         my($armaybe) = $self->{ARMAYBE};
590         print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
591                         "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
592         my(%dl) = %{$self->{dynamic_lib} || {}};
593         $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
594         delete $self->{ARMAYBE};
595     }
596     if (defined $self->{LDTARGET}){
597         print STDOUT "LDTARGET should be changed to LDFROM\n";
598         $self->{LDFROM} = $self->{LDTARGET};
599         delete $self->{LDTARGET};
600     }
601     # Turn a DIR argument on the command line into an array
602     if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
603         # So they can choose from the command line, which extensions they want
604         # the grep enables them to have some colons too much in case they
605         # have to build a list with the shell
606         $self->{DIR} = [grep $_, split ":", $self->{DIR}];
607     }
608     my $mmkey;
609     foreach $mmkey (sort keys %$self){
610         print STDOUT "  $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose;
611         print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n"
612             unless exists $Recognized_Att_Keys{$mmkey};
613     }
614 }
615
616 sub check_hints {
617     my($self) = @_;
618     # We allow extension-specific hints files.
619
620     return unless -d "hints";
621
622     # First we look for the best hintsfile we have
623     my(@goodhints);
624     my($hint)="$Config{osname}_$Config{osvers}";
625     $hint =~ s/\./_/g;
626     $hint =~ s/_$//;
627     return unless $hint;
628
629     # Also try without trailing minor version numbers.
630     while (1) {
631         last if -f "hints/$hint.pl";      # found
632     } continue {
633         last unless $hint =~ s/_[^_]*$//; # nothing to cut off
634     }
635     return unless -f "hints/$hint.pl";    # really there
636
637     # execute the hintsfile:
638     my $fh = new FileHandle;
639     $fh->open("hints/$hint.pl");
640     @goodhints = <$fh>;
641     $fh->close;
642     print STDOUT "Processing hints file hints/$hint.pl\n";
643     eval join('',@goodhints);
644     print STDOUT $@ if $@;
645 }
646
647 sub mv_all_methods {
648     my($from,$to) = @_;
649     my($method);
650     my($symtab) = \%{"${from}::"};
651 #    no strict;
652
653     # Here you see the *current* list of methods that are overridable
654     # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm
655     # still trying to reduce the list to some reasonable minimum --
656     # because I want to make it easier for the user. A.K.
657
658     foreach $method (@MM_Sections, qw[ dir_target
659 fileparse fileparse_set_fstype installpm_x libscan makeaperl
660 mksymlists needs_linking subdir_x test_via_harness
661 test_via_script writedoc ]) {
662
663         # We cannot say "next" here. Nick might call MY->makeaperl
664         # which isn't defined right now
665
666         # next unless defined &{"${from}::$method"};
667
668         *{"${to}::$method"} = \&{"${from}::$method"};
669
670         # delete would do, if we were sure, nobody ever called
671         # MY->makeaperl directly
672
673         # delete $symtab->{$method};
674
675         # If we delete a method, then it will be undefined and cannot
676         # be called.  But as long as we have Makefile.PLs that rely on
677         # %MY:: being intact, we have to fill the hole with an
678         # inheriting method:
679
680         eval "package MY; sub $method {local *$method; shift->MY::$method(\@_); }";
681
682     }
683
684     # We have to clean out %INC also, because the current directory is
685     # changed frequently and Graham Barr prefers to get his version
686     # out of a History.pl file which is "required" so woudn't get
687     # loaded again in another extension requiring a History.pl
688
689     my $inc;
690     foreach $inc (keys %INC) {
691         next if $NORMAL_INC{$inc};
692         #warn "***$inc*** deleted";
693         delete $INC{$inc};
694     }
695
696 }
697
698 sub prompt {
699     my($mess,$def)=@_;
700     BEGIN { $ISA_TTY = -t STDIN && -t STDOUT }
701     Carp::confess("prompt function called without an argument") unless defined $mess;
702     $def = "" unless defined $def;
703     my $dispdef = "[$def] ";
704     my $ans;
705     if ($ISA_TTY) {
706         local $|=1;
707         print "$mess $dispdef";
708         chop($ans = <STDIN>);
709     }
710     return $ans if defined $ans;
711     return $def;
712 }
713
714 sub help {print &attrib_help, "\n";}
715
716 sub skipcheck{
717     my($self) = shift;
718     my($section) = @_;
719     if ($section eq 'dynamic') {
720         print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
721         "in skipped section 'dynamic_bs'\n"
722             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
723         print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
724         "in skipped section 'dynamic_lib'\n"
725             if $self->{SKIPHASH}{dynamic_lib} && $Verbose;
726     }
727     if ($section eq 'dynamic_lib') {
728         print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
729         "targets in skipped section 'dynamic_bs'\n"
730             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
731     }
732     if ($section eq 'static') {
733         print STDOUT "Warning (non-fatal): Target 'static' depends on targets ",
734         "in skipped section 'static_lib'\n"
735             if $self->{SKIPHASH}{static_lib} && $Verbose;
736     }
737     return 'skipped' if $self->{SKIPHASH}{$section};
738     return '';
739 }
740
741 sub flush {
742     my $self = shift;
743     my($chunk);
744     my $fh = new FileHandle;
745     print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n";
746
747     unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
748     $fh->open(">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!";
749
750     for $chunk (@{$self->{RESULT}}) {
751         print $fh "$chunk\n";
752     }
753
754     $fh->close;
755     my($finalname) = $self->{MAKEFILE};
756     rename("MakeMaker.tmp", $finalname);
757     chmod 0644, $finalname unless $Is_VMS;
758     system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":";
759 }
760
761 # The following mkbootstrap() is only for installations that are calling
762 # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
763 # writes Makefiles, that use ExtUtils::Mkbootstrap directly.
764 sub mkbootstrap {
765     die <<END;
766 !!! Your Makefile has been built such a long time ago, !!!
767 !!! that is unlikely to work with current MakeMaker.   !!!
768 !!! Please rebuild your Makefile                       !!!
769 END
770 }
771
772 # Ditto for mksymlists() as of MakeMaker 5.17
773 sub mksymlists {
774     die <<END;
775 !!! Your Makefile has been built such a long time ago, !!!
776 !!! that is unlikely to work with current MakeMaker.   !!!
777 !!! Please rebuild your Makefile                       !!!
778 END
779 }
780
781 sub neatvalue {
782     my($v) = @_;
783     return "undef" unless defined $v;
784     my($t) = ref $v;
785     return "q[$v]" unless $t;
786     if ($t eq 'ARRAY') {
787         my(@m, $elem, @neat);
788         push @m, "[";
789         foreach $elem (@$v) {
790             push @neat, "q[$elem]";
791         }
792         push @m, join ", ", @neat;
793         push @m, "]";
794         return join "", @m;
795     }
796     return "$v" unless $t eq 'HASH';
797     my(@m, $key, $val);
798     push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
799     return "{ ".join(', ',@m)." }";
800 }
801
802 sub selfdocument {
803     my($self) = @_;
804     my(@m);
805     if ($Verbose){
806         push @m, "\n# Full list of MakeMaker attribute values:";
807         foreach $key (sort keys %$self){
808             next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
809             my($v) = neatvalue($self->{$key});
810             $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
811             $v =~ tr/\n/ /s;
812             push @m, "# $key => $v";
813         }
814     }
815     join "\n", @m;
816 }
817
818 package ExtUtils::MakeMaker;
819 1;
820
821 # Without selfLoader we need
822 __DATA__
823
824
825 # For SelfLoader we need 
826 # __END__ DATA
827
828
829 =head1 NAME
830
831 ExtUtils::MakeMaker - create an extension Makefile
832
833 =head1 SYNOPSIS
834
835 C<use ExtUtils::MakeMaker;>
836
837 C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
838
839 which is really
840
841 C<MM-E<gt>new(\%att)-E<gt>flush;>
842
843 =head1 DESCRIPTION
844
845 This utility is designed to write a Makefile for an extension module
846 from a Makefile.PL. It is based on the Makefile.SH model provided by
847 Andy Dougherty and the perl5-porters.
848
849 It splits the task of generating the Makefile into several subroutines
850 that can be individually overridden.  Each subroutine returns the text
851 it wishes to have written to the Makefile.
852
853 =head2 Hintsfile support
854
855 MakeMaker.pm uses the architecture specific information from
856 Config.pm. In addition it evaluates architecture specific hints files
857 in a C<hints/> directory. The hints files are expected to be named
858 like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
859 name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
860 MakeMaker within the WriteMakefile() subroutine, and can be used to
861 execute commands as well as to include special variables. The rules
862 which hintsfile is chosen are the same as in Configure.
863
864 The hintsfile is eval()ed immediately after the arguments given to
865 WriteMakefile are stuffed into a hash reference $self but before this
866 reference becomes blessed. So if you want to do the equivalent to
867 override or create an attribute you would say something like
868
869     $self->{LIBS} = ['-ldbm -lucb -lc'];
870
871 =head2 What's new in version 5 of MakeMaker
872
873 MakeMaker 5 is pure object oriented. This allows us to write an
874 unlimited number of Makefiles with a single perl process. 'perl
875 Makefile.PL' with MakeMaker 5 goes through all subdirectories
876 immediately and evaluates any Makefile.PL found in the next level
877 subdirectories. The benefit of this approach comes in useful for both
878 single and multi directories extensions.
879
880 Multi directory extensions have an immediately visible speed
881 advantage, because there's no startup penalty for any single
882 subdirectory Makefile.
883
884 Single directory packages benefit from the much improved
885 needs_linking() method. As the main Makefile knows everything about
886 the subdirectories, a needs_linking() method can now query all
887 subdirectories if there is any linking involved down in the tree. The
888 speedup for PM-only Makefiles seems to be around 1 second on my
889 Indy 100 MHz.
890
891 =head2 Incompatibilities between MakeMaker 5.00 and 4.23
892
893 There are no incompatibilities in the short term, as all changes are
894 accompanied by short-term workarounds that guarantee full backwards
895 compatibility.
896
897 You are likely to face a few warnings that expose deprecations which
898 will result in incompatibilities in the long run:
899
900 You should not use %att directly anymore. Instead any subroutine you
901 override in the MY package will be called by the object method, so you
902 can access all object attributes directly via the object in $_[0].
903
904 You should not call the class methos MM->something anymore. Instead
905 you should call the superclass. Something like
906
907     sub MY::constants {
908         my $self = shift;
909         $self->MM::constants();
910     }
911
912 Especially the libscan() and exescan() methods should be altered
913 towards OO programming, that means do not expect that $_ to contain
914 the path but rather $_[1].
915
916 Try to build several extensions simultanously to debug your
917 Makefile.PL. You can unpack a bunch of distributed packages within one
918 directory and run
919
920     perl -MExtUtils::MakeMaker -e 'WriteMakefile()'
921
922 That's actually fun to watch :)
923
924 Final suggestion: Try to delete all of your MY:: subroutines and
925 watch, if you really still need them. MakeMaker might already do what
926 you want without them. That's all about it.
927
928
929 =head2 Default Makefile Behaviour
930
931 The automatically generated Makefile enables the user of the extension
932 to invoke
933
934   perl Makefile.PL # optionally "perl Makefile.PL verbose"
935   make
936   make test        # optionally set TEST_VERBOSE=1
937   make install     # See below
938
939 The Makefile to be produced may be altered by adding arguments of the
940 form C<KEY=VALUE>. E.g.
941
942   perl Makefile.PL PREFIX=/tmp/myperl5
943
944 Other interesting targets in the generated Makefile are
945
946   make config     # to check if the Makefile is up-to-date
947   make clean      # delete local temp files (Makefile gets renamed)
948   make realclean  # delete derived files (including ./blib)
949   make ci         # check in all the files in the MANIFEST file
950   make dist       # see below the Distribution Support section
951
952 =head2 make test
953
954 MakeMaker checks for the existence of a file named "test.pl" in the
955 current directory and if it exists it adds commands to the test target
956 of the generated Makefile that will execute the script with the proper
957 set of perl C<-I> options.
958
959 MakeMaker also checks for any files matching glob("t/*.t"). It will
960 add commands to the test target of the generated Makefile that execute
961 all matching files via the L<Test::Harness> module with the C<-I>
962 switches set correctly.
963
964 =head2 make install
965
966 make alone puts all relevant files into directories that are named by
967 the macros INST_LIB, INST_ARCHLIB, INST_EXE, INST_MAN1DIR, and
968 INST_MAN3DIR. All these default to something below ./blib if
969 you are I<not> building below the perl source directory. If you I<are>
970 building below the perl source, INST_LIB and INST_ARCHLIB default to
971  ../../lib, and INST_EXE is not defined.
972
973 The I<install> target of the generated Makefile copies the files found
974 below each of the INST_* directories to their INSTALL*
975 counterparts. Which counterparts are chosen depends on the setting of
976 INSTALLDIRS according to the following table:
977
978                            INSTALLDIRS set to
979                         perl              site
980
981     INST_LIB        INSTALLPRIVLIB    INSTALLSITELIB
982     INST_ARCHLIB    INSTALLARCHLIB    INSTALLSITEARCH
983     INST_EXE                   INSTALLBIN
984     INST_MAN1DIR             INSTALLMAN1DIR
985     INST_MAN3DIR             INSTALLMAN3DIR
986
987 The INSTALL... macros in turn default to their %Config
988 ($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
989
990 If you don't want to keep the defaults, MakeMaker helps you to
991 minimize the typing needed: the usual relationship between
992 INSTALLPRIVLIB and INSTALLARCHLIB is determined by Configure at perl
993 compilation time. MakeMaker supports the user who sets
994 INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then
995 MakeMaker defaults the latter to be the same subdirectory of
996 INSTALLPRIVLIB as Configure decided for the counterparts in %Config ,
997 otherwise it defaults to INSTALLPRIVLIB. The same relationship holds
998 for INSTALLSITELIB and INSTALLSITEARCH.
999
1000 MakeMaker gives you much more freedom than needed to configure
1001 internal variables and get different results. It is worth to mention,
1002 that make(1) also lets you configure most of the variables that are
1003 used in the Makefile. But in the majority of situations this will not
1004 be necessary, and should only be done, if the author of a package
1005 recommends it.
1006
1007
1008 =head2 PREFIX attribute
1009
1010 The PREFIX attribute can be used to set the INSTALL* attributes in one
1011 go. The quickest way to install a module in a non-standard place
1012
1013     perl Makefile.PL PREFIX=~
1014
1015 This will replace the string specified by $Config{prefix} in all
1016 $Config{install*} values.
1017
1018 Note, that the tilde expansion is done by MakeMaker, not by perl by
1019 default, nor by make.
1020
1021 If the user has superuser privileges, and is not working on AFS
1022 (Andrew File System) or relatives, then the defaults for
1023 INSTALLPRIVLIB, INSTALLARCHLIB, INSTALLBIN, etc. will be appropriate,
1024 and this incantation will be the best:
1025
1026     perl Makefile.PL; make; make test
1027     make install
1028
1029 make install per default writes some documentation of what has been
1030 done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature
1031 can be bypassed by calling make pure_install.
1032
1033 =head2 AFS users
1034
1035 will have to specify the installation directories as these most
1036 probably have changed since perl itself has been installed. They will
1037 have to do this by calling
1038
1039     perl Makefile.PL INSTALLSITELIB=/afs/here/today \
1040         INSTALLBIN=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
1041     make
1042
1043 Be careful to repeat this procedure every time you recompile an
1044 extension, unless you are sure the AFS installation directories are
1045 still valid.
1046
1047 =head2 Static Linking of a new Perl Binary
1048
1049 An extension that is built with the above steps is ready to use on
1050 systems supporting dynamic loading. On systems that do not support
1051 dynamic loading, any newly created extension has to be linked together
1052 with the available resources. MakeMaker supports the linking process
1053 by creating appropriate targets in the Makefile whenever an extension
1054 is built. You can invoke the corresponding section of the makefile with
1055
1056     make perl
1057
1058 That produces a new perl binary in the current directory with all
1059 extensions linked in that can be found in INST_ARCHLIB , SITELIBEXP,
1060 and PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on
1061 UNIX, this is called Makefile.aperl (may be system dependent). If you
1062 want to force the creation of a new perl, it is recommended, that you
1063 delete this Makefile.aperl, so the directories are searched-through
1064 for linkable libraries again.
1065
1066 The binary can be installed into the directory where perl normally
1067 resides on your machine with
1068
1069     make inst_perl
1070
1071 To produce a perl binary with a different name than C<perl>, either say
1072
1073     perl Makefile.PL MAP_TARGET=myperl
1074     make myperl
1075     make inst_perl
1076
1077 or say
1078
1079     perl Makefile.PL
1080     make myperl MAP_TARGET=myperl
1081     make inst_perl MAP_TARGET=myperl
1082
1083 In any case you will be prompted with the correct invocation of the
1084 C<inst_perl> target that installs the new binary into INSTALLBIN.
1085
1086 make inst_perl per default writes some documentation of what has been
1087 done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
1088 can be bypassed by calling make pure_inst_perl.
1089
1090 Warning: the inst_perl: target will most probably overwrite your
1091 existing perl binary. Use with care!
1092
1093 Sometimes you might want to build a statically linked perl although
1094 your system supports dynamic loading. In this case you may explicitly
1095 set the linktype with the invocation of the Makefile.PL or make:
1096
1097     perl Makefile.PL LINKTYPE=static    # recommended
1098
1099 or
1100
1101     make LINKTYPE=static                # works on most systems
1102
1103 =head2 Determination of Perl Library and Installation Locations
1104
1105 MakeMaker needs to know, or to guess, where certain things are
1106 located.  Especially INST_LIB and INST_ARCHLIB (where to put the files
1107 during the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read
1108 existing modules from), and PERL_INC (header files and C<libperl*.*>).
1109
1110 Extensions may be built either using the contents of the perl source
1111 directory tree or from the installed perl library. The recommended way
1112 is to build extensions after you have run 'make install' on perl
1113 itself. You can do that in any directory on your hard disk that is not
1114 below the perl source tree. The support for extensions below the ext
1115 directory of the perl distribution is only good for the standard
1116 extensions that come with perl.
1117
1118 If an extension is being built below the C<ext/> directory of the perl
1119 source then MakeMaker will set PERL_SRC automatically (e.g.,
1120 C<../..>).  If PERL_SRC is defined and the extension is recognized as
1121 a standard extension, then other variables default to the following:
1122
1123   PERL_INC     = PERL_SRC
1124   PERL_LIB     = PERL_SRC/lib
1125   PERL_ARCHLIB = PERL_SRC/lib
1126   INST_LIB     = PERL_LIB
1127   INST_ARCHLIB = PERL_ARCHLIB
1128
1129 If an extension is being built away from the perl source then MakeMaker
1130 will leave PERL_SRC undefined and default to using the installed copy
1131 of the perl library. The other variables default to the following:
1132
1133   PERL_INC     = $archlibexp/CORE
1134   PERL_LIB     = $privlibexp
1135   PERL_ARCHLIB = $archlibexp
1136   INST_LIB     = ./blib/lib
1137   INST_ARCHLIB = ./blib/arch
1138
1139 If perl has not yet been installed then PERL_SRC can be defined on the
1140 command line as shown in the previous section.
1141
1142 =head2 Useful Default Makefile Macros
1143
1144 FULLEXT = Pathname for extension directory (eg DBD/Oracle).
1145
1146 BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
1147
1148 ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
1149
1150 INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)>
1151
1152 INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)>
1153
1154 INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)>
1155
1156 =head2 Using Attributes and Parameters
1157
1158 The following attributes can be specified as arguments to WriteMakefile()
1159 or as NAME=VALUE pairs on the command line:
1160
1161 =cut
1162
1163 # The following "=item C" is used by the attrib_help routine
1164 # likewise the "=back" below. So be careful when changing it!
1165
1166 =over 2
1167
1168 =item C
1169
1170 Ref to array of *.c file names. Initialised from a directory scan
1171 and the values portion of the XS attribute hash. This is not
1172 currently used by MakeMaker but may be handy in Makefile.PLs.
1173
1174 =item CONFIG
1175
1176 Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
1177 config.sh. MakeMaker will add to CONFIG the following values anyway:
1178 ar
1179 cc
1180 cccdlflags
1181 ccdlflags
1182 dlext
1183 dlsrc
1184 ld
1185 lddlflags
1186 ldflags
1187 libc
1188 lib_ext
1189 obj_ext
1190 ranlib
1191 sitelibexp
1192 sitearchexp
1193 so
1194
1195 =item CONFIGURE
1196
1197 CODE reference. The subroutine should return a hash reference. The
1198 hash may contain further attributes, e.g. {LIBS => ...}, that have to
1199 be determined by some evaluation method.
1200
1201 =item DEFINE
1202
1203 Something like C<"-DHAVE_UNISTD_H">
1204
1205 =item DIR
1206
1207 Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm'
1208 ] in ext/SDBM_File
1209
1210 =item DISTNAME
1211
1212 Your name for distributing the package (by tar file). This defaults to
1213 NAME above.
1214
1215 =item DL_FUNCS
1216
1217 Hashref of symbol names for routines to be made available as
1218 universal symbols.  Each key/value pair consists of the package name
1219 and an array of routine names in that package.  Used only under AIX
1220 (export lists) and VMS (linker options) at present.  The routine
1221 names supplied will be expanded in the same way as XSUB names are
1222 expanded by the XS() macro.  Defaults to
1223
1224   {"$(NAME)" => ["boot_$(NAME)" ] }
1225
1226 e.g.
1227
1228   {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
1229    "NetconfigPtr" => [ 'DESTROY'] }
1230
1231 =item DL_VARS
1232
1233 Array of symbol names for variables to be made available as
1234 universal symbols.  Used only under AIX (export lists) and VMS
1235 (linker options) at present.  Defaults to [].  (e.g. [ qw(
1236 Foo_version Foo_numstreams Foo_tree ) ])
1237
1238 =item EXE_FILES
1239
1240 Ref to array of executable files. The files will be copied to the
1241 INST_EXE directory. Make realclean will delete them from there
1242 again.
1243
1244 =item FIRST_MAKEFILE
1245
1246 The name of the Makefile to be produced. Defaults to the contents of
1247 MAKEFILE, but can be overridden. This is used for the second Makefile
1248 that will be produced for the MAP_TARGET.
1249
1250 =item FULLPERL
1251
1252 Perl binary able to run this extension.
1253
1254 =item H
1255
1256 Ref to array of *.h file names. Similar to C.
1257
1258 =item INC
1259
1260 Include file dirs eg: C<"-I/usr/5include -I/path/to/inc">
1261
1262 =item INSTALLARCHLIB
1263
1264 Used by 'make install', which copies files from INST_ARCHLIB to this
1265 directory if INSTALLDIRS is set to perl.
1266
1267 =item INSTALLBIN
1268
1269 Used by 'make install' which copies files from INST_EXE to this
1270 directory.
1271
1272 =item INSTALLDIRS
1273
1274 Determines which of the two sets of installation directories to
1275 choose: installprivlib and installarchlib versus installsitelib and
1276 installsitearch. The first pair is chosen with INSTALLDIRS=perl, the
1277 second with INSTALLDIRS=site. Default is site.
1278
1279 =item INSTALLMAN1DIR
1280
1281 This directory gets the man pages at 'make install' time. Defaults to
1282 $Config{installman1dir}.
1283
1284 =item INSTALLMAN3DIR
1285
1286 This directory gets the man pages at 'make install' time. Defaults to
1287 $Config{installman3dir}.
1288
1289 =item INSTALLPRIVLIB
1290
1291 Used by 'make install', which copies files from INST_LIB to this
1292 directory if INSTALLDIRS is set to perl.
1293
1294 =item INSTALLSITELIB
1295
1296 Used by 'make install', which copies files from INST_LIB to this
1297 directory if INSTALLDIRS is set to site (default).
1298
1299 =item INSTALLSITEARCH
1300
1301 Used by 'make install', which copies files from INST_ARCHLIB to this
1302 directory if INSTALLDIRS is set to site (default).
1303
1304 =item INST_ARCHLIB
1305
1306 Same as INST_LIB for architecture dependent files.
1307
1308 =item INST_EXE
1309
1310 Directory, where executable scripts should be installed during
1311 'make'. Defaults to "./blib/bin", just to have a dummy location during
1312 testing. make install will copy the files in INST_EXE to INSTALLBIN.
1313
1314 =item INST_LIB
1315
1316 Directory where we put library files of this extension while building
1317 it.
1318
1319 =item INST_MAN1DIR
1320
1321 Directory to hold the man pages at 'make' time
1322
1323 =item INST_MAN3DIR
1324
1325 Directory to hold the man pages at 'make' time
1326
1327 =item LDFROM
1328
1329 defaults to "$(OBJECT)" and is used in the ld command to specify
1330 what files to link/load from (also see dynamic_lib below for how to
1331 specify ld flags)
1332
1333 =item LIBPERL_A
1334
1335 The filename of the perllibrary that will be used together with this
1336 extension. Defaults to libperl.a.
1337
1338 =item LIBS
1339
1340 An anonymous array of alternative library
1341 specifications to be searched for (in order) until
1342 at least one library is found. E.g.
1343
1344   'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
1345
1346 Mind, that any element of the array
1347 contains a complete set of arguments for the ld
1348 command. So do not specify
1349
1350   'LIBS' => ["-ltcl", "-ltk", "-lX11"]
1351
1352 See ODBM_File/Makefile.PL for an example, where an array is needed. If
1353 you specify a scalar as in
1354
1355   'LIBS' => "-ltcl -ltk -lX11"
1356
1357 MakeMaker will turn it into an array with one element.
1358
1359 =item LINKTYPE
1360
1361 'static' or 'dynamic' (default unless usedl=undef in
1362 config.sh). Should only be used to force static linking (also see
1363 linkext below).
1364
1365 =item MAKEAPERL
1366
1367 Boolean which tells MakeMaker, that it should include the rules to
1368 make a perl. This is handled automatically as a switch by
1369 MakeMaker. The user normally does not need it.
1370
1371 =item MAKEFILE
1372
1373 The name of the Makefile to be produced.
1374
1375 =item MAN1PODS
1376
1377 Hashref of pod-containing files. MakeMaker will default this to all
1378 EXE_FILES files that include POD directives. The files listed
1379 here will be converted to man pages and installed as was requested
1380 at Configure time.
1381
1382 =item MAN3PODS
1383
1384 Hashref of .pm and .pod files. MakeMaker will default this to all
1385  .pod and any .pm files that include POD directives. The files listed
1386 here will be converted to man pages and installed as was requested
1387 at Configure time.
1388
1389 =item MAP_TARGET
1390
1391 If it is intended, that a new perl binary be produced, this variable
1392 may hold a name for that binary. Defaults to perl
1393
1394 =item MYEXTLIB
1395
1396 If the extension links to a library that it builds set this to the
1397 name of the library (see SDBM_File)
1398
1399 =item NAME
1400
1401 Perl module name for this extension (DBD::Oracle). This will default
1402 to the directory name but should be explicitly defined in the
1403 Makefile.PL.
1404
1405 =item NEEDS_LINKING
1406
1407 MakeMaker will figure out, if an extension contains linkable code
1408 anywhere down the directory tree, and will set this variable
1409 accordingly, but you can speed it up a very little bit, if you define
1410 this boolean variable yourself.
1411
1412 =item NOECHO
1413
1414 Defaults the C<@>. By setting it to an empty string you can generate a
1415 Makefile that echos all commands. Mainly used in debugging MakeMaker
1416 itself.
1417
1418 =item NORECURS
1419
1420 Boolean.  Attribute to inhibit descending into subdirectories.
1421
1422 =item OBJECT
1423
1424 List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
1425 string containing all object files, e.g. "tkpBind.o
1426 tkpButton.o tkpCanvas.o"
1427
1428 =item PERL
1429
1430 Perl binary for tasks that can be done by miniperl
1431
1432 =item PERLMAINCC
1433
1434 The call to the program that is able to compile perlmain.c. Defaults
1435 to $(CC).
1436
1437 =item PERL_ARCHLIB
1438
1439 Same as above for architecture dependent files
1440
1441 =item PERL_LIB
1442
1443 Directory containing the Perl library to use.
1444
1445 =item PERL_SRC
1446
1447 Directory containing the Perl source code (use of this should be
1448 avoided, it may be undefined)
1449
1450 =item PL_FILES
1451
1452 Ref to hash of files to be processed as perl programs. MakeMaker
1453 will default to any found *.PL file (except Makefile.PL) being keys
1454 and the basename of the file being the value. E.g.
1455
1456   {'foobar.PL' => 'foobar'}
1457
1458 The *.PL files are expected to produce output to the target files
1459 themselves.
1460
1461 =item PM
1462
1463 Hashref of .pm files and *.pl files to be installed.  e.g.
1464
1465   {'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm'}
1466
1467 By default this will include *.pm and *.pl. If a lib directory
1468 exists and is not listed in DIR (above) then any *.pm and *.pl files
1469 it contains will also be included by default.  Defining PM in the
1470 Makefile.PL will override PMLIBDIRS.
1471
1472 =item PMLIBDIRS
1473
1474 Ref to array of subdirectories containing library files.  Defaults to
1475 [ 'lib', $(BASEEXT) ]. The directories will be scanned and any files
1476 they contain will be installed in the corresponding location in the
1477 library.  A libscan() method can be used to alter the behaviour.
1478 Defining PM in the Makefile.PL will override PMLIBDIRS.
1479
1480 =item PREFIX
1481
1482 Can be used to set the three INSTALL* attributes in one go (except for
1483 probably INSTALLMAN1DIR, if it is not below PREFIX according to
1484 %Config).  They will have PREFIX as a common directory node and will
1485 branch from that node into lib/, lib/ARCHNAME or whatever Configure
1486 decided at the build time of your perl (unless you override one of
1487 them, of course).
1488
1489 =item PREREQ
1490
1491 Placeholder, not yet implemented. Will eventually be a hashref: Names
1492 of modules that need to be available to run this extension (e.g. Fcntl
1493 for SDBM_File) are the keys of the hash and the desired version is the
1494 value. Needs further evaluation, should probably allow to define
1495 prerequisites among header files, libraries, perl version, etc.
1496
1497 =item SKIP
1498
1499 Arryref. E.g. [qw(name1 name2)] skip (do not write) sections of the
1500 Makefile
1501
1502 =item TYPEMAPS
1503
1504 Ref to array of typemap file names.  Use this when the typemaps are
1505 in some directory other than the current directory or when they are
1506 not named B<typemap>.  The last typemap in the list takes
1507 precedence.  A typemap in the current directory has highest
1508 precedence, even if it isn't listed in TYPEMAPS.  The default system
1509 typemap has lowest precedence.
1510
1511 =item VERSION
1512
1513 Your version number for distributing the package.  This defaults to
1514 0.1.
1515
1516 =item VERSION_FROM
1517
1518 Instead of specifying the VERSION in the Makefile.PL you can let
1519 MakeMaker parse a file to determine the version number. The parsing
1520 routine requires that the file named by VERSION_FROM contains one
1521 single line to compute the version number. The first line in the file
1522 that contains the regular expression
1523
1524     /(\$[\w:]*\bVERSION)\b.*=/
1525
1526 will be evaluated with eval() and the value of the named variable
1527 B<after> the eval() will be assigned to the VERSION attribute of the
1528 MakeMaker object. The following lines will be parsed o.k.:
1529
1530     $VERSION = '1.00';
1531     ( $VERSION ) = '$Revision: 1.174 $ ' =~ /\$Revision:\s+([^\s]+)/;
1532     $FOO::VERSION = '1.10';
1533
1534 but these will fail:
1535
1536     my $VERSION = '1.01';
1537     local $VERSION = '1.02';
1538     local $FOO::VERSION = '1.30';
1539
1540 The file named in VERSION_FROM is added as a dependency to Makefile to
1541 guarantee, that the Makefile contains the correct VERSION macro after
1542 a change of the file.
1543
1544 =item XS
1545
1546 Hashref of .xs files. MakeMaker will default this.  e.g.
1547
1548   {'name_of_file.xs' => 'name_of_file.c'}
1549
1550 The .c files will automatically be included in the list of files
1551 deleted by a make clean.
1552
1553 =item XSOPT
1554
1555 String of options to pass to xsubpp.  This might include C<-C++> or
1556 C<-extern>.  Do not include typemaps here; the TYPEMAP parameter exists for
1557 that purpose.
1558
1559 =item XSPROTOARG
1560
1561 May be set to an empty string, which is identical to C<-prototypes>, or
1562 C<-noprototypes>. See the xsubpp documentation for details. MakeMaker
1563 defaults to the empty string.
1564
1565 =item XS_VERSION
1566
1567 Your version number for the .xs file of this package.  This defaults
1568 to the value of the VERSION attribute.
1569
1570 =back
1571
1572 =head2 Additional lowercase attributes
1573
1574 can be used to pass parameters to the methods which implement that
1575 part of the Makefile. These are not normally required:
1576
1577 =over 2
1578
1579 =item clean
1580
1581   {FILES => "*.xyz foo"}
1582
1583 =item depend
1584
1585   {ANY_TARGET => ANY_DEPENDECY, ...}
1586
1587 =item dist
1588
1589   {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => 'gz',
1590   SHAR => 'shar -m', DIST_CP => 'ln'}
1591
1592 If you specify COMPRESS, then SUFFIX should also be altered, as it is
1593 needed to tell make the target file of the compression. Setting
1594 DIST_CP to ln can be useful, if you need to preserve the timestamps on
1595 your files. DIST_CP can take the values 'cp', which copies the file,
1596 'ln', which links the file, and 'best' which copies symbolic links and
1597 links the rest. Default is 'best'.
1598
1599 =item dynamic_lib
1600
1601   {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
1602
1603 =item installpm
1604
1605   {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
1606
1607 =item linkext
1608
1609   {LINKTYPE => 'static', 'dynamic' or ''}
1610
1611 NB: Extensions that have nothing but *.pm files had to say
1612
1613   {LINKTYPE => ''}
1614
1615 with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
1616 can be deleted safely. MakeMaker recognizes, when there's nothing to
1617 be linked.
1618
1619 =item macro
1620
1621   {ANY_MACRO => ANY_VALUE, ...}
1622
1623 =item realclean
1624
1625   {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
1626
1627 =item tool_autosplit
1628
1629   {MAXLEN =E<gt> 8}
1630
1631 =back
1632
1633 =cut
1634
1635 # bug in pod2html, so leave the =back
1636
1637 # Don't delete this cut, MM depends on it!
1638
1639 =head2 Overriding MakeMaker Methods
1640
1641 If you cannot achieve the desired Makefile behaviour by specifying
1642 attributes you may define private subroutines in the Makefile.PL.
1643 Each subroutines returns the text it wishes to have written to
1644 the Makefile. To override a section of the Makefile you can
1645 either say:
1646
1647         sub MY::c_o { "new literal text" }
1648
1649 or you can edit the default by saying something like:
1650
1651         sub MY::c_o {
1652             my $self = shift;
1653             local *c_o;
1654             $_=$self->MM::c_o;
1655             s/old text/new text/;
1656             $_;
1657         }
1658
1659 Both methods above are available for backwards compatibility with
1660 older Makefile.PLs.
1661
1662 If you still need a different solution, try to develop another
1663 subroutine, that fits your needs and submit the diffs to
1664 F<perl5-porters@nicoh.com> or F<comp.lang.perl.misc> as appropriate.
1665
1666 =head2 Distribution Support
1667
1668 For authors of extensions MakeMaker provides several Makefile
1669 targets. Most of the support comes from the ExtUtils::Manifest module,
1670 where additional documentation can be found.
1671
1672 =over 4
1673
1674 =item    make distcheck
1675
1676 reports which files are below the build directory but not in the
1677 MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
1678 details)
1679
1680 =item    make skipcheck
1681
1682 reports which files are skipped due to the entries in the
1683 C<MANIFEST.SKIP> file (See ExtUtils::Manifest::skipcheck() for
1684 details)
1685
1686 =item    make distclean
1687
1688 does a realclean first and then the distcheck. Note that this is not
1689 needed to build a new distribution as long as you are sure, that the
1690 MANIFEST file is ok.
1691
1692 =item    make manifest
1693
1694 rewrites the MANIFEST file, adding all remaining files found (See
1695 ExtUtils::Manifest::mkmanifest() for details)
1696
1697 =item    make distdir
1698
1699 Copies all the files that are in the MANIFEST file to a newly created
1700 directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
1701 exists, it will be removed first.
1702
1703 =item   make disttest
1704
1705 Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and
1706 a make test in that directory.
1707
1708 =item    make tardist
1709
1710 First does a command $(PREOP) which defaults to a null command. Does a
1711 distdir next and runs C<tar> on that directory into a tarfile. Then
1712 deletes the distdir. Finishes with a command $(POSTOP) which defaults
1713 to a null command.
1714
1715 =item    make dist
1716
1717 Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
1718
1719 =item    make uutardist
1720
1721 Runs a tardist first and uuencodes the tarfile.
1722
1723 =item    make shdist
1724
1725 First does a command $(PREOP) which defaults to a null command. Does a
1726 distdir next and runs C<shar> on that directory into a sharfile. Then
1727 deletes the distdir. Finishes with a command $(POSTOP) which defaults
1728 to a null command.  Note: For shdist to work properly a C<shar>
1729 program that can handle directories is mandatory.
1730
1731 =item    make ci
1732
1733 Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
1734
1735 =back
1736
1737 Customization of the dist targets can be done by specifying a hash
1738 reference to the dist attribute of the WriteMakefile call. The
1739 following parameters are recognized:
1740
1741     CI           ('ci -u')
1742     COMPRESS     ('compress')
1743     POSTOP       ('@ :')
1744     PREOP        ('@ :')
1745     RCS_LABEL    ('rcs -q -Nv$(VERSION_SYM):')
1746     SHAR         ('shar')
1747     SUFFIX       ('Z')
1748     TAR          ('tar')
1749     TARFLAGS     ('cvf')
1750
1751 An example:
1752
1753     WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" })
1754
1755
1756 =head1 AUTHORS
1757
1758 Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas
1759 KE<ouml>nig F<E<lt>A.Koenig@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce
1760 F<E<lt>Tim.Bunce@ig.co.ukE<gt>>.  VMS support by Charles Bailey
1761 F<E<lt>bailey@HMIVAX.HUMGEN.UPENN.EDUE<gt>>. OS/2 support by Ilya
1762 Zakharevich F<E<lt>ilya@math.ohio-state.eduE<gt>>. Contact the
1763 makemaker mailing list C<mailto:makemaker@franz.ww.tu-berlin.de>, if
1764 you have any questions.
1765
1766 =head1 MODIFICATION HISTORY
1767
1768 For a more complete documentation see the file Changes in the
1769 MakeMaker distribution package.
1770
1771 =head1 TODO
1772
1773 See the file Todo in the MakeMaker distribution package.
1774
1775 =cut