File Coverage

lib/ExtUtils/MM_Unix.pm
Criterion Covered Total %
statement 922 1443 63.8
branch 323 764 42.2
condition 174 433 40.1
subroutine 105 125 84.0
pod 95 97 97.9
total 1619 2862 56.5


line stmt bran cond sub pod time code
1              
2             require 5.006;
3              
4             use strict;
5 52     52   15137 use warnings;
  52         93  
  52         1350  
6 52     52   214  
  52         80  
  52         1203  
7             use Carp;
8 52     52   213 use ExtUtils::MakeMaker::Config;
  52         88  
  52         2417  
9 52     52   588 use File::Basename qw(basename dirname);
  52         83  
  52         316  
10 52     52   252  
  52         390  
  52         4044  
11             our %Config_Override;
12              
13             use ExtUtils::MakeMaker qw($Verbose neatvalue _sprintf562);
14 52     52   924  
  52         93  
  52         6639  
15             # If we make $VERSION an our variable parse_version() breaks
16             use vars qw($VERSION);
17 52     52   324 $VERSION = '7.64';
  52         92  
  52         14915  
18             $VERSION =~ tr/_//d;
19              
20             require ExtUtils::MM_Any;
21             our @ISA = qw(ExtUtils::MM_Any);
22              
23             my %Is;
24             BEGIN {
25             $Is{OS2} = $^O eq 'os2';
26 52     52   318 $Is{Win32} = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
27 52   33     420 $Is{Dos} = $^O eq 'dos';
28 52         161 $Is{VMS} = $^O eq 'VMS';
29 52         105 $Is{OSF} = $^O eq 'dec_osf';
30 52         140 $Is{IRIX} = $^O eq 'irix';
31 52         110 $Is{NetBSD} = $^O eq 'netbsd';
32 52         135 $Is{Interix} = $^O eq 'interix';
33 52         152 $Is{SunOS4} = $^O eq 'sunos';
34 52         105 $Is{Solaris} = $^O eq 'solaris';
35 52         119 $Is{SunOS} = $Is{SunOS4} || $Is{Solaris};
36 52   33     267 $Is{BSD} = ($^O =~ /^(?:free|net|open)bsd$/ or
37 52   33     361 grep( $^O eq $_, qw(bsdos interix dragonfly) )
38             );
39             $Is{Android} = $^O =~ /android/;
40 52         142 if ( $^O eq 'darwin' && $^X eq '/usr/bin/perl' ) {
41 52 50 33     2437 my @osvers = split /\./, $Config{osvers};
42 0         0 $Is{ApplCor} = ( $osvers[0] >= 18 );
43 0         0 }
44             }
45              
46             BEGIN {
47             if( $Is{VMS} ) {
48 52 50   52   258709 # For things like vmsify()
49             require VMS::Filespec;
50 0         0 VMS::Filespec->import;
51 0         0 }
52             }
53              
54              
55             =head1 NAME
56              
57             ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
58              
59             =head1 SYNOPSIS
60              
61             require ExtUtils::MM_Unix;
62              
63             =head1 DESCRIPTION
64              
65             The methods provided by this package are designed to be used in
66             conjunction with L<ExtUtils::MakeMaker>. When MakeMaker writes a
67             Makefile, it creates one or more objects that inherit their methods
68             from a package L<MM|ExtUtils::MM>. MM itself doesn't provide any methods, but
69             it ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
70             specific packages take the responsibility for all the methods provided
71             by MM_Unix. We are trying to reduce the number of the necessary
72             overrides by defining rather primitive operations within
73             ExtUtils::MM_Unix.
74              
75             If you are going to write a platform specific MM package, please try
76             to limit the necessary overrides to primitive methods, and if it is not
77             possible to do so, let's work out how to achieve that gain.
78              
79             If you are overriding any of these methods in your Makefile.PL (in the
80             MY class), please report that to the makemaker mailing list. We are
81             trying to minimize the necessary method overrides and switch to data
82             driven Makefile.PLs wherever possible. In the long run less methods
83             will be overridable via the MY class.
84              
85             =head1 METHODS
86              
87             The following description of methods is still under
88             development. Please refer to the code for not suitably documented
89             sections and complain loudly to the makemaker@perl.org mailing list.
90             Better yet, provide a patch.
91              
92             Not all of the methods below are overridable in a
93             Makefile.PL. Overridable methods are marked as (o). All methods are
94             overridable by a platform specific MM_*.pm file.
95              
96             Cross-platform methods are being moved into L<MM_Any|ExtUtils::MM_Any>.
97             If you can't find something that used to be in here, look in MM_Any.
98              
99             =cut
100              
101             # So we don't have to keep calling the methods over and over again,
102             # we have these globals to cache the values. Faster and shrtr.
103             my $Curdir = __PACKAGE__->curdir;
104             my $Updir = __PACKAGE__->updir;
105              
106              
107             =head2 Methods
108              
109             =over 4
110              
111             =item os_flavor
112              
113             Simply says that we're Unix.
114              
115             =cut
116              
117             return('Unix');
118             }
119 223     223 1 2468  
120              
121             =item c_o (o)
122              
123             Defines the suffix rules to compile different flavors of C files to
124             object files.
125              
126             =cut
127              
128             # --- Translation Sections ---
129              
130             my($self) = shift;
131             return '' unless $self->needs_linking();
132             my(@m);
133 153     153 1 386  
134 153 50       456 my $command = '$(CCCMD)';
135 0         0 my $flags = '$(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE)';
136              
137 0         0 if ( $Is{ApplCor} ) {
138 0         0 $flags =~ s/"-I(\$\(PERL_INC\))"/-iwithsysroot "$1"/;
139             }
140 0 0       0  
141 0         0 if (my $cpp = $self->{CPPRUN}) {
142             my $cpp_cmd = $self->const_cccmd;
143             $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/\$(CPPRUN)/;
144 0 0       0 push @m, qq{
145 0         0 .c.i:
146 0         0 $cpp_cmd $flags \$*.c > \$*.i
147 0         0 };
148             }
149              
150             my $m_o = $self->{XSMULTI} ? $self->xs_obj_opt('$*.s') : '';
151             push @m, sprintf <<'EOF', $command, $flags, $m_o;
152              
153 0 0       0 .c.s :
154 0         0 %s -S %s $*.c %s
155             EOF
156              
157             my @exts = qw(c cpp cxx cc);
158             push @exts, 'C' if !$Is{OS2} and !$Is{Win32} and !$Is{Dos}; #Case-specific
159             $m_o = $self->{XSMULTI} ? $self->xs_obj_opt('$*$(OBJ_EXT)') : '';
160 0         0 my $dbgout = $self->dbgoutflag;
161 0 0 0     0 for my $ext (@exts) {
      0        
162 0 0       0 push @m, "\n.$ext\$(OBJ_EXT) :\n\t$command $flags "
163 0         0 .($dbgout?"$dbgout ":'')
164 0         0 ."\$*.$ext" . ( $m_o ? " $m_o" : '' ) . "\n";
165 0 0       0 }
    0          
166             return join "", @m;
167             }
168              
169 0         0  
170             =item xs_obj_opt
171              
172             Takes the object file as an argument, and returns the portion of compile
173             command-line that will output to the specified object file.
174              
175             =cut
176              
177             my ($self, $output_file) = @_;
178             "-o $output_file";
179             }
180              
181 0     0 1 0 =item dbgoutflag
182 0         0  
183             Returns a CC flag that tells the CC to emit a separate debugging symbol file
184             when compiling an object file.
185              
186             =cut
187              
188             '';
189             }
190              
191             =item cflags (o)
192              
193 0     0 1 0 Does very much the same as the cflags script in the perl
194             distribution. It doesn't return the whole compiler command line, but
195             initializes all of its parts. The const_cccmd method then actually
196             returns the definition of the CCCMD macro which uses these parts.
197              
198             =cut
199              
200             #'
201              
202             my($self,$libperl)=@_;
203             return $self->{CFLAGS} if $self->{CFLAGS};
204             return '' unless $self->needs_linking();
205              
206             my($prog, $uc, $perltype, %cflags);
207             $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
208 154     154 1 716 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
209 154 50       453  
210 154 100       472 @cflags{qw(cc ccflags optimize shellflags)}
211             = @Config{qw(cc ccflags optimize shellflags)};
212 1         2  
213 1   33     5 # Perl 5.21.4 adds the (gcc) warning (-Wall ...) and std (-std=c89)
      33        
214 1         2 # flags to the %Config, and the modules in the core should be built
215             # with the warning flags, but NOT the -std=c89 flags (the latter
216             # would break using any system header files that are strict C99).
217 1         6 my @ccextraflags = qw(ccwarnflags);
218             if ($ENV{PERL_CORE}) {
219             for my $x (@ccextraflags) {
220             if (exists $Config{$x}) {
221             $cflags{$x} = $Config{$x};
222             }
223 1         2 }
224 1 50       3 }
225 0         0  
226 0 0       0 my($optdebug) = "";
227 0         0  
228             $cflags{shellflags} ||= '';
229              
230             my(%map) = (
231             D => '-DDEBUGGING',
232 1         2 E => '-DEMBED',
233             DE => '-DDEBUGGING -DEMBED',
234 1   50     3 M => '-DEMBED -DMULTIPLICITY',
235             DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
236 1         5 );
237              
238             if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
239             $uc = uc($1);
240             } else {
241             $uc = ""; # avoid warning
242             }
243             $perltype = $map{$uc} ? $map{$uc} : "";
244 1 50       17  
245 1         3 if ($uc =~ /^D/) {
246             $optdebug = "-g";
247 0         0 }
248              
249 1 50       3  
250             my($name);
251 1 50       2 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
252 0         0 if ($prog = $Config{$name}) {
253             # Expand hints for this extension via the shell
254             print "Processing $name hint:\n" if $Verbose;
255             my(@o)=`cc=\"$cflags{cc}\"
256 1         2 ccflags=\"$cflags{ccflags}\"
257 1         2 optimize=\"$cflags{optimize}\"
258 1 50       3 perltype=\"$cflags{perltype}\"
259             optdebug=\"$cflags{optdebug}\"
260 0 0       0 eval '$prog'
261 0         0 echo cc=\$cc
262             echo ccflags=\$ccflags
263             echo optimize=\$optimize
264             echo perltype=\$perltype
265             echo optdebug=\$optdebug
266             `;
267             foreach my $line (@o){
268             chomp $line;
269             if ($line =~ /(.*?)=\s*(.*)\s*$/){
270             $cflags{$1} = $2;
271             print " $1 = $2\n" if $Verbose;
272             } else {
273 0         0 print "Unrecognised result from hint: '$line'\n";
274 0         0 }
275 0 0       0 }
276 0         0 }
277 0 0       0  
278             if ($optdebug) {
279 0         0 $cflags{optimize} = $optdebug;
280             }
281              
282             for (qw(ccflags optimize perltype)) {
283             $cflags{$_} ||= '';
284 1 50       3 $cflags{$_} =~ s/^\s+//;
285 0         0 $cflags{$_} =~ s/\s+/ /g;
286             $cflags{$_} =~ s/\s+$//;
287             $self->{uc $_} ||= $cflags{$_};
288 1         2 }
289 3   100     9  
290 3         4 if ($self->{POLLUTE}) {
291 3         9 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
292 3         5 }
293 3   100     11  
294             for my $x (@ccextraflags) {
295             next unless exists $cflags{$x};
296 1 50       3 $self->{CCFLAGS} .= $cflags{$x} =~ m!^\s! ? $cflags{$x} : ' ' . $cflags{$x};
297 0         0 }
298              
299             my $pollute = '';
300 1         2 if ($Config{usemymalloc} and not $Config{bincompat5005}
301 1 50       3 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
302 0 0       0 and $self->{PERL_MALLOC_OK}) {
303             $pollute = '$(PERL_MALLOC_DEF)';
304             }
305 1         1  
306 1 50 33     10 return $self->{CFLAGS} = qq{
      33        
      33        
307             CCFLAGS = $self->{CCFLAGS}
308             OPTIMIZE = $self->{OPTIMIZE}
309 0         0 PERLTYPE = $self->{PERLTYPE}
310             MPOLLUTE = $pollute
311             };
312 1         7  
313             }
314              
315              
316             =item const_cccmd (o)
317              
318             Returns the full compiler call for C programs and stores the
319             definition in CONST_CCCMD.
320              
321             =cut
322              
323             my($self,$libperl)=@_;
324             return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
325             return '' unless $self->needs_linking();
326             return $self->{CONST_CCCMD} =
327             q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
328             $(CCFLAGS) $(OPTIMIZE) \\
329             $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
330 153     153 1 416 $(XS_DEFINE_VERSION)};
331 153 50       462 }
332 153 50       390  
333             =item const_config (o)
334 0         0  
335             Sets SHELL if needed, then defines a couple of constants in the Makefile
336             that are imported from %Config.
337              
338             =cut
339              
340             # --- Constants Sections ---
341              
342             my($self) = shift;
343             my @m = $self->specify_shell(); # Usually returns empty string
344             push @m, <<"END";
345              
346             # These definitions are from config.sh (via $INC{'Config.pm'}).
347             # They may have been overridden via Makefile.PL or on the command line.
348             END
349              
350 154     154 1 488 my(%once_only);
351 154         1685 foreach my $key (@{$self->{CONFIG}}){
352 154         839 # SITE*EXP macros are defined in &constants; avoid duplicates here
353             next if $once_only{$key};
354             push @m, uc($key) , ' = ' , $self->{uc $key}, "\n";
355             $once_only{$key} = 1;
356             }
357             join('', @m);
358 154         296 }
359 154         235  
  154         958  
360             =item const_loadlibs (o)
361 3542 50       6031  
362 3542         11590 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
363 3542         8730 L<ExtUtils::Liblist> for details.
364              
365 154         2582 =cut
366              
367             my($self) = shift;
368             return "" unless $self->needs_linking;
369             my @m;
370             push @m, qq{
371             # $self->{NAME} might depend on some other libraries:
372             # See ExtUtils::Liblist for details
373             #
374             };
375             for my $tmp (qw/
376 153     153 1 372 EXTRALIBS LDLOADLIBS BSLOADLIBS
377 153 50       383 /) {
378 0         0 next unless defined $self->{$tmp};
379 0         0 push @m, "$tmp = $self->{$tmp}\n";
380             }
381             # don't set LD_RUN_PATH if empty
382             for my $tmp (qw/
383             LD_RUN_PATH
384 0         0 /) {
385             next unless $self->{$tmp};
386             push @m, "$tmp = $self->{$tmp}\n";
387 0 0       0 }
388 0         0 return join "", @m;
389             }
390              
391 0         0 =item constants (o)
392              
393             my $make_frag = $mm->constants;
394 0 0       0  
395 0         0 Prints out macros for lots of constants.
396              
397 0         0 =cut
398              
399             my($self) = @_;
400             my @m = ();
401              
402             $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use
403              
404             for my $macro (qw(
405              
406             AR_STATIC_ARGS DIRFILESEP DFSEP
407             NAME NAME_SYM
408             VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
409 154     154 1 419 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
410 154         341 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
411             INST_MAN1DIR INST_MAN3DIR
412 154         890 MAN1EXT MAN3EXT
413             MAN1SECTION MAN3SECTION
414 154         1257 INSTALLDIRS INSTALL_BASE DESTDIR PREFIX
415             PERLPREFIX SITEPREFIX VENDORPREFIX
416             ),
417             (map { ("INSTALL".$_,
418             "DESTINSTALL".$_)
419             } $self->installvars),
420             qw(
421             PERL_LIB
422             PERL_ARCHLIB PERL_ARCHLIBDEP
423             LIBPERL_A MYEXTLIB
424             FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
425             PERLMAINCC PERL_SRC PERL_INC PERL_INCDEP
426             PERL FULLPERL ABSPERL
427 2772         6695 PERLRUN FULLPERLRUN ABSPERLRUN
428             PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
429             PERL_CORE
430             PERM_DIR PERM_RW PERM_RWX
431              
432             ) )
433             {
434             next unless defined $self->{$macro};
435              
436             # pathnames can have sharp signs in them; escape them so
437             # make doesn't think it is a comment-start character.
438             $self->{$macro} =~ s/#/\\#/g;
439             $self->{$macro} = $self->quote_dep($self->{$macro})
440             if $ExtUtils::MakeMaker::macro_dep{$macro};
441             push @m, "$macro = $self->{$macro}\n";
442             }
443              
444 13860 100       24188 push @m, qq{
445             MAKEMAKER = $self->{MAKEMAKER}
446             MM_VERSION = $self->{MM_VERSION}
447             MM_REVISION = $self->{MM_REVISION}
448 13394         18950 };
449              
450 13394 100       21473 push @m, q{
451 13394         28596 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
452             # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
453             # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
454 154         1428 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
455             };
456              
457             for my $macro (qw/
458             MAKE
459             FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
460 154         454 LDFROM LINKTYPE BOOTDEP
461             / )
462             {
463             next unless defined $self->{$macro};
464             push @m, "$macro = $self->{$macro}\n";
465             }
466              
467 154         531 push @m, "
468             # Handy lists of source code files:
469             XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
470             C_FILES = ".$self->wraplist(sort @{$self->{C}})."
471             O_FILES = ".$self->wraplist(sort @{$self->{O_FILES}})."
472             H_FILES = ".$self->wraplist(sort @{$self->{H}})."
473 1848 100       3597 MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
474 1540         3034 MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
475             ";
476              
477             push @m, q{
478             SDKROOT := $(shell xcrun --show-sdk-path)
479 154         2366 PERL_SYSROOT = $(SDKROOT)
480 154         540 } if $Is{ApplCor} && $self->{'PERL_INC'} =~ m!^/System/Library/Perl/!;
481 154         510  
482 154         494 push @m, q{
483 154         590 # Where is the Config information that we are using/depend on
484 154         333 CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_SYSROOT)$(PERL_INCDEP)$(DFSEP)config.h
  154         668  
485             } if $Is{ApplCor};
486              
487             push @m, q{
488             # Where is the Config information that we are using/depend on
489             CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_INCDEP)$(DFSEP)config.h
490 153 50 33     700 } if -e $self->catfile( $self->{PERL_INC}, 'config.h' ) && !$Is{ApplCor};
491              
492             push @m, qq{
493             # Where to build things
494             INST_LIBDIR = $self->{INST_LIBDIR}
495 153 50       417 INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
496              
497             INST_AUTODIR = $self->{INST_AUTODIR}
498             INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
499              
500 153 50 33     733 INST_STATIC = $self->{INST_STATIC}
501             INST_DYNAMIC = $self->{INST_DYNAMIC}
502 153         1414 INST_BOOT = $self->{INST_BOOT}
503             };
504              
505             push @m, qq{
506             # Extra linker info
507             EXPORT_LIST = $self->{EXPORT_LIST}
508             PERL_ARCHIVE = $self->{PERL_ARCHIVE}
509             PERL_ARCHIVEDEP = $self->{PERL_ARCHIVEDEP}
510             PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
511             };
512              
513             push @m, "
514              
515 153         737 TO_INST_PM = ".$self->wraplist(map $self->quote_dep($_), sort keys %{$self->{PM}})."\n";
516              
517             join('',@m);
518             }
519              
520              
521             =item depend (o)
522              
523             Same as macro for the depend attribute.
524              
525 153         402 =cut
  153         1017  
