File Coverage

lib/ExtUtils/MM_Unix.pm
Criterion Covered Total %
statement 922 1445 63.8
branch 322 766 42.0
condition 173 433 39.9
subroutine 105 125 84.0
pod 95 97 97.9
total 1617 2866 56.4


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