1b39c5158Smillertpackage ExtUtils::MM_Any;
2b39c5158Smillert
3b39c5158Smillertuse strict;
4eac174f2Safresh1use warnings;
5*e0680481Safresh1our $VERSION = '7.70';
656d68f1eSafresh1$VERSION =~ tr/_//d;
7b39c5158Smillert
8b39c5158Smillertuse Carp;
9b39c5158Smillertuse File::Spec;
10b39c5158Smillertuse File::Basename;
11b39c5158SmillertBEGIN { our @ISA = qw(File::Spec); }
12b39c5158Smillert
13b39c5158Smillert# We need $Verbose
149f11ffb7Safresh1use ExtUtils::MakeMaker qw($Verbose neatvalue _sprintf562);
15b39c5158Smillert
16b39c5158Smillertuse ExtUtils::MakeMaker::Config;
17b39c5158Smillert
18b39c5158Smillert
19b39c5158Smillert# So we don't have to keep calling the methods over and over again,
20b39c5158Smillert# we have these globals to cache the values.  Faster and shrtr.
21b39c5158Smillertmy $Curdir  = __PACKAGE__->curdir;
229f11ffb7Safresh1#my $Updir   = __PACKAGE__->updir;
23b39c5158Smillert
249f11ffb7Safresh1my $METASPEC_URL = 'https://metacpan.org/pod/CPAN::Meta::Spec';
259f11ffb7Safresh1my $METASPEC_V = 2;
26b39c5158Smillert
27b39c5158Smillert=head1 NAME
28b39c5158Smillert
29b39c5158SmillertExtUtils::MM_Any - Platform-agnostic MM methods
30b39c5158Smillert
31b39c5158Smillert=head1 SYNOPSIS
32b39c5158Smillert
33b39c5158Smillert  FOR INTERNAL USE ONLY!
34b39c5158Smillert
35b39c5158Smillert  package ExtUtils::MM_SomeOS;
36b39c5158Smillert
37b39c5158Smillert  # Temporarily, you have to subclass both.  Put MM_Any first.
38b39c5158Smillert  require ExtUtils::MM_Any;
39b39c5158Smillert  require ExtUtils::MM_Unix;
40b39c5158Smillert  @ISA = qw(ExtUtils::MM_Any ExtUtils::Unix);
41b39c5158Smillert
42b39c5158Smillert=head1 DESCRIPTION
43b39c5158Smillert
44b39c5158SmillertB<FOR INTERNAL USE ONLY!>
45b39c5158Smillert
46b39c5158SmillertExtUtils::MM_Any is a superclass for the ExtUtils::MM_* set of
47b39c5158Smillertmodules.  It contains methods which are either inherently
48b39c5158Smillertcross-platform or are written in a cross-platform manner.
49b39c5158Smillert
5056d68f1eSafresh1Subclass off of ExtUtils::MM_Any I<and> L<ExtUtils::MM_Unix>.  This is a
51b39c5158Smillerttemporary solution.
52b39c5158Smillert
53b39c5158SmillertB<THIS MAY BE TEMPORARY!>
54b39c5158Smillert
55b39c5158Smillert
56b39c5158Smillert=head1 METHODS
57b39c5158Smillert
58b39c5158SmillertAny methods marked I<Abstract> must be implemented by subclasses.
59b39c5158Smillert
60b39c5158Smillert
61b39c5158Smillert=head2 Cross-platform helper methods
62b39c5158Smillert
63b39c5158SmillertThese are methods which help writing cross-platform code.
64b39c5158Smillert
65b39c5158Smillert
66b39c5158Smillert
67b39c5158Smillert=head3 os_flavor  I<Abstract>
68b39c5158Smillert
69b39c5158Smillert    my @os_flavor = $mm->os_flavor;
70b39c5158Smillert
71b39c5158Smillert@os_flavor is the style of operating system this is, usually
72b39c5158Smillertcorresponding to the MM_*.pm file we're using.
73b39c5158Smillert
74b39c5158SmillertThe first element of @os_flavor is the major family (ie. Unix,
75b39c5158SmillertWindows, VMS, OS/2, etc...) and the rest are sub families.
76b39c5158Smillert
77b39c5158SmillertSome examples:
78b39c5158Smillert
79b39c5158Smillert    Cygwin98       ('Unix',  'Cygwin', 'Cygwin9x')
80b39c5158Smillert    Windows        ('Win32')
81b39c5158Smillert    Win98          ('Win32', 'Win9x')
82b39c5158Smillert    Linux          ('Unix',  'Linux')
83b39c5158Smillert    MacOS X        ('Unix',  'Darwin', 'MacOS', 'MacOS X')
84b39c5158Smillert    OS/2           ('OS/2')
85b39c5158Smillert
86b39c5158SmillertThis is used to write code for styles of operating system.
87b39c5158SmillertSee os_flavor_is() for use.
88b39c5158Smillert
89b39c5158Smillert
90b39c5158Smillert=head3 os_flavor_is
91b39c5158Smillert
92b39c5158Smillert    my $is_this_flavor = $mm->os_flavor_is($this_flavor);
93b39c5158Smillert    my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
94b39c5158Smillert
95b39c5158SmillertChecks to see if the current operating system is one of the given flavors.
96b39c5158Smillert
97b39c5158SmillertThis is useful for code like:
98b39c5158Smillert
99b39c5158Smillert    if( $mm->os_flavor_is('Unix') ) {
100b39c5158Smillert        $out = `foo 2>&1`;
101b39c5158Smillert    }
102b39c5158Smillert    else {
103b39c5158Smillert        $out = `foo`;
104b39c5158Smillert    }
105b39c5158Smillert
106b39c5158Smillert=cut
107b39c5158Smillert
108b39c5158Smillertsub os_flavor_is {
109b39c5158Smillert    my $self = shift;
110b39c5158Smillert    my %flavors = map { ($_ => 1) } $self->os_flavor;
111b39c5158Smillert    return (grep { $flavors{$_} } @_) ? 1 : 0;
112b39c5158Smillert}
113b39c5158Smillert
114b39c5158Smillert
115b39c5158Smillert=head3 can_load_xs
116b39c5158Smillert
117b39c5158Smillert    my $can_load_xs = $self->can_load_xs;
118b39c5158Smillert
119b39c5158SmillertReturns true if we have the ability to load XS.
120b39c5158Smillert
121b39c5158SmillertThis is important because miniperl, used to build XS modules in the
122b39c5158Smillertcore, can not load XS.
123b39c5158Smillert
124b39c5158Smillert=cut
125b39c5158Smillert
126b39c5158Smillertsub can_load_xs {
127b39c5158Smillert    return defined &DynaLoader::boot_DynaLoader ? 1 : 0;
128b39c5158Smillert}
129b39c5158Smillert
130b39c5158Smillert
131b8851fccSafresh1=head3 can_run
132b8851fccSafresh1
133b8851fccSafresh1  use ExtUtils::MM;
134b8851fccSafresh1  my $runnable = MM->can_run($Config{make});
135b8851fccSafresh1
136b8851fccSafresh1If called in a scalar context it will return the full path to the binary
137b8851fccSafresh1you asked for if it was found, or C<undef> if it was not.
138b8851fccSafresh1
139b8851fccSafresh1If called in a list context, it will return a list of the full paths to instances
140b8851fccSafresh1of the binary where found in C<PATH>, or an empty list if it was not found.
141b8851fccSafresh1
142b8851fccSafresh1Copied from L<IPC::Cmd|IPC::Cmd/"$path = can_run( PROGRAM );">, but modified into
143b8851fccSafresh1a method (and removed C<$INSTANCES> capability).
144b8851fccSafresh1
145b8851fccSafresh1=cut
146b8851fccSafresh1
147b8851fccSafresh1sub can_run {
148b8851fccSafresh1    my ($self, $command) = @_;
149b8851fccSafresh1
150b8851fccSafresh1    # a lot of VMS executables have a symbol defined
151b8851fccSafresh1    # check those first
152b8851fccSafresh1    if ( $^O eq 'VMS' ) {
153b8851fccSafresh1        require VMS::DCLsym;
154b8851fccSafresh1        my $syms = VMS::DCLsym->new;
155b8851fccSafresh1        return $command if scalar $syms->getsym( uc $command );
156b8851fccSafresh1    }
157b8851fccSafresh1
158b8851fccSafresh1    my @possibles;
159b8851fccSafresh1
160b8851fccSafresh1    if( File::Spec->file_name_is_absolute($command) ) {
161b8851fccSafresh1        return $self->maybe_command($command);
162b8851fccSafresh1
163b8851fccSafresh1    } else {
164b8851fccSafresh1        for my $dir (
165b8851fccSafresh1            File::Spec->path,
166b8851fccSafresh1            File::Spec->curdir
167b8851fccSafresh1        ) {
168b8851fccSafresh1            next if ! $dir || ! -d $dir;
169b8851fccSafresh1            my $abs = File::Spec->catfile($self->os_flavor_is('Win32') ? Win32::GetShortPathName( $dir ) : $dir, $command);
170b8851fccSafresh1            push @possibles, $abs if $abs = $self->maybe_command($abs);
171b8851fccSafresh1        }
172b8851fccSafresh1    }
173b8851fccSafresh1    return @possibles if wantarray;
174b8851fccSafresh1    return shift @possibles;
175b8851fccSafresh1}
176b8851fccSafresh1
177b8851fccSafresh1
178b8851fccSafresh1=head3 can_redirect_error
179b8851fccSafresh1
180b8851fccSafresh1  $useredirect = MM->can_redirect_error;
181b8851fccSafresh1
182b8851fccSafresh1True if on an OS where qx operator (or backticks) can redirect C<STDERR>
183b8851fccSafresh1onto C<STDOUT>.
184b8851fccSafresh1
185b8851fccSafresh1=cut
186b8851fccSafresh1
187b8851fccSafresh1sub can_redirect_error {
188b8851fccSafresh1  my $self = shift;
189b8851fccSafresh1  $self->os_flavor_is('Unix')
190b8851fccSafresh1      or ($self->os_flavor_is('Win32') and !$self->os_flavor_is('Win9x'))
191b8851fccSafresh1      or $self->os_flavor_is('OS/2')
192b8851fccSafresh1}
193b8851fccSafresh1
194b8851fccSafresh1
195b8851fccSafresh1=head3 is_make_type
196b8851fccSafresh1
197b8851fccSafresh1    my $is_dmake = $self->is_make_type('dmake');
198b8851fccSafresh1
199b8851fccSafresh1Returns true if C<< $self->make >> is the given type; possibilities are:
200b8851fccSafresh1
201b8851fccSafresh1  gmake    GNU make
202b8851fccSafresh1  dmake
203b8851fccSafresh1  nmake
204b8851fccSafresh1  bsdmake  BSD pmake-derived
205b8851fccSafresh1
206b8851fccSafresh1=cut
207b8851fccSafresh1
208b8851fccSafresh1my %maketype2true;
209b8851fccSafresh1# undocumented - so t/cd.t can still do its thing
210b8851fccSafresh1sub _clear_maketype_cache { %maketype2true = () }
211b8851fccSafresh1
212b8851fccSafresh1sub is_make_type {
213b8851fccSafresh1    my($self, $type) = @_;
214b8851fccSafresh1    return $maketype2true{$type} if defined $maketype2true{$type};
215b8851fccSafresh1    (undef, undef, my $make_basename) = $self->splitpath($self->make);
216b8851fccSafresh1    return $maketype2true{$type} = 1
217b8851fccSafresh1        if $make_basename =~ /\b$type\b/i; # executable's filename
218b8851fccSafresh1    return $maketype2true{$type} = 0
219b8851fccSafresh1        if $make_basename =~ /\b[gdn]make\b/i; # Never fall through for dmake/nmake/gmake
220b8851fccSafresh1    # now have to run with "-v" and guess
221b8851fccSafresh1    my $redirect = $self->can_redirect_error ? '2>&1' : '';
222b8851fccSafresh1    my $make = $self->make || $self->{MAKE};
223b8851fccSafresh1    my $minus_v = `"$make" -v $redirect`;
224b8851fccSafresh1    return $maketype2true{$type} = 1
225b8851fccSafresh1        if $type eq 'gmake' and $minus_v =~ /GNU make/i;
226b8851fccSafresh1    return $maketype2true{$type} = 1
227b8851fccSafresh1        if $type eq 'bsdmake'
228b8851fccSafresh1      and $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im;
229b8851fccSafresh1    $maketype2true{$type} = 0; # it wasn't whatever you asked
230b8851fccSafresh1}
231b8851fccSafresh1
232b8851fccSafresh1
233b8851fccSafresh1=head3 can_dep_space
234b8851fccSafresh1
235b8851fccSafresh1    my $can_dep_space = $self->can_dep_space;
236b8851fccSafresh1
237b8851fccSafresh1Returns true if C<make> can handle (probably by quoting)
238b8851fccSafresh1dependencies that contain a space. Currently known true for GNU make,
239b8851fccSafresh1false for BSD pmake derivative.
240b8851fccSafresh1
241b8851fccSafresh1=cut
242b8851fccSafresh1
243b8851fccSafresh1my $cached_dep_space;
244b8851fccSafresh1sub can_dep_space {
245b8851fccSafresh1    my $self = shift;
246b8851fccSafresh1    return $cached_dep_space if defined $cached_dep_space;
247b8851fccSafresh1    return $cached_dep_space = 1 if $self->is_make_type('gmake');
248b8851fccSafresh1    return $cached_dep_space = 0 if $self->is_make_type('dmake'); # only on W32
249b8851fccSafresh1    return $cached_dep_space = 0 if $self->is_make_type('bsdmake');
250b8851fccSafresh1    return $cached_dep_space = 0; # assume no
251b8851fccSafresh1}
252b8851fccSafresh1
253b8851fccSafresh1
254b8851fccSafresh1=head3 quote_dep
255b8851fccSafresh1
256b8851fccSafresh1  $text = $mm->quote_dep($text);
257b8851fccSafresh1
258b8851fccSafresh1Method that protects Makefile single-value constants (mainly filenames),
259b8851fccSafresh1so that make will still treat them as single values even if they
260b8851fccSafresh1inconveniently have spaces in. If the make program being used cannot
261b8851fccSafresh1achieve such protection and the given text would need it, throws an
262b8851fccSafresh1exception.
263b8851fccSafresh1
264b8851fccSafresh1=cut
265b8851fccSafresh1
266b8851fccSafresh1sub quote_dep {
267b8851fccSafresh1    my ($self, $arg) = @_;
268b8851fccSafresh1    die <<EOF if $arg =~ / / and not $self->can_dep_space;
269b8851fccSafresh1Tried to use make dependency with space for make that can't:
270b8851fccSafresh1  '$arg'
271b8851fccSafresh1EOF
272b8851fccSafresh1    $arg =~ s/( )/\\$1/g; # how GNU make does it
273b8851fccSafresh1    return $arg;
274b8851fccSafresh1}
275b8851fccSafresh1
276b8851fccSafresh1
277b39c5158Smillert=head3 split_command
278b39c5158Smillert
279b39c5158Smillert    my @cmds = $MM->split_command($cmd, @args);
280b39c5158Smillert
281b39c5158SmillertMost OS have a maximum command length they can execute at once.  Large
282b39c5158Smillertmodules can easily generate commands well past that limit.  Its
283b39c5158Smillertnecessary to split long commands up into a series of shorter commands.
284b39c5158Smillert
285b39c5158SmillertC<split_command> will return a series of @cmds each processing part of
286b39c5158Smillertthe args.  Collectively they will process all the arguments.  Each
287b39c5158Smillertindividual line in @cmds will not be longer than the
288b39c5158Smillert$self->max_exec_len being careful to take into account macro expansion.
289b39c5158Smillert
290b39c5158Smillert$cmd should include any switches and repeated initial arguments.
291b39c5158Smillert
292b39c5158SmillertIf no @args are given, no @cmds will be returned.
293b39c5158Smillert
294b39c5158SmillertPairs of arguments will always be preserved in a single command, this
295b39c5158Smillertis a heuristic for things like pm_to_blib and pod2man which work on
296b39c5158Smillertpairs of arguments.  This makes things like this safe:
297b39c5158Smillert
298b39c5158Smillert    $self->split_command($cmd, %pod2man);
299b39c5158Smillert
300b39c5158Smillert
301b39c5158Smillert=cut
302b39c5158Smillert
303b39c5158Smillertsub split_command {
304b39c5158Smillert    my($self, $cmd, @args) = @_;
305b39c5158Smillert
306b39c5158Smillert    my @cmds = ();
307b39c5158Smillert    return(@cmds) unless @args;
308b39c5158Smillert
309b39c5158Smillert    # If the command was given as a here-doc, there's probably a trailing
310b39c5158Smillert    # newline.
311b39c5158Smillert    chomp $cmd;
312b39c5158Smillert
313b39c5158Smillert    # set aside 30% for macro expansion.
314b39c5158Smillert    my $len_left = int($self->max_exec_len * 0.70);
315b39c5158Smillert    $len_left -= length $self->_expand_macros($cmd);
316b39c5158Smillert
317b39c5158Smillert    do {
318b39c5158Smillert        my $arg_str = '';
319b39c5158Smillert        my @next_args;
320b39c5158Smillert        while( @next_args = splice(@args, 0, 2) ) {
321b39c5158Smillert            # Two at a time to preserve pairs.
322b39c5158Smillert            my $next_arg_str = "\t  ". join ' ', @next_args, "\n";
323b39c5158Smillert
324b39c5158Smillert            if( !length $arg_str ) {
325b39c5158Smillert                $arg_str .= $next_arg_str
326b39c5158Smillert            }
327b39c5158Smillert            elsif( length($arg_str) + length($next_arg_str) > $len_left ) {
328b39c5158Smillert                unshift @args, @next_args;
329b39c5158Smillert                last;
330b39c5158Smillert            }
331b39c5158Smillert            else {
332b39c5158Smillert                $arg_str .= $next_arg_str;
333b39c5158Smillert            }
334b39c5158Smillert        }
335b39c5158Smillert        chop $arg_str;
336b39c5158Smillert
337b39c5158Smillert        push @cmds, $self->escape_newlines("$cmd \n$arg_str");
338b39c5158Smillert    } while @args;
339b39c5158Smillert
340b39c5158Smillert    return @cmds;
341b39c5158Smillert}
342b39c5158Smillert
343b39c5158Smillert
344b39c5158Smillertsub _expand_macros {
345b39c5158Smillert    my($self, $cmd) = @_;
346b39c5158Smillert
347b39c5158Smillert    $cmd =~ s{\$\((\w+)\)}{
348b39c5158Smillert        defined $self->{$1} ? $self->{$1} : "\$($1)"
349b39c5158Smillert    }e;
350b39c5158Smillert    return $cmd;
351b39c5158Smillert}
352b39c5158Smillert
353b39c5158Smillert
3549f11ffb7Safresh1=head3 make_type
3559f11ffb7Safresh1
3569f11ffb7Safresh1Returns a suitable string describing the type of makefile being written.
3579f11ffb7Safresh1
3589f11ffb7Safresh1=cut
3599f11ffb7Safresh1
3609f11ffb7Safresh1# override if this isn't suitable!
3619f11ffb7Safresh1sub make_type { return 'Unix-style'; }
3629f11ffb7Safresh1
3639f11ffb7Safresh1
3649f11ffb7Safresh1=head3 stashmeta
3659f11ffb7Safresh1
3669f11ffb7Safresh1    my @recipelines = $MM->stashmeta($text, $file);
3679f11ffb7Safresh1
3689f11ffb7Safresh1Generates a set of C<@recipelines> which will result in the literal
3699f11ffb7Safresh1C<$text> ending up in literal C<$file> when the recipe is executed. Call
3709f11ffb7Safresh1it once, with all the text you want in C<$file>. Make macros will not
3719f11ffb7Safresh1be expanded, so the locations will be fixed at configure-time, not
3729f11ffb7Safresh1at build-time.
3739f11ffb7Safresh1
3749f11ffb7Safresh1=cut
3759f11ffb7Safresh1
3769f11ffb7Safresh1sub stashmeta {
3779f11ffb7Safresh1    my($self, $text, $file) = @_;
3789f11ffb7Safresh1    $self->echo($text, $file, { allow_variables => 0, append => 0 });
3799f11ffb7Safresh1}
3809f11ffb7Safresh1
3819f11ffb7Safresh1
382b39c5158Smillert=head3 echo
383b39c5158Smillert
384b39c5158Smillert    my @commands = $MM->echo($text);
385b39c5158Smillert    my @commands = $MM->echo($text, $file);
38648950c12Ssthen    my @commands = $MM->echo($text, $file, \%opts);
387b39c5158Smillert
388b39c5158SmillertGenerates a set of @commands which print the $text to a $file.
389b39c5158Smillert
390b39c5158SmillertIf $file is not given, output goes to STDOUT.
391b39c5158Smillert
39248950c12SsthenIf $opts{append} is true the $file will be appended to rather than
39348950c12Ssthenoverwritten.  Default is to overwrite.
39448950c12Ssthen
39548950c12SsthenIf $opts{allow_variables} is true, make variables of the form
39648950c12SsthenC<$(...)> will not be escaped.  Other C<$> will.  Default is to escape
39748950c12Ssthenall C<$>.
39848950c12Ssthen
39948950c12SsthenExample of use:
40048950c12Ssthen
4019f11ffb7Safresh1    my $make = join '', map "\t$_\n", $MM->echo($text, $file);
402b39c5158Smillert
403b39c5158Smillert=cut
404b39c5158Smillert
405b39c5158Smillertsub echo {
40648950c12Ssthen    my($self, $text, $file, $opts) = @_;
407b39c5158Smillert
40848950c12Ssthen    # Compatibility with old options
40948950c12Ssthen    if( !ref $opts ) {
41048950c12Ssthen        my $append = $opts;
41148950c12Ssthen        $opts = { append => $append || 0 };
41248950c12Ssthen    }
41348950c12Ssthen    $opts->{allow_variables} = 0 unless defined $opts->{allow_variables};
41448950c12Ssthen
41548950c12Ssthen    my $ql_opts = { allow_variables => $opts->{allow_variables} };
41648950c12Ssthen    my @cmds = map { '$(NOECHO) $(ECHO) '.$self->quote_literal($_, $ql_opts) }
417b39c5158Smillert               split /\n/, $text;
418b39c5158Smillert    if( $file ) {
41948950c12Ssthen        my $redirect = $opts->{append} ? '>>' : '>';
420b39c5158Smillert        $cmds[0] .= " $redirect $file";
421b39c5158Smillert        $_ .= " >> $file" foreach @cmds[1..$#cmds];
422b39c5158Smillert    }
423b39c5158Smillert
424b39c5158Smillert    return @cmds;
425b39c5158Smillert}
426b39c5158Smillert
427b39c5158Smillert
428b39c5158Smillert=head3 wraplist
429b39c5158Smillert
430b39c5158Smillert  my $args = $mm->wraplist(@list);
431b39c5158Smillert
432b39c5158SmillertTakes an array of items and turns them into a well-formatted list of
433b39c5158Smillertarguments.  In most cases this is simply something like:
434b39c5158Smillert
435b39c5158Smillert    FOO \
436b39c5158Smillert    BAR \
437b39c5158Smillert    BAZ
438b39c5158Smillert
439b39c5158Smillert=cut
440b39c5158Smillert
441b39c5158Smillertsub wraplist {
442b39c5158Smillert    my $self = shift;
443b39c5158Smillert    return join " \\\n\t", @_;
444b39c5158Smillert}
445b39c5158Smillert
446b39c5158Smillert
447b39c5158Smillert=head3 maketext_filter
448b39c5158Smillert
449b39c5158Smillert    my $filter_make_text = $mm->maketext_filter($make_text);
450b39c5158Smillert
451b39c5158SmillertThe text of the Makefile is run through this method before writing to
452b39c5158Smillertdisk.  It allows systems a chance to make portability fixes to the
453b39c5158SmillertMakefile.
454b39c5158Smillert
455b39c5158SmillertBy default it does nothing.
456b39c5158Smillert
457b39c5158SmillertThis method is protected and not intended to be called outside of
458b39c5158SmillertMakeMaker.
459b39c5158Smillert
460b39c5158Smillert=cut
461b39c5158Smillert
462b39c5158Smillertsub maketext_filter { return $_[1] }
463b39c5158Smillert
464b39c5158Smillert
465b39c5158Smillert=head3 cd  I<Abstract>
466b39c5158Smillert
467b39c5158Smillert  my $subdir_cmd = $MM->cd($subdir, @cmds);
468b39c5158Smillert
469b39c5158SmillertThis will generate a make fragment which runs the @cmds in the given
470b39c5158Smillert$dir.  The rough equivalent to this, except cross platform.
471b39c5158Smillert
472b39c5158Smillert  cd $subdir && $cmd
473b39c5158Smillert
474b39c5158SmillertCurrently $dir can only go down one level.  "foo" is fine.  "foo/bar" is
475b39c5158Smillertnot.  "../foo" is right out.
476b39c5158Smillert
477b39c5158SmillertThe resulting $subdir_cmd has no leading tab nor trailing newline.  This
478b39c5158Smillertmakes it easier to embed in a make string.  For example.
479b39c5158Smillert
480b39c5158Smillert      my $make = sprintf <<'CODE', $subdir_cmd;
481b39c5158Smillert  foo :
482b39c5158Smillert      $(ECHO) what
483b39c5158Smillert      %s
484b39c5158Smillert      $(ECHO) mouche
485b39c5158Smillert  CODE
486b39c5158Smillert
487b39c5158Smillert
488b39c5158Smillert=head3 oneliner  I<Abstract>
489b39c5158Smillert
490b39c5158Smillert  my $oneliner = $MM->oneliner($perl_code);
491b39c5158Smillert  my $oneliner = $MM->oneliner($perl_code, \@switches);
492b39c5158Smillert
493b39c5158SmillertThis will generate a perl one-liner safe for the particular platform
494b39c5158Smillertyou're on based on the given $perl_code and @switches (a -e is
495b39c5158Smillertassumed) suitable for using in a make target.  It will use the proper
496b39c5158Smillertshell quoting and escapes.
497b39c5158Smillert
498b39c5158Smillert$(PERLRUN) will be used as perl.
499b39c5158Smillert
500b39c5158SmillertAny newlines in $perl_code will be escaped.  Leading and trailing
501b39c5158Smillertnewlines will be stripped.  Makes this idiom much easier:
502b39c5158Smillert
503b39c5158Smillert    my $code = $MM->oneliner(<<'CODE', [...switches...]);
504b39c5158Smillertsome code here
505b39c5158Smillertanother line here
506b39c5158SmillertCODE
507b39c5158Smillert
508b39c5158SmillertUsage might be something like:
509b39c5158Smillert
510b39c5158Smillert    # an echo emulation
511b39c5158Smillert    $oneliner = $MM->oneliner('print "Foo\n"');
512b39c5158Smillert    $make = '$oneliner > somefile';
513b39c5158Smillert
5149f11ffb7Safresh1Dollar signs in the $perl_code will be protected from make using the
5159f11ffb7Safresh1C<quote_literal> method, unless they are recognised as being a make
5169f11ffb7Safresh1variable, C<$(varname)>, in which case they will be left for make
5179f11ffb7Safresh1to expand. Remember to quote make macros else it might be used as a
518b39c5158Smillertbareword. For example:
519b39c5158Smillert
520b39c5158Smillert    # Assign the value of the $(VERSION_FROM) make macro to $vf.
5219f11ffb7Safresh1    $oneliner = $MM->oneliner('$vf = "$(VERSION_FROM)"');
522b39c5158Smillert
523b39c5158SmillertIts currently very simple and may be expanded sometime in the figure
524b39c5158Smillertto include more flexible code and switches.
525b39c5158Smillert
526b39c5158Smillert
527b39c5158Smillert=head3 quote_literal  I<Abstract>
528b39c5158Smillert
529b39c5158Smillert    my $safe_text = $MM->quote_literal($text);
53048950c12Ssthen    my $safe_text = $MM->quote_literal($text, \%options);
531b39c5158Smillert
532b39c5158SmillertThis will quote $text so it is interpreted literally in the shell.
533b39c5158Smillert
534b39c5158SmillertFor example, on Unix this would escape any single-quotes in $text and
535b39c5158Smillertput single-quotes around the whole thing.
536b39c5158Smillert
53748950c12SsthenIf $options{allow_variables} is true it will leave C<'$(FOO)'> make
53848950c12Ssthenvariables untouched.  If false they will be escaped like any other
53948950c12SsthenC<$>.  Defaults to true.
54048950c12Ssthen
54148950c12Ssthen=head3 escape_dollarsigns
54248950c12Ssthen
54348950c12Ssthen    my $escaped_text = $MM->escape_dollarsigns($text);
54448950c12Ssthen
54548950c12SsthenEscapes stray C<$> so they are not interpreted as make variables.
54648950c12Ssthen
54748950c12SsthenIt lets by C<$(...)>.
54848950c12Ssthen
54948950c12Ssthen=cut
55048950c12Ssthen
55148950c12Ssthensub escape_dollarsigns {
55248950c12Ssthen    my($self, $text) = @_;
55348950c12Ssthen
55448950c12Ssthen    # Escape dollar signs which are not starting a variable
55548950c12Ssthen    $text =~ s{\$ (?!\() }{\$\$}gx;
55648950c12Ssthen
55748950c12Ssthen    return $text;
55848950c12Ssthen}
55948950c12Ssthen
56048950c12Ssthen
56148950c12Ssthen=head3 escape_all_dollarsigns
56248950c12Ssthen
56348950c12Ssthen    my $escaped_text = $MM->escape_all_dollarsigns($text);
56448950c12Ssthen
56548950c12SsthenEscapes all C<$> so they are not interpreted as make variables.
56648950c12Ssthen
56748950c12Ssthen=cut
56848950c12Ssthen
56948950c12Ssthensub escape_all_dollarsigns {
57048950c12Ssthen    my($self, $text) = @_;
57148950c12Ssthen
57248950c12Ssthen    # Escape dollar signs
57348950c12Ssthen    $text =~ s{\$}{\$\$}gx;
57448950c12Ssthen
57548950c12Ssthen    return $text;
57648950c12Ssthen}
57748950c12Ssthen
578b39c5158Smillert
579b39c5158Smillert=head3 escape_newlines  I<Abstract>
580b39c5158Smillert
581b39c5158Smillert    my $escaped_text = $MM->escape_newlines($text);
582b39c5158Smillert
583b39c5158SmillertShell escapes newlines in $text.
584b39c5158Smillert
585b39c5158Smillert
586b39c5158Smillert=head3 max_exec_len  I<Abstract>
587b39c5158Smillert
588b39c5158Smillert    my $max_exec_len = $MM->max_exec_len;
589b39c5158Smillert
590b39c5158SmillertCalculates the maximum command size the OS can exec.  Effectively,
591b39c5158Smillertthis is the max size of a shell command line.
592b39c5158Smillert
593b39c5158Smillert=for _private
594b39c5158Smillert$self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes.
595b39c5158Smillert
596b39c5158Smillert
597b39c5158Smillert=head3 make
598b39c5158Smillert
599b39c5158Smillert    my $make = $MM->make;
600b39c5158Smillert
601b39c5158SmillertReturns the make variant we're generating the Makefile for.  This attempts
602b39c5158Smillertto do some normalization on the information from %Config or the user.
603b39c5158Smillert
604b39c5158Smillert=cut
605b39c5158Smillert
606b39c5158Smillertsub make {
607b39c5158Smillert    my $self = shift;
608b39c5158Smillert
609b39c5158Smillert    my $make = lc $self->{MAKE};
610b39c5158Smillert
611b39c5158Smillert    # Truncate anything like foomake6 to just foomake.
612b39c5158Smillert    $make =~ s/^(\w+make).*/$1/;
613b39c5158Smillert
614b39c5158Smillert    # Turn gnumake into gmake.
615b39c5158Smillert    $make =~ s/^gnu/g/;
616b39c5158Smillert
617b39c5158Smillert    return $make;
618b39c5158Smillert}
619b39c5158Smillert
620b39c5158Smillert
621b39c5158Smillert=head2 Targets
622b39c5158Smillert
623b39c5158SmillertThese are methods which produce make targets.
624b39c5158Smillert
625b39c5158Smillert
626b39c5158Smillert=head3 all_target
627b39c5158Smillert
628b39c5158SmillertGenerate the default target 'all'.
629b39c5158Smillert
630b39c5158Smillert=cut
631b39c5158Smillert
632b39c5158Smillertsub all_target {
633b39c5158Smillert    my $self = shift;
634b39c5158Smillert
635b39c5158Smillert    return <<'MAKE_EXT';
636b39c5158Smillertall :: pure_all
637b39c5158Smillert	$(NOECHO) $(NOOP)
638b39c5158SmillertMAKE_EXT
639b39c5158Smillert
640b39c5158Smillert}
641b39c5158Smillert
642b39c5158Smillert
643b39c5158Smillert=head3 blibdirs_target
644b39c5158Smillert
645b39c5158Smillert    my $make_frag = $mm->blibdirs_target;
646b39c5158Smillert
647b39c5158SmillertCreates the blibdirs target which creates all the directories we use
648b39c5158Smillertin blib/.
649b39c5158Smillert
650b39c5158SmillertThe blibdirs.ts target is deprecated.  Depend on blibdirs instead.
651b39c5158Smillert
652b39c5158Smillert
653b39c5158Smillert=cut
654b39c5158Smillert
6559f11ffb7Safresh1sub _xs_list_basenames {
6569f11ffb7Safresh1    my ($self) = @_;
6579f11ffb7Safresh1    map { (my $b = $_) =~ s/\.xs$//; $b } sort keys %{ $self->{XS} };
6589f11ffb7Safresh1}
6599f11ffb7Safresh1
660b39c5158Smillertsub blibdirs_target {
661b39c5158Smillert    my $self = shift;
662b39c5158Smillert
663b39c5158Smillert    my @dirs = map { uc "\$(INST_$_)" } qw(libdir archlib
664b39c5158Smillert                                           autodir archautodir
665b39c5158Smillert                                           bin script
666b39c5158Smillert                                           man1dir man3dir
667b39c5158Smillert                                          );
6689f11ffb7Safresh1    if ($self->{XSMULTI}) {
6699f11ffb7Safresh1        for my $ext ($self->_xs_list_basenames) {
6709f11ffb7Safresh1            my ($v, $d, $f) = File::Spec->splitpath($ext);
6719f11ffb7Safresh1            my @d = File::Spec->splitdir($d);
6729f11ffb7Safresh1            shift @d if $d[0] eq 'lib';
6739f11ffb7Safresh1            push @dirs, $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
6749f11ffb7Safresh1	}
6759f11ffb7Safresh1    }
676b39c5158Smillert
677b39c5158Smillert    my @exists = map { $_.'$(DFSEP).exists' } @dirs;
678b39c5158Smillert
679b39c5158Smillert    my $make = sprintf <<'MAKE', join(' ', @exists);
680b39c5158Smillertblibdirs : %s
681b39c5158Smillert	$(NOECHO) $(NOOP)
682b39c5158Smillert
683b39c5158Smillert# Backwards compat with 6.18 through 6.25
684b39c5158Smillertblibdirs.ts : blibdirs
685b39c5158Smillert	$(NOECHO) $(NOOP)
686b39c5158Smillert
687b39c5158SmillertMAKE
688b39c5158Smillert
689b39c5158Smillert    $make .= $self->dir_target(@dirs);
690b39c5158Smillert
691b39c5158Smillert    return $make;
692b39c5158Smillert}
693b39c5158Smillert
694b39c5158Smillert
695b39c5158Smillert=head3 clean (o)
696b39c5158Smillert
697b39c5158SmillertDefines the clean target.
698b39c5158Smillert
699b39c5158Smillert=cut
700b39c5158Smillert
701b39c5158Smillertsub clean {
702b39c5158Smillert# --- Cleanup and Distribution Sections ---
703b39c5158Smillert
704b39c5158Smillert    my($self, %attribs) = @_;
705b39c5158Smillert    my @m;
706b39c5158Smillert    push(@m, '
707b39c5158Smillert# Delete temporary files but do not touch installed files. We don\'t delete
708b39c5158Smillert# the Makefile here so a later make realclean still has a makefile to use.
709b39c5158Smillert
710b39c5158Smillertclean :: clean_subdirs
711b39c5158Smillert');
712b39c5158Smillert
713e5157e49Safresh1    my @files = sort values %{$self->{XS}}; # .c files from *.xs files
7149f11ffb7Safresh1    push @files, map {
7159f11ffb7Safresh1	my $file = $_;
7169f11ffb7Safresh1	map { $file.$_ } $self->{OBJ_EXT}, qw(.def _def.old .bs .bso .exp .base);
7179f11ffb7Safresh1    } $self->_xs_list_basenames;
718b39c5158Smillert    my @dirs  = qw(blib);
719b39c5158Smillert
720b39c5158Smillert    # Normally these are all under blib but they might have been
721b39c5158Smillert    # redefined.
722b39c5158Smillert    # XXX normally this would be a good idea, but the Perl core sets
723b39c5158Smillert    # INST_LIB = ../../lib rather than actually installing the files.
724b39c5158Smillert    # So a "make clean" in an ext/ directory would blow away lib.
725b39c5158Smillert    # Until the core is adjusted let's leave this out.
726b39c5158Smillert#     push @dirs, qw($(INST_ARCHLIB) $(INST_LIB)
727b39c5158Smillert#                    $(INST_BIN) $(INST_SCRIPT)
728b39c5158Smillert#                    $(INST_MAN1DIR) $(INST_MAN3DIR)
729b39c5158Smillert#                    $(INST_LIBDIR) $(INST_ARCHLIBDIR) $(INST_AUTODIR)
730e5157e49Safresh1#                    $(INST_STATIC) $(INST_DYNAMIC)
731b39c5158Smillert#                 );
732b39c5158Smillert
733b39c5158Smillert
734b39c5158Smillert    if( $attribs{FILES} ) {
735b39c5158Smillert        # Use @dirs because we don't know what's in here.
736b39c5158Smillert        push @dirs, ref $attribs{FILES}                ?
737b39c5158Smillert                        @{$attribs{FILES}}             :
738b39c5158Smillert                        split /\s+/, $attribs{FILES}   ;
739b39c5158Smillert    }
740b39c5158Smillert
741b39c5158Smillert    push(@files, qw[$(MAKE_APERL_FILE)
74248950c12Ssthen                    MYMETA.json MYMETA.yml perlmain.c tmon.out mon.out so_locations
743b39c5158Smillert                    blibdirs.ts pm_to_blib pm_to_blib.ts
744b39c5158Smillert                    *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT)
745b39c5158Smillert                    $(BOOTSTRAP) $(BASEEXT).bso
746b39c5158Smillert                    $(BASEEXT).def lib$(BASEEXT).def
747b39c5158Smillert                    $(BASEEXT).exp $(BASEEXT).x
748b39c5158Smillert                   ]);
749b39c5158Smillert
750b39c5158Smillert    push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
751b39c5158Smillert    push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
752b39c5158Smillert
753b39c5158Smillert    # core files
754e5157e49Safresh1    if ($^O eq 'vos') {
755e5157e49Safresh1        push(@files, qw[perl*.kp]);
756e5157e49Safresh1    }
757e5157e49Safresh1    else {
758b39c5158Smillert        push(@files, qw[core core.*perl.*.? *perl.core]);
759e5157e49Safresh1    }
760e5157e49Safresh1
761b39c5158Smillert    push(@files, map { "core." . "[0-9]"x$_ } (1..5));
762b39c5158Smillert
763b39c5158Smillert    # OS specific things to clean up.  Use @dirs since we don't know
764b39c5158Smillert    # what might be in here.
765b39c5158Smillert    push @dirs, $self->extra_clean_files;
766b39c5158Smillert
767b39c5158Smillert    # Occasionally files are repeated several times from different sources
768e5157e49Safresh1    { my(%f) = map { ($_ => 1) } @files; @files = sort keys %f; }
769e5157e49Safresh1    { my(%d) = map { ($_ => 1) } @dirs;  @dirs  = sort keys %d; }
770b39c5158Smillert
771b39c5158Smillert    push @m, map "\t$_\n", $self->split_command('- $(RM_F)',  @files);
772b39c5158Smillert    push @m, map "\t$_\n", $self->split_command('- $(RM_RF)', @dirs);
773b39c5158Smillert
774b39c5158Smillert    # Leave Makefile.old around for realclean
775b39c5158Smillert    push @m, <<'MAKE';
776e5157e49Safresh1	  $(NOECHO) $(RM_F) $(MAKEFILE_OLD)
777b39c5158Smillert	- $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
778b39c5158SmillertMAKE
779b39c5158Smillert
780b39c5158Smillert    push(@m, "\t$attribs{POSTOP}\n")   if $attribs{POSTOP};
781b39c5158Smillert
782b39c5158Smillert    join("", @m);
783b39c5158Smillert}
784b39c5158Smillert
785b39c5158Smillert
786b39c5158Smillert=head3 clean_subdirs_target
787b39c5158Smillert
788b39c5158Smillert  my $make_frag = $MM->clean_subdirs_target;
789b39c5158Smillert
790b39c5158SmillertReturns the clean_subdirs target.  This is used by the clean target to
791b39c5158Smillertcall clean on any subdirectories which contain Makefiles.
792b39c5158Smillert
793b39c5158Smillert=cut
794b39c5158Smillert
795b39c5158Smillertsub clean_subdirs_target {
796b39c5158Smillert    my($self) = shift;
797b39c5158Smillert
798b39c5158Smillert    # No subdirectories, no cleaning.
799b39c5158Smillert    return <<'NOOP_FRAG' unless @{$self->{DIR}};
800b39c5158Smillertclean_subdirs :
801b39c5158Smillert	$(NOECHO) $(NOOP)
802b39c5158SmillertNOOP_FRAG
803b39c5158Smillert
804b39c5158Smillert
805b39c5158Smillert    my $clean = "clean_subdirs :\n";
806b39c5158Smillert
807b39c5158Smillert    for my $dir (@{$self->{DIR}}) {
808b39c5158Smillert        my $subclean = $self->oneliner(sprintf <<'CODE', $dir);
809e5157e49Safresh1exit 0 unless chdir '%s';  system '$(MAKE) clean' if -f '$(FIRST_MAKEFILE)';
810b39c5158SmillertCODE
811b39c5158Smillert
812b39c5158Smillert        $clean .= "\t$subclean\n";
813b39c5158Smillert    }
814b39c5158Smillert
815b39c5158Smillert    return $clean;
816b39c5158Smillert}
817b39c5158Smillert
818b39c5158Smillert
819b39c5158Smillert=head3 dir_target
820b39c5158Smillert
821b39c5158Smillert    my $make_frag = $mm->dir_target(@directories);
822b39c5158Smillert
823b39c5158SmillertGenerates targets to create the specified directories and set its
824b39c5158Smillertpermission to PERM_DIR.
825b39c5158Smillert
826b39c5158SmillertBecause depending on a directory to just ensure it exists doesn't work
827b39c5158Smillerttoo well (the modified time changes too often) dir_target() creates a
828b39c5158Smillert.exists file in the created directory.  It is this you should depend on.
829b39c5158SmillertFor portability purposes you should use the $(DIRFILESEP) macro rather
830e5157e49Safresh1than a '/' to separate the directory from the file.
831b39c5158Smillert
832b39c5158Smillert    yourdirectory$(DIRFILESEP).exists
833b39c5158Smillert
834b39c5158Smillert=cut
835b39c5158Smillert
836b39c5158Smillertsub dir_target {
837b39c5158Smillert    my($self, @dirs) = @_;
838b39c5158Smillert
839b39c5158Smillert    my $make = '';
840b39c5158Smillert    foreach my $dir (@dirs) {
841e5157e49Safresh1        $make .= sprintf <<'MAKE', ($dir) x 4;
842b39c5158Smillert%s$(DFSEP).exists :: Makefile.PL
843b39c5158Smillert	$(NOECHO) $(MKPATH) %s
844b39c5158Smillert	$(NOECHO) $(CHMOD) $(PERM_DIR) %s
845b39c5158Smillert	$(NOECHO) $(TOUCH) %s$(DFSEP).exists
846b39c5158Smillert
847b39c5158SmillertMAKE
848b39c5158Smillert
849b39c5158Smillert    }
850b39c5158Smillert
851b39c5158Smillert    return $make;
852b39c5158Smillert}
853b39c5158Smillert
854b39c5158Smillert
855b39c5158Smillert=head3 distdir
856b39c5158Smillert
857b39c5158SmillertDefines the scratch directory target that will hold the distribution
858b39c5158Smillertbefore tar-ing (or shar-ing).
859b39c5158Smillert
860b39c5158Smillert=cut
861b39c5158Smillert
862b39c5158Smillert# For backwards compatibility.
863b39c5158Smillert*dist_dir = *distdir;
864b39c5158Smillert
865b39c5158Smillertsub distdir {
866b39c5158Smillert    my($self) = shift;
867b39c5158Smillert
868b39c5158Smillert    my $meta_target = $self->{NO_META} ? '' : 'distmeta';
869b39c5158Smillert    my $sign_target = !$self->{SIGN}   ? '' : 'distsignature';
870b39c5158Smillert
871b39c5158Smillert    return sprintf <<'MAKE_FRAG', $meta_target, $sign_target;
872b39c5158Smillertcreate_distdir :
873b39c5158Smillert	$(RM_RF) $(DISTVNAME)
874b39c5158Smillert	$(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
875b39c5158Smillert		-e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
876b39c5158Smillert
877b39c5158Smillertdistdir : create_distdir %s %s
878b39c5158Smillert	$(NOECHO) $(NOOP)
879b39c5158Smillert
880b39c5158SmillertMAKE_FRAG
881b39c5158Smillert
882b39c5158Smillert}
883b39c5158Smillert
884b39c5158Smillert
885b39c5158Smillert=head3 dist_test
886b39c5158Smillert
887b39c5158SmillertDefines a target that produces the distribution in the
888b39c5158Smillertscratch directory, and runs 'perl Makefile.PL; make ;make test' in that
889b39c5158Smillertsubdirectory.
890b39c5158Smillert
891b39c5158Smillert=cut
892b39c5158Smillert
893b39c5158Smillertsub dist_test {
894b39c5158Smillert    my($self) = shift;
895b39c5158Smillert
896b39c5158Smillert    my $mpl_args = join " ", map qq["$_"], @ARGV;
897b39c5158Smillert
898b39c5158Smillert    my $test = $self->cd('$(DISTVNAME)',
899b39c5158Smillert                         '$(ABSPERLRUN) Makefile.PL '.$mpl_args,
900b39c5158Smillert                         '$(MAKE) $(PASTHRU)',
901b39c5158Smillert                         '$(MAKE) test $(PASTHRU)'
902b39c5158Smillert                        );
903b39c5158Smillert
904b39c5158Smillert    return sprintf <<'MAKE_FRAG', $test;
905b39c5158Smillertdisttest : distdir
906b39c5158Smillert	%s
907b39c5158Smillert
908b39c5158SmillertMAKE_FRAG
909b39c5158Smillert
910b39c5158Smillert
911b39c5158Smillert}
912b39c5158Smillert
913b39c5158Smillert
9149f11ffb7Safresh1=head3 xs_dlsyms_arg
9159f11ffb7Safresh1
9169f11ffb7Safresh1Returns command-line arg(s) to linker for file listing dlsyms to export.
9179f11ffb7Safresh1Defaults to returning empty string, can be overridden by e.g. AIX.
9189f11ffb7Safresh1
9199f11ffb7Safresh1=cut
9209f11ffb7Safresh1
9219f11ffb7Safresh1sub xs_dlsyms_arg {
9229f11ffb7Safresh1    return '';
9239f11ffb7Safresh1}
9249f11ffb7Safresh1
9259f11ffb7Safresh1=head3 xs_dlsyms_ext
9269f11ffb7Safresh1
9279f11ffb7Safresh1Returns file-extension for C<xs_make_dlsyms> method's output file,
9289f11ffb7Safresh1including any "." character.
9299f11ffb7Safresh1
9309f11ffb7Safresh1=cut
9319f11ffb7Safresh1
9329f11ffb7Safresh1sub xs_dlsyms_ext {
9339f11ffb7Safresh1    die "Pure virtual method";
9349f11ffb7Safresh1}
9359f11ffb7Safresh1
9369f11ffb7Safresh1=head3 xs_dlsyms_extra
9379f11ffb7Safresh1
9389f11ffb7Safresh1Returns any extra text to be prepended to the C<$extra> argument of
9399f11ffb7Safresh1C<xs_make_dlsyms>.
9409f11ffb7Safresh1
9419f11ffb7Safresh1=cut
9429f11ffb7Safresh1
9439f11ffb7Safresh1sub xs_dlsyms_extra {
9449f11ffb7Safresh1    '';
9459f11ffb7Safresh1}
9469f11ffb7Safresh1
9479f11ffb7Safresh1=head3 xs_dlsyms_iterator
9489f11ffb7Safresh1
9499f11ffb7Safresh1Iterates over necessary shared objects, calling C<xs_make_dlsyms> method
9509f11ffb7Safresh1for each with appropriate arguments.
9519f11ffb7Safresh1
9529f11ffb7Safresh1=cut
9539f11ffb7Safresh1
9549f11ffb7Safresh1sub xs_dlsyms_iterator {
9559f11ffb7Safresh1    my ($self, $attribs) = @_;
9569f11ffb7Safresh1    if ($self->{XSMULTI}) {
9579f11ffb7Safresh1        my @m;
9589f11ffb7Safresh1        for my $ext ($self->_xs_list_basenames) {
9599f11ffb7Safresh1            my @parts = File::Spec->splitdir($ext);
9609f11ffb7Safresh1            shift @parts if $parts[0] eq 'lib';
9619f11ffb7Safresh1            my $name = join '::', @parts;
9629f11ffb7Safresh1            push @m, $self->xs_make_dlsyms(
9639f11ffb7Safresh1                $attribs,
9649f11ffb7Safresh1                $ext . $self->xs_dlsyms_ext,
9659f11ffb7Safresh1                "$ext.xs",
9669f11ffb7Safresh1                $name,
9679f11ffb7Safresh1                $parts[-1],
9689f11ffb7Safresh1                {}, [], {}, [],
9699f11ffb7Safresh1                $self->xs_dlsyms_extra . q!, 'FILE' => ! . neatvalue($ext),
9709f11ffb7Safresh1            );
9719f11ffb7Safresh1        }
9729f11ffb7Safresh1        return join "\n", @m;
9739f11ffb7Safresh1    } else {
9749f11ffb7Safresh1        return $self->xs_make_dlsyms(
9759f11ffb7Safresh1            $attribs,
9769f11ffb7Safresh1            $self->{BASEEXT} . $self->xs_dlsyms_ext,
9779f11ffb7Safresh1            'Makefile.PL',
9789f11ffb7Safresh1            $self->{NAME},
9799f11ffb7Safresh1            $self->{DLBASE},
9809f11ffb7Safresh1            $attribs->{DL_FUNCS} || $self->{DL_FUNCS} || {},
9819f11ffb7Safresh1            $attribs->{FUNCLIST} || $self->{FUNCLIST} || [],
9829f11ffb7Safresh1            $attribs->{IMPORTS} || $self->{IMPORTS} || {},
9839f11ffb7Safresh1            $attribs->{DL_VARS} || $self->{DL_VARS} || [],
9849f11ffb7Safresh1            $self->xs_dlsyms_extra,
9859f11ffb7Safresh1        );
9869f11ffb7Safresh1    }
9879f11ffb7Safresh1}
9889f11ffb7Safresh1
9899f11ffb7Safresh1=head3 xs_make_dlsyms
9909f11ffb7Safresh1
9919f11ffb7Safresh1    $self->xs_make_dlsyms(
9929f11ffb7Safresh1        \%attribs, # hashref from %attribs in caller
9939f11ffb7Safresh1        "$self->{BASEEXT}.def", # output file for Makefile target
9949f11ffb7Safresh1        'Makefile.PL', # dependency
9959f11ffb7Safresh1        $self->{NAME}, # shared object's "name"
9969f11ffb7Safresh1        $self->{DLBASE}, # last ::-separated part of name
9979f11ffb7Safresh1        $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}, # various params
9989f11ffb7Safresh1        $attribs{FUNCLIST} || $self->{FUNCLIST} || [],
9999f11ffb7Safresh1        $attribs{IMPORTS} || $self->{IMPORTS} || {},
10009f11ffb7Safresh1        $attribs{DL_VARS} || $self->{DL_VARS} || [],
10019f11ffb7Safresh1        # optional extra param that will be added as param to Mksymlists
10029f11ffb7Safresh1    );
10039f11ffb7Safresh1
10049f11ffb7Safresh1Utility method that returns Makefile snippet to call C<Mksymlists>.
10059f11ffb7Safresh1
10069f11ffb7Safresh1=cut
10079f11ffb7Safresh1
10089f11ffb7Safresh1sub xs_make_dlsyms {
10099f11ffb7Safresh1    my ($self, $attribs, $target, $dep, $name, $dlbase, $funcs, $funclist, $imports, $vars, $extra) = @_;
10109f11ffb7Safresh1    my @m = (
10119f11ffb7Safresh1     "\n$target: $dep\n",
10129f11ffb7Safresh1     q!	$(PERLRUN) -MExtUtils::Mksymlists \\
10139f11ffb7Safresh1     -e "Mksymlists('NAME'=>\"!, $name,
10149f11ffb7Safresh1     q!\", 'DLBASE' => '!,$dlbase,
10159f11ffb7Safresh1     # The above two lines quoted differently to work around
10169f11ffb7Safresh1     # a bug in the 4DOS/4NT command line interpreter.  The visible
10179f11ffb7Safresh1     # result of the bug was files named q('extension_name',) *with the
10189f11ffb7Safresh1     # single quotes and the comma* in the extension build directories.
10199f11ffb7Safresh1     q!', 'DL_FUNCS' => !,neatvalue($funcs),
10209f11ffb7Safresh1     q!, 'FUNCLIST' => !,neatvalue($funclist),
10219f11ffb7Safresh1     q!, 'IMPORTS' => !,neatvalue($imports),
10229f11ffb7Safresh1     q!, 'DL_VARS' => !, neatvalue($vars)
10239f11ffb7Safresh1    );
10249f11ffb7Safresh1    push @m, $extra if defined $extra;
10259f11ffb7Safresh1    push @m, qq!);"\n!;
10269f11ffb7Safresh1    join '', @m;
10279f11ffb7Safresh1}
10289f11ffb7Safresh1
1029b39c5158Smillert=head3 dynamic (o)
1030b39c5158Smillert
1031b39c5158SmillertDefines the dynamic target.
1032b39c5158Smillert
1033b39c5158Smillert=cut
1034b39c5158Smillert
1035b39c5158Smillertsub dynamic {
1036b39c5158Smillert# --- Dynamic Loading Sections ---
1037b39c5158Smillert
1038b39c5158Smillert    my($self) = shift;
1039b39c5158Smillert    '
10409f11ffb7Safresh1dynamic :: $(FIRST_MAKEFILE) config $(INST_BOOT) $(INST_DYNAMIC)
1041b39c5158Smillert	$(NOECHO) $(NOOP)
1042b39c5158Smillert';
1043b39c5158Smillert}
1044b39c5158Smillert
1045b39c5158Smillert
1046b39c5158Smillert=head3 makemakerdflt_target
1047b39c5158Smillert
1048b39c5158Smillert  my $make_frag = $mm->makemakerdflt_target
1049b39c5158Smillert
1050b39c5158SmillertReturns a make fragment with the makemakerdeflt_target specified.
1051b39c5158SmillertThis target is the first target in the Makefile, is the default target
1052b39c5158Smillertand simply points off to 'all' just in case any make variant gets
1053b39c5158Smillertconfused or something gets snuck in before the real 'all' target.
1054b39c5158Smillert
1055b39c5158Smillert=cut
1056b39c5158Smillert
1057b39c5158Smillertsub makemakerdflt_target {
1058b39c5158Smillert    return <<'MAKE_FRAG';
1059b39c5158Smillertmakemakerdflt : all
1060b39c5158Smillert	$(NOECHO) $(NOOP)
1061b39c5158SmillertMAKE_FRAG
1062b39c5158Smillert
1063b39c5158Smillert}
1064b39c5158Smillert
1065b39c5158Smillert
1066b39c5158Smillert=head3 manifypods_target
1067b39c5158Smillert
1068b39c5158Smillert  my $manifypods_target = $self->manifypods_target;
1069b39c5158Smillert
1070b39c5158SmillertGenerates the manifypods target.  This target generates man pages from
1071b39c5158Smillertall POD files in MAN1PODS and MAN3PODS.
1072b39c5158Smillert
1073b39c5158Smillert=cut
1074b39c5158Smillert
1075b39c5158Smillertsub manifypods_target {
1076b39c5158Smillert    my($self) = shift;
1077b39c5158Smillert
1078b39c5158Smillert    my $man1pods      = '';
1079b39c5158Smillert    my $man3pods      = '';
1080b39c5158Smillert    my $dependencies  = '';
1081b39c5158Smillert
1082b39c5158Smillert    # populate manXpods & dependencies:
1083e5157e49Safresh1    foreach my $name (sort keys %{$self->{MAN1PODS}}, sort keys %{$self->{MAN3PODS}}) {
1084b39c5158Smillert        $dependencies .= " \\\n\t$name";
1085b39c5158Smillert    }
1086b39c5158Smillert
1087b39c5158Smillert    my $manify = <<END;
10889f11ffb7Safresh1manifypods : pure_all config $dependencies
1089b39c5158SmillertEND
1090b39c5158Smillert
1091b39c5158Smillert    my @man_cmds;
1092d0bd1485Safresh1    foreach my $num (qw(1 3)) {
1093d0bd1485Safresh1        my $pods = $self->{"MAN${num}PODS"};
1094d0bd1485Safresh1        my $p2m = sprintf <<'CMD', "\$(MAN${num}SECTION)", "$]" > 5.008 ? " -u" : "";
10959f11ffb7Safresh1	$(NOECHO) $(POD2MAN) --section=%s --perm_rw=$(PERM_RW)%s
1096b39c5158SmillertCMD
1097b8851fccSafresh1        push @man_cmds, $self->split_command($p2m, map {($_,$pods->{$_})} sort keys %$pods);
1098b39c5158Smillert    }
1099b39c5158Smillert
1100b39c5158Smillert    $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
1101b39c5158Smillert    $manify .= join '', map { "$_\n" } @man_cmds;
1102b39c5158Smillert
1103b39c5158Smillert    return $manify;
1104b39c5158Smillert}
1105b39c5158Smillert
11069f11ffb7Safresh1{
11079f11ffb7Safresh1    my $has_cpan_meta;
110848950c12Ssthen    sub _has_cpan_meta {
11099f11ffb7Safresh1        return $has_cpan_meta if defined $has_cpan_meta;
11109f11ffb7Safresh1        return $has_cpan_meta = !!eval {
111148950c12Ssthen            require CPAN::Meta;
111248950c12Ssthen            CPAN::Meta->VERSION(2.112150);
111348950c12Ssthen            1;
111448950c12Ssthen        };
111548950c12Ssthen    }
11169f11ffb7Safresh1}
1117b39c5158Smillert
1118b39c5158Smillert=head3 metafile_target
1119b39c5158Smillert
1120b39c5158Smillert    my $target = $mm->metafile_target;
1121b39c5158Smillert
1122b39c5158SmillertGenerate the metafile target.
1123b39c5158Smillert
1124e5157e49Safresh1Writes the file META.yml (YAML encoded meta-data) and META.json
1125e5157e49Safresh1(JSON encoded meta-data) about the module in the distdir.
1126e5157e49Safresh1The format follows Module::Build's as closely as possible.
1127b39c5158Smillert
1128b39c5158Smillert=cut
1129b39c5158Smillert
1130b39c5158Smillertsub metafile_target {
1131b39c5158Smillert    my $self = shift;
113248950c12Ssthen    return <<'MAKE_FRAG' if $self->{NO_META} or ! _has_cpan_meta();
1133b39c5158Smillertmetafile :
1134b39c5158Smillert	$(NOECHO) $(NOOP)
1135b39c5158SmillertMAKE_FRAG
1136b39c5158Smillert
11379f11ffb7Safresh1    my $metadata   = $self->metafile_data(
1138b39c5158Smillert        $self->{META_ADD}   || {},
1139b39c5158Smillert        $self->{META_MERGE} || {},
1140b39c5158Smillert    );
1141b39c5158Smillert
11429f11ffb7Safresh1    my $meta = $self->_fix_metadata_before_conversion( $metadata );
114348950c12Ssthen
11449f11ffb7Safresh1    my @write_metayml = $self->stashmeta(
114548950c12Ssthen      $meta->as_string({version => "1.4"}), 'META_new.yml'
114648950c12Ssthen    );
11479f11ffb7Safresh1    my @write_metajson = $self->stashmeta(
11489f11ffb7Safresh1      $meta->as_string({version => "2.0"}), 'META_new.json'
114948950c12Ssthen    );
115048950c12Ssthen
115148950c12Ssthen    my $metayml = join("\n\t", @write_metayml);
115248950c12Ssthen    my $metajson = join("\n\t", @write_metajson);
115348950c12Ssthen    return sprintf <<'MAKE_FRAG', $metayml, $metajson;
1154b39c5158Smillertmetafile : create_distdir
1155b39c5158Smillert	$(NOECHO) $(ECHO) Generating META.yml
1156b39c5158Smillert	%s
1157b39c5158Smillert	-$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
115848950c12Ssthen	$(NOECHO) $(ECHO) Generating META.json
115948950c12Ssthen	%s
116048950c12Ssthen	-$(NOECHO) $(MV) META_new.json $(DISTVNAME)/META.json
1161b39c5158SmillertMAKE_FRAG
1162b39c5158Smillert
1163b39c5158Smillert}
1164b39c5158Smillert
116548950c12Ssthen=begin private
116648950c12Ssthen
116748950c12Ssthen=head3 _fix_metadata_before_conversion
116848950c12Ssthen
11699f11ffb7Safresh1    $mm->_fix_metadata_before_conversion( \%metadata );
117048950c12Ssthen
117156d68f1eSafresh1Fixes errors in the metadata before it's handed off to L<CPAN::Meta> for
117248950c12Ssthenconversion. This hopefully results in something that can be used further
117348950c12Ssthenon, no guarantee is made though.
117448950c12Ssthen
117548950c12Ssthen=end private
117648950c12Ssthen
117748950c12Ssthen=cut
117848950c12Ssthen
117948950c12Ssthensub _fix_metadata_before_conversion {
11809f11ffb7Safresh1    my ( $self, $metadata ) = @_;
118148950c12Ssthen
118248950c12Ssthen    # we should never be called unless this already passed but
118348950c12Ssthen    # prefer to be defensive in case somebody else calls this
118448950c12Ssthen
118548950c12Ssthen    return unless _has_cpan_meta;
118648950c12Ssthen
118748950c12Ssthen    my $bad_version = $metadata->{version} &&
118848950c12Ssthen                      !CPAN::Meta::Validator->new->version( 'version', $metadata->{version} );
118948950c12Ssthen    # just delete all invalid versions
119048950c12Ssthen    if( $bad_version ) {
119148950c12Ssthen        warn "Can't parse version '$metadata->{version}'\n";
119248950c12Ssthen        $metadata->{version} = '';
119348950c12Ssthen    }
119448950c12Ssthen
11959f11ffb7Safresh1    my $validator2 = CPAN::Meta::Validator->new( $metadata );
11969f11ffb7Safresh1    my @errors;
11979f11ffb7Safresh1    push @errors, $validator2->errors if !$validator2->is_valid;
11989f11ffb7Safresh1    my $validator14 = CPAN::Meta::Validator->new(
11999f11ffb7Safresh1        {
12009f11ffb7Safresh1            %$metadata,
12019f11ffb7Safresh1            'meta-spec' => { version => 1.4 },
12029f11ffb7Safresh1        }
12039f11ffb7Safresh1    );
12049f11ffb7Safresh1    push @errors, $validator14->errors if !$validator14->is_valid;
120548950c12Ssthen    # fix non-camelcase custom resource keys (only other trick we know)
12069f11ffb7Safresh1    for my $error ( @errors ) {
120748950c12Ssthen        my ( $key ) = ( $error =~ /Custom resource '(.*)' must be in CamelCase./ );
120848950c12Ssthen        next if !$key;
120948950c12Ssthen
121048950c12Ssthen        # first try to remove all non-alphabetic chars
121148950c12Ssthen        ( my $new_key = $key ) =~ s/[^_a-zA-Z]//g;
121248950c12Ssthen
121348950c12Ssthen        # if that doesn't work, uppercase first one
12149f11ffb7Safresh1        $new_key = ucfirst $new_key if !$validator14->custom_1( $new_key );
121548950c12Ssthen
121648950c12Ssthen        # copy to new key if that worked
121748950c12Ssthen        $metadata->{resources}{$new_key} = $metadata->{resources}{$key}
12189f11ffb7Safresh1          if $validator14->custom_1( $new_key );
121948950c12Ssthen
122048950c12Ssthen        # and delete old one in any case
122148950c12Ssthen        delete $metadata->{resources}{$key};
122248950c12Ssthen    }
122348950c12Ssthen
12249f11ffb7Safresh1    # paper over validation issues, but still complain, necessary because
12259f11ffb7Safresh1    # there's no guarantee that the above will fix ALL errors
12269f11ffb7Safresh1    my $meta = eval { CPAN::Meta->create( $metadata, { lazy_validation => 1 } ) };
12279f11ffb7Safresh1    warn $@ if $@ and
12289f11ffb7Safresh1               $@ !~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/;
12299f11ffb7Safresh1
12309f11ffb7Safresh1    # use the original metadata straight if the conversion failed
12319f11ffb7Safresh1    # or if it can't be stringified.
12329f11ffb7Safresh1    if( !$meta                                                  ||
12339f11ffb7Safresh1        !eval { $meta->as_string( { version => $METASPEC_V } ) }      ||
12349f11ffb7Safresh1        !eval { $meta->as_string }
12359f11ffb7Safresh1    ) {
12369f11ffb7Safresh1        $meta = bless $metadata, 'CPAN::Meta';
12379f11ffb7Safresh1    }
12389f11ffb7Safresh1
12399f11ffb7Safresh1    my $now_license = $meta->as_struct({ version => 2 })->{license};
12409f11ffb7Safresh1    if ($self->{LICENSE} and $self->{LICENSE} ne 'unknown' and
12419f11ffb7Safresh1        @{$now_license} == 1 and $now_license->[0] eq 'unknown'
12429f11ffb7Safresh1    ) {
12439f11ffb7Safresh1        warn "Invalid LICENSE value '$self->{LICENSE}' ignored\n";
12449f11ffb7Safresh1    }
12459f11ffb7Safresh1
12469f11ffb7Safresh1    $meta;
124748950c12Ssthen}
124848950c12Ssthen
1249b39c5158Smillert
1250b39c5158Smillert=begin private
1251b39c5158Smillert
1252b39c5158Smillert=head3 _sort_pairs
1253b39c5158Smillert
1254b39c5158Smillert    my @pairs = _sort_pairs($sort_sub, \%hash);
1255b39c5158Smillert
1256b39c5158SmillertSorts the pairs of a hash based on keys ordered according
1257b39c5158Smillertto C<$sort_sub>.
1258b39c5158Smillert
1259b39c5158Smillert=end private
1260b39c5158Smillert
1261b39c5158Smillert=cut
1262b39c5158Smillert
1263b39c5158Smillertsub _sort_pairs {
1264b39c5158Smillert    my $sort  = shift;
1265b39c5158Smillert    my $pairs = shift;
1266b39c5158Smillert    return map  { $_ => $pairs->{$_} }
1267b39c5158Smillert           sort $sort
1268b39c5158Smillert           keys %$pairs;
1269b39c5158Smillert}
1270b39c5158Smillert
1271b39c5158Smillert
1272b39c5158Smillert# Taken from Module::Build::Base
1273b39c5158Smillertsub _hash_merge {
1274b39c5158Smillert    my ($self, $h, $k, $v) = @_;
1275b39c5158Smillert    if (ref $h->{$k} eq 'ARRAY') {
1276b39c5158Smillert        push @{$h->{$k}}, ref $v ? @$v : $v;
1277b39c5158Smillert    } elsif (ref $h->{$k} eq 'HASH') {
1278b39c5158Smillert        $self->_hash_merge($h->{$k}, $_, $v->{$_}) foreach keys %$v;
1279b39c5158Smillert    } else {
1280b39c5158Smillert        $h->{$k} = $v;
1281b39c5158Smillert    }
1282b39c5158Smillert}
1283b39c5158Smillert
1284b39c5158Smillert
1285b39c5158Smillert=head3 metafile_data
1286b39c5158Smillert
12879f11ffb7Safresh1    my $metadata_hashref = $mm->metafile_data(\%meta_add, \%meta_merge);
1288b39c5158Smillert
1289e5157e49Safresh1Returns the data which MakeMaker turns into the META.yml file
12909f11ffb7Safresh1and the META.json file. It is always in version 2.0 of the format.
1291b39c5158Smillert
1292b39c5158SmillertValues of %meta_add will overwrite any existing metadata in those
1293b39c5158Smillertkeys.  %meta_merge will be merged with them.
1294b39c5158Smillert
1295b39c5158Smillert=cut
1296b39c5158Smillert
1297b39c5158Smillertsub metafile_data {
1298b39c5158Smillert    my $self = shift;
1299b39c5158Smillert    my($meta_add, $meta_merge) = @_;
1300b39c5158Smillert
13019f11ffb7Safresh1    $meta_add ||= {};
13029f11ffb7Safresh1    $meta_merge ||= {};
13039f11ffb7Safresh1
13049f11ffb7Safresh1    my $version = _normalize_version($self->{VERSION});
13059f11ffb7Safresh1    my $release_status = ($version =~ /_/) ? 'unstable' : 'stable';
1306b39c5158Smillert    my %meta = (
130748950c12Ssthen        # required
130848950c12Ssthen        abstract     => $self->{ABSTRACT} || 'unknown',
13099f11ffb7Safresh1        author       => defined($self->{AUTHOR}) ? $self->{AUTHOR} : ['unknown'],
131048950c12Ssthen        dynamic_config => 1,
13119f11ffb7Safresh1        generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
13129f11ffb7Safresh1        license      => [ $self->{LICENSE} || 'unknown' ],
13139f11ffb7Safresh1        'meta-spec'  => {
13149f11ffb7Safresh1            url         => $METASPEC_URL,
13159f11ffb7Safresh1            version     => $METASPEC_V,
13169f11ffb7Safresh1        },
13179f11ffb7Safresh1        name         => $self->{DISTNAME},
13189f11ffb7Safresh1        release_status => $release_status,
13199f11ffb7Safresh1        version      => $version,
132048950c12Ssthen
132148950c12Ssthen        # optional
13229f11ffb7Safresh1        no_index     => { directory => [qw(t inc)] },
1323b39c5158Smillert    );
13249f11ffb7Safresh1    $self->_add_requirements_to_meta(\%meta);
1325b39c5158Smillert
13269f11ffb7Safresh1    if (!eval { require JSON::PP; require CPAN::Meta::Converter; CPAN::Meta::Converter->VERSION(2.141170) }) {
13279f11ffb7Safresh1      return \%meta;
132848950c12Ssthen    }
132948950c12Ssthen
13309f11ffb7Safresh1    # needs to be based on the original version
13319f11ffb7Safresh1    my $v1_add = _metaspec_version($meta_add) !~ /^2/;
13329f11ffb7Safresh1
13339f11ffb7Safresh1    my ($add_v, $merge_v) = map _metaspec_version($_), $meta_add, $meta_merge;
13349f11ffb7Safresh1    for my $frag ($meta_add, $meta_merge) {
13359f11ffb7Safresh1        my $def_v = $frag == $meta_add ? $merge_v : $add_v;
13369f11ffb7Safresh1        $frag = CPAN::Meta::Converter->new($frag, default_version => $def_v)->upgrade_fragment;
13379f11ffb7Safresh1    }
13389f11ffb7Safresh1
13399f11ffb7Safresh1    # if we upgraded a 1.x _ADD fragment, we gave it a prereqs key that
13409f11ffb7Safresh1    # will override all prereqs, which is more than the user asked for;
13419f11ffb7Safresh1    # instead, we'll go inside the prereqs and override all those
1342b39c5158Smillert    while( my($key, $val) = each %$meta_add ) {
13439f11ffb7Safresh1        if ($v1_add and $key eq 'prereqs') {
13449f11ffb7Safresh1            $meta{$key}{$_} = $val->{$_} for keys %$val;
13459f11ffb7Safresh1        } elsif ($key ne 'meta-spec') {
1346b39c5158Smillert            $meta{$key} = $val;
1347b39c5158Smillert        }
13489f11ffb7Safresh1    }
1349b39c5158Smillert
1350b39c5158Smillert    while( my($key, $val) = each %$meta_merge ) {
13519f11ffb7Safresh1        next if $key eq 'meta-spec';
1352b39c5158Smillert        $self->_hash_merge(\%meta, $key, $val);
1353b39c5158Smillert    }
1354b39c5158Smillert
13559f11ffb7Safresh1    return \%meta;
1356b39c5158Smillert}
1357b39c5158Smillert
1358b39c5158Smillert
1359b39c5158Smillert=begin private
1360b39c5158Smillert
136148950c12Ssthen=cut
136248950c12Ssthen
13639f11ffb7Safresh1sub _add_requirements_to_meta {
13649f11ffb7Safresh1    my ( $self, $meta ) = @_;
13659f11ffb7Safresh1    # Check the original args so we can tell between the user setting it
13669f11ffb7Safresh1    # to an empty hash and it just being initialized.
13679f11ffb7Safresh1    $meta->{prereqs}{configure}{requires} = $self->{ARGS}{CONFIGURE_REQUIRES}
13689f11ffb7Safresh1        ? $self->{CONFIGURE_REQUIRES}
13699f11ffb7Safresh1        : { 'ExtUtils::MakeMaker' => 0, };
13709f11ffb7Safresh1    $meta->{prereqs}{build}{requires} = $self->{ARGS}{BUILD_REQUIRES}
13719f11ffb7Safresh1        ? $self->{BUILD_REQUIRES}
13729f11ffb7Safresh1        : { 'ExtUtils::MakeMaker' => 0, };
13739f11ffb7Safresh1    $meta->{prereqs}{test}{requires} = $self->{TEST_REQUIRES}
13749f11ffb7Safresh1        if $self->{ARGS}{TEST_REQUIRES};
13759f11ffb7Safresh1    $meta->{prereqs}{runtime}{requires} = $self->{PREREQ_PM}
13769f11ffb7Safresh1        if $self->{ARGS}{PREREQ_PM};
13779f11ffb7Safresh1    $meta->{prereqs}{runtime}{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION})
13789f11ffb7Safresh1        if $self->{MIN_PERL_VERSION};
13799f11ffb7Safresh1}
13809f11ffb7Safresh1
13819f11ffb7Safresh1# spec version of given fragment - if not given, assume 1.4
1382e5157e49Safresh1sub _metaspec_version {
13839f11ffb7Safresh1  my ( $meta ) = @_;
13849f11ffb7Safresh1  return $meta->{'meta-spec'}->{version}
13859f11ffb7Safresh1    if defined $meta->{'meta-spec'}
13869f11ffb7Safresh1       and defined $meta->{'meta-spec'}->{version};
1387e5157e49Safresh1  return '1.4';
1388e5157e49Safresh1}
1389e5157e49Safresh1
1390e9ce3842Safresh1sub _add_requirements_to_meta_v1_4 {
13919f11ffb7Safresh1    my ( $self, $meta ) = @_;
139248950c12Ssthen    # Check the original args so we can tell between the user setting it
139348950c12Ssthen    # to an empty hash and it just being initialized.
1394e5157e49Safresh1    if( $self->{ARGS}{CONFIGURE_REQUIRES} ) {
13959f11ffb7Safresh1        $meta->{configure_requires} = $self->{CONFIGURE_REQUIRES};
1396e5157e49Safresh1    } else {
13979f11ffb7Safresh1        $meta->{configure_requires} = {
1398e5157e49Safresh1            'ExtUtils::MakeMaker'       => 0,
1399e5157e49Safresh1        };
1400e5157e49Safresh1    }
140148950c12Ssthen    if( $self->{ARGS}{BUILD_REQUIRES} ) {
14029f11ffb7Safresh1        $meta->{build_requires} = $self->{BUILD_REQUIRES};
140348950c12Ssthen    } else {
14049f11ffb7Safresh1        $meta->{build_requires} = {
140548950c12Ssthen            'ExtUtils::MakeMaker'       => 0,
140648950c12Ssthen        };
140748950c12Ssthen    }
1408e9ce3842Safresh1    if( $self->{ARGS}{TEST_REQUIRES} ) {
14099f11ffb7Safresh1        $meta->{build_requires} = {
14109f11ffb7Safresh1          %{ $meta->{build_requires} },
1411b8851fccSafresh1          %{ $self->{TEST_REQUIRES} },
1412e9ce3842Safresh1        };
1413e9ce3842Safresh1    }
14149f11ffb7Safresh1    $meta->{requires} = $self->{PREREQ_PM}
141548950c12Ssthen        if defined $self->{PREREQ_PM};
14169f11ffb7Safresh1    $meta->{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION})
141748950c12Ssthen        if $self->{MIN_PERL_VERSION};
1418e9ce3842Safresh1}
1419e9ce3842Safresh1
142048950c12Ssthen# Adapted from Module::Build::Base
142148950c12Ssthensub _normalize_version {
142248950c12Ssthen  my ($version) = @_;
142348950c12Ssthen  $version = 0 unless defined $version;
142448950c12Ssthen
142548950c12Ssthen  if ( ref $version eq 'version' ) { # version objects
14269f11ffb7Safresh1    $version = $version->stringify;
142748950c12Ssthen  }
142848950c12Ssthen  elsif ( $version =~ /^[^v][^.]*\.[^.]+\./ ) { # no leading v, multiple dots
142948950c12Ssthen    # normalize string tuples without "v": "1.2.3" -> "v1.2.3"
143048950c12Ssthen    $version = "v$version";
143148950c12Ssthen  }
143248950c12Ssthen  else {
143348950c12Ssthen    # leave alone
143448950c12Ssthen  }
143548950c12Ssthen  return $version;
143648950c12Ssthen}
143748950c12Ssthen
1438b39c5158Smillert=head3 _dump_hash
1439b39c5158Smillert
1440b39c5158Smillert    $yaml = _dump_hash(\%options, %hash);
1441b39c5158Smillert
1442b39c5158SmillertImplements a fake YAML dumper for a hash given
1443b39c5158Smillertas a list of pairs. No quoting/escaping is done. Keys
1444b39c5158Smillertare supposed to be strings. Values are undef, strings,
1445b39c5158Smillerthash refs or array refs of strings.
1446b39c5158Smillert
1447b39c5158SmillertSupported options are:
1448b39c5158Smillert
1449b39c5158Smillert    delta => STR - indentation delta
1450b39c5158Smillert    use_header => BOOL - whether to include a YAML header
1451b39c5158Smillert    indent => STR - a string of spaces
1452b39c5158Smillert          default: ''
1453b39c5158Smillert
1454b39c5158Smillert    max_key_length => INT - maximum key length used to align
1455b39c5158Smillert        keys and values of the same hash
1456b39c5158Smillert        default: 20
1457b39c5158Smillert    key_sort => CODE - a sort sub
1458b39c5158Smillert            It may be undef, which means no sorting by keys
1459b39c5158Smillert        default: sub { lc $a cmp lc $b }
1460b39c5158Smillert
1461b39c5158Smillert    customs => HASH - special options for certain keys
1462b39c5158Smillert           (whose values are hashes themselves)
1463b39c5158Smillert        may contain: max_key_length, key_sort, customs
1464b39c5158Smillert
1465b39c5158Smillert=end private
1466b39c5158Smillert
1467b39c5158Smillert=cut
1468b39c5158Smillert
1469b39c5158Smillertsub _dump_hash {
1470b39c5158Smillert    croak "first argument should be a hash ref" unless ref $_[0] eq 'HASH';
1471b39c5158Smillert    my $options = shift;
1472b39c5158Smillert    my %hash = @_;
1473b39c5158Smillert
1474b39c5158Smillert    # Use a list to preserve order.
1475b39c5158Smillert    my @pairs;
1476b39c5158Smillert
1477b39c5158Smillert    my $k_sort
1478b39c5158Smillert        = exists $options->{key_sort} ? $options->{key_sort}
1479b39c5158Smillert                                      : sub { lc $a cmp lc $b };
1480b39c5158Smillert    if ($k_sort) {
1481b39c5158Smillert        croak "'key_sort' should be a coderef" unless ref $k_sort eq 'CODE';
1482b39c5158Smillert        @pairs = _sort_pairs($k_sort, \%hash);
1483b39c5158Smillert    } else { # list of pairs, no sorting
1484b39c5158Smillert        @pairs = @_;
1485b39c5158Smillert    }
1486b39c5158Smillert
1487b39c5158Smillert    my $yaml     = $options->{use_header} ? "--- #YAML:1.0\n" : '';
1488b39c5158Smillert    my $indent   = $options->{indent} || '';
1489b39c5158Smillert    my $k_length = min(
1490b39c5158Smillert        ($options->{max_key_length} || 20),
1491b39c5158Smillert        max(map { length($_) + 1 } grep { !ref $hash{$_} } keys %hash)
1492b39c5158Smillert    );
1493b39c5158Smillert    my $customs  = $options->{customs} || {};
1494b39c5158Smillert
1495b39c5158Smillert    # printf format for key
1496b39c5158Smillert    my $k_format = "%-${k_length}s";
1497b39c5158Smillert
1498b39c5158Smillert    while( @pairs ) {
1499b39c5158Smillert        my($key, $val) = splice @pairs, 0, 2;
1500b39c5158Smillert        $val = '~' unless defined $val;
1501b39c5158Smillert        if(ref $val eq 'HASH') {
1502b39c5158Smillert            if ( keys %$val ) {
1503b39c5158Smillert                my %k_options = ( # options for recursive call
1504b39c5158Smillert                    delta => $options->{delta},
1505b39c5158Smillert                    use_header => 0,
1506b39c5158Smillert                    indent => $indent . $options->{delta},
1507b39c5158Smillert                );
1508b39c5158Smillert                if (exists $customs->{$key}) {
1509b39c5158Smillert                    my %k_custom = %{$customs->{$key}};
151048950c12Ssthen                    foreach my $k (qw(key_sort max_key_length customs)) {
1511b39c5158Smillert                        $k_options{$k} = $k_custom{$k} if exists $k_custom{$k};
1512b39c5158Smillert                    }
1513b39c5158Smillert                }
1514b39c5158Smillert                $yaml .= $indent . "$key:\n"
1515b39c5158Smillert                  . _dump_hash(\%k_options, %$val);
1516b39c5158Smillert            }
1517b39c5158Smillert            else {
1518b39c5158Smillert                $yaml .= $indent . "$key:  {}\n";
1519b39c5158Smillert            }
1520b39c5158Smillert        }
1521b39c5158Smillert        elsif (ref $val eq 'ARRAY') {
1522b39c5158Smillert            if( @$val ) {
1523b39c5158Smillert                $yaml .= $indent . "$key:\n";
1524b39c5158Smillert
1525b39c5158Smillert                for (@$val) {
1526b39c5158Smillert                    croak "only nested arrays of non-refs are supported" if ref $_;
1527b39c5158Smillert                    $yaml .= $indent . $options->{delta} . "- $_\n";
1528b39c5158Smillert                }
1529b39c5158Smillert            }
1530b39c5158Smillert            else {
1531b39c5158Smillert                $yaml .= $indent . "$key:  []\n";
1532b39c5158Smillert            }
1533b39c5158Smillert        }
1534b39c5158Smillert        elsif( ref $val and !blessed($val) ) {
1535b39c5158Smillert            croak "only nested hashes, arrays and objects are supported";
1536b39c5158Smillert        }
1537b39c5158Smillert        else {  # if it's an object, just stringify it
1538b39c5158Smillert            $yaml .= $indent . sprintf "$k_format  %s\n", "$key:", $val;
1539b39c5158Smillert        }
1540b39c5158Smillert    };
1541b39c5158Smillert
1542b39c5158Smillert    return $yaml;
1543b39c5158Smillert
1544b39c5158Smillert}
1545b39c5158Smillert
1546b39c5158Smillertsub blessed {
1547b39c5158Smillert    return eval { $_[0]->isa("UNIVERSAL"); };
1548b39c5158Smillert}
1549b39c5158Smillert
1550b39c5158Smillertsub max {
1551b39c5158Smillert    return (sort { $b <=> $a } @_)[0];
1552b39c5158Smillert}
1553b39c5158Smillert
1554b39c5158Smillertsub min {
1555b39c5158Smillert    return (sort { $a <=> $b } @_)[0];
1556b39c5158Smillert}
1557b39c5158Smillert
1558b39c5158Smillert=head3 metafile_file
1559b39c5158Smillert
1560b39c5158Smillert    my $meta_yml = $mm->metafile_file(@metadata_pairs);
1561b39c5158Smillert
1562b39c5158SmillertTurns the @metadata_pairs into YAML.
1563b39c5158Smillert
1564b39c5158SmillertThis method does not implement a complete YAML dumper, being limited
1565b39c5158Smillertto dump a hash with values which are strings, undef's or nested hashes
1566b39c5158Smillertand arrays of strings. No quoting/escaping is done.
1567b39c5158Smillert
1568b39c5158Smillert=cut
1569b39c5158Smillert
1570b39c5158Smillertsub metafile_file {
1571b39c5158Smillert    my $self = shift;
1572b39c5158Smillert
1573b39c5158Smillert    my %dump_options = (
1574b39c5158Smillert        use_header => 1,
1575b39c5158Smillert        delta      => ' ' x 4,
1576b39c5158Smillert        key_sort   => undef,
1577b39c5158Smillert    );
1578b39c5158Smillert    return _dump_hash(\%dump_options, @_);
1579b39c5158Smillert
1580b39c5158Smillert}
1581b39c5158Smillert
1582b39c5158Smillert
1583b39c5158Smillert=head3 distmeta_target
1584b39c5158Smillert
1585b39c5158Smillert    my $make_frag = $mm->distmeta_target;
1586b39c5158Smillert
1587e5157e49Safresh1Generates the distmeta target to add META.yml and META.json to the MANIFEST
1588e5157e49Safresh1in the distdir.
1589b39c5158Smillert
1590b39c5158Smillert=cut
1591b39c5158Smillert
1592b39c5158Smillertsub distmeta_target {
1593b39c5158Smillert    my $self = shift;
1594b39c5158Smillert
159548950c12Ssthen    my @add_meta = (
159648950c12Ssthen      $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']),
159748950c12Ssthenexit unless -e q{META.yml};
159848950c12Sstheneval { maniadd({q{META.yml} => q{Module YAML meta-data (added by MakeMaker)}}) }
15999f11ffb7Safresh1    or die "Could not add META.yml to MANIFEST: ${'@'}"
1600b39c5158SmillertCODE
160148950c12Ssthen      $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd'])
160248950c12Ssthenexit unless -f q{META.json};
160348950c12Sstheneval { maniadd({q{META.json} => q{Module JSON meta-data (added by MakeMaker)}}) }
16049f11ffb7Safresh1    or die "Could not add META.json to MANIFEST: ${'@'}"
160548950c12SsthenCODE
160648950c12Ssthen    );
1607b39c5158Smillert
160848950c12Ssthen    my @add_meta_to_distdir = map { $self->cd('$(DISTVNAME)', $_) } @add_meta;
1609b39c5158Smillert
161048950c12Ssthen    return sprintf <<'MAKE', @add_meta_to_distdir;
1611b39c5158Smillertdistmeta : create_distdir metafile
1612b39c5158Smillert	$(NOECHO) %s
161348950c12Ssthen	$(NOECHO) %s
1614b39c5158Smillert
1615b39c5158SmillertMAKE
1616b39c5158Smillert
1617b39c5158Smillert}
1618b39c5158Smillert
1619b39c5158Smillert
162048950c12Ssthen=head3 mymeta
162148950c12Ssthen
162248950c12Ssthen    my $mymeta = $mm->mymeta;
162348950c12Ssthen
1624e5157e49Safresh1Generate MYMETA information as a hash either from an existing CPAN Meta file
1625e5157e49Safresh1(META.json or META.yml) or from internal data.
162648950c12Ssthen
162748950c12Ssthen=cut
162848950c12Ssthen
162948950c12Ssthensub mymeta {
163048950c12Ssthen    my $self = shift;
163148950c12Ssthen    my $file = shift || ''; # for testing
163248950c12Ssthen
163348950c12Ssthen    my $mymeta = $self->_mymeta_from_meta($file);
1634e9ce3842Safresh1    my $v2 = 1;
163548950c12Ssthen
163648950c12Ssthen    unless ( $mymeta ) {
16379f11ffb7Safresh1        $mymeta = $self->metafile_data(
163848950c12Ssthen            $self->{META_ADD}   || {},
163948950c12Ssthen            $self->{META_MERGE} || {},
164048950c12Ssthen        );
1641e9ce3842Safresh1        $v2 = 0;
164248950c12Ssthen    }
164348950c12Ssthen
164448950c12Ssthen    # Overwrite the non-configure dependency hashes
16459f11ffb7Safresh1    $self->_add_requirements_to_meta($mymeta);
164648950c12Ssthen
164748950c12Ssthen    $mymeta->{dynamic_config} = 0;
164848950c12Ssthen
164948950c12Ssthen    return $mymeta;
165048950c12Ssthen}
165148950c12Ssthen
165248950c12Ssthen
165348950c12Ssthensub _mymeta_from_meta {
165448950c12Ssthen    my $self = shift;
165548950c12Ssthen    my $metafile = shift || ''; # for testing
165648950c12Ssthen
165748950c12Ssthen    return unless _has_cpan_meta();
165848950c12Ssthen
165948950c12Ssthen    my $meta;
166048950c12Ssthen    for my $file ( $metafile, "META.json", "META.yml" ) {
166148950c12Ssthen      next unless -e $file;
166248950c12Ssthen      eval {
1663e9ce3842Safresh1          $meta = CPAN::Meta->load_file($file)->as_struct( { version => 2 } );
166448950c12Ssthen      };
166548950c12Ssthen      last if $meta;
166648950c12Ssthen    }
1667e9ce3842Safresh1    return unless $meta;
166848950c12Ssthen
166948950c12Ssthen    # META.yml before 6.25_01 cannot be trusted.  META.yml lived in the source directory.
167048950c12Ssthen    # There was a good chance the author accidentally uploaded a stale META.yml if they
167148950c12Ssthen    # rolled their own tarball rather than using "make dist".
167248950c12Ssthen    if ($meta->{generated_by} &&
167348950c12Ssthen        $meta->{generated_by} =~ /ExtUtils::MakeMaker version ([\d\._]+)/) {
1674eac174f2Safresh1        my $eummv = do { no warnings; $1+0; };
167548950c12Ssthen        if ($eummv < 6.2501) {
1676e9ce3842Safresh1            return;
167748950c12Ssthen        }
167848950c12Ssthen    }
167948950c12Ssthen
168048950c12Ssthen    return $meta;
168148950c12Ssthen}
168248950c12Ssthen
168348950c12Ssthen=head3 write_mymeta
168448950c12Ssthen
168548950c12Ssthen    $self->write_mymeta( $mymeta );
168648950c12Ssthen
1687e5157e49Safresh1Write MYMETA information to MYMETA.json and MYMETA.yml.
168848950c12Ssthen
168948950c12Ssthen=cut
169048950c12Ssthen
169148950c12Ssthensub write_mymeta {
169248950c12Ssthen    my $self = shift;
169348950c12Ssthen    my $mymeta = shift;
169448950c12Ssthen
169548950c12Ssthen    return unless _has_cpan_meta();
169648950c12Ssthen
16979f11ffb7Safresh1    my $meta_obj = $self->_fix_metadata_before_conversion( $mymeta );
169848950c12Ssthen
16999f11ffb7Safresh1    $meta_obj->save( 'MYMETA.json', { version => "2.0" } );
170048950c12Ssthen    $meta_obj->save( 'MYMETA.yml', { version => "1.4" } );
170148950c12Ssthen    return 1;
170248950c12Ssthen}
170348950c12Ssthen
1704b39c5158Smillert=head3 realclean (o)
1705b39c5158Smillert
1706b39c5158SmillertDefines the realclean target.
1707b39c5158Smillert
1708b39c5158Smillert=cut
1709b39c5158Smillert
1710b39c5158Smillertsub realclean {
1711b39c5158Smillert    my($self, %attribs) = @_;
1712b39c5158Smillert
1713b39c5158Smillert    my @dirs  = qw($(DISTVNAME));
1714b39c5158Smillert    my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD));
1715b39c5158Smillert
1716b39c5158Smillert    # Special exception for the perl core where INST_* is not in blib.
1717b39c5158Smillert    # This cleans up the files built from the ext/ directory (all XS).
1718b39c5158Smillert    if( $self->{PERL_CORE} ) {
1719b39c5158Smillert        push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR));
1720b39c5158Smillert        push @files, values %{$self->{PM}};
1721b39c5158Smillert    }
1722b39c5158Smillert
1723b39c5158Smillert    if( $self->has_link_code ){
1724b39c5158Smillert        push @files, qw($(OBJECT));
1725b39c5158Smillert    }
1726b39c5158Smillert
1727b39c5158Smillert    if( $attribs{FILES} ) {
1728b39c5158Smillert        if( ref $attribs{FILES} ) {
1729b39c5158Smillert            push @dirs, @{ $attribs{FILES} };
1730b39c5158Smillert        }
1731b39c5158Smillert        else {
1732b39c5158Smillert            push @dirs, split /\s+/, $attribs{FILES};
1733b39c5158Smillert        }
1734b39c5158Smillert    }
1735b39c5158Smillert
1736b39c5158Smillert    # Occasionally files are repeated several times from different sources
17379f11ffb7Safresh1    { my(%f) = map { ($_ => 1) } @files;  @files = sort keys %f; }
17389f11ffb7Safresh1    { my(%d) = map { ($_ => 1) } @dirs;   @dirs  = sort keys %d; }
1739b39c5158Smillert
1740b39c5158Smillert    my $rm_cmd  = join "\n\t", map { "$_" }
1741b39c5158Smillert                    $self->split_command('- $(RM_F)',  @files);
1742b39c5158Smillert    my $rmf_cmd = join "\n\t", map { "$_" }
1743b39c5158Smillert                    $self->split_command('- $(RM_RF)', @dirs);
1744b39c5158Smillert
1745b39c5158Smillert    my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
1746b39c5158Smillert# Delete temporary files (via clean) and also delete dist files
17479f11ffb7Safresh1realclean purge :: realclean_subdirs
1748b39c5158Smillert	%s
1749b39c5158Smillert	%s
1750b39c5158SmillertMAKE
1751b39c5158Smillert
1752b39c5158Smillert    $m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP};
1753b39c5158Smillert
1754b39c5158Smillert    return $m;
1755b39c5158Smillert}
1756b39c5158Smillert
1757b39c5158Smillert
1758b39c5158Smillert=head3 realclean_subdirs_target
1759b39c5158Smillert
1760b39c5158Smillert  my $make_frag = $MM->realclean_subdirs_target;
1761b39c5158Smillert
1762b39c5158SmillertReturns the realclean_subdirs target.  This is used by the realclean
1763b39c5158Smillerttarget to call realclean on any subdirectories which contain Makefiles.
1764b39c5158Smillert
1765b39c5158Smillert=cut
1766b39c5158Smillert
1767b39c5158Smillertsub realclean_subdirs_target {
1768b39c5158Smillert    my $self = shift;
17699f11ffb7Safresh1    my @m = <<'EOF';
17709f11ffb7Safresh1# so clean is forced to complete before realclean_subdirs runs
17719f11ffb7Safresh1realclean_subdirs : clean
17729f11ffb7Safresh1EOF
17739f11ffb7Safresh1    return join '', @m, "\t\$(NOECHO) \$(NOOP)\n" unless @{$self->{DIR}};
1774b39c5158Smillert    foreach my $dir (@{$self->{DIR}}) {
1775b39c5158Smillert        foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
17769f11ffb7Safresh1            my $subrclean .= $self->oneliner(_sprintf562 <<'CODE', $dir, $makefile);
17779f11ffb7Safresh1chdir '%1$s';  system '$(MAKE) $(USEMAKEFILE) %2$s realclean' if -f '%2$s';
1778b39c5158SmillertCODE
17799f11ffb7Safresh1            push @m, "\t- $subrclean\n";
1780b39c5158Smillert        }
1781b39c5158Smillert    }
17829f11ffb7Safresh1    return join '', @m;
1783b39c5158Smillert}
1784b39c5158Smillert
1785b39c5158Smillert
1786b39c5158Smillert=head3 signature_target
1787b39c5158Smillert
1788b39c5158Smillert    my $target = $mm->signature_target;
1789b39c5158Smillert
1790b39c5158SmillertGenerate the signature target.
1791b39c5158Smillert
1792b39c5158SmillertWrites the file SIGNATURE with "cpansign -s".
1793b39c5158Smillert
1794b39c5158Smillert=cut
1795b39c5158Smillert
1796b39c5158Smillertsub signature_target {
1797b39c5158Smillert    my $self = shift;
1798b39c5158Smillert
1799b39c5158Smillert    return <<'MAKE_FRAG';
1800b39c5158Smillertsignature :
1801b39c5158Smillert	cpansign -s
1802b39c5158SmillertMAKE_FRAG
1803b39c5158Smillert
1804b39c5158Smillert}
1805b39c5158Smillert
1806b39c5158Smillert
1807b39c5158Smillert=head3 distsignature_target
1808b39c5158Smillert
1809b39c5158Smillert    my $make_frag = $mm->distsignature_target;
1810b39c5158Smillert
1811b39c5158SmillertGenerates the distsignature target to add SIGNATURE to the MANIFEST in the
1812b39c5158Smillertdistdir.
1813b39c5158Smillert
1814b39c5158Smillert=cut
1815b39c5158Smillert
1816b39c5158Smillertsub distsignature_target {
1817b39c5158Smillert    my $self = shift;
1818b39c5158Smillert
1819b39c5158Smillert    my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
1820b39c5158Smillerteval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }
18219f11ffb7Safresh1    or die "Could not add SIGNATURE to MANIFEST: ${'@'}"
1822b39c5158SmillertCODE
1823b39c5158Smillert
1824b39c5158Smillert    my $sign_dist        = $self->cd('$(DISTVNAME)' => 'cpansign -s');
1825b39c5158Smillert
1826b39c5158Smillert    # cpansign -s complains if SIGNATURE is in the MANIFEST yet does not
1827b39c5158Smillert    # exist
1828b39c5158Smillert    my $touch_sig        = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE');
1829b39c5158Smillert    my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign );
1830b39c5158Smillert
1831b39c5158Smillert    return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_dist
1832b8851fccSafresh1distsignature : distmeta
1833b39c5158Smillert	$(NOECHO) %s
1834b39c5158Smillert	$(NOECHO) %s
1835b39c5158Smillert	%s
1836b39c5158Smillert
1837b39c5158SmillertMAKE
1838b39c5158Smillert
1839b39c5158Smillert}
1840b39c5158Smillert
1841b39c5158Smillert
1842b39c5158Smillert=head3 special_targets
1843b39c5158Smillert
1844b39c5158Smillert  my $make_frag = $mm->special_targets
1845b39c5158Smillert
1846b39c5158SmillertReturns a make fragment containing any targets which have special
1847b39c5158Smillertmeaning to make.  For example, .SUFFIXES and .PHONY.
1848b39c5158Smillert
1849b39c5158Smillert=cut
1850b39c5158Smillert
1851b39c5158Smillertsub special_targets {
1852b39c5158Smillert    my $make_frag = <<'MAKE_FRAG';
1853b39c5158Smillert.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
1854b39c5158Smillert
18559f11ffb7Safresh1.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir pure_all subdirs clean_subdirs makemakerdflt manifypods realclean_subdirs subdirs_dynamic subdirs_pure_nolink subdirs_static subdirs-test_dynamic subdirs-test_static test_dynamic test_static
1856b39c5158Smillert
1857b39c5158SmillertMAKE_FRAG
1858b39c5158Smillert
1859b39c5158Smillert    $make_frag .= <<'MAKE_FRAG' if $ENV{CLEARCASE_ROOT};
1860b39c5158Smillert.NO_CONFIG_REC: Makefile
1861b39c5158Smillert
1862b39c5158SmillertMAKE_FRAG
1863b39c5158Smillert
1864b39c5158Smillert    return $make_frag;
1865b39c5158Smillert}
1866b39c5158Smillert
1867b39c5158Smillert
1868b39c5158Smillert
1869b39c5158Smillert
1870b39c5158Smillert=head2 Init methods
1871b39c5158Smillert
1872b39c5158SmillertMethods which help initialize the MakeMaker object and macros.
1873b39c5158Smillert
1874b39c5158Smillert
1875b39c5158Smillert=head3 init_ABSTRACT
1876b39c5158Smillert
1877b39c5158Smillert    $mm->init_ABSTRACT
1878b39c5158Smillert
1879b39c5158Smillert=cut
1880b39c5158Smillert
1881b39c5158Smillertsub init_ABSTRACT {
1882b39c5158Smillert    my $self = shift;
1883b39c5158Smillert
1884b39c5158Smillert    if( $self->{ABSTRACT_FROM} and $self->{ABSTRACT} ) {
1885b39c5158Smillert        warn "Both ABSTRACT_FROM and ABSTRACT are set.  ".
1886b39c5158Smillert             "Ignoring ABSTRACT_FROM.\n";
1887b39c5158Smillert        return;
1888b39c5158Smillert    }
1889b39c5158Smillert
1890b39c5158Smillert    if ($self->{ABSTRACT_FROM}){
1891b39c5158Smillert        $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
1892b39c5158Smillert            carp "WARNING: Setting ABSTRACT via file ".
1893b39c5158Smillert                 "'$self->{ABSTRACT_FROM}' failed\n";
1894b39c5158Smillert    }
1895e5157e49Safresh1
1896e5157e49Safresh1    if ($self->{ABSTRACT} && $self->{ABSTRACT} =~ m![[:cntrl:]]+!) {
1897e5157e49Safresh1            warn "WARNING: ABSTRACT contains control character(s),".
1898e5157e49Safresh1                 " they will be removed\n";
1899e5157e49Safresh1            $self->{ABSTRACT} =~ s![[:cntrl:]]+!!g;
1900e5157e49Safresh1            return;
1901e5157e49Safresh1    }
1902b39c5158Smillert}
1903b39c5158Smillert
1904b39c5158Smillert=head3 init_INST
1905b39c5158Smillert
1906b39c5158Smillert    $mm->init_INST;
1907b39c5158Smillert
1908b39c5158SmillertCalled by init_main.  Sets up all INST_* variables except those related
1909b39c5158Smillertto XS code.  Those are handled in init_xs.
1910b39c5158Smillert
1911b39c5158Smillert=cut
1912b39c5158Smillert
1913b39c5158Smillertsub init_INST {
1914b39c5158Smillert    my($self) = shift;
1915b39c5158Smillert
1916b39c5158Smillert    $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
1917b39c5158Smillert    $self->{INST_BIN}     ||= $self->catdir($Curdir,'blib','bin');
1918b39c5158Smillert
1919b39c5158Smillert    # INST_LIB typically pre-set if building an extension after
1920b39c5158Smillert    # perl has been built and installed. Setting INST_LIB allows
1921b39c5158Smillert    # you to build directly into, say $Config{privlibexp}.
1922b39c5158Smillert    unless ($self->{INST_LIB}){
1923b39c5158Smillert        if ($self->{PERL_CORE}) {
1924b39c5158Smillert            $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
1925b39c5158Smillert        } else {
1926b39c5158Smillert            $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
1927b39c5158Smillert        }
1928b39c5158Smillert    }
1929b39c5158Smillert
1930b39c5158Smillert    my @parentdir = split(/::/, $self->{PARENT_NAME});
1931b39c5158Smillert    $self->{INST_LIBDIR}      = $self->catdir('$(INST_LIB)',     @parentdir);
1932b39c5158Smillert    $self->{INST_ARCHLIBDIR}  = $self->catdir('$(INST_ARCHLIB)', @parentdir);
1933b39c5158Smillert    $self->{INST_AUTODIR}     = $self->catdir('$(INST_LIB)', 'auto',
1934b39c5158Smillert                                              '$(FULLEXT)');
1935b39c5158Smillert    $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto',
1936b39c5158Smillert                                              '$(FULLEXT)');
1937b39c5158Smillert
1938b39c5158Smillert    $self->{INST_SCRIPT}  ||= $self->catdir($Curdir,'blib','script');
1939b39c5158Smillert
1940b39c5158Smillert    $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1');
1941b39c5158Smillert    $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3');
1942b39c5158Smillert
1943b39c5158Smillert    return 1;
1944b39c5158Smillert}
1945b39c5158Smillert
1946b39c5158Smillert
1947b39c5158Smillert=head3 init_INSTALL
1948b39c5158Smillert
1949b39c5158Smillert    $mm->init_INSTALL;
1950b39c5158Smillert
1951b39c5158SmillertCalled by init_main.  Sets up all INSTALL_* variables (except
1952b39c5158SmillertINSTALLDIRS) and *PREFIX.
1953b39c5158Smillert
1954b39c5158Smillert=cut
1955b39c5158Smillert
1956b39c5158Smillertsub init_INSTALL {
1957b39c5158Smillert    my($self) = shift;
1958b39c5158Smillert
1959b39c5158Smillert    if( $self->{ARGS}{INSTALL_BASE} and $self->{ARGS}{PREFIX} ) {
1960b39c5158Smillert        die "Only one of PREFIX or INSTALL_BASE can be given.  Not both.\n";
1961b39c5158Smillert    }
1962b39c5158Smillert
1963b39c5158Smillert    if( $self->{ARGS}{INSTALL_BASE} ) {
1964b39c5158Smillert        $self->init_INSTALL_from_INSTALL_BASE;
1965b39c5158Smillert    }
1966b39c5158Smillert    else {
1967b39c5158Smillert        $self->init_INSTALL_from_PREFIX;
1968b39c5158Smillert    }
1969b39c5158Smillert}
1970b39c5158Smillert
1971b39c5158Smillert
1972b39c5158Smillert=head3 init_INSTALL_from_PREFIX
1973b39c5158Smillert
1974b39c5158Smillert  $mm->init_INSTALL_from_PREFIX;
1975b39c5158Smillert
1976b39c5158Smillert=cut
1977b39c5158Smillert
1978b39c5158Smillertsub init_INSTALL_from_PREFIX {
1979b39c5158Smillert    my $self = shift;
1980b39c5158Smillert
1981b39c5158Smillert    $self->init_lib2arch;
1982b39c5158Smillert
1983b39c5158Smillert    # There are often no Config.pm defaults for these new man variables so
1984b39c5158Smillert    # we fall back to the old behavior which is to use installman*dir
1985b39c5158Smillert    foreach my $num (1, 3) {
1986b39c5158Smillert        my $k = 'installsiteman'.$num.'dir';
1987b39c5158Smillert
1988b39c5158Smillert        $self->{uc $k} ||= uc "\$(installman${num}dir)"
1989b39c5158Smillert          unless $Config{$k};
1990b39c5158Smillert    }
1991b39c5158Smillert
1992b39c5158Smillert    foreach my $num (1, 3) {
1993b39c5158Smillert        my $k = 'installvendorman'.$num.'dir';
1994b39c5158Smillert
1995b39c5158Smillert        unless( $Config{$k} ) {
1996b39c5158Smillert            $self->{uc $k}  ||= $Config{usevendorprefix}
1997b39c5158Smillert                              ? uc "\$(installman${num}dir)"
1998b39c5158Smillert                              : '';
1999b39c5158Smillert        }
2000b39c5158Smillert    }
2001b39c5158Smillert
2002b39c5158Smillert    $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)'
2003b39c5158Smillert      unless $Config{installsitebin};
2004b39c5158Smillert    $self->{INSTALLSITESCRIPT} ||= '$(INSTALLSCRIPT)'
2005b39c5158Smillert      unless $Config{installsitescript};
2006b39c5158Smillert
2007b39c5158Smillert    unless( $Config{installvendorbin} ) {
2008b39c5158Smillert        $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix}
2009b39c5158Smillert                                    ? $Config{installbin}
2010b39c5158Smillert                                    : '';
2011b39c5158Smillert    }
2012b39c5158Smillert    unless( $Config{installvendorscript} ) {
2013b39c5158Smillert        $self->{INSTALLVENDORSCRIPT} ||= $Config{usevendorprefix}
2014b39c5158Smillert                                       ? $Config{installscript}
2015b39c5158Smillert                                       : '';
2016b39c5158Smillert    }
2017b39c5158Smillert
2018b39c5158Smillert
2019b39c5158Smillert    my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
2020b39c5158Smillert                  $Config{prefixexp}        || $Config{prefix} || '';
2021b39c5158Smillert    my $vprefix = $Config{usevendorprefix}  ? $Config{vendorprefixexp} : '';
2022b39c5158Smillert    my $sprefix = $Config{siteprefixexp}    || '';
2023b39c5158Smillert
2024b39c5158Smillert    # 5.005_03 doesn't have a siteprefix.
2025b39c5158Smillert    $sprefix = $iprefix unless $sprefix;
2026b39c5158Smillert
2027b39c5158Smillert
2028b39c5158Smillert    $self->{PREFIX}       ||= '';
2029b39c5158Smillert
2030b39c5158Smillert    if( $self->{PREFIX} ) {
2031b39c5158Smillert        @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
2032b39c5158Smillert          ('$(PREFIX)') x 3;
2033b39c5158Smillert    }
2034b39c5158Smillert    else {
2035b39c5158Smillert        $self->{PERLPREFIX}   ||= $iprefix;
2036b39c5158Smillert        $self->{SITEPREFIX}   ||= $sprefix;
2037b39c5158Smillert        $self->{VENDORPREFIX} ||= $vprefix;
2038b39c5158Smillert
2039b39c5158Smillert        # Lots of MM extension authors like to use $(PREFIX) so we
2040b39c5158Smillert        # put something sensible in there no matter what.
2041b39c5158Smillert        $self->{PREFIX} = '$('.uc $self->{INSTALLDIRS}.'PREFIX)';
2042b39c5158Smillert    }
2043b39c5158Smillert
2044b39c5158Smillert    my $arch    = $Config{archname};
2045b39c5158Smillert    my $version = $Config{version};
2046b39c5158Smillert
2047b39c5158Smillert    # default style
2048b39c5158Smillert    my $libstyle = $Config{installstyle} || 'lib/perl5';
2049b39c5158Smillert    my $manstyle = '';
2050b39c5158Smillert
2051b39c5158Smillert    if( $self->{LIBSTYLE} ) {
2052b39c5158Smillert        $libstyle = $self->{LIBSTYLE};
2053b39c5158Smillert        $manstyle = $self->{LIBSTYLE} eq 'lib/perl5' ? 'lib/perl5' : '';
2054b39c5158Smillert    }
2055b39c5158Smillert
2056b39c5158Smillert    # Some systems, like VOS, set installman*dir to '' if they can't
2057b39c5158Smillert    # read man pages.
2058b39c5158Smillert    for my $num (1, 3) {
2059b39c5158Smillert        $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
2060b39c5158Smillert          unless $Config{'installman'.$num.'dir'};
2061b39c5158Smillert    }
2062b39c5158Smillert
2063b39c5158Smillert    my %bin_layouts =
2064b39c5158Smillert    (
2065b39c5158Smillert        bin         => { s => $iprefix,
2066b39c5158Smillert                         t => 'perl',
2067b39c5158Smillert                         d => 'bin' },
2068b39c5158Smillert        vendorbin   => { s => $vprefix,
2069b39c5158Smillert                         t => 'vendor',
2070b39c5158Smillert                         d => 'bin' },
2071b39c5158Smillert        sitebin     => { s => $sprefix,
2072b39c5158Smillert                         t => 'site',
2073b39c5158Smillert                         d => 'bin' },
2074b39c5158Smillert        script      => { s => $iprefix,
2075b39c5158Smillert                         t => 'perl',
2076b39c5158Smillert                         d => 'bin' },
2077b39c5158Smillert        vendorscript=> { s => $vprefix,
2078b39c5158Smillert                         t => 'vendor',
2079b39c5158Smillert                         d => 'bin' },
2080b39c5158Smillert        sitescript  => { s => $sprefix,
2081b39c5158Smillert                         t => 'site',
2082b39c5158Smillert                         d => 'bin' },
2083b39c5158Smillert    );
2084b39c5158Smillert
2085b39c5158Smillert    my %man_layouts =
2086b39c5158Smillert    (
2087b39c5158Smillert        man1dir         => { s => $iprefix,
2088b39c5158Smillert                             t => 'perl',
2089b39c5158Smillert                             d => 'man/man1',
2090b39c5158Smillert                             style => $manstyle, },
2091b39c5158Smillert        siteman1dir     => { s => $sprefix,
2092b39c5158Smillert                             t => 'site',
2093b39c5158Smillert                             d => 'man/man1',
2094b39c5158Smillert                             style => $manstyle, },
2095b39c5158Smillert        vendorman1dir   => { s => $vprefix,
2096b39c5158Smillert                             t => 'vendor',
2097b39c5158Smillert                             d => 'man/man1',
2098b39c5158Smillert                             style => $manstyle, },
2099b39c5158Smillert
2100b39c5158Smillert        man3dir         => { s => $iprefix,
2101b39c5158Smillert                             t => 'perl',
2102b39c5158Smillert                             d => 'man/man3',
2103b39c5158Smillert                             style => $manstyle, },
2104b39c5158Smillert        siteman3dir     => { s => $sprefix,
2105b39c5158Smillert                             t => 'site',
2106b39c5158Smillert                             d => 'man/man3',
2107b39c5158Smillert                             style => $manstyle, },
2108b39c5158Smillert        vendorman3dir   => { s => $vprefix,
2109b39c5158Smillert                             t => 'vendor',
2110b39c5158Smillert                             d => 'man/man3',
2111b39c5158Smillert                             style => $manstyle, },
2112b39c5158Smillert    );
2113b39c5158Smillert
2114b39c5158Smillert    my %lib_layouts =
2115b39c5158Smillert    (
2116b39c5158Smillert        privlib     => { s => $iprefix,
2117b39c5158Smillert                         t => 'perl',
2118b39c5158Smillert                         d => '',
2119b39c5158Smillert                         style => $libstyle, },
2120b39c5158Smillert        vendorlib   => { s => $vprefix,
2121b39c5158Smillert                         t => 'vendor',
2122b39c5158Smillert                         d => '',
2123b39c5158Smillert                         style => $libstyle, },
2124b39c5158Smillert        sitelib     => { s => $sprefix,
2125b39c5158Smillert                         t => 'site',
2126b39c5158Smillert                         d => 'site_perl',
2127b39c5158Smillert                         style => $libstyle, },
2128b39c5158Smillert
2129b39c5158Smillert        archlib     => { s => $iprefix,
2130b39c5158Smillert                         t => 'perl',
2131b39c5158Smillert                         d => "$version/$arch",
2132b39c5158Smillert                         style => $libstyle },
2133b39c5158Smillert        vendorarch  => { s => $vprefix,
2134b39c5158Smillert                         t => 'vendor',
2135b39c5158Smillert                         d => "$version/$arch",
2136b39c5158Smillert                         style => $libstyle },
2137b39c5158Smillert        sitearch    => { s => $sprefix,
2138b39c5158Smillert                         t => 'site',
2139b39c5158Smillert                         d => "site_perl/$version/$arch",
2140b39c5158Smillert                         style => $libstyle },
2141b39c5158Smillert    );
2142b39c5158Smillert
2143b39c5158Smillert
2144b39c5158Smillert    # Special case for LIB.
2145b39c5158Smillert    if( $self->{LIB} ) {
2146b39c5158Smillert        foreach my $var (keys %lib_layouts) {
2147b39c5158Smillert            my $Installvar = uc "install$var";
2148b39c5158Smillert
2149b39c5158Smillert            if( $var =~ /arch/ ) {
2150b39c5158Smillert                $self->{$Installvar} ||=
2151b39c5158Smillert                  $self->catdir($self->{LIB}, $Config{archname});
2152b39c5158Smillert            }
2153b39c5158Smillert            else {
2154b39c5158Smillert                $self->{$Installvar} ||= $self->{LIB};
2155b39c5158Smillert            }
2156b39c5158Smillert        }
2157b39c5158Smillert    }
2158b39c5158Smillert
2159b39c5158Smillert    my %type2prefix = ( perl    => 'PERLPREFIX',
2160b39c5158Smillert                        site    => 'SITEPREFIX',
2161b39c5158Smillert                        vendor  => 'VENDORPREFIX'
2162b39c5158Smillert                      );
2163b39c5158Smillert
2164b39c5158Smillert    my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
2165b39c5158Smillert    while( my($var, $layout) = each(%layouts) ) {
2166b39c5158Smillert        my($s, $t, $d, $style) = @{$layout}{qw(s t d style)};
2167b39c5158Smillert        my $r = '$('.$type2prefix{$t}.')';
2168b39c5158Smillert
2169e9ce3842Safresh1        warn "Prefixing $var\n" if $Verbose >= 2;
2170b39c5158Smillert
2171b39c5158Smillert        my $installvar = "install$var";
2172b39c5158Smillert        my $Installvar = uc $installvar;
2173b39c5158Smillert        next if $self->{$Installvar};
2174b39c5158Smillert
2175b39c5158Smillert        $d = "$style/$d" if $style;
2176b39c5158Smillert        $self->prefixify($installvar, $s, $r, $d);
2177b39c5158Smillert
2178e9ce3842Safresh1        warn "  $Installvar == $self->{$Installvar}\n"
2179b39c5158Smillert          if $Verbose >= 2;
2180b39c5158Smillert    }
2181b39c5158Smillert
2182b39c5158Smillert    # Generate these if they weren't figured out.
2183b39c5158Smillert    $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH};
2184b39c5158Smillert    $self->{VENDORLIBEXP}  ||= $self->{INSTALLVENDORLIB};
2185b39c5158Smillert
2186b39c5158Smillert    return 1;
2187b39c5158Smillert}
2188b39c5158Smillert
2189b39c5158Smillert
2190b39c5158Smillert=head3 init_from_INSTALL_BASE
2191b39c5158Smillert
2192b39c5158Smillert    $mm->init_from_INSTALL_BASE
2193b39c5158Smillert
2194b39c5158Smillert=cut
2195b39c5158Smillert
2196b39c5158Smillertmy %map = (
2197b39c5158Smillert           lib      => [qw(lib perl5)],
2198b39c5158Smillert           arch     => [('lib', 'perl5', $Config{archname})],
2199b39c5158Smillert           bin      => [qw(bin)],
2200b39c5158Smillert           man1dir  => [qw(man man1)],
2201b39c5158Smillert           man3dir  => [qw(man man3)]
2202b39c5158Smillert          );
2203b39c5158Smillert$map{script} = $map{bin};
2204b39c5158Smillert
2205b39c5158Smillertsub init_INSTALL_from_INSTALL_BASE {
2206b39c5158Smillert    my $self = shift;
2207b39c5158Smillert
2208b39c5158Smillert    @{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} =
2209b39c5158Smillert                                                         '$(INSTALL_BASE)';
2210b39c5158Smillert
2211b39c5158Smillert    my %install;
2212b39c5158Smillert    foreach my $thing (keys %map) {
2213b39c5158Smillert        foreach my $dir (('', 'SITE', 'VENDOR')) {
2214b39c5158Smillert            my $uc_thing = uc $thing;
2215b39c5158Smillert            my $key = "INSTALL".$dir.$uc_thing;
2216b39c5158Smillert
2217b39c5158Smillert            $install{$key} ||=
221856d68f1eSafresh1                ($thing =~ /^man.dir$/ and not $Config{lc $key})
221956d68f1eSafresh1                ? 'none'
222056d68f1eSafresh1                : $self->catdir('$(INSTALL_BASE)', @{$map{$thing}});
2221b39c5158Smillert        }
2222b39c5158Smillert    }
2223b39c5158Smillert
2224b39c5158Smillert    # Adjust for variable quirks.
2225b39c5158Smillert    $install{INSTALLARCHLIB} ||= delete $install{INSTALLARCH};
2226b39c5158Smillert    $install{INSTALLPRIVLIB} ||= delete $install{INSTALLLIB};
2227b39c5158Smillert
2228b39c5158Smillert    foreach my $key (keys %install) {
2229b39c5158Smillert        $self->{$key} ||= $install{$key};
2230b39c5158Smillert    }
2231b39c5158Smillert
2232b39c5158Smillert    return 1;
2233b39c5158Smillert}
2234b39c5158Smillert
2235b39c5158Smillert
2236b39c5158Smillert=head3 init_VERSION  I<Abstract>
2237b39c5158Smillert
2238b39c5158Smillert    $mm->init_VERSION
2239b39c5158Smillert
2240b39c5158SmillertInitialize macros representing versions of MakeMaker and other tools
2241b39c5158Smillert
2242b39c5158SmillertMAKEMAKER: path to the MakeMaker module.
2243b39c5158Smillert
2244b39c5158SmillertMM_VERSION: ExtUtils::MakeMaker Version
2245b39c5158Smillert
2246b39c5158SmillertMM_REVISION: ExtUtils::MakeMaker version control revision (for backwards
2247b39c5158Smillert             compat)
2248b39c5158Smillert
2249b39c5158SmillertVERSION: version of your module
2250b39c5158Smillert
2251b39c5158SmillertVERSION_MACRO: which macro represents the version (usually 'VERSION')
2252b39c5158Smillert
2253b39c5158SmillertVERSION_SYM: like version but safe for use as an RCS revision number
2254b39c5158Smillert
2255b39c5158SmillertDEFINE_VERSION: -D line to set the module version when compiling
2256b39c5158Smillert
2257b39c5158SmillertXS_VERSION: version in your .xs file.  Defaults to $(VERSION)
2258b39c5158Smillert
2259b39c5158SmillertXS_VERSION_MACRO: which macro represents the XS version.
2260b39c5158Smillert
2261b39c5158SmillertXS_DEFINE_VERSION: -D line to set the xs version when compiling.
2262b39c5158Smillert
2263b39c5158SmillertCalled by init_main.
2264b39c5158Smillert
2265b39c5158Smillert=cut
2266b39c5158Smillert
2267b39c5158Smillertsub init_VERSION {
2268b39c5158Smillert    my($self) = shift;
2269b39c5158Smillert
2270b39c5158Smillert    $self->{MAKEMAKER}  = $ExtUtils::MakeMaker::Filename;
2271b39c5158Smillert    $self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION;
2272b39c5158Smillert    $self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision;
2273b39c5158Smillert    $self->{VERSION_FROM} ||= '';
2274b39c5158Smillert
2275b39c5158Smillert    if ($self->{VERSION_FROM}){
2276b39c5158Smillert        $self->{VERSION} = $self->parse_version($self->{VERSION_FROM});
2277b39c5158Smillert        if( $self->{VERSION} eq 'undef' ) {
2278b39c5158Smillert            carp("WARNING: Setting VERSION via file ".
2279b39c5158Smillert                 "'$self->{VERSION_FROM}' failed\n");
2280b39c5158Smillert        }
2281b39c5158Smillert    }
2282b39c5158Smillert
2283b39c5158Smillert    if (defined $self->{VERSION}) {
2284e5157e49Safresh1        if ( $self->{VERSION} !~ /^\s*v?[\d_\.]+\s*$/ ) {
2285e5157e49Safresh1          require version;
2286b8851fccSafresh1          my $normal = eval { version->new( $self->{VERSION} ) };
2287e5157e49Safresh1          $self->{VERSION} = $normal if defined $normal;
2288e5157e49Safresh1        }
2289b39c5158Smillert        $self->{VERSION} =~ s/^\s+//;
2290b39c5158Smillert        $self->{VERSION} =~ s/\s+$//;
2291b39c5158Smillert    }
2292b39c5158Smillert    else {
2293b39c5158Smillert        $self->{VERSION} = '';
2294b39c5158Smillert    }
2295b39c5158Smillert
2296b39c5158Smillert
2297b39c5158Smillert    $self->{VERSION_MACRO}  = 'VERSION';
2298b39c5158Smillert    ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
2299b39c5158Smillert    $self->{DEFINE_VERSION} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
2300b39c5158Smillert
2301b39c5158Smillert
2302b39c5158Smillert    # Graham Barr and Paul Marquess had some ideas how to ensure
2303b39c5158Smillert    # version compatibility between the *.pm file and the
2304b39c5158Smillert    # corresponding *.xs file. The bottom line was, that we need an
2305b39c5158Smillert    # XS_VERSION macro that defaults to VERSION:
2306b39c5158Smillert    $self->{XS_VERSION} ||= $self->{VERSION};
2307b39c5158Smillert
2308b39c5158Smillert    $self->{XS_VERSION_MACRO}  = 'XS_VERSION';
2309b39c5158Smillert    $self->{XS_DEFINE_VERSION} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
2310b39c5158Smillert
2311b39c5158Smillert}
2312b39c5158Smillert
2313b39c5158Smillert
231448950c12Ssthen=head3 init_tools
2315b39c5158Smillert
231648950c12Ssthen    $MM->init_tools();
2317b39c5158Smillert
231848950c12SsthenInitializes the simple macro definitions used by tools_other() and
231948950c12Ssthenplaces them in the $MM object.  These use conservative cross platform
232048950c12Ssthenversions and should be overridden with platform specific versions for
232148950c12Ssthenperformance.
2322b39c5158Smillert
2323b39c5158SmillertDefines at least these macros.
2324b39c5158Smillert
2325b39c5158Smillert  Macro             Description
2326b39c5158Smillert
2327b39c5158Smillert  NOOP              Do nothing
2328b39c5158Smillert  NOECHO            Tell make not to display the command itself
2329b39c5158Smillert
2330b39c5158Smillert  SHELL             Program used to run shell commands
2331b39c5158Smillert
2332b39c5158Smillert  ECHO              Print text adding a newline on the end
2333b39c5158Smillert  RM_F              Remove a file
2334b39c5158Smillert  RM_RF             Remove a directory
2335b39c5158Smillert  TOUCH             Update a file's timestamp
2336b39c5158Smillert  TEST_F            Test for a file's existence
2337e5157e49Safresh1  TEST_S            Test the size of a file
2338b39c5158Smillert  CP                Copy a file
2339e5157e49Safresh1  CP_NONEMPTY       Copy a file if it is not empty
2340b39c5158Smillert  MV                Move a file
2341b39c5158Smillert  CHMOD             Change permissions on a file
2342b39c5158Smillert  FALSE             Exit with non-zero
2343b39c5158Smillert  TRUE              Exit with zero
2344b39c5158Smillert
2345b39c5158Smillert  UMASK_NULL        Nullify umask
2346b39c5158Smillert  DEV_NULL          Suppress all command output
2347b39c5158Smillert
2348b39c5158Smillert=cut
2349b39c5158Smillert
235048950c12Ssthensub init_tools {
2351b39c5158Smillert    my $self = shift;
2352b39c5158Smillert
2353b8851fccSafresh1    $self->{ECHO}     ||= $self->oneliner('binmode STDOUT, qq{:raw}; print qq{@ARGV}', ['-l']);
2354b39c5158Smillert    $self->{ECHO_N}   ||= $self->oneliner('print qq{@ARGV}');
2355b39c5158Smillert
2356b39c5158Smillert    $self->{TOUCH}    ||= $self->oneliner('touch', ["-MExtUtils::Command"]);
2357b39c5158Smillert    $self->{CHMOD}    ||= $self->oneliner('chmod', ["-MExtUtils::Command"]);
2358b39c5158Smillert    $self->{RM_F}     ||= $self->oneliner('rm_f',  ["-MExtUtils::Command"]);
2359b39c5158Smillert    $self->{RM_RF}    ||= $self->oneliner('rm_rf', ["-MExtUtils::Command"]);
2360b39c5158Smillert    $self->{TEST_F}   ||= $self->oneliner('test_f', ["-MExtUtils::Command"]);
2361e5157e49Safresh1    $self->{TEST_S}   ||= $self->oneliner('test_s', ["-MExtUtils::Command::MM"]);
2362e5157e49Safresh1    $self->{CP_NONEMPTY} ||= $self->oneliner('cp_nonempty', ["-MExtUtils::Command::MM"]);
2363b39c5158Smillert    $self->{FALSE}    ||= $self->oneliner('exit 1');
2364b39c5158Smillert    $self->{TRUE}     ||= $self->oneliner('exit 0');
2365b39c5158Smillert
2366b39c5158Smillert    $self->{MKPATH}   ||= $self->oneliner('mkpath', ["-MExtUtils::Command"]);
2367b39c5158Smillert
2368b39c5158Smillert    $self->{CP}       ||= $self->oneliner('cp', ["-MExtUtils::Command"]);
2369b39c5158Smillert    $self->{MV}       ||= $self->oneliner('mv', ["-MExtUtils::Command"]);
2370b39c5158Smillert
2371b39c5158Smillert    $self->{MOD_INSTALL} ||=
2372b39c5158Smillert      $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
2373b39c5158Smillertinstall([ from_to => {@ARGV}, verbose => '$(VERBINST)', uninstall_shadows => '$(UNINST)', dir_mode => '$(PERM_DIR)' ]);
2374b39c5158SmillertCODE
2375b39c5158Smillert    $self->{DOC_INSTALL} ||= $self->oneliner('perllocal_install', ["-MExtUtils::Command::MM"]);
2376b39c5158Smillert    $self->{UNINSTALL}   ||= $self->oneliner('uninstall', ["-MExtUtils::Command::MM"]);
2377b39c5158Smillert    $self->{WARN_IF_OLD_PACKLIST} ||=
2378b39c5158Smillert      $self->oneliner('warn_if_old_packlist', ["-MExtUtils::Command::MM"]);
2379b39c5158Smillert    $self->{FIXIN}       ||= $self->oneliner('MY->fixin(shift)', ["-MExtUtils::MY"]);
2380b39c5158Smillert    $self->{EQUALIZE_TIMESTAMP} ||= $self->oneliner('eqtime', ["-MExtUtils::Command"]);
2381b39c5158Smillert
2382b39c5158Smillert    $self->{UNINST}     ||= 0;
2383b39c5158Smillert    $self->{VERBINST}   ||= 0;
2384b39c5158Smillert
238548950c12Ssthen    $self->{SHELL}              ||= $Config{sh};
238648950c12Ssthen
238748950c12Ssthen    # UMASK_NULL is not used by MakeMaker but some CPAN modules
238848950c12Ssthen    # make use of it.
238948950c12Ssthen    $self->{UMASK_NULL}         ||= "umask 0";
239048950c12Ssthen
239148950c12Ssthen    # Not the greatest default, but its something.
239248950c12Ssthen    $self->{DEV_NULL}           ||= "> /dev/null 2>&1";
239348950c12Ssthen
239448950c12Ssthen    $self->{NOOP}               ||= '$(TRUE)';
239548950c12Ssthen    $self->{NOECHO}             = '@' unless defined $self->{NOECHO};
239648950c12Ssthen
2397b39c5158Smillert    $self->{FIRST_MAKEFILE}     ||= $self->{MAKEFILE} || 'Makefile';
2398b39c5158Smillert    $self->{MAKEFILE}           ||= $self->{FIRST_MAKEFILE};
2399b39c5158Smillert    $self->{MAKEFILE_OLD}       ||= $self->{MAKEFILE}.'.old';
2400b39c5158Smillert    $self->{MAKE_APERL_FILE}    ||= $self->{MAKEFILE}.'.aperl';
2401b39c5158Smillert
2402b39c5158Smillert    # Not everybody uses -f to indicate "use this Makefile instead"
2403b39c5158Smillert    $self->{USEMAKEFILE}        ||= '-f';
2404b39c5158Smillert
2405b39c5158Smillert    # Some makes require a wrapper around macros passed in on the command
2406b39c5158Smillert    # line.
2407b39c5158Smillert    $self->{MACROSTART}         ||= '';
2408b39c5158Smillert    $self->{MACROEND}           ||= '';
2409b39c5158Smillert
241048950c12Ssthen    return;
241148950c12Ssthen}
2412b39c5158Smillert
2413b39c5158Smillert
241448950c12Ssthen=head3 init_others
2415b39c5158Smillert
241648950c12Ssthen    $MM->init_others();
241748950c12Ssthen
241848950c12SsthenInitializes the macro definitions having to do with compiling and
241948950c12Ssthenlinking used by tools_other() and places them in the $MM object.
242048950c12Ssthen
242148950c12SsthenIf there is no description, its the same as the parameter to
242256d68f1eSafresh1WriteMakefile() documented in L<ExtUtils::MakeMaker>.
242348950c12Ssthen
242448950c12Ssthen=cut
242548950c12Ssthen
242648950c12Ssthensub init_others {
242748950c12Ssthen    my $self = shift;
2428b39c5158Smillert
2429b39c5158Smillert    $self->{LD_RUN_PATH} = "";
2430b39c5158Smillert
2431b39c5158Smillert    $self->{LIBS} = $self->_fix_libs($self->{LIBS});
2432b39c5158Smillert
2433b39c5158Smillert    # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
2434b39c5158Smillert    foreach my $libs ( @{$self->{LIBS}} ){
2435b39c5158Smillert        $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
2436b39c5158Smillert        my(@libs) = $self->extliblist($libs);
2437b39c5158Smillert        if ($libs[0] or $libs[1] or $libs[2]){
2438b39c5158Smillert            # LD_RUN_PATH now computed by ExtUtils::Liblist
2439b39c5158Smillert            ($self->{EXTRALIBS},  $self->{BSLOADLIBS},
2440b39c5158Smillert             $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
2441b39c5158Smillert            last;
2442b39c5158Smillert        }
2443b39c5158Smillert    }
2444b39c5158Smillert
2445b39c5158Smillert    if ( $self->{OBJECT} ) {
2446e5157e49Safresh1        $self->{OBJECT} = join(" ", @{$self->{OBJECT}}) if ref $self->{OBJECT};
2447e5157e49Safresh1        $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
24489f11ffb7Safresh1    } elsif ( ($self->{MAGICXS} || $self->{XSMULTI}) && @{$self->{O_FILES}||[]} ) {
2449e5157e49Safresh1        $self->{OBJECT} = join(" ", @{$self->{O_FILES}});
2450b39c5158Smillert        $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
2451b39c5158Smillert    } else {
2452b39c5158Smillert        # init_dirscan should have found out, if we have C files
2453b39c5158Smillert        $self->{OBJECT} = "";
2454b39c5158Smillert        $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
2455b39c5158Smillert    }
2456b39c5158Smillert    $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
2457b39c5158Smillert
2458b39c5158Smillert    $self->{BOOTDEP}  = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
2459b39c5158Smillert    $self->{PERLMAINCC} ||= '$(CC)';
2460b39c5158Smillert    $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
2461b39c5158Smillert
2462b39c5158Smillert    # Sanity check: don't define LINKTYPE = dynamic if we're skipping
2463b39c5158Smillert    # the 'dynamic' section of MM.  We don't have this problem with
2464b39c5158Smillert    # 'static', since we either must use it (%Config says we can't
2465b39c5158Smillert    # use dynamic loading) or the caller asked for it explicitly.
2466b39c5158Smillert    if (!$self->{LINKTYPE}) {
2467b39c5158Smillert       $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
2468b39c5158Smillert                        ? 'static'
2469b39c5158Smillert                        : ($Config{usedl} ? 'dynamic' : 'static');
2470b39c5158Smillert    }
2471b39c5158Smillert
247248950c12Ssthen    return;
2473b39c5158Smillert}
2474b39c5158Smillert
2475b39c5158Smillert
2476b39c5158Smillert# Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
2477b39c5158Smillert# undefined. In any case we turn it into an anon array
2478b39c5158Smillertsub _fix_libs {
2479b39c5158Smillert    my($self, $libs) = @_;
2480b39c5158Smillert
2481b39c5158Smillert    return !defined $libs       ? ['']          :
2482b39c5158Smillert           !ref $libs           ? [$libs]       :
2483b39c5158Smillert           !defined $libs->[0]  ? ['']          :
2484b39c5158Smillert                                  $libs         ;
2485b39c5158Smillert}
2486b39c5158Smillert
2487b39c5158Smillert
2488b39c5158Smillert=head3 tools_other
2489b39c5158Smillert
2490b39c5158Smillert    my $make_frag = $MM->tools_other;
2491b39c5158Smillert
2492b39c5158SmillertReturns a make fragment containing definitions for the macros init_others()
2493b39c5158Smillertinitializes.
2494b39c5158Smillert
2495b39c5158Smillert=cut
2496b39c5158Smillert
2497b39c5158Smillertsub tools_other {
2498b39c5158Smillert    my($self) = shift;
2499b39c5158Smillert    my @m;
2500b39c5158Smillert
2501b39c5158Smillert    # We set PM_FILTER as late as possible so it can see all the earlier
2502b39c5158Smillert    # on macro-order sensitive makes such as nmake.
2503b39c5158Smillert    for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
2504b39c5158Smillert                      UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
2505b39c5158Smillert                      FALSE TRUE
2506b39c5158Smillert                      ECHO ECHO_N
2507b39c5158Smillert                      UNINST VERBINST
2508b39c5158Smillert                      MOD_INSTALL DOC_INSTALL UNINSTALL
2509b39c5158Smillert                      WARN_IF_OLD_PACKLIST
2510b39c5158Smillert                      MACROSTART MACROEND
2511b39c5158Smillert                      USEMAKEFILE
2512b39c5158Smillert                      PM_FILTER
2513b39c5158Smillert                      FIXIN
2514e5157e49Safresh1                      CP_NONEMPTY
2515b39c5158Smillert                    } )
2516b39c5158Smillert    {
2517b39c5158Smillert        next unless defined $self->{$tool};
2518b39c5158Smillert        push @m, "$tool = $self->{$tool}\n";
2519b39c5158Smillert    }
2520b39c5158Smillert
2521b39c5158Smillert    return join "", @m;
2522b39c5158Smillert}
2523b39c5158Smillert
2524b39c5158Smillert
2525b39c5158Smillert=head3 init_DIRFILESEP  I<Abstract>
2526b39c5158Smillert
2527b39c5158Smillert  $MM->init_DIRFILESEP;
2528b39c5158Smillert  my $dirfilesep = $MM->{DIRFILESEP};
2529b39c5158Smillert
2530e5157e49Safresh1Initializes the DIRFILESEP macro which is the separator between the
2531b39c5158Smillertdirectory and filename in a filepath.  ie. / on Unix, \ on Win32 and
2532b39c5158Smillertnothing on VMS.
2533b39c5158Smillert
2534b39c5158SmillertFor example:
2535b39c5158Smillert
2536b39c5158Smillert    # instead of $(INST_ARCHAUTODIR)/extralibs.ld
2537b39c5158Smillert    $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
2538b39c5158Smillert
2539b39c5158SmillertSomething of a hack but it prevents a lot of code duplication between
2540b39c5158SmillertMM_* variants.
2541b39c5158Smillert
2542e5157e49Safresh1Do not use this as a separator between directories.  Some operating
2543e5157e49Safresh1systems use different separators between subdirectories as between
2544b39c5158Smillertdirectories and filenames (for example:  VOLUME:[dir1.dir2]file on VMS).
2545b39c5158Smillert
2546b39c5158Smillert=head3 init_linker  I<Abstract>
2547b39c5158Smillert
2548b39c5158Smillert    $mm->init_linker;
2549b39c5158Smillert
2550b39c5158SmillertInitialize macros which have to do with linking.
2551b39c5158Smillert
2552b39c5158SmillertPERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
2553b39c5158Smillertextensions.
2554b39c5158Smillert
2555b39c5158SmillertPERL_ARCHIVE_AFTER: path to a library which should be put on the
2556b39c5158Smillertlinker command line I<after> the external libraries to be linked to
2557b39c5158Smillertdynamic extensions.  This may be needed if the linker is one-pass, and
2558b39c5158SmillertPerl includes some overrides for C RTL functions, such as malloc().
2559b39c5158Smillert
2560b39c5158SmillertEXPORT_LIST: name of a file that is passed to linker to define symbols
2561b39c5158Smillertto be exported.
2562b39c5158Smillert
2563b39c5158SmillertSome OSes do not need these in which case leave it blank.
2564b39c5158Smillert
2565b39c5158Smillert
2566b39c5158Smillert=head3 init_platform
2567b39c5158Smillert
2568b39c5158Smillert    $mm->init_platform
2569b39c5158Smillert
2570b39c5158SmillertInitialize any macros which are for platform specific use only.
2571b39c5158Smillert
2572e5157e49Safresh1A typical one is the version number of your OS specific module.
2573b39c5158Smillert(ie. MM_Unix_VERSION or MM_VMS_VERSION).
2574b39c5158Smillert
2575b39c5158Smillert=cut
2576b39c5158Smillert
2577b39c5158Smillertsub init_platform {
2578b39c5158Smillert    return '';
2579b39c5158Smillert}
2580b39c5158Smillert
2581b39c5158Smillert
2582b39c5158Smillert=head3 init_MAKE
2583b39c5158Smillert
2584b39c5158Smillert    $mm->init_MAKE
2585b39c5158Smillert
2586b39c5158SmillertInitialize MAKE from either a MAKE environment variable or $Config{make}.
2587b39c5158Smillert
2588b39c5158Smillert=cut
2589b39c5158Smillert
2590b39c5158Smillertsub init_MAKE {
2591b39c5158Smillert    my $self = shift;
2592b39c5158Smillert
2593b39c5158Smillert    $self->{MAKE} ||= $ENV{MAKE} || $Config{make};
2594b39c5158Smillert}
2595b39c5158Smillert
2596b39c5158Smillert
2597b39c5158Smillert=head2 Tools
2598b39c5158Smillert
2599b39c5158SmillertA grab bag of methods to generate specific macros and commands.
2600b39c5158Smillert
2601b39c5158Smillert
2602b39c5158Smillert
2603b39c5158Smillert=head3 manifypods
2604b39c5158Smillert
2605b39c5158SmillertDefines targets and routines to translate the pods into manpages and
2606b39c5158Smillertput them into the INST_* directories.
2607b39c5158Smillert
2608b39c5158Smillert=cut
2609b39c5158Smillert
2610b39c5158Smillertsub manifypods {
2611b39c5158Smillert    my $self          = shift;
2612b39c5158Smillert
2613b39c5158Smillert    my $POD2MAN_macro = $self->POD2MAN_macro();
2614b39c5158Smillert    my $manifypods_target = $self->manifypods_target();
2615b39c5158Smillert
2616b39c5158Smillert    return <<END_OF_TARGET;
2617b39c5158Smillert
2618b39c5158Smillert$POD2MAN_macro
2619b39c5158Smillert
2620b39c5158Smillert$manifypods_target
2621b39c5158Smillert
2622b39c5158SmillertEND_OF_TARGET
2623b39c5158Smillert
2624b39c5158Smillert}
2625b39c5158Smillert
2626b39c5158Smillert
2627b39c5158Smillert=head3 POD2MAN_macro
2628b39c5158Smillert
2629b39c5158Smillert  my $pod2man_macro = $self->POD2MAN_macro
2630b39c5158Smillert
2631b39c5158SmillertReturns a definition for the POD2MAN macro.  This is a program
2632b39c5158Smillertwhich emulates the pod2man utility.  You can add more switches to the
2633b39c5158Smillertcommand by simply appending them on the macro.
2634b39c5158Smillert
2635b39c5158SmillertTypical usage:
2636b39c5158Smillert
2637b39c5158Smillert    $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
2638b39c5158Smillert
2639b39c5158Smillert=cut
2640b39c5158Smillert
2641b39c5158Smillertsub POD2MAN_macro {
2642b39c5158Smillert    my $self = shift;
2643b39c5158Smillert
2644b39c5158Smillert# Need the trailing '--' so perl stops gobbling arguments and - happens
2645e5157e49Safresh1# to be an alternative end of line separator on VMS so we quote it
2646b39c5158Smillert    return <<'END_OF_DEF';
2647b39c5158SmillertPOD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
2648b39c5158SmillertPOD2MAN = $(POD2MAN_EXE)
2649b39c5158SmillertEND_OF_DEF
2650b39c5158Smillert}
2651b39c5158Smillert
2652b39c5158Smillert
2653b39c5158Smillert=head3 test_via_harness
2654b39c5158Smillert
2655b39c5158Smillert  my $command = $mm->test_via_harness($perl, $tests);
2656b39c5158Smillert
2657b39c5158SmillertReturns a $command line which runs the given set of $tests with
2658b39c5158SmillertTest::Harness and the given $perl.
2659b39c5158Smillert
2660b39c5158SmillertUsed on the t/*.t files.
2661b39c5158Smillert
2662b39c5158Smillert=cut
2663b39c5158Smillert
2664b39c5158Smillertsub test_via_harness {
2665b39c5158Smillert    my($self, $perl, $tests) = @_;
2666b39c5158Smillert
2667e5157e49Safresh1    return qq{\t$perl "-MExtUtils::Command::MM" "-MTest::Harness" }.
2668e5157e49Safresh1           qq{"-e" "undef *Test::Harness::Switches; test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
2669b39c5158Smillert}
2670b39c5158Smillert
2671b39c5158Smillert=head3 test_via_script
2672b39c5158Smillert
2673b39c5158Smillert  my $command = $mm->test_via_script($perl, $script);
2674b39c5158Smillert
2675b39c5158SmillertReturns a $command line which just runs a single test without
2676b39c5158SmillertTest::Harness.  No checks are done on the results, they're just
2677b39c5158Smillertprinted.
2678b39c5158Smillert
2679b39c5158SmillertUsed for test.pl, since they don't always follow Test::Harness
2680b39c5158Smillertformatting.
2681b39c5158Smillert
2682b39c5158Smillert=cut
2683b39c5158Smillert
2684b39c5158Smillertsub test_via_script {
2685b39c5158Smillert    my($self, $perl, $script) = @_;
2686b39c5158Smillert    return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
2687b39c5158Smillert}
2688b39c5158Smillert
2689b39c5158Smillert
2690b39c5158Smillert=head3 tool_autosplit
2691b39c5158Smillert
2692b39c5158SmillertDefines a simple perl call that runs autosplit. May be deprecated by
2693b39c5158Smillertpm_to_blib soon.
2694b39c5158Smillert
2695b39c5158Smillert=cut
2696b39c5158Smillert
2697b39c5158Smillertsub tool_autosplit {
2698b39c5158Smillert    my($self, %attribs) = @_;
2699b39c5158Smillert
2700b39c5158Smillert    my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};'
2701b39c5158Smillert                                  : '';
2702b39c5158Smillert
2703b39c5158Smillert    my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
2704b39c5158Smillertuse AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
2705b39c5158SmillertPERL_CODE
2706b39c5158Smillert
2707b39c5158Smillert    return sprintf <<'MAKE_FRAG', $asplit;
2708b39c5158Smillert# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
2709b39c5158SmillertAUTOSPLITFILE = %s
2710b39c5158Smillert
2711b39c5158SmillertMAKE_FRAG
2712b39c5158Smillert
2713b39c5158Smillert}
2714b39c5158Smillert
2715b39c5158Smillert
2716b39c5158Smillert=head3 arch_check
2717b39c5158Smillert
2718b39c5158Smillert    my $arch_ok = $mm->arch_check(
2719b39c5158Smillert        $INC{"Config.pm"},
2720b39c5158Smillert        File::Spec->catfile($Config{archlibexp}, "Config.pm")
2721b39c5158Smillert    );
2722b39c5158Smillert
2723b39c5158SmillertA sanity check that what Perl thinks the architecture is and what
2724b39c5158SmillertConfig thinks the architecture is are the same.  If they're not it
2725b39c5158Smillertwill return false and show a diagnostic message.
2726b39c5158Smillert
2727b39c5158SmillertWhen building Perl it will always return true, as nothing is installed
2728b39c5158Smillertyet.
2729b39c5158Smillert
2730b39c5158SmillertThe interface is a bit odd because this is the result of a
2731b39c5158Smillertquick refactoring.  Don't rely on it.
2732b39c5158Smillert
2733b39c5158Smillert=cut
2734b39c5158Smillert
2735b39c5158Smillertsub arch_check {
2736b39c5158Smillert    my $self = shift;
2737b39c5158Smillert    my($pconfig, $cconfig) = @_;
2738b39c5158Smillert
2739b39c5158Smillert    return 1 if $self->{PERL_SRC};
2740b39c5158Smillert
2741b39c5158Smillert    my($pvol, $pthinks) = $self->splitpath($pconfig);
2742b39c5158Smillert    my($cvol, $cthinks) = $self->splitpath($cconfig);
2743b39c5158Smillert
2744b39c5158Smillert    $pthinks = $self->canonpath($pthinks);
2745b39c5158Smillert    $cthinks = $self->canonpath($cthinks);
2746b39c5158Smillert
2747b39c5158Smillert    my $ret = 1;
2748b39c5158Smillert    if ($pthinks ne $cthinks) {
2749b39c5158Smillert        print "Have $pthinks\n";
2750b39c5158Smillert        print "Want $cthinks\n";
2751b39c5158Smillert
2752b39c5158Smillert        $ret = 0;
2753b39c5158Smillert
2754b39c5158Smillert        my $arch = (grep length, $self->splitdir($pthinks))[-1];
2755b39c5158Smillert
2756e9ce3842Safresh1        print <<END unless $self->{UNINSTALLED_PERL};
2757b39c5158SmillertYour perl and your Config.pm seem to have different ideas about the
2758b39c5158Smillertarchitecture they are running on.
2759b39c5158SmillertPerl thinks: [$arch]
2760b39c5158SmillertConfig says: [$Config{archname}]
2761b39c5158SmillertThis may or may not cause problems. Please check your installation of perl
2762b39c5158Smillertif you have problems building this extension.
2763b39c5158SmillertEND
2764b39c5158Smillert    }
2765b39c5158Smillert
2766b39c5158Smillert    return $ret;
2767b39c5158Smillert}
2768b39c5158Smillert
2769b39c5158Smillert
2770b39c5158Smillert
2771b39c5158Smillert=head2 File::Spec wrappers
2772b39c5158Smillert
277356d68f1eSafresh1ExtUtils::MM_Any is a subclass of L<File::Spec>.  The methods noted here
2774b39c5158Smillertoverride File::Spec.
2775b39c5158Smillert
2776b39c5158Smillert
2777b39c5158Smillert
2778b39c5158Smillert=head3 catfile
2779b39c5158Smillert
2780b39c5158SmillertFile::Spec <= 0.83 has a bug where the file part of catfile is not
2781b39c5158Smillertcanonicalized.  This override fixes that bug.
2782b39c5158Smillert
2783b39c5158Smillert=cut
2784b39c5158Smillert
2785b39c5158Smillertsub catfile {
2786b39c5158Smillert    my $self = shift;
2787b39c5158Smillert    return $self->canonpath($self->SUPER::catfile(@_));
2788b39c5158Smillert}
2789b39c5158Smillert
2790b39c5158Smillert
2791b39c5158Smillert
2792b39c5158Smillert=head2 Misc
2793b39c5158Smillert
2794b39c5158SmillertMethods I can't really figure out where they should go yet.
2795b39c5158Smillert
2796b39c5158Smillert
2797b39c5158Smillert=head3 find_tests
2798b39c5158Smillert
2799b39c5158Smillert  my $test = $mm->find_tests;
2800b39c5158Smillert
2801b39c5158SmillertReturns a string suitable for feeding to the shell to return all
2802b39c5158Smillerttests in t/*.t.
2803b39c5158Smillert
2804b39c5158Smillert=cut
2805b39c5158Smillert
2806b39c5158Smillertsub find_tests {
2807b39c5158Smillert    my($self) = shift;
2808b39c5158Smillert    return -d 't' ? 't/*.t' : '';
2809b39c5158Smillert}
2810b39c5158Smillert
2811e5157e49Safresh1=head3 find_tests_recursive
2812e5157e49Safresh1
2813e5157e49Safresh1  my $tests = $mm->find_tests_recursive;
2814e5157e49Safresh1
2815e5157e49Safresh1Returns a string suitable for feeding to the shell to return all
28169f11ffb7Safresh1tests in t/ but recursively. Equivalent to
28179f11ffb7Safresh1
28189f11ffb7Safresh1  my $tests = $mm->find_tests_recursive_in('t');
2819e5157e49Safresh1
2820e5157e49Safresh1=cut
2821e5157e49Safresh1
2822e5157e49Safresh1sub find_tests_recursive {
28239f11ffb7Safresh1    my $self = shift;
28249f11ffb7Safresh1    return $self->find_tests_recursive_in('t');
28259f11ffb7Safresh1}
28269f11ffb7Safresh1
28279f11ffb7Safresh1=head3 find_tests_recursive_in
28289f11ffb7Safresh1
28299f11ffb7Safresh1  my $tests = $mm->find_tests_recursive_in($dir);
28309f11ffb7Safresh1
28319f11ffb7Safresh1Returns a string suitable for feeding to the shell to return all
28329f11ffb7Safresh1tests in $dir recursively.
28339f11ffb7Safresh1
28349f11ffb7Safresh1=cut
28359f11ffb7Safresh1
28369f11ffb7Safresh1sub find_tests_recursive_in {
28379f11ffb7Safresh1    my($self, $dir) = @_;
28389f11ffb7Safresh1    return '' unless -d $dir;
2839e5157e49Safresh1
2840e5157e49Safresh1    require File::Find;
2841e5157e49Safresh1
28429f11ffb7Safresh1    my $base_depth = grep { $_ ne '' } File::Spec->splitdir( (File::Spec->splitpath($dir))[1] );
28439f11ffb7Safresh1    my %depths;
2844e5157e49Safresh1
2845e5157e49Safresh1    my $wanted = sub {
2846e5157e49Safresh1        return unless m!\.t$!;
2847e5157e49Safresh1        my ($volume,$directories,$file) =
2848e5157e49Safresh1            File::Spec->splitpath( $File::Find::name  );
28499f11ffb7Safresh1        my $depth = grep { $_ ne '' } File::Spec->splitdir( $directories );
28509f11ffb7Safresh1        $depth -= $base_depth;
28519f11ffb7Safresh1        $depths{ $depth } = 1;
2852e5157e49Safresh1    };
2853e5157e49Safresh1
28549f11ffb7Safresh1    File::Find::find( $wanted, $dir );
2855e5157e49Safresh1
28569f11ffb7Safresh1    return join ' ',
28579f11ffb7Safresh1        map { $dir . '/*' x $_ . '.t' }
28589f11ffb7Safresh1        sort { $a <=> $b }
28599f11ffb7Safresh1        keys %depths;
2860e5157e49Safresh1}
2861b39c5158Smillert
2862b39c5158Smillert=head3 extra_clean_files
2863b39c5158Smillert
2864b39c5158Smillert    my @files_to_clean = $MM->extra_clean_files;
2865b39c5158Smillert
2866b39c5158SmillertReturns a list of OS specific files to be removed in the clean target in
2867b39c5158Smillertaddition to the usual set.
2868b39c5158Smillert
2869b39c5158Smillert=cut
2870b39c5158Smillert
2871b39c5158Smillert# An empty method here tickled a perl 5.8.1 bug and would return its object.
2872b39c5158Smillertsub extra_clean_files {
2873b39c5158Smillert    return;
2874b39c5158Smillert}
2875b39c5158Smillert
2876b39c5158Smillert
2877b39c5158Smillert=head3 installvars
2878b39c5158Smillert
2879b39c5158Smillert    my @installvars = $mm->installvars;
2880b39c5158Smillert
2881b39c5158SmillertA list of all the INSTALL* variables without the INSTALL prefix.  Useful
2882b39c5158Smillertfor iteration or building related variable sets.
2883b39c5158Smillert
2884b39c5158Smillert=cut
2885b39c5158Smillert
2886b39c5158Smillertsub installvars {
2887b39c5158Smillert    return qw(PRIVLIB SITELIB  VENDORLIB
2888b39c5158Smillert              ARCHLIB SITEARCH VENDORARCH
2889b39c5158Smillert              BIN     SITEBIN  VENDORBIN
2890b39c5158Smillert              SCRIPT  SITESCRIPT  VENDORSCRIPT
2891b39c5158Smillert              MAN1DIR SITEMAN1DIR VENDORMAN1DIR
2892b39c5158Smillert              MAN3DIR SITEMAN3DIR VENDORMAN3DIR
2893b39c5158Smillert             );
2894b39c5158Smillert}
2895b39c5158Smillert
2896b39c5158Smillert
2897b39c5158Smillert=head3 libscan
2898b39c5158Smillert
2899b39c5158Smillert  my $wanted = $self->libscan($path);
2900b39c5158Smillert
2901b39c5158SmillertTakes a path to a file or dir and returns an empty string if we don't
2902b39c5158Smillertwant to include this file in the library.  Otherwise it returns the
2903b39c5158Smillertthe $path unchanged.
2904b39c5158Smillert
29059f11ffb7Safresh1Mainly used to exclude version control administrative directories
29069f11ffb7Safresh1and base-level F<README.pod> from installation.
2907b39c5158Smillert
2908b39c5158Smillert=cut
2909b39c5158Smillert
2910b39c5158Smillertsub libscan {
2911b39c5158Smillert    my($self,$path) = @_;
29129f11ffb7Safresh1
29139f11ffb7Safresh1    if ($path =~ m<^README\.pod$>i) {
291456d68f1eSafresh1        warn "WARNING: Older versions of ExtUtils::MakeMaker may errantly install $path as part of this distribution. It is recommended to avoid using this path in CPAN modules.\n";
29159f11ffb7Safresh1        return '';
29169f11ffb7Safresh1    }
29179f11ffb7Safresh1
2918b39c5158Smillert    my($dirs,$file) = ($self->splitpath($path))[1,2];
2919b39c5158Smillert    return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/,
2920b39c5158Smillert                     $self->splitdir($dirs), $file;
2921b39c5158Smillert
2922b39c5158Smillert    return $path;
2923b39c5158Smillert}
2924b39c5158Smillert
2925b39c5158Smillert
2926b39c5158Smillert=head3 platform_constants
2927b39c5158Smillert
2928b39c5158Smillert    my $make_frag = $mm->platform_constants
2929b39c5158Smillert
2930b39c5158SmillertReturns a make fragment defining all the macros initialized in
2931b39c5158Smillertinit_platform() rather than put them in constants().
2932b39c5158Smillert
2933b39c5158Smillert=cut
2934b39c5158Smillert
2935b39c5158Smillertsub platform_constants {
2936b39c5158Smillert    return '';
2937b39c5158Smillert}
2938b39c5158Smillert
29399f11ffb7Safresh1=head3 post_constants (o)
29409f11ffb7Safresh1
29419f11ffb7Safresh1Returns an empty string per default. Dedicated to overrides from
29429f11ffb7Safresh1within Makefile.PL after all constants have been defined.
29439f11ffb7Safresh1
29449f11ffb7Safresh1=cut
29459f11ffb7Safresh1
29469f11ffb7Safresh1sub post_constants {
29479f11ffb7Safresh1    "";
29489f11ffb7Safresh1}
29499f11ffb7Safresh1
29509f11ffb7Safresh1=head3 post_initialize (o)
29519f11ffb7Safresh1
29529f11ffb7Safresh1Returns an empty string per default. Used in Makefile.PLs to add some
29539f11ffb7Safresh1chunk of text to the Makefile after the object is initialized.
29549f11ffb7Safresh1
29559f11ffb7Safresh1=cut
29569f11ffb7Safresh1
29579f11ffb7Safresh1sub post_initialize {
29589f11ffb7Safresh1    "";
29599f11ffb7Safresh1}
29609f11ffb7Safresh1
29619f11ffb7Safresh1=head3 postamble (o)
29629f11ffb7Safresh1
29639f11ffb7Safresh1Returns an empty string. Can be used in Makefile.PLs to write some
29649f11ffb7Safresh1text to the Makefile at the end.
29659f11ffb7Safresh1
29669f11ffb7Safresh1=cut
29679f11ffb7Safresh1
29689f11ffb7Safresh1sub postamble {
29699f11ffb7Safresh1    "";
29709f11ffb7Safresh1}
29719f11ffb7Safresh1
2972b39c5158Smillert=begin private
2973b39c5158Smillert
2974b39c5158Smillert=head3 _PREREQ_PRINT
2975b39c5158Smillert
2976b39c5158Smillert    $self->_PREREQ_PRINT;
2977b39c5158Smillert
2978b39c5158SmillertImplements PREREQ_PRINT.
2979b39c5158Smillert
2980b39c5158SmillertRefactored out of MakeMaker->new().
2981b39c5158Smillert
2982b39c5158Smillert=end private
2983b39c5158Smillert
2984b39c5158Smillert=cut
2985b39c5158Smillert
2986b39c5158Smillertsub _PREREQ_PRINT {
2987b39c5158Smillert    my $self = shift;
2988b39c5158Smillert
2989b39c5158Smillert    require Data::Dumper;
2990b39c5158Smillert    my @what = ('PREREQ_PM');
2991b39c5158Smillert    push @what, 'MIN_PERL_VERSION' if $self->{MIN_PERL_VERSION};
2992b39c5158Smillert    push @what, 'BUILD_REQUIRES'   if $self->{BUILD_REQUIRES};
2993b39c5158Smillert    print Data::Dumper->Dump([@{$self}{@what}], \@what);
2994b39c5158Smillert    exit 0;
2995b39c5158Smillert}
2996b39c5158Smillert
2997b39c5158Smillert
2998b39c5158Smillert=begin private
2999b39c5158Smillert
3000b39c5158Smillert=head3 _PRINT_PREREQ
3001b39c5158Smillert
3002b39c5158Smillert  $mm->_PRINT_PREREQ;
3003b39c5158Smillert
3004b39c5158SmillertImplements PRINT_PREREQ, a slightly different version of PREREQ_PRINT
3005b39c5158Smillertadded by Redhat to, I think, support generating RPMs from Perl modules.
3006b39c5158Smillert
30079f11ffb7Safresh1Should not include BUILD_REQUIRES as RPMs do not include them.
3008b39c5158Smillert
3009b39c5158SmillertRefactored out of MakeMaker->new().
3010b39c5158Smillert
3011b39c5158Smillert=end private
3012b39c5158Smillert
3013b39c5158Smillert=cut
3014b39c5158Smillert
3015b39c5158Smillertsub _PRINT_PREREQ {
3016b39c5158Smillert    my $self = shift;
3017b39c5158Smillert
3018b39c5158Smillert    my $prereqs= $self->{PREREQ_PM};
3019b39c5158Smillert    my @prereq = map { [$_, $prereqs->{$_}] } keys %$prereqs;
3020b39c5158Smillert
3021b39c5158Smillert    if ( $self->{MIN_PERL_VERSION} ) {
3022b39c5158Smillert        push @prereq, ['perl' => $self->{MIN_PERL_VERSION}];
3023b39c5158Smillert    }
3024b39c5158Smillert
3025b39c5158Smillert    print join(" ", map { "perl($_->[0])>=$_->[1] " }
3026b39c5158Smillert                 sort { $a->[0] cmp $b->[0] } @prereq), "\n";
3027b39c5158Smillert    exit 0;
3028b39c5158Smillert}
3029b39c5158Smillert
3030b39c5158Smillert
3031b39c5158Smillert=begin private
3032b39c5158Smillert
3033e9ce3842Safresh1=head3 _perl_header_files
3034e9ce3842Safresh1
3035e9ce3842Safresh1  my $perl_header_files= $self->_perl_header_files;
3036e9ce3842Safresh1
3037e9ce3842Safresh1returns a sorted list of header files as found in PERL_SRC or $archlibexp/CORE.
3038e9ce3842Safresh1
3039e9ce3842Safresh1Used by perldepend() in MM_Unix and MM_VMS via _perl_header_files_fragment()
3040e9ce3842Safresh1
3041e9ce3842Safresh1=end private
3042e9ce3842Safresh1
3043e9ce3842Safresh1=cut
3044e9ce3842Safresh1
3045e9ce3842Safresh1sub _perl_header_files {
3046e9ce3842Safresh1    my $self = shift;
3047e9ce3842Safresh1
3048b8851fccSafresh1    my $header_dir = $self->{PERL_SRC} || $ENV{PERL_SRC} || $self->catdir($Config{archlibexp}, 'CORE');
3049e9ce3842Safresh1    opendir my $dh, $header_dir
3050e9ce3842Safresh1        or die "Failed to opendir '$header_dir' to find header files: $!";
3051e9ce3842Safresh1
3052e9ce3842Safresh1    # we need to use a temporary here as the sort in scalar context would have undefined results.
3053e9ce3842Safresh1    my @perl_headers= sort grep { /\.h\z/ } readdir($dh);
3054e9ce3842Safresh1
3055e9ce3842Safresh1    closedir $dh;
3056e9ce3842Safresh1
3057e9ce3842Safresh1    return @perl_headers;
3058e9ce3842Safresh1}
3059e9ce3842Safresh1
3060e9ce3842Safresh1=begin private
3061e9ce3842Safresh1
3062e9ce3842Safresh1=head3 _perl_header_files_fragment ($o, $separator)
3063e9ce3842Safresh1
3064e9ce3842Safresh1  my $perl_header_files_fragment= $self->_perl_header_files_fragment("/");
3065e9ce3842Safresh1
3066e9ce3842Safresh1return a Makefile fragment which holds the list of perl header files which
3067e9ce3842Safresh1XS code depends on $(PERL_INC), and sets up the dependency for the $(OBJECT) file.
3068e9ce3842Safresh1
3069e9ce3842Safresh1The $separator argument defaults to "". MM_VMS will set it to "" and MM_UNIX to "/"
3070e9ce3842Safresh1in perldepend(). This reason child subclasses need to control this is that in
3071e9ce3842Safresh1VMS the $(PERL_INC) directory will already have delimiters in it, but in
3072e9ce3842Safresh1UNIX $(PERL_INC) will need a slash between it an the filename. Hypothetically
3073e9ce3842Safresh1win32 could use "\\" (but it doesn't need to).
3074e9ce3842Safresh1
3075e9ce3842Safresh1=end private
3076e9ce3842Safresh1
3077e9ce3842Safresh1=cut
3078e9ce3842Safresh1
3079e9ce3842Safresh1sub _perl_header_files_fragment {
3080e9ce3842Safresh1    my ($self, $separator)= @_;
3081e9ce3842Safresh1    $separator ||= "";
3082e9ce3842Safresh1    return join("\\\n",
3083e9ce3842Safresh1                "PERL_HDRS = ",
3084e9ce3842Safresh1                map {
3085b8851fccSafresh1                    sprintf( "        \$(PERL_INCDEP)%s%s            ", $separator, $_ )
3086e9ce3842Safresh1                } $self->_perl_header_files()
3087e9ce3842Safresh1           ) . "\n\n"
3088e9ce3842Safresh1           . "\$(OBJECT) : \$(PERL_HDRS)\n";
3089e9ce3842Safresh1}
3090e9ce3842Safresh1
3091b39c5158Smillert
3092b39c5158Smillert=head1 AUTHOR
3093b39c5158Smillert
3094b39c5158SmillertMichael G Schwern <schwern@pobox.com> and the denizens of
3095b39c5158Smillertmakemaker@perl.org with code from ExtUtils::MM_Unix and
3096b39c5158SmillertExtUtils::MM_Win32.
3097b39c5158Smillert
3098b39c5158Smillert
3099b39c5158Smillert=cut
3100b39c5158Smillert
3101b39c5158Smillert1;
3102