526              
527 153         3706 my($self,%attribs) = @_;
528             my(@m,$key,$val);
529             for my $key (sort keys %attribs){
530             my $val = $attribs{$key};
531             next unless defined $key and defined $val;
532             push @m, "$key : $val\n";
533             }
534             join "", @m;
535             }
536              
537              
538 153     153 1 418 =item init_DEST
539 153         393  
540 153         709 $mm->init_DEST
541 0         0  
542 0 0 0     0 Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
543 0         0  
544             =cut
545 153         670  
546             my $self = shift;
547              
548             # Initialize DESTDIR
549             $self->{DESTDIR} ||= '';
550              
551             # Make DEST variables.
552             foreach my $var ($self->installvars) {
553             my $destvar = 'DESTINSTALL'.$var;
554             $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
555             }
556             }
557              
558 155     155 1 332  
559             =item init_dist
560              
561 155   50     1125 $mm->init_dist;
562              
563             Defines a lot of macros for distribution support.
564 155         1434  
565 2790         3929 macro description default
566 2790   33     8680  
567             TAR tar command to use tar
568             TARFLAGS flags to pass to TAR cvf
569              
570             ZIP zip command to use zip
571             ZIPFLAGS flags to pass to ZIP -r
572              
573             COMPRESS compression command to gzip --best
574             use for tarfiles
575             SUFFIX suffix to put on .gz
576             compressed files
577              
578             SHAR shar command to use shar
579              
580             PREOP extra commands to run before
581             making the archive
582             POSTOP extra commands to run after
583             making the archive
584              
585             TO_UNIX a command to convert linefeeds
586             to Unix style in your archive
587              
588             CI command to checkin your ci -u
589             sources to version control
590             RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
591             just after CI is run
592              
593             DIST_CP $how argument to manicopy() best
594             when the distdir is created
595              
596             DIST_DEFAULT default target to use to tardist
597             create a distribution
598              
599             DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
600             (minus suffixes)
601              
602             =cut
603              
604             my $self = shift;
605              
606             $self->{TAR} ||= 'tar';
607             $self->{TARFLAGS} ||= 'cvf';
608             $self->{ZIP} ||= 'zip';
609             $self->{ZIPFLAGS} ||= '-r';
610             $self->{COMPRESS} ||= 'gzip --best';
611             $self->{SUFFIX} ||= '.gz';
612             $self->{SHAR} ||= 'shar';
613             $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
614             $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
615             $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
616              
617 155     155 1 339 $self->{CI} ||= 'ci -u';
618             $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
619 155   50     1259 $self->{DIST_CP} ||= 'best';
620 155   50     761 $self->{DIST_DEFAULT} ||= 'tardist';
621 155   50     767  
622 155   50     993 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
623 155   50     805 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
624 155   50     1246 }
625 155   50     741  
626 155   50     934 =item dist (o)
627 155   50     738  
628 155   50     736 my $dist_macros = $mm->dist(%overrides);
629              
630 155   50     921 Generates a make fragment defining all the macros initialized in
631 155   50     836 init_dist.
632 155   50     762  
633 155   50     683 %overrides can be used to override any of the above.
634              
635 155 100       1269 =cut
636 155   66     1460  
637             my($self, %attribs) = @_;
638              
639             my $make = '';
640             if ( $attribs{SUFFIX} && $attribs{SUFFIX} !~ m!^\.! ) {
641             $attribs{SUFFIX} = '.' . $attribs{SUFFIX};
642             }
643             foreach my $key (qw(
644             TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
645             PREOP POSTOP TO_UNIX
646             CI RCS_LABEL DIST_CP DIST_DEFAULT
647             DISTNAME DISTVNAME
648             ))
649             {
650             my $value = $attribs{$key} || $self->{$key};
651 96     96 1 261 $make .= "$key = $value\n";
652             }
653 96         389  
654 96 50 33     514 return $make;
655 0         0 }
656              
657 96         664 =item dist_basics (o)
658              
659             Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
660              
661             =cut
662              
663             my($self) = shift;
664 1536   33     4663  
665 1536         3165 return <<'MAKE_FRAG';
666             distclean :: realclean distcheck
667             $(NOECHO) $(NOOP)
668 96         454  
669             distcheck :
670             $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
671              
672             skipcheck :
673             $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
674              
675             manifest :
676             $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
677              
678 97     97 1 16448 veryclean : realclean
679             $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old
680 97         310  
681             MAKE_FRAG
682              
683             }
684              
685             =item dist_ci (o)
686              
687             Defines a check in target for RCS.
688              
689             =cut
690              
691             my($self) = shift;
692             return sprintf "ci :\n\t%s\n", $self->oneliner(<<'EOF', [qw(-MExtUtils::Manifest=maniread)]);
693             @all = sort keys %{ maniread() };
694             print(qq{Executing $(CI) @all\n});
695             system(qq{$(CI) @all}) == 0 or die $!;
696             print(qq{Executing $(RCS_LABEL) ...\n});
697             system(qq{$(RCS_LABEL) @all}) == 0 or die $!;
698             EOF
699             }
700              
701             =item dist_core (o)
702              
703             my $dist_make_fragment = $MM->dist_core;
704              
705             Puts the targets necessary for 'make dist' together into one make
706             fragment.
707 96     96 1 332  
708 96         645 =cut
709              
710             my($self) = shift;
711              
712             my $make_frag = '';
713             foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
714             shdist))
715             {
716             my $method = $target.'_target';
717             $make_frag .= "\n";
718             $make_frag .= $self->$method();
719             }
720              
721             return $make_frag;
722             }
723              
724              
725             =item B<dist_target>
726              
727 96     96 1 253 my $make_frag = $MM->dist_target;
728              
729 96         308 Returns the 'dist' target to make an archive for distribution. This
730 96         707 target simply checks to make sure the Makefile is up-to-date and
731             depends on $(DIST_DEFAULT).
732              
733 672         1226 =cut
734 672         805  
735 672         5343 my($self) = shift;
736              
737             my $date_check = $self->oneliner(<<'CODE', ['-l']);
738 96         545 print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
739             if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
740             CODE
741              
742             return sprintf <<'MAKE_FRAG', $date_check;
743             dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
744             $(NOECHO) %s
745             MAKE_FRAG
746             }
747              
748             =item B<tardist_target>
749              
750             my $make_frag = $MM->tardist_target;
751              
752             Returns the 'tardist' target which is simply so 'make tardist' works.
753 96     96 1 316 The real work is done by the dynamically named tardistfile_target()
754             method, tardist should have that as a dependency.
755 96         676  
756             =cut
757              
758             my($self) = shift;
759              
760 96         637 return <<'MAKE_FRAG';
761             tardist : $(DISTVNAME).tar$(SUFFIX)
762             $(NOECHO) $(NOOP)
763             MAKE_FRAG
764             }
765              
766             =item B<zipdist_target>
767              
768             my $make_frag = $MM->zipdist_target;
769              
770             Returns the 'zipdist' target which is simply so 'make zipdist' works.
771             The real work is done by the dynamically named zipdistfile_target()
772             method, zipdist should have that as a dependency.
773              
774             =cut
775              
776             my($self) = shift;
777 96     96 1 234  
778             return <<'MAKE_FRAG';
779 96         236 zipdist : $(DISTVNAME).zip
780             $(NOECHO) $(NOOP)
781             MAKE_FRAG
782             }
783              
784             =item B<tarfile_target>
785              
786             my $make_frag = $MM->tarfile_target;
787              
788             The name of this target is the name of the tarball generated by
789             tardist. This target does the actual work of turning the distdir into
790             a tarball.
791              
792             =cut
793              
794             my($self) = shift;
795              
796 96     96 1 244 return <<'MAKE_FRAG';
797             $(DISTVNAME).tar$(SUFFIX) : distdir
798 96         246 $(PREOP)
799             $(TO_UNIX)
800             $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
801             $(RM_RF) $(DISTVNAME)
802             $(COMPRESS) $(DISTVNAME).tar
803             $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)'
804             $(POSTOP)
805             MAKE_FRAG
806             }
807              
808             =item zipfile_target
809              
810             my $make_frag = $MM->zipfile_target;
811              
812             The name of this target is the name of the zip file generated by
813             zipdist. This target does the actual work of turning the distdir into
814             a zip file.
815 96     96 1 282  
816             =cut
817 96         253  
818             my($self) = shift;
819              
820             return <<'MAKE_FRAG';
821             $(DISTVNAME).zip : distdir
822             $(PREOP)
823             $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
824             $(RM_RF) $(DISTVNAME)
825             $(NOECHO) $(ECHO) 'Created $(DISTVNAME).zip'
826             $(POSTOP)
827             MAKE_FRAG
828             }
829              
830             =item uutardist_target
831              
832             my $make_frag = $MM->uutardist_target;
833              
834             Converts the tarfile into a uuencoded file
835              
836             =cut
837              
838             my($self) = shift;
839              
840 96     96 1 215 return <<'MAKE_FRAG';
841             uutardist : $(DISTVNAME).tar$(SUFFIX)
842 96         288 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
843             $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)_uu'
844             MAKE_FRAG
845             }
846              
847              
848             =item shdist_target
849              
850             my $make_frag = $MM->shdist_target;
851              
852             Converts the distdir into a shell archive.
853              
854             =cut
855              
856             my($self) = shift;
857              
858             return <<'MAKE_FRAG';
859             shdist : distdir
860             $(PREOP)
861 96     96 1 318 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
862             $(RM_RF) $(DISTVNAME)
863 96         293 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).shar'
864             $(POSTOP)
865             MAKE_FRAG
866             }
867              
868              
869             =item dlsyms (o)
870              
871             Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files.
872              
873             Normally just returns an empty string.
874              
875             =cut
876              
877             return '';
878             }
879              
880 96     96 1 206  
881             =item dynamic_bs (o)
882 96         283  
883             Defines targets for bootstrap files.
884              
885             =cut
886              
887             my($self, %attribs) = @_;
888             return "\nBOOTSTRAP =\n" unless $self->has_link_code();
889             my @exts;
890             if ($self->{XSMULTI}) {
891             @exts = $self->_xs_list_basenames;
892             } else {
893             @exts = '$(BASEEXT)';
894             }
895             return join "\n",
896             "BOOTSTRAP = @{[map { qq{$_.bs} } @exts]}\n",
897             map { $self->_xs_make_bs($_) } @exts;
898             }
899              
900             my ($self, $basename) = @_;
901             my ($v, $d, $f) = File::Spec->splitpath($basename);
902 153     153 1 767 my @d = File::Spec->splitdir($d);
903             shift @d if $self->{XSMULTI} and $d[0] eq 'lib';
904             my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
905             $instdir = '$(INST_ARCHAUTODIR)' if $basename eq '$(BASEEXT)';
906             my $instfile = $self->catfile($instdir, "$f.bs");
907             my $exists = "$instdir\$(DFSEP).exists"; # match blibdirs_target
908             # 1 2 3
909             return _sprintf562 <<'MAKE_FRAG', $basename, $instfile, $exists;
910             # As Mkbootstrap might not write a file (if none is required)
911             # we use touch to prevent make continually trying to remake it.
912             # The DynaLoader only reads a non-empty file.
913 153     153 1 385 %1$s.bs : $(FIRST_MAKEFILE) $(BOOTDEP)
914 153 50       466 $(NOECHO) $(ECHO) "Running Mkbootstrap for %1$s ($(BSLOADLIBS))"
915 0         0 $(NOECHO) $(PERLRUN) \
916 0 0       0 "-MExtUtils::Mkbootstrap" \
917 0         0 -e "Mkbootstrap('%1$s','$(BSLOADLIBS)');"
918             $(NOECHO) $(TOUCH) "%1$s.bs"
919 0         0 $(CHMOD) $(PERM_RW) "%1$s.bs"
920              
921             %2$s : %1$s.bs %3$s
922 0         0 $(NOECHO) $(RM_RF) %2$s
  0         0  
923 0         0 - $(CP_NONEMPTY) %1$s.bs %2$s $(PERM_RW)
  0         0  
924             MAKE_FRAG
925             }
926              
927 0     0   0 =item dynamic_lib (o)
928 0         0  
929 0         0 Defines how to produce the *.so (or equivalent) files.
930 0 0 0     0  
931 0         0 =cut
932 0 0       0  
933 0         0 my($self, %attribs) = @_;
934 0         0 return '' unless $self->needs_linking(); #might be because of a subdir
935             return '' unless $self->has_link_code;
936 0         0 my @m = $self->xs_dynamic_lib_macros(\%attribs);
937             my @libs;
938             my $dlsyms_ext = eval { $self->xs_dlsyms_ext };
939             if ($self->{XSMULTI}) {
940             my @exts = $self->_xs_list_basenames;
941             for my $ext (@exts) {
942             my ($v, $d, $f) = File::Spec->splitpath($ext);
943             my @d = File::Spec->splitdir($d);
944             shift @d if $d[0] eq 'lib';
945             pop @d if $d[$#d] eq '';
946             my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
947              
948             # Dynamic library names may need special handling.
949             eval { require DynaLoader };
950             if (defined &DynaLoader::mod2fname) {
951             $f = &DynaLoader::mod2fname([@d, $f]);
952             }
953              
954             my $instfile = $self->catfile($instdir, "$f.\$(DLEXT)");
955             my $objfile = $self->_xsbuild_value('xs', $ext, 'OBJECT');
956             $objfile = "$ext\$(OBJ_EXT)" unless defined $objfile;
957             my $ldfrom = $self->_xsbuild_value('xs', $ext, 'LDFROM');
958             $ldfrom = $objfile unless defined $ldfrom;
959             my $exportlist = "$ext.def";
960             my @libchunk = ($objfile, $instfile, $instdir, $ldfrom, $exportlist);
961 153     153 1 423 push @libchunk, $dlsyms_ext ? $ext.$dlsyms_ext : undef;
962 153 50       593 push @libs, \@libchunk;
963 0 0       0 }
964 0         0 } else {
965 0         0 my @libchunk = qw($(OBJECT) $(INST_DYNAMIC) $(INST_ARCHAUTODIR) $(LDFROM) $(EXPORT_LIST));
966 0         0 push @libchunk, $dlsyms_ext ? '$(BASEEXT)'.$dlsyms_ext : undef;
  0         0  
967 0 0       0 @libs = (\@libchunk);
968 0         0 }
969 0         0 push @m, map { $self->xs_make_dynamic_lib(\%attribs, @$_); } @libs;
970 0         0  
971 0         0 return join("\n",@m);
972 0 0       0 }
973 0 0       0  
974 0         0 =item xs_dynamic_lib_macros
975              
976             Defines the macros for the C<dynamic_lib> section.
977 0         0  
  0         0  
978 0 0       0 =cut
979 0         0  
980             my ($self, $attribs) = @_;
981             my $otherldflags = $attribs->{OTHERLDFLAGS} || "";
982 0         0 my $inst_dynamic_dep = $attribs->{INST_DYNAMIC_DEP} || "";
983 0         0 my $armaybe = $self->_xs_armaybe($attribs);
984 0 0       0 my $ld_opt = $Is{OS2} ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
985 0         0 my $ld_fix = $Is{OS2} ? '|| ( $(RM_F) $@ && sh -c false )' : '';
986 0 0       0 sprintf <<'EOF', $armaybe, $ld_opt.$otherldflags, $inst_dynamic_dep, $ld_fix;
987 0         0 # This section creates the dynamically loadable objects from relevant
988 0         0 # objects and possibly $(MYEXTLIB).
989 0 0       0 ARMAYBE = %s
990 0         0 OTHERLDFLAGS = %s
991             INST_DYNAMIC_DEP = %s
992             INST_DYNAMIC_FIX = %s
993 0         0 EOF
994 0 0       0 }
995 0         0  
996             my ($self, $attribs) = @_;
997 0         0 my $armaybe = $attribs->{ARMAYBE} || $self->{ARMAYBE} || ":";
  0         0  
998             $armaybe = 'ar' if ($Is{OSF} and $armaybe eq ':');
999 0         0 $armaybe;
1000             }
1001              
1002             =item xs_make_dynamic_lib
1003              
1004             Defines the recipes for the C<dynamic_lib> section.
1005              
1006             =cut
1007              
1008             my ($self, $attribs, $object, $to, $todir, $ldfrom, $exportlist, $dlsyms) = @_;
1009 0     0 1 0 $exportlist = '' if $exportlist ne '$(EXPORT_LIST)';
1010 0   0     0 my $armaybe = $self->_xs_armaybe($attribs);
1011 0   0     0 my @m = sprintf '%s : %s $(MYEXTLIB) %s$(DFSEP).exists %s $(PERL_ARCHIVEDEP) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP) %s'."\n", $to, $object, $todir, $exportlist, ($dlsyms || '');
1012 0         0 my $dlsyms_arg = $self->xs_dlsyms_arg($dlsyms);
1013 0 0       0 if ($armaybe ne ':'){
1014 0 0       0 $ldfrom = 'tmp$(LIB_EXT)';
1015 0         0 push(@m," \$(ARMAYBE) cr $ldfrom $object\n");
1016             push(@m," \$(RANLIB) $ldfrom\n");
1017             }
1018             $ldfrom = "-all $ldfrom -none" if $Is{OSF};
1019              
1020             my $ldrun = '';
1021             # The IRIX linker doesn't use LD_RUN_PATH
1022             if ( $self->{LD_RUN_PATH} ) {
1023             if ( $Is{IRIX} ) {
1024             $ldrun = qq{-rpath "$self->{LD_RUN_PATH}"};
1025             }
1026 0     0   0 elsif ( $^O eq 'darwin' ) {
1027 0   0     0 # both clang and gcc support -Wl,-rpath, but only clang supports
1028 0 0 0     0 # -rpath so by using -Wl,-rpath we avoid having to check for the
1029 0         0 # type of compiler
1030             $ldrun = qq{-Wl,-rpath,"$self->{LD_RUN_PATH}"};
1031             }
1032             }
1033              
1034             # For example in AIX the shared objects/libraries from previous builds
1035             # linger quite a while in the shared dynalinker cache even when nobody
1036             # is using them. This is painful if one for instance tries to restart
1037             # a failed build because the link command will fail unnecessarily 'cos
1038             # the shared object/library is 'busy'.
1039 0     0 1 0 push(@m," \$(RM_F) \$\@\n");
1040 0 0       0  
1041 0         0 my $libs = '$(LDLOADLIBS)';
1042 0   0     0 if (($Is{NetBSD} || $Is{Interix} || $Is{Android}) && $Config{'useshrplib'} eq 'true') {
1043 0         0 # Use nothing on static perl platforms, and to the flags needed
1044 0 0       0 # to link against the shared libperl library on shared perl
1045 0         0 # platforms. We peek at lddlflags to see if we need -Wl,-R
1046 0         0 # or -R to add paths to the run-time library search path.
1047 0         0 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
1048             $libs .= ' "-L$(PERL_INC)" "-Wl,-R$(INSTALLARCHLIB)/CORE" "-Wl,-R$(PERL_ARCHLIB)/CORE" -lperl';
1049 0 0       0 } elsif ($Config{'lddlflags'} =~ /-R/) {
1050             $libs .= ' "-L$(PERL_INC)" "-R$(INSTALLARCHLIB)/CORE" "-R$(PERL_ARCHLIB)/CORE" -lperl';
1051 0         0 } elsif ( $Is{Android} ) {
1052             # The Android linker will not recognize symbols from
1053 0 0       0 # libperl unless the module explicitly depends on it.
1054 0 0       0 $libs .= ' "-L$(PERL_INC)" -lperl';
    0          
1055 0         0 }
1056             }
1057              
1058             my $ld_run_path_shell = "";
1059             if ($self->{LD_RUN_PATH} ne "") {
1060             $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
1061 0         0 }
1062              
1063             push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $dlsyms_arg, $ldfrom, $self->xs_obj_opt('$@'), $libs, $exportlist;
1064             %s$(LD) %s $(LDDLFLAGS) %s %s $(OTHERLDFLAGS) %s $(MYEXTLIB) \
1065             $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) %s \
1066             $(INST_DYNAMIC_FIX)
1067             $(CHMOD) $(PERM_RWX) $@
1068             MAKE
1069             join '', @m;
1070 0         0 }
1071              
1072 0         0 =item exescan
1073 0 0 0     0  
      0        
