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