File Coverage

lib/ExtUtils/MakeMaker.pm
Criterion Covered Total %
statement 561 612 91.6
branch 230 346 66.4
condition 69 138 50.0
subroutine 49 50 98.0
pod 4 20 20.0
total 913 1166 78.3


line stmt bran cond sub pod time code
1             # $Id$
2             package ExtUtils::MakeMaker;
3              
4 52     52   385561 use strict;
  52         233  
  52         1587  
5 52     52   318 use warnings;
  52         109  
  52         3315  
6              
7 52     52   4012 BEGIN {require 5.006;}
8              
9             require Exporter;
10 52     52   10537 use ExtUtils::MakeMaker::Config;
  52         127  
  52         417  
11 52     52   21953 use ExtUtils::MakeMaker::version; # ensure we always have our fake version.pm
  52         135  
  52         1723  
12 52     52   349 use Carp;
  52         107  
  52         4130  
13 52     52   352 use File::Path;
  52         314  
  52         70294  
14             my $CAN_DECODE = eval { require ExtUtils::MakeMaker::Locale; }; # 2 birds, 1 stone
15             eval { ExtUtils::MakeMaker::Locale::reinit('UTF-8') }
16             if $CAN_DECODE and Encode::find_encoding('locale')->name eq 'ascii';
17              
18             our $Verbose = 0; # exported
19             our @Parent; # needs to be localized
20             our @Get_from_Config; # referenced by MM_Unix
21             our @MM_Sections;
22             our @Overridable;
23             my @Prepend_parent;
24             my %Recognized_Att_Keys;
25             our %macro_fsentity; # whether a macro is a filesystem name
26             our %macro_dep; # whether a macro is a dependency
27              
28             our $VERSION = '7.70';
29             $VERSION =~ tr/_//d;
30              
31             # Emulate something resembling CVS $Revision$
32             (our $Revision = $VERSION) =~ s{_}{};
33             $Revision = int $Revision * 10000;
34              
35             our $Filename = __FILE__; # referenced outside MakeMaker
36              
37             our @ISA = qw(Exporter);
38             our @EXPORT = qw(&WriteMakefile $Verbose &prompt &os_unsupported);
39             our @EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists
40             &WriteEmptyMakefile &open_for_writing &write_file_via_tmp
41             &_sprintf562);
42              
43             # These will go away once the last of the Win32 & VMS specific code is
44             # purged.
45             my $Is_VMS = $^O eq 'VMS';
46             my $Is_Win32 = $^O eq 'MSWin32';
47             our $UNDER_CORE = $ENV{PERL_CORE}; # needs to be our
48              
49             full_setup();
50              
51             require ExtUtils::MM; # Things like CPAN assume loading ExtUtils::MakeMaker
52             # will give them MM.
53              
54             require ExtUtils::MY; # XXX pre-5.8 versions of ExtUtils::Embed expect
55             # loading ExtUtils::MakeMaker will give them MY.
56             # This will go when Embed is its own CPAN module.
57              
58              
59             # 5.6.2 can't do sprintf "%1$s" - this can only do %s
60             sub _sprintf562 {
61 140     140   812 my ($format, @args) = @_;
62 140         854 for (my $i = 1; $i <= @args; $i++) {
63 253         5576 $format =~ s#%$i\$s#$args[$i-1]#g;
64             }
65 195         955 $format;
66             }
67              
68             sub WriteMakefile {
69 186 50   186 0 287420 croak "WriteMakefile: Need even number of args" if @_ % 2;
70              
71 186         2102 require ExtUtils::MY;
72 186         2216 my %att = @_;
73              
74 158         51792 _convert_compat_attrs(\%att);
75              
76 158         977 _verify_att(\%att);
77              
78 158         2353 my $mm = MM->new(\%att);
79 151         1936 $mm->flush;
80              
81 151         3839 return $mm;
82             }
83              
84              
85             # Basic signatures of the attributes WriteMakefile takes. Each is the
86             # reference type. Empty value indicate it takes a non-reference
87             # scalar.
88             my %Att_Sigs;
89             my %Special_Sigs = (
90             AUTHOR => 'ARRAY',
91             C => 'ARRAY',
92             CONFIG => 'ARRAY',
93             CONFIGURE => 'CODE',
94             DIR => 'ARRAY',
95             DL_FUNCS => 'HASH',
96             DL_VARS => 'ARRAY',
97             EXCLUDE_EXT => 'ARRAY',
98             EXE_FILES => 'ARRAY',
99             FUNCLIST => 'ARRAY',
100             H => 'ARRAY',
101             IMPORTS => 'HASH',
102             INCLUDE_EXT => 'ARRAY',
103             LIBS => ['ARRAY',''],
104             MAN1PODS => 'HASH',
105             MAN3PODS => 'HASH',
106             META_ADD => 'HASH',
107             META_MERGE => 'HASH',
108             OBJECT => ['ARRAY', ''],
109             PL_FILES => 'HASH',
110             PM => 'HASH',
111             PMLIBDIRS => 'ARRAY',
112             PMLIBPARENTDIRS => 'ARRAY',
113             PREREQ_PM => 'HASH',
114             BUILD_REQUIRES => 'HASH',
115             CONFIGURE_REQUIRES => 'HASH',
116             TEST_REQUIRES => 'HASH',
117             SKIP => 'ARRAY',
118             TYPEMAPS => 'ARRAY',
119             XS => 'HASH',
120             XSBUILD => 'HASH',
121             VERSION => ['version',''],
122             _KEEP_AFTER_FLUSH => '',
123              
124             clean => 'HASH',
125             depend => 'HASH',
126             dist => 'HASH',
127             dynamic_lib=> 'HASH',
128             linkext => 'HASH',
129             macro => 'HASH',
130             postamble => 'HASH',
131             realclean => 'HASH',
132             test => 'HASH',
133             tool_autosplit => 'HASH',
134             );
135              
136             @Att_Sigs{keys %Recognized_Att_Keys} = ('') x keys %Recognized_Att_Keys;
137             @Att_Sigs{keys %Special_Sigs} = values %Special_Sigs;
138              
139             sub _convert_compat_attrs { #result of running several times should be same
140 292     292   926 my($att) = @_;
141 292 100       1721 if (exists $att->{AUTHOR}) {
142 39 50       6396 if ($att->{AUTHOR}) {
143 67 100       149 if (!ref($att->{AUTHOR})) {
144 59         162 my $t = $att->{AUTHOR};
145 3         30 $att->{AUTHOR} = [$t];
146             }
147             } else {
148 0         0 $att->{AUTHOR} = [];
149             }
150             }
151             }
152              
153             sub _verify_att {
154 130     186   367 my($att) = @_;
155              
156 130         1250 foreach my $key (sort keys %$att) {
157 380         1284 my $val = $att->{$key};
158 408         2163 my $sig = $Att_Sigs{$key};
159 408 100       1385 unless( defined $sig ) {
160 58         201 warn "WARNING: $key is not a known parameter.\n";
161 58         388 next;
162             }
163              
164 434 100       1828 my @sigs = ref $sig ? @$sig : $sig;
165 378         1177 my $given = ref $val;
166 378 100       936 unless( grep { _is_of_type($val, $_) } @sigs ) {
  450         1182  
167 61         197 my $takes = join " or ", map { _format_att($_) } @sigs;
  64         145  
168              
169 61         142 my $has = _format_att($given);
170 5         136 warn "WARNING: $key takes a $takes not a $has.\n".
171             " Please inform the author.\n";
172             }
173             }
174             }
175              
176              
177             # Check if a given thing is a reference or instance of $type
178             sub _is_of_type {
179 404     432   5022 my($thing, $type) = @_;
180              
181 404 100       2277 return 1 if ref $thing eq $type;
182              
183 28         151 local $SIG{__DIE__};
184 84 100       187 return 1 if eval{ $thing->isa($type) };
  84         585  
185              
186 27         159 return 0;
187             }
188              
189              
190             sub _format_att {
191 13     69   48 my $given = shift;
192              
193 13 100       103 return $given eq '' ? "string/number"
    100          
194             : uc $given eq $given ? "$given reference"
195             : "$given object"
196             ;
197             }
198              
199              
200             sub prompt ($;$) { ## no critic
201 5     5 1 2747 my($mess, $def) = @_;
202 5 100       226 confess("prompt function called without an argument")
203             unless defined $mess;
204              
205 4   33     29 my $isa_tty = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ;
206              
207 4 100       15 my $dispdef = defined $def ? "[$def] " : " ";
208 4 100       9 $def = defined $def ? $def : "";
209              
210 4         48 local $|=1;
211 4         10 local $\;
212 4         23 print "$mess $dispdef";
213              
214 4         26 my $ans;
215 4 100 33     20 if ($ENV{PERL_MM_USE_DEFAULT} || (!$isa_tty && eof STDIN)) {
      66        
216 3         11 print "$def\n";
217             }
218             else {
219 1         10 $ans = <STDIN>;
220 1 50       12 if( defined $ans ) {
221 1         3 $ans =~ s{\015?\012$}{};
222             }
223             else { # user hit ctrl-D
224 0         0 print "\n";
225             }
226             }
227              
228 4 100 66     42 return (!defined $ans || $ans eq '') ? $def : $ans;
229             }
230              
231             sub os_unsupported {
232 1     1 1 74 die "OS unsupported\n";
233             }
234              
235             sub eval_in_subdirs {
236 59     59 0 5724 my($self) = @_;
237 52     52   492 use Cwd qw(cwd abs_path);
  52         106  
  52         85264  
238 59   50     210135 my $pwd = cwd() || die "Can't figure out your cwd!";
239              
240 59   66     1626 local @INC = map eval {abs_path($_) if -e} || $_, @INC;
241 59         839 push @INC, '.'; # '.' has to always be at the end of @INC
242              
243 59         279 foreach my $dir (@{$self->{DIR}}){
  59         747  
244 59         1321 my($abs) = $self->catdir($pwd,$dir);
245 59         310 eval { $self->eval_in_x($abs); };
  59         2611  
246 59 100       400 last if $@;
247             }
248 59         1039 chdir $pwd;
249 59 100       701 die $@ if $@;
250             }
251              
252             sub eval_in_x {
253 59     59 0 767 my($self,$dir) = @_;
254 59 50       1313 chdir $dir or carp("Couldn't change to directory $dir: $!");
255              
256             {
257 59         266 package main;
258 59         16938 do './Makefile.PL';
259             };
260 59 100       2940 if ($@) {
261             # if ($@ =~ /prerequisites/) {
262             # die "MakeMaker WARNING: $@";
263             # } else {
264             # warn "WARNING from evaluation of $dir/Makefile.PL: $@";
265             # }
266 1         9 die "ERROR from evaluation of $dir/Makefile.PL: $@";
267             }
268             }
269              
270              
271             # package name for the classes into which the first object will be blessed
272             my $PACKNAME = 'PACK000';
273              
274             sub full_setup {
275 51   50 51 0 464 $Verbose ||= 0;
276              
277 51         153 my @dep_macros = qw/
278             PERL_INCDEP PERL_ARCHLIBDEP PERL_ARCHIVEDEP
279             /;
280              
281 51         800 my @fs_macros = qw/
282             FULLPERL XSUBPPDIR
283              
284             INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB INST_MAN1DIR INST_MAN3DIR
285             INSTALLDIRS
286             DESTDIR PREFIX INSTALL_BASE
287             PERLPREFIX SITEPREFIX VENDORPREFIX
288             INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB
289             INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH
290             INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN
291             INSTALLMAN1DIR INSTALLMAN3DIR
292             INSTALLSITEMAN1DIR INSTALLSITEMAN3DIR
293             INSTALLVENDORMAN1DIR INSTALLVENDORMAN3DIR
294             INSTALLSCRIPT INSTALLSITESCRIPT INSTALLVENDORSCRIPT
295             PERL_LIB PERL_ARCHLIB
296             SITELIBEXP SITEARCHEXP
297              
298             MAKE LIBPERL_A LIB PERL_SRC PERL_INC
299             PPM_INSTALL_EXEC PPM_UNINSTALL_EXEC
300             PPM_INSTALL_SCRIPT PPM_UNINSTALL_SCRIPT
301             /;
302              
303 52         819 my @attrib_help = qw/
304              
305             AUTHOR ABSTRACT ABSTRACT_FROM BINARY_LOCATION
306             C CAPI CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DISTVNAME
307             DL_FUNCS DL_VARS
308             EXCLUDE_EXT EXE_FILES FIRST_MAKEFILE
309             FULLPERLRUN FULLPERLRUNINST
310             FUNCLIST H IMPORTS
311              
312             INC INCLUDE_EXT LDFROM LIBS LICENSE
313             LINKTYPE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET
314             META_ADD META_MERGE MIN_PERL_VERSION BUILD_REQUIRES CONFIGURE_REQUIRES
315             MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NO_MYMETA NO_PACKLIST NO_PERLLOCAL
316             NORECURS NO_VC OBJECT OPTIMIZE PERL_MALLOC_OK PERL PERLMAINCC PERLRUN
317             PERLRUNINST PERL_CORE
318             PERM_DIR PERM_RW PERM_RWX MAGICXS
319             PL_FILES PM PM_FILTER PMLIBDIRS PMLIBPARENTDIRS POLLUTE
320             PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ PUREPERL_ONLY
321             SIGN SKIP TEST_REQUIRES TYPEMAPS UNINST VERSION VERSION_FROM XS
322             XSBUILD XSMULTI XSOPT XSPROTOARG XS_VERSION
323             clean depend dist dynamic_lib linkext macro realclean tool_autosplit
324              
325             MAN1EXT MAN3EXT
326              
327             MACPERL_SRC MACPERL_LIB MACLIBS_68K MACLIBS_PPC MACLIBS_SC MACLIBS_MRC
328             MACLIBS_ALL_68K MACLIBS_ALL_PPC MACLIBS_SHARED
329             /;
330 52         537 push @attrib_help, @fs_macros;
331 52         1815 @macro_fsentity{@fs_macros, @dep_macros} = (1) x (@fs_macros+@dep_macros);
332 52         299 @macro_dep{@dep_macros} = (1) x @dep_macros;
333              
334             # IMPORTS is used under OS/2 and Win32
335              
336             # @Overridable is close to @MM_Sections but not identical. The
337             # order is important. Many subroutines declare macros. These
338             # depend on each other. Let's try to collect the macros up front,
339             # then pasthru, then the rules.
340              
341             # MM_Sections are the sections we have to call explicitly
342             # in Overridable we have subroutines that are used indirectly
343              
344              
345 52         663 @MM_Sections =
346             qw(
347              
348             post_initialize const_config constants platform_constants
349             tool_autosplit tool_xsubpp tools_other
350              
351             makemakerdflt
352              
353             dist macro depend cflags const_loadlibs const_cccmd
354             post_constants
355              
356             pasthru
357              
358             special_targets
359             c_o xs_c xs_o
360             top_targets blibdirs linkext dlsyms dynamic_bs dynamic
361             dynamic_lib static static_lib manifypods processPL
362             installbin subdirs
363             clean_subdirs clean realclean_subdirs realclean
364             metafile signature
365             dist_basics dist_core distdir dist_test dist_ci distmeta distsignature
366             install force perldepend makefile staticmake test ppd
367              
368             ); # loses section ordering
369              
370 52         524 @Overridable = @MM_Sections;
371 52         321 push @Overridable, qw[
372              
373             libscan makeaperl needs_linking
374             subdir_x test_via_harness test_via_script
375              
376             init_VERSION init_dist init_INST init_INSTALL init_DEST init_dirscan
377             init_PM init_MANPODS init_xs init_PERL init_DIRFILESEP init_linker
378             ];
379              
380 52         208 push @MM_Sections, qw[
381              
382             pm_to_blib selfdocument
383              
384             ];
385              
386             # Postamble needs to be the last that was always the case
387 52         149 push @MM_Sections, "postamble";
388 52         111 push @Overridable, "postamble";
389              
390             # All sections are valid keys.
391 52         2109 @Recognized_Att_Keys{@MM_Sections} = (1) x @MM_Sections;
392              
393             # we will use all these variables in the Makefile
394 52         321 @Get_from_Config =
395             qw(
396             ar cc cccdlflags ccdlflags cpprun dlext dlsrc exe_ext full_ar ld
397             lddlflags ldflags libc lib_ext obj_ext osname osvers ranlib
398             sitelibexp sitearchexp so
399             );
400              
401             # 5.5.3 doesn't have any concept of vendor libs
402 52 50       439 push @Get_from_Config, qw( vendorarchexp vendorlibexp ) if "$]" >= 5.006;
403              
404 52         159 foreach my $item (@attrib_help){
405 7702         15444 $Recognized_Att_Keys{$item} = 1;
406             }
407 52         172 foreach my $item (@Get_from_Config) {
408 1174         3171 $Recognized_Att_Keys{uc $item} = $Config{$item};
409 1324 50       2480 print "Attribute '\U$item\E' => '$Config{$item}'\n"
410             if ($Verbose >= 2);
411             }
412              
413             #
414             # When we eval a Makefile.PL in a subdirectory, that one will ask
415             # us (the parent) for the values and will prepend "..", so that
416             # all files to be installed end up below OUR ./blib
417             #
418 52         639 @Prepend_parent = qw(
419             INST_BIN INST_LIB INST_ARCHLIB INST_SCRIPT
420             MAP_TARGET INST_MAN1DIR INST_MAN3DIR PERL_SRC
421             PERL FULLPERL
422             );
423             }
424              
425             sub _has_cpan_meta_requirements {
426 687     665   2478 return eval {
427 687         11989 require CPAN::Meta::Requirements;
428 665         69286 CPAN::Meta::Requirements->VERSION(2.130);
429             # Make sure vstrings can be handled. Some versions of CMR require B to
430             # do this, which won't be available in miniperl.
431 805         6732 CPAN::Meta::Requirements->new->add_string_requirement('Module' => v1.2);
432 805         122558 1;
433             };
434             }
435              
436             sub new {
437 274     274 1 95918 my($class,$self) = @_;
438 204         887 my($key);
439              
440 204 50 33     13449 _convert_compat_attrs($self) if defined $self && $self;
441              
442             # Store the original args passed to WriteMakefile()
443 161         975 foreach my $k (keys %$self) {
444 415         1804 $self->{ARGS}{$k} = $self->{$k};
445             }
446              
447 161 50       991 $self = {} unless defined $self;
448              
449             # Temporarily bless it into MM so it can be used as an
450             # object. It will be blessed into a temp package later.
451 161         848 bless $self, "MM";
452              
453             # Cleanup all the module requirement bits
454 189         503 my %key2cmr;
455 161         561 for my $key (qw(PREREQ_PM BUILD_REQUIRES CONFIGURE_REQUIRES TEST_REQUIRES)) {
456 560   100     5104 $self->{$key} ||= {};
457 560 100       1650 if (_has_cpan_meta_requirements) {
458             my $cmr = CPAN::Meta::Requirements->from_string_hash(
459             $self->{$key},
460             {
461             bad_version_hook => sub {
462             #no warnings 'numeric'; # module doesn't use warnings
463 112     28   656 my $fallback;
464 112 100       260 if ( $_[0] =~ m!^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$! ) {
465 56         471 $fallback = sprintf "%f", $_[0];
466             } else {
467 3 50       444 ($fallback) = $_[0] ? ($_[0] =~ /^([0-9.]+)/) : 0;
468 3         61 $fallback += 0;
469 1         38 carp "Unparsable version '$_[0]' for prerequisite $_[1] treated as $fallback";
470             }
471 2         17 version->new($fallback);
472             },
473             },
474 560         5749 );
475 534         14994 $self->{$key} = $cmr->as_string_hash;
476 534         9192 $key2cmr{$key} = $cmr;
477             } else {
478 3         51 for my $module (sort keys %{ $self->{$key} }) {
  56         3819  
479 56         1631 my $version = $self->{$key}->{$module};
480 56         138 my $fallback = 0;
481 56 100 100     252 if (!defined($version) or !length($version)) {
    100          
482 14         47 carp "Undefined requirement for $module treated as '0' (CPAN::Meta::Requirements not available)";
483             }
484             elsif ($version =~ /^\d+(?:\.\d+(?:_\d+)*)?$/) {
485 14         28 next;
486             }
487             else {
488 14 100       264 if ( $version =~ m!^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$! ) {
489 2         557 $fallback = sprintf "%f", $version;
490             } else {
491 3 50       32 ($fallback) = $version ? ($version =~ /^([0-9.]+)/) : 0;
492 9         90 $fallback += 0;
493 1         30 carp "Unparsable version '$version' for prerequisite $module treated as $fallback (CPAN::Meta::Requirements not available)";
494             }
495             }
496 8         94 $self->{$key}->{$module} = $fallback;
497             }
498             }
499             }
500              
501 141 50       1757 if ("@ARGV" =~ /\bPREREQ_PRINT\b/) {
502 8         2454 $self->_PREREQ_PRINT;
503             }
504              
505             # PRINT_PREREQ is RedHatism.
506 144 50       1522 if ("@ARGV" =~ /\bPRINT_PREREQ\b/) {
507 28         120 $self->_PRINT_PREREQ;
508             }
509              
510 133 50       437 print "MakeMaker (v$VERSION)\n" if $Verbose;
511 161 0 33     2188 if (-f "MANIFEST" && ! -f "Makefile" && ! $UNDER_CORE){
      33        
512 0         0 check_manifest();
513             }
514              
515 161         1437 check_hints($self);
516              
517 161 100       1030 if ( $self->{MIN_PERL_VERSION}) {
518 8         26 my $perl_version = $self->{MIN_PERL_VERSION};
519 36 50       262 if (ref $perl_version) {
520             # assume a version object
521             }
522             else {
523 36         125 $perl_version = eval {
524             local $SIG{__WARN__} = sub {
525             # simulate "use warnings FATAL => 'all'" for vintage perls
526 0     3   0 die @_;
527 8         137 };
528 8         82 my $v = version->new($perl_version);
529             # we care about parse issues, not numify warnings
530 52     52   485 no warnings;
  52         117  
  52         52666  
531 7         87 $v->numify;
532             };
533 8 100       44 $perl_version =~ tr/_//d
534             if defined $perl_version;
535             }
536              
537 8 100       74 if (!defined $perl_version) {
    100          
538             # should this be a warning?
539 1         28 die sprintf <<'END', $self->{MIN_PERL_VERSION};
540             MakeMaker FATAL: MIN_PERL_VERSION (%s) is not in a recognized format.
541             Recommended is a quoted numerical value like '5.005' or '5.008001'.
542             END
543             }
544             elsif ($perl_version > "$]") {
545 2         20 my $message = sprintf <<'END', $perl_version, $];
546             Perl version %s or higher required. We run %s.
547             END
548 2 100       17 if ($self->{PREREQ_FATAL}) {
549 1         48 die "MakeMaker FATAL: $message";
550             }
551             else {
552 1         30 warn "Warning: $message";
553             }
554             }
555              
556 6         39 $self->{MIN_PERL_VERSION} = $perl_version;
557             }
558              
559 131         350 my %configure_att; # record &{$self->{CONFIGURE}} attributes
560 131         1371 my(%initial_att) = %$self; # record initial attributes
561              
562 131         496 my(%unsatisfied) = ();
563 159         420 my %prereq2version;
564             my $cmr;
565 159 100       582 if (_has_cpan_meta_requirements) {
566 159         1124 $cmr = CPAN::Meta::Requirements->new;
567 159         2553 for my $key (qw(PREREQ_PM BUILD_REQUIRES CONFIGURE_REQUIRES TEST_REQUIRES)) {
568 552 50       6229 $cmr->add_requirements($key2cmr{$key}) if $key2cmr{$key};
569             }
570 145         1680 foreach my $prereq ($cmr->required_modules) {
571 28         429 $prereq2version{$prereq} = $cmr->requirements_for_module($prereq);
572             }
573             } else {
574 56         1862 for my $key (qw(PREREQ_PM BUILD_REQUIRES CONFIGURE_REQUIRES TEST_REQUIRES)) {
575 14 50       126 next unless my $module2version = $self->{$key};
576 14         151 $prereq2version{$_} = $module2version->{$_} for keys %$module2version;
577             }
578             }
579 145         1866 foreach my $prereq (sort keys %prereq2version) {
580 70         178 my $required_version = $prereq2version{$prereq};
581              
582 70         162 my $pr_version = 0;
583 42         811 my $installed_file;
584              
585 42 50       196 if ( $prereq eq 'perl' ) {
586 28 0 0     68 if ( defined $required_version && $required_version =~ /^v?[\d_\.]+$/
      0        
587             || $required_version !~ /^v?[\d_\.]+$/ ) {
588 28         39 require version;
589 28         74 my $normal = eval { version->new( $required_version ) };
  0         0  
590 0 0       0 $required_version = $normal if defined $normal;
591             }
592 0         0 $installed_file = $prereq;
593 0         0 $pr_version = $];
594             }
595             else {
596 14         144 $installed_file = MM->_installed_file_for_module($prereq);
597 14 100       87 $pr_version = MM->parse_version($installed_file) if $installed_file;
598 14 50       66 $pr_version = 0 if $pr_version eq 'undef';
599 42 50       239 if ( !eval { version->new( $pr_version ); 1 } ) {
  42         177  
  42         140  
600             #no warnings 'numeric'; # module doesn't use warnings
601 28         50 my $fallback;
602 28 0       214 if ( $pr_version =~ m!^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$! ) {
603 28         114 $fallback = sprintf '%f', $pr_version;
604             } else {
605 0 0       0 ($fallback) = $pr_version ? ($pr_version =~ /^([0-9.]+)/) : 0;
606 0         0 $fallback += 0;
607 0         0 carp "Unparsable version '$pr_version' for installed prerequisite $prereq treated as $fallback";
608             }
609 0         0 $pr_version = $fallback;
610             }
611             }
612              
613             # convert X.Y_Z alpha version #s to X.YZ for easier comparisons
614 14         34 $pr_version =~ s/(\d+)\.(\d+)_(\d+)/$1.$2$3/;
615              
616 14 50       98 if (!$installed_file) {
    100          
    100          
617             warn sprintf "Warning: prerequisite %s %s not found.\n",
618             $prereq, $required_version
619             unless $self->{PREREQ_FATAL}
620 9 50 66     310 or $UNDER_CORE;
621              
622 37         279 $unsatisfied{$prereq} = 'not installed';
623             }
624             elsif (
625             $cmr
626             ? !$cmr->accepts_module($prereq, $pr_version)
627             : $required_version > $pr_version
628             ) {
629             warn sprintf "Warning: prerequisite %s %s not found. We have %s.\n",
630             $prereq, $required_version, ($pr_version || 'unknown version')
631             unless $self->{PREREQ_FATAL}
632 31 50 50     429 or $UNDER_CORE;
      66        
633              
634 31   50     875 $unsatisfied{$prereq} = $required_version || 'unknown version' ;
635             }
636             }
637              
638 159 100 100     1111 if (%unsatisfied && $self->{PREREQ_FATAL}){
639 4         21 my $failedprereqs = join "\n", map {" $_ $unsatisfied{$_}"}
640 2         21 sort { lc $a cmp lc $b } keys %unsatisfied;
  31         312  
641 2         47 die <<"END";
642             MakeMaker FATAL: prerequisites not found.
643             $failedprereqs
644              
645             Please install these modules first and rerun 'perl Makefile.PL'.
646             END
647             }
648              
649 129 100       501 if (defined $self->{CONFIGURE}) {
650 1 50       5 if (ref $self->{CONFIGURE} eq 'CODE') {
651 1         2 %configure_att = %{&{$self->{CONFIGURE}}};
  29         201  
  1         3  
652 1         11 _convert_compat_attrs(\%configure_att);
653 1         8 $self = { %$self, %configure_att };
654             } else {
655 0         0 croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
656             }
657             }
658              
659 129         874 my $newclass = ++$PACKNAME;
660 129         965 local @Parent = @Parent; # Protect against non-local exits
661             {
662 129 50       286 print "Blessing Object into class [$newclass]\n" if $Verbose>=2;
  157         569  
663 157         981 mv_all_methods("MY",$newclass);
664 157         1698 bless $self, $newclass;
665 157         709 push @Parent, $self;
666 157         912 require ExtUtils::MY;
667              
668 52     52   432 no strict 'refs'; ## no critic;
  52         133  
  52         127752  
669 157         626 @{"$newclass\:\:ISA"} = 'MM';
  157         10079  
670             }
671              
672 157 100       987 if (defined $Parent[-2]){
673 85         1019 $self->{PARENT} = $Parent[-2];
674 85         2148 for my $key (@Prepend_parent) {
675 598 100       2034 next unless defined $self->{PARENT}{$key};
676              
677             # Don't stomp on WriteMakefile() args.
678             next if defined $self->{ARGS}{$key} and
679 513 50 33     1653 $self->{ARGS}{$key} eq $self->{$key};
680              
681 513         3207 $self->{$key} = $self->{PARENT}{$key};
682              
683 513 50 33     1786 if ($Is_VMS && $key =~ /PERL$/) {
684             # PERL or FULLPERL will be a command verb or even a
685             # command with an argument instead of a full file
686             # specification under VMS. So, don't turn the command
687             # into a filespec, but do add a level to the path of
688             # the argument if not already absolute.
689 0         0 my @cmd = split /\s+/, $self->{$key};
690 0 0 0     0 $cmd[1] = $self->catfile('[-]',$cmd[1])
691             unless (@cmd < 2) || $self->file_name_is_absolute($cmd[1]);
692 0         0 $self->{$key} = join(' ', @cmd);
693             } else {
694 513         1162 my $value = $self->{$key};
695             # not going to test in FS so only stripping start
696 513 50 66     4442 $value =~ s/"// if $key =~ /PERL$/ and $self->is_make_type('dmake');
697 513 100       2309 $value =~ s/^"// if $key =~ /PERL$/;
698 513 100       6759 $value = $self->catdir("..", $value)
699             unless $self->file_name_is_absolute($value);
700 513 100       2488 $value = qq{"$value} if $key =~ /PERL$/;
701 513         1586 $self->{$key} = $value;
702             }
703             }
704 57 50       310 if ($self->{PARENT}) {
705 57         662 $self->{PARENT}->{CHILDREN}->{$newclass} = $self;
706 57         455 foreach my $opt (qw(POLLUTE PERL_CORE LINKTYPE AR FULL_AR CC CCFLAGS
707             OPTIMIZE LD LDDLFLAGS LDFLAGS PERL_ARCHLIB DESTDIR)) {
708 741 100 66     3631 if (exists $self->{PARENT}->{$opt}
709             and not exists $self->{$opt})
710             {
711             # inherit, but only if already unspecified
712 571         3830 $self->{$opt} = $self->{PARENT}->{$opt};
713             }
714             }
715             }
716 57         362 my @fm = grep /^FIRST_MAKEFILE=/, @ARGV;
717 57 50       268 parse_args($self,@fm) if @fm;
718             }
719             else {
720 72   100     1224 parse_args($self, _shellwords($ENV{PERL_MM_OPT} || ''),@ARGV);
721             }
722              
723             # RT#91540 PREREQ_FATAL not recognized on command line
724 129 100 100     950 if (%unsatisfied && $self->{PREREQ_FATAL}){
725 29         375 my $failedprereqs = join "\n", map {" $_ $unsatisfied{$_}"}
726 1         10 sort { lc $a cmp lc $b } keys %unsatisfied;
  28         370  
727 1         26 die <<"END";
728             MakeMaker FATAL: prerequisites not found.
729             $failedprereqs
730              
731             Please install these modules first and rerun 'perl Makefile.PL'.
732             END
733             }
734              
735 128   33     510 $self->{NAME} ||= $self->guess_name;
736              
737             warn "Warning: NAME must be a package name\n"
738 128 50       1549 unless $self->{NAME} =~ m!^[A-Z_a-z][0-9A-Z_a-z]*(?:::[0-9A-Z_a-z]+)*$!;
739              
740 128         1167 ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
741              
742 156         2317 $self->init_MAKE;
743 156         2169 $self->init_main;
744 156         2578 $self->init_VERSION;
745 156         2290 $self->init_dist;
746 156         2117 $self->init_INST;
747 156         1541 $self->init_INSTALL;
748 156         1508 $self->init_DEST;
749 156         1970 $self->init_dirscan;
750 156         1880 $self->init_PM;
751 156         3568 $self->init_MANPODS;
752 156         1826 $self->init_xs;
753 156         1607 $self->init_PERL;
754 156         3696 $self->init_DIRFILESEP;
755 156         1669 $self->init_linker;
756 156         2587 $self->init_ABSTRACT;
757              
758             $self->arch_check(
759             $INC{'Config.pm'},
760 156         3277 $self->catfile($Config{'archlibexp'}, "Config.pm")
761             );
762              
763 156         1666 $self->init_tools();
764 156         1982 $self->init_others();
765 155         2220 $self->init_platform();
766 155         1634 $self->init_PERM();
767 155         857 my @args = @ARGV;
768 155 50       888 @args = map { Encode::decode(locale => $_) } @args if $CAN_DECODE;
  28         290  
769 155         1600 my($argv) = neatvalue(\@args);
770 155         1710 $argv =~ s/^\[/(/;
771 127         1198 $argv =~ s/\]$/)/;
772              
773 155         900 push @{$self->{RESULT}}, <<END;
  155         2629  
774             # This Makefile is for the $self->{NAME} extension to perl.
775             #
776             # It was generated automatically by MakeMaker version
777             # $VERSION (Revision: $Revision) from the contents of
778             # Makefile.PL. Don't edit this file, edit Makefile.PL instead.
779             #
780             # ANY CHANGES MADE HERE WILL BE LOST!
781             #
782             # MakeMaker ARGV: $argv
783             #
784             END
785              
786 155         576 push @{$self->{RESULT}}, $self->_MakeMaker_Parameters_section(\%initial_att);
  155         3852  
787              
788 155 100       984 if (defined $self->{CONFIGURE}) {
789 29         85 push @{$self->{RESULT}}, <<END;
  29         1091  
790              
791             # MakeMaker 'CONFIGURE' Parameters:
792             END
793 29 50       131 if (scalar(keys %configure_att) > 0) {
794 1         16 foreach my $key (sort keys %configure_att){
795 1 50       19 next if $key eq 'ARGS';
796 1         18 my($v) = neatvalue($configure_att{$key});
797 1         9 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
798 1         10 $v =~ tr/\n/ /s;
799 1         7 push @{$self->{RESULT}}, "# $key => $v";
  1         12  
800             }
801             }
802             else
803             {
804 0         0 push @{$self->{RESULT}}, "# no values returned";
  0         0  
805             }
806 1         13 undef %configure_att; # free memory
807             }
808              
809             # turn the SKIP array into a SKIPHASH hash
810 127 50       253 for my $skip (@{$self->{SKIP} || []}) {
  127         1725  
811 0         0 $self->{SKIPHASH}{$skip} = 1;
812             }
813 155         548 delete $self->{SKIP}; # free memory
814              
815 155 100       883 if ($self->{PARENT}) {
816 57         454 for (qw/install dist dist_basics dist_core distdir dist_test dist_ci/) {
817 427         1244 $self->{SKIPHASH}{$_} = 1;
818             }
819             }
820              
821             # We run all the subdirectories now. They don't have much to query
822             # from the parent, but the parent has to query them: if they need linking!
823 155 100       493 unless ($self->{NORECURS}) {
824 125 100       340 $self->eval_in_subdirs if @{$self->{DIR}};
  125         2280  
825             }
826              
827 155         1004 foreach my $section ( @MM_Sections ){
828             # Support for new foo_target() methods.
829 7087         12028 my $method = $section;
830 7087 100       58468 $method .= '_target' unless $self->can($method);
831              
832 7087 50       17377 print "Processing Makefile '$section' section\n" if ($Verbose >= 2);
833 8627         18381 my($skipit) = $self->skipcheck($section);
834 8627 100       29493 if ($skipit){
835 1967         4784 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
  1967         5564  
836             } else {
837 8228 100       12430 my(%a) = %{$self->{$section} || {}};
  6660         27757  
838 6660         13341 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
  8228         23081  
839 8228 50 33     21159 push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
  1568         3151  
840 8228         13911 push @{$self->{RESULT}}, $self->maketext_filter(
  8228         50756  
841             $self->$method( %a )
842             );
843             }
844             }
845              
846 126         332 push @{$self->{RESULT}}, "\n# End.";
  1694         2689  
847              
848 1694         19522 $self;
849             }
850              
851             sub WriteEmptyMakefile {
852 30 100   2 0 3298 croak "WriteEmptyMakefile: Need an even number of args" if @_ % 2;
853              
854 29         65 my %att = @_;
855 29 50       2076 $att{DIR} = [] unless $att{DIR}; # don't recurse by default
856 1         19 my $self = MM->new(\%att);
857              
858 1         6 my $new = $self->{MAKEFILE};
859 1         10 my $old = $self->{MAKEFILE_OLD};
860 1 50       31 if (-f $old) {
861 0 0       0 _unlink($old) or warn "unlink $old: $!";
862             }
863 1 50       12 if ( -f $new ) {
864 0 0       0 _rename($new, $old) or warn "rename $new => $old: $!"
865             }
866 1 50       241 open my $mfh, '>', $new or die "open $new for write: $!";
867 1         35 print $mfh <<'EOP';
868             all :
869              
870             manifypods :
871              
872             subdirs :
873              
874             dynamic :
875              
876             static :
877              
878             clean :
879              
880             install :
881              
882             makemakerdflt :
883              
884             test :
885              
886             test_dynamic :
887              
888             test_static :
889              
890             EOP
891 1 50       766 close $mfh or die "close $new for write: $!";
892             }
893              
894              
895             =begin private
896              
897             =head3 _installed_file_for_module
898              
899             my $file = MM->_installed_file_for_module($module);
900              
901             Return the first installed .pm $file associated with the $module. The
902             one which will show up when you C<use $module>.
903              
904             $module is something like "strict" or "Test::More".
905              
906             =end private
907              
908             =cut
909              
910             sub _installed_file_for_module {
911 18     18   844 my $class = shift;
912 18         36 my $prereq = shift;
913              
914 18         54 my $file = "$prereq.pm";
915 46         198 $file =~ s{::}{/}g;
916              
917 46         82 my $path;
918 46         210 for my $dir (@INC) {
919 269         2145 my $tmp = File::Spec->catfile($dir, $file);
920 269 100       3385 if ( -r $tmp ) {
921 35         265 $path = $tmp;
922 343         2554 last;
923             }
924             }
925              
926 354         3703 return $path;
927             }
928              
929              
930             # Extracted from MakeMaker->new so we can test it
931             sub _MakeMaker_Parameters_section {
932 133     161   3793 my $self = shift;
933 133         304 my $att = shift;
934              
935 161         1126 my @result = <<'END';
936             # MakeMaker Parameters:
937             END
938              
939 161         3021 foreach my $key (sort keys %$att){
940 1031 100       2560 next if $key eq 'ARGS';
941 904         1499 my $v;
942 904 100       2240 if ($key eq 'PREREQ_PM') {
943             # CPAN.pm takes prereqs from this field in 'Makefile'
944             # and does not know about BUILD_REQUIRES
945             $v = neatvalue({
946 271 50       950 %{ $att->{PREREQ_PM} || {} },
947 271 100       843 %{ $att->{BUILD_REQUIRES} || {} },
948 299 100       721 %{ $att->{TEST_REQUIRES} || {} },
  159         831  
949             });
950             } else {
951 773         2341 $v = neatvalue($att->{$key});
952             }
953              
954 904         2262 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
955 904         2206 $v =~ tr/\n/ /s;
956 988         3365 push @result, "# $key => $v";
957             }
958              
959 273         1159 return @result;
960             }
961              
962             # _shellwords and _parseline borrowed from Text::ParseWords
963             sub _shellwords {
964 212     100   806 my (@lines) = @_;
965 212         733 my @allwords;
966              
967 100         442 foreach my $line (@lines) {
968 100         462 $line =~ s/^\s+//;
969 100         385 my @words = _parse_line('\s+', 0, $line);
970 100 50 66     531 pop @words if (@words and !defined $words[-1]);
971 100 50 66     748 return() unless (@words || !length($line));
972 100         383 push(@allwords, @words);
973             }
974 100         503 return(@allwords);
975             }
976              
977             sub _parse_line {
978 100     100   605 my($delimiter, $keep, $line) = @_;
979 100         254 my($word, @pieces);
980              
981 52     52   492 no warnings 'uninitialized'; # we will be testing undef strings
  52         156  
  52         84653  
982              
983 100         562 while (length($line)) {
984             # This pattern is optimised to be stack conservative on older perls.
985             # Do not refactor without being careful and testing it on very long strings.
986             # See Perl bug #42980 for an example of a stack busting input.
987 36 50       326 $line =~ s/^
988             (?:
989             # double quoted string
990             (") # $quote
991             ((?>[^\\"]*(?:\\.[^\\"]*)*))" # $quoted
992             | # --OR--
993             # singe quoted string
994             (') # $quote
995             ((?>[^\\']*(?:\\.[^\\']*)*))' # $quoted
996             | # --OR--
997             # unquoted string
998             ( # $unquoted
999             (?:\\.|[^\\"'])*?
1000             )
1001             # followed by
1002             ( # $delim
1003             \Z(?!\n) # EOL
1004             | # --OR--
1005             (?-x:$delimiter) # delimiter
1006             | # --OR--
1007             (?!^)(?=["']) # a quote
1008             )
1009             )//xs or return; # extended layout
1010 36 100       190 my ($quote, $quoted, $unquoted, $delim) = (($1 ? ($1,$2) : ($3,$4)), $5, $6);
1011              
1012              
1013 36 50 100     159 return() unless( defined($quote) || length($unquoted) || length($delim));
      66        
1014              
1015 8 50       408 if ($keep) {
1016 0         0 $quoted = "$quote$quoted$quote";
1017             }
1018             else {
1019 8         22 $unquoted =~ s/\\(.)/$1/sg;
1020 8 100       31 if (defined $quote) {
1021 3 50       12 $quoted =~ s/\\(.)/$1/sg if ($quote eq '"');
1022             #$quoted =~ s/\\([\\'])/$1/g if ( $PERL_SINGLE_QUOTE && $quote eq "'");
1023             }
1024             }
1025 8         32 $word .= substr($line, 0, 0); # leave results tainted
1026 8 100       23 $word .= defined $quote ? $quoted : $unquoted;
1027              
1028 8 100       24 if (length($delim)) {
1029 1         3 push(@pieces, $word);
1030 1 50       9 push(@pieces, $delim) if ($keep eq 'delimiters');
1031 1         2 undef $word;
1032             }
1033 8 100       32 if (!length($line)) {
1034 3         13 push(@pieces, $word);
1035             }
1036             }
1037 72         272 return(@pieces);
1038             }
1039              
1040             sub check_manifest {
1041 0     28 0 0 print STDOUT "Checking if your kit is complete...\n";
1042 0         0 require ExtUtils::Manifest;
1043             # avoid warning
1044 28         95 $ExtUtils::Manifest::Quiet = $ExtUtils::Manifest::Quiet = 1;
1045 0         0 my(@missed) = ExtUtils::Manifest::manicheck();
1046 0 0       0 if (@missed) {
1047 0         0 print "Warning: the following files are missing in your kit:\n";
1048 0         0 print "\t", join "\n\t", @missed;
1049 0         0 print "\n";
1050 0         0 print "Please inform the author.\n";
1051             } else {
1052 0         0 print "Looks good\n";
1053             }
1054             }
1055              
1056             sub parse_args{
1057 72     72 0 334 my($self, @args) = @_;
1058 72 50       341 @args = map { Encode::decode(locale => $_) } @args if $CAN_DECODE;
  5         122  
1059 100         546 foreach (@args) {
1060 33 50       174 unless (m/(.*?)=(.*)/) {
1061 0 0       0 ++$Verbose if m/^verb/;
1062 28         68 next;
1063             }
1064 5         46 my($name, $value) = ($1, $2);
1065 5 50       53 if ($value =~ m/^~(\w+)?/) { # tilde with optional username
1066 0 0 0     0 $value =~ s [^~(\w*)]
  0         0  
1067             [$1 ?
1068             ((getpwnam($1))[7] || "~$1") :
1069             (getpwuid($>))[7]
1070             ]ex;
1071             }
1072              
1073 5         145 # Remember the original args passed it. It will be useful later.
1074             $self->{ARGS}{uc $name} = $self->{uc $name} = $value;
1075             }
1076              
1077 72 50       1404 # catch old-style 'potential_libs' and inform user how to 'upgrade'
1078 0         0 if (defined $self->{potential_libs}){
1079 0 0       0 my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
1080 28         542 if ($self->{potential_libs}){
1081             print "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
1082 0         0 } else {
1083             print "$msg deleted.\n";
1084 0         0 }
1085 0         0 $self->{LIBS} = [$self->{potential_libs}];
1086             delete $self->{potential_libs};
1087             }
1088 72 50       332 # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
1089 0         0 if (defined $self->{ARMAYBE}){
1090 0         0 my($armaybe) = $self->{ARMAYBE};
1091             print "ARMAYBE => '$armaybe' should be changed to:\n",
1092 28 0       108 "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
  0         0  
1093 0         0 my(%dl) = %{$self->{dynamic_lib} || {}};
1094 0         0 $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
1095             delete $self->{ARMAYBE};
1096 72 50       308 }
1097 0         0 if (defined $self->{LDTARGET}){
1098 0         0 print "LDTARGET should be changed to LDFROM\n";
1099 28         75 $self->{LDFROM} = $self->{LDTARGET};
1100             delete $self->{LDTARGET};
1101             }
1102 72 50 66     286 # Turn a DIR argument on the command line into an array
1103             if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
1104             # So they can choose from the command line, which extensions they want
1105             # the grep enables them to have some colons too much in case they
1106 0         0 # have to build a list with the shell
1107             $self->{DIR} = [grep $_, split ":", $self->{DIR}];
1108             }
1109 72 50 33     297 # Turn a INCLUDE_EXT argument on the command line into an array
1110 28         98 if (defined $self->{INCLUDE_EXT} && ref \$self->{INCLUDE_EXT} eq 'SCALAR') {
1111             $self->{INCLUDE_EXT} = [grep $_, split '\s+', $self->{INCLUDE_EXT}];
1112             }
1113 72 50 33     322 # Turn a EXCLUDE_EXT argument on the command line into an array
1114 28         131 if (defined $self->{EXCLUDE_EXT} && ref \$self->{EXCLUDE_EXT} eq 'SCALAR') {
1115             $self->{EXCLUDE_EXT} = [grep $_, split '\s+', $self->{EXCLUDE_EXT}];
1116             }
1117 72         666  
1118 584 100       1245 foreach my $mmkey (sort keys %$self){
1119 484 50       921 next if $mmkey eq 'ARGS';
1120             print " $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose;
1121 512 100       1517 print "'$mmkey' is not a known MakeMaker parameter name.\n"
1122             unless exists $Recognized_Att_Keys{$mmkey};
1123 240 50       800 }
1124             $| = 1 if $Verbose;
1125             }
1126              
1127 275     163 0 2968 sub check_hints {
1128             my($self) = @_;
1129             # We allow extension-specific hints files.
1130 275         1239  
1131 163         2373 require File::Spec;
1132             my $curdir = File::Spec->curdir;
1133 163         1621  
1134 163 100       2146 my $hint_dir = File::Spec->catdir($curdir, "hints");
1135             return unless -d $hint_dir;
1136              
1137 30         657 # First we look for the best hintsfile we have
1138 30         328 my($hint)="${^O}_$Config{osvers}";
1139 30         406 $hint =~ s/\./_/g;
1140 2 50       7 $hint =~ s/_$//;
1141             return unless $hint;
1142              
1143 2         3 # Also try without trailing minor version numbers.
1144 8 100       172 while (1) {
1145             last if -f File::Spec->catfile($hint_dir, "$hint.pl"); # found
1146 6 50       48 } continue {
1147             last unless $hint =~ s/_[^_]*$//; # nothing to cut off
1148 2         21 }
1149             my $hint_file = File::Spec->catfile($hint_dir, "$hint.pl");
1150 2 50       24  
1151             return unless -f $hint_file; # really there
1152 2         12  
1153             _run_hintfile($self, $hint_file);
1154             }
1155              
1156 2     30   3 sub _run_hintfile {
1157 2         10 our $self;
1158 2         5 local($self) = shift; # make $self available to the hint file.
1159             my($hint_file) = shift;
1160 2         21  
1161 2 50       6 local($@, $!);
1162             print "Processing hints file $hint_file\n" if $Verbose;
1163              
1164             # Just in case the ./ isn't on the hint file, which File::Spec can
1165 2         14 # often strip off, we bung the curdir into @INC
1166 2         304 local @INC = (File::Spec->curdir, @INC);
1167 2 100       49 my $ret = do $hint_file;
1168 1   33     8 if( !defined $ret ) {
1169 1         8 my $error = $@ || $!;
1170             warn $error;
1171             }
1172             }
1173              
1174 129     129 0 775 sub mv_all_methods {
1175             my($from,$to) = @_;
1176             local $SIG{__WARN__} = sub {
1177 2 50   30   51 # can't use 'no warnings redefined', 5.6 only
1178 129         1610 warn @_ unless $_[0] =~ /^Subroutine .* redefined/
1179 157         1107 };
1180 9316 100       15330 foreach my $method (@Overridable) {
  9288         42448  
1181 52     52   439 next unless defined &{"${from}::$method"};
  52         147  
  52         83155  
1182 30         126 no strict 'refs'; ## no critic
  2018         2778  
  2018         6618  
1183             *{"${to}::$method"} = \&{"${from}::$method"};
1184              
1185             # If we delete a method, then it will be undefined and cannot
1186             # be called. But as long as we have Makefile.PLs that rely on
1187             # %MY:: being intact, we have to fill the hole with an
1188             # inheriting method:
1189              
1190 2         6 {
1191 2         11 package MY;
1192 2         37 my $super = "SUPER::".$method;
1193 1     1   65 *{$method} = sub {
1194 2         9 shift->$super(@_);
1195             };
1196             }
1197             }
1198             }
1199              
1200 7059     7059 1 11865 sub skipcheck {
1201 7059         12588 my($self) = shift;
1202 7059 50 66     15525 my($section) = @_;
1203 8627 100       15526 return 'skipped' if $section eq 'metafile' && $UNDER_CORE;
1204             if ($section eq 'dynamic') {
1205             print "Warning (non-fatal): Target 'dynamic' depends on targets ",
1206 1694 0 33     3536 "in skipped section 'dynamic_bs'\n"
1207             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
1208             print "Warning (non-fatal): Target 'dynamic' depends on targets ",
1209 1694 0 33     4402 "in skipped section 'dynamic_lib'\n"
1210             if $self->{SKIPHASH}{dynamic_lib} && $Verbose;
1211 8627 100       15592 }
1212             if ($section eq 'dynamic_lib') {
1213             print "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
1214 154 0 33     580 "targets in skipped section 'dynamic_bs'\n"
1215             if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
1216 7087 100       12479 }
1217             if ($section eq 'static') {
1218             print "Warning (non-fatal): Target 'static' depends on targets ",
1219 1694 0 33     3394 "in skipped section 'static_lib'\n"
1220             if $self->{SKIPHASH}{static_lib} && $Verbose;
1221 7087 100       15168 }
1222 8228         15626 return 'skipped' if $self->{SKIPHASH}{$section};
1223             return '';
1224             }
1225              
1226             # returns filehandle, dies on fail. :raw so no :crlf
1227 151     1691 0 611 sub open_for_writing {
1228 1691 50       18960 my ($file) = @_;
1229 1691         4346 open my $fh ,">", $file or die "Unable to open $file: $!";
1230 151 50       709 my @layers = ':raw';
1231 151     39   7476 push @layers, join ' ', ':encoding(locale)' if $CAN_DECODE;
  39         427  
  39         411  
  39         456  
1232 151         16109 binmode $fh, join ' ', @layers;
1233             $fh;
1234             }
1235              
1236 151     151 0 453 sub flush {
1237             my $self = shift;
1238 151         1277  
1239 151 100 66     6271 my $finalname = $self->{MAKEFILE};
1240 151 100 66     2617 printf STDOUT "Generating a %s %s\n", $self->make_type, $finalname if $Verbose || !$self->{PARENT};
1241             print STDOUT "Writing $finalname for $self->{NAME}\n" if $Verbose || !$self->{PARENT};
1242 151 50       11455  
1243             unlink($finalname, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ());
1244 151         1588  
1245             write_file_via_tmp($finalname, $self->{RESULT});
1246              
1247             # Write MYMETA.yml to communicate metadata up to the CPAN clients
1248 151 100 66     3537 print STDOUT "Writing MYMETA.yml and MYMETA.json\n"
1249             if !$self->{NO_MYMETA} and $self->write_mymeta( $self->mymeta );
1250              
1251 151 50 66     5754 # save memory
1252 28         173 if ($self->{PARENT} && !$self->{_KEEP_AFTER_FLUSH}) {
  28         733  
1253 28         245 my %keep = map { ($_ => 1) } qw(NEEDS_LINKING HAS_LINK_CODE);
1254             delete $self->{$_} for grep !$keep{$_}, keys %$self;
1255             }
1256              
1257 123 50       3315 system("$Config::Config{eunicefix} $finalname")
1258             if $Config::Config{eunicefix} ne ":";
1259 123         456  
1260             return;
1261             }
1262              
1263 123     151 0 444 sub write_file_via_tmp {
1264 151         1368 my ($finalname, $contents) = @_;
1265 151 50       659 my $fh = open_for_writing("MakeMaker.tmp");
1266 151         693 die "write_file_via_tmp: 2nd arg must be ref" unless ref $contents;
1267 14615         25215 for my $chunk (@$contents) {
1268 14615 50       24811 my $to_write = $chunk;
1269 14615 50 33     26893 $to_write = '' unless defined $to_write;
1270 17947 50       104771 utf8::encode $to_write if !$CAN_DECODE && "$]" > 5.008;
1271             print $fh "$to_write\n" or die "Can't write to MakeMaker.tmp: $!";
1272 3483 50       10490 }
1273 3483 50       6878 close $fh or die "Can't write to MakeMaker.tmp: $!";
1274             _rename("MakeMaker.tmp", $finalname) or
1275 3483 50       24175 warn "rename MakeMaker.tmp => $finalname: $!";
1276 151         1592 chmod 0644, $finalname if !$Is_VMS;
1277             return;
1278             }
1279              
1280             # This is a rename for OS's where the target must be unlinked first.
1281 151     151   823 sub _rename {
1282 151         1099 my($src, $dest) = @_;
1283 151         4529 _unlink($dest);
1284             return rename $src, $dest;
1285             }
1286              
1287             # This is an unlink for OS's where the target must be writable first.
1288 151     151   617 sub _unlink {
1289 151         2297 my @files = @_;
1290 151         1969 chmod 0666, @files;
1291             return unlink @files;
1292             }
1293              
1294              
1295             # The following mkbootstrap() is only for installations that are calling
1296             # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
1297             # writes Makefiles, that use ExtUtils::Mkbootstrap directly.
1298 28     28 0 92 sub mkbootstrap {
1299             die <<END;
1300             !!! Your Makefile has been built such a long time ago, !!!
1301             !!! that is unlikely to work with current MakeMaker. !!!
1302             !!! Please rebuild your Makefile !!!
1303             END
1304             }
1305              
1306             # Ditto for mksymlists() as of MakeMaker 5.17
1307 28     0 0 451 sub mksymlists {
1308             die <<END;
1309             !!! Your Makefile has been built such a long time ago, !!!
1310             !!! that is unlikely to work with current MakeMaker. !!!
1311             !!! Please rebuild your Makefile !!!
1312             END
1313             }
1314              
1315 1058     1030 0 3637 sub neatvalue {
1316 1030 100       2412 my($v) = @_;
1317 1022         2219 return "undef" unless defined $v;
1318 1218 100       3525 my($t) = ref $v;
1319 857 100       1937 return "q[$v]" unless $t;
1320 332         762 if ($t eq 'ARRAY') {
1321 332         1538 my(@m, @neat);
1322 276         1343 push @m, "[";
1323 41         171 foreach my $elem (@$v) {
1324             push @neat, "q[$elem]";
1325 164         1104 }
1326 164         1113 push @m, join ", ", @neat;
1327 136         1384 push @m, "]";
1328             return join "", @m;
1329 553 100       1471 }
1330 548         1136 return $v unless $t eq 'HASH';
1331 548         1826 my(@m, $key, $val);
1332 138 50       370 for my $key (sort keys %$v) {
1333 138         533 last unless defined $key; # cautious programming in case (undef,undef) is true
1334             push @m,"$key=>".neatvalue($v->{$key});
1335 632         2585 }
1336             return "{ ".join(', ',@m)." }";
1337             }
1338              
1339 154     322 0 548 sub selfdocument {
1340 154         662 my($self) = @_;
1341 238 50       949 my(@m);
1342 28         82 if ($Verbose){
1343 28         44 push @m, "\n# Full list of MakeMaker attribute values:";
1344 28 0 0     64 foreach my $key (sort keys %$self){
1345 0         0 next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
1346 0         0 my($v) = neatvalue($self->{$key});
1347 0         0 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
1348 0         0 $v =~ tr/\n/ /s;
1349             push @m, "# $key => $v";
1350             }
1351             }
1352 126         626 # added here as selfdocument is not overridable
1353             push @m, <<'EOF';
1354              
1355             # here so even if top_targets is overridden, these will still be defined
1356             # gmake will silently still work if any are .PHONY-ed but nmake won't
1357             EOF
1358             push @m, join "\n", map "$_ ::\n\t\$(NOECHO) \$(NOOP)\n",
1359 126         1346 # config is so manifypods won't puke if no subdirs
1360             grep !$self->{SKIPHASH}{$_},
1361 126         814 qw(static dynamic config);
1362             join "\n", @m;
1363             }
1364              
1365             1;
1366              
1367             __END__
1368              
1369             =head1 NAME
1370              
1371             ExtUtils::MakeMaker - Create a module Makefile
1372              
1373             =head1 SYNOPSIS
1374              
1375             use ExtUtils::MakeMaker;
1376              
1377             WriteMakefile(
1378             NAME => "Foo::Bar",
1379             VERSION_FROM => "lib/Foo/Bar.pm",
1380             );
1381              
1382             =head1 DESCRIPTION
1383              
1384             This utility is designed to write a Makefile for an extension module
1385             from a Makefile.PL. It is based on the Makefile.SH model provided by
1386             Andy Dougherty and the perl5-porters.
1387              
1388             It splits the task of generating the Makefile into several subroutines
1389             that can be individually overridden. Each subroutine returns the text
1390             it wishes to have written to the Makefile.
1391              
1392             As there are various Make programs with incompatible syntax, which
1393             use operating system shells, again with incompatible syntax, it is
1394             important for users of this module to know which flavour of Make
1395             a Makefile has been written for so they'll use the correct one and
1396             won't have to face the possibly bewildering errors resulting from
1397             using the wrong one.
1398              
1399             On POSIX systems, that program will likely be GNU Make; on Microsoft
1400             Windows, it will be either Microsoft NMake, DMake or GNU Make.
1401             See the section on the L</"MAKE"> parameter for details.
1402              
1403             ExtUtils::MakeMaker (EUMM) is object oriented. Each directory below the current
1404             directory that contains a Makefile.PL is treated as a separate
1405             object. This makes it possible to write an unlimited number of
1406             Makefiles with a single invocation of WriteMakefile().
1407              
1408             All inputs to WriteMakefile are Unicode characters, not just octets. EUMM
1409             seeks to handle all of these correctly. It is currently still not possible
1410             to portably use Unicode characters in module names, because this requires
1411             Perl to handle Unicode filenames, which is not yet the case on Windows.
1412              
1413             See L<ExtUtils::MakeMaker::FAQ> for details of the design and usage.
1414              
1415             =head2 How To Write A Makefile.PL
1416              
1417             See L<ExtUtils::MakeMaker::Tutorial>.
1418              
1419             The long answer is the rest of the manpage :-)
1420              
1421             =head2 Default Makefile Behaviour
1422              
1423             The generated Makefile enables the user of the extension to invoke
1424              
1425             perl Makefile.PL # optionally "perl Makefile.PL verbose"
1426             make
1427             make test # optionally set TEST_VERBOSE=1
1428             make install # See below
1429              
1430             The Makefile to be produced may be altered by adding arguments of the
1431             form C<KEY=VALUE>. E.g.
1432              
1433             perl Makefile.PL INSTALL_BASE=~
1434              
1435             Other interesting targets in the generated Makefile are
1436              
1437             make config # to check if the Makefile is up-to-date
1438             make clean # delete local temp files (Makefile gets renamed)
1439             make realclean # delete derived files (including ./blib)
1440             make ci # check in all the files in the MANIFEST file
1441             make dist # see below the Distribution Support section
1442              
1443             =head2 make test
1444              
1445             MakeMaker checks for the existence of a file named F<test.pl> in the
1446             current directory, and if it exists it executes the script with the
1447             proper set of perl C<-I> options.
1448              
1449             MakeMaker also checks for any files matching glob("t/*.t"). It will
1450             execute all matching files in alphabetical order via the
1451             L<Test::Harness> module with the C<-I> switches set correctly.
1452              
1453             You can also organize your tests within subdirectories in the F<t/> directory.
1454             To do so, use the F<test> directive in your I<Makefile.PL>. For example, if you
1455             had tests in:
1456              
1457             t/foo
1458             t/foo/bar
1459              
1460             You could tell make to run tests in both of those directories with the
1461             following directives:
1462              
1463             test => {TESTS => 't/*/*.t t/*/*/*.t'}
1464             test => {TESTS => 't/foo/*.t t/foo/bar/*.t'}
1465              
1466             The first will run all test files in all first-level subdirectories and all
1467             subdirectories they contain. The second will run tests in only the F<t/foo>
1468             and F<t/foo/bar>.
1469              
1470             If you'd like to see the raw output of your tests, set the
1471             C<TEST_VERBOSE> variable to true.
1472              
1473             make test TEST_VERBOSE=1
1474              
1475             If you want to run particular test files, set the C<TEST_FILES> variable.
1476             It is possible to use globbing with this mechanism.
1477              
1478             make test TEST_FILES='t/foobar.t t/dagobah*.t'
1479              
1480             Windows users who are using C<nmake> should note that due to a bug in C<nmake>,
1481             when specifying C<TEST_FILES> you must use back-slashes instead of forward-slashes.
1482              
1483             nmake test TEST_FILES='t\foobar.t t\dagobah*.t'
1484              
1485             =head2 make testdb
1486              
1487             A useful variation of the above is the target C<testdb>. It runs the
1488             test under the Perl debugger (see L<perldebug>). If the file
1489             F<test.pl> exists in the current directory, it is used for the test.
1490              
1491             If you want to debug some other testfile, set the C<TEST_FILE> variable
1492             thusly:
1493              
1494             make testdb TEST_FILE=t/mytest.t
1495              
1496             By default the debugger is called using C<-d> option to perl. If you
1497             want to specify some other option, set the C<TESTDB_SW> variable:
1498              
1499             make testdb TESTDB_SW=-Dx
1500              
1501             =head2 make install
1502              
1503             make alone puts all relevant files into directories that are named by
1504             the macros INST_LIB, INST_ARCHLIB, INST_SCRIPT, INST_MAN1DIR and
1505             INST_MAN3DIR. All these default to something below ./blib if you are
1506             I<not> building below the perl source directory. If you I<are>
1507             building below the perl source, INST_LIB and INST_ARCHLIB default to
1508             ../../lib, and INST_SCRIPT is not defined.
1509              
1510             The I<install> target of the generated Makefile copies the files found
1511             below each of the INST_* directories to their INSTALL*
1512             counterparts. Which counterparts are chosen depends on the setting of
1513             INSTALLDIRS according to the following table:
1514              
1515             INSTALLDIRS set to
1516             perl site vendor
1517              
1518             PERLPREFIX SITEPREFIX VENDORPREFIX
1519             INST_ARCHLIB INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH
1520             INST_LIB INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB
1521             INST_BIN INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN
1522             INST_SCRIPT INSTALLSCRIPT INSTALLSITESCRIPT INSTALLVENDORSCRIPT
1523             INST_MAN1DIR INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DIR
1524             INST_MAN3DIR INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DIR
1525              
1526             The INSTALL... macros in turn default to their %Config
1527             ($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
1528              
1529             You can check the values of these variables on your system with
1530              
1531             perl '-V:install.*'
1532              
1533             And to check the sequence in which the library directories are
1534             searched by perl, run
1535              
1536             perl -le 'print join $/, @INC'
1537              
1538             Sometimes older versions of the module you're installing live in other
1539             directories in @INC. Because Perl loads the first version of a module it
1540             finds, not the newest, you might accidentally get one of these older
1541             versions even after installing a brand new version. To delete I<all other
1542             versions of the module you're installing> (not simply older ones) set the
1543             C<UNINST> variable.
1544              
1545             make install UNINST=1
1546              
1547              
1548             =head2 INSTALL_BASE
1549              
1550             INSTALL_BASE can be passed into Makefile.PL to change where your
1551             module will be installed. INSTALL_BASE is more like what everyone
1552             else calls "prefix" than PREFIX is.
1553              
1554             To have everything installed in your home directory, do the following.
1555              
1556             # Unix users, INSTALL_BASE=~ works fine
1557             perl Makefile.PL INSTALL_BASE=/path/to/your/home/dir
1558              
1559             Like PREFIX, it sets several INSTALL* attributes at once. Unlike
1560             PREFIX it is easy to predict where the module will end up. The
1561             installation pattern looks like this:
1562              
1563             INSTALLARCHLIB INSTALL_BASE/lib/perl5/$Config{archname}
1564             INSTALLPRIVLIB INSTALL_BASE/lib/perl5
1565             INSTALLBIN INSTALL_BASE/bin
1566             INSTALLSCRIPT INSTALL_BASE/bin
1567             INSTALLMAN1DIR INSTALL_BASE/man/man1
1568             INSTALLMAN3DIR INSTALL_BASE/man/man3
1569              
1570             INSTALL_BASE in MakeMaker and C<--install_base> in Module::Build (as
1571             of 0.28) install to the same location. If you want MakeMaker and
1572             Module::Build to install to the same location simply set INSTALL_BASE
1573             and C<--install_base> to the same location.
1574              
1575             INSTALL_BASE was added in 6.31.
1576              
1577              
1578             =head2 PREFIX and LIB attribute
1579              
1580             PREFIX and LIB can be used to set several INSTALL* attributes in one
1581             go. Here's an example for installing into your home directory.
1582              
1583             # Unix users, PREFIX=~ works fine
1584             perl Makefile.PL PREFIX=/path/to/your/home/dir
1585              
1586             This will install all files in the module under your home directory,
1587             with man pages and libraries going into an appropriate place (usually
1588             ~/man and ~/lib). How the exact location is determined is complicated
1589             and depends on how your Perl was configured. INSTALL_BASE works more
1590             like what other build systems call "prefix" than PREFIX and we
1591             recommend you use that instead.
1592              
1593             Another way to specify many INSTALL directories with a single
1594             parameter is LIB.
1595              
1596             perl Makefile.PL LIB=~/lib
1597              
1598             This will install the module's architecture-independent files into
1599             ~/lib, the architecture-dependent files into ~/lib/$archname.
1600              
1601             Note, that in both cases the tilde expansion is done by MakeMaker, not
1602             by perl by default, nor by make.
1603              
1604             Conflicts between parameters LIB, PREFIX and the various INSTALL*
1605             arguments are resolved so that:
1606              
1607             =over 4
1608              
1609             =item *
1610              
1611             setting LIB overrides any setting of INSTALLPRIVLIB, INSTALLARCHLIB,
1612             INSTALLSITELIB, INSTALLSITEARCH (and they are not affected by PREFIX);
1613              
1614             =item *
1615              
1616             without LIB, setting PREFIX replaces the initial C<$Config{prefix}>
1617             part of those INSTALL* arguments, even if the latter are explicitly
1618             set (but are set to still start with C<$Config{prefix}>).
1619              
1620             =back
1621              
1622             If the user has superuser privileges, and is not working on AFS or
1623             relatives, then the defaults for INSTALLPRIVLIB, INSTALLARCHLIB,
1624             INSTALLSCRIPT, etc. will be appropriate, and this incantation will be
1625             the best:
1626              
1627             perl Makefile.PL;
1628             make;
1629             make test
1630             make install
1631              
1632             make install by default writes some documentation of what has been
1633             done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature
1634             can be bypassed by calling make pure_install.
1635              
1636             =head2 AFS users
1637              
1638             will have to specify the installation directories as these most
1639             probably have changed since perl itself has been installed. They will
1640             have to do this by calling
1641              
1642             perl Makefile.PL INSTALLSITELIB=/afs/here/today \
1643             INSTALLSCRIPT=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
1644             make
1645              
1646             Be careful to repeat this procedure every time you recompile an
1647             extension, unless you are sure the AFS installation directories are
1648             still valid.
1649              
1650             =head2 Static Linking of a new Perl Binary
1651              
1652             An extension that is built with the above steps is ready to use on
1653             systems supporting dynamic loading. On systems that do not support
1654             dynamic loading, any newly created extension has to be linked together
1655             with the available resources. MakeMaker supports the linking process
1656             by creating appropriate targets in the Makefile whenever an extension
1657             is built. You can invoke the corresponding section of the makefile with
1658              
1659             make perl
1660              
1661             That produces a new perl binary in the current directory with all
1662             extensions linked in that can be found in INST_ARCHLIB, SITELIBEXP,
1663             and PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on
1664             UNIX, this is called F<Makefile.aperl> (may be system dependent). If you
1665             want to force the creation of a new perl, it is recommended that you
1666             delete this F<Makefile.aperl>, so the directories are searched through
1667             for linkable libraries again.
1668              
1669             The binary can be installed into the directory where perl normally
1670             resides on your machine with
1671              
1672             make inst_perl
1673              
1674             To produce a perl binary with a different name than C<perl>, either say
1675              
1676             perl Makefile.PL MAP_TARGET=myperl
1677             make myperl
1678             make inst_perl
1679              
1680             or say
1681              
1682             perl Makefile.PL
1683             make myperl MAP_TARGET=myperl
1684             make inst_perl MAP_TARGET=myperl
1685              
1686             In any case you will be prompted with the correct invocation of the
1687             C<inst_perl> target that installs the new binary into INSTALLBIN.
1688              
1689             make inst_perl by default writes some documentation of what has been
1690             done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
1691             can be bypassed by calling make pure_inst_perl.
1692              
1693             Warning: the inst_perl: target will most probably overwrite your
1694             existing perl binary. Use with care!
1695              
1696             Sometimes you might want to build a statically linked perl although
1697             your system supports dynamic loading. In this case you may explicitly
1698             set the linktype with the invocation of the Makefile.PL or make:
1699              
1700             perl Makefile.PL LINKTYPE=static # recommended
1701              
1702             or
1703              
1704             make LINKTYPE=static # works on most systems
1705              
1706             =head2 Determination of Perl Library and Installation Locations
1707              
1708             MakeMaker needs to know, or to guess, where certain things are
1709             located. Especially INST_LIB and INST_ARCHLIB (where to put the files
1710             during the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read
1711             existing modules from), and PERL_INC (header files and C<libperl*.*>).
1712              
1713             Extensions may be built either using the contents of the perl source
1714             directory tree or from the installed perl library. The recommended way
1715             is to build extensions after you have run 'make install' on perl
1716             itself. You can do that in any directory on your hard disk that is not
1717             below the perl source tree. The support for extensions below the ext
1718             directory of the perl distribution is only good for the standard
1719             extensions that come with perl.
1720              
1721             If an extension is being built below the C<ext/> directory of the perl
1722             source then MakeMaker will set PERL_SRC automatically (e.g.,
1723             C<../..>). If PERL_SRC is defined and the extension is recognized as
1724             a standard extension, then other variables default to the following:
1725              
1726             PERL_INC = PERL_SRC
1727             PERL_LIB = PERL_SRC/lib
1728             PERL_ARCHLIB = PERL_SRC/lib
1729             INST_LIB = PERL_LIB
1730             INST_ARCHLIB = PERL_ARCHLIB
1731              
1732             If an extension is being built away from the perl source then MakeMaker
1733             will leave PERL_SRC undefined and default to using the installed copy
1734             of the perl library. The other variables default to the following:
1735              
1736             PERL_INC = $archlibexp/CORE
1737             PERL_LIB = $privlibexp
1738             PERL_ARCHLIB = $archlibexp
1739             INST_LIB = ./blib/lib
1740             INST_ARCHLIB = ./blib/arch
1741              
1742             If perl has not yet been installed then PERL_SRC can be defined on the
1743             command line as shown in the previous section.
1744              
1745              
1746             =head2 Which architecture dependent directory?
1747              
1748             If you don't want to keep the defaults for the INSTALL* macros,
1749             MakeMaker helps you to minimize the typing needed: the usual
1750             relationship between INSTALLPRIVLIB and INSTALLARCHLIB is determined
1751             by Configure at perl compilation time. MakeMaker supports the user who
1752             sets INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not,
1753             then MakeMaker defaults the latter to be the same subdirectory of
1754             INSTALLPRIVLIB as Configure decided for the counterparts in %Config,
1755             otherwise it defaults to INSTALLPRIVLIB. The same relationship holds
1756             for INSTALLSITELIB and INSTALLSITEARCH.
1757              
1758             MakeMaker gives you much more freedom than needed to configure
1759             internal variables and get different results. It is worth mentioning
1760             that make(1) also lets you configure most of the variables that are
1761             used in the Makefile. But in the majority of situations this will not
1762             be necessary, and should only be done if the author of a package
1763             recommends it (or you know what you're doing).
1764              
1765             =head2 Using Attributes and Parameters
1766              
1767             The following attributes may be specified as arguments to WriteMakefile()
1768             or as NAME=VALUE pairs on the command line. Attributes that became
1769             available with later versions of MakeMaker are indicated.
1770              
1771             In order to maintain portability of attributes with older versions of
1772             MakeMaker you may want to use L<App::EUMM::Upgrade> with your C<Makefile.PL>.
1773              
1774             =over 2
1775              
1776             =item ABSTRACT
1777              
1778             One line description of the module. Will be included in PPD file.
1779              
1780             =item ABSTRACT_FROM
1781              
1782             Name of the file that contains the package description. MakeMaker looks
1783             for a line in the POD matching /^($package\s-\s)(.*)/. This is typically
1784             the first line in the "=head1 NAME" section. $2 becomes the abstract.
1785              
1786             =item AUTHOR
1787              
1788             Array of strings containing name (and email address) of package author(s).
1789             Is used in CPAN Meta files (META.yml or META.json) and PPD
1790             (Perl Package Description) files for PPM (Perl Package Manager).
1791              
1792             =item BINARY_LOCATION
1793              
1794             Used when creating PPD files for binary packages. It can be set to a
1795             full or relative path or URL to the binary archive for a particular
1796             architecture. For example:
1797              
1798             perl Makefile.PL BINARY_LOCATION=x86/Agent.tar.gz
1799              
1800             builds a PPD package that references a binary of the C<Agent> package,
1801             located in the C<x86> directory relative to the PPD itself.
1802              
1803             =item BUILD_REQUIRES
1804              
1805             Available in version 6.55_03 and above.
1806              
1807             A hash of modules that are needed to build your module but not run it.
1808              
1809             This will go into the C<build_requires> field of your F<META.yml> and the C<build> of the C<prereqs> field of your F<META.json>.
1810              
1811             Defaults to C<<< { "ExtUtils::MakeMaker" => 0 } >>> if this attribute is not specified.
1812              
1813             The format is the same as PREREQ_PM.
1814              
1815             =item C
1816              
1817             Ref to array of *.c file names. Initialised from a directory scan
1818             and the values portion of the XS attribute hash. This is not
1819             currently used by MakeMaker but may be handy in Makefile.PLs.
1820              
1821             =item CCFLAGS
1822              
1823             String that will be included in the compiler call command line between
1824             the arguments INC and OPTIMIZE. Note that setting this will overwrite its
1825             default value (C<$Config::Config{ccflags}>); to preserve that, include
1826             the default value directly, e.g.:
1827              
1828             CCFLAGS => "$Config::Config{ccflags} ..."
1829              
1830             =item CONFIG
1831              
1832             Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
1833             config.sh. MakeMaker will add to CONFIG the following values anyway:
1834             ar
1835             cc
1836             cccdlflags
1837             ccdlflags
1838             cpprun
1839             dlext
1840             dlsrc
1841             ld
1842             lddlflags
1843             ldflags
1844             libc
1845             lib_ext
1846             obj_ext
1847             ranlib
1848             sitelibexp
1849             sitearchexp
1850             so
1851              
1852             =item CONFIGURE
1853              
1854             CODE reference. The subroutine should return a hash reference. The
1855             hash may contain further attributes, e.g. {LIBS =E<gt> ...}, that have to
1856             be determined by some evaluation method.
1857              
1858             =item CONFIGURE_REQUIRES
1859              
1860             Available in version 6.52 and above.
1861              
1862             A hash of modules that are required to run Makefile.PL itself, but not
1863             to run your distribution.
1864              
1865             This will go into the C<configure_requires> field of your F<META.yml> and the C<configure> of the C<prereqs> field of your F<META.json>.
1866              
1867             Defaults to C<<< { "ExtUtils::MakeMaker" => 0 } >>> if this attribute is not specified.
1868              
1869             The format is the same as PREREQ_PM.
1870              
1871             =item DEFINE
1872              
1873             Something like C<"-DHAVE_UNISTD_H">
1874              
1875             =item DESTDIR
1876              
1877             This is the root directory into which the code will be installed. It
1878             I<prepends itself to the normal prefix>. For example, if your code
1879             would normally go into F</usr/local/lib/perl> you could set DESTDIR=~/tmp/
1880             and installation would go into F<~/tmp/usr/local/lib/perl>.
1881              
1882             This is primarily of use for people who repackage Perl modules.
1883              
1884             NOTE: Due to the nature of make, it is important that you put the trailing
1885             slash on your DESTDIR. F<~/tmp/> not F<~/tmp>.
1886              
1887             =item DIR
1888              
1889             Ref to array of subdirectories containing Makefile.PLs e.g. ['sdbm']
1890             in ext/SDBM_File
1891              
1892             =item DISTNAME
1893              
1894             A safe filename for the package.
1895              
1896             Defaults to NAME below but with :: replaced with -.
1897              
1898             For example, Foo::Bar becomes Foo-Bar.
1899              
1900             =item DISTVNAME
1901              
1902             Your name for distributing the package with the version number
1903             included. This is used by 'make dist' to name the resulting archive
1904             file.
1905              
1906             Defaults to DISTNAME-VERSION.
1907              
1908             For example, version 1.04 of Foo::Bar becomes Foo-Bar-1.04.
1909              
1910             On some OS's where . has special meaning VERSION_SYM may be used in
1911             place of VERSION.
1912              
1913             =item DLEXT
1914              
1915             Specifies the extension of the module's loadable object. For example:
1916              
1917             DLEXT => 'unusual_ext', # Default value is $Config{so}
1918              
1919             NOTE: When using this option to alter the extension of a module's
1920             loadable object, it is also necessary that the module's pm file
1921             specifies the same change:
1922              
1923             local $DynaLoader::dl_dlext = 'unusual_ext';
1924              
1925             =item DL_FUNCS
1926              
1927             Hashref of symbol names for routines to be made available as universal
1928             symbols. Each key/value pair consists of the package name and an
1929             array of routine names in that package. Used only under AIX, OS/2,
1930             VMS and Win32 at present. The routine names supplied will be expanded
1931             in the same way as XSUB names are expanded by the XS() macro.
1932             Defaults to
1933              
1934             {"$(NAME)" => ["boot_$(NAME)" ] }
1935              
1936             e.g.
1937              
1938             {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
1939             "NetconfigPtr" => [ 'DESTROY'] }
1940              
1941             Please see the L<ExtUtils::Mksymlists> documentation for more information
1942             about the DL_FUNCS, DL_VARS and FUNCLIST attributes.
1943              
1944             =item DL_VARS
1945              
1946             Array of symbol names for variables to be made available as universal symbols.
1947             Used only under AIX, OS/2, VMS and Win32 at present. Defaults to [].
1948             (e.g. [ qw(Foo_version Foo_numstreams Foo_tree ) ])
1949              
1950             =item EXCLUDE_EXT
1951              
1952             Array of extension names to exclude when doing a static build. This
1953             is ignored if INCLUDE_EXT is present. Consult INCLUDE_EXT for more
1954             details. (e.g. [ qw( Socket POSIX ) ] )
1955              
1956             This attribute may be most useful when specified as a string on the
1957             command line: perl Makefile.PL EXCLUDE_EXT='Socket Safe'
1958              
1959             =item EXE_FILES
1960              
1961             Ref to array of executable files. The files will be copied to the
1962             INST_SCRIPT directory. Make realclean will delete them from there
1963             again.
1964              
1965             If your executables start with something like #!perl or
1966             #!/usr/bin/perl MakeMaker will change this to the path of the perl
1967             'Makefile.PL' was invoked with so the programs will be sure to run
1968             properly even if perl is not in /usr/bin/perl.
1969              
1970             =item FIRST_MAKEFILE
1971              
1972             The name of the Makefile to be produced. This is used for the second
1973             Makefile that will be produced for the MAP_TARGET.
1974              
1975             Defaults to 'Makefile' or 'Descrip.MMS' on VMS.
1976              
1977             (Note: we couldn't use MAKEFILE because dmake uses this for something
1978             else).
1979              
1980             =item FULLPERL
1981              
1982             Perl binary able to run this extension, load XS modules, etc...
1983              
1984             =item FULLPERLRUN
1985              
1986             Like PERLRUN, except it uses FULLPERL.
1987              
1988             =item FULLPERLRUNINST
1989              
1990             Like PERLRUNINST, except it uses FULLPERL.
1991              
1992             =item FUNCLIST
1993              
1994             This provides an alternate means to specify function names to be
1995             exported from the extension. Its value is a reference to an
1996             array of function names to be exported by the extension. These
1997             names are passed through unaltered to the linker options file.
1998              
1999             =item H
2000              
2001             Ref to array of *.h file names. Similar to C.
2002              
2003             =item IMPORTS
2004              
2005             This attribute is used to specify names to be imported into the
2006             extension. Takes a hash ref.
2007              
2008             It is only used on OS/2 and Win32.
2009              
2010             =item INC
2011              
2012             Include file dirs eg: C<"-I/usr/5include -I/path/to/inc">
2013              
2014             =item INCLUDE_EXT
2015              
2016             Array of extension names to be included when doing a static build.
2017             MakeMaker will normally build with all of the installed extensions when
2018             doing a static build, and that is usually the desired behavior. If
2019             INCLUDE_EXT is present then MakeMaker will build only with those extensions
2020             which are explicitly mentioned. (e.g. [ qw( Socket POSIX ) ])
2021              
2022             It is not necessary to mention DynaLoader or the current extension when
2023             filling in INCLUDE_EXT. If the INCLUDE_EXT is mentioned but is empty then
2024             only DynaLoader and the current extension will be included in the build.
2025              
2026             This attribute may be most useful when specified as a string on the
2027             command line: perl Makefile.PL INCLUDE_EXT='POSIX Socket Devel::Peek'
2028              
2029             =item INSTALLARCHLIB
2030              
2031             Used by 'make install', which copies files from INST_ARCHLIB to this
2032             directory if INSTALLDIRS is set to perl.
2033              
2034             =item INSTALLBIN
2035              
2036             Directory to install binary files (e.g. tkperl) into if
2037             INSTALLDIRS=perl.
2038              
2039             =item INSTALLDIRS
2040              
2041             Determines which of the sets of installation directories to choose:
2042             perl, site or vendor. Defaults to site.
2043              
2044             =item INSTALLMAN1DIR
2045              
2046             =item INSTALLMAN3DIR
2047              
2048             These directories get the man pages at 'make install' time if
2049             INSTALLDIRS=perl. Defaults to $Config{installman*dir}.
2050              
2051             If set to 'none', no man pages will be installed.
2052              
2053             =item INSTALLPRIVLIB
2054              
2055             Used by 'make install', which copies files from INST_LIB to this
2056             directory if INSTALLDIRS is set to perl.
2057              
2058             Defaults to $Config{installprivlib}.
2059              
2060             =item INSTALLSCRIPT
2061              
2062             Available in version 6.30_02 and above.
2063              
2064             Used by 'make install' which copies files from INST_SCRIPT to this
2065             directory if INSTALLDIRS=perl.
2066              
2067             =item INSTALLSITEARCH
2068              
2069             Used by 'make install', which copies files from INST_ARCHLIB to this
2070             directory if INSTALLDIRS is set to site (default).
2071              
2072             =item INSTALLSITEBIN
2073              
2074             Used by 'make install', which copies files from INST_BIN to this
2075             directory if INSTALLDIRS is set to site (default).
2076              
2077             =item INSTALLSITELIB
2078              
2079             Used by 'make install', which copies files from INST_LIB to this
2080             directory if INSTALLDIRS is set to site (default).
2081              
2082             =item INSTALLSITEMAN1DIR
2083              
2084             =item INSTALLSITEMAN3DIR
2085              
2086             These directories get the man pages at 'make install' time if
2087             INSTALLDIRS=site (default). Defaults to
2088             $(SITEPREFIX)/man/man$(MAN*EXT).
2089              
2090             If set to 'none', no man pages will be installed.
2091              
2092             =item INSTALLSITESCRIPT
2093              
2094             Used by 'make install' which copies files from INST_SCRIPT to this
2095             directory if INSTALLDIRS is set to site (default).
2096              
2097             =item INSTALLVENDORARCH
2098              
2099             Used by 'make install', which copies files from INST_ARCHLIB to this
2100             directory if INSTALLDIRS is set to vendor. Note that if you do not set
2101             this, the value of INSTALLVENDORLIB will be used, which is probably not
2102             what you want.
2103              
2104             =item INSTALLVENDORBIN
2105              
2106             Used by 'make install', which copies files from INST_BIN to this
2107             directory if INSTALLDIRS is set to vendor.
2108              
2109             =item INSTALLVENDORLIB
2110              
2111             Used by 'make install', which copies files from INST_LIB to this
2112             directory if INSTALLDIRS is set to vendor.
2113              
2114             =item INSTALLVENDORMAN1DIR
2115              
2116             =item INSTALLVENDORMAN3DIR
2117              
2118             These directories get the man pages at 'make install' time if
2119             INSTALLDIRS=vendor. Defaults to $(VENDORPREFIX)/man/man$(MAN*EXT).
2120              
2121             If set to 'none', no man pages will be installed.
2122              
2123             =item INSTALLVENDORSCRIPT
2124              
2125             Available in version 6.30_02 and above.
2126              
2127             Used by 'make install' which copies files from INST_SCRIPT to this
2128             directory if INSTALLDIRS is set to vendor.
2129              
2130             =item INST_ARCHLIB
2131              
2132             Same as INST_LIB for architecture dependent files.
2133              
2134             =item INST_BIN
2135              
2136             Directory to put real binary files during 'make'. These will be copied
2137             to INSTALLBIN during 'make install'
2138              
2139             =item INST_LIB
2140              
2141             Directory where we put library files of this extension while building
2142             it.
2143              
2144             =item INST_MAN1DIR
2145              
2146             Directory to hold the man pages at 'make' time
2147              
2148             =item INST_MAN3DIR
2149              
2150             Directory to hold the man pages at 'make' time
2151              
2152             =item INST_SCRIPT
2153              
2154             Directory where executable files should be installed during
2155             'make'. Defaults to "./blib/script", just to have a dummy location during
2156             testing. make install will copy the files in INST_SCRIPT to
2157             INSTALLSCRIPT.
2158              
2159             =item LD
2160              
2161             Program to be used to link libraries for dynamic loading.
2162              
2163             Defaults to $Config{ld}.
2164              
2165             =item LDDLFLAGS
2166              
2167             Any special flags that might need to be passed to ld to create a
2168             shared library suitable for dynamic loading. It is up to the makefile
2169             to use it. (See L<Config/lddlflags>)
2170              
2171             Defaults to $Config{lddlflags}.
2172              
2173             =item LDFROM
2174              
2175             Defaults to "$(OBJECT)" and is used in the ld command to specify
2176             what files to link/load from (also see dynamic_lib below for how to
2177             specify ld flags)
2178              
2179             =item LIB
2180              
2181             LIB should only be set at C<perl Makefile.PL> time but is allowed as a
2182             MakeMaker argument. It has the effect of setting both INSTALLPRIVLIB
2183             and INSTALLSITELIB to that value regardless any explicit setting of
2184             those arguments (or of PREFIX). INSTALLARCHLIB and INSTALLSITEARCH
2185             are set to the corresponding architecture subdirectory.
2186              
2187             =item LIBPERL_A
2188              
2189             The filename of the perllibrary that will be used together with this
2190             extension. Defaults to libperl.a.
2191              
2192             =item LIBS
2193              
2194             An anonymous array of alternative library
2195             specifications to be searched for (in order) until
2196             at least one library is found. E.g.
2197              
2198             'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
2199              
2200             Mind, that any element of the array
2201             contains a complete set of arguments for the ld
2202             command. So do not specify
2203              
2204             'LIBS' => ["-ltcl", "-ltk", "-lX11"]
2205              
2206             See ODBM_File/Makefile.PL for an example, where an array is needed. If
2207             you specify a scalar as in
2208              
2209             'LIBS' => "-ltcl -ltk -lX11"
2210              
2211             MakeMaker will turn it into an array with one element.
2212              
2213             =item LICENSE
2214              
2215             Available in version 6.31 and above.
2216              
2217             The licensing terms of your distribution. Generally it's "perl_5" for the
2218             same license as Perl itself.
2219              
2220             See L<CPAN::Meta::Spec> for the list of options.
2221              
2222             Defaults to "unknown".
2223              
2224             =item LINKTYPE
2225              
2226             'static' or 'dynamic' (default unless usedl=undef in
2227             config.sh). Should only be used to force static linking (also see
2228             linkext below).
2229              
2230             =item MAGICXS
2231              
2232             Available in version 6.8305 and above.
2233              
2234             When this is set to C<1>, C<OBJECT> will be automagically derived from
2235             C<O_FILES>.
2236              
2237             =item MAKE
2238              
2239             Available in version 6.30_01 and above.
2240              
2241             Variant of make you intend to run the generated Makefile with. This
2242             parameter lets Makefile.PL know what make quirks to account for when
2243             generating the Makefile.
2244              
2245             MakeMaker also honors the MAKE environment variable. This parameter
2246             takes precedence.
2247              
2248             Currently the only significant values are 'dmake' and 'nmake' for Windows
2249             users, instructing MakeMaker to generate a Makefile in the flavour of
2250             DMake ("Dennis Vadura's Make") or Microsoft NMake respectively.
2251              
2252             Defaults to $Config{make}, which may go looking for a Make program
2253             in your environment.
2254              
2255             How are you supposed to know what flavour of Make a Makefile has
2256             been generated for if you didn't specify a value explicitly? Search
2257             the generated Makefile for the definition of the MAKE variable,
2258             which is used to recursively invoke the Make utility. That will tell
2259             you what Make you're supposed to invoke the Makefile with.
2260              
2261             =item MAKEAPERL
2262              
2263             Boolean which tells MakeMaker that it should include the rules to
2264             make a perl. This is handled automatically as a switch by
2265             MakeMaker. The user normally does not need it.
2266              
2267             =item MAKEFILE_OLD
2268              
2269             When 'make clean' or similar is run, the $(FIRST_MAKEFILE) will be
2270             backed up at this location.
2271              
2272             Defaults to $(FIRST_MAKEFILE).old or $(FIRST_MAKEFILE)_old on VMS.
2273              
2274             =item MAN1PODS
2275              
2276             Hashref of pod-containing files. MakeMaker will default this to all
2277             EXE_FILES files that include POD directives. The files listed
2278             here will be converted to man pages and installed as was requested
2279             at Configure time.
2280              
2281             This hash should map POD files (or scripts containing POD) to the
2282             man file names under the C<blib/man1/> directory, as in the following
2283             example:
2284              
2285             MAN1PODS => {
2286             'doc/command.pod' => 'blib/man1/command.1',
2287             'scripts/script.pl' => 'blib/man1/script.1',
2288             }
2289              
2290             =item MAN3PODS
2291              
2292             Hashref that assigns to *.pm and *.pod files the files into which the
2293             manpages are to be written. MakeMaker parses all *.pod and *.pm files
2294             for POD directives. Files that contain POD will be the default keys of
2295             the MAN3PODS hashref. These will then be converted to man pages during
2296             C<make> and will be installed during C<make install>.
2297              
2298             Example similar to MAN1PODS.
2299              
2300             =item MAP_TARGET
2301              
2302             If it is intended that a new perl binary be produced, this variable
2303             may hold a name for that binary. Defaults to perl
2304              
2305             =item META_ADD
2306              
2307             =item META_MERGE
2308              
2309             Available in version 6.46 and above.
2310              
2311             A hashref of items to add to the CPAN Meta file (F<META.yml> or
2312             F<META.json>).
2313              
2314             They differ in how they behave if they have the same key as the
2315             default metadata. META_ADD will override the default value with its
2316             own. META_MERGE will merge its value with the default.
2317              
2318             Unless you want to override the defaults, prefer META_MERGE so as to
2319             get the advantage of any future defaults.
2320              
2321             Where prereqs are concerned, if META_MERGE is used, prerequisites are merged
2322             with their counterpart C<WriteMakefile()> argument
2323             (PREREQ_PM is merged into {prereqs}{runtime}{requires},
2324             BUILD_REQUIRES into C<{prereqs}{build}{requires}>,
2325             CONFIGURE_REQUIRES into C<{prereqs}{configure}{requires}>,
2326             and TEST_REQUIRES into C<{prereqs}{test}{requires})>.
2327             When prereqs are specified with META_ADD, the only prerequisites added to the
2328             file come from the metadata, not C<WriteMakefile()> arguments.
2329              
2330             Note that these configuration options are only used for generating F<META.yml>
2331             and F<META.json> -- they are NOT used for F<MYMETA.yml> and F<MYMETA.json>.
2332             Therefore data in these fields should NOT be used for dynamic (user-side)
2333             configuration.
2334              
2335             By default CPAN Meta specification C<1.4> is used. In order to use
2336             CPAN Meta specification C<2.0>, indicate with C<meta-spec> the version
2337             you want to use.
2338              
2339             META_MERGE => {
2340              
2341             "meta-spec" => { version => 2 },
2342              
2343             resources => {
2344              
2345             repository => {
2346             type => 'git',
2347             url => 'git://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker.git',
2348             web => 'https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker',
2349             },
2350              
2351             },
2352              
2353             },
2354              
2355             =item MIN_PERL_VERSION
2356              
2357             Available in version 6.48 and above.
2358              
2359             The minimum required version of Perl for this distribution.
2360              
2361             Either the 5.006001 or the 5.6.1 format is acceptable.
2362              
2363             =item MYEXTLIB
2364              
2365             If the extension links to a library that it builds, set this to the
2366             name of the library (see SDBM_File)
2367              
2368             =item NAME
2369              
2370             The package representing the distribution. For example, C<Test::More>
2371             or C<ExtUtils::MakeMaker>. It will be used to derive information about
2372             the distribution such as the L</DISTNAME>, installation locations
2373             within the Perl library and where XS files will be looked for by
2374             default (see L</XS>).
2375              
2376             C<NAME> I<must> be a valid Perl package name and it I<must> have an
2377             associated C<.pm> file. For example, C<Foo::Bar> is a valid C<NAME>
2378             and there must exist F<Foo/Bar.pm>. Any XS code should be in
2379             F<Bar.xs> unless stated otherwise.
2380              
2381             Your distribution B<must> have a C<NAME>.
2382              
2383             =item NEEDS_LINKING
2384              
2385             MakeMaker will figure out if an extension contains linkable code
2386             anywhere down the directory tree, and will set this variable
2387             accordingly, but you can speed it up a very little bit if you define
2388             this boolean variable yourself.
2389              
2390             =item NOECHO
2391              
2392             Command so make does not print the literal commands it's running.
2393              
2394             By setting it to an empty string you can generate a Makefile that
2395             prints all commands. Mainly used in debugging MakeMaker itself.
2396              
2397             Defaults to C<@>.
2398              
2399             =item NORECURS
2400              
2401             Boolean. Attribute to inhibit descending into subdirectories.
2402              
2403             =item NO_META
2404              
2405             When true, suppresses the generation and addition to the MANIFEST of
2406             the META.yml and META.json module meta-data files during 'make distdir'.
2407              
2408             Defaults to false.
2409              
2410             =item NO_MYMETA
2411              
2412             Available in version 6.57_02 and above.
2413              
2414             When true, suppresses the generation of MYMETA.yml and MYMETA.json module
2415             meta-data files during 'perl Makefile.PL'.
2416              
2417             Defaults to false.
2418              
2419             =item NO_PACKLIST
2420              
2421             Available in version 6.7501 and above.
2422              
2423             When true, suppresses the writing of C<packlist> files for installs.
2424              
2425             Defaults to false.
2426              
2427             =item NO_PERLLOCAL
2428              
2429             Available in version 6.7501 and above.
2430              
2431             When true, suppresses the appending of installations to C<perllocal>.
2432              
2433             Defaults to false.
2434              
2435             =item NO_VC
2436              
2437             In general, any generated Makefile checks for the current version of
2438             MakeMaker and the version the Makefile was built under. If NO_VC is
2439             set, the version check is neglected. Do not write this into your
2440             Makefile.PL, use it interactively instead.
2441              
2442             =item OBJECT
2443              
2444             List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
2445             string or an array containing all object files, e.g. "tkpBind.o
2446             tkpButton.o tkpCanvas.o" or ["tkpBind.o", "tkpButton.o", "tkpCanvas.o"]
2447              
2448             (Where BASEEXT is the last component of NAME, and OBJ_EXT is $Config{obj_ext}.)
2449              
2450             =item OPTIMIZE
2451              
2452             Defaults to C<-O>. Set it to C<-g> to turn debugging on. The flag is
2453             passed to subdirectory makes.
2454              
2455             =item PERL
2456              
2457             Perl binary for tasks that can be done by miniperl. If it contains
2458             spaces or other shell metacharacters, it needs to be quoted in a way
2459             that protects them, since this value is intended to be inserted in a
2460             shell command line in the Makefile. E.g.:
2461              
2462             # Perl executable lives in "C:/Program Files/Perl/bin"
2463             # Normally you don't need to set this yourself!
2464             $ perl Makefile.PL PERL='"C:/Program Files/Perl/bin/perl.exe" -w'
2465              
2466             =item PERL_CORE
2467              
2468             Set only when MakeMaker is building the extensions of the Perl core
2469             distribution.
2470              
2471             =item PERLMAINCC
2472              
2473             The call to the program that is able to compile perlmain.c. Defaults
2474             to $(CC).
2475              
2476             =item PERL_ARCHLIB
2477              
2478             Same as for PERL_LIB, but for architecture dependent files.
2479              
2480             Used only when MakeMaker is building the extensions of the Perl core
2481             distribution (because normally $(PERL_ARCHLIB) is automatically in @INC,
2482             and adding it would get in the way of PERL5LIB).
2483              
2484             =item PERL_LIB
2485              
2486             Directory containing the Perl library to use.
2487              
2488             Used only when MakeMaker is building the extensions of the Perl core
2489             distribution (because normally $(PERL_LIB) is automatically in @INC,
2490             and adding it would get in the way of PERL5LIB).
2491              
2492             =item PERL_MALLOC_OK
2493              
2494             defaults to 0. Should be set to TRUE if the extension can work with
2495             the memory allocation routines substituted by the Perl malloc() subsystem.
2496             This should be applicable to most extensions with exceptions of those
2497              
2498             =over 4
2499              
2500             =item *
2501              
2502             with bugs in memory allocations which are caught by Perl's malloc();
2503              
2504             =item *
2505              
2506             which interact with the memory allocator in other ways than via
2507             malloc(), realloc(), free(), calloc(), sbrk() and brk();
2508              
2509             =item *
2510              
2511             which rely on special alignment which is not provided by Perl's malloc().
2512              
2513             =back
2514              
2515             B<NOTE.> Neglecting to set this flag in I<any one> of the loaded extension
2516             nullifies many advantages of Perl's malloc(), such as better usage of
2517             system resources, error detection, memory usage reporting, catchable failure
2518             of memory allocations, etc.
2519              
2520             =item PERLPREFIX
2521              
2522             Directory under which core modules are to be installed.
2523              
2524             Defaults to $Config{installprefixexp}, falling back to
2525             $Config{installprefix}, $Config{prefixexp} or $Config{prefix} should
2526             $Config{installprefixexp} not exist.
2527              
2528             Overridden by PREFIX.
2529              
2530             =item PERLRUN
2531              
2532             Use this instead of $(PERL) when you wish to run perl. It will set up
2533             extra necessary flags for you.
2534              
2535             =item PERLRUNINST
2536              
2537             Use this instead of $(PERL) when you wish to run perl to work with
2538             modules. It will add things like -I$(INST_ARCH) and other necessary
2539             flags so perl can see the modules you're about to install.
2540              
2541             =item PERL_SRC
2542              
2543             Directory containing the Perl source code (use of this should be
2544             avoided, it may be undefined)
2545              
2546             =item PERM_DIR
2547              
2548             Available in version 6.51_01 and above.
2549              
2550             Desired permission for directories. Defaults to C<755>.
2551              
2552             =item PERM_RW
2553              
2554             Desired permission for read/writable files. Defaults to C<644>.
2555              
2556             =item PERM_RWX
2557              
2558             Desired permission for executable files. Defaults to C<755>.
2559              
2560             =item PL_FILES
2561              
2562             MakeMaker can run programs to generate files for you at build time.
2563             By default any file named *.PL (except Makefile.PL and Build.PL) in
2564             the top level directory will be assumed to be a Perl program and run
2565             passing its own basename in as an argument. This basename is actually a build
2566             target, and there is an intention, but not a requirement, that the *.PL file
2567             make the file passed to to as an argument. For example...
2568              
2569             perl foo.PL foo
2570              
2571             This behavior can be overridden by supplying your own set of files to
2572             search. PL_FILES accepts a hash ref, the key being the file to run
2573             and the value is passed in as the first argument when the PL file is run.
2574              
2575             PL_FILES => {'bin/foobar.PL' => 'bin/foobar'}
2576              
2577             PL_FILES => {'foo.PL' => 'foo.c'}
2578              
2579             Would run bin/foobar.PL like this:
2580              
2581             perl bin/foobar.PL bin/foobar
2582              
2583             If multiple files from one program are desired an array ref can be used.
2584              
2585             PL_FILES => {'bin/foobar.PL' => [qw(bin/foobar1 bin/foobar2)]}
2586              
2587             In this case the program will be run multiple times using each target file.
2588              
2589             perl bin/foobar.PL bin/foobar1
2590             perl bin/foobar.PL bin/foobar2
2591              
2592             If an output file depends on extra input files beside the script itself,
2593             a hash ref can be used in version 7.36 and above:
2594              
2595             PL_FILES => { 'foo.PL' => {
2596             'foo.out' => 'foo.in',
2597             'bar.out' => [qw(bar1.in bar2.in)],
2598             }
2599              
2600             In this case the extra input files will be passed to the program after
2601             the target file:
2602              
2603             perl foo.PL foo.out foo.in
2604             perl foo.PL bar.out bar1.in bar2.in
2605              
2606             PL files are normally run B<after> pm_to_blib and include INST_LIB and
2607             INST_ARCH in their C<@INC>, so the just built modules can be
2608             accessed... unless the PL file is making a module (or anything else in
2609             PM) in which case it is run B<before> pm_to_blib and does not include
2610             INST_LIB and INST_ARCH in its C<@INC>. This apparently odd behavior
2611             is there for backwards compatibility (and it's somewhat DWIM). The argument
2612             passed to the .PL is set up as a target to build in the Makefile. In other
2613             sections such as C<postamble> you can specify a dependency on the
2614             filename/argument that the .PL is supposed (or will have, now that that is
2615             is a dependency) to generate. Note the file to be generated will still be
2616             generated and the .PL will still run even without an explicit dependency created
2617             by you, since the C<all> target still depends on running all eligible to run.PL
2618             files.
2619              
2620             =item PM
2621              
2622             Hashref of .pm files and *.pl files to be installed. e.g.
2623              
2624             {'name_of_file.pm' => '$(INST_LIB)/install_as.pm'}
2625              
2626             By default this will include *.pm and *.pl and the files found in
2627             the PMLIBDIRS directories. Defining PM in the
2628             Makefile.PL will override PMLIBDIRS.
2629              
2630             =item PMLIBDIRS
2631              
2632             Ref to array of subdirectories containing library files. Defaults to
2633             [ 'lib', $(BASEEXT) ]. The directories will be scanned and I<any> files
2634             they contain will be installed in the corresponding location in the
2635             library. A libscan() method can be used to alter the behaviour.
2636             Defining PM in the Makefile.PL will override PMLIBDIRS.
2637              
2638             (Where BASEEXT is the last component of NAME.)
2639              
2640             =item PM_FILTER
2641              
2642             A filter program, in the traditional Unix sense (input from stdin, output
2643             to stdout) that is passed on each .pm file during the build (in the
2644             pm_to_blib() phase). It is empty by default, meaning no filtering is done.
2645             You could use:
2646              
2647             PM_FILTER => 'perl -ne "print unless /^\\#/"',
2648              
2649             to remove all the leading comments on the fly during the build. In order
2650             to be as portable as possible, please consider using a Perl one-liner
2651             rather than Unix (or other) utilities, as above. The # is escaped for
2652             the Makefile, since what is going to be generated will then be:
2653              
2654             PM_FILTER = perl -ne "print unless /^\#/"
2655              
2656             Without the \ before the #, we'd have the start of a Makefile comment,
2657             and the macro would be incorrectly defined.
2658              
2659             You will almost certainly be better off using the C<PL_FILES> system,
2660             instead. See above, or the L<ExtUtils::MakeMaker::FAQ> entry.
2661              
2662             =item POLLUTE
2663              
2664             Prior to 5.6 various interpreter variables were available without a C<PL_>
2665             prefix, eg. C<PL_undef> was available as C<undef>. As of release 5.6, these
2666             are only defined if the POLLUTE flag is enabled:
2667              
2668             perl Makefile.PL POLLUTE=1
2669              
2670             Please inform the module author if this is necessary to successfully install
2671             a module under 5.6 or later.
2672              
2673             =item PPM_INSTALL_EXEC
2674              
2675             Name of the executable used to run C<PPM_INSTALL_SCRIPT> below. (e.g. perl)
2676              
2677             =item PPM_INSTALL_SCRIPT
2678              
2679             Name of the script that gets executed by the Perl Package Manager after
2680             the installation of a package.
2681              
2682             =item PPM_UNINSTALL_EXEC
2683              
2684             Available in version 6.8502 and above.
2685              
2686             Name of the executable used to run C<PPM_UNINSTALL_SCRIPT> below. (e.g. perl)
2687              
2688             =item PPM_UNINSTALL_SCRIPT
2689              
2690             Available in version 6.8502 and above.
2691              
2692             Name of the script that gets executed by the Perl Package Manager before
2693             the removal of a package.
2694              
2695             =item PREFIX
2696              
2697             This overrides all the default install locations. Man pages,
2698             libraries, scripts, etc... MakeMaker will try to make an educated
2699             guess about where to place things under the new PREFIX based on your
2700             Config defaults. Failing that, it will fall back to a structure
2701             which should be sensible for your platform.
2702              
2703             If you specify LIB or any INSTALL* variables they will not be affected
2704             by the PREFIX.
2705              
2706             =item PREREQ_FATAL
2707              
2708             Bool. If this parameter is true, failing to have the required modules
2709             (or the right versions thereof) will be fatal. C<perl Makefile.PL>
2710             will C<die> instead of simply informing the user of the missing dependencies.
2711              
2712             It is I<extremely> rare to have to use C<PREREQ_FATAL>. Its use by module
2713             authors is I<strongly discouraged> and should never be used lightly.
2714              
2715             For dependencies that are required in order to run C<Makefile.PL>,
2716             see C<CONFIGURE_REQUIRES>.
2717              
2718             Module installation tools have ways of resolving unmet dependencies but
2719             to do that they need a F<Makefile>. Using C<PREREQ_FATAL> breaks this.
2720             That's bad.
2721              
2722             Assuming you have good test coverage, your tests should fail with
2723             missing dependencies informing the user more strongly that something
2724             is wrong. You can write a F<t/00compile.t> test which will simply
2725             check that your code compiles and stop "make test" prematurely if it
2726             doesn't. See L<Test::More/BAIL_OUT> for more details.
2727              
2728              
2729             =item PREREQ_PM
2730              
2731             A hash of modules that are needed to run your module. The keys are
2732             the module names ie. Test::More, and the minimum version is the
2733             value. If the required version number is 0 any version will do.
2734             The versions given may be a Perl v-string (see L<version>) or a range
2735             (see L<CPAN::Meta::Requirements>).
2736              
2737             This will go into the C<requires> field of your F<META.yml> and the
2738             C<runtime> of the C<prereqs> field of your F<META.json>.
2739              
2740             PREREQ_PM => {
2741             # Require Test::More at least 0.47
2742             "Test::More" => "0.47",
2743              
2744             # Require any version of Acme::Buffy
2745             "Acme::Buffy" => 0,
2746             }
2747              
2748             =item PREREQ_PRINT
2749              
2750             Bool. If this parameter is true, the prerequisites will be printed to
2751             stdout and MakeMaker will exit. The output format is an evalable hash
2752             ref.
2753              
2754             $PREREQ_PM = {
2755             'A::B' => Vers1,
2756             'C::D' => Vers2,
2757             ...
2758             };
2759              
2760             If a distribution defines a minimal required perl version, this is
2761             added to the output as an additional line of the form:
2762              
2763             $MIN_PERL_VERSION = '5.008001';
2764              
2765             If BUILD_REQUIRES is not empty, it will be dumped as $BUILD_REQUIRES hashref.
2766              
2767             =item PRINT_PREREQ
2768              
2769             RedHatism for C<PREREQ_PRINT>. The output format is different, though:
2770              
2771             perl(A::B)>=Vers1 perl(C::D)>=Vers2 ...
2772              
2773             A minimal required perl version, if present, will look like this:
2774              
2775             perl(perl)>=5.008001
2776              
2777             =item SITEPREFIX
2778              
2779             Like PERLPREFIX, but only for the site install locations.
2780              
2781             Defaults to $Config{siteprefixexp}. Perls prior to 5.6.0 didn't have
2782             an explicit siteprefix in the Config. In those cases
2783             $Config{installprefix} will be used.
2784              
2785             Overridable by PREFIX
2786              
2787             =item SIGN
2788              
2789             Available in version 6.18 and above.
2790              
2791             When true, perform the generation and addition to the MANIFEST of the
2792             SIGNATURE file in the distdir during 'make distdir', via 'cpansign
2793             -s'.
2794              
2795             Note that you need to install the Module::Signature module to
2796             perform this operation.
2797              
2798             Defaults to false.
2799              
2800             =item SKIP
2801              
2802             Arrayref. E.g. [qw(name1 name2)] skip (do not write) sections of the
2803             Makefile. Caution! Do not use the SKIP attribute for the negligible
2804             speedup. It may seriously damage the resulting Makefile. Only use it
2805             if you really need it.
2806              
2807             =item TEST_REQUIRES
2808              
2809             Available in version 6.64 and above.
2810              
2811             A hash of modules that are needed to test your module but not run or
2812             build it.
2813              
2814             This will go into the C<build_requires> field of your F<META.yml> and the C<test> of the C<prereqs> field of your F<META.json>.
2815              
2816             The format is the same as PREREQ_PM.
2817              
2818             =item TYPEMAPS
2819              
2820             Ref to array of typemap file names. Use this when the typemaps are
2821             in some directory other than the current directory or when they are
2822             not named B<typemap>. The last typemap in the list takes
2823             precedence. A typemap in the current directory has highest
2824             precedence, even if it isn't listed in TYPEMAPS. The default system
2825             typemap has lowest precedence.
2826              
2827             =item VENDORPREFIX
2828              
2829             Like PERLPREFIX, but only for the vendor install locations.
2830              
2831             Defaults to $Config{vendorprefixexp}.
2832              
2833             Overridable by PREFIX
2834              
2835             =item VERBINST
2836              
2837             If true, make install will be verbose
2838              
2839             =item VERSION
2840              
2841             Your version number for distributing the package. This defaults to
2842             0.1.
2843              
2844             =item VERSION_FROM
2845              
2846             Instead of specifying the VERSION in the Makefile.PL you can let
2847             MakeMaker parse a file to determine the version number. The parsing
2848             routine requires that the file named by VERSION_FROM contains one
2849             single line to compute the version number. The first line in the file
2850             that contains something like a $VERSION assignment or C<package Name
2851             VERSION> will be used. The following lines will be parsed o.k.:
2852              
2853             # Good
2854             package Foo::Bar 1.23; # 1.23
2855             $VERSION = '1.00'; # 1.00
2856             *VERSION = \'1.01'; # 1.01
2857             ($VERSION) = q$Revision$ =~ /(\d+)/g; # The digits in $Revision$
2858             $FOO::VERSION = '1.10'; # 1.10
2859             *FOO::VERSION = \'1.11'; # 1.11
2860              
2861             but these will fail:
2862              
2863             # Bad
2864             my $VERSION = '1.01';
2865             local $VERSION = '1.02';
2866             local $FOO::VERSION = '1.30';
2867              
2868             (Putting C<my> or C<local> on the preceding line will work o.k.)
2869              
2870             "Version strings" are incompatible and should not be used.
2871              
2872             # Bad
2873             $VERSION = 1.2.3;
2874             $VERSION = v1.2.3;
2875              
2876             L<version> objects are fine. As of MakeMaker 6.35 version.pm will be
2877             automatically loaded, but you must declare the dependency on version.pm.
2878             For compatibility with older MakeMaker you should load on the same line
2879             as $VERSION is declared.
2880              
2881             # All on one line
2882             use version; our $VERSION = qv(1.2.3);
2883              
2884             The file named in VERSION_FROM is not added as a dependency to
2885             Makefile. This is not really correct, but it would be a major pain
2886             during development to have to rewrite the Makefile for any smallish
2887             change in that file. If you want to make sure that the Makefile
2888             contains the correct VERSION macro after any change of the file, you
2889             would have to do something like
2890              
2891             depend => { Makefile => '$(VERSION_FROM)' }
2892              
2893             See attribute C<depend> below.
2894              
2895             =item VERSION_SYM
2896              
2897             A sanitized VERSION with . replaced by _. For places where . has
2898             special meaning (some filesystems, RCS labels, etc...)
2899              
2900             =item XS
2901              
2902             Hashref of .xs files. MakeMaker will default this. e.g.
2903              
2904             {'name_of_file.xs' => 'name_of_file.c'}
2905              
2906             The .c files will automatically be included in the list of files
2907             deleted by a make clean.
2908              
2909             =item XSBUILD
2910              
2911             Available in version 7.12 and above.
2912              
2913             Hashref with options controlling the operation of C<XSMULTI>:
2914              
2915             {
2916             xs => {
2917             all => {
2918             # options applying to all .xs files for this distribution
2919             },
2920             'lib/Class/Name/File' => { # specifically for this file
2921             DEFINE => '-Dfunktastic', # defines for only this file
2922             INC => "-I$funkyliblocation", # include flags for only this file
2923             # OBJECT => 'lib/Class/Name/File$(OBJ_EXT)', # default
2924             LDFROM => "lib/Class/Name/File\$(OBJ_EXT) $otherfile\$(OBJ_EXT)", # what's linked
2925             },
2926             },
2927             }
2928              
2929             Note C<xs> is the file-extension. More possibilities may arise in the
2930             future. Note that object names are specified without their XS extension.
2931              
2932             C<LDFROM> defaults to the same as C<OBJECT>. C<OBJECT> defaults to,
2933             for C<XSMULTI>, just the XS filename with the extension replaced with
2934             the compiler-specific object-file extension.
2935              
2936             The distinction between C<OBJECT> and C<LDFROM>: C<OBJECT> is the make
2937             target, so make will try to build it. However, C<LDFROM> is what will
2938             actually be linked together to make the shared object or static library
2939             (SO/SL), so if you override it, make sure it includes what you want to
2940             make the final SO/SL, almost certainly including the XS basename with
2941             C<$(OBJ_EXT)> appended.
2942              
2943             =item XSMULTI
2944              
2945             Available in version 7.12 and above.
2946              
2947             When this is set to C<1>, multiple XS files may be placed under F<lib/>
2948             next to their corresponding C<*.pm> files (this is essential for compiling
2949             with the correct C<VERSION> values). This feature should be considered
2950             experimental, and details of it may change.
2951              
2952             This feature was inspired by, and small portions of code copied from,
2953             L<ExtUtils::MakeMaker::BigHelper>. Hopefully this feature will render
2954             that module mainly obsolete.
2955              
2956             =item XSOPT
2957              
2958             String of options to pass to xsubpp. This might include C<-C++> or
2959             C<-extern>. Do not include typemaps here; the TYPEMAP parameter exists for
2960             that purpose.
2961              
2962             =item XSPROTOARG
2963              
2964             May be set to C<-prototypes>, C<-noprototypes> or the empty string. The
2965             empty string is equivalent to the xsubpp default, or C<-noprototypes>.
2966             See the xsubpp documentation for details. MakeMaker
2967             defaults to the empty string.
2968              
2969             =item XS_VERSION
2970              
2971             Your version number for the .xs file of this package. This defaults
2972             to the value of the VERSION attribute.
2973              
2974             =back
2975              
2976             =head2 Additional lowercase attributes
2977              
2978             can be used to pass parameters to the methods which implement that
2979             part of the Makefile. Parameters are specified as a hash ref but are
2980             passed to the method as a hash.
2981              
2982             =over 2
2983              
2984             =item clean
2985              
2986             {FILES => "*.xyz foo"}
2987              
2988             =item depend
2989              
2990             {ANY_TARGET => ANY_DEPENDENCY, ...}
2991              
2992             (ANY_TARGET must not be given a double-colon rule by MakeMaker.)
2993              
2994             =item dist
2995              
2996             {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => '.gz',
2997             SHAR => 'shar -m', DIST_CP => 'ln', ZIP => '/bin/zip',
2998             ZIPFLAGS => '-rl', DIST_DEFAULT => 'private tardist' }
2999              
3000             If you specify COMPRESS, then SUFFIX should also be altered, as it is
3001             needed to tell make the target file of the compression. Setting
3002             DIST_CP to ln can be useful, if you need to preserve the timestamps on
3003             your files. DIST_CP can take the values 'cp', which copies the file,
3004             'ln', which links the file, and 'best' which copies symbolic links and
3005             links the rest. Default is 'best'.
3006              
3007             =item dynamic_lib
3008              
3009             {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
3010              
3011             =item linkext
3012              
3013             {LINKTYPE => 'static', 'dynamic' or ''}
3014              
3015             NB: Extensions that have nothing but *.pm files had to say
3016              
3017             {LINKTYPE => ''}
3018              
3019             with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
3020             can be deleted safely. MakeMaker recognizes when there's nothing to
3021             be linked.
3022              
3023             =item macro
3024              
3025             {ANY_MACRO => ANY_VALUE, ...}
3026              
3027             =item postamble
3028              
3029             Anything put here will be passed to
3030             L<MY::postamble()|ExtUtils::MM_Any/postamble (o)> if you have one.
3031              
3032             =item realclean
3033              
3034             {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
3035              
3036             =item test
3037              
3038             Specify the targets for testing.
3039              
3040             {TESTS => 't/*.t'}
3041              
3042             C<RECURSIVE_TEST_FILES> can be used to include all directories
3043             recursively under C<t> that contain C<.t> files. It will be ignored if
3044             you provide your own C<TESTS> attribute, defaults to false.
3045              
3046             {RECURSIVE_TEST_FILES=>1}
3047              
3048             This is supported since 6.76
3049              
3050             =item tool_autosplit
3051              
3052             {MAXLEN => 8}
3053              
3054             =back
3055              
3056             =head2 Overriding MakeMaker Methods
3057              
3058             If you cannot achieve the desired Makefile behaviour by specifying
3059             attributes you may define private subroutines in the Makefile.PL.
3060             Each subroutine returns the text it wishes to have written to
3061             the Makefile. To override a section of the Makefile you can
3062             either say:
3063              
3064             sub MY::c_o { "new literal text" }
3065              
3066             or you can edit the default by saying something like:
3067              
3068             package MY; # so that "SUPER" works right
3069             sub c_o {
3070             my $inherited = shift->SUPER::c_o(@_);
3071             $inherited =~ s/old text/new text/;
3072             $inherited;
3073             }
3074              
3075             If you are running experiments with embedding perl as a library into
3076             other applications, you might find MakeMaker is not sufficient. You'd
3077             better have a look at L<ExtUtils::Embed> which is a collection of utilities
3078             for embedding.
3079              
3080             If you still need a different solution, try to develop another
3081             subroutine that fits your needs and submit the diffs to
3082             C<makemaker@perl.org>
3083              
3084             For a complete description of all MakeMaker methods see
3085             L<ExtUtils::MM_Unix>.
3086              
3087             Here is a simple example of how to add a new target to the generated
3088             Makefile:
3089              
3090             sub MY::postamble {
3091             return <<'MAKE_FRAG';
3092             $(MYEXTLIB): sdbm/Makefile
3093             cd sdbm && $(MAKE) all
3094              
3095             MAKE_FRAG
3096             }
3097              
3098             =head2 The End Of Cargo Cult Programming
3099              
3100             WriteMakefile() now does some basic sanity checks on its parameters to
3101             protect against typos and malformatted values. This means some things
3102             which happened to work in the past will now throw warnings and
3103             possibly produce internal errors.
3104              
3105             Some of the most common mistakes:
3106              
3107             =over 2
3108              
3109             =item C<< MAN3PODS => ' ' >>
3110              
3111             This is commonly used to suppress the creation of man pages. MAN3PODS
3112             takes a hash ref not a string, but the above worked by accident in old
3113             versions of MakeMaker.
3114              
3115             The correct code is C<< MAN3PODS => { } >>.
3116              
3117             =back
3118              
3119              
3120             =head2 Hintsfile support
3121              
3122             MakeMaker.pm uses the architecture-specific information from
3123             Config.pm. In addition it evaluates architecture specific hints files
3124             in a C<hints/> directory. The hints files are expected to be named
3125             like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
3126             name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
3127             MakeMaker within the WriteMakefile() subroutine, and can be used to
3128             execute commands as well as to include special variables. The rules
3129             which hintsfile is chosen are the same as in Configure.
3130              
3131             The hintsfile is eval()ed immediately after the arguments given to
3132             WriteMakefile are stuffed into a hash reference $self but before this
3133             reference becomes blessed. So if you want to do the equivalent to
3134             override or create an attribute you would say something like
3135              
3136             $self->{LIBS} = ['-ldbm -lucb -lc'];
3137              
3138             =head2 Distribution Support
3139              
3140             For authors of extensions MakeMaker provides several Makefile
3141             targets. Most of the support comes from the L<ExtUtils::Manifest> module,
3142             where additional documentation can be found.
3143              
3144             =over 4
3145              
3146             =item make distcheck
3147              
3148             reports which files are below the build directory but not in the
3149             MANIFEST file and vice versa. (See L<ExtUtils::Manifest/fullcheck> for
3150             details)
3151              
3152             =item make skipcheck
3153              
3154             reports which files are skipped due to the entries in the
3155             C<MANIFEST.SKIP> file (See L<ExtUtils::Manifest/skipcheck> for
3156             details)
3157              
3158             =item make distclean
3159              
3160             does a realclean first and then the distcheck. Note that this is not
3161             needed to build a new distribution as long as you are sure that the
3162             MANIFEST file is ok.
3163              
3164             =item make veryclean
3165              
3166             does a realclean first and then removes backup files such as C<*~>,
3167             C<*.bak>, C<*.old> and C<*.orig>
3168              
3169             =item make manifest
3170              
3171             rewrites the MANIFEST file, adding all remaining files found (See
3172             L<ExtUtils::Manifest/mkmanifest> for details)
3173              
3174             =item make distdir
3175              
3176             Copies all the files that are in the MANIFEST file to a newly created
3177             directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
3178             exists, it will be removed first.
3179              
3180             Additionally, it will create META.yml and META.json module meta-data file
3181             in the distdir and add this to the distdir's MANIFEST. You can shut this
3182             behavior off with the NO_META flag.
3183              
3184             =item make disttest
3185              
3186             Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and
3187             a make test in that directory.
3188              
3189             =item make tardist
3190              
3191             First does a distdir. Then a command $(PREOP) which defaults to a null
3192             command, followed by $(TO_UNIX), which defaults to a null command under
3193             UNIX, and will convert files in distribution directory to UNIX format
3194             otherwise. Next it runs C<tar> on that directory into a tarfile and
3195             deletes the directory. Finishes with a command $(POSTOP) which
3196             defaults to a null command.
3197              
3198             =item make dist
3199              
3200             Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
3201              
3202             =item make uutardist
3203              
3204             Runs a tardist first and uuencodes the tarfile.
3205              
3206             =item make shdist
3207              
3208             First does a distdir. Then a command $(PREOP) which defaults to a null
3209             command. Next it runs C<shar> on that directory into a sharfile and
3210             deletes the intermediate directory again. Finishes with a command
3211             $(POSTOP) which defaults to a null command. Note: For shdist to work
3212             properly a C<shar> program that can handle directories is mandatory.
3213              
3214             =item make zipdist
3215              
3216             First does a distdir. Then a command $(PREOP) which defaults to a null
3217             command. Runs C<$(ZIP) $(ZIPFLAGS)> on that directory into a
3218             zipfile. Then deletes that directory. Finishes with a command
3219             $(POSTOP) which defaults to a null command.
3220              
3221             =item make ci
3222              
3223             Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
3224              
3225             =back
3226              
3227             Customization of the dist targets can be done by specifying a hash
3228             reference to the dist attribute of the WriteMakefile call. The
3229             following parameters are recognized:
3230              
3231             CI ('ci -u')
3232             COMPRESS ('gzip --best')
3233             POSTOP ('@ :')
3234             PREOP ('@ :')
3235             TO_UNIX (depends on the system)
3236             RCS_LABEL ('rcs -q -Nv$(VERSION_SYM):')
3237             SHAR ('shar')
3238             SUFFIX ('.gz')
3239             TAR ('tar')
3240             TARFLAGS ('cvf')
3241             ZIP ('zip')
3242             ZIPFLAGS ('-r')
3243              
3244             An example:
3245              
3246             WriteMakefile(
3247             ...other options...
3248             dist => {
3249             COMPRESS => "bzip2",
3250             SUFFIX => ".bz2"
3251             }
3252             );
3253              
3254              
3255             =head2 Module Meta-Data (META and MYMETA)
3256              
3257             Long plaguing users of MakeMaker based modules has been the problem of
3258             getting basic information about the module out of the sources
3259             I<without> running the F<Makefile.PL> and doing a bunch of messy
3260             heuristics on the resulting F<Makefile>. Over the years, it has become
3261             standard to keep this information in one or more CPAN Meta files
3262             distributed with each distribution.
3263              
3264             The original format of CPAN Meta files was L<YAML> and the corresponding
3265             file was called F<META.yml>. In 2010, version 2 of the L<CPAN::Meta::Spec>
3266             was released, which mandates JSON format for the metadata in order to
3267             overcome certain compatibility issues between YAML serializers and to
3268             avoid breaking older clients unable to handle a new version of the spec.
3269             The L<CPAN::Meta> library is now standard for accessing old and new-style
3270             Meta files.
3271              
3272             If L<CPAN::Meta> is installed, MakeMaker will automatically generate
3273             F<META.json> and F<META.yml> files for you and add them to your F<MANIFEST> as
3274             part of the 'distdir' target (and thus the 'dist' target). This is intended to
3275             seamlessly and rapidly populate CPAN with module meta-data. If you wish to
3276             shut this feature off, set the C<NO_META> C<WriteMakefile()> flag to true.
3277              
3278             At the 2008 QA Hackathon in Oslo, Perl module toolchain maintainers agreed
3279             to use the CPAN Meta format to communicate post-configuration requirements
3280             between toolchain components. These files, F<MYMETA.json> and F<MYMETA.yml>,
3281             are generated when F<Makefile.PL> generates a F<Makefile> (if L<CPAN::Meta>
3282             is installed). Clients like L<CPAN> or L<CPANPLUS> will read these
3283             files to see what prerequisites must be fulfilled before building or testing
3284             the distribution. If you wish to shut this feature off, set the C<NO_MYMETA>
3285             C<WriteMakefile()> flag to true.
3286              
3287             =head2 Disabling an extension
3288              
3289             If some events detected in F<Makefile.PL> imply that there is no way
3290             to create the Module, but this is a normal state of things, then you
3291             can create a F<Makefile> which does nothing, but succeeds on all the
3292             "usual" build targets. To do so, use
3293              
3294             use ExtUtils::MakeMaker qw(WriteEmptyMakefile);
3295             WriteEmptyMakefile();
3296              
3297             instead of WriteMakefile().
3298              
3299             This may be useful if other modules expect this module to be I<built>
3300             OK, as opposed to I<work> OK (say, this system-dependent module builds
3301             in a subdirectory of some other distribution, or is listed as a
3302             dependency in a CPAN::Bundle, but the functionality is supported by
3303             different means on the current architecture).
3304              
3305             =head2 Other Handy Functions
3306              
3307             =over 4
3308              
3309             =item prompt
3310              
3311             my $value = prompt($message);
3312             my $value = prompt($message, $default);
3313              
3314             The C<prompt()> function provides an easy way to request user input
3315             used to write a makefile. It displays the $message as a prompt for
3316             input. If a $default is provided it will be used as a default. The
3317             function returns the $value selected by the user.
3318              
3319             If C<prompt()> detects that it is not running interactively and there
3320             is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
3321             is set to true, the $default will be used without prompting. This
3322             prevents automated processes from blocking on user input.
3323              
3324             If no $default is provided an empty string will be used instead.
3325              
3326             =item os_unsupported
3327              
3328             os_unsupported();
3329             os_unsupported if $^O eq 'MSWin32';
3330              
3331             The C<os_unsupported()> function provides a way to correctly exit your
3332             C<Makefile.PL> before calling C<WriteMakefile>. It is essentially a
3333             C<die> with the message "OS unsupported".
3334              
3335             This is supported since 7.26
3336              
3337             =back
3338              
3339             =head2 Supported versions of Perl
3340              
3341             Please note that while this module works on Perl 5.6, it is no longer
3342             being routinely tested on 5.6 - the earliest Perl version being routinely
3343             tested, and expressly supported, is 5.8.1. However, patches to repair
3344             any breakage on 5.6 are still being accepted.
3345              
3346             =head1 ENVIRONMENT
3347              
3348             =over 4
3349              
3350             =item PERL_MM_OPT
3351              
3352             Command line options used by C<MakeMaker-E<gt>new()>, and thus by
3353             C<WriteMakefile()>. The string is split as the shell would, and the result
3354             is processed before any actual command line arguments are processed.
3355              
3356             PERL_MM_OPT='CCFLAGS="-Wl,-rpath -Wl,/foo/bar/lib" LIBS="-lwibble -lwobble"'
3357              
3358             =item PERL_MM_USE_DEFAULT
3359              
3360             If set to a true value then MakeMaker's prompt function will
3361             always return the default without waiting for user input.
3362              
3363             =item PERL_CORE
3364              
3365             Same as the PERL_CORE parameter. The parameter overrides this.
3366              
3367             =back
3368              
3369             =head1 SEE ALSO
3370              
3371             L<Module::Build> is a pure-Perl alternative to MakeMaker which does
3372             not rely on make or any other external utility. It may be easier to
3373             extend to suit your needs.
3374              
3375             L<Module::Build::Tiny> is a minimal pure-Perl alternative to MakeMaker
3376             that follows the Build.PL protocol of Module::Build but without its
3377             complexity and cruft, implementing only the installation of the module
3378             and leaving authoring to L<mbtiny> or other authoring tools.
3379              
3380             L<Module::Install> is a (now discouraged) wrapper around MakeMaker which
3381             adds features not normally available.
3382              
3383             L<ExtUtils::ModuleMaker> and L<Module::Starter> are both modules to
3384             help you setup your distribution.
3385              
3386             L<CPAN::Meta> and L<CPAN::Meta::Spec> explain CPAN Meta files in detail.
3387              
3388             L<File::ShareDir::Install> makes it easy to install static, sometimes
3389             also referred to as 'shared' files. L<File::ShareDir> helps accessing
3390             the shared files after installation. L<Test::File::ShareDir> helps when
3391             writing tests to use the shared files both before and after installation.
3392              
3393             L<Dist::Zilla> is an authoring tool which allows great customization and
3394             extensibility of the author experience, relying on the existing install
3395             tools like ExtUtils::MakeMaker only for installation.
3396              
3397             L<Dist::Milla> is a Dist::Zilla bundle that greatly simplifies common
3398             usage.
3399              
3400             L<Minilla> is a minimal authoring tool that does the same things as
3401             Dist::Milla without the overhead of Dist::Zilla.
3402              
3403             =head1 AUTHORS
3404              
3405             Andy Dougherty C<doughera@lafayette.edu>, Andreas KE<ouml>nig
3406             C<andreas.koenig@mind.de>, Tim Bunce C<timb@cpan.org>. VMS
3407             support by Charles Bailey C<bailey@newman.upenn.edu>. OS/2 support
3408             by Ilya Zakharevich C<ilya@math.ohio-state.edu>.
3409              
3410             Currently maintained by Michael G Schwern C<schwern@pobox.com>
3411              
3412             Send patches and ideas to C<makemaker@perl.org>.
3413              
3414             Send bug reports via http://rt.cpan.org/. Please send your
3415             generated Makefile along with your report.
3416              
3417             For more up-to-date information, see L<https://metacpan.org/release/ExtUtils-MakeMaker>.
3418              
3419             Repository available at L<https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker>.
3420              
3421             =head1 LICENSE
3422              
3423             This program is free software; you can redistribute it and/or
3424             modify it under the same terms as Perl itself.
3425              
3426             See L<http://www.perl.com/perl/misc/Artistic.html>
3427              
3428              
3429             =cut