1074             Deprecated method. Use libscan instead.
1075              
1076             =cut
1077              
1078 0 0       0 my($self,$path) = @_;
    0          
    0          
1079 0         0 $path;
1080             }
1081 0         0  
1082             =item extliblist
1083              
1084             Called by init_others, and calls ext ExtUtils::Liblist. See
1085 0         0 L<ExtUtils::Liblist> for details.
1086              
1087             =cut
1088              
1089 0         0 my($self,$libs) = @_;
1090 0 0       0 require ExtUtils::Liblist;
1091 0         0 $self->ext($libs, $Verbose);
1092             }
1093              
1094 0         0 =item find_perl
1095              
1096             Finds the executables PERL and FULLPERL
1097              
1098             =cut
1099              
1100 0         0 my($self, $ver, $names, $dirs, $trace) = @_;
1101             if ($trace >= 2){
1102             print "Looking for perl $ver by these names:
1103             @$names
1104             in these dirs:
1105             @$dirs
1106             ";
1107             }
1108              
1109             my $stderr_duped = 0;
1110 0     0 1 0 local *STDERR_COPY;
1111 0         0  
1112             unless ($Is{BSD}) {
1113             # >& and lexical filehandles together give 5.6.2 indigestion
1114             if( open(STDERR_COPY, '>&STDERR') ) { ## no critic
1115             $stderr_duped = 1;
1116             }
1117             else {
1118             warn <<WARNING;
1119             find_perl() can't dup STDERR: $!
1120             You might see some garbage while we search for Perl
1121             WARNING
1122 155     155 1 600 }
1123 155         1914 }
1124 155         4564  
1125             foreach my $name (@$names){
1126             my ($abs, $use_dir);
1127             if ($self->file_name_is_absolute($name)) { # /foo/bar
1128             $abs = $name;
1129             } elsif ($self->canonpath($name) eq
1130             $self->canonpath(basename($name))) { # foo
1131             $use_dir = 1;
1132             } else { # foo/bar
1133             $abs = $self->catfile($Curdir, $name);
1134 99     99 1 459 }
1135 99 50       285 foreach my $dir ($use_dir ? @$dirs : 1){
1136 0         0 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1137              
1138             $abs = $self->catfile($dir, $name)
1139             if $use_dir;
1140              
1141             print "Checking $abs\n" if ($trace >= 2);
1142             next unless $self->maybe_command($abs);
1143 99         203 print "Executing $abs\n" if ($trace >= 2);
1144 99         257  
1145             my $val;
1146 99 50       348 my $version_check = qq{"$abs" -le "require $ver; print qq{VER_OK}"};
1147              
1148 99 50       2255 # To avoid using the unportable 2>&1 to suppress STDERR,
1149 99         324 # we close it before running the command.
1150             # However, thanks to a thread library bug in many BSDs
1151             # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1152 0         0 # we cannot use the fancier more portable way in here
1153             # but instead need to use the traditional 2>&1 construct.
1154             if ($Is{BSD}) {
1155             $val = `$version_check 2>&1`;
1156             } else {
1157             close STDERR if $stderr_duped;
1158             $val = `$version_check`;
1159 99         488  
1160 99         362 # 5.6.2's 3-arg open doesn't work with >&
1161 99 50       2203 open STDERR, ">&STDERR_COPY" ## no critic
    0          
1162 99         253 if $stderr_duped;
1163             }
1164              
1165 0         0 if ($val =~ /^VER_OK/m) {
1166             print "Using PERL=$abs\n" if $trace;
1167 0         0 return $abs;
1168             } elsif ($trace >= 2) {
1169 99 50       371 print "Result: '$val' ".($? >> 8)."\n";
1170 99 50       337 }
1171             }
1172 99 50       232 }
1173             print "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1174             0; # false and not empty
1175 99 50       231 }
1176 99 50       937  
1177 99 50       414  
1178             =item fixin
1179 99         170  
1180 99         732 $mm->fixin(@files);
1181              
1182             Inserts the sharpbang or equivalent magic number to a set of @files.
1183              
1184             =cut
1185              
1186             my ( $self, @files ) = @_;
1187              
1188 99 50       309 for my $file (@files) {
1189 0         0 my $file_new = "$file.new";
1190             my $file_bak = "$file.bak";
1191 99 50       739  
1192 99         557438 open( my $fixin, '<', $file ) or croak "Can't process '$file': $!";
1193             local $/ = "\n";
1194             chomp( my $line = <$fixin> );
1195 99 50       4494 next unless $line =~ s/^\s*\#!\s*//; # Not a shebang file.
1196              
1197             my $shb = $self->_fixin_replace_shebang( $file, $line );
1198             next unless defined $shb;
1199 99 50       2625  
    0          
1200 99 50       580 open( my $fixout, ">", "$file_new" ) or do {
1201 99         5370 warn "Can't create new $file: $!\n";
1202             next;
1203 0         0 };
1204              
1205             # Print out the new #! line (or equivalent).
1206             local $\;
1207 0         0 local $/;
1208 0         0 print $fixout $shb, <$fixin>;
1209             close $fixin;
1210             close $fixout;
1211              
1212             chmod 0666, $file_bak;
1213             unlink $file_bak;
1214             unless ( _rename( $file, $file_bak ) ) {
1215             warn "Can't rename $file to $file_bak: $!";
1216             next;
1217             }
1218             unless ( _rename( $file_new, $file ) ) {
1219             warn "Can't rename $file_new to $file: $!";
1220             unless ( _rename( $file_bak, $file ) ) {
1221 6     6 1 16860 warn "Can't rename $file_bak back to $file either: $!";
1222             warn "Leaving $file renamed as $file_bak\n";
1223 6         15 }
1224 6         13 next;
1225 6         10 }
1226             unlink $file_bak;
1227 6 50       200 }
1228 6         33 continue {
1229 6         71 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
1230 6 50       49 }
1231             }
1232 6         38  
1233 6 100       50  
1234             my($old, $new) = @_;
1235 5 50       273  
1236 0         0 foreach my $file ($old, $new) {
1237 0         0 if( $Is{VMS} and basename($file) !~ /\./ ) {
1238             # rename() in 5.8.0 on VMS will not rename a file if it
1239             # does not contain a dot yet it returns success.
1240             $file = "$file.";
1241 5         45 }
1242 5         13 }
1243 5         197  
1244 5         86 return rename($old, $new);
1245 5         129 }
1246              
1247 5         65 my ( $self, $file, $line ) = @_;
1248 5         31  
1249 5 50       15 # Now figure out the interpreter name.
1250 0         0 my ( $origcmd, $arg ) = split ' ', $line, 2;
1251 0         0 (my $cmd = $origcmd) =~ s!^.*/!!;
1252              
1253 5 50       16 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
1254 0         0 my $interpreter;
1255 0 0       0 if ( defined $ENV{PERL_MM_SHEBANG} && $ENV{PERL_MM_SHEBANG} eq "relocatable" ) {
1256 0         0 $interpreter = "/usr/bin/env perl";
1257 0         0 }
1258             elsif ( $cmd =~ m{^perl(?:\z|[^a-z])} ) {
1259 0         0 if ( $Config{startperl} =~ m,^\#!.*/perl, ) {
1260             $interpreter = $Config{startperl};
1261 5         201 $interpreter =~ s,^\#!,,;
1262             }
1263             else {
1264 6 50       43 $interpreter = $Config{perlpath};
1265             }
1266             }
1267             else {
1268             my (@absdirs)
1269             = reverse grep { $self->file_name_is_absolute($_) } $self->path;
1270 10     10   22 $interpreter = '';
1271              
1272 10         15 foreach my $dir (@absdirs) {
1273 20 50 33     49 my $maybefile = $self->catfile($dir,$cmd);
1274             if ( $self->maybe_command($maybefile) ) {
1275             warn "Ignoring $interpreter in $file\n"
1276 0         0 if $Verbose && $interpreter;
1277             $interpreter = $maybefile;
1278             }
1279             }
1280 10         226  
1281             # If the shebang is absolute and exists in PATH, but was not
1282             # the first one found, leave it alone if it's actually the
1283             # same file as first one. This avoids packages built on
1284 6     6   14 # merged-/usr systems with /usr/bin before /bin in the path
1285             # breaking when installed on systems without merged /usr
1286             if ($origcmd ne $interpreter and $self->file_name_is_absolute($origcmd)) {
1287 6         15 my $origdir = dirname($origcmd);
1288 6         23 if ($self->maybe_command($origcmd) && grep { $_ eq $origdir } @absdirs) {
1289             my ($odev, $oino) = stat $origcmd;
1290             my ($idev, $iino) = stat $interpreter;
1291 6         9 if ($odev == $idev && $oino eq $iino) {
1292 6 50 33     55 warn "$origcmd is the same as $interpreter, leaving alone"
    100          
1293 0         0 if $Verbose;
1294             $interpreter = $origcmd;
1295             }
1296 3 50       14 }
1297 3         6 }
1298 3         9 }
1299              
1300             # Figure out how to invoke interpreter on this machine.
1301 0         0  
1302             my ($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1303             my ($shb) = "";
1304             if ($interpreter) {
1305             print "Changing sharpbang in $file to $interpreter"
1306 3         42 if $Verbose;
  13         49  
1307 3         7 # this is probably value-free on DOSISH platforms
1308             if ($does_shbang) {
1309 3         5 $shb .= "$Config{'sharpbang'}$interpreter";
1310 12         38 $shb .= ' ' . $arg if defined $arg;
1311 12 100       26 $shb .= "\n";
1312 3 50 33     9 }
1313             }
1314 3         8 else {
1315             warn "Can't find $cmd in PATH, $file unchanged"
1316             if $Verbose;
1317             return;
1318             }
1319             return $shb
1320             }
1321              
1322             =item force (o)
1323 3 50 33     25  
1324 3         89 Writes an empty FORCE: target.
1325 3 100 66     7  
  2         7  
1326 1         15 =cut
1327 1         12  
1328 1 50 33     9 my($self) = shift;
1329 1 50       4 '# Phony target to force checking subdirectories.
1330             FORCE :
1331 1         2 $(NOECHO) $(NOOP)
1332             ';
1333             }
1334              
1335             =item guess_name
1336              
1337             Guess the name of this package by examining the working directory's
1338             name. MakeMaker calls this only if the developer has not supplied a
1339 6         27 NAME attribute.
1340 6         9  
1341 6 100       13 =cut
1342 5 50       12  
1343             # ';
1344              
1345 5 50       11 my($self) = @_;
1346 5         12 use Cwd 'cwd';
1347 5 100       22 my $name = basename(cwd());
1348 5         8 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
1349             # strip minus or underline
1350             # followed by a float or some such
1351             print "Warning: Guessing NAME [$name] from current directory name.\n";
1352 1 50       3 $name;
1353             }
1354 1         3  
1355             =item has_link_code
1356 5         14  
1357             Returns true if C, XS, MYEXTLIB or similar objects exist within this
1358             object that need a compiler. Does not descend into subdirectories as
1359             needs_linking() does.
1360              
1361             =cut
1362              
1363             my($self) = shift;
1364             return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1365             if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1366 153     153 1 403 $self->{HAS_LINK_CODE} = 1;
1367 153         710 return 1;
1368             }
1369             return $self->{HAS_LINK_CODE} = 0;
1370             }
1371              
1372              
1373             =item init_dirscan
1374              
1375             Scans the directory structure and initializes DIR, XS, XS_FILES,
1376             C, C_FILES, O_FILES, H, H_FILES, PL_FILES, EXE_FILES.
1377              
1378             Called by init_main.
1379              
1380             =cut
1381              
1382             my($self) = @_;
1383             my(%dir, %xs, %c, %o, %h, %pl_files, %pm);
1384 0     0 1 0  
1385 52     52   490 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
  52         115  
  52         351503  
1386 0         0  
1387 0         0 # ignore the distdir
1388             $Is{VMS} ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1389             : $ignore{$self->{DISTVNAME}} = 1;
1390 0         0  
1391 0         0 my $distprefix = $Is{VMS} ? qr/^\Q$self->{DISTNAME}\E-v?[\d\.]+\.dir$/i
1392             : qr/^\Q$self->{DISTNAME}\E-v?[\d\.]+$/;
1393              
1394             @ignore{map lc, keys %ignore} = values %ignore if $Is{VMS};
1395              
1396             if ( defined $self->{XS} and !defined $self->{C} ) {
1397             my @c_files = grep { m/\.c(pp|xx)?\z/i } values %{$self->{XS}};
1398             my @o_files = grep { m/(?:.(?:o(?:bj)?)|\$\(OBJ_EXT\))\z/i } values %{$self->{XS}};
1399             %c = map { $_ => 1 } @c_files;
1400             %o = map { $_ => 1 } @o_files;
1401             }
1402              
1403 773     773 1 1454 foreach my $name ($self->lsdir($Curdir)){
1404 773 100       4577 next if $name =~ /\#/;
1405 159 100 100     823 next if $name =~ $distprefix && -d $name;
  158 100 100     1500  
1406 3         4 $name = lc($name) if $Is{VMS};
1407 3         11 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
1408             next unless $self->libscan($name);
1409 156         626 if (-d $name){
1410             next if -l $name; # We do not support symlinks at all
1411             next if $self->{NORECURS};
1412             $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1413             } elsif ($name =~ /\.xs\z/){
1414             my($c); ($c = $name) =~ s/\.xs\z/.c/;
1415             $xs{$name} = $c;
1416             $c{$c} = 1;
1417             } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
1418             $c{$name} = 1
1419             unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1420             } elsif ($name =~ /\.h\z/i){
1421             $h{$name} = 1;
1422             } elsif ($name =~ /\.PL\z/) {
1423 155     155 1 472 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
1424 155         358 } elsif (($Is{VMS} || $Is{Dos}) && $name =~ /[._]pl$/i) {
1425             # case-insensitive filesystem, one dot per name, so foo.h.PL
1426 155         392 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
  620         2621  
1427             local($/); open(my $pl, '<', $name); my $txt = <$pl>; close $pl;
1428             if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
1429             ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
1430 155 50       949 }
1431             else {
1432 155 50       5707 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1433             }
1434             } elsif ($name =~ /\.(p[ml]|pod)\z/){
1435 155 50       763 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1436             }
1437 155 50 33     567 }
1438 0         0  
  0         0  
  0         0  
1439 0         0 $self->{PL_FILES} ||= \%pl_files;
  0         0  
  0         0  
1440 0         0 $self->{DIR} ||= [sort keys %dir];
  0         0  
1441 0         0 $self->{XS} ||= \%xs;
  0         0  
1442             $self->{C} ||= [sort keys %c];
1443             $self->{H} ||= [sort keys %h];
1444 155         1413 $self->{PM} ||= \%pm;
1445 1251 50       3520  
1446 1251 50 33     5469 my @o_files = @{$self->{C}};
1447 1251 50       2508 %o = (%o, map { $_ => 1 } grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files);
1448 1251 100 100     5520 $self->{O_FILES} = [sort keys %o];
      100        
1449 645 100       3409 }
1450 641 100 33     12806  
    50 33        
    50          
    50          
    50          
    50          
    50          
1451 298 50       2961  
1452 298 50       872 =item init_MANPODS
1453 298 100       1025  
1454             Determines if man pages should be generated and initializes MAN1PODS
1455 0         0 and MAN3PODS as appropriate.
  0         0  
1456 0         0  
1457 0         0 =cut
1458              
1459 0 0       0 my $self = shift;
1460              
1461             # Set up names of manual pages to generate from pods
1462 0         0 foreach my $man (qw(MAN1 MAN3)) {
1463             if ( $self->{"${man}PODS"}
1464 0         0 or $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/
1465             ) {
1466             $self->{"${man}PODS"} ||= {};
1467             }
1468 0         0 else {
  0         0  
  0         0  
  0         0  
1469 0 0       0 my $init_method = "init_${man}PODS";
1470 0         0 $self->$init_method();
1471             }
1472             }
1473 0         0  
1474             # logic similar to picking man${num}ext in perl's Configure script
1475             foreach my $num (1,3) {
1476 0         0 my $installdirs = uc $self->{INSTALLDIRS};
1477             $installdirs = '' if $installdirs eq 'PERL';
1478             my @mandirs = File::Spec->splitdir( $self->_expand_macros(
1479             $self->{ "INSTALL${installdirs}MAN${num}DIR" } ) );
1480 155   50     1672 my $mandir = pop @mandirs;
1481 155   100     1819 my $section = $num;
1482 155   50     1881  
1483 155   50     1074 foreach ($num, "${num}p", "${num}pm", qw< l n o C L >, "L$num") {
1484 155   50     915 if ( $mandir =~ /^(?:man|cat)$_$/ ) {
1485 155   100     801 $section = $_;
1486             last;
1487 155         308 }
  155         626  
1488 155         743 }
  0         0  
1489 155         1153  
1490             $self->{"MAN${num}SECTION"} = $section;
1491             }
1492             }
1493              
1494              
1495             my($self, $file) = @_;
1496              
1497             my($ispod)=0;
1498             if (open( my $fh, '<', $file )) {
1499             while (<$fh>) {
1500             if (/^=(?:head\d+|item|pod)\b/) {
1501 155     155 1 324 $ispod=1;
1502             last;
1503             }
1504 155         707 }
1505 310 100 100     3073 close $fh;
1506             } else {
1507             # If it doesn't exist yet, we assume, it has pods in it
1508 229   100     1353 $ispod = 1;
1509             }
1510              
1511 81         217 return $ispod;
1512 81         709 }
1513              
1514              
1515             =item init_MAN1PODS
1516              
1517 155         413 Initializes MAN1PODS from the list of EXE_FILES.
1518 310         754  
1519 310 100       769 =cut
1520              
1521 310         2545 my($self) = @_;
1522 310         752  
1523 310         529 if ( exists $self->{EXE_FILES} ) {
1524             foreach my $name (@{$self->{EXE_FILES}}) {
1525 310         912 next unless $self->_has_pod($name);
1526 2605 100       35116  
1527 48         155 $self->{MAN1PODS}->{$name} =
1528 48         123 $self->catfile("\$(INST_MAN1DIR)",
1529             basename($name).".\$(MAN1EXT)");
1530             }
1531             }
1532 310         1435 }
1533              
1534              
1535             =item init_MAN3PODS
1536              
1537             Initializes MAN3PODS from the list of PM files.
1538 42     42   136  
1539             =cut
1540 42         114  
1541 42 50       1640 my $self = shift;
1542 42         1182  
1543 211 100       858 my %manifypods = (); # we collect the keys first, i.e. the files
1544 22         51 # we have to convert to pod
1545 22         46  
1546             foreach my $name (keys %{$self->{PM}}) {
1547             if ($name =~ /\.pod\z/ ) {
1548 42         526 $manifypods{$name} = $self->{PM}{$name};
1549             } elsif ($name =~ /\.p[ml]\z/ ) {
1550             if( $self->_has_pod($name) ) {
1551 0         0 $manifypods{$name} = $self->{PM}{$name};
1552             }
1553             }
1554 42         398 }
1555              
1556             my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1557              
1558             # Remove "Configure.pm" and similar, if it's not the only pod listed
1559             # To force inclusion, just name it "Configure.pod", or override
1560             # MAN3PODS
1561             foreach my $name (keys %manifypods) {
1562             if (
1563             ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) or
1564             ( $name =~ m/^README\.pod$/i ) # don't manify top-level README.pod
1565 40     40 1 204 ) {
1566             delete $manifypods{$name};
1567 40 100       222 next;
1568 1         2 }
  1         4  
