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