xref: /openbsd-src/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm (revision e068048151d29f2562a32185e21a8ba885482260)
1b39c5158Smillert# $Id$
2b39c5158Smillertpackage ExtUtils::MakeMaker;
3b39c5158Smillert
4b39c5158Smillertuse strict;
5eac174f2Safresh1use warnings;
6b39c5158Smillert
7b39c5158SmillertBEGIN {require 5.006;}
8b39c5158Smillert
9b39c5158Smillertrequire Exporter;
10b39c5158Smillertuse ExtUtils::MakeMaker::Config;
11b8851fccSafresh1use ExtUtils::MakeMaker::version; # ensure we always have our fake version.pm
1248950c12Ssthenuse Carp;
13b39c5158Smillertuse File::Path;
14b8851fccSafresh1my $CAN_DECODE = eval { require ExtUtils::MakeMaker::Locale; }; # 2 birds, 1 stone
15b8851fccSafresh1eval { ExtUtils::MakeMaker::Locale::reinit('UTF-8') }
169f11ffb7Safresh1  if $CAN_DECODE and Encode::find_encoding('locale')->name eq 'ascii';
17b39c5158Smillert
18b39c5158Smillertour $Verbose = 0;       # exported
19b39c5158Smillertour @Parent;            # needs to be localized
20b39c5158Smillertour @Get_from_Config;   # referenced by MM_Unix
21b39c5158Smillertour @MM_Sections;
22b39c5158Smillertour @Overridable;
23b39c5158Smillertmy @Prepend_parent;
24b39c5158Smillertmy %Recognized_Att_Keys;
25b8851fccSafresh1our %macro_fsentity; # whether a macro is a filesystem name
26b8851fccSafresh1our %macro_dep; # whether a macro is a dependency
27b39c5158Smillert
28*e0680481Safresh1our $VERSION = '7.70';
2956d68f1eSafresh1$VERSION =~ tr/_//d;
30b39c5158Smillert
31b39c5158Smillert# Emulate something resembling CVS $Revision$
32b39c5158Smillert(our $Revision = $VERSION) =~ s{_}{};
33b39c5158Smillert$Revision = int $Revision * 10000;
34b39c5158Smillert
35b39c5158Smillertour $Filename = __FILE__;   # referenced outside MakeMaker
36b39c5158Smillert
37b39c5158Smillertour @ISA = qw(Exporter);
389f11ffb7Safresh1our @EXPORT    = qw(&WriteMakefile $Verbose &prompt &os_unsupported);
39b39c5158Smillertour @EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists
409f11ffb7Safresh1                    &WriteEmptyMakefile &open_for_writing &write_file_via_tmp
419f11ffb7Safresh1                    &_sprintf562);
42b39c5158Smillert
43b39c5158Smillert# These will go away once the last of the Win32 & VMS specific code is
44b39c5158Smillert# purged.
45b39c5158Smillertmy $Is_VMS     = $^O eq 'VMS';
46b39c5158Smillertmy $Is_Win32   = $^O eq 'MSWin32';
47b8851fccSafresh1our $UNDER_CORE = $ENV{PERL_CORE}; # needs to be our
48b39c5158Smillert
49b39c5158Smillertfull_setup();
50b39c5158Smillert
51b39c5158Smillertrequire ExtUtils::MM;  # Things like CPAN assume loading ExtUtils::MakeMaker
52b39c5158Smillert                       # will give them MM.
53b39c5158Smillert
54b39c5158Smillertrequire ExtUtils::MY;  # XXX pre-5.8 versions of ExtUtils::Embed expect
55b39c5158Smillert                       # loading ExtUtils::MakeMaker will give them MY.
56b39c5158Smillert                       # This will go when Embed is its own CPAN module.
57b39c5158Smillert
58b39c5158Smillert
599f11ffb7Safresh1# 5.6.2 can't do sprintf "%1$s" - this can only do %s
609f11ffb7Safresh1sub _sprintf562 {
619f11ffb7Safresh1    my ($format, @args) = @_;
629f11ffb7Safresh1    for (my $i = 1; $i <= @args; $i++) {
639f11ffb7Safresh1        $format =~ s#%$i\$s#$args[$i-1]#g;
649f11ffb7Safresh1    }
659f11ffb7Safresh1    $format;
669f11ffb7Safresh1}
679f11ffb7Safresh1
68b39c5158Smillertsub WriteMakefile {
6948950c12Ssthen    croak "WriteMakefile: Need even number of args" if @_ % 2;
70b39c5158Smillert
71b39c5158Smillert    require ExtUtils::MY;
72b39c5158Smillert    my %att = @_;
73b39c5158Smillert
7448950c12Ssthen    _convert_compat_attrs(\%att);
7548950c12Ssthen
76b39c5158Smillert    _verify_att(\%att);
77b39c5158Smillert
78b39c5158Smillert    my $mm = MM->new(\%att);
79b39c5158Smillert    $mm->flush;
80b39c5158Smillert
81b39c5158Smillert    return $mm;
82b39c5158Smillert}
83b39c5158Smillert
84b39c5158Smillert
85b39c5158Smillert# Basic signatures of the attributes WriteMakefile takes.  Each is the
86b39c5158Smillert# reference type.  Empty value indicate it takes a non-reference
87b39c5158Smillert# scalar.
88b39c5158Smillertmy %Att_Sigs;
89b39c5158Smillertmy %Special_Sigs = (
9048950c12Ssthen AUTHOR             => 'ARRAY',
91b39c5158Smillert C                  => 'ARRAY',
92b39c5158Smillert CONFIG             => 'ARRAY',
93b39c5158Smillert CONFIGURE          => 'CODE',
94b39c5158Smillert DIR                => 'ARRAY',
95b39c5158Smillert DL_FUNCS           => 'HASH',
96b39c5158Smillert DL_VARS            => 'ARRAY',
97b39c5158Smillert EXCLUDE_EXT        => 'ARRAY',
98b39c5158Smillert EXE_FILES          => 'ARRAY',
99b39c5158Smillert FUNCLIST           => 'ARRAY',
100b39c5158Smillert H                  => 'ARRAY',
101b39c5158Smillert IMPORTS            => 'HASH',
102b39c5158Smillert INCLUDE_EXT        => 'ARRAY',
103b39c5158Smillert LIBS               => ['ARRAY',''],
104b39c5158Smillert MAN1PODS           => 'HASH',
105b39c5158Smillert MAN3PODS           => 'HASH',
106b39c5158Smillert META_ADD           => 'HASH',
107b39c5158Smillert META_MERGE         => 'HASH',
108e5157e49Safresh1 OBJECT             => ['ARRAY', ''],
109b39c5158Smillert PL_FILES           => 'HASH',
110b39c5158Smillert PM                 => 'HASH',
111b39c5158Smillert PMLIBDIRS          => 'ARRAY',
112b39c5158Smillert PMLIBPARENTDIRS    => 'ARRAY',
113b39c5158Smillert PREREQ_PM          => 'HASH',
114b39c5158Smillert BUILD_REQUIRES     => 'HASH',
115b39c5158Smillert CONFIGURE_REQUIRES => 'HASH',
116e9ce3842Safresh1 TEST_REQUIRES      => 'HASH',
117b39c5158Smillert SKIP               => 'ARRAY',
118b39c5158Smillert TYPEMAPS           => 'ARRAY',
119b39c5158Smillert XS                 => 'HASH',
1209f11ffb7Safresh1 XSBUILD            => 'HASH',
121b39c5158Smillert VERSION            => ['version',''],
122b39c5158Smillert _KEEP_AFTER_FLUSH  => '',
123b39c5158Smillert
124b39c5158Smillert clean      => 'HASH',
125b39c5158Smillert depend     => 'HASH',
126b39c5158Smillert dist       => 'HASH',
127b39c5158Smillert dynamic_lib=> 'HASH',
128b39c5158Smillert linkext    => 'HASH',
129b39c5158Smillert macro      => 'HASH',
130b39c5158Smillert postamble  => 'HASH',
131b39c5158Smillert realclean  => 'HASH',
132b39c5158Smillert test       => 'HASH',
133b39c5158Smillert tool_autosplit => 'HASH',
134b39c5158Smillert);
135b39c5158Smillert
136b39c5158Smillert@Att_Sigs{keys %Recognized_Att_Keys} = ('') x keys %Recognized_Att_Keys;
137b39c5158Smillert@Att_Sigs{keys %Special_Sigs} = values %Special_Sigs;
138b39c5158Smillert
13948950c12Ssthensub _convert_compat_attrs { #result of running several times should be same
14048950c12Ssthen    my($att) = @_;
14148950c12Ssthen    if (exists $att->{AUTHOR}) {
14248950c12Ssthen        if ($att->{AUTHOR}) {
14348950c12Ssthen            if (!ref($att->{AUTHOR})) {
14448950c12Ssthen                my $t = $att->{AUTHOR};
14548950c12Ssthen                $att->{AUTHOR} = [$t];
14648950c12Ssthen            }
14748950c12Ssthen        } else {
14848950c12Ssthen                $att->{AUTHOR} = [];
14948950c12Ssthen        }
15048950c12Ssthen    }
15148950c12Ssthen}
152b39c5158Smillert
153b39c5158Smillertsub _verify_att {
154b39c5158Smillert    my($att) = @_;
155b39c5158Smillert
1569f11ffb7Safresh1    foreach my $key (sort keys %$att) {
1579f11ffb7Safresh1        my $val = $att->{$key};
158b39c5158Smillert        my $sig = $Att_Sigs{$key};
159b39c5158Smillert        unless( defined $sig ) {
160b39c5158Smillert            warn "WARNING: $key is not a known parameter.\n";
161b39c5158Smillert            next;
162b39c5158Smillert        }
163b39c5158Smillert
164b39c5158Smillert        my @sigs   = ref $sig ? @$sig : $sig;
165b39c5158Smillert        my $given  = ref $val;
166b39c5158Smillert        unless( grep { _is_of_type($val, $_) } @sigs ) {
167b39c5158Smillert            my $takes = join " or ", map { _format_att($_) } @sigs;
168b39c5158Smillert
169b39c5158Smillert            my $has = _format_att($given);
170b39c5158Smillert            warn "WARNING: $key takes a $takes not a $has.\n".
171b39c5158Smillert                 "         Please inform the author.\n";
172b39c5158Smillert        }
173b39c5158Smillert    }
174b39c5158Smillert}
175b39c5158Smillert
176b39c5158Smillert
177b39c5158Smillert# Check if a given thing is a reference or instance of $type
178b39c5158Smillertsub _is_of_type {
179b39c5158Smillert    my($thing, $type) = @_;
180b39c5158Smillert
181b39c5158Smillert    return 1 if ref $thing eq $type;
182b39c5158Smillert
183b39c5158Smillert    local $SIG{__DIE__};
184b39c5158Smillert    return 1 if eval{ $thing->isa($type) };
185b39c5158Smillert
186b39c5158Smillert    return 0;
187b39c5158Smillert}
188b39c5158Smillert
189b39c5158Smillert
190b39c5158Smillertsub _format_att {
191b39c5158Smillert    my $given = shift;
192b39c5158Smillert
193b39c5158Smillert    return $given eq ''        ? "string/number"
194b39c5158Smillert         : uc $given eq $given ? "$given reference"
195b39c5158Smillert         :                       "$given object"
196b39c5158Smillert         ;
197b39c5158Smillert}
198b39c5158Smillert
199b39c5158Smillert
200b39c5158Smillertsub prompt ($;$) {  ## no critic
201b39c5158Smillert    my($mess, $def) = @_;
20248950c12Ssthen    confess("prompt function called without an argument")
203b39c5158Smillert        unless defined $mess;
204b39c5158Smillert
205b39c5158Smillert    my $isa_tty = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ;
206b39c5158Smillert
207b39c5158Smillert    my $dispdef = defined $def ? "[$def] " : " ";
208b39c5158Smillert    $def = defined $def ? $def : "";
209b39c5158Smillert
210b39c5158Smillert    local $|=1;
211b39c5158Smillert    local $\;
212b39c5158Smillert    print "$mess $dispdef";
213b39c5158Smillert
214b39c5158Smillert    my $ans;
215b39c5158Smillert    if ($ENV{PERL_MM_USE_DEFAULT} || (!$isa_tty && eof STDIN)) {
216b39c5158Smillert        print "$def\n";
217b39c5158Smillert    }
218b39c5158Smillert    else {
219b39c5158Smillert        $ans = <STDIN>;
220b39c5158Smillert        if( defined $ans ) {
221e5157e49Safresh1            $ans =~ s{\015?\012$}{};
222b39c5158Smillert        }
223b39c5158Smillert        else { # user hit ctrl-D
224b39c5158Smillert            print "\n";
225b39c5158Smillert        }
226b39c5158Smillert    }
227b39c5158Smillert
228b39c5158Smillert    return (!defined $ans || $ans eq '') ? $def : $ans;
229b39c5158Smillert}
230b39c5158Smillert
2319f11ffb7Safresh1sub os_unsupported {
2329f11ffb7Safresh1    die "OS unsupported\n";
2339f11ffb7Safresh1}
2349f11ffb7Safresh1
235b39c5158Smillertsub eval_in_subdirs {
236b39c5158Smillert    my($self) = @_;
237b39c5158Smillert    use Cwd qw(cwd abs_path);
238b39c5158Smillert    my $pwd = cwd() || die "Can't figure out your cwd!";
239b39c5158Smillert
240b39c5158Smillert    local @INC = map eval {abs_path($_) if -e} || $_, @INC;
241b39c5158Smillert    push @INC, '.';     # '.' has to always be at the end of @INC
242b39c5158Smillert
243b39c5158Smillert    foreach my $dir (@{$self->{DIR}}){
244b39c5158Smillert        my($abs) = $self->catdir($pwd,$dir);
245b39c5158Smillert        eval { $self->eval_in_x($abs); };
246b39c5158Smillert        last if $@;
247b39c5158Smillert    }
248b39c5158Smillert    chdir $pwd;
249b39c5158Smillert    die $@ if $@;
250b39c5158Smillert}
251b39c5158Smillert
252b39c5158Smillertsub eval_in_x {
253b39c5158Smillert    my($self,$dir) = @_;
25448950c12Ssthen    chdir $dir or carp("Couldn't change to directory $dir: $!");
255b39c5158Smillert
256b39c5158Smillert    {
257b39c5158Smillert        package main;
258b39c5158Smillert        do './Makefile.PL';
259b39c5158Smillert    };
260b39c5158Smillert    if ($@) {
261b39c5158Smillert#         if ($@ =~ /prerequisites/) {
262b39c5158Smillert#             die "MakeMaker WARNING: $@";
263b39c5158Smillert#         } else {
264b39c5158Smillert#             warn "WARNING from evaluation of $dir/Makefile.PL: $@";
265b39c5158Smillert#         }
266b39c5158Smillert        die "ERROR from evaluation of $dir/Makefile.PL: $@";
267b39c5158Smillert    }
268b39c5158Smillert}
269b39c5158Smillert
270b39c5158Smillert
271b39c5158Smillert# package name for the classes into which the first object will be blessed
272b39c5158Smillertmy $PACKNAME = 'PACK000';
273b39c5158Smillert
274b39c5158Smillertsub full_setup {
275b39c5158Smillert    $Verbose ||= 0;
276b39c5158Smillert
277b8851fccSafresh1    my @dep_macros = qw/
278b8851fccSafresh1    PERL_INCDEP        PERL_ARCHLIBDEP     PERL_ARCHIVEDEP
279b8851fccSafresh1    /;
280b39c5158Smillert
281b8851fccSafresh1    my @fs_macros = qw/
282b8851fccSafresh1    FULLPERL XSUBPPDIR
283b39c5158Smillert
284b39c5158Smillert    INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB INST_MAN1DIR INST_MAN3DIR
285b39c5158Smillert    INSTALLDIRS
286b39c5158Smillert    DESTDIR PREFIX INSTALL_BASE
287b39c5158Smillert    PERLPREFIX      SITEPREFIX      VENDORPREFIX
288b39c5158Smillert    INSTALLPRIVLIB  INSTALLSITELIB  INSTALLVENDORLIB
289b39c5158Smillert    INSTALLARCHLIB  INSTALLSITEARCH INSTALLVENDORARCH
290b39c5158Smillert    INSTALLBIN      INSTALLSITEBIN  INSTALLVENDORBIN
291b39c5158Smillert    INSTALLMAN1DIR          INSTALLMAN3DIR
292b39c5158Smillert    INSTALLSITEMAN1DIR      INSTALLSITEMAN3DIR
293b39c5158Smillert    INSTALLVENDORMAN1DIR    INSTALLVENDORMAN3DIR
294b39c5158Smillert    INSTALLSCRIPT   INSTALLSITESCRIPT  INSTALLVENDORSCRIPT
295b39c5158Smillert    PERL_LIB        PERL_ARCHLIB
296b39c5158Smillert    SITELIBEXP      SITEARCHEXP
297b39c5158Smillert
298b8851fccSafresh1    MAKE LIBPERL_A LIB PERL_SRC PERL_INC
299b8851fccSafresh1    PPM_INSTALL_EXEC PPM_UNINSTALL_EXEC
300b8851fccSafresh1    PPM_INSTALL_SCRIPT PPM_UNINSTALL_SCRIPT
301b8851fccSafresh1    /;
302b8851fccSafresh1
303b8851fccSafresh1    my @attrib_help = qw/
304b8851fccSafresh1
305b8851fccSafresh1    AUTHOR ABSTRACT ABSTRACT_FROM BINARY_LOCATION
306b8851fccSafresh1    C CAPI CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DISTVNAME
307b8851fccSafresh1    DL_FUNCS DL_VARS
308b8851fccSafresh1    EXCLUDE_EXT EXE_FILES FIRST_MAKEFILE
309b8851fccSafresh1    FULLPERLRUN FULLPERLRUNINST
310b8851fccSafresh1    FUNCLIST H IMPORTS
311b8851fccSafresh1
312b8851fccSafresh1    INC INCLUDE_EXT LDFROM LIBS LICENSE
313b8851fccSafresh1    LINKTYPE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET
314b39c5158Smillert    META_ADD META_MERGE MIN_PERL_VERSION BUILD_REQUIRES CONFIGURE_REQUIRES
315e5157e49Safresh1    MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NO_MYMETA NO_PACKLIST NO_PERLLOCAL
316e9ce3842Safresh1    NORECURS NO_VC OBJECT OPTIMIZE PERL_MALLOC_OK PERL PERLMAINCC PERLRUN
317e9ce3842Safresh1    PERLRUNINST PERL_CORE
318b8851fccSafresh1    PERM_DIR PERM_RW PERM_RWX MAGICXS
319b8851fccSafresh1    PL_FILES PM PM_FILTER PMLIBDIRS PMLIBPARENTDIRS POLLUTE
32056d68f1eSafresh1    PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ PUREPERL_ONLY
3219f11ffb7Safresh1    SIGN SKIP TEST_REQUIRES TYPEMAPS UNINST VERSION VERSION_FROM XS
3229f11ffb7Safresh1    XSBUILD XSMULTI XSOPT XSPROTOARG XS_VERSION
3239f11ffb7Safresh1    clean depend dist dynamic_lib linkext macro realclean tool_autosplit
324b39c5158Smillert
325b8851fccSafresh1    MAN1EXT MAN3EXT
326b8851fccSafresh1
327b39c5158Smillert    MACPERL_SRC MACPERL_LIB MACLIBS_68K MACLIBS_PPC MACLIBS_SC MACLIBS_MRC
328b39c5158Smillert    MACLIBS_ALL_68K MACLIBS_ALL_PPC MACLIBS_SHARED
329b39c5158Smillert        /;
330b8851fccSafresh1    push @attrib_help, @fs_macros;
331b8851fccSafresh1    @macro_fsentity{@fs_macros, @dep_macros} = (1) x (@fs_macros+@dep_macros);
332b8851fccSafresh1    @macro_dep{@dep_macros} = (1) x @dep_macros;
333b39c5158Smillert
334b39c5158Smillert    # IMPORTS is used under OS/2 and Win32
335b39c5158Smillert
336b39c5158Smillert    # @Overridable is close to @MM_Sections but not identical.  The
337b39c5158Smillert    # order is important. Many subroutines declare macros. These
338b39c5158Smillert    # depend on each other. Let's try to collect the macros up front,
339b39c5158Smillert    # then pasthru, then the rules.
340b39c5158Smillert
341b39c5158Smillert    # MM_Sections are the sections we have to call explicitly
342b39c5158Smillert    # in Overridable we have subroutines that are used indirectly
343b39c5158Smillert
344b39c5158Smillert
345b39c5158Smillert    @MM_Sections =
346b39c5158Smillert        qw(
347b39c5158Smillert
348b39c5158Smillert post_initialize const_config constants platform_constants
349b39c5158Smillert tool_autosplit tool_xsubpp tools_other
350b39c5158Smillert
351b39c5158Smillert makemakerdflt
352b39c5158Smillert
353b39c5158Smillert dist macro depend cflags const_loadlibs const_cccmd
354b39c5158Smillert post_constants
355b39c5158Smillert
356b39c5158Smillert pasthru
357b39c5158Smillert
358b39c5158Smillert special_targets
359b39c5158Smillert c_o xs_c xs_o
360e5157e49Safresh1 top_targets blibdirs linkext dlsyms dynamic_bs dynamic
361b39c5158Smillert dynamic_lib static static_lib manifypods processPL
362b39c5158Smillert installbin subdirs
363b39c5158Smillert clean_subdirs clean realclean_subdirs realclean
364b39c5158Smillert metafile signature
365b39c5158Smillert dist_basics dist_core distdir dist_test dist_ci distmeta distsignature
366b39c5158Smillert install force perldepend makefile staticmake test ppd
367b39c5158Smillert
368b39c5158Smillert          ); # loses section ordering
369b39c5158Smillert
370b39c5158Smillert    @Overridable = @MM_Sections;
371b39c5158Smillert    push @Overridable, qw[
372b39c5158Smillert
373b39c5158Smillert libscan makeaperl needs_linking
374b39c5158Smillert subdir_x test_via_harness test_via_script
375b39c5158Smillert
376b39c5158Smillert init_VERSION init_dist init_INST init_INSTALL init_DEST init_dirscan
377b39c5158Smillert init_PM init_MANPODS init_xs init_PERL init_DIRFILESEP init_linker
378b39c5158Smillert                         ];
379b39c5158Smillert
380b39c5158Smillert    push @MM_Sections, qw[
381b39c5158Smillert
382b39c5158Smillert pm_to_blib selfdocument
383b39c5158Smillert
384b39c5158Smillert                         ];
385b39c5158Smillert
386b39c5158Smillert    # Postamble needs to be the last that was always the case
387b39c5158Smillert    push @MM_Sections, "postamble";
388b39c5158Smillert    push @Overridable, "postamble";
389b39c5158Smillert
390b39c5158Smillert    # All sections are valid keys.
391b39c5158Smillert    @Recognized_Att_Keys{@MM_Sections} = (1) x @MM_Sections;
392b39c5158Smillert
393b39c5158Smillert    # we will use all these variables in the Makefile
394b39c5158Smillert    @Get_from_Config =
395b39c5158Smillert        qw(
396eac174f2Safresh1           ar cc cccdlflags ccdlflags cpprun dlext dlsrc exe_ext full_ar ld
397b39c5158Smillert           lddlflags ldflags libc lib_ext obj_ext osname osvers ranlib
398b39c5158Smillert           sitelibexp sitearchexp so
399b39c5158Smillert          );
400b39c5158Smillert
401b39c5158Smillert    # 5.5.3 doesn't have any concept of vendor libs
40256d68f1eSafresh1    push @Get_from_Config, qw( vendorarchexp vendorlibexp ) if "$]" >= 5.006;
403b39c5158Smillert
404b39c5158Smillert    foreach my $item (@attrib_help){
405b39c5158Smillert        $Recognized_Att_Keys{$item} = 1;
406b39c5158Smillert    }
407b39c5158Smillert    foreach my $item (@Get_from_Config) {
408b39c5158Smillert        $Recognized_Att_Keys{uc $item} = $Config{$item};
409b39c5158Smillert        print "Attribute '\U$item\E' => '$Config{$item}'\n"
410b39c5158Smillert            if ($Verbose >= 2);
411b39c5158Smillert    }
412b39c5158Smillert
413b39c5158Smillert    #
414b39c5158Smillert    # When we eval a Makefile.PL in a subdirectory, that one will ask
415b39c5158Smillert    # us (the parent) for the values and will prepend "..", so that
416b39c5158Smillert    # all files to be installed end up below OUR ./blib
417b39c5158Smillert    #
418b39c5158Smillert    @Prepend_parent = qw(
419b39c5158Smillert           INST_BIN INST_LIB INST_ARCHLIB INST_SCRIPT
420b39c5158Smillert           MAP_TARGET INST_MAN1DIR INST_MAN3DIR PERL_SRC
421b39c5158Smillert           PERL FULLPERL
422b39c5158Smillert    );
423b39c5158Smillert}
424b39c5158Smillert
4259f11ffb7Safresh1sub _has_cpan_meta_requirements {
4269f11ffb7Safresh1    return eval {
4279f11ffb7Safresh1      require CPAN::Meta::Requirements;
4289f11ffb7Safresh1      CPAN::Meta::Requirements->VERSION(2.130);
429eac174f2Safresh1      # Make sure vstrings can be handled. Some versions of CMR require B to
430eac174f2Safresh1      # do this, which won't be available in miniperl.
431eac174f2Safresh1      CPAN::Meta::Requirements->new->add_string_requirement('Module' => v1.2);
432eac174f2Safresh1      1;
4339f11ffb7Safresh1    };
4349f11ffb7Safresh1}
4359f11ffb7Safresh1
436b39c5158Smillertsub new {
437b39c5158Smillert    my($class,$self) = @_;
438b39c5158Smillert    my($key);
439b39c5158Smillert
44048950c12Ssthen    _convert_compat_attrs($self) if defined $self && $self;
44148950c12Ssthen
442b39c5158Smillert    # Store the original args passed to WriteMakefile()
443b39c5158Smillert    foreach my $k (keys %$self) {
444b39c5158Smillert        $self->{ARGS}{$k} = $self->{$k};
445b39c5158Smillert    }
446b39c5158Smillert
447b39c5158Smillert    $self = {} unless defined $self;
448b39c5158Smillert
449b39c5158Smillert    # Temporarily bless it into MM so it can be used as an
450b39c5158Smillert    # object.  It will be blessed into a temp package later.
451b39c5158Smillert    bless $self, "MM";
452b39c5158Smillert
45348950c12Ssthen    # Cleanup all the module requirement bits
4549f11ffb7Safresh1    my %key2cmr;
455e9ce3842Safresh1    for my $key (qw(PREREQ_PM BUILD_REQUIRES CONFIGURE_REQUIRES TEST_REQUIRES)) {
45648950c12Ssthen        $self->{$key}      ||= {};
4579f11ffb7Safresh1        if (_has_cpan_meta_requirements) {
4589f11ffb7Safresh1            my $cmr = CPAN::Meta::Requirements->from_string_hash(
4599f11ffb7Safresh1                $self->{$key},
4609f11ffb7Safresh1                {
4619f11ffb7Safresh1                  bad_version_hook => sub {
4629f11ffb7Safresh1                    #no warnings 'numeric'; # module doesn't use warnings
4639f11ffb7Safresh1                    my $fallback;
4649f11ffb7Safresh1                    if ( $_[0] =~ m!^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$! ) {
4659f11ffb7Safresh1                      $fallback = sprintf "%f", $_[0];
4669f11ffb7Safresh1                    } else {
4679f11ffb7Safresh1                      ($fallback) = $_[0] ? ($_[0] =~ /^([0-9.]+)/) : 0;
4689f11ffb7Safresh1                      $fallback += 0;
4699f11ffb7Safresh1                      carp "Unparsable version '$_[0]' for prerequisite $_[1] treated as $fallback";
47048950c12Ssthen                    }
4719f11ffb7Safresh1                    version->new($fallback);
4729f11ffb7Safresh1                  },
4739f11ffb7Safresh1                },
4749f11ffb7Safresh1            );
4759f11ffb7Safresh1            $self->{$key} = $cmr->as_string_hash;
4769f11ffb7Safresh1            $key2cmr{$key} = $cmr;
4779f11ffb7Safresh1        } else {
4789f11ffb7Safresh1            for my $module (sort keys %{ $self->{$key} }) {
4799f11ffb7Safresh1                my $version = $self->{$key}->{$module};
4809f11ffb7Safresh1                my $fallback = 0;
4819f11ffb7Safresh1                if (!defined($version) or !length($version)) {
4829f11ffb7Safresh1                    carp "Undefined requirement for $module treated as '0' (CPAN::Meta::Requirements not available)";
4839f11ffb7Safresh1                }
4849f11ffb7Safresh1                elsif ($version =~ /^\d+(?:\.\d+(?:_\d+)*)?$/) {
4859f11ffb7Safresh1                    next;
4869f11ffb7Safresh1                }
4879f11ffb7Safresh1                else {
4889f11ffb7Safresh1                    if ( $version =~ m!^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$! ) {
4899f11ffb7Safresh1                      $fallback = sprintf "%f", $version;
4909f11ffb7Safresh1                    } else {
4919f11ffb7Safresh1                      ($fallback) = $version ? ($version =~ /^([0-9.]+)/) : 0;
4929f11ffb7Safresh1                      $fallback += 0;
4939f11ffb7Safresh1                      carp "Unparsable version '$version' for prerequisite $module treated as $fallback (CPAN::Meta::Requirements not available)";
4949f11ffb7Safresh1                    }
4959f11ffb7Safresh1                }
4969f11ffb7Safresh1                $self->{$key}->{$module} = $fallback;
4979f11ffb7Safresh1            }
4989f11ffb7Safresh1        }
4999f11ffb7Safresh1    }
50048950c12Ssthen
501b39c5158Smillert    if ("@ARGV" =~ /\bPREREQ_PRINT\b/) {
502b39c5158Smillert        $self->_PREREQ_PRINT;
503b39c5158Smillert    }
504b39c5158Smillert
505b39c5158Smillert    # PRINT_PREREQ is RedHatism.
506b39c5158Smillert    if ("@ARGV" =~ /\bPRINT_PREREQ\b/) {
507b39c5158Smillert        $self->_PRINT_PREREQ;
508b39c5158Smillert   }
509b39c5158Smillert
510e9ce3842Safresh1    print "MakeMaker (v$VERSION)\n" if $Verbose;
511b8851fccSafresh1    if (-f "MANIFEST" && ! -f "Makefile" && ! $UNDER_CORE){
512b39c5158Smillert        check_manifest();
513b39c5158Smillert    }
514b39c5158Smillert
515b39c5158Smillert    check_hints($self);
516b39c5158Smillert
517eac174f2Safresh1    if ( $self->{MIN_PERL_VERSION}) {
518eac174f2Safresh1        my $perl_version = $self->{MIN_PERL_VERSION};
519eac174f2Safresh1        if (ref $perl_version) {
520eac174f2Safresh1            # assume a version object
521eac174f2Safresh1        }
522eac174f2Safresh1        else {
523eac174f2Safresh1            $perl_version = eval {
524e5157e49Safresh1                local $SIG{__WARN__} = sub {
525e5157e49Safresh1                    # simulate "use warnings FATAL => 'all'" for vintage perls
526e5157e49Safresh1                    die @_;
527e5157e49Safresh1                };
528*e0680481Safresh1                my $v = version->new($perl_version);
529*e0680481Safresh1                # we care about parse issues, not numify warnings
530*e0680481Safresh1                no warnings;
531*e0680481Safresh1                $v->numify;
532e5157e49Safresh1            };
533eac174f2Safresh1            $perl_version =~ tr/_//d
534eac174f2Safresh1                if defined $perl_version;
535e5157e49Safresh1        }
536e5157e49Safresh1
537eac174f2Safresh1        if (!defined $perl_version) {
538eac174f2Safresh1            # should this be a warning?
539eac174f2Safresh1            die sprintf <<'END', $self->{MIN_PERL_VERSION};
540eac174f2Safresh1MakeMaker FATAL: MIN_PERL_VERSION (%s) is not in a recognized format.
541b39c5158SmillertRecommended is a quoted numerical value like '5.005' or '5.008001'.
542b39c5158SmillertEND
543b39c5158Smillert        }
544eac174f2Safresh1        elsif ($perl_version > "$]") {
545eac174f2Safresh1            my $message = sprintf <<'END', $perl_version, $];
546eac174f2Safresh1Perl version %s or higher required. We run %s.
547b39c5158SmillertEND
548eac174f2Safresh1            if ($self->{PREREQ_FATAL}) {
549eac174f2Safresh1                die "MakeMaker FATAL: $message";
550b39c5158Smillert            }
551b39c5158Smillert            else {
552eac174f2Safresh1                warn "Warning: $message";
553b39c5158Smillert            }
554b39c5158Smillert        }
555b39c5158Smillert
556eac174f2Safresh1        $self->{MIN_PERL_VERSION} = $perl_version;
557eac174f2Safresh1    }
558eac174f2Safresh1
559b39c5158Smillert    my %configure_att;         # record &{$self->{CONFIGURE}} attributes
560b39c5158Smillert    my(%initial_att) = %$self; # record initial attributes
561b39c5158Smillert
562b39c5158Smillert    my(%unsatisfied) = ();
5639f11ffb7Safresh1    my %prereq2version;
5649f11ffb7Safresh1    my $cmr;
5659f11ffb7Safresh1    if (_has_cpan_meta_requirements) {
5669f11ffb7Safresh1        $cmr = CPAN::Meta::Requirements->new;
5679f11ffb7Safresh1        for my $key (qw(PREREQ_PM BUILD_REQUIRES CONFIGURE_REQUIRES TEST_REQUIRES)) {
5689f11ffb7Safresh1            $cmr->add_requirements($key2cmr{$key}) if $key2cmr{$key};
5699f11ffb7Safresh1        }
5709f11ffb7Safresh1        foreach my $prereq ($cmr->required_modules) {
5719f11ffb7Safresh1            $prereq2version{$prereq} = $cmr->requirements_for_module($prereq);
5729f11ffb7Safresh1        }
5739f11ffb7Safresh1    } else {
5749f11ffb7Safresh1        for my $key (qw(PREREQ_PM BUILD_REQUIRES CONFIGURE_REQUIRES TEST_REQUIRES)) {
5759f11ffb7Safresh1            next unless my $module2version = $self->{$key};
5769f11ffb7Safresh1            $prereq2version{$_} = $module2version->{$_} for keys %$module2version;
5779f11ffb7Safresh1        }
5789f11ffb7Safresh1    }
5799f11ffb7Safresh1    foreach my $prereq (sort keys %prereq2version) {
5809f11ffb7Safresh1        my $required_version = $prereq2version{$prereq};
581b39c5158Smillert
582b39c5158Smillert        my $pr_version = 0;
583e5157e49Safresh1        my $installed_file;
584e5157e49Safresh1
585e5157e49Safresh1        if ( $prereq eq 'perl' ) {
586e5157e49Safresh1          if ( defined $required_version && $required_version =~ /^v?[\d_\.]+$/
587e5157e49Safresh1               || $required_version !~ /^v?[\d_\.]+$/ ) {
588e5157e49Safresh1            require version;
589b8851fccSafresh1            my $normal = eval { version->new( $required_version ) };
590e5157e49Safresh1            $required_version = $normal if defined $normal;
591e5157e49Safresh1          }
592e5157e49Safresh1          $installed_file = $prereq;
593e5157e49Safresh1          $pr_version = $];
594e5157e49Safresh1        }
595e5157e49Safresh1        else {
596e5157e49Safresh1          $installed_file = MM->_installed_file_for_module($prereq);
597b39c5158Smillert          $pr_version = MM->parse_version($installed_file) if $installed_file;
598b39c5158Smillert          $pr_version = 0 if $pr_version eq 'undef';
5999f11ffb7Safresh1          if ( !eval { version->new( $pr_version ); 1 } ) {
6009f11ffb7Safresh1            #no warnings 'numeric'; # module doesn't use warnings
6019f11ffb7Safresh1            my $fallback;
6029f11ffb7Safresh1            if ( $pr_version =~ m!^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$! ) {
6039f11ffb7Safresh1              $fallback = sprintf '%f', $pr_version;
6049f11ffb7Safresh1            } else {
6059f11ffb7Safresh1              ($fallback) = $pr_version ? ($pr_version =~ /^([0-9.]+)/) : 0;
6069f11ffb7Safresh1              $fallback += 0;
6079f11ffb7Safresh1              carp "Unparsable version '$pr_version' for installed prerequisite $prereq treated as $fallback";
6089f11ffb7Safresh1            }
6099f11ffb7Safresh1            $pr_version = $fallback;
6109f11ffb7Safresh1          }
611e5157e49Safresh1        }
612b39c5158Smillert
613b39c5158Smillert        # convert X.Y_Z alpha version #s to X.YZ for easier comparisons
614b39c5158Smillert        $pr_version =~ s/(\d+)\.(\d+)_(\d+)/$1.$2$3/;
615b39c5158Smillert
616b39c5158Smillert        if (!$installed_file) {
617b39c5158Smillert            warn sprintf "Warning: prerequisite %s %s not found.\n",
618b39c5158Smillert              $prereq, $required_version
61948950c12Ssthen                   unless $self->{PREREQ_FATAL}
620b8851fccSafresh1                       or $UNDER_CORE;
621b39c5158Smillert
622b39c5158Smillert            $unsatisfied{$prereq} = 'not installed';
623b39c5158Smillert        }
6249f11ffb7Safresh1        elsif (
6259f11ffb7Safresh1            $cmr
6269f11ffb7Safresh1                ? !$cmr->accepts_module($prereq, $pr_version)
6279f11ffb7Safresh1                : $required_version > $pr_version
6289f11ffb7Safresh1        ) {
629b39c5158Smillert            warn sprintf "Warning: prerequisite %s %s not found. We have %s.\n",
630b39c5158Smillert              $prereq, $required_version, ($pr_version || 'unknown version')
63148950c12Ssthen                  unless $self->{PREREQ_FATAL}
632b8851fccSafresh1                       or $UNDER_CORE;
633b39c5158Smillert
6349f11ffb7Safresh1            $unsatisfied{$prereq} = $required_version || 'unknown version' ;
635b39c5158Smillert        }
636b39c5158Smillert    }
637b39c5158Smillert
638b39c5158Smillert    if (%unsatisfied && $self->{PREREQ_FATAL}){
639b39c5158Smillert        my $failedprereqs = join "\n", map {"    $_ $unsatisfied{$_}"}
640eac174f2Safresh1                            sort { lc $a cmp lc $b } keys %unsatisfied;
641b39c5158Smillert        die <<"END";
642b39c5158SmillertMakeMaker FATAL: prerequisites not found.
643b39c5158Smillert$failedprereqs
644b39c5158Smillert
645b39c5158SmillertPlease install these modules first and rerun 'perl Makefile.PL'.
646b39c5158SmillertEND
647b39c5158Smillert    }
648b39c5158Smillert
649b39c5158Smillert    if (defined $self->{CONFIGURE}) {
650b39c5158Smillert        if (ref $self->{CONFIGURE} eq 'CODE') {
651b39c5158Smillert            %configure_att = %{&{$self->{CONFIGURE}}};
65248950c12Ssthen            _convert_compat_attrs(\%configure_att);
653b39c5158Smillert            $self = { %$self, %configure_att };
654b39c5158Smillert        } else {
65548950c12Ssthen            croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
656b39c5158Smillert        }
657b39c5158Smillert    }
658b39c5158Smillert
659b39c5158Smillert    my $newclass = ++$PACKNAME;
660b39c5158Smillert    local @Parent = @Parent;    # Protect against non-local exits
661b39c5158Smillert    {
662b39c5158Smillert        print "Blessing Object into class [$newclass]\n" if $Verbose>=2;
663b39c5158Smillert        mv_all_methods("MY",$newclass);
664b39c5158Smillert        bless $self, $newclass;
665b39c5158Smillert        push @Parent, $self;
666b39c5158Smillert        require ExtUtils::MY;
667b39c5158Smillert
668b39c5158Smillert        no strict 'refs';   ## no critic;
669b39c5158Smillert        @{"$newclass\:\:ISA"} = 'MM';
670b39c5158Smillert    }
671b39c5158Smillert
672b39c5158Smillert    if (defined $Parent[-2]){
673b39c5158Smillert        $self->{PARENT} = $Parent[-2];
674b39c5158Smillert        for my $key (@Prepend_parent) {
675b39c5158Smillert            next unless defined $self->{PARENT}{$key};
676b39c5158Smillert
677b39c5158Smillert            # Don't stomp on WriteMakefile() args.
678b39c5158Smillert            next if defined $self->{ARGS}{$key} and
679b39c5158Smillert                    $self->{ARGS}{$key} eq $self->{$key};
680b39c5158Smillert
681b39c5158Smillert            $self->{$key} = $self->{PARENT}{$key};
682b39c5158Smillert
683b8851fccSafresh1            if ($Is_VMS && $key =~ /PERL$/) {
684b39c5158Smillert                # PERL or FULLPERL will be a command verb or even a
685b39c5158Smillert                # command with an argument instead of a full file
686b39c5158Smillert                # specification under VMS.  So, don't turn the command
687b39c5158Smillert                # into a filespec, but do add a level to the path of
688b39c5158Smillert                # the argument if not already absolute.
689b39c5158Smillert                my @cmd = split /\s+/, $self->{$key};
690b39c5158Smillert                $cmd[1] = $self->catfile('[-]',$cmd[1])
691b39c5158Smillert                  unless (@cmd < 2) || $self->file_name_is_absolute($cmd[1]);
692b39c5158Smillert                $self->{$key} = join(' ', @cmd);
693b8851fccSafresh1            } else {
694b8851fccSafresh1                my $value = $self->{$key};
695b8851fccSafresh1                # not going to test in FS so only stripping start
69656d68f1eSafresh1                $value =~ s/"// if $key =~ /PERL$/ and $self->is_make_type('dmake');
697b8851fccSafresh1                $value =~ s/^"// if $key =~ /PERL$/;
698b8851fccSafresh1                $value = $self->catdir("..", $value)
699b8851fccSafresh1                  unless $self->file_name_is_absolute($value);
700b8851fccSafresh1                $value = qq{"$value} if $key =~ /PERL$/;
701b8851fccSafresh1                $self->{$key} = $value;
702b39c5158Smillert            }
703b39c5158Smillert        }
704b39c5158Smillert        if ($self->{PARENT}) {
705b39c5158Smillert            $self->{PARENT}->{CHILDREN}->{$newclass} = $self;
70656d68f1eSafresh1            foreach my $opt (qw(POLLUTE PERL_CORE LINKTYPE AR FULL_AR CC CCFLAGS
70756d68f1eSafresh1                                OPTIMIZE LD LDDLFLAGS LDFLAGS PERL_ARCHLIB DESTDIR)) {
708b39c5158Smillert                if (exists $self->{PARENT}->{$opt}
709b39c5158Smillert                    and not exists $self->{$opt})
710b39c5158Smillert                    {
711b39c5158Smillert                        # inherit, but only if already unspecified
712b39c5158Smillert                        $self->{$opt} = $self->{PARENT}->{$opt};
713b39c5158Smillert                    }
714b39c5158Smillert            }
715b39c5158Smillert        }
716b39c5158Smillert        my @fm = grep /^FIRST_MAKEFILE=/, @ARGV;
717b39c5158Smillert        parse_args($self,@fm) if @fm;
718e5157e49Safresh1    }
719e5157e49Safresh1    else {
720e5157e49Safresh1        parse_args($self, _shellwords($ENV{PERL_MM_OPT} || ''),@ARGV);
721b39c5158Smillert    }
722b39c5158Smillert
723e5157e49Safresh1    # RT#91540 PREREQ_FATAL not recognized on command line
724e5157e49Safresh1    if (%unsatisfied && $self->{PREREQ_FATAL}){
725e5157e49Safresh1        my $failedprereqs = join "\n", map {"    $_ $unsatisfied{$_}"}
726eac174f2Safresh1                            sort { lc $a cmp lc $b } keys %unsatisfied;
727e5157e49Safresh1        die <<"END";
728e5157e49Safresh1MakeMaker FATAL: prerequisites not found.
729e5157e49Safresh1$failedprereqs
730e5157e49Safresh1
731e5157e49Safresh1Please install these modules first and rerun 'perl Makefile.PL'.
732e5157e49Safresh1END
733e5157e49Safresh1    }
734b39c5158Smillert
735b39c5158Smillert    $self->{NAME} ||= $self->guess_name;
736b39c5158Smillert
737e5157e49Safresh1    warn "Warning: NAME must be a package name\n"
738e5157e49Safresh1      unless $self->{NAME} =~ m!^[A-Z_a-z][0-9A-Z_a-z]*(?:::[0-9A-Z_a-z]+)*$!;
739e5157e49Safresh1
740b39c5158Smillert    ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
741b39c5158Smillert
742b39c5158Smillert    $self->init_MAKE;
743b39c5158Smillert    $self->init_main;
744b39c5158Smillert    $self->init_VERSION;
745b39c5158Smillert    $self->init_dist;
746b39c5158Smillert    $self->init_INST;
747b39c5158Smillert    $self->init_INSTALL;
748b39c5158Smillert    $self->init_DEST;
749b39c5158Smillert    $self->init_dirscan;
750b39c5158Smillert    $self->init_PM;
751b39c5158Smillert    $self->init_MANPODS;
752b39c5158Smillert    $self->init_xs;
753b39c5158Smillert    $self->init_PERL;
754b39c5158Smillert    $self->init_DIRFILESEP;
755b39c5158Smillert    $self->init_linker;
756b39c5158Smillert    $self->init_ABSTRACT;
757b39c5158Smillert
758b39c5158Smillert    $self->arch_check(
759b39c5158Smillert        $INC{'Config.pm'},
760b39c5158Smillert        $self->catfile($Config{'archlibexp'}, "Config.pm")
761b39c5158Smillert    );
762b39c5158Smillert
76348950c12Ssthen    $self->init_tools();
764b39c5158Smillert    $self->init_others();
765b39c5158Smillert    $self->init_platform();
766b39c5158Smillert    $self->init_PERM();
7679f11ffb7Safresh1    my @args = @ARGV;
7689f11ffb7Safresh1    @args = map { Encode::decode(locale => $_) } @args if $CAN_DECODE;
7699f11ffb7Safresh1    my($argv) = neatvalue(\@args);
770b39c5158Smillert    $argv =~ s/^\[/(/;
771b39c5158Smillert    $argv =~ s/\]$/)/;
772b39c5158Smillert
773b39c5158Smillert    push @{$self->{RESULT}}, <<END;
774b39c5158Smillert# This Makefile is for the $self->{NAME} extension to perl.
775b39c5158Smillert#
776b39c5158Smillert# It was generated automatically by MakeMaker version
777b39c5158Smillert# $VERSION (Revision: $Revision) from the contents of
778b39c5158Smillert# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
779b39c5158Smillert#
780b39c5158Smillert#       ANY CHANGES MADE HERE WILL BE LOST!
781b39c5158Smillert#
782b39c5158Smillert#   MakeMaker ARGV: $argv
783b39c5158Smillert#
784b39c5158SmillertEND
785b39c5158Smillert
786b39c5158Smillert    push @{$self->{RESULT}}, $self->_MakeMaker_Parameters_section(\%initial_att);
787b39c5158Smillert
788b39c5158Smillert    if (defined $self->{CONFIGURE}) {
789b39c5158Smillert       push @{$self->{RESULT}}, <<END;
790b39c5158Smillert
791b39c5158Smillert#   MakeMaker 'CONFIGURE' Parameters:
792b39c5158SmillertEND
793b39c5158Smillert        if (scalar(keys %configure_att) > 0) {
794b39c5158Smillert            foreach my $key (sort keys %configure_att){
795b39c5158Smillert               next if $key eq 'ARGS';
796b39c5158Smillert               my($v) = neatvalue($configure_att{$key});
797b39c5158Smillert               $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
798b39c5158Smillert               $v =~ tr/\n/ /s;
799b39c5158Smillert               push @{$self->{RESULT}}, "#     $key => $v";
800b39c5158Smillert            }
801b39c5158Smillert        }
802b39c5158Smillert        else
803b39c5158Smillert        {
804b39c5158Smillert           push @{$self->{RESULT}}, "# no values returned";
805b39c5158Smillert        }
806b39c5158Smillert        undef %configure_att;  # free memory
807b39c5158Smillert    }
808b39c5158Smillert
809b39c5158Smillert    # turn the SKIP array into a SKIPHASH hash
810b39c5158Smillert    for my $skip (@{$self->{SKIP} || []}) {
811b39c5158Smillert        $self->{SKIPHASH}{$skip} = 1;
812b39c5158Smillert    }
813b39c5158Smillert    delete $self->{SKIP}; # free memory
814b39c5158Smillert
815b39c5158Smillert    if ($self->{PARENT}) {
816b39c5158Smillert        for (qw/install dist dist_basics dist_core distdir dist_test dist_ci/) {
817b39c5158Smillert            $self->{SKIPHASH}{$_} = 1;
818b39c5158Smillert        }
819b39c5158Smillert    }
820b39c5158Smillert
821b39c5158Smillert    # We run all the subdirectories now. They don't have much to query
822b39c5158Smillert    # from the parent, but the parent has to query them: if they need linking!
823b39c5158Smillert    unless ($self->{NORECURS}) {
824b39c5158Smillert        $self->eval_in_subdirs if @{$self->{DIR}};
825b39c5158Smillert    }
826b39c5158Smillert
827b39c5158Smillert    foreach my $section ( @MM_Sections ){
828b39c5158Smillert        # Support for new foo_target() methods.
829b39c5158Smillert        my $method = $section;
830b39c5158Smillert        $method .= '_target' unless $self->can($method);
831b39c5158Smillert
832b39c5158Smillert        print "Processing Makefile '$section' section\n" if ($Verbose >= 2);
833b39c5158Smillert        my($skipit) = $self->skipcheck($section);
834b39c5158Smillert        if ($skipit){
835b39c5158Smillert            push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
836b39c5158Smillert        } else {
837b39c5158Smillert            my(%a) = %{$self->{$section} || {}};
838b39c5158Smillert            push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
839b39c5158Smillert            push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
840b39c5158Smillert            push @{$self->{RESULT}}, $self->maketext_filter(
841b39c5158Smillert                $self->$method( %a )
842b39c5158Smillert            );
843b39c5158Smillert        }
844b39c5158Smillert    }
845b39c5158Smillert
846b39c5158Smillert    push @{$self->{RESULT}}, "\n# End.";
847b39c5158Smillert
848b39c5158Smillert    $self;
849b39c5158Smillert}
850b39c5158Smillert
851b39c5158Smillertsub WriteEmptyMakefile {
85248950c12Ssthen    croak "WriteEmptyMakefile: Need an even number of args" if @_ % 2;
853b39c5158Smillert
854b39c5158Smillert    my %att = @_;
8559f11ffb7Safresh1    $att{DIR} = [] unless $att{DIR}; # don't recurse by default
856b39c5158Smillert    my $self = MM->new(\%att);
857b39c5158Smillert
858b39c5158Smillert    my $new = $self->{MAKEFILE};
859b39c5158Smillert    my $old = $self->{MAKEFILE_OLD};
860b39c5158Smillert    if (-f $old) {
861b39c5158Smillert        _unlink($old) or warn "unlink $old: $!";
862b39c5158Smillert    }
863b39c5158Smillert    if ( -f $new ) {
864b39c5158Smillert        _rename($new, $old) or warn "rename $new => $old: $!"
865b39c5158Smillert    }
866b39c5158Smillert    open my $mfh, '>', $new or die "open $new for write: $!";
867b39c5158Smillert    print $mfh <<'EOP';
868b39c5158Smillertall :
869b39c5158Smillert
8709f11ffb7Safresh1manifypods :
8719f11ffb7Safresh1
8729f11ffb7Safresh1subdirs :
8739f11ffb7Safresh1
8749f11ffb7Safresh1dynamic :
8759f11ffb7Safresh1
8769f11ffb7Safresh1static :
8779f11ffb7Safresh1
878b39c5158Smillertclean :
879b39c5158Smillert
880b39c5158Smillertinstall :
881b39c5158Smillert
882b39c5158Smillertmakemakerdflt :
883b39c5158Smillert
884b39c5158Smillerttest :
885b39c5158Smillert
8869f11ffb7Safresh1test_dynamic :
8879f11ffb7Safresh1
8889f11ffb7Safresh1test_static :
8899f11ffb7Safresh1
890b39c5158SmillertEOP
891b39c5158Smillert    close $mfh or die "close $new for write: $!";
892b39c5158Smillert}
893b39c5158Smillert
894b39c5158Smillert
895b39c5158Smillert=begin private
896b39c5158Smillert
897b39c5158Smillert=head3 _installed_file_for_module
898b39c5158Smillert
899b39c5158Smillert  my $file = MM->_installed_file_for_module($module);
900b39c5158Smillert
901b39c5158SmillertReturn the first installed .pm $file associated with the $module.  The
902b39c5158Smillertone which will show up when you C<use $module>.
903b39c5158Smillert
904b39c5158Smillert$module is something like "strict" or "Test::More".
905b39c5158Smillert
906b39c5158Smillert=end private
907b39c5158Smillert
908b39c5158Smillert=cut
909b39c5158Smillert
910b39c5158Smillertsub _installed_file_for_module {
911b39c5158Smillert    my $class  = shift;
912b39c5158Smillert    my $prereq = shift;
913b39c5158Smillert
914b39c5158Smillert    my $file = "$prereq.pm";
915b39c5158Smillert    $file =~ s{::}{/}g;
916b39c5158Smillert
917b39c5158Smillert    my $path;
918b39c5158Smillert    for my $dir (@INC) {
919b39c5158Smillert        my $tmp = File::Spec->catfile($dir, $file);
920b39c5158Smillert        if ( -r $tmp ) {
921b39c5158Smillert            $path = $tmp;
922b39c5158Smillert            last;
923b39c5158Smillert        }
924b39c5158Smillert    }
925b39c5158Smillert
926b39c5158Smillert    return $path;
927b39c5158Smillert}
928b39c5158Smillert
929b39c5158Smillert
930b39c5158Smillert# Extracted from MakeMaker->new so we can test it
931b39c5158Smillertsub _MakeMaker_Parameters_section {
932b39c5158Smillert    my $self = shift;
933b39c5158Smillert    my $att  = shift;
934b39c5158Smillert
935b39c5158Smillert    my @result = <<'END';
936b39c5158Smillert#   MakeMaker Parameters:
937b39c5158SmillertEND
938b39c5158Smillert
939b39c5158Smillert    foreach my $key (sort keys %$att){
940b39c5158Smillert        next if $key eq 'ARGS';
941b8851fccSafresh1        my $v;
942b39c5158Smillert        if ($key eq 'PREREQ_PM') {
943b39c5158Smillert            # CPAN.pm takes prereqs from this field in 'Makefile'
944b39c5158Smillert            # and does not know about BUILD_REQUIRES
945e9ce3842Safresh1            $v = neatvalue({
946e9ce3842Safresh1                %{ $att->{PREREQ_PM} || {} },
947e9ce3842Safresh1                %{ $att->{BUILD_REQUIRES} || {} },
948e9ce3842Safresh1                %{ $att->{TEST_REQUIRES} || {} },
949e9ce3842Safresh1            });
950b39c5158Smillert        } else {
951b39c5158Smillert            $v = neatvalue($att->{$key});
952b39c5158Smillert        }
953b39c5158Smillert
954b39c5158Smillert        $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
955b39c5158Smillert        $v =~ tr/\n/ /s;
956b39c5158Smillert        push @result, "#     $key => $v";
957b39c5158Smillert    }
958b39c5158Smillert
959b39c5158Smillert    return @result;
960b39c5158Smillert}
961b39c5158Smillert
962e5157e49Safresh1# _shellwords and _parseline borrowed from Text::ParseWords
963e5157e49Safresh1sub _shellwords {
964e5157e49Safresh1    my (@lines) = @_;
965e5157e49Safresh1    my @allwords;
966e5157e49Safresh1
967e5157e49Safresh1    foreach my $line (@lines) {
968e5157e49Safresh1      $line =~ s/^\s+//;
969e5157e49Safresh1      my @words = _parse_line('\s+', 0, $line);
970e5157e49Safresh1      pop @words if (@words and !defined $words[-1]);
971e5157e49Safresh1      return() unless (@words || !length($line));
972e5157e49Safresh1      push(@allwords, @words);
973e5157e49Safresh1    }
974e5157e49Safresh1    return(@allwords);
975e5157e49Safresh1}
976e5157e49Safresh1
977e5157e49Safresh1sub _parse_line {
978e5157e49Safresh1    my($delimiter, $keep, $line) = @_;
979e5157e49Safresh1    my($word, @pieces);
980e5157e49Safresh1
981e5157e49Safresh1    no warnings 'uninitialized';  # we will be testing undef strings
982e5157e49Safresh1
983e5157e49Safresh1    while (length($line)) {
984e5157e49Safresh1        # This pattern is optimised to be stack conservative on older perls.
985e5157e49Safresh1        # Do not refactor without being careful and testing it on very long strings.
986e5157e49Safresh1        # See Perl bug #42980 for an example of a stack busting input.
987e5157e49Safresh1        $line =~ s/^
988e5157e49Safresh1                    (?:
989e5157e49Safresh1                        # double quoted string
990e5157e49Safresh1                        (")                             # $quote
991e5157e49Safresh1                        ((?>[^\\"]*(?:\\.[^\\"]*)*))"   # $quoted
992e5157e49Safresh1        | # --OR--
993e5157e49Safresh1                        # singe quoted string
994e5157e49Safresh1                        (')                             # $quote
995e5157e49Safresh1                        ((?>[^\\']*(?:\\.[^\\']*)*))'   # $quoted
996e5157e49Safresh1                    |   # --OR--
997e5157e49Safresh1                        # unquoted string
998e5157e49Safresh1            (                               # $unquoted
999e5157e49Safresh1                            (?:\\.|[^\\"'])*?
1000e5157e49Safresh1                        )
1001e5157e49Safresh1                        # followed by
1002e5157e49Safresh1            (                               # $delim
1003e5157e49Safresh1                            \Z(?!\n)                    # EOL
1004e5157e49Safresh1                        |   # --OR--
1005e5157e49Safresh1                            (?-x:$delimiter)            # delimiter
1006e5157e49Safresh1                        |   # --OR--
1007e5157e49Safresh1                            (?!^)(?=["'])               # a quote
1008e5157e49Safresh1                        )
1009e5157e49Safresh1        )//xs or return;    # extended layout
1010e5157e49Safresh1        my ($quote, $quoted, $unquoted, $delim) = (($1 ? ($1,$2) : ($3,$4)), $5, $6);
1011e5157e49Safresh1
1012e5157e49Safresh1
1013e5157e49Safresh1  return() unless( defined($quote) || length($unquoted) || length($delim));
1014e5157e49Safresh1
1015e5157e49Safresh1        if ($keep) {
1016e5157e49Safresh1      $quoted = "$quote$quoted$quote";
1017e5157e49Safresh1  }
1018e5157e49Safresh1        else {
1019e5157e49Safresh1      $unquoted =~ s/\\(.)/$1/sg;
1020e5157e49Safresh1      if (defined $quote) {
1021e5157e49Safresh1    $quoted =~ s/\\(.)/$1/sg if ($quote eq '"');
1022e5157e49Safresh1    #$quoted =~ s/\\([\\'])/$1/g if ( $PERL_SINGLE_QUOTE && $quote eq "'");
1023e5157e49Safresh1            }
1024e5157e49Safresh1  }
1025e5157e49Safresh1        $word .= substr($line, 0, 0); # leave results tainted
1026e5157e49Safresh1        $word .= defined $quote ? $quoted : $unquoted;
1027e5157e49Safresh1
1028e5157e49Safresh1        if (length($delim)) {
1029e5157e49Safresh1            push(@pieces, $word);
1030e5157e49Safresh1            push(@pieces, $delim) if ($keep eq 'delimiters');
1031e5157e49Safresh1            undef $word;
1032e5157e49Safresh1        }
1033e5157e49Safresh1        if (!length($line)) {
1034e5157e49Safresh1            push(@pieces, $word);
1035e5157e49Safresh1  }
1036e5157e49Safresh1    }
1037e5157e49Safresh1    return(@pieces);
1038e5157e49Safresh1}
1039b39c5158Smillert
1040b39c5158Smillertsub check_manifest {
1041eac174f2Safresh1    print STDOUT "Checking if your kit is complete...\n";
1042b39c5158Smillert    require ExtUtils::Manifest;
1043b39c5158Smillert    # avoid warning
1044b39c5158Smillert    $ExtUtils::Manifest::Quiet = $ExtUtils::Manifest::Quiet = 1;
1045b39c5158Smillert    my(@missed) = ExtUtils::Manifest::manicheck();
1046b39c5158Smillert    if (@missed) {
1047e9ce3842Safresh1        print "Warning: the following files are missing in your kit:\n";
1048b39c5158Smillert        print "\t", join "\n\t", @missed;
1049e9ce3842Safresh1        print "\n";
1050e9ce3842Safresh1        print "Please inform the author.\n";
1051b39c5158Smillert    } else {
1052e9ce3842Safresh1        print "Looks good\n";
1053b39c5158Smillert    }
1054b39c5158Smillert}
1055b39c5158Smillert
1056b39c5158Smillertsub parse_args{
1057b39c5158Smillert    my($self, @args) = @_;
1058b8851fccSafresh1    @args = map { Encode::decode(locale => $_) } @args if $CAN_DECODE;
1059b39c5158Smillert    foreach (@args) {
1060b39c5158Smillert        unless (m/(.*?)=(.*)/) {
1061b39c5158Smillert            ++$Verbose if m/^verb/;
1062b39c5158Smillert            next;
1063b39c5158Smillert        }
1064b39c5158Smillert        my($name, $value) = ($1, $2);
1065b39c5158Smillert        if ($value =~ m/^~(\w+)?/) { # tilde with optional username
1066b39c5158Smillert            $value =~ s [^~(\w*)]
1067b39c5158Smillert                [$1 ?
1068b39c5158Smillert                 ((getpwnam($1))[7] || "~$1") :
1069b39c5158Smillert                 (getpwuid($>))[7]
1070b39c5158Smillert                 ]ex;
1071b39c5158Smillert        }
1072b39c5158Smillert
1073b39c5158Smillert        # Remember the original args passed it.  It will be useful later.
1074b39c5158Smillert        $self->{ARGS}{uc $name} = $self->{uc $name} = $value;
1075b39c5158Smillert    }
1076b39c5158Smillert
1077b39c5158Smillert    # catch old-style 'potential_libs' and inform user how to 'upgrade'
1078b39c5158Smillert    if (defined $self->{potential_libs}){
1079b39c5158Smillert        my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
1080b39c5158Smillert        if ($self->{potential_libs}){
1081e9ce3842Safresh1            print "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
1082b39c5158Smillert        } else {
1083e9ce3842Safresh1            print "$msg deleted.\n";
1084b39c5158Smillert        }
1085b39c5158Smillert        $self->{LIBS} = [$self->{potential_libs}];
1086b39c5158Smillert        delete $self->{potential_libs};
1087b39c5158Smillert    }
1088b39c5158Smillert    # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
1089b39c5158Smillert    if (defined $self->{ARMAYBE}){
1090b39c5158Smillert        my($armaybe) = $self->{ARMAYBE};
1091e9ce3842Safresh1        print "ARMAYBE => '$armaybe' should be changed to:\n",
1092b39c5158Smillert                        "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
1093b39c5158Smillert        my(%dl) = %{$self->{dynamic_lib} || {}};
1094b39c5158Smillert        $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
1095b39c5158Smillert        delete $self->{ARMAYBE};
1096b39c5158Smillert    }
1097b39c5158Smillert    if (defined $self->{LDTARGET}){
1098e9ce3842Safresh1        print "LDTARGET should be changed to LDFROM\n";
1099b39c5158Smillert        $self->{LDFROM} = $self->{LDTARGET};
1100b39c5158Smillert        delete $self->{LDTARGET};
1101b39c5158Smillert    }
1102b39c5158Smillert    # Turn a DIR argument on the command line into an array
1103b39c5158Smillert    if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
1104b39c5158Smillert        # So they can choose from the command line, which extensions they want
1105b39c5158Smillert        # the grep enables them to have some colons too much in case they
1106b39c5158Smillert        # have to build a list with the shell
1107b39c5158Smillert        $self->{DIR} = [grep $_, split ":", $self->{DIR}];
1108b39c5158Smillert    }
1109b39c5158Smillert    # Turn a INCLUDE_EXT argument on the command line into an array
1110b39c5158Smillert    if (defined $self->{INCLUDE_EXT} && ref \$self->{INCLUDE_EXT} eq 'SCALAR') {
1111b39c5158Smillert        $self->{INCLUDE_EXT} = [grep $_, split '\s+', $self->{INCLUDE_EXT}];
1112b39c5158Smillert    }
1113b39c5158Smillert    # Turn a EXCLUDE_EXT argument on the command line into an array
1114b39c5158Smillert    if (defined $self->{EXCLUDE_EXT} && ref \$self->{EXCLUDE_EXT} eq 'SCALAR') {
1115b39c5158Smillert        $self->{EXCLUDE_EXT} = [grep $_, split '\s+', $self->{EXCLUDE_EXT}];
1116b39c5158Smillert    }
1117b39c5158Smillert
1118b39c5158Smillert    foreach my $mmkey (sort keys %$self){
1119b39c5158Smillert        next if $mmkey eq 'ARGS';
1120e9ce3842Safresh1        print "  $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose;
1121e9ce3842Safresh1        print "'$mmkey' is not a known MakeMaker parameter name.\n"
1122b39c5158Smillert            unless exists $Recognized_Att_Keys{$mmkey};
1123b39c5158Smillert    }
1124b39c5158Smillert    $| = 1 if $Verbose;
1125b39c5158Smillert}
1126b39c5158Smillert
1127b39c5158Smillertsub check_hints {
1128b39c5158Smillert    my($self) = @_;
1129b39c5158Smillert    # We allow extension-specific hints files.
1130b39c5158Smillert
1131b39c5158Smillert    require File::Spec;
1132b39c5158Smillert    my $curdir = File::Spec->curdir;
1133b39c5158Smillert
1134b39c5158Smillert    my $hint_dir = File::Spec->catdir($curdir, "hints");
1135b39c5158Smillert    return unless -d $hint_dir;
1136b39c5158Smillert
1137b39c5158Smillert    # First we look for the best hintsfile we have
1138b39c5158Smillert    my($hint)="${^O}_$Config{osvers}";
1139b39c5158Smillert    $hint =~ s/\./_/g;
1140b39c5158Smillert    $hint =~ s/_$//;
1141b39c5158Smillert    return unless $hint;
1142b39c5158Smillert
1143b39c5158Smillert    # Also try without trailing minor version numbers.
1144b39c5158Smillert    while (1) {
1145b39c5158Smillert        last if -f File::Spec->catfile($hint_dir, "$hint.pl");  # found
1146b39c5158Smillert    } continue {
1147b39c5158Smillert        last unless $hint =~ s/_[^_]*$//; # nothing to cut off
1148b39c5158Smillert    }
1149b39c5158Smillert    my $hint_file = File::Spec->catfile($hint_dir, "$hint.pl");
1150b39c5158Smillert
1151b39c5158Smillert    return unless -f $hint_file;    # really there
1152b39c5158Smillert
1153b39c5158Smillert    _run_hintfile($self, $hint_file);
1154b39c5158Smillert}
1155b39c5158Smillert
1156b39c5158Smillertsub _run_hintfile {
1157*e0680481Safresh1    our $self;
1158*e0680481Safresh1    local($self) = shift;       # make $self available to the hint file.
1159*e0680481Safresh1    my($hint_file) = shift;
1160b39c5158Smillert
1161b39c5158Smillert    local($@, $!);
11629f11ffb7Safresh1    print "Processing hints file $hint_file\n" if $Verbose;
1163b39c5158Smillert
1164*e0680481Safresh1    # Just in case the ./ isn't on the hint file, which File::Spec can
1165*e0680481Safresh1    # often strip off, we bung the curdir into @INC
1166*e0680481Safresh1    local @INC = (File::Spec->curdir, @INC);
1167*e0680481Safresh1    my $ret = do $hint_file;
1168*e0680481Safresh1    if( !defined $ret ) {
1169*e0680481Safresh1        my $error = $@ || $!;
1170*e0680481Safresh1        warn $error;
1171b39c5158Smillert    }
1172b39c5158Smillert}
1173b39c5158Smillert
1174b39c5158Smillertsub mv_all_methods {
1175b39c5158Smillert    my($from,$to) = @_;
1176b39c5158Smillert    local $SIG{__WARN__} = sub {
1177b39c5158Smillert        # can't use 'no warnings redefined', 5.6 only
1178b39c5158Smillert        warn @_ unless $_[0] =~ /^Subroutine .* redefined/
1179b39c5158Smillert    };
1180b39c5158Smillert    foreach my $method (@Overridable) {
1181b39c5158Smillert        next unless defined &{"${from}::$method"};
1182b39c5158Smillert        no strict 'refs';   ## no critic
1183b39c5158Smillert        *{"${to}::$method"} = \&{"${from}::$method"};
1184b39c5158Smillert
1185b39c5158Smillert        # If we delete a method, then it will be undefined and cannot
1186b39c5158Smillert        # be called.  But as long as we have Makefile.PLs that rely on
1187b39c5158Smillert        # %MY:: being intact, we have to fill the hole with an
1188b39c5158Smillert        # inheriting method:
1189b39c5158Smillert
1190b39c5158Smillert        {
1191b39c5158Smillert            package MY;
1192b39c5158Smillert            my $super = "SUPER::".$method;
1193b39c5158Smillert            *{$method} = sub {
1194b39c5158Smillert                shift->$super(@_);
1195b39c5158Smillert            };
1196b39c5158Smillert        }
1197b39c5158Smillert    }
1198b39c5158Smillert}
1199b39c5158Smillert
1200b39c5158Smillertsub skipcheck {
1201b39c5158Smillert    my($self) = shift;
1202b39c5158Smillert    my($section) = @_;
12039f11ffb7Safresh1    return 'skipped' if $section eq 'metafile' && $UNDER_CORE;
1204b39c5158Smillert    if ($section eq 'dynamic') {
1205e9ce3842Safresh1        print "Warning (non-fatal): Target 'dynamic' depends on targets ",
1206b39c5158Smillert        "in skipped section 'dynamic_bs'\n"
1207b39c5158Smillert            if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
1208e9ce3842Safresh1        print "Warning (non-fatal): Target 'dynamic' depends on targets ",
1209b39c5158Smillert        "in skipped section 'dynamic_lib'\n"
1210b39c5158Smillert            if $self->{SKIPHASH}{dynamic_lib} && $Verbose;
1211b39c5158Smillert    }
1212b39c5158Smillert    if ($section eq 'dynamic_lib') {
1213e9ce3842Safresh1        print "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
1214b39c5158Smillert        "targets in skipped section 'dynamic_bs'\n"
1215b39c5158Smillert            if $self->{SKIPHASH}{dynamic_bs} && $Verbose;
1216b39c5158Smillert    }
1217b39c5158Smillert    if ($section eq 'static') {
1218e9ce3842Safresh1        print "Warning (non-fatal): Target 'static' depends on targets ",
1219b39c5158Smillert        "in skipped section 'static_lib'\n"
1220b39c5158Smillert            if $self->{SKIPHASH}{static_lib} && $Verbose;
1221b39c5158Smillert    }
1222b39c5158Smillert    return 'skipped' if $self->{SKIPHASH}{$section};
1223b39c5158Smillert    return '';
1224b39c5158Smillert}
1225b39c5158Smillert
12269f11ffb7Safresh1# returns filehandle, dies on fail. :raw so no :crlf
12279f11ffb7Safresh1sub open_for_writing {
12289f11ffb7Safresh1    my ($file) = @_;
12299f11ffb7Safresh1    open my $fh ,">", $file or die "Unable to open $file: $!";
12309f11ffb7Safresh1    my @layers = ':raw';
12319f11ffb7Safresh1    push @layers, join ' ', ':encoding(locale)' if $CAN_DECODE;
12329f11ffb7Safresh1    binmode $fh, join ' ', @layers;
12339f11ffb7Safresh1    $fh;
12349f11ffb7Safresh1}
12359f11ffb7Safresh1
1236b39c5158Smillertsub flush {
1237b39c5158Smillert    my $self = shift;
1238b39c5158Smillert
1239b39c5158Smillert    my $finalname = $self->{MAKEFILE};
1240eac174f2Safresh1    printf STDOUT "Generating a %s %s\n", $self->make_type, $finalname if $Verbose || !$self->{PARENT};
1241eac174f2Safresh1    print STDOUT "Writing $finalname for $self->{NAME}\n" if $Verbose || !$self->{PARENT};
1242b39c5158Smillert
1243b39c5158Smillert    unlink($finalname, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ());
1244b39c5158Smillert
12459f11ffb7Safresh1    write_file_via_tmp($finalname, $self->{RESULT});
12469f11ffb7Safresh1
12479f11ffb7Safresh1    # Write MYMETA.yml to communicate metadata up to the CPAN clients
1248eac174f2Safresh1    print STDOUT "Writing MYMETA.yml and MYMETA.json\n"
12499f11ffb7Safresh1      if !$self->{NO_MYMETA} and $self->write_mymeta( $self->mymeta );
12509f11ffb7Safresh1
12519f11ffb7Safresh1    # save memory
12529f11ffb7Safresh1    if ($self->{PARENT} && !$self->{_KEEP_AFTER_FLUSH}) {
12539f11ffb7Safresh1        my %keep = map { ($_ => 1) } qw(NEEDS_LINKING HAS_LINK_CODE);
12549f11ffb7Safresh1        delete $self->{$_} for grep !$keep{$_}, keys %$self;
12559f11ffb7Safresh1    }
12569f11ffb7Safresh1
12579f11ffb7Safresh1    system("$Config::Config{eunicefix} $finalname")
12589f11ffb7Safresh1      if $Config::Config{eunicefix} ne ":";
12599f11ffb7Safresh1
12609f11ffb7Safresh1    return;
12619f11ffb7Safresh1}
12629f11ffb7Safresh1
12639f11ffb7Safresh1sub write_file_via_tmp {
12649f11ffb7Safresh1    my ($finalname, $contents) = @_;
12659f11ffb7Safresh1    my $fh = open_for_writing("MakeMaker.tmp");
12669f11ffb7Safresh1    die "write_file_via_tmp: 2nd arg must be ref" unless ref $contents;
12679f11ffb7Safresh1    for my $chunk (@$contents) {
1268b8851fccSafresh1        my $to_write = $chunk;
1269*e0680481Safresh1        $to_write = '' unless defined $to_write;
127056d68f1eSafresh1        utf8::encode $to_write if !$CAN_DECODE && "$]" > 5.008;
1271b8851fccSafresh1        print $fh "$to_write\n" or die "Can't write to MakeMaker.tmp: $!";
1272b39c5158Smillert    }
12739f11ffb7Safresh1    close $fh or die "Can't write to MakeMaker.tmp: $!";
1274b39c5158Smillert    _rename("MakeMaker.tmp", $finalname) or
1275b39c5158Smillert      warn "rename MakeMaker.tmp => $finalname: $!";
12769f11ffb7Safresh1    chmod 0644, $finalname if !$Is_VMS;
12779f11ffb7Safresh1    return;
1278b39c5158Smillert}
1279b39c5158Smillert
1280b39c5158Smillert# This is a rename for OS's where the target must be unlinked first.
1281b39c5158Smillertsub _rename {
1282b39c5158Smillert    my($src, $dest) = @_;
12839f11ffb7Safresh1    _unlink($dest);
1284b39c5158Smillert    return rename $src, $dest;
1285b39c5158Smillert}
1286b39c5158Smillert
1287b39c5158Smillert# This is an unlink for OS's where the target must be writable first.
1288b39c5158Smillertsub _unlink {
1289b39c5158Smillert    my @files = @_;
1290b39c5158Smillert    chmod 0666, @files;
1291b39c5158Smillert    return unlink @files;
1292b39c5158Smillert}
1293b39c5158Smillert
1294b39c5158Smillert
1295b39c5158Smillert# The following mkbootstrap() is only for installations that are calling
1296b39c5158Smillert# the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
1297b39c5158Smillert# writes Makefiles, that use ExtUtils::Mkbootstrap directly.
1298b39c5158Smillertsub mkbootstrap {
1299b39c5158Smillert    die <<END;
1300b39c5158Smillert!!! Your Makefile has been built such a long time ago, !!!
1301b39c5158Smillert!!! that is unlikely to work with current MakeMaker.   !!!
1302b39c5158Smillert!!! Please rebuild your Makefile                       !!!
1303b39c5158SmillertEND
1304b39c5158Smillert}
1305b39c5158Smillert
1306b39c5158Smillert# Ditto for mksymlists() as of MakeMaker 5.17
1307b39c5158Smillertsub mksymlists {
1308b39c5158Smillert    die <<END;
1309b39c5158Smillert!!! Your Makefile has been built such a long time ago, !!!
1310b39c5158Smillert!!! that is unlikely to work with current MakeMaker.   !!!
1311b39c5158Smillert!!! Please rebuild your Makefile                       !!!
1312b39c5158SmillertEND
1313b39c5158Smillert}
1314b39c5158Smillert
1315b39c5158Smillertsub neatvalue {
1316b39c5158Smillert    my($v) = @_;
1317b39c5158Smillert    return "undef" unless defined $v;
1318b39c5158Smillert    my($t) = ref $v;
1319b39c5158Smillert    return "q[$v]" unless $t;
1320b39c5158Smillert    if ($t eq 'ARRAY') {
1321b39c5158Smillert        my(@m, @neat);
1322b39c5158Smillert        push @m, "[";
1323b39c5158Smillert        foreach my $elem (@$v) {
1324b39c5158Smillert            push @neat, "q[$elem]";
1325b39c5158Smillert        }
1326b39c5158Smillert        push @m, join ", ", @neat;
1327b39c5158Smillert        push @m, "]";
1328b39c5158Smillert        return join "", @m;
1329b39c5158Smillert    }
1330b8851fccSafresh1    return $v unless $t eq 'HASH';
1331b39c5158Smillert    my(@m, $key, $val);
1332b8851fccSafresh1    for my $key (sort keys %$v) {
1333b39c5158Smillert        last unless defined $key; # cautious programming in case (undef,undef) is true
1334b8851fccSafresh1        push @m,"$key=>".neatvalue($v->{$key});
1335b39c5158Smillert    }
1336b39c5158Smillert    return "{ ".join(', ',@m)." }";
1337b39c5158Smillert}
1338b39c5158Smillert
1339b39c5158Smillertsub selfdocument {
1340b39c5158Smillert    my($self) = @_;
1341b39c5158Smillert    my(@m);
1342b39c5158Smillert    if ($Verbose){
1343b39c5158Smillert        push @m, "\n# Full list of MakeMaker attribute values:";
1344b39c5158Smillert        foreach my $key (sort keys %$self){
1345b39c5158Smillert            next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
1346b39c5158Smillert            my($v) = neatvalue($self->{$key});
1347b39c5158Smillert            $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
1348b39c5158Smillert            $v =~ tr/\n/ /s;
1349b39c5158Smillert            push @m, "# $key => $v";
1350b39c5158Smillert        }
1351b39c5158Smillert    }
13529f11ffb7Safresh1    # added here as selfdocument is not overridable
13539f11ffb7Safresh1    push @m, <<'EOF';
13549f11ffb7Safresh1
13559f11ffb7Safresh1# here so even if top_targets is overridden, these will still be defined
13569f11ffb7Safresh1# gmake will silently still work if any are .PHONY-ed but nmake won't
13579f11ffb7Safresh1EOF
13589f11ffb7Safresh1    push @m, join "\n", map "$_ ::\n\t\$(NOECHO) \$(NOOP)\n",
13599f11ffb7Safresh1        # config is so manifypods won't puke if no subdirs
13609f11ffb7Safresh1        grep !$self->{SKIPHASH}{$_},
13619f11ffb7Safresh1        qw(static dynamic config);
1362b39c5158Smillert    join "\n", @m;
1363b39c5158Smillert}
1364b39c5158Smillert
1365b39c5158Smillert1;
1366b39c5158Smillert
1367b39c5158Smillert__END__
1368b39c5158Smillert
1369b39c5158Smillert=head1 NAME
1370b39c5158Smillert
1371b39c5158SmillertExtUtils::MakeMaker - Create a module Makefile
1372b39c5158Smillert
1373b39c5158Smillert=head1 SYNOPSIS
1374b39c5158Smillert
1375b39c5158Smillert  use ExtUtils::MakeMaker;
1376b39c5158Smillert
1377e9ce3842Safresh1  WriteMakefile(
1378e9ce3842Safresh1      NAME              => "Foo::Bar",
1379e9ce3842Safresh1      VERSION_FROM      => "lib/Foo/Bar.pm",
1380e9ce3842Safresh1  );
1381b39c5158Smillert
1382b39c5158Smillert=head1 DESCRIPTION
1383b39c5158Smillert
1384b39c5158SmillertThis utility is designed to write a Makefile for an extension module
1385b39c5158Smillertfrom a Makefile.PL. It is based on the Makefile.SH model provided by
1386b39c5158SmillertAndy Dougherty and the perl5-porters.
1387b39c5158Smillert
1388b39c5158SmillertIt splits the task of generating the Makefile into several subroutines
1389b39c5158Smillertthat can be individually overridden.  Each subroutine returns the text
1390b39c5158Smillertit wishes to have written to the Makefile.
1391b39c5158Smillert
1392e9ce3842Safresh1As there are various Make programs with incompatible syntax, which
1393e9ce3842Safresh1use operating system shells, again with incompatible syntax, it is
1394e9ce3842Safresh1important for users of this module to know which flavour of Make
1395e9ce3842Safresh1a Makefile has been written for so they'll use the correct one and
1396e9ce3842Safresh1won't have to face the possibly bewildering errors resulting from
1397e9ce3842Safresh1using the wrong one.
1398e9ce3842Safresh1
1399e9ce3842Safresh1On POSIX systems, that program will likely be GNU Make; on Microsoft
1400b8851fccSafresh1Windows, it will be either Microsoft NMake, DMake or GNU Make.
1401e9ce3842Safresh1See the section on the L</"MAKE"> parameter for details.
1402e9ce3842Safresh1
1403b8851fccSafresh1ExtUtils::MakeMaker (EUMM) is object oriented. Each directory below the current
1404b39c5158Smillertdirectory that contains a Makefile.PL is treated as a separate
1405b39c5158Smillertobject. This makes it possible to write an unlimited number of
1406b39c5158SmillertMakefiles with a single invocation of WriteMakefile().
1407b39c5158Smillert
1408b8851fccSafresh1All inputs to WriteMakefile are Unicode characters, not just octets. EUMM
1409b8851fccSafresh1seeks to handle all of these correctly. It is currently still not possible
1410b8851fccSafresh1to portably use Unicode characters in module names, because this requires
1411b8851fccSafresh1Perl to handle Unicode filenames, which is not yet the case on Windows.
1412b8851fccSafresh1
141356d68f1eSafresh1See L<ExtUtils::MakeMaker::FAQ> for details of the design and usage.
141456d68f1eSafresh1
1415b39c5158Smillert=head2 How To Write A Makefile.PL
1416b39c5158Smillert
1417e9ce3842Safresh1See L<ExtUtils::MakeMaker::Tutorial>.
1418b39c5158Smillert
1419b39c5158SmillertThe long answer is the rest of the manpage :-)
1420b39c5158Smillert
1421b39c5158Smillert=head2 Default Makefile Behaviour
1422b39c5158Smillert
1423b39c5158SmillertThe generated Makefile enables the user of the extension to invoke
1424b39c5158Smillert
1425b39c5158Smillert  perl Makefile.PL # optionally "perl Makefile.PL verbose"
1426b39c5158Smillert  make
1427b39c5158Smillert  make test        # optionally set TEST_VERBOSE=1
1428b39c5158Smillert  make install     # See below
1429b39c5158Smillert
1430b39c5158SmillertThe Makefile to be produced may be altered by adding arguments of the
1431b39c5158Smillertform C<KEY=VALUE>. E.g.
1432b39c5158Smillert
1433b39c5158Smillert  perl Makefile.PL INSTALL_BASE=~
1434b39c5158Smillert
1435b39c5158SmillertOther interesting targets in the generated Makefile are
1436b39c5158Smillert
1437b39c5158Smillert  make config     # to check if the Makefile is up-to-date
1438b39c5158Smillert  make clean      # delete local temp files (Makefile gets renamed)
1439b39c5158Smillert  make realclean  # delete derived files (including ./blib)
1440b39c5158Smillert  make ci         # check in all the files in the MANIFEST file
1441b39c5158Smillert  make dist       # see below the Distribution Support section
1442b39c5158Smillert
1443b39c5158Smillert=head2 make test
1444b39c5158Smillert
1445b39c5158SmillertMakeMaker checks for the existence of a file named F<test.pl> in the
1446e9ce3842Safresh1current directory, and if it exists it executes the script with the
1447b39c5158Smillertproper set of perl C<-I> options.
1448b39c5158Smillert
1449b39c5158SmillertMakeMaker also checks for any files matching glob("t/*.t"). It will
1450b39c5158Smillertexecute all matching files in alphabetical order via the
1451b39c5158SmillertL<Test::Harness> module with the C<-I> switches set correctly.
1452b39c5158Smillert
14539f11ffb7Safresh1You can also organize your tests within subdirectories in the F<t/> directory.
14549f11ffb7Safresh1To do so, use the F<test> directive in your I<Makefile.PL>. For example, if you
14559f11ffb7Safresh1had tests in:
14569f11ffb7Safresh1
14579f11ffb7Safresh1    t/foo
14589f11ffb7Safresh1    t/foo/bar
14599f11ffb7Safresh1
14609f11ffb7Safresh1You could tell make to run tests in both of those directories with the
14619f11ffb7Safresh1following directives:
14629f11ffb7Safresh1
14639f11ffb7Safresh1    test => {TESTS => 't/*/*.t t/*/*/*.t'}
14649f11ffb7Safresh1    test => {TESTS => 't/foo/*.t t/foo/bar/*.t'}
14659f11ffb7Safresh1
14669f11ffb7Safresh1The first will run all test files in all first-level subdirectories and all
14679f11ffb7Safresh1subdirectories they contain. The second will run tests in only the F<t/foo>
14689f11ffb7Safresh1and F<t/foo/bar>.
14699f11ffb7Safresh1
1470b39c5158SmillertIf you'd like to see the raw output of your tests, set the
1471b39c5158SmillertC<TEST_VERBOSE> variable to true.
1472b39c5158Smillert
1473b39c5158Smillert  make test TEST_VERBOSE=1
1474b39c5158Smillert
1475e5157e49Safresh1If you want to run particular test files, set the C<TEST_FILES> variable.
1476e5157e49Safresh1It is possible to use globbing with this mechanism.
1477e5157e49Safresh1
1478e5157e49Safresh1  make test TEST_FILES='t/foobar.t t/dagobah*.t'
1479e5157e49Safresh1
1480b8851fccSafresh1Windows users who are using C<nmake> should note that due to a bug in C<nmake>,
1481b8851fccSafresh1when specifying C<TEST_FILES> you must use back-slashes instead of forward-slashes.
1482b8851fccSafresh1
1483b8851fccSafresh1  nmake test TEST_FILES='t\foobar.t t\dagobah*.t'
1484b8851fccSafresh1
1485b39c5158Smillert=head2 make testdb
1486b39c5158Smillert
1487b39c5158SmillertA useful variation of the above is the target C<testdb>. It runs the
1488b39c5158Smillerttest under the Perl debugger (see L<perldebug>). If the file
1489b39c5158SmillertF<test.pl> exists in the current directory, it is used for the test.
1490b39c5158Smillert
1491b39c5158SmillertIf you want to debug some other testfile, set the C<TEST_FILE> variable
1492b39c5158Smillertthusly:
1493b39c5158Smillert
1494b39c5158Smillert  make testdb TEST_FILE=t/mytest.t
1495b39c5158Smillert
1496b39c5158SmillertBy default the debugger is called using C<-d> option to perl. If you
1497b39c5158Smillertwant to specify some other option, set the C<TESTDB_SW> variable:
1498b39c5158Smillert
1499b39c5158Smillert  make testdb TESTDB_SW=-Dx
1500b39c5158Smillert
1501b39c5158Smillert=head2 make install
1502b39c5158Smillert
1503b39c5158Smillertmake alone puts all relevant files into directories that are named by
1504b39c5158Smillertthe macros INST_LIB, INST_ARCHLIB, INST_SCRIPT, INST_MAN1DIR and
1505b39c5158SmillertINST_MAN3DIR.  All these default to something below ./blib if you are
1506b39c5158SmillertI<not> building below the perl source directory. If you I<are>
1507b39c5158Smillertbuilding below the perl source, INST_LIB and INST_ARCHLIB default to
1508b39c5158Smillert../../lib, and INST_SCRIPT is not defined.
1509b39c5158Smillert
1510b39c5158SmillertThe I<install> target of the generated Makefile copies the files found
1511b39c5158Smillertbelow each of the INST_* directories to their INSTALL*
1512b39c5158Smillertcounterparts. Which counterparts are chosen depends on the setting of
1513b39c5158SmillertINSTALLDIRS according to the following table:
1514b39c5158Smillert
1515b39c5158Smillert                                 INSTALLDIRS set to
1516b39c5158Smillert                           perl        site          vendor
1517b39c5158Smillert
1518b39c5158Smillert                 PERLPREFIX      SITEPREFIX          VENDORPREFIX
1519b39c5158Smillert  INST_ARCHLIB   INSTALLARCHLIB  INSTALLSITEARCH     INSTALLVENDORARCH
1520b39c5158Smillert  INST_LIB       INSTALLPRIVLIB  INSTALLSITELIB      INSTALLVENDORLIB
1521b39c5158Smillert  INST_BIN       INSTALLBIN      INSTALLSITEBIN      INSTALLVENDORBIN
1522b39c5158Smillert  INST_SCRIPT    INSTALLSCRIPT   INSTALLSITESCRIPT   INSTALLVENDORSCRIPT
1523b39c5158Smillert  INST_MAN1DIR   INSTALLMAN1DIR  INSTALLSITEMAN1DIR  INSTALLVENDORMAN1DIR
1524b39c5158Smillert  INST_MAN3DIR   INSTALLMAN3DIR  INSTALLSITEMAN3DIR  INSTALLVENDORMAN3DIR
1525b39c5158Smillert
1526b39c5158SmillertThe INSTALL... macros in turn default to their %Config
1527b39c5158Smillert($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
1528b39c5158Smillert
1529b39c5158SmillertYou can check the values of these variables on your system with
1530b39c5158Smillert
1531b39c5158Smillert    perl '-V:install.*'
1532b39c5158Smillert
1533b39c5158SmillertAnd to check the sequence in which the library directories are
1534b39c5158Smillertsearched by perl, run
1535b39c5158Smillert
1536b39c5158Smillert    perl -le 'print join $/, @INC'
1537b39c5158Smillert
1538b39c5158SmillertSometimes older versions of the module you're installing live in other
1539b39c5158Smillertdirectories in @INC.  Because Perl loads the first version of a module it
1540b39c5158Smillertfinds, not the newest, you might accidentally get one of these older
1541b39c5158Smillertversions even after installing a brand new version.  To delete I<all other
1542b39c5158Smillertversions of the module you're installing> (not simply older ones) set the
1543b39c5158SmillertC<UNINST> variable.
1544b39c5158Smillert
1545b39c5158Smillert    make install UNINST=1
1546b39c5158Smillert
1547b39c5158Smillert
1548b39c5158Smillert=head2 INSTALL_BASE
1549b39c5158Smillert
1550b39c5158SmillertINSTALL_BASE can be passed into Makefile.PL to change where your
1551b39c5158Smillertmodule will be installed.  INSTALL_BASE is more like what everyone
1552b39c5158Smillertelse calls "prefix" than PREFIX is.
1553b39c5158Smillert
1554b39c5158SmillertTo have everything installed in your home directory, do the following.
1555b39c5158Smillert
1556b39c5158Smillert    # Unix users, INSTALL_BASE=~ works fine
1557b39c5158Smillert    perl Makefile.PL INSTALL_BASE=/path/to/your/home/dir
1558b39c5158Smillert
1559b39c5158SmillertLike PREFIX, it sets several INSTALL* attributes at once.  Unlike
1560b39c5158SmillertPREFIX it is easy to predict where the module will end up.  The
1561b39c5158Smillertinstallation pattern looks like this:
1562b39c5158Smillert
1563b39c5158Smillert    INSTALLARCHLIB     INSTALL_BASE/lib/perl5/$Config{archname}
1564b39c5158Smillert    INSTALLPRIVLIB     INSTALL_BASE/lib/perl5
1565b39c5158Smillert    INSTALLBIN         INSTALL_BASE/bin
1566b39c5158Smillert    INSTALLSCRIPT      INSTALL_BASE/bin
1567b39c5158Smillert    INSTALLMAN1DIR     INSTALL_BASE/man/man1
1568b39c5158Smillert    INSTALLMAN3DIR     INSTALL_BASE/man/man3
1569b39c5158Smillert
1570b39c5158SmillertINSTALL_BASE in MakeMaker and C<--install_base> in Module::Build (as
1571b39c5158Smillertof 0.28) install to the same location.  If you want MakeMaker and
1572b39c5158SmillertModule::Build to install to the same location simply set INSTALL_BASE
1573b39c5158Smillertand C<--install_base> to the same location.
1574b39c5158Smillert
1575b39c5158SmillertINSTALL_BASE was added in 6.31.
1576b39c5158Smillert
1577b39c5158Smillert
1578b39c5158Smillert=head2 PREFIX and LIB attribute
1579b39c5158Smillert
1580b39c5158SmillertPREFIX and LIB can be used to set several INSTALL* attributes in one
1581b39c5158Smillertgo.  Here's an example for installing into your home directory.
1582b39c5158Smillert
1583b39c5158Smillert    # Unix users, PREFIX=~ works fine
1584b39c5158Smillert    perl Makefile.PL PREFIX=/path/to/your/home/dir
1585b39c5158Smillert
1586b39c5158SmillertThis will install all files in the module under your home directory,
1587b39c5158Smillertwith man pages and libraries going into an appropriate place (usually
1588b39c5158Smillert~/man and ~/lib).  How the exact location is determined is complicated
1589b39c5158Smillertand depends on how your Perl was configured.  INSTALL_BASE works more
1590b39c5158Smillertlike what other build systems call "prefix" than PREFIX and we
1591b39c5158Smillertrecommend you use that instead.
1592b39c5158Smillert
1593b39c5158SmillertAnother way to specify many INSTALL directories with a single
1594b39c5158Smillertparameter is LIB.
1595b39c5158Smillert
1596b39c5158Smillert    perl Makefile.PL LIB=~/lib
1597b39c5158Smillert
1598b39c5158SmillertThis will install the module's architecture-independent files into
1599b39c5158Smillert~/lib, the architecture-dependent files into ~/lib/$archname.
1600b39c5158Smillert
1601b39c5158SmillertNote, that in both cases the tilde expansion is done by MakeMaker, not
1602b39c5158Smillertby perl by default, nor by make.
1603b39c5158Smillert
1604b39c5158SmillertConflicts between parameters LIB, PREFIX and the various INSTALL*
1605b39c5158Smillertarguments are resolved so that:
1606b39c5158Smillert
1607b39c5158Smillert=over 4
1608b39c5158Smillert
1609b39c5158Smillert=item *
1610b39c5158Smillert
1611b39c5158Smillertsetting LIB overrides any setting of INSTALLPRIVLIB, INSTALLARCHLIB,
1612b39c5158SmillertINSTALLSITELIB, INSTALLSITEARCH (and they are not affected by PREFIX);
1613b39c5158Smillert
1614b39c5158Smillert=item *
1615b39c5158Smillert
1616b39c5158Smillertwithout LIB, setting PREFIX replaces the initial C<$Config{prefix}>
1617b39c5158Smillertpart of those INSTALL* arguments, even if the latter are explicitly
1618b39c5158Smillertset (but are set to still start with C<$Config{prefix}>).
1619b39c5158Smillert
1620b39c5158Smillert=back
1621b39c5158Smillert
1622b39c5158SmillertIf the user has superuser privileges, and is not working on AFS or
1623b39c5158Smillertrelatives, then the defaults for INSTALLPRIVLIB, INSTALLARCHLIB,
1624b39c5158SmillertINSTALLSCRIPT, etc. will be appropriate, and this incantation will be
1625b39c5158Smillertthe best:
1626b39c5158Smillert
1627b39c5158Smillert    perl Makefile.PL;
1628b39c5158Smillert    make;
1629b39c5158Smillert    make test
1630b39c5158Smillert    make install
1631b39c5158Smillert
1632e9ce3842Safresh1make install by default writes some documentation of what has been
1633b39c5158Smillertdone into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature
1634b39c5158Smillertcan be bypassed by calling make pure_install.
1635b39c5158Smillert
1636b39c5158Smillert=head2 AFS users
1637b39c5158Smillert
1638b39c5158Smillertwill have to specify the installation directories as these most
1639b39c5158Smillertprobably have changed since perl itself has been installed. They will
1640b39c5158Smillerthave to do this by calling
1641b39c5158Smillert
1642b39c5158Smillert    perl Makefile.PL INSTALLSITELIB=/afs/here/today \
1643b39c5158Smillert        INSTALLSCRIPT=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages
1644b39c5158Smillert    make
1645b39c5158Smillert
1646b39c5158SmillertBe careful to repeat this procedure every time you recompile an
1647b39c5158Smillertextension, unless you are sure the AFS installation directories are
1648b39c5158Smillertstill valid.
1649b39c5158Smillert
1650b39c5158Smillert=head2 Static Linking of a new Perl Binary
1651b39c5158Smillert
1652b39c5158SmillertAn extension that is built with the above steps is ready to use on
1653b39c5158Smillertsystems supporting dynamic loading. On systems that do not support
1654b39c5158Smillertdynamic loading, any newly created extension has to be linked together
1655b39c5158Smillertwith the available resources. MakeMaker supports the linking process
1656b39c5158Smillertby creating appropriate targets in the Makefile whenever an extension
1657b39c5158Smillertis built. You can invoke the corresponding section of the makefile with
1658b39c5158Smillert
1659b39c5158Smillert    make perl
1660b39c5158Smillert
1661b39c5158SmillertThat produces a new perl binary in the current directory with all
1662b39c5158Smillertextensions linked in that can be found in INST_ARCHLIB, SITELIBEXP,
1663b39c5158Smillertand PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on
1664e9ce3842Safresh1UNIX, this is called F<Makefile.aperl> (may be system dependent). If you
1665e9ce3842Safresh1want to force the creation of a new perl, it is recommended that you
1666e9ce3842Safresh1delete this F<Makefile.aperl>, so the directories are searched through
1667b39c5158Smillertfor linkable libraries again.
1668b39c5158Smillert
1669b39c5158SmillertThe binary can be installed into the directory where perl normally
1670b39c5158Smillertresides on your machine with
1671b39c5158Smillert
1672b39c5158Smillert    make inst_perl
1673b39c5158Smillert
1674b39c5158SmillertTo produce a perl binary with a different name than C<perl>, either say
1675b39c5158Smillert
1676b39c5158Smillert    perl Makefile.PL MAP_TARGET=myperl
1677b39c5158Smillert    make myperl
1678b39c5158Smillert    make inst_perl
1679b39c5158Smillert
1680b39c5158Smillertor say
1681b39c5158Smillert
1682b39c5158Smillert    perl Makefile.PL
1683b39c5158Smillert    make myperl MAP_TARGET=myperl
1684b39c5158Smillert    make inst_perl MAP_TARGET=myperl
1685b39c5158Smillert
1686b39c5158SmillertIn any case you will be prompted with the correct invocation of the
1687b39c5158SmillertC<inst_perl> target that installs the new binary into INSTALLBIN.
1688b39c5158Smillert
1689e9ce3842Safresh1make inst_perl by default writes some documentation of what has been
1690b39c5158Smillertdone into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This
1691b39c5158Smillertcan be bypassed by calling make pure_inst_perl.
1692b39c5158Smillert
1693b39c5158SmillertWarning: the inst_perl: target will most probably overwrite your
1694b39c5158Smillertexisting perl binary. Use with care!
1695b39c5158Smillert
1696b39c5158SmillertSometimes you might want to build a statically linked perl although
1697b39c5158Smillertyour system supports dynamic loading. In this case you may explicitly
1698b39c5158Smillertset the linktype with the invocation of the Makefile.PL or make:
1699b39c5158Smillert
1700b39c5158Smillert    perl Makefile.PL LINKTYPE=static    # recommended
1701b39c5158Smillert
1702b39c5158Smillertor
1703b39c5158Smillert
1704b39c5158Smillert    make LINKTYPE=static                # works on most systems
1705b39c5158Smillert
1706b39c5158Smillert=head2 Determination of Perl Library and Installation Locations
1707b39c5158Smillert
1708b39c5158SmillertMakeMaker needs to know, or to guess, where certain things are
1709b39c5158Smillertlocated.  Especially INST_LIB and INST_ARCHLIB (where to put the files
1710b39c5158Smillertduring the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read
1711b39c5158Smillertexisting modules from), and PERL_INC (header files and C<libperl*.*>).
1712b39c5158Smillert
1713b39c5158SmillertExtensions may be built either using the contents of the perl source
1714b39c5158Smillertdirectory tree or from the installed perl library. The recommended way
1715b39c5158Smillertis to build extensions after you have run 'make install' on perl
1716b39c5158Smillertitself. You can do that in any directory on your hard disk that is not
1717b39c5158Smillertbelow the perl source tree. The support for extensions below the ext
1718b39c5158Smillertdirectory of the perl distribution is only good for the standard
1719b39c5158Smillertextensions that come with perl.
1720b39c5158Smillert
1721b39c5158SmillertIf an extension is being built below the C<ext/> directory of the perl
1722b39c5158Smillertsource then MakeMaker will set PERL_SRC automatically (e.g.,
1723b39c5158SmillertC<../..>).  If PERL_SRC is defined and the extension is recognized as
1724b39c5158Smillerta standard extension, then other variables default to the following:
1725b39c5158Smillert
1726b39c5158Smillert  PERL_INC     = PERL_SRC
1727b39c5158Smillert  PERL_LIB     = PERL_SRC/lib
1728b39c5158Smillert  PERL_ARCHLIB = PERL_SRC/lib
1729b39c5158Smillert  INST_LIB     = PERL_LIB
1730b39c5158Smillert  INST_ARCHLIB = PERL_ARCHLIB
1731b39c5158Smillert
1732b39c5158SmillertIf an extension is being built away from the perl source then MakeMaker
1733b39c5158Smillertwill leave PERL_SRC undefined and default to using the installed copy
1734b39c5158Smillertof the perl library. The other variables default to the following:
1735b39c5158Smillert
1736b39c5158Smillert  PERL_INC     = $archlibexp/CORE
1737b39c5158Smillert  PERL_LIB     = $privlibexp
1738b39c5158Smillert  PERL_ARCHLIB = $archlibexp
1739b39c5158Smillert  INST_LIB     = ./blib/lib
1740b39c5158Smillert  INST_ARCHLIB = ./blib/arch
1741b39c5158Smillert
1742b39c5158SmillertIf perl has not yet been installed then PERL_SRC can be defined on the
1743b39c5158Smillertcommand line as shown in the previous section.
1744b39c5158Smillert
1745b39c5158Smillert
1746b39c5158Smillert=head2 Which architecture dependent directory?
1747b39c5158Smillert
1748b39c5158SmillertIf you don't want to keep the defaults for the INSTALL* macros,
1749b39c5158SmillertMakeMaker helps you to minimize the typing needed: the usual
1750b39c5158Smillertrelationship between INSTALLPRIVLIB and INSTALLARCHLIB is determined
1751b39c5158Smillertby Configure at perl compilation time. MakeMaker supports the user who
1752b39c5158Smillertsets INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not,
1753b39c5158Smillertthen MakeMaker defaults the latter to be the same subdirectory of
1754b39c5158SmillertINSTALLPRIVLIB as Configure decided for the counterparts in %Config,
1755b39c5158Smillertotherwise it defaults to INSTALLPRIVLIB. The same relationship holds
1756b39c5158Smillertfor INSTALLSITELIB and INSTALLSITEARCH.
1757b39c5158Smillert
1758b39c5158SmillertMakeMaker gives you much more freedom than needed to configure
1759e9ce3842Safresh1internal variables and get different results. It is worth mentioning
1760b39c5158Smillertthat make(1) also lets you configure most of the variables that are
1761b39c5158Smillertused in the Makefile. But in the majority of situations this will not
1762b39c5158Smillertbe necessary, and should only be done if the author of a package
1763b39c5158Smillertrecommends it (or you know what you're doing).
1764b39c5158Smillert
1765b39c5158Smillert=head2 Using Attributes and Parameters
1766b39c5158Smillert
1767b39c5158SmillertThe following attributes may be specified as arguments to WriteMakefile()
1768e5157e49Safresh1or as NAME=VALUE pairs on the command line. Attributes that became
1769e5157e49Safresh1available with later versions of MakeMaker are indicated.
1770e5157e49Safresh1
1771e5157e49Safresh1In order to maintain portability of attributes with older versions of
1772e5157e49Safresh1MakeMaker you may want to use L<App::EUMM::Upgrade> with your C<Makefile.PL>.
1773b39c5158Smillert
1774b39c5158Smillert=over 2
1775b39c5158Smillert
1776b39c5158Smillert=item ABSTRACT
1777b39c5158Smillert
1778b39c5158SmillertOne line description of the module. Will be included in PPD file.
1779b39c5158Smillert
1780b39c5158Smillert=item ABSTRACT_FROM
1781b39c5158Smillert
1782b39c5158SmillertName of the file that contains the package description. MakeMaker looks
1783b39c5158Smillertfor a line in the POD matching /^($package\s-\s)(.*)/. This is typically
1784b39c5158Smillertthe first line in the "=head1 NAME" section. $2 becomes the abstract.
1785b39c5158Smillert
1786b39c5158Smillert=item AUTHOR
1787b39c5158Smillert
178848950c12SsthenArray of strings containing name (and email address) of package author(s).
178948950c12SsthenIs used in CPAN Meta files (META.yml or META.json) and PPD
179048950c12Ssthen(Perl Package Description) files for PPM (Perl Package Manager).
1791b39c5158Smillert
1792b39c5158Smillert=item BINARY_LOCATION
1793b39c5158Smillert
1794b39c5158SmillertUsed when creating PPD files for binary packages.  It can be set to a
1795b39c5158Smillertfull or relative path or URL to the binary archive for a particular
1796b39c5158Smillertarchitecture.  For example:
1797b39c5158Smillert
1798b39c5158Smillert        perl Makefile.PL BINARY_LOCATION=x86/Agent.tar.gz
1799b39c5158Smillert
1800b39c5158Smillertbuilds a PPD package that references a binary of the C<Agent> package,
1801b39c5158Smillertlocated in the C<x86> directory relative to the PPD itself.
1802b39c5158Smillert
1803b39c5158Smillert=item BUILD_REQUIRES
1804b39c5158Smillert
18059f11ffb7Safresh1Available in version 6.55_03 and above.
1806e5157e49Safresh1
1807b39c5158SmillertA hash of modules that are needed to build your module but not run it.
1808b39c5158Smillert
1809e5157e49Safresh1This 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>.
1810e5157e49Safresh1
1811e5157e49Safresh1Defaults to C<<< { "ExtUtils::MakeMaker" => 0 } >>> if this attribute is not specified.
1812b39c5158Smillert
1813b39c5158SmillertThe format is the same as PREREQ_PM.
1814b39c5158Smillert
1815b39c5158Smillert=item C
1816b39c5158Smillert
1817b39c5158SmillertRef to array of *.c file names. Initialised from a directory scan
1818b39c5158Smillertand the values portion of the XS attribute hash. This is not
1819b39c5158Smillertcurrently used by MakeMaker but may be handy in Makefile.PLs.
1820b39c5158Smillert
1821b39c5158Smillert=item CCFLAGS
1822b39c5158Smillert
1823b39c5158SmillertString that will be included in the compiler call command line between
1824eac174f2Safresh1the arguments INC and OPTIMIZE. Note that setting this will overwrite its
1825eac174f2Safresh1default value (C<$Config::Config{ccflags}>); to preserve that, include
1826eac174f2Safresh1the default value directly, e.g.:
1827eac174f2Safresh1
1828eac174f2Safresh1    CCFLAGS => "$Config::Config{ccflags} ..."
1829b39c5158Smillert
1830b39c5158Smillert=item CONFIG
1831b39c5158Smillert
1832b39c5158SmillertArrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from
1833b39c5158Smillertconfig.sh. MakeMaker will add to CONFIG the following values anyway:
1834b39c5158Smillertar
1835b39c5158Smillertcc
1836b39c5158Smillertcccdlflags
1837b39c5158Smillertccdlflags
1838eac174f2Safresh1cpprun
1839b39c5158Smillertdlext
1840b39c5158Smillertdlsrc
1841b39c5158Smillertld
1842b39c5158Smillertlddlflags
1843b39c5158Smillertldflags
1844b39c5158Smillertlibc
1845b39c5158Smillertlib_ext
1846b39c5158Smillertobj_ext
1847b39c5158Smillertranlib
1848b39c5158Smillertsitelibexp
1849b39c5158Smillertsitearchexp
1850b39c5158Smillertso
1851b39c5158Smillert
1852b39c5158Smillert=item CONFIGURE
1853b39c5158Smillert
1854b39c5158SmillertCODE reference. The subroutine should return a hash reference. The
1855b39c5158Smillerthash may contain further attributes, e.g. {LIBS =E<gt> ...}, that have to
1856b39c5158Smillertbe determined by some evaluation method.
1857b39c5158Smillert
1858b39c5158Smillert=item CONFIGURE_REQUIRES
1859b39c5158Smillert
1860e5157e49Safresh1Available in version 6.52 and above.
1861e5157e49Safresh1
1862b39c5158SmillertA hash of modules that are required to run Makefile.PL itself, but not
1863b39c5158Smillertto run your distribution.
1864b39c5158Smillert
1865e5157e49Safresh1This 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>.
1866b39c5158Smillert
1867e5157e49Safresh1Defaults to C<<< { "ExtUtils::MakeMaker" => 0 } >>> if this attribute is not specified.
1868b39c5158Smillert
1869b39c5158SmillertThe format is the same as PREREQ_PM.
1870b39c5158Smillert
1871b39c5158Smillert=item DEFINE
1872b39c5158Smillert
1873b39c5158SmillertSomething like C<"-DHAVE_UNISTD_H">
1874b39c5158Smillert
1875b39c5158Smillert=item DESTDIR
1876b39c5158Smillert
1877b39c5158SmillertThis is the root directory into which the code will be installed.  It
1878b39c5158SmillertI<prepends itself to the normal prefix>.  For example, if your code
1879b39c5158Smillertwould normally go into F</usr/local/lib/perl> you could set DESTDIR=~/tmp/
1880b39c5158Smillertand installation would go into F<~/tmp/usr/local/lib/perl>.
1881b39c5158Smillert
1882b39c5158SmillertThis is primarily of use for people who repackage Perl modules.
1883b39c5158Smillert
1884b39c5158SmillertNOTE: Due to the nature of make, it is important that you put the trailing
1885b39c5158Smillertslash on your DESTDIR.  F<~/tmp/> not F<~/tmp>.
1886b39c5158Smillert
1887b39c5158Smillert=item DIR
1888b39c5158Smillert
1889b39c5158SmillertRef to array of subdirectories containing Makefile.PLs e.g. ['sdbm']
1890b39c5158Smillertin ext/SDBM_File
1891b39c5158Smillert
1892b39c5158Smillert=item DISTNAME
1893b39c5158Smillert
1894b39c5158SmillertA safe filename for the package.
1895b39c5158Smillert
1896e9ce3842Safresh1Defaults to NAME below but with :: replaced with -.
1897b39c5158Smillert
1898b39c5158SmillertFor example, Foo::Bar becomes Foo-Bar.
1899b39c5158Smillert
1900b39c5158Smillert=item DISTVNAME
1901b39c5158Smillert
1902b39c5158SmillertYour name for distributing the package with the version number
1903b39c5158Smillertincluded.  This is used by 'make dist' to name the resulting archive
1904b39c5158Smillertfile.
1905b39c5158Smillert
1906b39c5158SmillertDefaults to DISTNAME-VERSION.
1907b39c5158Smillert
1908b39c5158SmillertFor example, version 1.04 of Foo::Bar becomes Foo-Bar-1.04.
1909b39c5158Smillert
1910b39c5158SmillertOn some OS's where . has special meaning VERSION_SYM may be used in
1911b39c5158Smillertplace of VERSION.
1912b39c5158Smillert
1913e5157e49Safresh1=item DLEXT
1914e5157e49Safresh1
1915e5157e49Safresh1Specifies the extension of the module's loadable object. For example:
1916e5157e49Safresh1
1917e5157e49Safresh1  DLEXT => 'unusual_ext', # Default value is $Config{so}
1918e5157e49Safresh1
1919e5157e49Safresh1NOTE: When using this option to alter the extension of a module's
1920e5157e49Safresh1loadable object, it is also necessary that the module's pm file
1921e5157e49Safresh1specifies the same change:
1922e5157e49Safresh1
1923e5157e49Safresh1  local $DynaLoader::dl_dlext = 'unusual_ext';
1924e5157e49Safresh1
1925b39c5158Smillert=item DL_FUNCS
1926b39c5158Smillert
1927b39c5158SmillertHashref of symbol names for routines to be made available as universal
1928b39c5158Smillertsymbols.  Each key/value pair consists of the package name and an
1929b39c5158Smillertarray of routine names in that package.  Used only under AIX, OS/2,
1930b39c5158SmillertVMS and Win32 at present.  The routine names supplied will be expanded
1931b39c5158Smillertin the same way as XSUB names are expanded by the XS() macro.
1932b39c5158SmillertDefaults to
1933b39c5158Smillert
1934b39c5158Smillert  {"$(NAME)" => ["boot_$(NAME)" ] }
1935b39c5158Smillert
1936b39c5158Smillerte.g.
1937b39c5158Smillert
1938b39c5158Smillert  {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
1939b39c5158Smillert   "NetconfigPtr" => [ 'DESTROY'] }
1940b39c5158Smillert
1941b39c5158SmillertPlease see the L<ExtUtils::Mksymlists> documentation for more information
1942b39c5158Smillertabout the DL_FUNCS, DL_VARS and FUNCLIST attributes.
1943b39c5158Smillert
1944b39c5158Smillert=item DL_VARS
1945b39c5158Smillert
1946b39c5158SmillertArray of symbol names for variables to be made available as universal symbols.
1947b39c5158SmillertUsed only under AIX, OS/2, VMS and Win32 at present.  Defaults to [].
1948b39c5158Smillert(e.g. [ qw(Foo_version Foo_numstreams Foo_tree ) ])
1949b39c5158Smillert
1950b39c5158Smillert=item EXCLUDE_EXT
1951b39c5158Smillert
1952b39c5158SmillertArray of extension names to exclude when doing a static build.  This
1953b39c5158Smillertis ignored if INCLUDE_EXT is present.  Consult INCLUDE_EXT for more
1954b39c5158Smillertdetails.  (e.g.  [ qw( Socket POSIX ) ] )
1955b39c5158Smillert
1956b39c5158SmillertThis attribute may be most useful when specified as a string on the
1957b39c5158Smillertcommand line:  perl Makefile.PL EXCLUDE_EXT='Socket Safe'
1958b39c5158Smillert
1959b39c5158Smillert=item EXE_FILES
1960b39c5158Smillert
1961b39c5158SmillertRef to array of executable files. The files will be copied to the
1962b39c5158SmillertINST_SCRIPT directory. Make realclean will delete them from there
1963b39c5158Smillertagain.
1964b39c5158Smillert
1965b39c5158SmillertIf your executables start with something like #!perl or
1966b39c5158Smillert#!/usr/bin/perl MakeMaker will change this to the path of the perl
1967b39c5158Smillert'Makefile.PL' was invoked with so the programs will be sure to run
1968b39c5158Smillertproperly even if perl is not in /usr/bin/perl.
1969b39c5158Smillert
1970b39c5158Smillert=item FIRST_MAKEFILE
1971b39c5158Smillert
1972b39c5158SmillertThe name of the Makefile to be produced.  This is used for the second
1973b39c5158SmillertMakefile that will be produced for the MAP_TARGET.
1974b39c5158Smillert
1975b39c5158SmillertDefaults to 'Makefile' or 'Descrip.MMS' on VMS.
1976b39c5158Smillert
1977b39c5158Smillert(Note: we couldn't use MAKEFILE because dmake uses this for something
1978b39c5158Smillertelse).
1979b39c5158Smillert
1980b39c5158Smillert=item FULLPERL
1981b39c5158Smillert
1982b39c5158SmillertPerl binary able to run this extension, load XS modules, etc...
1983b39c5158Smillert
1984b39c5158Smillert=item FULLPERLRUN
1985b39c5158Smillert
1986b39c5158SmillertLike PERLRUN, except it uses FULLPERL.
1987b39c5158Smillert
1988b39c5158Smillert=item FULLPERLRUNINST
1989b39c5158Smillert
1990b39c5158SmillertLike PERLRUNINST, except it uses FULLPERL.
1991b39c5158Smillert
1992b39c5158Smillert=item FUNCLIST
1993b39c5158Smillert
1994b39c5158SmillertThis provides an alternate means to specify function names to be
1995b39c5158Smillertexported from the extension.  Its value is a reference to an
1996b39c5158Smillertarray of function names to be exported by the extension.  These
1997b39c5158Smillertnames are passed through unaltered to the linker options file.
1998b39c5158Smillert
1999b39c5158Smillert=item H
2000b39c5158Smillert
2001b39c5158SmillertRef to array of *.h file names. Similar to C.
2002b39c5158Smillert
2003b39c5158Smillert=item IMPORTS
2004b39c5158Smillert
2005b39c5158SmillertThis attribute is used to specify names to be imported into the
2006b39c5158Smillertextension. Takes a hash ref.
2007b39c5158Smillert
2008b39c5158SmillertIt is only used on OS/2 and Win32.
2009b39c5158Smillert
2010b39c5158Smillert=item INC
2011b39c5158Smillert
2012b39c5158SmillertInclude file dirs eg: C<"-I/usr/5include -I/path/to/inc">
2013b39c5158Smillert
2014b39c5158Smillert=item INCLUDE_EXT
2015b39c5158Smillert
2016b39c5158SmillertArray of extension names to be included when doing a static build.
2017b39c5158SmillertMakeMaker will normally build with all of the installed extensions when
2018b39c5158Smillertdoing a static build, and that is usually the desired behavior.  If
2019b39c5158SmillertINCLUDE_EXT is present then MakeMaker will build only with those extensions
2020b39c5158Smillertwhich are explicitly mentioned. (e.g.  [ qw( Socket POSIX ) ])
2021b39c5158Smillert
2022b39c5158SmillertIt is not necessary to mention DynaLoader or the current extension when
2023b39c5158Smillertfilling in INCLUDE_EXT.  If the INCLUDE_EXT is mentioned but is empty then
2024b39c5158Smillertonly DynaLoader and the current extension will be included in the build.
2025b39c5158Smillert
2026b39c5158SmillertThis attribute may be most useful when specified as a string on the
2027b39c5158Smillertcommand line:  perl Makefile.PL INCLUDE_EXT='POSIX Socket Devel::Peek'
2028b39c5158Smillert
2029b39c5158Smillert=item INSTALLARCHLIB
2030b39c5158Smillert
2031b39c5158SmillertUsed by 'make install', which copies files from INST_ARCHLIB to this
2032b39c5158Smillertdirectory if INSTALLDIRS is set to perl.
2033b39c5158Smillert
2034b39c5158Smillert=item INSTALLBIN
2035b39c5158Smillert
2036b39c5158SmillertDirectory to install binary files (e.g. tkperl) into if
2037b39c5158SmillertINSTALLDIRS=perl.
2038b39c5158Smillert
2039b39c5158Smillert=item INSTALLDIRS
2040b39c5158Smillert
2041b39c5158SmillertDetermines which of the sets of installation directories to choose:
2042b39c5158Smillertperl, site or vendor.  Defaults to site.
2043b39c5158Smillert
2044b39c5158Smillert=item INSTALLMAN1DIR
2045b39c5158Smillert
2046b39c5158Smillert=item INSTALLMAN3DIR
2047b39c5158Smillert
2048b39c5158SmillertThese directories get the man pages at 'make install' time if
2049b39c5158SmillertINSTALLDIRS=perl.  Defaults to $Config{installman*dir}.
2050b39c5158Smillert
2051b39c5158SmillertIf set to 'none', no man pages will be installed.
2052b39c5158Smillert
2053b39c5158Smillert=item INSTALLPRIVLIB
2054b39c5158Smillert
2055b39c5158SmillertUsed by 'make install', which copies files from INST_LIB to this
2056b39c5158Smillertdirectory if INSTALLDIRS is set to perl.
2057b39c5158Smillert
2058b39c5158SmillertDefaults to $Config{installprivlib}.
2059b39c5158Smillert
2060b39c5158Smillert=item INSTALLSCRIPT
2061b39c5158Smillert
20629f11ffb7Safresh1Available in version 6.30_02 and above.
20639f11ffb7Safresh1
2064b39c5158SmillertUsed by 'make install' which copies files from INST_SCRIPT to this
2065b39c5158Smillertdirectory if INSTALLDIRS=perl.
2066b39c5158Smillert
2067b39c5158Smillert=item INSTALLSITEARCH
2068b39c5158Smillert
2069b39c5158SmillertUsed by 'make install', which copies files from INST_ARCHLIB to this
2070b39c5158Smillertdirectory if INSTALLDIRS is set to site (default).
2071b39c5158Smillert
2072b39c5158Smillert=item INSTALLSITEBIN
2073b39c5158Smillert
2074b39c5158SmillertUsed by 'make install', which copies files from INST_BIN to this
2075b39c5158Smillertdirectory if INSTALLDIRS is set to site (default).
2076b39c5158Smillert
2077b39c5158Smillert=item INSTALLSITELIB
2078b39c5158Smillert
2079b39c5158SmillertUsed by 'make install', which copies files from INST_LIB to this
2080b39c5158Smillertdirectory if INSTALLDIRS is set to site (default).
2081b39c5158Smillert
2082b39c5158Smillert=item INSTALLSITEMAN1DIR
2083b39c5158Smillert
2084b39c5158Smillert=item INSTALLSITEMAN3DIR
2085b39c5158Smillert
2086b39c5158SmillertThese directories get the man pages at 'make install' time if
2087b39c5158SmillertINSTALLDIRS=site (default).  Defaults to
2088b39c5158Smillert$(SITEPREFIX)/man/man$(MAN*EXT).
2089b39c5158Smillert
2090b39c5158SmillertIf set to 'none', no man pages will be installed.
2091b39c5158Smillert
2092b39c5158Smillert=item INSTALLSITESCRIPT
2093b39c5158Smillert
2094b39c5158SmillertUsed by 'make install' which copies files from INST_SCRIPT to this
2095b39c5158Smillertdirectory if INSTALLDIRS is set to site (default).
2096b39c5158Smillert
2097b39c5158Smillert=item INSTALLVENDORARCH
2098b39c5158Smillert
2099b39c5158SmillertUsed by 'make install', which copies files from INST_ARCHLIB to this
21009f11ffb7Safresh1directory if INSTALLDIRS is set to vendor. Note that if you do not set
21019f11ffb7Safresh1this, the value of INSTALLVENDORLIB will be used, which is probably not
21029f11ffb7Safresh1what you want.
2103b39c5158Smillert
2104b39c5158Smillert=item INSTALLVENDORBIN
2105b39c5158Smillert
2106b39c5158SmillertUsed by 'make install', which copies files from INST_BIN to this
2107b39c5158Smillertdirectory if INSTALLDIRS is set to vendor.
2108b39c5158Smillert
2109b39c5158Smillert=item INSTALLVENDORLIB
2110b39c5158Smillert
2111b39c5158SmillertUsed by 'make install', which copies files from INST_LIB to this
2112b39c5158Smillertdirectory if INSTALLDIRS is set to vendor.
2113b39c5158Smillert
2114b39c5158Smillert=item INSTALLVENDORMAN1DIR
2115b39c5158Smillert
2116b39c5158Smillert=item INSTALLVENDORMAN3DIR
2117b39c5158Smillert
2118b39c5158SmillertThese directories get the man pages at 'make install' time if
2119b39c5158SmillertINSTALLDIRS=vendor.  Defaults to $(VENDORPREFIX)/man/man$(MAN*EXT).
2120b39c5158Smillert
2121b39c5158SmillertIf set to 'none', no man pages will be installed.
2122b39c5158Smillert
2123b39c5158Smillert=item INSTALLVENDORSCRIPT
2124b39c5158Smillert
21259f11ffb7Safresh1Available in version 6.30_02 and above.
21269f11ffb7Safresh1
2127b39c5158SmillertUsed by 'make install' which copies files from INST_SCRIPT to this
2128b39c5158Smillertdirectory if INSTALLDIRS is set to vendor.
2129b39c5158Smillert
2130b39c5158Smillert=item INST_ARCHLIB
2131b39c5158Smillert
2132b39c5158SmillertSame as INST_LIB for architecture dependent files.
2133b39c5158Smillert
2134b39c5158Smillert=item INST_BIN
2135b39c5158Smillert
2136b39c5158SmillertDirectory to put real binary files during 'make'. These will be copied
2137b39c5158Smillertto INSTALLBIN during 'make install'
2138b39c5158Smillert
2139b39c5158Smillert=item INST_LIB
2140b39c5158Smillert
2141b39c5158SmillertDirectory where we put library files of this extension while building
2142b39c5158Smillertit.
2143b39c5158Smillert
2144b39c5158Smillert=item INST_MAN1DIR
2145b39c5158Smillert
2146b39c5158SmillertDirectory to hold the man pages at 'make' time
2147b39c5158Smillert
2148b39c5158Smillert=item INST_MAN3DIR
2149b39c5158Smillert
2150b39c5158SmillertDirectory to hold the man pages at 'make' time
2151b39c5158Smillert
2152b39c5158Smillert=item INST_SCRIPT
2153b39c5158Smillert
2154e9ce3842Safresh1Directory where executable files should be installed during
2155b39c5158Smillert'make'. Defaults to "./blib/script", just to have a dummy location during
2156b39c5158Smillerttesting. make install will copy the files in INST_SCRIPT to
2157b39c5158SmillertINSTALLSCRIPT.
2158b39c5158Smillert
2159b39c5158Smillert=item LD
2160b39c5158Smillert
2161b39c5158SmillertProgram to be used to link libraries for dynamic loading.
2162b39c5158Smillert
2163b39c5158SmillertDefaults to $Config{ld}.
2164b39c5158Smillert
2165b39c5158Smillert=item LDDLFLAGS
2166b39c5158Smillert
2167b39c5158SmillertAny special flags that might need to be passed to ld to create a
2168b39c5158Smillertshared library suitable for dynamic loading.  It is up to the makefile
2169b39c5158Smillertto use it.  (See L<Config/lddlflags>)
2170b39c5158Smillert
2171b39c5158SmillertDefaults to $Config{lddlflags}.
2172b39c5158Smillert
2173b39c5158Smillert=item LDFROM
2174b39c5158Smillert
2175b39c5158SmillertDefaults to "$(OBJECT)" and is used in the ld command to specify
2176b39c5158Smillertwhat files to link/load from (also see dynamic_lib below for how to
2177b39c5158Smillertspecify ld flags)
2178b39c5158Smillert
2179b39c5158Smillert=item LIB
2180b39c5158Smillert
2181b39c5158SmillertLIB should only be set at C<perl Makefile.PL> time but is allowed as a
2182b39c5158SmillertMakeMaker argument. It has the effect of setting both INSTALLPRIVLIB
2183b39c5158Smillertand INSTALLSITELIB to that value regardless any explicit setting of
2184b39c5158Smillertthose arguments (or of PREFIX).  INSTALLARCHLIB and INSTALLSITEARCH
2185b39c5158Smillertare set to the corresponding architecture subdirectory.
2186b39c5158Smillert
2187b39c5158Smillert=item LIBPERL_A
2188b39c5158Smillert
2189b39c5158SmillertThe filename of the perllibrary that will be used together with this
2190b39c5158Smillertextension. Defaults to libperl.a.
2191b39c5158Smillert
2192b39c5158Smillert=item LIBS
2193b39c5158Smillert
2194b39c5158SmillertAn anonymous array of alternative library
2195b39c5158Smillertspecifications to be searched for (in order) until
2196b39c5158Smillertat least one library is found. E.g.
2197b39c5158Smillert
2198b39c5158Smillert  'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]
2199b39c5158Smillert
2200b39c5158SmillertMind, that any element of the array
2201b39c5158Smillertcontains a complete set of arguments for the ld
2202b39c5158Smillertcommand. So do not specify
2203b39c5158Smillert
2204b39c5158Smillert  'LIBS' => ["-ltcl", "-ltk", "-lX11"]
2205b39c5158Smillert
2206b39c5158SmillertSee ODBM_File/Makefile.PL for an example, where an array is needed. If
2207b39c5158Smillertyou specify a scalar as in
2208b39c5158Smillert
2209b39c5158Smillert  'LIBS' => "-ltcl -ltk -lX11"
2210b39c5158Smillert
2211b39c5158SmillertMakeMaker will turn it into an array with one element.
2212b39c5158Smillert
2213b39c5158Smillert=item LICENSE
2214b39c5158Smillert
2215e5157e49Safresh1Available in version 6.31 and above.
2216e5157e49Safresh1
2217e5157e49Safresh1The licensing terms of your distribution.  Generally it's "perl_5" for the
2218b39c5158Smillertsame license as Perl itself.
2219b39c5158Smillert
2220e5157e49Safresh1See L<CPAN::Meta::Spec> for the list of options.
2221b39c5158Smillert
2222b39c5158SmillertDefaults to "unknown".
2223b39c5158Smillert
2224b39c5158Smillert=item LINKTYPE
2225b39c5158Smillert
2226b39c5158Smillert'static' or 'dynamic' (default unless usedl=undef in
2227b39c5158Smillertconfig.sh). Should only be used to force static linking (also see
2228b39c5158Smillertlinkext below).
2229b39c5158Smillert
2230e5157e49Safresh1=item MAGICXS
2231e5157e49Safresh1
22329f11ffb7Safresh1Available in version 6.8305 and above.
22339f11ffb7Safresh1
2234b8851fccSafresh1When this is set to C<1>, C<OBJECT> will be automagically derived from
2235b8851fccSafresh1C<O_FILES>.
2236e5157e49Safresh1
2237b39c5158Smillert=item MAKE
2238b39c5158Smillert
22399f11ffb7Safresh1Available in version 6.30_01 and above.
22409f11ffb7Safresh1
2241b39c5158SmillertVariant of make you intend to run the generated Makefile with.  This
2242b39c5158Smillertparameter lets Makefile.PL know what make quirks to account for when
2243b39c5158Smillertgenerating the Makefile.
2244b39c5158Smillert
2245b39c5158SmillertMakeMaker also honors the MAKE environment variable.  This parameter
2246e9ce3842Safresh1takes precedence.
2247b39c5158Smillert
2248b39c5158SmillertCurrently the only significant values are 'dmake' and 'nmake' for Windows
2249e9ce3842Safresh1users, instructing MakeMaker to generate a Makefile in the flavour of
2250e9ce3842Safresh1DMake ("Dennis Vadura's Make") or Microsoft NMake respectively.
2251b39c5158Smillert
2252e9ce3842Safresh1Defaults to $Config{make}, which may go looking for a Make program
2253e9ce3842Safresh1in your environment.
2254e9ce3842Safresh1
2255e9ce3842Safresh1How are you supposed to know what flavour of Make a Makefile has
2256e9ce3842Safresh1been generated for if you didn't specify a value explicitly? Search
2257e9ce3842Safresh1the generated Makefile for the definition of the MAKE variable,
2258e9ce3842Safresh1which is used to recursively invoke the Make utility. That will tell
2259e9ce3842Safresh1you what Make you're supposed to invoke the Makefile with.
2260b39c5158Smillert
2261b39c5158Smillert=item MAKEAPERL
2262b39c5158Smillert
2263e9ce3842Safresh1Boolean which tells MakeMaker that it should include the rules to
2264b39c5158Smillertmake a perl. This is handled automatically as a switch by
2265b39c5158SmillertMakeMaker. The user normally does not need it.
2266b39c5158Smillert
2267b39c5158Smillert=item MAKEFILE_OLD
2268b39c5158Smillert
2269b39c5158SmillertWhen 'make clean' or similar is run, the $(FIRST_MAKEFILE) will be
2270b39c5158Smillertbacked up at this location.
2271b39c5158Smillert
2272b39c5158SmillertDefaults to $(FIRST_MAKEFILE).old or $(FIRST_MAKEFILE)_old on VMS.
2273b39c5158Smillert
2274b39c5158Smillert=item MAN1PODS
2275b39c5158Smillert
2276b39c5158SmillertHashref of pod-containing files. MakeMaker will default this to all
2277b39c5158SmillertEXE_FILES files that include POD directives. The files listed
2278b39c5158Smillerthere will be converted to man pages and installed as was requested
2279b39c5158Smillertat Configure time.
2280b39c5158Smillert
2281b39c5158SmillertThis hash should map POD files (or scripts containing POD) to the
2282b39c5158Smillertman file names under the C<blib/man1/> directory, as in the following
2283b39c5158Smillertexample:
2284b39c5158Smillert
2285b39c5158Smillert  MAN1PODS            => {
2286b39c5158Smillert    'doc/command.pod'    => 'blib/man1/command.1',
2287b39c5158Smillert    'scripts/script.pl'  => 'blib/man1/script.1',
2288b39c5158Smillert  }
2289b39c5158Smillert
2290b39c5158Smillert=item MAN3PODS
2291b39c5158Smillert
2292b39c5158SmillertHashref that assigns to *.pm and *.pod files the files into which the
2293b39c5158Smillertmanpages are to be written. MakeMaker parses all *.pod and *.pm files
2294b39c5158Smillertfor POD directives. Files that contain POD will be the default keys of
2295b39c5158Smillertthe MAN3PODS hashref. These will then be converted to man pages during
2296b39c5158SmillertC<make> and will be installed during C<make install>.
2297b39c5158Smillert
2298b39c5158SmillertExample similar to MAN1PODS.
2299b39c5158Smillert
2300b39c5158Smillert=item MAP_TARGET
2301b39c5158Smillert
2302e9ce3842Safresh1If it is intended that a new perl binary be produced, this variable
2303b39c5158Smillertmay hold a name for that binary. Defaults to perl
2304b39c5158Smillert
2305b39c5158Smillert=item META_ADD
2306b39c5158Smillert
2307b39c5158Smillert=item META_MERGE
2308b39c5158Smillert
2309e5157e49Safresh1Available in version 6.46 and above.
2310e5157e49Safresh1
2311e9ce3842Safresh1A hashref of items to add to the CPAN Meta file (F<META.yml> or
231248950c12SsthenF<META.json>).
2313b39c5158Smillert
2314b39c5158SmillertThey differ in how they behave if they have the same key as the
231548950c12Ssthendefault metadata.  META_ADD will override the default value with its
2316b39c5158Smillertown.  META_MERGE will merge its value with the default.
2317b39c5158Smillert
2318b39c5158SmillertUnless you want to override the defaults, prefer META_MERGE so as to
2319b39c5158Smillertget the advantage of any future defaults.
2320b39c5158Smillert
2321b8851fccSafresh1Where prereqs are concerned, if META_MERGE is used, prerequisites are merged
2322b8851fccSafresh1with their counterpart C<WriteMakefile()> argument
2323b8851fccSafresh1(PREREQ_PM is merged into {prereqs}{runtime}{requires},
2324b8851fccSafresh1BUILD_REQUIRES into C<{prereqs}{build}{requires}>,
2325b8851fccSafresh1CONFIGURE_REQUIRES into C<{prereqs}{configure}{requires}>,
2326b8851fccSafresh1and TEST_REQUIRES into C<{prereqs}{test}{requires})>.
2327b8851fccSafresh1When prereqs are specified with META_ADD, the only prerequisites added to the
2328b8851fccSafresh1file come from the metadata, not C<WriteMakefile()> arguments.
2329b8851fccSafresh1
2330b8851fccSafresh1Note that these configuration options are only used for generating F<META.yml>
2331b8851fccSafresh1and F<META.json> -- they are NOT used for F<MYMETA.yml> and F<MYMETA.json>.
2332b8851fccSafresh1Therefore data in these fields should NOT be used for dynamic (user-side)
2333b8851fccSafresh1configuration.
2334b8851fccSafresh1
2335e5157e49Safresh1By default CPAN Meta specification C<1.4> is used. In order to use
2336e5157e49Safresh1CPAN Meta specification C<2.0>, indicate with C<meta-spec> the version
2337e5157e49Safresh1you want to use.
2338e5157e49Safresh1
2339e5157e49Safresh1  META_MERGE        => {
2340e5157e49Safresh1
2341e5157e49Safresh1    "meta-spec" => { version => 2 },
2342e5157e49Safresh1
2343e5157e49Safresh1    resources => {
2344e5157e49Safresh1
2345e5157e49Safresh1      repository => {
2346e5157e49Safresh1          type => 'git',
2347e5157e49Safresh1          url => 'git://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker.git',
2348e5157e49Safresh1          web => 'https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker',
2349e5157e49Safresh1      },
2350e5157e49Safresh1
2351e5157e49Safresh1    },
2352e5157e49Safresh1
2353e5157e49Safresh1  },
2354e5157e49Safresh1
2355b39c5158Smillert=item MIN_PERL_VERSION
2356b39c5158Smillert
2357e5157e49Safresh1Available in version 6.48 and above.
2358e5157e49Safresh1
2359b39c5158SmillertThe minimum required version of Perl for this distribution.
2360b39c5158Smillert
2361e9ce3842Safresh1Either the 5.006001 or the 5.6.1 format is acceptable.
2362b39c5158Smillert
2363b39c5158Smillert=item MYEXTLIB
2364b39c5158Smillert
2365e9ce3842Safresh1If the extension links to a library that it builds, set this to the
2366b39c5158Smillertname of the library (see SDBM_File)
2367b39c5158Smillert
2368b39c5158Smillert=item NAME
2369b39c5158Smillert
2370e9ce3842Safresh1The package representing the distribution. For example, C<Test::More>
2371e9ce3842Safresh1or C<ExtUtils::MakeMaker>. It will be used to derive information about
2372b8851fccSafresh1the distribution such as the L</DISTNAME>, installation locations
2373e9ce3842Safresh1within the Perl library and where XS files will be looked for by
2374b8851fccSafresh1default (see L</XS>).
2375e9ce3842Safresh1
2376e9ce3842Safresh1C<NAME> I<must> be a valid Perl package name and it I<must> have an
2377e9ce3842Safresh1associated C<.pm> file. For example, C<Foo::Bar> is a valid C<NAME>
2378e9ce3842Safresh1and there must exist F<Foo/Bar.pm>.  Any XS code should be in
2379e9ce3842Safresh1F<Bar.xs> unless stated otherwise.
2380e9ce3842Safresh1
2381e9ce3842Safresh1Your distribution B<must> have a C<NAME>.
2382b39c5158Smillert
2383b39c5158Smillert=item NEEDS_LINKING
2384b39c5158Smillert
2385b39c5158SmillertMakeMaker will figure out if an extension contains linkable code
2386b39c5158Smillertanywhere down the directory tree, and will set this variable
2387b39c5158Smillertaccordingly, but you can speed it up a very little bit if you define
2388b39c5158Smillertthis boolean variable yourself.
2389b39c5158Smillert
2390b39c5158Smillert=item NOECHO
2391b39c5158Smillert
2392e9ce3842Safresh1Command so make does not print the literal commands it's running.
2393b39c5158Smillert
2394b39c5158SmillertBy setting it to an empty string you can generate a Makefile that
2395b39c5158Smillertprints all commands. Mainly used in debugging MakeMaker itself.
2396b39c5158Smillert
2397b39c5158SmillertDefaults to C<@>.
2398b39c5158Smillert
2399b39c5158Smillert=item NORECURS
2400b39c5158Smillert
2401b39c5158SmillertBoolean.  Attribute to inhibit descending into subdirectories.
2402b39c5158Smillert
2403b39c5158Smillert=item NO_META
2404b39c5158Smillert
2405b39c5158SmillertWhen true, suppresses the generation and addition to the MANIFEST of
240648950c12Ssthenthe META.yml and META.json module meta-data files during 'make distdir'.
240748950c12Ssthen
240848950c12SsthenDefaults to false.
240948950c12Ssthen
241048950c12Ssthen=item NO_MYMETA
241148950c12Ssthen
24129f11ffb7Safresh1Available in version 6.57_02 and above.
24139f11ffb7Safresh1
241448950c12SsthenWhen true, suppresses the generation of MYMETA.yml and MYMETA.json module
241548950c12Ssthenmeta-data files during 'perl Makefile.PL'.
2416b39c5158Smillert
2417b39c5158SmillertDefaults to false.
2418b39c5158Smillert
2419e5157e49Safresh1=item NO_PACKLIST
2420e5157e49Safresh1
24219f11ffb7Safresh1Available in version 6.7501 and above.
24229f11ffb7Safresh1
2423e5157e49Safresh1When true, suppresses the writing of C<packlist> files for installs.
2424e5157e49Safresh1
2425e5157e49Safresh1Defaults to false.
2426e5157e49Safresh1
2427e5157e49Safresh1=item NO_PERLLOCAL
2428e5157e49Safresh1
24299f11ffb7Safresh1Available in version 6.7501 and above.
24309f11ffb7Safresh1
2431e5157e49Safresh1When true, suppresses the appending of installations to C<perllocal>.
2432e5157e49Safresh1
2433e5157e49Safresh1Defaults to false.
2434e5157e49Safresh1
2435b39c5158Smillert=item NO_VC
2436b39c5158Smillert
2437b39c5158SmillertIn general, any generated Makefile checks for the current version of
2438b39c5158SmillertMakeMaker and the version the Makefile was built under. If NO_VC is
2439b39c5158Smillertset, the version check is neglected. Do not write this into your
2440b39c5158SmillertMakefile.PL, use it interactively instead.
2441b39c5158Smillert
2442b39c5158Smillert=item OBJECT
2443b39c5158Smillert
2444b39c5158SmillertList of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long
2445e5157e49Safresh1string or an array containing all object files, e.g. "tkpBind.o
2446e5157e49Safresh1tkpButton.o tkpCanvas.o" or ["tkpBind.o", "tkpButton.o", "tkpCanvas.o"]
2447b39c5158Smillert
2448b39c5158Smillert(Where BASEEXT is the last component of NAME, and OBJ_EXT is $Config{obj_ext}.)
2449b39c5158Smillert
2450b39c5158Smillert=item OPTIMIZE
2451b39c5158Smillert
2452b39c5158SmillertDefaults to C<-O>. Set it to C<-g> to turn debugging on. The flag is
2453b39c5158Smillertpassed to subdirectory makes.
2454b39c5158Smillert
2455b39c5158Smillert=item PERL
2456b39c5158Smillert
24579f11ffb7Safresh1Perl binary for tasks that can be done by miniperl. If it contains
24589f11ffb7Safresh1spaces or other shell metacharacters, it needs to be quoted in a way
24599f11ffb7Safresh1that protects them, since this value is intended to be inserted in a
24609f11ffb7Safresh1shell command line in the Makefile. E.g.:
24619f11ffb7Safresh1
24629f11ffb7Safresh1  # Perl executable lives in "C:/Program Files/Perl/bin"
24639f11ffb7Safresh1  # Normally you don't need to set this yourself!
24649f11ffb7Safresh1  $ perl Makefile.PL PERL='"C:/Program Files/Perl/bin/perl.exe" -w'
2465b39c5158Smillert
2466b39c5158Smillert=item PERL_CORE
2467b39c5158Smillert
2468b39c5158SmillertSet only when MakeMaker is building the extensions of the Perl core
2469b39c5158Smillertdistribution.
2470b39c5158Smillert
2471b39c5158Smillert=item PERLMAINCC
2472b39c5158Smillert
2473b39c5158SmillertThe call to the program that is able to compile perlmain.c. Defaults
2474b39c5158Smillertto $(CC).
2475b39c5158Smillert
2476b39c5158Smillert=item PERL_ARCHLIB
2477b39c5158Smillert
2478b39c5158SmillertSame as for PERL_LIB, but for architecture dependent files.
2479b39c5158Smillert
2480b39c5158SmillertUsed only when MakeMaker is building the extensions of the Perl core
2481b39c5158Smillertdistribution (because normally $(PERL_ARCHLIB) is automatically in @INC,
2482b39c5158Smillertand adding it would get in the way of PERL5LIB).
2483b39c5158Smillert
2484b39c5158Smillert=item PERL_LIB
2485b39c5158Smillert
2486b39c5158SmillertDirectory containing the Perl library to use.
2487b39c5158Smillert
2488b39c5158SmillertUsed only when MakeMaker is building the extensions of the Perl core
2489b39c5158Smillertdistribution (because normally $(PERL_LIB) is automatically in @INC,
2490b39c5158Smillertand adding it would get in the way of PERL5LIB).
2491b39c5158Smillert
2492b39c5158Smillert=item PERL_MALLOC_OK
2493b39c5158Smillert
2494b39c5158Smillertdefaults to 0.  Should be set to TRUE if the extension can work with
2495b39c5158Smillertthe memory allocation routines substituted by the Perl malloc() subsystem.
2496b39c5158SmillertThis should be applicable to most extensions with exceptions of those
2497b39c5158Smillert
2498b39c5158Smillert=over 4
2499b39c5158Smillert
2500b39c5158Smillert=item *
2501b39c5158Smillert
2502b39c5158Smillertwith bugs in memory allocations which are caught by Perl's malloc();
2503b39c5158Smillert
2504b39c5158Smillert=item *
2505b39c5158Smillert
2506b39c5158Smillertwhich interact with the memory allocator in other ways than via
2507b39c5158Smillertmalloc(), realloc(), free(), calloc(), sbrk() and brk();
2508b39c5158Smillert
2509b39c5158Smillert=item *
2510b39c5158Smillert
2511b39c5158Smillertwhich rely on special alignment which is not provided by Perl's malloc().
2512b39c5158Smillert
2513b39c5158Smillert=back
2514b39c5158Smillert
2515e9ce3842Safresh1B<NOTE.>  Neglecting to set this flag in I<any one> of the loaded extension
2516b39c5158Smillertnullifies many advantages of Perl's malloc(), such as better usage of
2517b39c5158Smillertsystem resources, error detection, memory usage reporting, catchable failure
2518b39c5158Smillertof memory allocations, etc.
2519b39c5158Smillert
2520b39c5158Smillert=item PERLPREFIX
2521b39c5158Smillert
2522b39c5158SmillertDirectory under which core modules are to be installed.
2523b39c5158Smillert
2524e9ce3842Safresh1Defaults to $Config{installprefixexp}, falling back to
2525b39c5158Smillert$Config{installprefix}, $Config{prefixexp} or $Config{prefix} should
2526b39c5158Smillert$Config{installprefixexp} not exist.
2527b39c5158Smillert
2528b39c5158SmillertOverridden by PREFIX.
2529b39c5158Smillert
2530b39c5158Smillert=item PERLRUN
2531b39c5158Smillert
2532b39c5158SmillertUse this instead of $(PERL) when you wish to run perl.  It will set up
2533b39c5158Smillertextra necessary flags for you.
2534b39c5158Smillert
2535b39c5158Smillert=item PERLRUNINST
2536b39c5158Smillert
2537b39c5158SmillertUse this instead of $(PERL) when you wish to run perl to work with
2538b39c5158Smillertmodules.  It will add things like -I$(INST_ARCH) and other necessary
2539b39c5158Smillertflags so perl can see the modules you're about to install.
2540b39c5158Smillert
2541b39c5158Smillert=item PERL_SRC
2542b39c5158Smillert
2543b39c5158SmillertDirectory containing the Perl source code (use of this should be
2544b39c5158Smillertavoided, it may be undefined)
2545b39c5158Smillert
2546b39c5158Smillert=item PERM_DIR
2547b39c5158Smillert
25489f11ffb7Safresh1Available in version 6.51_01 and above.
25499f11ffb7Safresh1
2550b39c5158SmillertDesired permission for directories. Defaults to C<755>.
2551b39c5158Smillert
2552b39c5158Smillert=item PERM_RW
2553b39c5158Smillert
2554b39c5158SmillertDesired permission for read/writable files. Defaults to C<644>.
2555b39c5158Smillert
2556b39c5158Smillert=item PERM_RWX
2557b39c5158Smillert
2558b39c5158SmillertDesired permission for executable files. Defaults to C<755>.
2559b39c5158Smillert
2560b39c5158Smillert=item PL_FILES
2561b39c5158Smillert
2562b39c5158SmillertMakeMaker can run programs to generate files for you at build time.
2563b39c5158SmillertBy default any file named *.PL (except Makefile.PL and Build.PL) in
2564b39c5158Smillertthe top level directory will be assumed to be a Perl program and run
25659f11ffb7Safresh1passing its own basename in as an argument.  This basename is actually a build
25669f11ffb7Safresh1target, and there is an intention, but not a requirement, that the *.PL file
25679f11ffb7Safresh1make the file passed to to as an argument. For example...
2568b39c5158Smillert
2569b39c5158Smillert    perl foo.PL foo
2570b39c5158Smillert
2571b39c5158SmillertThis behavior can be overridden by supplying your own set of files to
2572b39c5158Smillertsearch.  PL_FILES accepts a hash ref, the key being the file to run
2573b39c5158Smillertand the value is passed in as the first argument when the PL file is run.
2574b39c5158Smillert
2575b39c5158Smillert    PL_FILES => {'bin/foobar.PL' => 'bin/foobar'}
2576b39c5158Smillert
25779f11ffb7Safresh1    PL_FILES => {'foo.PL' => 'foo.c'}
25789f11ffb7Safresh1
2579b39c5158SmillertWould run bin/foobar.PL like this:
2580b39c5158Smillert
2581b39c5158Smillert    perl bin/foobar.PL bin/foobar
2582b39c5158Smillert
2583b39c5158SmillertIf multiple files from one program are desired an array ref can be used.
2584b39c5158Smillert
2585b39c5158Smillert    PL_FILES => {'bin/foobar.PL' => [qw(bin/foobar1 bin/foobar2)]}
2586b39c5158Smillert
2587b39c5158SmillertIn this case the program will be run multiple times using each target file.
2588b39c5158Smillert
2589b39c5158Smillert    perl bin/foobar.PL bin/foobar1
2590b39c5158Smillert    perl bin/foobar.PL bin/foobar2
2591b39c5158Smillert
259256d68f1eSafresh1If an output file depends on extra input files beside the script itself,
259356d68f1eSafresh1a hash ref can be used in version 7.36 and above:
259456d68f1eSafresh1
259556d68f1eSafresh1    PL_FILES => { 'foo.PL' => {
259656d68f1eSafresh1        'foo.out' => 'foo.in',
259756d68f1eSafresh1        'bar.out' => [qw(bar1.in bar2.in)],
259856d68f1eSafresh1    }
259956d68f1eSafresh1
260056d68f1eSafresh1In this case the extra input files will be passed to the program after
260156d68f1eSafresh1the target file:
260256d68f1eSafresh1
260356d68f1eSafresh1   perl foo.PL foo.out foo.in
260456d68f1eSafresh1   perl foo.PL bar.out bar1.in bar2.in
260556d68f1eSafresh1
2606b39c5158SmillertPL files are normally run B<after> pm_to_blib and include INST_LIB and
2607e9ce3842Safresh1INST_ARCH in their C<@INC>, so the just built modules can be
2608b39c5158Smillertaccessed... unless the PL file is making a module (or anything else in
2609b39c5158SmillertPM) in which case it is run B<before> pm_to_blib and does not include
2610b39c5158SmillertINST_LIB and INST_ARCH in its C<@INC>.  This apparently odd behavior
26119f11ffb7Safresh1is there for backwards compatibility (and it's somewhat DWIM).  The argument
26129f11ffb7Safresh1passed to the .PL is set up as a target to build in the Makefile.  In other
26139f11ffb7Safresh1sections such as C<postamble> you can specify a dependency on the
26149f11ffb7Safresh1filename/argument that the .PL is supposed (or will have, now that that is
26159f11ffb7Safresh1is a dependency) to generate.  Note the file to be generated will still be
26169f11ffb7Safresh1generated and the .PL will still run even without an explicit dependency created
26179f11ffb7Safresh1by you, since the C<all> target still depends on running all eligible to run.PL
26189f11ffb7Safresh1files.
2619b39c5158Smillert
2620b39c5158Smillert=item PM
2621b39c5158Smillert
2622b39c5158SmillertHashref of .pm files and *.pl files to be installed.  e.g.
2623b39c5158Smillert
2624e5157e49Safresh1  {'name_of_file.pm' => '$(INST_LIB)/install_as.pm'}
2625b39c5158Smillert
2626b39c5158SmillertBy default this will include *.pm and *.pl and the files found in
2627b39c5158Smillertthe PMLIBDIRS directories.  Defining PM in the
2628b39c5158SmillertMakefile.PL will override PMLIBDIRS.
2629b39c5158Smillert
2630b39c5158Smillert=item PMLIBDIRS
2631b39c5158Smillert
2632b39c5158SmillertRef to array of subdirectories containing library files.  Defaults to
2633b39c5158Smillert[ 'lib', $(BASEEXT) ]. The directories will be scanned and I<any> files
2634b39c5158Smillertthey contain will be installed in the corresponding location in the
2635b39c5158Smillertlibrary.  A libscan() method can be used to alter the behaviour.
2636b39c5158SmillertDefining PM in the Makefile.PL will override PMLIBDIRS.
2637b39c5158Smillert
2638b39c5158Smillert(Where BASEEXT is the last component of NAME.)
2639b39c5158Smillert
2640b39c5158Smillert=item PM_FILTER
2641b39c5158Smillert
2642b39c5158SmillertA filter program, in the traditional Unix sense (input from stdin, output
2643b39c5158Smillertto stdout) that is passed on each .pm file during the build (in the
2644b39c5158Smillertpm_to_blib() phase).  It is empty by default, meaning no filtering is done.
26459f11ffb7Safresh1You could use:
2646b39c5158Smillert
26479f11ffb7Safresh1  PM_FILTER => 'perl -ne "print unless /^\\#/"',
2648b39c5158Smillert
26499f11ffb7Safresh1to remove all the leading comments on the fly during the build.  In order
26509f11ffb7Safresh1to be as portable as possible, please consider using a Perl one-liner
26519f11ffb7Safresh1rather than Unix (or other) utilities, as above.  The # is escaped for
26529f11ffb7Safresh1the Makefile, since what is going to be generated will then be:
2653b39c5158Smillert
26549f11ffb7Safresh1  PM_FILTER = perl -ne "print unless /^\#/"
2655b39c5158Smillert
26569f11ffb7Safresh1Without the \ before the #, we'd have the start of a Makefile comment,
2657b39c5158Smillertand the macro would be incorrectly defined.
2658b39c5158Smillert
26599f11ffb7Safresh1You will almost certainly be better off using the C<PL_FILES> system,
26609f11ffb7Safresh1instead. See above, or the L<ExtUtils::MakeMaker::FAQ> entry.
26619f11ffb7Safresh1
2662b39c5158Smillert=item POLLUTE
2663b39c5158Smillert
2664eac174f2Safresh1Prior to 5.6 various interpreter variables were available without a C<PL_>
2665eac174f2Safresh1prefix, eg. C<PL_undef> was available as C<undef>. As of release 5.6, these
2666eac174f2Safresh1are only defined if the POLLUTE flag is enabled:
2667b39c5158Smillert
2668b39c5158Smillert  perl Makefile.PL POLLUTE=1
2669b39c5158Smillert
2670b39c5158SmillertPlease inform the module author if this is necessary to successfully install
2671b39c5158Smillerta module under 5.6 or later.
2672b39c5158Smillert
2673b39c5158Smillert=item PPM_INSTALL_EXEC
2674b39c5158Smillert
2675b39c5158SmillertName of the executable used to run C<PPM_INSTALL_SCRIPT> below. (e.g. perl)
2676b39c5158Smillert
2677b39c5158Smillert=item PPM_INSTALL_SCRIPT
2678b39c5158Smillert
2679b39c5158SmillertName of the script that gets executed by the Perl Package Manager after
2680b39c5158Smillertthe installation of a package.
2681b39c5158Smillert
2682e5157e49Safresh1=item PPM_UNINSTALL_EXEC
2683e5157e49Safresh1
26849f11ffb7Safresh1Available in version 6.8502 and above.
26859f11ffb7Safresh1
2686e5157e49Safresh1Name of the executable used to run C<PPM_UNINSTALL_SCRIPT> below. (e.g. perl)
2687e5157e49Safresh1
2688e5157e49Safresh1=item PPM_UNINSTALL_SCRIPT
2689e5157e49Safresh1
26909f11ffb7Safresh1Available in version 6.8502 and above.
26919f11ffb7Safresh1
2692e5157e49Safresh1Name of the script that gets executed by the Perl Package Manager before
2693e5157e49Safresh1the removal of a package.
2694e5157e49Safresh1
2695b39c5158Smillert=item PREFIX
2696b39c5158Smillert
2697b39c5158SmillertThis overrides all the default install locations.  Man pages,
2698b39c5158Smillertlibraries, scripts, etc...  MakeMaker will try to make an educated
2699b39c5158Smillertguess about where to place things under the new PREFIX based on your
2700b39c5158SmillertConfig defaults.  Failing that, it will fall back to a structure
2701b39c5158Smillertwhich should be sensible for your platform.
2702b39c5158Smillert
2703e9ce3842Safresh1If you specify LIB or any INSTALL* variables they will not be affected
2704b39c5158Smillertby the PREFIX.
2705b39c5158Smillert
2706b39c5158Smillert=item PREREQ_FATAL
2707b39c5158Smillert
2708b39c5158SmillertBool. If this parameter is true, failing to have the required modules
2709b39c5158Smillert(or the right versions thereof) will be fatal. C<perl Makefile.PL>
2710b39c5158Smillertwill C<die> instead of simply informing the user of the missing dependencies.
2711b39c5158Smillert
2712b39c5158SmillertIt is I<extremely> rare to have to use C<PREREQ_FATAL>. Its use by module
2713b39c5158Smillertauthors is I<strongly discouraged> and should never be used lightly.
271448950c12Ssthen
2715e5157e49Safresh1For dependencies that are required in order to run C<Makefile.PL>,
2716e5157e49Safresh1see C<CONFIGURE_REQUIRES>.
2717e5157e49Safresh1
2718e9ce3842Safresh1Module installation tools have ways of resolving unmet dependencies but
2719b39c5158Smillertto do that they need a F<Makefile>.  Using C<PREREQ_FATAL> breaks this.
2720b39c5158SmillertThat's bad.
2721b39c5158Smillert
272248950c12SsthenAssuming you have good test coverage, your tests should fail with
272348950c12Ssthenmissing dependencies informing the user more strongly that something
272448950c12Ssthenis wrong.  You can write a F<t/00compile.t> test which will simply
272548950c12Ssthencheck that your code compiles and stop "make test" prematurely if it
272648950c12Ssthendoesn't.  See L<Test::More/BAIL_OUT> for more details.
2727b39c5158Smillert
2728b39c5158Smillert
2729b39c5158Smillert=item PREREQ_PM
2730b39c5158Smillert
2731b39c5158SmillertA hash of modules that are needed to run your module.  The keys are
2732b39c5158Smillertthe module names ie. Test::More, and the minimum version is the
2733b39c5158Smillertvalue. If the required version number is 0 any version will do.
27349f11ffb7Safresh1The versions given may be a Perl v-string (see L<version>) or a range
27359f11ffb7Safresh1(see L<CPAN::Meta::Requirements>).
2736b39c5158Smillert
27379f11ffb7Safresh1This will go into the C<requires> field of your F<META.yml> and the
27389f11ffb7Safresh1C<runtime> of the C<prereqs> field of your F<META.json>.
2739b39c5158Smillert
2740b39c5158Smillert    PREREQ_PM => {
2741b39c5158Smillert        # Require Test::More at least 0.47
2742b39c5158Smillert        "Test::More" => "0.47",
2743b39c5158Smillert
2744b39c5158Smillert        # Require any version of Acme::Buffy
2745b39c5158Smillert        "Acme::Buffy" => 0,
2746b39c5158Smillert    }
2747b39c5158Smillert
2748b39c5158Smillert=item PREREQ_PRINT
2749b39c5158Smillert
2750b39c5158SmillertBool.  If this parameter is true, the prerequisites will be printed to
2751b39c5158Smillertstdout and MakeMaker will exit.  The output format is an evalable hash
2752b39c5158Smillertref.
2753b39c5158Smillert
2754b39c5158Smillert  $PREREQ_PM = {
2755b39c5158Smillert                 'A::B' => Vers1,
2756b39c5158Smillert                 'C::D' => Vers2,
2757b39c5158Smillert                 ...
2758b39c5158Smillert               };
2759b39c5158Smillert
2760b39c5158SmillertIf a distribution defines a minimal required perl version, this is
2761b39c5158Smillertadded to the output as an additional line of the form:
2762b39c5158Smillert
2763b39c5158Smillert  $MIN_PERL_VERSION = '5.008001';
2764b39c5158Smillert
2765e9ce3842Safresh1If BUILD_REQUIRES is not empty, it will be dumped as $BUILD_REQUIRES hashref.
2766b39c5158Smillert
2767b39c5158Smillert=item PRINT_PREREQ
2768b39c5158Smillert
2769b39c5158SmillertRedHatism for C<PREREQ_PRINT>.  The output format is different, though:
2770b39c5158Smillert
2771b39c5158Smillert    perl(A::B)>=Vers1 perl(C::D)>=Vers2 ...
2772b39c5158Smillert
2773b39c5158SmillertA minimal required perl version, if present, will look like this:
2774b39c5158Smillert
2775b39c5158Smillert    perl(perl)>=5.008001
2776b39c5158Smillert
2777b39c5158Smillert=item SITEPREFIX
2778b39c5158Smillert
2779b39c5158SmillertLike PERLPREFIX, but only for the site install locations.
2780b39c5158Smillert
2781b39c5158SmillertDefaults to $Config{siteprefixexp}.  Perls prior to 5.6.0 didn't have
2782b39c5158Smillertan explicit siteprefix in the Config.  In those cases
2783b39c5158Smillert$Config{installprefix} will be used.
2784b39c5158Smillert
2785b39c5158SmillertOverridable by PREFIX
2786b39c5158Smillert
2787b39c5158Smillert=item SIGN
2788b39c5158Smillert
27899f11ffb7Safresh1Available in version 6.18 and above.
27909f11ffb7Safresh1
2791b39c5158SmillertWhen true, perform the generation and addition to the MANIFEST of the
2792b39c5158SmillertSIGNATURE file in the distdir during 'make distdir', via 'cpansign
2793b39c5158Smillert-s'.
2794b39c5158Smillert
2795b39c5158SmillertNote that you need to install the Module::Signature module to
2796b39c5158Smillertperform this operation.
2797b39c5158Smillert
2798b39c5158SmillertDefaults to false.
2799b39c5158Smillert
2800b39c5158Smillert=item SKIP
2801b39c5158Smillert
2802b39c5158SmillertArrayref. E.g. [qw(name1 name2)] skip (do not write) sections of the
2803b39c5158SmillertMakefile. Caution! Do not use the SKIP attribute for the negligible
2804b39c5158Smillertspeedup. It may seriously damage the resulting Makefile. Only use it
2805b39c5158Smillertif you really need it.
2806b39c5158Smillert
2807e9ce3842Safresh1=item TEST_REQUIRES
2808e9ce3842Safresh1
2809e5157e49Safresh1Available in version 6.64 and above.
2810e5157e49Safresh1
2811e9ce3842Safresh1A hash of modules that are needed to test your module but not run or
2812e9ce3842Safresh1build it.
2813e9ce3842Safresh1
2814e5157e49Safresh1This 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>.
2815e9ce3842Safresh1
2816e9ce3842Safresh1The format is the same as PREREQ_PM.
2817e9ce3842Safresh1
2818b39c5158Smillert=item TYPEMAPS
2819b39c5158Smillert
2820b39c5158SmillertRef to array of typemap file names.  Use this when the typemaps are
2821b39c5158Smillertin some directory other than the current directory or when they are
2822b39c5158Smillertnot named B<typemap>.  The last typemap in the list takes
2823b39c5158Smillertprecedence.  A typemap in the current directory has highest
2824b39c5158Smillertprecedence, even if it isn't listed in TYPEMAPS.  The default system
2825b39c5158Smillerttypemap has lowest precedence.
2826b39c5158Smillert
2827b39c5158Smillert=item VENDORPREFIX
2828b39c5158Smillert
2829b39c5158SmillertLike PERLPREFIX, but only for the vendor install locations.
2830b39c5158Smillert
2831b39c5158SmillertDefaults to $Config{vendorprefixexp}.
2832b39c5158Smillert
2833b39c5158SmillertOverridable by PREFIX
2834b39c5158Smillert
2835b39c5158Smillert=item VERBINST
2836b39c5158Smillert
2837b39c5158SmillertIf true, make install will be verbose
2838b39c5158Smillert
2839b39c5158Smillert=item VERSION
2840b39c5158Smillert
2841b39c5158SmillertYour version number for distributing the package.  This defaults to
2842b39c5158Smillert0.1.
2843b39c5158Smillert
2844b39c5158Smillert=item VERSION_FROM
2845b39c5158Smillert
2846b39c5158SmillertInstead of specifying the VERSION in the Makefile.PL you can let
2847b39c5158SmillertMakeMaker parse a file to determine the version number. The parsing
2848b39c5158Smillertroutine requires that the file named by VERSION_FROM contains one
2849b39c5158Smillertsingle line to compute the version number. The first line in the file
2850b39c5158Smillertthat contains something like a $VERSION assignment or C<package Name
2851b39c5158SmillertVERSION> will be used. The following lines will be parsed o.k.:
2852b39c5158Smillert
2853b39c5158Smillert    # Good
2854b39c5158Smillert    package Foo::Bar 1.23;                      # 1.23
2855b39c5158Smillert    $VERSION   = '1.00';                        # 1.00
2856b39c5158Smillert    *VERSION   = \'1.01';                       # 1.01
2857b39c5158Smillert    ($VERSION) = q$Revision$ =~ /(\d+)/g;       # The digits in $Revision$
2858b39c5158Smillert    $FOO::VERSION = '1.10';                     # 1.10
2859b39c5158Smillert    *FOO::VERSION = \'1.11';                    # 1.11
2860b39c5158Smillert
2861b39c5158Smillertbut these will fail:
2862b39c5158Smillert
2863b39c5158Smillert    # Bad
2864b39c5158Smillert    my $VERSION         = '1.01';
2865b39c5158Smillert    local $VERSION      = '1.02';
2866b39c5158Smillert    local $FOO::VERSION = '1.30';
2867b39c5158Smillert
2868e5157e49Safresh1(Putting C<my> or C<local> on the preceding line will work o.k.)
2869e5157e49Safresh1
2870e9ce3842Safresh1"Version strings" are incompatible and should not be used.
2871b39c5158Smillert
2872b39c5158Smillert    # Bad
2873b39c5158Smillert    $VERSION = 1.2.3;
2874b39c5158Smillert    $VERSION = v1.2.3;
2875b39c5158Smillert
2876b39c5158SmillertL<version> objects are fine.  As of MakeMaker 6.35 version.pm will be
2877b39c5158Smillertautomatically loaded, but you must declare the dependency on version.pm.
2878b39c5158SmillertFor compatibility with older MakeMaker you should load on the same line
2879b39c5158Smillertas $VERSION is declared.
2880b39c5158Smillert
2881b39c5158Smillert    # All on one line
2882b39c5158Smillert    use version; our $VERSION = qv(1.2.3);
2883b39c5158Smillert
2884b39c5158SmillertThe file named in VERSION_FROM is not added as a dependency to
2885b39c5158SmillertMakefile. This is not really correct, but it would be a major pain
2886b39c5158Smillertduring development to have to rewrite the Makefile for any smallish
2887b39c5158Smillertchange in that file. If you want to make sure that the Makefile
2888b39c5158Smillertcontains the correct VERSION macro after any change of the file, you
2889b39c5158Smillertwould have to do something like
2890b39c5158Smillert
2891b39c5158Smillert    depend => { Makefile => '$(VERSION_FROM)' }
2892b39c5158Smillert
2893b39c5158SmillertSee attribute C<depend> below.
2894b39c5158Smillert
2895b39c5158Smillert=item VERSION_SYM
2896b39c5158Smillert
2897b39c5158SmillertA sanitized VERSION with . replaced by _.  For places where . has
2898b39c5158Smillertspecial meaning (some filesystems, RCS labels, etc...)
2899b39c5158Smillert
2900b39c5158Smillert=item XS
2901b39c5158Smillert
2902b39c5158SmillertHashref of .xs files. MakeMaker will default this.  e.g.
2903b39c5158Smillert
2904b39c5158Smillert  {'name_of_file.xs' => 'name_of_file.c'}
2905b39c5158Smillert
2906b39c5158SmillertThe .c files will automatically be included in the list of files
2907b39c5158Smillertdeleted by a make clean.
2908b39c5158Smillert
29099f11ffb7Safresh1=item XSBUILD
29109f11ffb7Safresh1
29119f11ffb7Safresh1Available in version 7.12 and above.
29129f11ffb7Safresh1
29139f11ffb7Safresh1Hashref with options controlling the operation of C<XSMULTI>:
29149f11ffb7Safresh1
29159f11ffb7Safresh1  {
29169f11ffb7Safresh1    xs => {
29179f11ffb7Safresh1        all => {
29189f11ffb7Safresh1            # options applying to all .xs files for this distribution
29199f11ffb7Safresh1        },
29209f11ffb7Safresh1        'lib/Class/Name/File' => { # specifically for this file
29219f11ffb7Safresh1            DEFINE => '-Dfunktastic', # defines for only this file
29229f11ffb7Safresh1            INC => "-I$funkyliblocation", # include flags for only this file
29239f11ffb7Safresh1            # OBJECT => 'lib/Class/Name/File$(OBJ_EXT)', # default
29249f11ffb7Safresh1            LDFROM => "lib/Class/Name/File\$(OBJ_EXT) $otherfile\$(OBJ_EXT)", # what's linked
29259f11ffb7Safresh1        },
29269f11ffb7Safresh1    },
29279f11ffb7Safresh1  }
29289f11ffb7Safresh1
29299f11ffb7Safresh1Note C<xs> is the file-extension. More possibilities may arise in the
29309f11ffb7Safresh1future. Note that object names are specified without their XS extension.
29319f11ffb7Safresh1
29329f11ffb7Safresh1C<LDFROM> defaults to the same as C<OBJECT>. C<OBJECT> defaults to,
29339f11ffb7Safresh1for C<XSMULTI>, just the XS filename with the extension replaced with
29349f11ffb7Safresh1the compiler-specific object-file extension.
29359f11ffb7Safresh1
29369f11ffb7Safresh1The distinction between C<OBJECT> and C<LDFROM>: C<OBJECT> is the make
29379f11ffb7Safresh1target, so make will try to build it. However, C<LDFROM> is what will
29389f11ffb7Safresh1actually be linked together to make the shared object or static library
29399f11ffb7Safresh1(SO/SL), so if you override it, make sure it includes what you want to
29409f11ffb7Safresh1make the final SO/SL, almost certainly including the XS basename with
29419f11ffb7Safresh1C<$(OBJ_EXT)> appended.
29429f11ffb7Safresh1
29439f11ffb7Safresh1=item XSMULTI
29449f11ffb7Safresh1
29459f11ffb7Safresh1Available in version 7.12 and above.
29469f11ffb7Safresh1
29479f11ffb7Safresh1When this is set to C<1>, multiple XS files may be placed under F<lib/>
29489f11ffb7Safresh1next to their corresponding C<*.pm> files (this is essential for compiling
29499f11ffb7Safresh1with the correct C<VERSION> values). This feature should be considered
29509f11ffb7Safresh1experimental, and details of it may change.
29519f11ffb7Safresh1
29529f11ffb7Safresh1This feature was inspired by, and small portions of code copied from,
29539f11ffb7Safresh1L<ExtUtils::MakeMaker::BigHelper>. Hopefully this feature will render
29549f11ffb7Safresh1that module mainly obsolete.
29559f11ffb7Safresh1
2956b39c5158Smillert=item XSOPT
2957b39c5158Smillert
2958b39c5158SmillertString of options to pass to xsubpp.  This might include C<-C++> or
2959b39c5158SmillertC<-extern>.  Do not include typemaps here; the TYPEMAP parameter exists for
2960b39c5158Smillertthat purpose.
2961b39c5158Smillert
2962b39c5158Smillert=item XSPROTOARG
2963b39c5158Smillert
2964eac174f2Safresh1May be set to C<-prototypes>, C<-noprototypes> or the empty string.  The
2965e5157e49Safresh1empty string is equivalent to the xsubpp default, or C<-noprototypes>.
2966e5157e49Safresh1See the xsubpp documentation for details.  MakeMaker
2967b39c5158Smillertdefaults to the empty string.
2968b39c5158Smillert
2969b39c5158Smillert=item XS_VERSION
2970b39c5158Smillert
2971b39c5158SmillertYour version number for the .xs file of this package.  This defaults
2972b39c5158Smillertto the value of the VERSION attribute.
2973b39c5158Smillert
2974b39c5158Smillert=back
2975b39c5158Smillert
2976b39c5158Smillert=head2 Additional lowercase attributes
2977b39c5158Smillert
2978b39c5158Smillertcan be used to pass parameters to the methods which implement that
2979b39c5158Smillertpart of the Makefile.  Parameters are specified as a hash ref but are
2980b39c5158Smillertpassed to the method as a hash.
2981b39c5158Smillert
2982b39c5158Smillert=over 2
2983b39c5158Smillert
2984b39c5158Smillert=item clean
2985b39c5158Smillert
2986b39c5158Smillert  {FILES => "*.xyz foo"}
2987b39c5158Smillert
2988b39c5158Smillert=item depend
2989b39c5158Smillert
2990b39c5158Smillert  {ANY_TARGET => ANY_DEPENDENCY, ...}
2991b39c5158Smillert
2992b39c5158Smillert(ANY_TARGET must not be given a double-colon rule by MakeMaker.)
2993b39c5158Smillert
2994b39c5158Smillert=item dist
2995b39c5158Smillert
2996b39c5158Smillert  {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => '.gz',
2997b39c5158Smillert  SHAR => 'shar -m', DIST_CP => 'ln', ZIP => '/bin/zip',
2998b39c5158Smillert  ZIPFLAGS => '-rl', DIST_DEFAULT => 'private tardist' }
2999b39c5158Smillert
3000b39c5158SmillertIf you specify COMPRESS, then SUFFIX should also be altered, as it is
3001b39c5158Smillertneeded to tell make the target file of the compression. Setting
3002b39c5158SmillertDIST_CP to ln can be useful, if you need to preserve the timestamps on
3003b39c5158Smillertyour files. DIST_CP can take the values 'cp', which copies the file,
3004b39c5158Smillert'ln', which links the file, and 'best' which copies symbolic links and
3005b39c5158Smillertlinks the rest. Default is 'best'.
3006b39c5158Smillert
3007b39c5158Smillert=item dynamic_lib
3008b39c5158Smillert
3009b39c5158Smillert  {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'}
3010b39c5158Smillert
3011b39c5158Smillert=item linkext
3012b39c5158Smillert
3013b39c5158Smillert  {LINKTYPE => 'static', 'dynamic' or ''}
3014b39c5158Smillert
3015b39c5158SmillertNB: Extensions that have nothing but *.pm files had to say
3016b39c5158Smillert
3017b39c5158Smillert  {LINKTYPE => ''}
3018b39c5158Smillert
3019b39c5158Smillertwith Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
3020b39c5158Smillertcan be deleted safely. MakeMaker recognizes when there's nothing to
3021b39c5158Smillertbe linked.
3022b39c5158Smillert
3023b39c5158Smillert=item macro
3024b39c5158Smillert
3025b39c5158Smillert  {ANY_MACRO => ANY_VALUE, ...}
3026b39c5158Smillert
3027b39c5158Smillert=item postamble
3028b39c5158Smillert
302956d68f1eSafresh1Anything put here will be passed to
303056d68f1eSafresh1L<MY::postamble()|ExtUtils::MM_Any/postamble (o)> if you have one.
3031b39c5158Smillert
3032b39c5158Smillert=item realclean
3033b39c5158Smillert
3034b39c5158Smillert  {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
3035b39c5158Smillert
3036b39c5158Smillert=item test
3037b39c5158Smillert
3038e5157e49Safresh1Specify the targets for testing.
3039e5157e49Safresh1
3040b39c5158Smillert  {TESTS => 't/*.t'}
3041b39c5158Smillert
3042e5157e49Safresh1C<RECURSIVE_TEST_FILES> can be used to include all directories
3043e5157e49Safresh1recursively under C<t> that contain C<.t> files. It will be ignored if
3044e5157e49Safresh1you provide your own C<TESTS> attribute, defaults to false.
3045e5157e49Safresh1
3046e5157e49Safresh1  {RECURSIVE_TEST_FILES=>1}
3047e5157e49Safresh1
30489f11ffb7Safresh1This is supported since 6.76
30499f11ffb7Safresh1
3050b39c5158Smillert=item tool_autosplit
3051b39c5158Smillert
3052b39c5158Smillert  {MAXLEN => 8}
3053b39c5158Smillert
3054b39c5158Smillert=back
3055b39c5158Smillert
3056b39c5158Smillert=head2 Overriding MakeMaker Methods
3057b39c5158Smillert
3058b39c5158SmillertIf you cannot achieve the desired Makefile behaviour by specifying
3059b39c5158Smillertattributes you may define private subroutines in the Makefile.PL.
3060b39c5158SmillertEach subroutine returns the text it wishes to have written to
3061b39c5158Smillertthe Makefile. To override a section of the Makefile you can
3062b39c5158Smillerteither say:
3063b39c5158Smillert
3064b39c5158Smillert        sub MY::c_o { "new literal text" }
3065b39c5158Smillert
3066b39c5158Smillertor you can edit the default by saying something like:
3067b39c5158Smillert
3068b39c5158Smillert        package MY; # so that "SUPER" works right
3069b39c5158Smillert        sub c_o {
3070b39c5158Smillert            my $inherited = shift->SUPER::c_o(@_);
3071b39c5158Smillert            $inherited =~ s/old text/new text/;
3072b39c5158Smillert            $inherited;
3073b39c5158Smillert        }
3074b39c5158Smillert
3075b39c5158SmillertIf you are running experiments with embedding perl as a library into
3076b39c5158Smillertother applications, you might find MakeMaker is not sufficient. You'd
307756d68f1eSafresh1better have a look at L<ExtUtils::Embed> which is a collection of utilities
3078b39c5158Smillertfor embedding.
3079b39c5158Smillert
3080b39c5158SmillertIf you still need a different solution, try to develop another
3081b39c5158Smillertsubroutine that fits your needs and submit the diffs to
3082b39c5158SmillertC<makemaker@perl.org>
3083b39c5158Smillert
3084b39c5158SmillertFor a complete description of all MakeMaker methods see
3085b39c5158SmillertL<ExtUtils::MM_Unix>.
3086b39c5158Smillert
3087b39c5158SmillertHere is a simple example of how to add a new target to the generated
3088b39c5158SmillertMakefile:
3089b39c5158Smillert
3090b39c5158Smillert    sub MY::postamble {
3091b39c5158Smillert        return <<'MAKE_FRAG';
3092b39c5158Smillert    $(MYEXTLIB): sdbm/Makefile
3093b39c5158Smillert            cd sdbm && $(MAKE) all
3094b39c5158Smillert
3095b39c5158Smillert    MAKE_FRAG
3096b39c5158Smillert    }
3097b39c5158Smillert
3098b39c5158Smillert=head2 The End Of Cargo Cult Programming
3099b39c5158Smillert
3100b39c5158SmillertWriteMakefile() now does some basic sanity checks on its parameters to
3101b39c5158Smillertprotect against typos and malformatted values.  This means some things
3102b39c5158Smillertwhich happened to work in the past will now throw warnings and
3103b39c5158Smillertpossibly produce internal errors.
3104b39c5158Smillert
3105b39c5158SmillertSome of the most common mistakes:
3106b39c5158Smillert
3107b39c5158Smillert=over 2
3108b39c5158Smillert
3109b39c5158Smillert=item C<< MAN3PODS => ' ' >>
3110b39c5158Smillert
3111b39c5158SmillertThis is commonly used to suppress the creation of man pages.  MAN3PODS
3112b39c5158Smillerttakes a hash ref not a string, but the above worked by accident in old
3113b39c5158Smillertversions of MakeMaker.
3114b39c5158Smillert
3115b39c5158SmillertThe correct code is C<< MAN3PODS => { } >>.
3116b39c5158Smillert
3117b39c5158Smillert=back
3118b39c5158Smillert
3119b39c5158Smillert
3120b39c5158Smillert=head2 Hintsfile support
3121b39c5158Smillert
3122e9ce3842Safresh1MakeMaker.pm uses the architecture-specific information from
3123b39c5158SmillertConfig.pm. In addition it evaluates architecture specific hints files
3124b39c5158Smillertin a C<hints/> directory. The hints files are expected to be named
3125b39c5158Smillertlike their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
3126b39c5158Smillertname extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
3127b39c5158SmillertMakeMaker within the WriteMakefile() subroutine, and can be used to
3128b39c5158Smillertexecute commands as well as to include special variables. The rules
3129b39c5158Smillertwhich hintsfile is chosen are the same as in Configure.
3130b39c5158Smillert
3131b39c5158SmillertThe hintsfile is eval()ed immediately after the arguments given to
3132b39c5158SmillertWriteMakefile are stuffed into a hash reference $self but before this
3133b39c5158Smillertreference becomes blessed. So if you want to do the equivalent to
3134b39c5158Smillertoverride or create an attribute you would say something like
3135b39c5158Smillert
3136b39c5158Smillert    $self->{LIBS} = ['-ldbm -lucb -lc'];
3137b39c5158Smillert
3138b39c5158Smillert=head2 Distribution Support
3139b39c5158Smillert
3140b39c5158SmillertFor authors of extensions MakeMaker provides several Makefile
314156d68f1eSafresh1targets. Most of the support comes from the L<ExtUtils::Manifest> module,
3142b39c5158Smillertwhere additional documentation can be found.
3143b39c5158Smillert
3144b39c5158Smillert=over 4
3145b39c5158Smillert
3146b39c5158Smillert=item    make distcheck
3147b39c5158Smillert
3148b39c5158Smillertreports which files are below the build directory but not in the
314956d68f1eSafresh1MANIFEST file and vice versa. (See L<ExtUtils::Manifest/fullcheck> for
3150b39c5158Smillertdetails)
3151b39c5158Smillert
3152b39c5158Smillert=item    make skipcheck
3153b39c5158Smillert
3154b39c5158Smillertreports which files are skipped due to the entries in the
315556d68f1eSafresh1C<MANIFEST.SKIP> file (See L<ExtUtils::Manifest/skipcheck> for
3156b39c5158Smillertdetails)
3157b39c5158Smillert
3158b39c5158Smillert=item    make distclean
3159b39c5158Smillert
3160b39c5158Smillertdoes a realclean first and then the distcheck. Note that this is not
3161b39c5158Smillertneeded to build a new distribution as long as you are sure that the
3162b39c5158SmillertMANIFEST file is ok.
3163b39c5158Smillert
3164e5157e49Safresh1=item    make veryclean
3165e5157e49Safresh1
3166e5157e49Safresh1does a realclean first and then removes backup files such as C<*~>,
3167e5157e49Safresh1C<*.bak>, C<*.old> and C<*.orig>
3168e5157e49Safresh1
3169b39c5158Smillert=item    make manifest
3170b39c5158Smillert
3171b39c5158Smillertrewrites the MANIFEST file, adding all remaining files found (See
317256d68f1eSafresh1L<ExtUtils::Manifest/mkmanifest> for details)
3173b39c5158Smillert
3174b39c5158Smillert=item    make distdir
3175b39c5158Smillert
3176b39c5158SmillertCopies all the files that are in the MANIFEST file to a newly created
3177b39c5158Smillertdirectory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
3178b39c5158Smillertexists, it will be removed first.
3179b39c5158Smillert
318048950c12SsthenAdditionally, it will create META.yml and META.json module meta-data file
318148950c12Ssthenin the distdir and add this to the distdir's MANIFEST.  You can shut this
3182b39c5158Smillertbehavior off with the NO_META flag.
3183b39c5158Smillert
3184b39c5158Smillert=item   make disttest
3185b39c5158Smillert
3186b39c5158SmillertMakes a distdir first, and runs a C<perl Makefile.PL>, a make, and
3187b39c5158Smillerta make test in that directory.
3188b39c5158Smillert
3189b39c5158Smillert=item    make tardist
3190b39c5158Smillert
3191b39c5158SmillertFirst does a distdir. Then a command $(PREOP) which defaults to a null
3192b39c5158Smillertcommand, followed by $(TO_UNIX), which defaults to a null command under
3193b39c5158SmillertUNIX, and will convert files in distribution directory to UNIX format
3194b39c5158Smillertotherwise. Next it runs C<tar> on that directory into a tarfile and
3195b39c5158Smillertdeletes the directory. Finishes with a command $(POSTOP) which
3196b39c5158Smillertdefaults to a null command.
3197b39c5158Smillert
3198b39c5158Smillert=item    make dist
3199b39c5158Smillert
3200b39c5158SmillertDefaults to $(DIST_DEFAULT) which in turn defaults to tardist.
3201b39c5158Smillert
3202b39c5158Smillert=item    make uutardist
3203b39c5158Smillert
3204b39c5158SmillertRuns a tardist first and uuencodes the tarfile.
3205b39c5158Smillert
3206b39c5158Smillert=item    make shdist
3207b39c5158Smillert
3208b39c5158SmillertFirst does a distdir. Then a command $(PREOP) which defaults to a null
3209b39c5158Smillertcommand. Next it runs C<shar> on that directory into a sharfile and
3210b39c5158Smillertdeletes the intermediate directory again. Finishes with a command
3211b39c5158Smillert$(POSTOP) which defaults to a null command.  Note: For shdist to work
3212b39c5158Smillertproperly a C<shar> program that can handle directories is mandatory.
3213b39c5158Smillert
3214b39c5158Smillert=item    make zipdist
3215b39c5158Smillert
3216b39c5158SmillertFirst does a distdir. Then a command $(PREOP) which defaults to a null
3217b39c5158Smillertcommand. Runs C<$(ZIP) $(ZIPFLAGS)> on that directory into a
3218b39c5158Smillertzipfile. Then deletes that directory. Finishes with a command
3219b39c5158Smillert$(POSTOP) which defaults to a null command.
3220b39c5158Smillert
3221b39c5158Smillert=item    make ci
3222b39c5158Smillert
3223b39c5158SmillertDoes a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file.
3224b39c5158Smillert
3225b39c5158Smillert=back
3226b39c5158Smillert
3227b39c5158SmillertCustomization of the dist targets can be done by specifying a hash
3228b39c5158Smillertreference to the dist attribute of the WriteMakefile call. The
3229b39c5158Smillertfollowing parameters are recognized:
3230b39c5158Smillert
3231b39c5158Smillert    CI           ('ci -u')
3232b39c5158Smillert    COMPRESS     ('gzip --best')
3233b39c5158Smillert    POSTOP       ('@ :')
3234b39c5158Smillert    PREOP        ('@ :')
3235b39c5158Smillert    TO_UNIX      (depends on the system)
3236b39c5158Smillert    RCS_LABEL    ('rcs -q -Nv$(VERSION_SYM):')
3237b39c5158Smillert    SHAR         ('shar')
3238b39c5158Smillert    SUFFIX       ('.gz')
3239b39c5158Smillert    TAR          ('tar')
3240b39c5158Smillert    TARFLAGS     ('cvf')
3241b39c5158Smillert    ZIP          ('zip')
3242b39c5158Smillert    ZIPFLAGS     ('-r')
3243b39c5158Smillert
3244b39c5158SmillertAn example:
3245b39c5158Smillert
3246b39c5158Smillert    WriteMakefile(
3247b39c5158Smillert        ...other options...
3248b39c5158Smillert        dist => {
3249b39c5158Smillert            COMPRESS => "bzip2",
3250b39c5158Smillert            SUFFIX   => ".bz2"
3251b39c5158Smillert        }
3252b39c5158Smillert    );
3253b39c5158Smillert
3254b39c5158Smillert
325548950c12Ssthen=head2 Module Meta-Data (META and MYMETA)
3256b39c5158Smillert
3257b39c5158SmillertLong plaguing users of MakeMaker based modules has been the problem of
3258b39c5158Smillertgetting basic information about the module out of the sources
3259b39c5158SmillertI<without> running the F<Makefile.PL> and doing a bunch of messy
326048950c12Ssthenheuristics on the resulting F<Makefile>.  Over the years, it has become
326148950c12Ssthenstandard to keep this information in one or more CPAN Meta files
326248950c12Ssthendistributed with each distribution.
3263b39c5158Smillert
326448950c12SsthenThe original format of CPAN Meta files was L<YAML> and the corresponding
326548950c12Ssthenfile was called F<META.yml>.  In 2010, version 2 of the L<CPAN::Meta::Spec>
326648950c12Ssthenwas released, which mandates JSON format for the metadata in order to
326748950c12Ssthenovercome certain compatibility issues between YAML serializers and to
326848950c12Ssthenavoid breaking older clients unable to handle a new version of the spec.
326948950c12SsthenThe L<CPAN::Meta> library is now standard for accessing old and new-style
327048950c12SsthenMeta files.
3271b39c5158Smillert
327248950c12SsthenIf L<CPAN::Meta> is installed, MakeMaker will automatically generate
327348950c12SsthenF<META.json> and F<META.yml> files for you and add them to your F<MANIFEST> as
327448950c12Ssthenpart of the 'distdir' target (and thus the 'dist' target).  This is intended to
327548950c12Ssthenseamlessly and rapidly populate CPAN with module meta-data.  If you wish to
327648950c12Ssthenshut this feature off, set the C<NO_META> C<WriteMakefile()> flag to true.
3277b39c5158Smillert
32789f11ffb7Safresh1At the 2008 QA Hackathon in Oslo, Perl module toolchain maintainers agreed
327948950c12Ssthento use the CPAN Meta format to communicate post-configuration requirements
328048950c12Ssthenbetween toolchain components.  These files, F<MYMETA.json> and F<MYMETA.yml>,
328148950c12Ssthenare generated when F<Makefile.PL> generates a F<Makefile> (if L<CPAN::Meta>
32829f11ffb7Safresh1is installed).  Clients like L<CPAN> or L<CPANPLUS> will read these
328348950c12Ssthenfiles to see what prerequisites must be fulfilled before building or testing
32849f11ffb7Safresh1the distribution.  If you wish to shut this feature off, set the C<NO_MYMETA>
3285*e0680481Safresh1C<WriteMakefile()> flag to true.
3286b39c5158Smillert
3287b39c5158Smillert=head2 Disabling an extension
3288b39c5158Smillert
3289b39c5158SmillertIf some events detected in F<Makefile.PL> imply that there is no way
3290b39c5158Smillertto create the Module, but this is a normal state of things, then you
3291b39c5158Smillertcan create a F<Makefile> which does nothing, but succeeds on all the
3292b39c5158Smillert"usual" build targets.  To do so, use
3293b39c5158Smillert
3294b39c5158Smillert    use ExtUtils::MakeMaker qw(WriteEmptyMakefile);
3295b39c5158Smillert    WriteEmptyMakefile();
3296b39c5158Smillert
3297b39c5158Smillertinstead of WriteMakefile().
3298b39c5158Smillert
3299b39c5158SmillertThis may be useful if other modules expect this module to be I<built>
3300b39c5158SmillertOK, as opposed to I<work> OK (say, this system-dependent module builds
3301b39c5158Smillertin a subdirectory of some other distribution, or is listed as a
3302b39c5158Smillertdependency in a CPAN::Bundle, but the functionality is supported by
3303b39c5158Smillertdifferent means on the current architecture).
3304b39c5158Smillert
3305b39c5158Smillert=head2 Other Handy Functions
3306b39c5158Smillert
3307b39c5158Smillert=over 4
3308b39c5158Smillert
3309b39c5158Smillert=item prompt
3310b39c5158Smillert
3311b39c5158Smillert    my $value = prompt($message);
3312b39c5158Smillert    my $value = prompt($message, $default);
3313b39c5158Smillert
3314b39c5158SmillertThe C<prompt()> function provides an easy way to request user input
3315b39c5158Smillertused to write a makefile.  It displays the $message as a prompt for
3316b39c5158Smillertinput.  If a $default is provided it will be used as a default.  The
3317b39c5158Smillertfunction returns the $value selected by the user.
3318b39c5158Smillert
3319b39c5158SmillertIf C<prompt()> detects that it is not running interactively and there
3320b39c5158Smillertis nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
3321b39c5158Smillertis set to true, the $default will be used without prompting.  This
3322b39c5158Smillertprevents automated processes from blocking on user input.
3323b39c5158Smillert
3324b39c5158SmillertIf no $default is provided an empty string will be used instead.
3325b39c5158Smillert
33269f11ffb7Safresh1=item os_unsupported
33279f11ffb7Safresh1
33289f11ffb7Safresh1  os_unsupported();
33299f11ffb7Safresh1  os_unsupported if $^O eq 'MSWin32';
33309f11ffb7Safresh1
33319f11ffb7Safresh1The C<os_unsupported()> function provides a way to correctly exit your
33329f11ffb7Safresh1C<Makefile.PL> before calling C<WriteMakefile>. It is essentially a
33339f11ffb7Safresh1C<die> with the message "OS unsupported".
33349f11ffb7Safresh1
33359f11ffb7Safresh1This is supported since 7.26
33369f11ffb7Safresh1
3337b39c5158Smillert=back
3338b39c5158Smillert
3339b8851fccSafresh1=head2 Supported versions of Perl
3340b8851fccSafresh1
3341b8851fccSafresh1Please note that while this module works on Perl 5.6, it is no longer
3342b8851fccSafresh1being routinely tested on 5.6 - the earliest Perl version being routinely
3343b8851fccSafresh1tested, and expressly supported, is 5.8.1. However, patches to repair
3344b8851fccSafresh1any breakage on 5.6 are still being accepted.
3345b39c5158Smillert
3346b39c5158Smillert=head1 ENVIRONMENT
3347b39c5158Smillert
3348b39c5158Smillert=over 4
3349b39c5158Smillert
3350b39c5158Smillert=item PERL_MM_OPT
3351b39c5158Smillert
3352b39c5158SmillertCommand line options used by C<MakeMaker-E<gt>new()>, and thus by
3353e5157e49Safresh1C<WriteMakefile()>.  The string is split as the shell would, and the result
3354b39c5158Smillertis processed before any actual command line arguments are processed.
3355b39c5158Smillert
3356e5157e49Safresh1  PERL_MM_OPT='CCFLAGS="-Wl,-rpath -Wl,/foo/bar/lib" LIBS="-lwibble -lwobble"'
3357e5157e49Safresh1
3358b39c5158Smillert=item PERL_MM_USE_DEFAULT
3359b39c5158Smillert
3360b39c5158SmillertIf set to a true value then MakeMaker's prompt function will
3361b39c5158Smillertalways return the default without waiting for user input.
3362b39c5158Smillert
3363b39c5158Smillert=item PERL_CORE
3364b39c5158Smillert
3365b39c5158SmillertSame as the PERL_CORE parameter.  The parameter overrides this.
3366b39c5158Smillert
3367b39c5158Smillert=back
3368b39c5158Smillert
3369b39c5158Smillert=head1 SEE ALSO
3370b39c5158Smillert
3371b39c5158SmillertL<Module::Build> is a pure-Perl alternative to MakeMaker which does
337256d68f1eSafresh1not rely on make or any other external utility.  It may be easier to
3373b39c5158Smillertextend to suit your needs.
3374b39c5158Smillert
337556d68f1eSafresh1L<Module::Build::Tiny> is a minimal pure-Perl alternative to MakeMaker
337656d68f1eSafresh1that follows the Build.PL protocol of Module::Build but without its
337756d68f1eSafresh1complexity and cruft, implementing only the installation of the module
337856d68f1eSafresh1and leaving authoring to L<mbtiny> or other authoring tools.
337956d68f1eSafresh1
338056d68f1eSafresh1L<Module::Install> is a (now discouraged) wrapper around MakeMaker which
338156d68f1eSafresh1adds features not normally available.
3382b39c5158Smillert
3383b39c5158SmillertL<ExtUtils::ModuleMaker> and L<Module::Starter> are both modules to
3384b39c5158Smillerthelp you setup your distribution.
3385b39c5158Smillert
338648950c12SsthenL<CPAN::Meta> and L<CPAN::Meta::Spec> explain CPAN Meta files in detail.
338748950c12Ssthen
3388b8851fccSafresh1L<File::ShareDir::Install> makes it easy to install static, sometimes
3389b8851fccSafresh1also referred to as 'shared' files. L<File::ShareDir> helps accessing
339056d68f1eSafresh1the shared files after installation. L<Test::File::ShareDir> helps when
339156d68f1eSafresh1writing tests to use the shared files both before and after installation.
3392b8851fccSafresh1
339356d68f1eSafresh1L<Dist::Zilla> is an authoring tool which allows great customization and
339456d68f1eSafresh1extensibility of the author experience, relying on the existing install
339556d68f1eSafresh1tools like ExtUtils::MakeMaker only for installation.
339656d68f1eSafresh1
339756d68f1eSafresh1L<Dist::Milla> is a Dist::Zilla bundle that greatly simplifies common
339856d68f1eSafresh1usage.
339956d68f1eSafresh1
340056d68f1eSafresh1L<Minilla> is a minimal authoring tool that does the same things as
340156d68f1eSafresh1Dist::Milla without the overhead of Dist::Zilla.
3402b8851fccSafresh1
3403b39c5158Smillert=head1 AUTHORS
3404b39c5158Smillert
3405b39c5158SmillertAndy Dougherty C<doughera@lafayette.edu>, Andreas KE<ouml>nig
3406b39c5158SmillertC<andreas.koenig@mind.de>, Tim Bunce C<timb@cpan.org>.  VMS
3407b39c5158Smillertsupport by Charles Bailey C<bailey@newman.upenn.edu>.  OS/2 support
3408b39c5158Smillertby Ilya Zakharevich C<ilya@math.ohio-state.edu>.
3409b39c5158Smillert
3410b39c5158SmillertCurrently maintained by Michael G Schwern C<schwern@pobox.com>
3411b39c5158Smillert
3412b39c5158SmillertSend patches and ideas to C<makemaker@perl.org>.
3413b39c5158Smillert
3414b39c5158SmillertSend bug reports via http://rt.cpan.org/.  Please send your
3415b39c5158Smillertgenerated Makefile along with your report.
3416b39c5158Smillert
3417e5157e49Safresh1For more up-to-date information, see L<https://metacpan.org/release/ExtUtils-MakeMaker>.
3418b39c5158Smillert
341948950c12SsthenRepository available at L<https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker>.
342048950c12Ssthen
3421b39c5158Smillert=head1 LICENSE
3422b39c5158Smillert
3423b39c5158SmillertThis program is free software; you can redistribute it and/or
3424b39c5158Smillertmodify it under the same terms as Perl itself.
3425b39c5158Smillert
3426b39c5158SmillertSee L<http://www.perl.com/perl/misc/Artistic.html>
3427b39c5158Smillert
3428b39c5158Smillert
3429b39c5158Smillert=cut
3430