1569 1 50       9 my($manpagename) = $name;
1570             $manpagename =~ s/\.p(od|m|l)\z//;
1571 1         33 # everything below lib is ok
1572             unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1573             $manpagename = $self->catfile(
1574             split(/::/,$self->{PARENT_NAME}),$manpagename
1575             );
1576             }
1577             $manpagename = $self->replace_manpage_separator($manpagename);
1578             $self->{MAN3PODS}->{$name} =
1579             $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1580             }
1581             }
1582              
1583              
1584             =item init_PM
1585              
1586 41     41 1 109 Initializes PMLIBDIRS and PM from PMLIBDIRS.
1587              
1588 41         89 =cut
1589              
1590             my $self = shift;
1591 41         80  
  41         176  
1592 41 50       295 # Some larger extensions often wish to install a number of *.pm/pl
    50          
1593 0         0 # files into the library in various locations.
1594              
1595 41 100       243 # The attribute PMLIBDIRS holds an array reference which lists
1596 21         105 # subdirectories which we should search for library files to
1597             # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1598             # recursively search through the named directories (skipping any
1599             # which don't exist or contain Makefile.PL files).
1600              
1601 41         137 # For each *.pm or *.pl file found $self->libscan() is called with
  41         171  
1602             # the default installation path in $_[1]. The return value of
1603             # libscan defines the actual installation location. The default
1604             # libscan function simply returns the path. The file is skipped
1605             # if libscan returns false.
1606 41         202  
1607 21 50 33     162 # The default installation location passed to libscan in $_[1] is:
      33        
1608             #
1609             # ./*.pm => $(INST_LIBDIR)/*.pm
1610             # ./xyz/... => $(INST_LIBDIR)/xyz/...
1611 0         0 # ./lib/... => $(INST_LIB)/...
1612 0         0 #
1613             # In this way the 'lib' directory is seen as the root of the actual
1614 21         71 # perl library whereas the others are relative to INST_LIBDIR
1615 21         145 # (which includes PARENT_NAME). This is a subtle distinction but one
1616             # that's important for nested modules.
1617 21 50       286  
1618             unless( $self->{PMLIBDIRS} ) {
1619 0         0 if( $Is{VMS} ) {
1620             # Avoid logical name vs directory collisions
1621             $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1622 21         260 }
1623 21         117 else {
1624             $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1625             }
1626             }
1627              
1628             #only existing directories that aren't in $dir are allowed
1629              
1630             # Avoid $_ wherever possible:
1631             # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1632             my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1633             @{$self->{PMLIBDIRS}} = ();
1634             my %dir = map { ($_ => $_) } @{$self->{DIR}};
1635             foreach my $pmlibdir (@pmlibdirs) {
1636 155     155 1 376 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1637             }
1638              
1639             unless( $self->{PMLIBPARENTDIRS} ) {
1640             @{$self->{PMLIBPARENTDIRS}} = ('lib');
1641             }
1642              
1643             return if $self->{PM} and $self->{ARGS}{PM};
1644              
1645             if (@{$self->{PMLIBDIRS}}){
1646             print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1647             if ($Verbose >= 2);
1648             require File::Find;
1649             File::Find::find(sub {
1650             if (-d $_){
1651             unless ($self->libscan($_)){
1652             $File::Find::prune = 1;
1653             }
1654             return;
1655             }
1656             return if /\#/;
1657             return if /~$/; # emacs temp files
1658             return if /,v$/; # RCS files
1659             return if m{\.swp$}; # vim swap files
1660              
1661             my $path = $File::Find::name;
1662             my $prefix = $self->{INST_LIBDIR};
1663             my $striplibpath;
1664 155 50       509  
1665 155 50       453 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1666             $prefix = $self->{INST_LIB}
1667 0         0 if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W}
1668             {$1}i;
1669              
1670 155         637 my($inst) = $self->catfile($prefix,$striplibpath);
1671             local($_) = $inst; # for backwards compatibility
1672             $inst = $self->libscan($inst);
1673             print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1674             return unless $inst;
1675             if ($self->{XSMULTI} and $inst =~ /\.xs\z/) {
1676             my($base); ($base = $path) =~ s/\.xs\z//;
1677             $self->{XS}{$path} = "$base.c";
1678 155         266 push @{$self->{C}}, "$base.c";
  155         489  
1679 155         306 push @{$self->{O_FILES}}, "$base$self->{OBJ_EXT}";
  155         385  
1680 155         247 } else {
  58         222  
  155         449  
1681 155         621 $self->{PM}{$path} = $inst;
1682 310 100 66     3756 }
  123         481  
1683             }, @{$self->{PMLIBDIRS}});
1684             }
1685 155 50       530 }
1686 155         281  
  155         527  
1687              
1688             =item init_DIRFILESEP
1689 155 100 66     1038  
1690             Using / for Unix. Called by init_main.
1691 154 100       281  
  154         511  
1692 122 50       332 =cut
  0         0  
1693              
1694 122         935 my($self) = shift;
1695              
1696 366 100   366   3939 $self->{DIRFILESEP} = '/';
1697 244 50       1119 }
1698 0         0  
1699              
1700 244         20191 =item init_main
1701              
1702 122 50       544 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1703 122 50       392 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1704 122 50       338 INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1705 122 50       374 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1706             PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1707 122         254 VERSION_SYM, XS_VERSION.
1708 122         269  
1709 122         211 =cut
1710              
1711 122         210 my($self) = @_;
  122         567  
1712              
1713 122 50       2275 # --- Initialize Module Name and Paths
1714              
1715 122         588 # NAME = Foo::Bar::Oracle
1716 122         319 # FULLEXT = Foo/Bar/Oracle
1717 122         311 # BASEEXT = Oracle
1718 122 50       386 # PARENT_NAME = Foo::Bar
1719 122 50       315 ### Only UNIX:
1720 122 50 33     471 ### ($self->{FULLEXT} =
1721 0         0 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
  0         0  
1722 0         0 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1723 0         0  
  0         0  
1724 0         0  
  0         0  
1725             # Copied from DynaLoader:
1726 122         4217  
1727             my(@modparts) = split(/::/,$self->{NAME});
1728 122         1003 my($modfname) = $modparts[-1];
  122         13273  
1729              
1730             # Some systems have restrictions on files names for DLL's etc.
1731             # mod2fname returns appropriate file base name (typically truncated)
1732             # It may also edit @modparts if required.
1733             # We require DynaLoader to make sure that mod2fname is loaded
1734             eval { require DynaLoader };
1735             if (defined &DynaLoader::mod2fname) {
1736             $modfname = &DynaLoader::mod2fname(\@modparts);
1737             }
1738              
1739             ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1740 155     155 1 514 $self->{PARENT_NAME} ||= '';
1741              
1742 155         1190 if (defined &DynaLoader::mod2fname) {
1743             # As of 5.001m, dl_os2 appends '_'
1744             $self->{DLBASE} = $modfname;
1745             } else {
1746             $self->{DLBASE} = '$(BASEEXT)';
1747             }
1748              
1749              
1750             # --- Initialize PERL_LIB, PERL_SRC
1751              
1752             # *Real* information: where did we get these two from? ...
1753             my $inc_config_dir = dirname($INC{'Config.pm'});
1754             my $inc_carp_dir = dirname($INC{'Carp.pm'});
1755              
1756             unless ($self->{PERL_SRC}){
1757             foreach my $dir_count (1..8) { # 8 is the VMS limit for nesting
1758 155     155 1 445 my $dir = $self->catdir(($Updir) x $dir_count);
1759              
1760             if (-f $self->catfile($dir,"config_h.SH") &&
1761             -f $self->catfile($dir,"perl.h") &&
1762             -f $self->catfile($dir,"lib","strict.pm")
1763             ) {
1764             $self->{PERL_SRC}=$dir ;
1765             last;
1766             }
1767             }
1768             }
1769 155         2190  
1770             warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1771             $self->{PERL_CORE} and !$self->{PERL_SRC};
1772              
1773             if ($self->{PERL_SRC}){
1774 155         1193 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1775 155         454  
1776             $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1777             $self->{PERL_INC} = ($Is{Win32}) ?
1778             $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1779              
1780             # catch a situation that has occurred a few times in the past:
1781 155         345 unless (
  155         792  
1782 155 50       542 -s $self->catfile($self->{PERL_SRC},'cflags')
1783 0         0 or
1784             $Is{VMS}
1785             &&
1786 155         2195 -s $self->catfile($self->{PERL_SRC},'vmsish.h')
1787 155   100     576 or
1788             $Is{Win32}
1789 155 50       447 ){
1790             warn qq{
1791 0         0 You cannot build extensions below the perl source tree after executing
1792             a 'make clean' in the perl source tree.
1793 155         715  
1794             To rebuild extensions distributed with the perl source you should
1795             simply Configure (to include those extensions) and then build perl as
1796             normal. After installing perl the source tree can be deleted. It is
1797             not needed for building extensions by running 'perl Makefile.PL'
1798             usually without extra arguments.
1799              
1800 155         12071 It is recommended that you unpack and build additional extensions away
1801 155         3565 from the perl source tree.
1802             };
1803 155 50       590 }
1804 155         664 } else {
1805 1240         7014 # we should also consider $ENV{PERL5LIB} here
1806             my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1807 1240 0 33     5034 $self->{PERL_LIB} ||= $Config{privlibexp};
      33        
1808             $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1809             $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1810             my $perl_h;
1811 0         0  
1812 0         0 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1813             and not $old){
1814             # Maybe somebody tries to build an extension with an
1815             # uninstalled Perl outside of Perl build tree
1816             my $lib;
1817             for my $dir (@INC) {
1818 155 50 33     682 $lib = $dir, last if -e $self->catfile($dir, "Config.pm");
1819             }
1820 155 50       490 if ($lib) {
1821 0   0     0 # Win32 puts its header files in /perl/src/lib/CORE.
1822             # Unix leaves them in /perl/src.
1823 0         0 my $inc = $Is{Win32} ? $self->catdir($lib, "CORE" )
1824             : dirname $lib;
1825 0 0       0 if (-e $self->catfile($inc, "perl.h")) {
1826             $self->{PERL_LIB} = $lib;
1827             $self->{PERL_ARCHLIB} = $lib;
1828 0 0 0     0 $self->{PERL_INC} = $inc;
      0        
      0        
1829             $self->{UNINSTALLED_PERL} = 1;
1830             print <<EOP;
1831             ... Detected uninstalled Perl. Trying to continue.
1832             EOP
1833             }
1834             }
1835             }
1836             }
1837 0         0  
1838             if ($Is{Android}) {
1839             # Android fun times!
1840             # ../../perl -I../../lib -MFile::Glob -e1 works
1841             # ../../../perl -I../../../lib -MFile::Glob -e1 fails to find
1842             # the .so for File::Glob.
1843             # This always affects core perl, but may also affect an installed
1844             # perl built with -Duserelocatableinc.
1845             $self->{PERL_LIB} = File::Spec->rel2abs($self->{PERL_LIB});
1846             $self->{PERL_ARCHLIB} = File::Spec->rel2abs($self->{PERL_ARCHLIB});
1847             }
1848             $self->{PERL_INCDEP} = $self->{PERL_INC};
1849             $self->{PERL_ARCHLIBDEP} = $self->{PERL_ARCHLIB};
1850              
1851             # We get SITELIBEXP and SITEARCHEXP directly via
1852             # Get_from_Config. When we are running standard modules, these
1853 155   66     1865 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1854 155   33     1732 # set it to "site". I prefer that INSTALLDIRS be set from outside
1855 155   66     994 # MakeMaker.
1856 155         1436 $self->{INSTALLDIRS} ||= "site";
1857 155         458  
1858             $self->{MAN1EXT} ||= $Config{man1ext};
1859 155 0 33     620 $self->{MAN3EXT} ||= $Config{man3ext};
1860              
1861             # Get some stuff out of %Config if we haven't yet done so
1862             print "CONFIG must be an array ref\n"
1863 0         0 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1864 0         0 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1865 0 0       0 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1866             push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1867 0 0       0 my(%once_only);
1868             foreach my $m (@{$self->{CONFIG}}){
1869             next if $once_only{$m};
1870 0 0       0 print "CONFIG key '$m' does not exist in Config.pm\n"
1871             unless exists $Config{$m};
1872 0 0       0 $self->{uc $m} ||= $Config{$m};
1873 0         0 $once_only{$m} = 1;
1874 0         0 }
1875 0         0  
1876 0         0 # This is too dangerous:
1877 0         0 # if ($^O eq "next") {
1878             # $self->{AR} = "libtool";
1879             # $self->{AR_STATIC_ARGS} = "-o";
1880             # }
1881             # But I leave it as a placeholder
1882              
1883             $self->{AR_STATIC_ARGS} ||= "cr";
1884              
1885 155 50       737 # These should never be needed
1886             $self->{OBJ_EXT} ||= '.o';
1887             $self->{LIB_EXT} ||= '.a';
1888              
1889             $self->{MAP_TARGET} ||= "perl";
1890              
1891             $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1892 0         0  
1893 0         0 # make a simple check if we find strict
1894             warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1895 155         549 (strict.pm not found)"
1896 155         368 unless -f $self->catfile("$self->{PERL_LIB}","strict.pm") ||
1897             $self->{NAME} eq "ExtUtils::MakeMaker";
1898             }
1899              
1900             =item init_tools
1901              
1902             Initializes tools to use their common (and faster) Unix commands.
1903 155   100     1337  
1904             =cut
1905 155   66     1274  
1906 155   33     921 my $self = shift;
1907              
1908             $self->{ECHO} ||= 'echo';
1909             $self->{ECHO_N} ||= 'echo -n';
1910 155 50 33     479 $self->{RM_F} ||= "rm -f";
1911 155 50       832 $self->{RM_RF} ||= "rm -rf";
1912 155         349 $self->{TOUCH} ||= "touch";
  155         1517  
1913 155 50       531 $self->{TEST_F} ||= "test -f";
  0         0  
1914 155         267 $self->{TEST_S} ||= "test -s";
1915 155         304 $self->{CP} ||= "cp";
  155         427  
1916 3565 50       5912 $self->{MV} ||= "mv";
1917             $self->{CHMOD} ||= "chmod";
1918 3565 50       6657 $self->{FALSE} ||= 'false';
1919 3565   100     14195 $self->{TRUE} ||= 'true';
1920 3565         8085  
1921             $self->{LD} ||= 'ld';
1922              
1923             return $self->SUPER::init_tools(@_);
1924              
1925             # After SUPER::init_tools so $Config{shell} has a
1926             # chance to get set.
1927             $self->{SHELL} ||= '/bin/sh';
1928              
1929             return;
1930 155   50     1243 }
1931              
1932              
1933 155   50     414 =item init_linker
1934 155   50     380  
1935             Unix has no need of special linker flags.
1936 155   100     970  
1937             =cut
1938 155   33     1254  
1939             my($self) = shift;
1940             $self->{PERL_ARCHIVE} ||= '';
1941             $self->{PERL_ARCHIVEDEP} ||= '';
1942             $self->{PERL_ARCHIVE_AFTER} ||= '';
1943             $self->{EXPORT_LIST} ||= '';
1944 155 50 33     812 }
1945              
1946              
1947             =begin _protected
1948              
1949             =item init_lib2arch
1950              
1951             $mm->init_lib2arch
1952              
1953             =end _protected
1954 156     156 1 485  
1955             =cut
1956 156   50     2335  
1957 156   50     1611 my($self) = shift;
1958 156   50     1166  
1959 156   50     1518 # The user who requests an installation directory explicitly
1960 156   50     1375 # should not have to tell us an architecture installation directory
1961 156   50     1269 # as well. We look if a directory exists that is named after the
1962 156   50     1306 # architecture. If not we take it as a sign that it should be the
1963 156   50     1401 # same as the requested installation directory. Otherwise we take
1964 156   50     811 # the found one.
1965 156   50     1093 for my $libpair ({l=>"privlib", a=>"archlib"},
1966 156   50     1496 {l=>"sitelib", a=>"sitearch"},
1967 156   50     1139 {l=>"vendorlib", a=>"vendorarch"},
1968             )
1969 156   100     442 {
1970             my $lib = "install$libpair->{l}";
1971 156         1804 my $Lib = uc $lib;
1972             my $Arch = uc "install$libpair->{a}";
1973             if( $self->{$Lib} && ! $self->{$Arch} ){
1974             my($ilib) = $Config{$lib};
1975 0   0     0  
1976             $self->prefixify($Arch,$ilib,$self->{$Lib});
1977 0         0  
1978             unless (-d $self->{$Arch}) {
1979             print "Directory $self->{$Arch} not found\n"
1980             if $Verbose;
1981             $self->{$Arch} = $self->{$Lib};
1982             }
1983             print "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1984             }
1985             }
1986             }
1987              
1988 156     156 1 404  
1989 156   50     2230 =item init_PERL
1990 156   50     1667  
1991 156   50     1050 $mm->init_PERL;
1992 156   50     1179  
1993             Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1994             *PERLRUN* permutations.
1995              
1996             PERL is allowed to be miniperl
1997             FULLPERL must be a complete perl
1998              
1999             ABSPERL is PERL converted to an absolute path
2000              
2001             *PERLRUN contains everything necessary to run perl, find it's
2002             libraries, etc...
2003              
2004             *PERLRUNINST is *PERLRUN + everything necessary to find the
2005             modules being built.
2006              
2007 153     153 1 390 =cut
2008              
2009             my($self) = shift;
2010              
2011             my @defpath = ();
2012             foreach my $component ($self->{PERL_SRC}, $self->path(),
2013             $Config{binexp})
2014             {
2015 153         2811 push @defpath, $component if defined $component;
2016             }
2017              
2018             # Build up a set of file names (not command names).
2019             my $thisperl = $self->canonpath($^X);
2020 459         1087 $thisperl .= $Config{exe_ext} unless
2021 459         769 # VMS might have a file version # at the end
2022 459         740 $Is{VMS} ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
2023 459 50 33     1253 : $thisperl =~ m/$Config{exe_ext}$/i;
2024 0         0  
2025             # We need a relative path to perl when in the core.
2026 0         0 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
2027              
2028 0 0       0 my @perls = ($thisperl);
2029 0 0       0 push @perls, map { "$_$Config{exe_ext}" }
2030             ("perl$Config{version}", 'perl5', 'perl');
2031 0         0  
2032             # miniperl has priority over all but the canonical perl when in the
2033 0 0       0 # core. Otherwise its a last resort.
2034             my $miniperl = "miniperl$Config{exe_ext}";
2035             if( $self->{PERL_CORE} ) {
2036             splice @perls, 1, 0, $miniperl;
2037             }
2038             else {
2039             push @perls, $miniperl;
2040             }
2041              
2042             $self->{PERL} ||=
2043             $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
2044              
2045             my $perl = $self->{PERL};
2046             $perl =~ s/^"//;
2047             my $has_mcr = $perl =~ s/^MCR\s*//;
2048             my $perlflags = '';
2049             my $stripped_perl;
2050             while ($perl) {
2051             ($stripped_perl = $perl) =~ s/"$//;
2052             last if -x $stripped_perl;
2053             last unless $perl =~ s/(\s+\S+)$//;
2054             $perlflags = $1.$perlflags;
2055             }
2056             $self->{PERL} = $stripped_perl;
2057             $self->{PERL} = 'MCR '.$self->{PERL} if $has_mcr || $Is{VMS};
2058              
2059             # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
2060 156     156 1 389 my $perl_name = 'perl';
2061             $perl_name = 'ndbgperl' if $Is{VMS} &&
2062 156         258 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
2063 156         3741  
2064             # XXX This logic is flawed. If "miniperl" is anywhere in the path
2065             # it will get confused. It should be fixed to work only on the filename.
2066 1716 100       3368 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
2067             unless ($self->{FULLPERL}) {
2068             ($self->{FULLPERL} = $self->{PERL}) =~ s/\Q$miniperl\E$/$perl_name$Config{exe_ext}/i;
2069             $self->{FULLPERL} = qq{"$self->{FULLPERL}"}.$perlflags;
2070 156         841 }
2071             # Can't have an image name with quotes, and findperl will have
2072             # already escaped spaces.
2073 156 50       1489 $self->{FULLPERL} =~ tr/"//d if $Is{VMS};
    50          
