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