2074              
2075             # `dmake` can fail for image (aka, executable) names which start with double-quotes
2076             # * push quote inward by at least one character (or the drive prefix, if present)
2077 156 50       480 # * including any initial directory separator preserves the `file_name_is_absolute` property
2078             $self->{FULLPERL} =~ s/^"(\S(:\\|:)?)/$1"/ if $self->is_make_type('dmake');
2079 156         506  
2080 156         549 # Little hack to get around VMS's find_perl putting "MCR" in front
  468         1145  
2081             # sometimes.
2082             $self->{ABSPERL} = $self->{PERL};
2083             $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
2084             if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
2085 156         534 $self->{ABSPERL} = '$(PERL)';
2086 156 50       403 }
2087 0         0 else {
2088             $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
2089              
2090 156         318 # Quote the perl command if it contains whitespace
2091             $self->{ABSPERL} = $self->quote_literal($self->{ABSPERL})
2092             if $self->{ABSPERL} =~ /\s/;
2093              
2094 156   66     1996 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
2095             }
2096 156         1050 $self->{PERL} = qq{"$self->{PERL}"}.$perlflags;
2097 156         1581  
2098 156         1193 # Can't have an image name with quotes, and findperl will have
2099 156         788 # already escaped spaces.
2100 156         388 $self->{PERL} =~ tr/"//d if $Is{VMS};
2101 156         646  
2102 156         1176 # `dmake` can fail for image (aka, executable) names which start with double-quotes
2103 156 50       3581 # * push quote inward by at least one character (or the drive prefix, if present)
2104 0 0       0 # * including any initial directory separator preserves the `file_name_is_absolute` property
2105 0         0 $self->{PERL} =~ s/^"(\S(:\\|:)?)/$1"/ if $self->is_make_type('dmake');
2106              
2107 156         613 # Are we building the core?
2108 156 50 33     1929 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
2109             $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
2110              
2111 156         739 # Make sure perl can find itself before it's installed.
2112             my $lib_paths = $self->{UNINSTALLED_PERL} || $self->{PERL_CORE}
2113 156 0 33     713 ? ( $self->{PERL_ARCHLIB} && $self->{PERL_LIB} && $self->{PERL_ARCHLIB} ne $self->{PERL_LIB} ) ?
      33        
2114             q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"} : q{ "-I$(PERL_LIB)"}
2115             : undef;
2116             my $inst_lib_paths = $self->{INST_ARCHLIB} ne $self->{INST_LIB}
2117             ? 'RUN)'.$perlflags.' "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"'
2118 156 100       617 : 'RUN)'.$perlflags.' "-I$(INST_LIB)"';
2119 99         2556 # How do we run perl?
2120 99         831 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
2121             my $run = $perl.'RUN';
2122              
2123             $self->{$run} = qq{\$($perl)};
2124 156 50       587 $self->{$run} .= $lib_paths if $lib_paths;
2125              
2126             $self->{$perl.'RUNINST'} = '$('.$perl.$inst_lib_paths;
2127             }
2128              
2129 156 50       4392 return 1;
2130             }
2131              
2132              
2133 156         1180 =item init_platform
2134 156         808  
2135 156 50       3761 =item platform_constants
2136 156         930  
2137             Add MM_Unix_VERSION.
2138              
2139 0         0 =cut
2140              
2141             my($self) = shift;
2142              
2143 0 0       0 $self->{MM_Unix_VERSION} = $VERSION;
2144             $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2145 0 0       0 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2146             '-Dcalloc=Perl_calloc';
2147 156         1733  
2148             }
2149              
2150             my($self) = shift;
2151 156 50       811 my $make_frag = '';
2152              
2153             foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2154             {
2155             next unless defined $self->{$macro};
2156 156 50       874 $make_frag .= "$macro = $self->{$macro}\n";
2157             }
2158              
2159 156 100       1243 return $make_frag;
2160 156 100       837 }
2161              
2162              
2163             =item init_PERM
2164 156 0 33     2195  
    50 0        
2165             $mm->init_PERM
2166              
2167             Called by init_main. Initializes PERL_*
2168 156 50       943  
2169             =cut
2170              
2171 156         694 my($self) = shift;
2172 468         1296  
2173             $self->{PERM_DIR} = 755 unless defined $self->{PERM_DIR};
2174 468         2512 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2175 468 50       1722 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2176              
2177 468         2900 return 1;
2178             }
2179              
2180 156         3400  
2181             =item init_xs
2182              
2183             $mm->init_xs
2184              
2185             Sets up macros having to do with XS code. Currently just INST_STATIC,
2186             INST_DYNAMIC and INST_BOOT.
2187              
2188             =cut
2189              
2190             my $self = shift;
2191              
2192             if ($self->has_link_code()) {
2193 154     154 1 358 $self->{INST_STATIC} =
2194             $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2195 154         748 $self->{INST_DYNAMIC} =
2196 154         546 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2197             $self->{INST_BOOT} =
2198             $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2199             if ($self->{XSMULTI}) {
2200             my @exts = $self->_xs_list_basenames;
2201             my (@statics, @dynamics, @boots);
2202             for my $ext (@exts) {
2203 153     153 1 361 my ($v, $d, $f) = File::Spec->splitpath($ext);
2204 153         353 my @d = File::Spec->splitdir($d);
2205             shift @d if defined $d[0] and $d[0] eq 'lib';
2206 153         708 pop @d if $d[$#d] eq '';
2207             my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
2208 306 50       914 my $instfile = $self->catfile($instdir, $f);
2209 306         1094 push @statics, "$instfile\$(LIB_EXT)";
2210              
2211             # Dynamic library names may need special handling.
2212 153         583 my $dynfile = $instfile;
2213             eval { require DynaLoader };
2214             if (defined &DynaLoader::mod2fname) {
2215             $dynfile = $self->catfile($instdir, &DynaLoader::mod2fname([@d, $f]));
2216             }
2217              
2218             push @dynamics, "$dynfile.\$(DLEXT)";
2219             push @boots, "$instfile.bs";
2220             }
2221             $self->{INST_STATIC} = join ' ', @statics;
2222             $self->{INST_DYNAMIC} = join ' ', @dynamics;
2223             $self->{INST_BOOT} = join ' ', @boots;
2224             }
2225 155     155 1 385 } else {
2226             $self->{INST_STATIC} = '';
2227 155 50       666 $self->{INST_DYNAMIC} = '';
2228 155 50       546 $self->{INST_BOOT} = '';
2229 155 50       432 }
2230             }
2231 155         350  
2232             =item install (o)
2233              
2234             Defines the install target.
2235              
2236             =cut
2237              
2238             my($self, %attribs) = @_;
2239             my(@m);
2240              
2241             push @m, q{
2242             install :: pure_install doc_install
2243             $(NOECHO) $(NOOP)
2244              
2245 155     155 1 362 install_perl :: pure_perl_install doc_perl_install
2246             $(NOECHO) $(NOOP)
2247 155 50       1124  
2248             install_site :: pure_site_install doc_site_install
2249 0         0 $(NOECHO) $(NOOP)
2250              
2251 0         0 install_vendor :: pure_vendor_install doc_vendor_install
2252             $(NOECHO) $(NOOP)
2253 0         0  
2254 0 0       0 pure_install :: pure_$(INSTALLDIRS)_install
2255 0         0 $(NOECHO) $(NOOP)
2256 0         0  
2257 0         0 doc_install :: doc_$(INSTALLDIRS)_install
2258 0         0 $(NOECHO) $(NOOP)
2259 0         0  
2260 0 0 0     0 pure__install : pure_site_install
2261 0 0       0 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2262 0         0  
2263 0         0 doc__install : doc_site_install
2264 0         0 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2265              
2266             pure_perl_install :: all
2267 0         0 $(NOECHO) $(MOD_INSTALL) \
2268 0         0 };
  0         0  
2269 0 0       0  
2270 0         0 push @m,
2271             q{ read "}.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{" \
2272             write "}.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{" \
2273 0         0 } unless $self->{NO_PACKLIST};
2274 0         0  
2275             push @m,
2276 0         0 q{ "$(INST_LIB)" "$(DESTINSTALLPRIVLIB)" \
2277 0         0 "$(INST_ARCHLIB)" "$(DESTINSTALLARCHLIB)" \
2278 0         0 "$(INST_BIN)" "$(DESTINSTALLBIN)" \
2279             "$(INST_SCRIPT)" "$(DESTINSTALLSCRIPT)" \
2280             "$(INST_MAN1DIR)" "$(DESTINSTALLMAN1DIR)" \
2281 155         515 "$(INST_MAN3DIR)" "$(DESTINSTALLMAN3DIR)"
2282 155         424 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2283 155         536 "}.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{"
2284              
2285              
2286             pure_site_install :: all
2287             $(NOECHO) $(MOD_INSTALL) \
2288             };
2289             push @m,
2290             q{ read "}.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{" \
2291             write "}.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{" \
2292             } unless $self->{NO_PACKLIST};
2293              
2294 96     96 1 343 push @m,
2295 96         283 q{ "$(INST_LIB)" "$(DESTINSTALLSITELIB)" \
2296             "$(INST_ARCHLIB)" "$(DESTINSTALLSITEARCH)" \
2297 96         735 "$(INST_BIN)" "$(DESTINSTALLSITEBIN)" \
2298             "$(INST_SCRIPT)" "$(DESTINSTALLSITESCRIPT)" \
2299             "$(INST_MAN1DIR)" "$(DESTINSTALLSITEMAN1DIR)" \
2300             "$(INST_MAN3DIR)" "$(DESTINSTALLSITEMAN3DIR)"
2301             $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2302             "}.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{"
2303              
2304             pure_vendor_install :: all
2305             $(NOECHO) $(MOD_INSTALL) \
2306             };
2307             push @m,
2308             q{ read "}.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{" \
2309             write "}.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{" \
2310             } unless $self->{NO_PACKLIST};
2311              
2312             push @m,
2313             q{ "$(INST_LIB)" "$(DESTINSTALLVENDORLIB)" \
2314             "$(INST_ARCHLIB)" "$(DESTINSTALLVENDORARCH)" \
2315             "$(INST_BIN)" "$(DESTINSTALLVENDORBIN)" \
2316             "$(INST_SCRIPT)" "$(DESTINSTALLVENDORSCRIPT)" \
2317             "$(INST_MAN1DIR)" "$(DESTINSTALLVENDORMAN1DIR)" \
2318             "$(INST_MAN3DIR)" "$(DESTINSTALLVENDORMAN3DIR)"
2319              
2320             };
2321              
2322             push @m, q{
2323             doc_perl_install :: all
2324             $(NOECHO) $(NOOP)
2325              
2326             doc_site_install :: all
2327             $(NOECHO) $(NOOP)
2328              
2329 96 50       760 doc_vendor_install :: all
2330             $(NOECHO) $(NOOP)
2331 96         861  
2332             } if $self->{NO_PERLLOCAL};
2333              
2334             push @m, q{
2335             doc_perl_install :: all
2336             $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod"
2337             -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)"
2338             -$(NOECHO) $(DOC_INSTALL) \
2339             "Module" "$(NAME)" \
2340             "installed into" "$(INSTALLPRIVLIB)" \
2341             LINKTYPE "$(LINKTYPE)" \
2342             VERSION "$(VERSION)" \
2343             EXE_FILES "$(EXE_FILES)" \
2344             >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{"
2345              
2346             doc_site_install :: all
2347             $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod"
2348 96 50       616 -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)"
2349             -$(NOECHO) $(DOC_INSTALL) \
2350 96         661 "Module" "$(NAME)" \
2351             "installed into" "$(INSTALLSITELIB)" \
2352             LINKTYPE "$(LINKTYPE)" \
2353             VERSION "$(VERSION)" \
2354             EXE_FILES "$(EXE_FILES)" \
2355             >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{"
2356              
2357             doc_vendor_install :: all
2358             $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod"
2359             -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)"
2360             -$(NOECHO) $(DOC_INSTALL) \
2361             "Module" "$(NAME)" \
2362             "installed into" "$(INSTALLVENDORLIB)" \
2363             LINKTYPE "$(LINKTYPE)" \
2364             VERSION "$(VERSION)" \
2365             EXE_FILES "$(EXE_FILES)" \
2366 96 50       526 >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{"
2367              
2368 96         404 } unless $self->{NO_PERLLOCAL};
2369              
2370             push @m, q{
2371             uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2372             $(NOECHO) $(NOOP)
2373              
2374             uninstall_from_perldirs ::
2375             $(NOECHO) $(UNINSTALL) "}.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{"
2376              
2377             uninstall_from_sitedirs ::
2378             $(NOECHO) $(UNINSTALL) "}.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{"
2379              
2380             uninstall_from_vendordirs ::
2381             $(NOECHO) $(UNINSTALL) "}.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{"
2382             };
2383              
2384             join("",@m);
2385             }
2386              
2387             =item installbin (o)
2388 96 50       337  
2389             Defines targets to make and to install EXE_FILES.
2390              
2391             =cut
2392              
2393             my($self) = shift;
2394              
2395             return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2396             my @exefiles = sort @{$self->{EXE_FILES}};
2397             return "" unless @exefiles;
2398              
2399             @exefiles = map vmsify($_), @exefiles if $Is{VMS};
2400              
2401             my %fromto;
2402             for my $from (@exefiles) {
2403             my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2404              
2405             local($_) = $path; # for backwards compatibility
2406             my $to = $self->libscan($path);
2407             print "libscan($from) => '$to'\n" if ($Verbose >=2);
2408              
2409             $to = vmsify($to) if $Is{VMS};
2410             $fromto{$from} = $to;
2411             }
2412             my @to = sort values %fromto;
2413              
2414             my @m;
2415             push(@m, qq{
2416             EXE_FILES = @exefiles
2417              
2418             pure_all :: @to
2419             \$(NOECHO) \$(NOOP)
2420              
2421             realclean ::
2422             });
2423              
2424 96 50       451 # realclean can get rather large.
2425             push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2426 96         520 push @m, "\n";
2427              
2428             # A target for each exe file.
2429             my @froms = sort keys %fromto;
2430             for my $from (@froms) {
2431             # 1 2
2432             push @m, _sprintf562 <<'MAKE', $from, $fromto{$from};
2433             %2$s : %1$s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2434             $(NOECHO) $(RM_F) %2$s
2435             $(CP) %1$s %2$s
2436             $(FIXIN) %2$s
2437             -$(NOECHO) $(CHMOD) $(PERM_RWX) %2$s
2438              
2439             MAKE
2440 96         2061  
2441             }
2442              
2443             join "", @m;
2444             }
2445              
2446             =item linkext (o)
2447              
2448             Defines the linkext target which in turn defines the LINKTYPE.
2449              
2450 153     153 1 356 =cut
2451              
2452 153 100 66     895 # LINKTYPE => static or dynamic or ''
2453 1         2 my($self, %attribs) = @_;
  1         4  
2454 1 50       4 my $linktype = $attribs{LINKTYPE};
2455             $linktype = $self->{LINKTYPE} unless defined $linktype;
2456 1 50       4 if (defined $linktype and $linktype eq '') {
2457             warn "Warning: LINKTYPE set to '', no longer necessary\n";
2458 1         2 }
2459 1         6 $linktype = '$(LINKTYPE)' unless defined $linktype;
2460 1         66 "
2461             linkext :: $linktype
2462 1         4 \$(NOECHO) \$(NOOP)
2463 1         3 ";
2464 1 50       4 }
2465              
2466 1 50       3 =item lsdir
2467 1         8  
2468             Takes as arguments a directory name and a regular expression. Returns
2469 1         4 all entries in the directory that match the regular expression.
2470              
2471 1         2 =cut
2472 1         7  
2473             # $self
2474             my(undef, $dir, $regex) = @_;
2475             opendir(my $dh, defined($dir) ? $dir : ".")
2476             or return;
2477             my @ls = readdir $dh;
2478             closedir $dh;
2479             @ls = grep(/$regex/, @ls) if defined $regex;
2480             @ls;
2481             }
2482 1         4  
2483 1         2 =item macro (o)
2484              
2485             Simple subroutine to insert the macros defined by the macro attribute
2486 1         5 into the Makefile.
2487 1         3  
2488             =cut
2489 1         12  
2490             my($self,%attribs) = @_;
2491             my @m;
2492             foreach my $key (sort keys %attribs) {
2493             my $val = $attribs{$key};
2494             push @m, "$key = $val\n";
2495             }
2496             join "", @m;
2497             }
2498              
2499             =item makeaperl (o)
2500 1         6  
2501             Called by staticmake. Defines how to write the Makefile to produce a
2502             static new perl.
2503              
2504             By default the Makefile produced includes all the static extensions in
2505             the perl library. (Purified versions of library files, e.g.,
2506             DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2507              
2508             =cut
2509              
2510             my($self, %attribs) = @_;
2511 153     153 1 414 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2512 153         337 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2513 153 50       493 s/^(.*)/"-I$1"/ for @{$perlinc || []};
2514 153 50 33     1109 my(@m);
2515 0         0 push @m, "
2516             # --- MakeMaker makeaperl section ---
2517 153 50       420 MAP_TARGET = $target
2518 153         862 FULLPERL = $self->{FULLPERL}
2519             MAP_PERLINC = @{$perlinc || []}
2520             ";
2521             return join '', @m if $self->{PARENT};
2522              
2523             my($dir) = join ":", @{$self->{DIR}};
2524              
2525             unless ($self->{MAKEAPERL}) {
2526             push @m, q{
2527             $(MAP_TARGET) :: $(MAKE_APERL_FILE)
2528             $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
2529              
2530             $(MAKE_APERL_FILE) : static $(FIRST_MAKEFILE) pm_to_blib
2531             $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2532             $(NOECHO) $(PERLRUNINST) \
2533 323     323 1 1041 Makefile.PL DIR="}, $dir, q{" \
2534 323 50       11544 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
    100          
2535             MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2536 299         18041  
2537 299         3446 foreach (@ARGV){
2538 299 100       4463 my $arg = $_; # avoid lvalue aliasing
2539 299         6611 if ( $arg =~ /(^.*?=)(.*['\s].*)/ ) {
2540             $arg = $1 . $self->quote_literal($2);
2541             }
2542             push @m, " \\\n\t\t$arg";
2543             }
2544             push @m, "\n";
2545              
2546             return join '', @m;
2547             }
2548              
2549             my $cccmd = $self->const_cccmd($libperl);
2550 153     153 1 438 $cccmd =~ s/^CCCMD\s*=\s*//;
2551 153         260 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2552 153         853 $cccmd .= " $Config{cccdlflags}"
2553 0         0 if ($Config{useshrplib} eq 'true');
2554 0         0 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2555              
2556 153         829 # The front matter of the linkcommand...
2557             my $linkcmd = join ' ', "\$(CC)",
2558             grep($_, @Config{qw(ldflags ccdlflags)});
2559             $linkcmd =~ s/\s+/ /g;
2560             $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2561              
2562             # Which *.a files could we make use of...
2563             my $staticlib21 = $self->_find_static_libs($searchdirs);
2564             # We trust that what has been handed in as argument, will be buildable
2565             $static = [] unless $static;
2566             @$staticlib21{@{$static}} = (1) x @{$static};
2567              
2568             $extra = [] unless $extra && ref $extra eq 'ARRAY';
2569             for (sort keys %$staticlib21) {
2570             next unless /\Q$self->{LIB_EXT}\E\z/;
2571 154     154 1 2333 $_ = dirname($_) . "/extralibs.ld";
2572             push @$extra, $_;
2573 154         1018 }
2574 154 100       326  
  154         3165  
2575 154         343 s/^(.*)/"-I$1"/ for @{$perlinc || []};
2576 154         769  
2577             $target ||= "perl";
2578             $tmp ||= ".";
2579              
2580 154 100       877 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2581             # regenerate the Makefiles, MAP_STATIC and the dependencies for
2582 154 100       1047 # extralibs.all are computed correctly
2583             my @map_static = reverse sort keys %$staticlib21;
2584 97         210 push @m, "
  97         351  
2585             MAP_LINKCMD = $linkcmd
2586 97 50       344 MAP_STATIC = ", join(" \\\n\t", map { qq{"$_"} } @map_static), "
2587 97         710 MAP_STATICDEP = ", join(' ', map { $self->quote_dep($_) } @map_static), "
2588              
2589             MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2590             ";
2591              
2592             my $lperl;
2593             if (defined $libperl) {
2594             ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2595             }
2596             unless ($libperl && -f $lperl) { # Ilya's code...
2597             my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2598 97         327 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2599 1         2 $libperl ||= "libperl$self->{LIB_EXT}";
2600 1 50       11 $libperl = "$dir/$libperl";
2601 1         5 $lperl ||= "libperl$self->{LIB_EXT}";
2602             $lperl = "$dir/$lperl";
2603 1         3  
2604             if (! -f $libperl and ! -f $lperl) {
2605 97         423 # We did not find a static libperl. Maybe there is a shared one?
2606             if ($Is{SunOS}) {
2607 97         1314 $lperl = $libperl = "$dir/$Config{libperl}";
2608             # SUNOS ld does not take the full path to a shared library
2609             $libperl = '' if $Is{SunOS4};
2610 0         0 }
2611 0         0 }
2612 0         0  
2613             print <<EOF unless -f $lperl || defined($self->{PERL_SRC});
2614 0 0       0 Warning: $libperl not found
2615 0         0 If you're going to build a static perl binary, make sure perl is installed
2616             otherwise ignore this warning
2617             EOF
2618             }
2619 0         0  
2620 0         0 # SUNOS ld does not take the full path to a shared library
2621 0         0 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2622             my $libperl_dep = $self->quote_dep($libperl);
2623              
2624 0         0 push @m, "
2625             MAP_LIBPERL = $libperl
2626 0 0       0 MAP_LIBPERLDEP = $libperl_dep
2627 0         0 LLIBPERL = $llibperl
  0         0  
  0         0  
2628             ";
2629 0 0 0     0  
2630 0         0 push @m, '
2631 0 0       0 $(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
2632 0         0 $(NOECHO) $(RM_F) $@
2633 0         0 $(NOECHO) $(TOUCH) $@
2634             ';
2635              
2636 0 0       0 foreach my $catfile (@$extra){
  0         0  
2637             push @m, "\tcat $catfile >> \$\@\n";
2638 0   0     0 }
2639 0   0     0  
2640             my $ldfrom = $self->{XSMULTI} ? '' : '$(LDFROM)';
2641             # 1 2 3 4
2642             push @m, _sprintf562 <<'EOF', $tmp, $ldfrom, $self->xs_obj_opt('$@'), $makefilename;
2643             $(MAP_TARGET) :: %1$s/perlmain$(OBJ_EXT) $(MAP_LIBPERLDEP) $(MAP_STATICDEP) $(INST_ARCHAUTODIR)/extralibs.all
2644 0         0 $(MAP_LINKCMD) %2$s $(OPTIMIZE) %1$s/perlmain$(OBJ_EXT) %3$s $(MAP_STATIC) "$(LLIBPERL)" `cat $(INST_ARCHAUTODIR)/extralibs.all` $(MAP_PRELIBS)
2645             $(NOECHO) $(ECHO) "To install the new '$(MAP_TARGET)' binary, call"
2646             $(NOECHO) $(ECHO) " $(MAKE) $(USEMAKEFILE) %4$s inst_perl MAP_TARGET=$(MAP_TARGET)"
2647 0         0 $(NOECHO) $(ECHO) " $(MAKE) $(USEMAKEFILE) %4$s map_clean"
2648 0         0  
  0         0  
2649             %1$s/perlmain\$(OBJ_EXT): %1$s/perlmain.c
2650             EOF
2651             push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
2652              
2653 0         0 my $maybe_DynaLoader = $Config{usedl} ? 'q(DynaLoader)' : '';
2654 0 0       0 push @m, _sprintf562 <<'EOF', $tmp, $makefilename, $maybe_DynaLoader;
2655 0         0  
2656             %1$s/perlmain.c: %2$s
2657 0 0 0     0 $(NOECHO) $(ECHO) Writing $@
2658 0   0     0 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \
2659 0 0       0 -e "writemain(grep(s#.*/auto/##s, @ARGV), %3$s)" $(MAP_STATIC) > $@t
2660 0   0     0 $(MV) $@t $@
2661 0         0  
2662 0   0     0 EOF
2663 0         0 push @m, "\t", q{$(NOECHO) $(PERL) "$(INSTALLSCRIPT)/fixpmain"
2664             } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2665 0 0 0     0  
2666              
2667 0 0       0 push @m, q{
2668 0         0 doc_inst_perl :
2669             $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod"
2670 0 0       0 -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)"
2671             -$(NOECHO) $(DOC_INSTALL) \
2672             "Perl binary" "$(MAP_TARGET)" \
2673             MAP_STATIC "$(MAP_STATIC)" \
2674 0 0 0     0 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2675             MAP_LIBPERL "$(MAP_LIBPERL)" \
2676             >> "}.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{"
2677              
2678             };
2679              
2680             push @m, q{
2681             inst_perl : pure_inst_perl doc_inst_perl
2682 0 0       0  
2683 0         0 pure_inst_perl : $(MAP_TARGET)
2684             }.$self->{CP}.q{ $(MAP_TARGET) "}.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{"
2685 0         0  
2686             clean :: map_clean
2687              
2688             map_clean :
2689             }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2690             };
2691 0         0  
2692             join '', @m;
2693             }
2694              
2695             # utility method
2696             my ($self, $searchdirs) = @_;
2697 0         0 # don't use File::Spec here because on Win32 F::F still uses "/"
2698 0         0 my $installed_version = join('/',
2699             'auto', $self->{FULLEXT}, "$self->{BASEEXT}$self->{LIB_EXT}"
2700             );
2701 0 0       0 my %staticlib21;
2702             require File::Find;
2703 0         0 File::Find::find(sub {
2704             if ($File::Find::name =~ m{/auto/share\z}) {
2705             # in a subdir of auto/share, prune because e.g.
2706             # Alien::pkgconfig uses File::ShareDir to put .a files
2707             # there. do not want
2708             $File::Find::prune = 1;
2709             return;
2710             }
2711              
2712 0         0 return unless m/\Q$self->{LIB_EXT}\E$/;
2713              
2714 0 0       0 return unless -f 'extralibs.ld'; # this checks is a "proper" XS installation
2715 0         0  
2716             # Skip perl's libraries.
2717             return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2718              
2719             # Skip purified versions of libraries
2720             # (e.g., DynaLoader_pure_p1_c0_032.a)
2721             return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2722              
2723             if( exists $self->{INCLUDE_EXT} ){
2724 0 0 0     0 my $found = 0;
2725              
2726             (my $xx = $File::Find::name) =~ s,.*?/auto/,,s;
2727             $xx =~ s,/?$_,,;
2728 0         0 $xx =~ s,/,::,g;
2729              
2730             # Throw away anything not explicitly marked for inclusion.
2731             # DynaLoader is implied.
2732             foreach my $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2733             if( $xx eq $incl ){
2734             $found++;
2735             last;
2736             }
2737             }
2738             return unless $found;
2739             }
2740             elsif( exists $self->{EXCLUDE_EXT} ){
2741             (my $xx = $File::Find::name) =~ s,.*?/auto/,,s;
2742             $xx =~ s,/?$_,,;
2743             $xx =~ s,/,::,g;
2744              
2745             # Throw away anything explicitly marked for exclusion
2746             foreach my $excl (@{$self->{EXCLUDE_EXT}}){
2747             return if( $xx eq $excl );
2748             }
2749             }
2750 0         0  
2751             # don't include the installed version of this extension. I
2752             # leave this line here, although it is not necessary anymore:
2753 0         0 # I patched minimod.PL instead, so that Miniperl.pm won't
2754             # include duplicates
2755              
2756             # Once the patch to minimod.PL is in the distribution, I can
2757             # drop it
2758 0     0   0 return if $File::Find::name =~ m:\Q$installed_version\E\z:;
2759             return if !$self->xs_static_lib_is_xs($_);
2760             use Cwd 'cwd';
2761 0         0 $staticlib21{cwd() . "/" . $_}++;
2762             }, grep( -d $_, map { $self->catdir($_, 'auto') } @{$searchdirs || []}) );
2763 0         0 return \%staticlib21;
2764 0         0 }
2765              
2766 0 0   0   0 =item xs_static_lib_is_xs (o)
2767              
2768             Called by a utility method of makeaperl. Checks whether a given file
2769             is an XS library by seeing whether it defines any symbols starting
2770 0         0 with C<boot_> (with an optional leading underscore - needed on MacOS).
2771 0         0  
2772             =cut
2773              
2774 0 0       0 my ($self, $libfile) = @_;
2775             my $devnull = File::Spec->devnull;
2776 0 0       0 return `nm $libfile 2>$devnull` =~ /\b_?boot_/;
2777             }
2778              
2779 0 0 0     0 =item makefile (o)
2780              
2781             Defines how to rewrite the Makefile.
2782              
2783 0 0 0     0 =cut
2784              
2785 0 0       0 my($self) = shift;
    0          
2786 0         0 my $m;
2787             # We do not know what target was originally specified so we
2788 0         0 # must force a manual rerun to be sure. But as it should only
2789 0         0 # happen very rarely it is not a significant problem.
2790 0         0 $m = '
2791             $(OBJECT) : $(FIRST_MAKEFILE)
2792              
2793             ' if $self->{OBJECT};
2794 0         0  
  0         0  
2795 0 0       0 my $newer_than_target = $Is{VMS} ? '$(MMS$SOURCE_LIST)' : '$?';
2796 0         0 my $mpl_args = join " ", map qq["$_"], @ARGV;
2797 0         0 my $cross = '';
2798             if (defined $::Cross::platform) {
2799             # Inherited from win32/buildext.pl
2800 0 0       0 $cross = "-MCross=$::Cross::platform ";
2801             }
2802             $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $cross, $mpl_args;
2803 0         0 # We take a very conservative approach here, but it's worth it.
2804 0         0 # We move Makefile to Makefile.old here to avoid gnu make looping.
2805 0         0 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2806             $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
2807             $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2808 0         0 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
  0         0  
2809 0 0       0 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2810             - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2811             $(PERLRUN) %sMakefile.PL %s
2812             $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2813             $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
2814             $(FALSE)
2815              
2816             MAKE_FRAG
2817              
2818             return $m;
2819             }
2820 0 0       0  
2821 0 0       0  
2822 52     52   522 =item maybe_command
  52         113  
  52         52666  
2823 0         0  
2824 0 0       0 Returns true, if the argument is likely to be a command.
  0         0  
  0         0  
2825 0         0  
2826             =cut
2827              
2828             my($self,$file) = @_;
2829             return $file if -x $file && ! -d $file;
2830             return;
2831             }
2832              
2833              
2834             =item needs_linking (o)
2835              
2836             Does this module need linking? Looks into subdirectory objects (see
2837 0     0 1 0 also has_link_code())
2838 0         0  
2839 0         0 =cut
2840              
2841             my($self) = shift;
2842              
2843             my $caller = (caller(0))[3];
2844             confess("needs_linking called too early") if
2845             $caller =~ /^ExtUtils::MakeMaker::/;
2846             return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2847             if ($self->has_link_code or $self->{MAKEAPERL}){
2848             $self->{NEEDS_LINKING} = 1;
2849 153     153 1 378 return 1;
2850 153         245 }
2851             foreach my $child (keys %{$self->{CHILDREN}}) {
2852             if ($self->{CHILDREN}->{$child}->needs_linking) {
2853             $self->{NEEDS_LINKING} = 1;
2854             return 1;
2855             }
2856             }
2857 153 50       626 return $self->{NEEDS_LINKING} = 0;
2858             }
2859 153 50       1067  
2860 153         677  
2861 153         452 =item parse_abstract
2862 153 50       458  
2863             parse a file and return what you think is the ABSTRACT
2864 0         0  
2865             =cut
2866 153         1188  
2867             my($self,$parsefile) = @_;
2868             my $result;
2869              
2870             local $/ = "\n";
2871             open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!";
2872             binmode $fh;
2873             my $inpod = 0;
2874             my $pod_encoding;
2875             my $package = $self->{DISTNAME};
2876             $package =~ s/-/::/g;
2877             while (<$fh>) {
2878             $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2879             next if !$inpod;
2880             s#\r*\n\z##; # handle CRLF input
2881              
2882 153         639 if ( /^=encoding\s*(.*)$/i ) {
2883             $pod_encoding = $1;
2884             }
2885              
2886             if ( /^($package(?:\.pm)? \s+ -+ \s+)(.*)/x ) {
2887             $result = $2;
2888             next;
2889             }
2890             next unless $result;
2891              
2892             if ( $result && ( /^\s*$/ || /^\=/ ) ) {
2893 197     197 1 470 last;
2894 197 100 66     4118 }
2895 93         353 $result = join ' ', $result, $_;
2896             }
2897             close $fh;
2898              
2899             if ( $pod_encoding and !( "$]" < 5.008 or !$Config{useperlio} ) ) {
2900             # Have to wrap in an eval{} for when running under PERL_CORE
2901             # Encode isn't available during build phase and parsing
2902             # ABSTRACT isn't important there
2903             eval {
2904             require Encode;
2905             $result = Encode::decode($pod_encoding, $result);
2906             }
2907 1660     1660 1 2477 }
2908              
2909 1660         9413 return $result;
2910 1660 50       4902 }
2911              
2912 1660 100       9800 =item parse_version
2913 153 50 33     649  
2914 0         0 my $version = MM->parse_version($file);
2915 0         0  
2916             Parse a $file and return what $VERSION is set to by the first assignment.
2917 153         349 It will return the string "undef" if it can't figure out what $VERSION
  153         883  
2918 56 50       570 is. $VERSION should be for all to see, so C<our $VERSION> or plain $VERSION
2919 0         0 are okay, but C<my $VERSION> is not.
2920 0         0  
2921             C<package Foo VERSION> is also checked for. The first version
2922             declaration found is used, but this may change as it differs from how
2923 153         1343 Perl does it.
2924              
2925             parse_version() will try to C<use version> before checking for
2926             C<$VERSION> so the following will work.
2927              
2928             $VERSION = qv(1.2.3);
2929              
2930             =cut
2931              
2932             my($self,$parsefile) = @_;
2933             my $result;
2934 13     13 1 9810  
2935 13         22 local $/ = "\n";
2936             local $_;
2937 13         61 open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!";
2938 13 50       405 my $inpod = 0;
2939 13         41 while (<$fh>) {
2940 13         20 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2941 13         17 next if $inpod || /^\s*#/;
2942 13         40 chop;
2943 13         43 next if /^\s*(if|unless|elsif)/;
2944 13         163 if ( m{^ \s* package \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* (;|\{) }x ) {
2945 70 100       172 no warnings;
    100          
2946 70 100       118 $result = $1;
2947 52         157 }
2948             elsif ( m{(?<!\\) ([\$*]) (([\w\:\']*) \bVERSION)\b .* (?<![<>=!])\=[^=]}x ) {
2949 52 100       116 $result = $self->get_version($parsefile, $1, $2);
2950 1         8 }
2951             else {
2952             next;
2953 52 100       267 }
2954 13         38 last if defined $result;
2955 13         88 }
2956             close $fh;
2957 39 100       109  
2958             if ( defined $result && $result !~ /^v?[\d_\.]+$/ ) {
2959 5 100 66     38 require version;
      33        
2960 3         5 my $normal = eval { version->new( $result ) };
2961             $result = $normal if defined $normal;
2962 2         23 }
2963             if ( defined $result ) {
2964 13         130 $result = "undef" unless $result =~ m!^v?[\d_\.]+$!
2965             or eval { version->parse( $result ) };
2966 13 100 33     51 }
      66        
2967             $result = "undef" unless defined $result;
2968             return $result;
2969             }
2970 1         7  
2971 1         12 my ($self, $parsefile, $sigil, $name) = @_;
2972 1         26 my $line = $_; # from the while() loop in parse_version
2973             {
2974             undef *version; # in case of unexpected version() sub
2975             eval {
2976 13         191 require version;
2977             version::->import;
2978             };
2979             no strict;
2980             no warnings;
2981             local *{$name};
2982             $line = $1 if $line =~ m{^(.+)}s;
2983             eval($line); ## no critic
2984             return ${$name};
2985             }
2986              
2987             =item pasthru (o)
2988              
2989             Defines the string that is passed to recursive make calls in
2990             subdirectories. The variables like C<PASTHRU_DEFINE> are used in each
2991             level, and passed downwards on the command-line with e.g. the value of
2992             that level's DEFINE. Example:
2993              
2994             # Level 0 has DEFINE = -Dfunky
2995             # This code will define level 0's PASTHRU=PASTHRU_DEFINE="$(DEFINE)
2996             # $(PASTHRU_DEFINE)"
2997             # Level 0's $(CCCMD) will include macros $(DEFINE) and $(PASTHRU_DEFINE)
2998             # So will level 1's, so when level 1 compiles, it will get right values
2999             # And so ad infinitum
3000 155     155 1 82835  
3001 155         260 =cut
3002              
3003 155         1031 my($self) = shift;
3004 155         371 my(@m);
3005 155 50       6692  
3006 155         522 my(@pasthru);
3007 155         3069 my($sep) = $Is{VMS} ? ',' : '';
3008 355 50       1500 $sep .= "\\\n\t";
    50          
3009 355 50 33     1599  
3010 355         796 foreach my $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
3011 355 100       1146 PREFIX INSTALL_BASE)
3012 353 100       2348 )
    100          
3013 52     52   383 {
  52         104  
  52         17931  
3014 16         41 next unless defined $self->{$key};
3015             push @pasthru, "$key=\"\$($key)\"";
3016             }
3017 130         1876  
3018             foreach my $key (qw(DEFINE INC)) {
3019             # default to the make var
3020 207         579 my $val = qq{\$($key)};
3021             # expand within perl if given since need to use quote_literal
3022 146 100       496 # since INC might include space-protecting ""!
3023             chomp($val = $self->{$key}) if defined $self->{$key};
3024 155         2141 $val .= " \$(PASTHRU_$key)";
3025             my $quoted = $self->quote_literal($val);
3026 155 100 100     2226 push @pasthru, qq{PASTHRU_$key=$quoted};
3027 3         11 }
3028 3         6  
  3         20  
3029 3 100       9 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
3030             join "", @m;
3031 155 100       499 }
3032              
3033 142 100 66     892 =item perl_script
  2         10  
3034              
3035 155 100       457 Takes one argument, a file name, and returns the file name, if the
3036 155         1222 argument is likely to be a perl script. On MM_Unix this is true for
3037             any ordinary, readable file.
3038              
3039             =cut
3040 130     130 0 1052  
3041 130         429 my($self,$file) = @_;
3042             return $file if -r $file && -f _;
3043 130         215 return;
3044 130         669 }
3045 130         274  
3046 130         730 =item perldepend (o)
3047 130         1370  
3048             Defines the dependency from all *.h files that come with the perl
3049 52     52   369 distribution.
  52         123  
  52         1501  
3050 52     52   266  
  52         100  
  52         231148  
3051 130         6376 =cut
  130         578  
3052 130 50       1153  
3053 130     1   10596 my($self) = shift;
  1     1   10  
  1     1   6  
  1         2  
  1         3  
  1         4  
  1         2  
  1         2  
3054 130         584 my(@m);
  130         582  
3055              
3056             my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
3057              
3058             push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
3059             # Check for unpropogated config.sh changes. Should never happen.
3060             # We do NOT just update config.h because that is not sufficient.
3061             # An out of date config.h is not fatal but complains loudly!
3062             $(PERL_INCDEP)/config.h: $(PERL_SRC)/config.sh
3063             -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; $(FALSE)
3064              
3065             $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
3066             $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
3067             %s
3068             MAKE_FRAG
3069              
3070             return join "", @m unless $self->needs_linking;
3071              
3072             if ($self->{OBJECT}) {
3073             # Need to add an object file dependency on the perl headers.
3074             # this is very important for XS modules in perl.git development.
3075 153     153 1 344 push @m, $self->_perl_header_files_fragment("/"); # Directory separator between $(PERL_INC)/header.h
3076 153         467 }
3077              
3078             push @m, join(" ", sort values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
3079 153 50       765  
3080 153         388 return join "\n", @m;
3081             }
3082 153         731  
3083              
3084             =item pm_to_blib
3085              
3086 918 100       2040 Defines target that copies all files in the hash PM to their
3087 461         1259 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
3088              
3089             =cut
3090 153         369  
3091             my $self = shift;
3092 306         697 my($autodir) = $self->catdir('$(INST_LIB)','auto');
3093             my $r = q{
3094             pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)
3095 306 50       726 };
3096 306         622  
3097 306         682 # VMS will swallow '' and PM_FILTER is often empty. So use q[]
3098 306         1109 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
3099             pm_to_blib({\@ARGV}, '$autodir', q[\$(PM_FILTER)], '\$(PERM_DIR)')
3100             CODE
3101 153         1180  
3102 153         887 my @cmds = $self->split_command($pm_to_blib,
3103             map { ($self->quote_literal($_) => $self->quote_literal($self->{PM}->{$_})) } sort keys %{$self->{PM}});
3104              
3105             $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
3106             $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
3107              
3108             return $r;
3109             }
3110              
3111             # transform dot-separated version string into comma-separated quadruple
3112             # examples: '1.2.3.4.5' => '1,2,3,4'
3113             # '1.2.3' => '1,2,3,0'
3114 1     1 1 284 my ($self, $string) = @_;
3115 1 50 33     20 return join ',', ((split /\./, $string), (0) x 4)[0..3];
3116 0         0 }
3117              
3118             =item ppd
3119              
3120             Defines target that creates a PPD (Perl Package Description) file
3121             for a binary distribution.
3122              
3123             =cut
3124              
3125             my($self) = @_;
3126              
3127 153     153 1 344 my $abstract = $self->{ABSTRACT} || '';
3128 153         267 $abstract =~ s/\n/\\n/sg;
3129             $abstract =~ s/</&lt;/g;
3130 153         432 $abstract =~ s/>/&gt;/g;
3131              
3132 153 50       799 my $author = join(', ',@{ ref $self->{AUTHOR} eq 'ARRAY' ? $self->{AUTHOR} : [ $self->{AUTHOR} || '']});
3133             $author =~ s/</&lt;/g;
3134             $author =~ s/>/&gt;/g;
3135              
3136             my $ppd_file = "$self->{DISTNAME}.ppd";
3137              
3138             my @ppd_chunks = qq(<SOFTPKG NAME="$self->{DISTNAME}" VERSION="$self->{VERSION}">\n);
3139              
3140             push @ppd_chunks, sprintf <<'PPD_HTML', $abstract, $author;
3141             <ABSTRACT>%s</ABSTRACT>
3142             <AUTHOR>%s</AUTHOR>
3143             PPD_HTML
3144 153 50       549  
3145             push @ppd_chunks, " <IMPLEMENTATION>\n";
3146 0 0       0 if ( $self->{MIN_PERL_VERSION} ) {
3147             my $min_perl_version = $self->_ppd_version($self->{MIN_PERL_VERSION});
3148             push @ppd_chunks, sprintf <<'PPD_PERLVERS', $min_perl_version;
3149 0         0 <PERLCORE VERSION="%s" />
3150             PPD_PERLVERS
3151              
3152 0 0       0 }
  0         0  
  0         0  
3153              
3154 0         0 # Don't add "perl" to requires. perl dependencies are
3155             # handles by ARCHITECTURE.
3156             my %prereqs = %{$self->{PREREQ_PM}};
3157             delete $prereqs{perl};
3158              
3159             # Build up REQUIRE
3160             foreach my $prereq (sort keys %prereqs) {
3161             my $name = $prereq;
3162             $name .= '::' unless $name =~ /::/;
3163             my $version = $prereqs{$prereq};
3164              
3165             my %attrs = ( NAME => $name );
3166 153     153 1 319 $attrs{VERSION} = $version if $version;
3167 153         1252 my $attrs = join " ", map { qq[$_="$attrs{$_}"] } sort keys %attrs;
3168 153         724 push @ppd_chunks, qq( <REQUIRE $attrs />\n);
3169             }
3170              
3171             my $archname = $Config{archname};
3172              
3173 153         1114 # archname did not change from 5.6 to 5.8, but those versions may
3174             # not be not binary compatible so now we append the part of the
3175             # version that changes when binary compatibility may change
3176             if ("$]" >= 5.008) {
3177             $archname .= "-$Config{api_revision}.$Config{api_version}";
3178 153         455 }
  121         368  
  153         685  
3179             push @ppd_chunks, sprintf <<'PPD_OUT', $archname;
3180 153         529 <ARCHITECTURE NAME="%s" />
  121         806  
3181 153         387 PPD_OUT
3182              
3183 153         511 if ($self->{PPM_INSTALL_SCRIPT}) {
3184             if ($self->{PPM_INSTALL_EXEC}) {
3185             push @ppd_chunks, sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
3186             $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
3187             }
3188             else {
3189             push @ppd_chunks, sprintf qq{ <INSTALL>%s</INSTALL>\n},
3190 5     5   14 $self->{PPM_INSTALL_SCRIPT};
3191 5         42 }
3192             }
3193              
3194             if ($self->{PPM_UNINSTALL_SCRIPT}) {
3195             if ($self->{PPM_UNINSTALL_EXEC}) {
3196             push @ppd_chunks, sprintf qq{ <UNINSTALL EXEC="%s">%s</UNINSTALL>\n},
3197             $self->{PPM_UNINSTALL_EXEC}, $self->{PPM_UNINSTALL_SCRIPT};
3198             }
3199             else {
3200             push @ppd_chunks, sprintf qq{ <UNINSTALL>%s</UNINSTALL>\n},
3201             $self->{PPM_UNINSTALL_SCRIPT};
3202 153     153 1 521 }
3203             }
3204 153   100     1497  
3205 153         466 my ($bin_location) = $self->{BINARY_LOCATION} || '';
3206 153         295 $bin_location =~ s/\\/\\\\/g;
3207 153         343  
3208             push @ppd_chunks, sprintf <<'PPD_XML', $bin_location;
3209 153 100 100     324 <CODEBASE HREF="%s" />
  153         2069  
3210 153         482 </IMPLEMENTATION>
3211 153         297 </SOFTPKG>
3212             PPD_XML
3213 153         597  
3214             my @ppd_cmds = $self->stashmeta(join('', @ppd_chunks), $ppd_file);
3215 153         1422  
3216             return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3217 153         994 # Creates a PPD (Perl Package Description) for a binary distribution.
3218             ppd :
3219             %s
3220             PPD_OUT
3221              
3222 153         479 }
3223 153 100       695  
3224 5         50 =item prefixify
3225 5         16  
3226             $MM->prefixify($var, $prefix, $new_prefix, $default);
3227              
3228             Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3229             replace it's $prefix with a $new_prefix.
3230              
3231             Should the $prefix fail to match I<AND> a PREFIX was given as an
3232             argument to WriteMakefile() it will set it to the $new_prefix +
3233 153         308 $default. This is for systems whose file layouts don't neatly fit into
  153         593  
3234 153         345 our ideas of prefixes.
3235              
3236             This is for heuristics which attempt to create directory structures
3237 153         772 that mirror those of the installed perl.
3238 35         79  
3239 35 100       282 For example:
3240 35         156  
3241             $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3242 35         113  
3243 35 100       135 this will attempt to remove '/usr' from the front of the
3244 35         116 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
  53         244  
3245 35         224 if necessary) and replace it with '/home/foo'. If this fails it will
3246             simply use '/home/foo/man/man1'.
3247              
3248 153         656 =cut
3249              
3250             my($self,$var,$sprefix,$rprefix,$default) = @_;
3251              
3252             my $path = $self->{uc $var} ||
3253 153 50       1221 $Config_Override{lc $var} || $Config{lc $var} || '';
3254 153         875  
3255             $rprefix .= '/' if $sprefix =~ m|/$|;
3256 153         706  
3257             warn " prefixify $var => $path\n" if $Verbose >= 2;
3258             warn " from $sprefix to $rprefix\n" if $Verbose >= 2;
3259              
3260 153 50       524 if( $self->{ARGS}{PREFIX} &&
3261 0 0       0 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3262             {
3263 0         0  
3264             warn " cannot prefix, using default.\n" if $Verbose >= 2;
3265             warn " no default!\n" if !$default && $Verbose >= 2;
3266              
3267 0         0 $path = $self->catdir($rprefix, $default) if $default;
3268             }
3269              
3270             print " now $path\n" if $Verbose >= 2;
3271 153 50       473 return $self->{uc $var} = $path;
3272 0 0       0 }
3273              
3274 0         0  
3275             =item processPL (o)
3276              
3277             Defines targets to run *.PL files.
3278 0         0  
3279             =cut
3280              
3281             my $self = shift;
3282 153   50     1189 my $pl_files = $self->{PL_FILES};
3283 153         402  
3284             return "" unless $pl_files;
3285 153         654  
3286             my $m = '';
3287             foreach my $plfile (sort keys %$pl_files) {
3288             my $targets = $pl_files->{$plfile};
3289             my $list =
3290             ref($targets) eq 'HASH' ? [ sort keys %$targets ] :
3291 153         1128 ref($targets) eq 'ARRAY' ? $pl_files->{$plfile} :
3292             [$pl_files->{$plfile}];
3293 153         1810  
3294             foreach my $target (@$list) {
3295             if( $Is{VMS} ) {
3296             $plfile = vmsify($self->eliminate_macros($plfile));
3297             $target = vmsify($self->eliminate_macros($target));
3298             }
3299              
3300             # Normally a .PL file runs AFTER pm_to_blib so it can have
3301             # blib in its @INC and load the just built modules. BUT if
3302             # the generated module is something in $(TO_INST_PM) which
3303             # pm_to_blib depends on then it can't depend on pm_to_blib
3304             # else we have a dependency loop.
3305             my $pm_dep;
3306             my $perlrun;
3307             if( defined $self->{PM}{$target} ) {
3308             $pm_dep = '';
3309             $perlrun = 'PERLRUN';
3310             }
3311             else {
3312             $pm_dep = 'pm_to_blib';
3313             $perlrun = 'PERLRUNINST';
3314             }
3315              
3316             my $extra_inputs = '';
3317             if( ref($targets) eq 'HASH' ) {
3318             my $inputs = ref($targets->{$target})
3319             ? $targets->{$target}
3320             : [$targets->{$target}];
3321              
3322             for my $input (@$inputs) {
3323             if( $Is{VMS} ) {
3324             $input = vmsify($self->eliminate_macros($input));
3325             }
3326             $extra_inputs .= ' '.$input;
3327             }
3328 2221     2221 1 5328 }
3329              
3330             $m .= <<MAKE_FRAG;
3331 2221   100     11631  
3332             pure_all :: $target
3333 2221 50       4261 \$(NOECHO) \$(NOOP)
3334              
3335 2221 50       3367 $target :: $plfile $pm_dep $extra_inputs
3336 2221 50       2995 \$($perlrun) $plfile $target $extra_inputs
3337             MAKE_FRAG
3338 2221 100 100     4299  
3339             }
3340             }
3341              
3342 14 50       29 return $m;
3343 14 50 33     28 }
3344              
3345 14 50       73 =item specify_shell
3346              
3347             Specify SHELL if needed - not done on Unix.
3348 2221 50       3302  
3349 2221         5900 =cut
3350              
3351             return '';
3352             }
3353              
3354             =item quote_paren
3355              
3356             Backslashes parentheses C<()> in command line arguments.
3357             Doesn't handle recursive Makefile C<$(...)> constructs,
3358             but handles simple ones.
3359              
3360 153     153 1 370 =cut
3361 153         358  
3362             my $arg = shift;
3363 153 50       430 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3364             $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3365 153         456 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
3366 153         880 return $arg;
3367 0         0 }
3368              
3369             =item replace_manpage_separator
3370              
3371 0 0       0 my $man_name = $MM->replace_manpage_separator($file_path);
    0          
3372              
3373 0         0 Takes the name of a package, which may be a nested package, in the
3374 0 0       0 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3375 0         0 safe for a man page file name. Returns the replacement.
3376 0         0  
3377             =cut
3378              
3379             my($self,$man) = @_;
3380              
3381             $man =~ s,/+,::,g;
3382             return $man;
3383             }
3384 0         0  
3385              
3386 0 0       0 =item cd
3387 0         0  
3388 0         0 =cut
3389              
3390             my($self, $dir, @cmds) = @_;
3391 0         0  
3392 0         0 # No leading tab and no trailing newline makes for easier embedding
3393             my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3394              
3395 0         0 return $make_frag;
3396 0 0       0 }
3397              
3398             =item oneliner
3399 0 0       0  
3400             =cut
3401 0         0  
3402 0 0       0 my($self, $cmd, $switches) = @_;
3403 0         0 $switches = [] unless defined $switches;
3404              
3405 0         0 # Strip leading and trailing newlines
3406             $cmd =~ s{^\n+}{};
3407             $cmd =~ s{\n+$}{};
3408              
3409 0         0 my @cmds = split /\n/, $cmd;
3410             $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
3411             $cmd = $self->escape_newlines($cmd);
3412              
3413             $switches = join ' ', @$switches;
3414              
3415             return qq{\$(ABSPERLRUN) $switches -e $cmd --};
3416             }
3417              
3418              
3419             =item quote_literal
3420              
3421 153         623 Quotes macro literal value suitable for being used on a command line so
3422             that when expanded by make, will be received by command as given to
3423             this method:
3424              
3425             my $quoted = $mm->quote_literal(q{it isn't});
3426             # returns:
3427             # 'it isn'\''t'
3428             print MAKEFILE "target:\n\techo $quoted\n";
3429             # when run "make target", will output:
3430             # it isn't
3431 154     154 1 970  
3432             =cut
3433              
3434             my($self, $text, $opts) = @_;
3435             $opts->{allow_variables} = 1 unless defined $opts->{allow_variables};
3436              
3437             # Quote single quotes
3438             $text =~ s{'}{'\\''}g;
3439              
3440             $text = $opts->{allow_variables}
3441             ? $self->escape_dollarsigns($text) : $self->escape_all_dollarsigns($text);
3442              
3443 0     0 1 0 return "'$text'";
3444 0         0 }
3445 0         0  
3446 0         0  
3447 0         0 =item escape_newlines
3448              
3449             =cut
3450              
3451             my($self, $text) = @_;
3452              
3453             $text =~ s{\n}{\\\n}g;
3454              
3455             return $text;
3456             }
3457              
3458              
3459             =item max_exec_len
3460              
3461 22     22 1 354 Using L<POSIX>::ARG_MAX. Otherwise falling back to 4096.
3462              
3463 22         235 =cut
3464 22         74  
3465             my $self = shift;
3466              
3467             if (!defined $self->{_MAX_EXEC_LEN}) {
3468             if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3469             $self->{_MAX_EXEC_LEN} = $arg_max;
3470             }
3471             else { # POSIX minimum exec size
3472             $self->{_MAX_EXEC_LEN} = 4096;
3473 1184     1184 1 4113 }
3474             }
3475              
3476 1184         2316 return $self->{_MAX_EXEC_LEN};
  1378         4142  
3477             }
3478 1184         3525  
3479              
3480             =item static (o)
3481              
3482             Defines the static target.
3483              
3484             =cut
3485              
3486 2388     2388 1 95494 # --- Static Loading Sections ---
3487 2388 100       4589  
3488             my($self) = shift;
3489             '
3490 2388         4438 ## $(INST_PM) has been moved to the all: target.
3491 2388         8200 ## It remains here for awhile to allow for old usage: "make static"
3492             static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3493 2388         6990 $(NOECHO) $(NOOP)
3494 2388         7274 ';
3495 2388         6115 }
3496              
3497 2388         4857 my($self) = @_;
3498             return '' unless $self->has_link_code;
3499 2388         9461 my(@m);
3500             my @libs;
3501             if ($self->{XSMULTI}) {
3502             for my $ext ($self->_xs_list_basenames) {
3503             my ($v, $d, $f) = File::Spec->splitpath($ext);
3504             my @d = File::Spec->splitdir($d);
3505             shift @d if $d[0] eq 'lib';
3506             my $instdir = $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
3507             my $instfile = $self->catfile($instdir, "$f\$(LIB_EXT)");
3508             my $objfile = "$ext\$(OBJ_EXT)";
3509             push @libs, [ $objfile, $instfile, $instdir ];
3510             }
3511             } else {
3512             @libs = ([ qw($(OBJECT) $(INST_STATIC) $(INST_ARCHAUTODIR)) ]);
3513             }
3514             push @m, map { $self->xs_make_static_lib(@$_); } @libs;
3515             join "\n", @m;
3516             }
3517              
3518             =item xs_make_static_lib
3519 12815     12815 1 19287  
3520 12815 100       23467 Defines the recipes for the C<static_lib> section.
3521              
3522             =cut
3523 12815         21094  
3524             my ($self, $from, $to, $todir) = @_;
3525             my @m = sprintf '%s: %s $(MYEXTLIB) %s$(DFSEP).exists'."\n", $to, $from, $todir;
3526 12815 100       30261 push @m, "\t\$(RM_F) \"\$\@\"\n";
3527             push @m, $self->static_lib_fixtures;
3528 12815         37249 push @m, $self->static_lib_pure_cmd($from);
3529             push @m, "\t\$(CHMOD) \$(PERM_RWX) \$\@\n";
3530             push @m, $self->static_lib_closures($todir);
3531             join '', @m;
3532             }
3533              
3534             =item static_lib_closures
3535              
3536             Records C<$(EXTRALIBS)> in F<extralibs.ld> and F<$(PERL_SRC)/ext.libs>.
3537 3153     3153 1 5386  
3538             =cut
3539 3153         7803  
3540             my ($self, $todir) = @_;
3541 3153         6704 my @m = sprintf <<'MAKE_FRAG', $todir;
3542             $(NOECHO) $(ECHO) "$(EXTRALIBS)" > %s$(DFSEP)extralibs.ld
3543             MAKE_FRAG
3544             # Old mechanism - still available:
3545             push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3546             $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)$(DFSEP)ext.libs
3547             MAKE_FRAG
3548             @m;
3549             }
3550              
3551             =item static_lib_fixtures
3552 762     762 1 1308  
3553             Handles copying C<$(MYEXTLIB)> as starter for final static library that
3554 762 100       1855 then gets added to.
3555 154 50       442  
  154         11161  
  154         97905  
3556 0         0 =cut
3557              
3558             my ($self) = @_;
3559 154         5614 # If this extension has its own library (eg SDBM_File)
3560             # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3561             return unless $self->{MYEXTLIB};
3562             "\t\$(CP) \$(MYEXTLIB) \"\$\@\"\n";
3563 762         3276 }
3564              
3565             =item static_lib_pure_cmd
3566              
3567             Defines how to run the archive utility.
3568              
3569             =cut
3570              
3571             my ($self, $from) = @_;
3572             my $ar;
3573             if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3574             # Prefer the absolute pathed ar if available so that PATH
3575             # doesn't confuse us. Perl itself is built with the full_ar.
3576 153     153 1 386 $ar = 'FULL_AR';
3577 153         816 } else {
3578             $ar = 'AR';
3579             }
3580             sprintf <<'MAKE_FRAG', $ar, $from;
3581             $(%s) $(AR_STATIC_ARGS) "$@" %s
3582             $(RANLIB) "$@"
3583             MAKE_FRAG
3584             }
3585              
3586 153     153 0 408 =item staticmake (o)
3587 153 50       498  
3588 0         0 Calls makeaperl.
3589              
3590 0 0       0 =cut
3591 0         0  
3592 0         0 my($self, %attribs) = @_;
3593 0         0 my(@static);
3594 0 0       0  
3595 0         0 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3596 0         0  
3597 0         0 # And as it's not yet built, we add the current extension
3598 0         0 # but only if it has some C code (or XS code, which implies C code)
3599             if (@{$self->{C}}) {
3600             @static = $self->catfile($self->{INST_ARCHLIB},
3601 0         0 "auto",
3602             $self->{FULLEXT},
3603 0         0 "$self->{BASEEXT}$self->{LIB_EXT}"
  0         0  
3604 0         0 );
3605             }
3606              
3607             # Either we determine now, which libraries we will produce in the
3608             # subdirectories or we do it at runtime of the make.
3609              
3610             # We could ask all subdir objects, but I cannot imagine, why it
3611             # would be necessary.
3612              
3613             # Instead we determine all libraries for the new perl at
3614 0     0 1 0 # runtime.
3615 0         0 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3616 0         0  
3617 0         0 $self->makeaperl(MAKE => $self->{MAKEFILE},
3618 0         0 DIRS => \@searchdirs,
3619 0         0 STAT => \@static,
3620 0         0 INCL => \@perlinc,
3621 0         0 TARGET => $self->{MAP_TARGET},
3622             TMP => "",
3623             LIBPERL => $self->{LIBPERL_A}
3624             );
3625             }
3626              
3627             =item subdir_x (o)
3628              
3629             Helper subroutine for subdirs
3630              
3631 0     0 1 0 =cut
3632 0         0  
3633             my($self, $subdir) = @_;
3634              
3635             my $subdir_cmd = $self->cd($subdir,
3636 0 0 0     0 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3637             );
3638             return sprintf <<'EOT', $subdir_cmd;
3639 0         0  
3640             subdirs ::
3641             $(NOECHO) %s
3642             EOT
3643              
3644             }
3645              
3646             =item subdirs (o)
3647              
3648             Defines targets to process subdirectories.
3649              
3650 0     0 1 0 =cut
3651              
3652             # --- Sub-directory Sections ---
3653 0 0       0 my($self) = shift;
3654 0         0 my(@m);
3655             # This method provides a mechanism to automatically deal with
3656             # subdirectories containing further Makefile.PL scripts.
3657             # It calls the subdir_x() method for each subdirectory.
3658             foreach my $dir (@{$self->{DIR}}){
3659             push @m, $self->subdir_x($dir);
3660             #### print "Including $dir subdirectory\n";
3661             }
3662             if (@m){
3663             unshift @m, <<'EOF';
3664 0     0 1 0  
3665 0         0 # The default clean, realclean and test targets in this Makefile
3666 0 0 0     0 # have automatically been given entries for each subdir.
3667              
3668             EOF
3669 0         0 } else {
3670             push(@m, "\n# none")
3671 0         0 }
3672             join('',@m);
3673 0         0 }
3674              
3675             =item test (o)
3676              
3677             Defines the test targets.
3678              
3679             =cut
3680              
3681             my($self, %attribs) = @_;
3682             my $tests = $attribs{TESTS} || '';
3683             if (!$tests && -d 't' && defined $attribs{RECURSIVE_TEST_FILES}) {
3684             $tests = $self->find_tests_recursive;
3685             }
3686 153     153 1 440 elsif (!$tests && -d 't') {
3687 153         278 $tests = $self->find_tests;
3688             }
3689 153         833 # have to do this because nmake is broken
3690             $tests =~ s!/!\\!g if $self->is_make_type('nmake');
3691             # note: 'test.pl' name is also hardcoded in init_dirscan()
3692             my @m;
3693 153 50       297 my $default_testtype = $Config{usedl} ? 'dynamic' : 'static';
  153         528  
3694             push @m, <<EOF;
3695             TEST_VERBOSE=0
3696             TEST_TYPE=test_\$(LINKTYPE)
3697 0         0 TEST_FILE = test.pl
3698             TEST_FILES = $tests
3699             TESTDB_SW = -d
3700              
3701             testdb :: testdb_\$(LINKTYPE)
3702             \$(NOECHO) \$(NOOP)
3703              
3704             test :: \$(TEST_TYPE)
3705             \$(NOECHO) \$(NOOP)
3706              
3707             # Occasionally we may face this degenerate target:
3708             test_ : test_$default_testtype
3709 153         697 \$(NOECHO) \$(NOOP)
3710              
3711             EOF
3712              
3713             for my $linktype (qw(dynamic static)) {
3714             my $directdeps = join ' ', grep !$self->{SKIPHASH}{$_}, $linktype, "pure_all"; # no depend on a linktype if SKIPped
3715             push @m, "subdirs-test_$linktype :: $directdeps\n";
3716             foreach my $dir (@{ $self->{DIR} }) {
3717             my $test = $self->cd($dir, "\$(MAKE) test_$linktype \$(PASTHRU)");
3718 153         1867 push @m, "\t\$(NOECHO) $test\n";
3719             }
3720             push @m, "\n";
3721             if ($tests or -f "test.pl") {
3722             for my $testspec ([ '', '' ], [ 'db', ' $(TESTDB_SW)' ]) {
3723             my ($db, $switch) = @$testspec;
3724             my ($command, $deps);
3725             # if testdb, build all but don't test all
3726             $deps = $db eq 'db' ? $directdeps : "subdirs-test_$linktype";
3727             if ($linktype eq 'static' and $self->needs_linking) {
3728 56     56 1 229 my $target = File::Spec->rel2abs('$(MAP_TARGET)');
3729             $command = qq{"$target" \$(MAP_PERLINC)};
3730 56         338 $deps .= ' $(MAP_TARGET)';
3731             } else {
3732             $command = '$(FULLPERLRUN)' . $switch;
3733 56         500 }
3734             push @m, "test${db}_$linktype :: $deps\n";
3735             if ($db eq 'db') {
3736             push @m, $self->test_via_script($command, '$(TEST_FILE)')
3737             } else {
3738             push @m, $self->test_via_script($command, '$(TEST_FILE)')
3739             if -f "test.pl";
3740             push @m, $self->test_via_harness($command, '$(TEST_FILES)')
3741             if $tests;
3742             }
3743             push @m, "\n";
3744             }
3745             } else {
3746             push @m, _sprintf562 <<'EOF', $linktype;
3747             testdb_%1$s test_%1$s :: subdirs-test_%1$s
3748             $(NOECHO) $(ECHO) 'No tests defined for $(NAME) extension.'
3749 153     153 1 591  
3750 153         240 EOF
3751             }
3752             }
3753              
3754 153         244 join "", @m;
  153         813  
3755 56         376 }
3756              
3757             =item test_via_harness (override)
3758 153 100       592  
3759 56         202 For some reason which I forget, Unix machines like to have
3760             PERL_DL_NONLAZY set for tests.
3761              
3762             =cut
3763              
3764             my($self, $perl, $tests) = @_;
3765             return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3766 97         679 }
3767              
3768 153         1070 =item test_via_script (override)
3769              
3770             Again, the PERL_DL_NONLAZY thing.
3771              
3772             =cut
3773              
3774             my($self, $perl, $script) = @_;
3775             return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3776             }
3777              
3778 153     153 1 425  
3779 153   50     1219 =item tool_xsubpp (o)
3780 153 50 66     6169  
    100 66        
      66        
3781 0         0 Determines typemaps, xsubpp version, prototype behaviour.
3782              
3783             =cut
3784 113         1144  
3785             my($self) = shift;
3786             return "" unless $self->needs_linking;
3787 153 50       875  
3788             my $xsdir;
3789 153         558 my @xsubpp_dirs = @INC;
3790 153 50       811  
3791 153         1196 # Make sure we pick up the new xsubpp if we're building perl.
3792             unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3793              
3794             my $foundxsubpp = 0;
3795             foreach my $dir (@xsubpp_dirs) {
3796             $xsdir = $self->catdir($dir, 'ExtUtils');
3797             if( -r $self->catfile($xsdir, "xsubpp") ) {
3798             $foundxsubpp = 1;
3799             last;
3800             }
3801             }
3802             die "ExtUtils::MM_Unix::tool_xsubpp : Can't find xsubpp" if !$foundxsubpp;
3803              
3804             my $tmdir = $self->catdir($self->{PERL_LIB},"ExtUtils");
3805             my(@tmdeps) = $self->catfile($tmdir,'typemap');
3806             if( $self->{TYPEMAPS} ){
3807             foreach my $typemap (@{$self->{TYPEMAPS}}){
3808             if( ! -f $typemap ) {
3809             warn "Typemap $typemap not found.\n";
3810 153         683 }
3811 306         1562 else {
3812 306         1147 $typemap = vmsify($typemap) if $Is{VMS};
3813 306         546 push(@tmdeps, $typemap);
  306         871  
3814 112         449 }
3815 112         372 }
3816             }
3817 306         646 push(@tmdeps, "typemap") if -f "typemap";
3818 306 100 66     1886 # absolutised because with deep-located typemaps, eg "lib/XS/typemap",
3819 226         791 # if xsubpp is called from top level with
3820 452         918 # $(XSUBPP) ... -typemap "lib/XS/typemap" "lib/XS/Test.xs"
3821 452         618 # it says:
3822             # Can't find lib/XS/type map in (fulldir)/lib/XS
3823 452 100       1139 # because ExtUtils::ParseXS::process_file chdir's to .xs file's
3824 452 50 66     1639 # location. This is the only way to get all specified typemaps used,
3825 0         0 # wherever located.
3826 0         0 my @tmargs = map { '-typemap '.$self->quote_literal(File::Spec->rel2abs($_)) } @tmdeps;
3827 0         0 $_ = $self->quote_dep($_) for @tmdeps;
3828             if( exists $self->{XSOPT} ){
3829 452         802 unshift( @tmargs, $self->{XSOPT} );
3830             }
3831 452         1339  
3832 452 100       887 if ($Is{VMS} &&
3833 226         753 $Config{'ldflags'} &&
3834             $Config{'ldflags'} =~ m!/Debug!i &&
3835 226 100       3092 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
3836             )
3837 226 50       1694 {
3838             unshift(@tmargs,'-nolinenumbers');
3839             }
3840 452         1271  
3841              
3842             $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3843 80         769 my $xsdirdep = $self->quote_dep($xsdir);
3844             # -dep for use when dependency not command
3845              
3846             return qq{
3847             XSUBPPDIR = $xsdir
3848             XSUBPP = "\$(XSUBPPDIR)\$(DFSEP)xsubpp"
3849             XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
3850             XSPROTOARG = $self->{XSPROTOARG}
3851 153         1559 XSUBPPDEPS = @tmdeps $xsdirdep\$(DFSEP)xsubpp
3852             XSUBPPARGS = @tmargs
3853             XSUBPP_EXTRA_ARGS =
3854             };
3855             }
3856              
3857              
3858             =item all_target
3859              
3860             Build man pages, too
3861              
3862 226     226 1 720 =cut
3863 226         1179  
3864             my $self = shift;
3865              
3866             return <<'MAKE_EXT';
3867             all :: pure_all manifypods
3868             $(NOECHO) $(NOOP)
3869             MAKE_EXT
3870             }
3871              
3872             =item top_targets (o)
3873 338     338 1 860  
3874 338         1279 Defines the targets all, subdirs, config, and O_FILES
3875              
3876             =cut
3877              
3878             # --- Target Sections ---
3879              
3880             my($self) = shift;
3881             my(@m);
3882              
3883             push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3884              
3885 153     153 1 459 push @m, sprintf <<'EOF';
3886 153 50       1653 pure_all :: config pm_to_blib subdirs linkext
3887             $(NOECHO) $(NOOP)
3888 0         0  
3889 0         0 subdirs :: $(MYEXTLIB)
3890             $(NOECHO) $(NOOP)
3891              
3892 0 0       0 config :: $(FIRST_MAKEFILE) blibdirs
3893             $(NOECHO) $(NOOP)
3894 0         0 EOF
3895 0         0  
3896 0         0 push @m, '
3897 0 0       0 $(O_FILES) : $(H_FILES)
3898 0         0 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3899 0         0  
3900             push @m, q{
3901             help :
3902 0 0       0 perldoc ExtUtils::MakeMaker
3903             };
3904 0         0  
3905 0         0 join('',@m);
3906 0 0       0 }
3907 0         0  
  0         0  
3908 0 0       0 =item writedoc
3909 0         0  
3910             Obsolete, deprecated method. Not used since Version 5.21.
3911              
3912 0 0       0 =cut
3913 0         0  
3914             # --- perllocal.pod section ---
3915             my($self,$what,$name,@attribs)=@_;
3916             my $time = gmtime($ENV{SOURCE_DATE_EPOCH} || time);
3917 0 0       0 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3918             print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3919             print "\n\n=back\n\n";
3920             }
3921              
3922             =item xs_c (o)
3923              
3924             Defines the suffix rules to compile XS files to C.
3925              
3926 0         0 =cut
  0         0  
3927 0         0  
3928 0 0       0 my($self) = shift;
3929 0         0 return '' unless $self->needs_linking();
3930             '
3931             .xs.c:
3932 0 0 0     0 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc
      0        
      0        
      0        
3933             $(MV) $*.xsc $*.c
3934             ';
3935             }
3936              
3937             =item xs_cpp (o)
3938 0         0  
3939             Defines the suffix rules to compile XS files to C++.
3940              
3941             =cut
3942 0 0       0  
3943 0         0 my($self) = shift;
3944             return '' unless $self->needs_linking();
3945             '
3946 0         0 .xs.cpp:
3947             $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc
3948             $(MV) $*.xsc $*.cpp
3949             ';
3950             }
3951              
3952             =item xs_o (o)
3953              
3954             Defines suffix rules to go from XS to object files directly. This was
3955             originally only intended for broken make implementations, but is now
3956             necessary for per-XS file under C<XSMULTI>, since each XS file might
3957             have an individual C<$(VERSION)>.
3958              
3959             =cut
3960              
3961             my ($self) = @_;
3962             return '' unless $self->needs_linking();
3963             my $m_o = $self->{XSMULTI} ? $self->xs_obj_opt('$*$(OBJ_EXT)') : '';
3964             my $dbgout = $self->dbgoutflag;
3965 153     153 1 341 $dbgout = $dbgout ? "$dbgout " : '';
3966             my $frag = '';
3967 153         800 # dmake makes noise about ambiguous rule
3968             $frag .= sprintf <<'EOF', $dbgout, $m_o unless $self->is_make_type('dmake');
3969             .xs$(OBJ_EXT) :
3970             $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc
3971             $(MV) $*.xsc $*.c
3972             $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) %s$*.c %s
3973             EOF
3974             if ($self->{XSMULTI}) {
3975             for my $ext ($self->_xs_list_basenames) {
3976             my $pmfile = "$ext.pm";
3977             croak "$ext.xs has no matching $pmfile: $!" unless -f $pmfile;
3978             my $version = $self->parse_version($pmfile);
3979             my $cccmd = $self->{CONST_CCCMD};
3980             $cccmd =~ s/^\s*CCCMD\s*=\s*//;
3981             $cccmd =~ s/\$\(DEFINE_VERSION\)/-DVERSION=\\"$version\\"/;
3982 153     153 1 365 $cccmd =~ s/\$\(XS_DEFINE_VERSION\)/-DXS_VERSION=\\"$version\\"/;
3983 153         254 $self->_xsbuild_replace_macro($cccmd, 'xs', $ext, 'INC');
3984             my $define = '$(DEFINE)';
3985 153 50       1461 $self->_xsbuild_replace_macro($define, 'xs', $ext, 'DEFINE');
3986             # 1 2 3 4 5
3987 153         474 $frag .= _sprintf562 <<'EOF', $ext, $cccmd, $m_o, $define, $dbgout;
3988              
3989             %1$s$(OBJ_EXT): %1$s.xs
3990             $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc
3991             $(MV) $*.xsc $*.c
3992             %2$s $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) %4$s %5$s$*.c %3$s
3993             EOF
3994             }
3995             }
3996             $frag =~ s/"-I(\$\(PERL_INC\))"/-iwithsysroot "$1"/sg if $Is{ApplCor};
3997             $frag;
3998             }
3999              
4000 153 50 33     220 # param gets modified
  153 0       768  
  0 50       0  
4001             my ($self, undef, $xstype, $ext, $varname) = @_;
4002 153         577 my $value = $self->_xsbuild_value($xstype, $ext, $varname);
4003             return unless defined $value;
4004             $_[1] =~ s/\$\($varname\)/$value/;
4005             }
4006              
4007 153         1015 my ($self, $xstype, $ext, $varname) = @_;
4008             return $self->{XSBUILD}{$xstype}{$ext}{$varname}
4009             if $self->{XSBUILD}{$xstype}{$ext}{$varname};
4010             return $self->{XSBUILD}{$xstype}{all}{$varname}
4011             if $self->{XSBUILD}{$xstype}{all}{$varname};
4012             ();
4013             }
4014              
4015             1;
4016              
4017             =back
4018 0     0 1 0  
4019 0   0     0 =head1 SEE ALSO
4020 0         0  
4021 0         0 L<ExtUtils::MakeMaker>
4022 0         0  
4023             =cut
4024