This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update to MakeMaker 6.30
[perl5.git] / lib / ExtUtils / MM_Unix.pm
CommitLineData
1e44e2bf
PP
1package ExtUtils::MM_Unix;
2
f6d6199c
MS
3require 5.005_03; # Maybe further back, dunno
4
b75c8c73
MS
5use strict;
6
dbc738d9 7use Exporter ();
45bc4d3a 8use Carp;
7292dc67 9use ExtUtils::MakeMaker::Config;
a7d1454b 10use File::Basename qw(basename dirname);
f1387719 11use DirHandle;
479d2113 12
f6d6199c 13use vars qw($VERSION @ISA
7292dc67
RGS
14 $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos
15 $Is_OSF $Is_IRIX $Is_NetBSD $Is_BSD
0c52c6a9 16 $Is_SunOS4 $Is_Solaris $Is_SunOS $Is_Interix
5dca256e 17 $Verbose %pm
5c161494
MS
18 %Config_Override
19 );
f6d6199c
MS
20
21use ExtUtils::MakeMaker qw($Verbose neatvalue);
dbc738d9 22
4325052d 23$VERSION = '1.50';
1e44e2bf 24
f6d6199c
MS
25require ExtUtils::MM_Any;
26@ISA = qw(ExtUtils::MM_Any);
1e44e2bf 27
7292dc67
RGS
28BEGIN {
29 $Is_OS2 = $^O eq 'os2';
30 $Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
31 $Is_Dos = $^O eq 'dos';
32 $Is_VMS = $^O eq 'VMS';
33 $Is_OSF = $^O eq 'dec_osf';
34 $Is_IRIX = $^O eq 'irix';
35 $Is_NetBSD = $^O eq 'netbsd';
36 $Is_Interix = $^O eq 'interix';
37 $Is_SunOS4 = $^O eq 'sunos';
38 $Is_Solaris = $^O eq 'solaris';
39 $Is_SunOS = $Is_SunOS4 || $Is_Solaris;
40 $Is_BSD = $^O =~ /^(?:free|net|open)bsd$/ or
41 $^O eq 'bsdos' or $^O eq 'interix';
42}
43
44BEGIN {
45 if( $Is_VMS ) {
46 # For things like vmsify()
47 require VMS::Filespec;
48 VMS::Filespec->import;
49 }
50}
479d2113 51
1e44e2bf
PP
52
53=head1 NAME
54
55ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
56
57=head1 SYNOPSIS
58
59C<require ExtUtils::MM_Unix;>
60
61=head1 DESCRIPTION
62
63The methods provided by this package are designed to be used in
64conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
65Makefile, it creates one or more objects that inherit their methods
66from a package C<MM>. MM itself doesn't provide any methods, but it
67ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
68specific packages take the responsibility for all the methods provided
69by MM_Unix. We are trying to reduce the number of the necessary
70overrides by defining rather primitive operations within
71ExtUtils::MM_Unix.
72
73If you are going to write a platform specific MM package, please try
1fef88e7
JM
74to limit the necessary overrides to primitive methods, and if it is not
75possible to do so, let's work out how to achieve that gain.
1e44e2bf 76
f4ae0f5e
PP
77If you are overriding any of these methods in your Makefile.PL (in the
78MY class), please report that to the makemaker mailing list. We are
79trying to minimize the necessary method overrides and switch to data
80driven Makefile.PLs wherever possible. In the long run less methods
81will be overridable via the MY class.
82
1e44e2bf
PP
83=head1 METHODS
84
85The following description of methods is still under
86development. Please refer to the code for not suitably documented
479d2113
MS
87sections and complain loudly to the makemaker@perl.org mailing list.
88Better yet, provide a patch.
1e44e2bf 89
f1387719 90Not all of the methods below are overridable in a
f4ae0f5e 91Makefile.PL. Overridable methods are marked as (o). All methods are
7292dc67
RGS
92overridable by a platform specific MM_*.pm file.
93
94Cross-platform methods are being moved into MM_Any. If you can't find
95something that used to be in here, look in MM_Any.
f4ae0f5e 96
1e44e2bf
PP
97=cut
98
f6d6199c 99# So we don't have to keep calling the methods over and over again,
479d2113
MS
100# we have these globals to cache the values. Faster and shrtr.
101my $Curdir = __PACKAGE__->curdir;
102my $Rootdir = __PACKAGE__->rootdir;
103my $Updir = __PACKAGE__->updir;
f4ae0f5e 104
479d2113
MS
105
106=head2 Methods
107
108=over 4
bab2b58e 109
7292dc67 110=item os_flavor
dedf98bc
MS
111
112Simply says that we're Unix.
113
114=cut
115
116sub os_flavor {
117 return('Unix');
118}
119
120
f1387719 121=item c_o (o)
1e44e2bf 122
f1387719
PP
123Defines the suffix rules to compile different flavors of C files to
124object files.
1e44e2bf
PP
125
126=cut
127
f1387719
PP
128sub c_o {
129# --- Translation Sections ---
1e44e2bf 130
f1387719
PP
131 my($self) = shift;
132 return '' unless $self->needs_linking();
133 my(@m);
b207e5e2
DM
134 if (my $cpp = $Config{cpprun}) {
135 my $cpp_cmd = $self->const_cccmd;
136 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/;
137 push @m, '
138.c.i:
071e6b84 139 '. $cpp_cmd . ' $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i
b207e5e2
DM
140';
141 }
f1387719 142 push @m, '
58486d1a 143.c.s:
071e6b84 144 $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
58486d1a
DM
145';
146 push @m, '
f1387719 147.c$(OBJ_EXT):
071e6b84 148 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
a0d6894c
PP
149';
150 push @m, '
f1387719 151.C$(OBJ_EXT):
071e6b84 152 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C
f6d6199c 153' if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific
a0d6894c 154 push @m, '
f1387719 155.cpp$(OBJ_EXT):
071e6b84 156 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp
1e44e2bf 157
f1387719 158.cxx$(OBJ_EXT):
071e6b84 159 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx
1e44e2bf 160
f1387719 161.cc$(OBJ_EXT):
071e6b84 162 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc
f1387719
PP
163';
164 join "", @m;
1e44e2bf
PP
165}
166
f1387719 167=item cflags (o)
1e44e2bf 168
f1387719
PP
169Does very much the same as the cflags script in the perl
170distribution. It doesn't return the whole compiler command line, but
171initializes all of its parts. The const_cccmd method then actually
172returns the definition of the CCCMD macro which uses these parts.
1e44e2bf
PP
173
174=cut
175
f1387719 176#'
1e44e2bf 177
f1387719
PP
178sub cflags {
179 my($self,$libperl)=@_;
180 return $self->{CFLAGS} if $self->{CFLAGS};
181 return '' unless $self->needs_linking();
1e44e2bf 182
f1387719
PP
183 my($prog, $uc, $perltype, %cflags);
184 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
185 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
1e44e2bf 186
5869b1f1
JH
187 @cflags{qw(cc ccflags optimize shellflags)}
188 = @Config{qw(cc ccflags optimize shellflags)};
f1387719 189 my($optdebug) = "";
1e44e2bf 190
f1387719 191 $cflags{shellflags} ||= '';
1e44e2bf 192
f1387719
PP
193 my(%map) = (
194 D => '-DDEBUGGING',
195 E => '-DEMBED',
196 DE => '-DDEBUGGING -DEMBED',
197 M => '-DEMBED -DMULTIPLICITY',
198 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
199 );
1e44e2bf 200
f1387719
PP
201 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
202 $uc = uc($1);
203 } else {
204 $uc = ""; # avoid warning
205 }
206 $perltype = $map{$uc} ? $map{$uc} : "";
1e44e2bf 207
f1387719
PP
208 if ($uc =~ /^D/) {
209 $optdebug = "-g";
210 }
1e44e2bf 211
1e44e2bf 212
f1387719
PP
213 my($name);
214 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
e0678a30 215 if ($prog = $Config{$name}) {
f1387719
PP
216 # Expand hints for this extension via the shell
217 print STDOUT "Processing $name hint:\n" if $Verbose;
218 my(@o)=`cc=\"$cflags{cc}\"
219 ccflags=\"$cflags{ccflags}\"
220 optimize=\"$cflags{optimize}\"
221 perltype=\"$cflags{perltype}\"
222 optdebug=\"$cflags{optdebug}\"
f1387719
PP
223 eval '$prog'
224 echo cc=\$cc
225 echo ccflags=\$ccflags
226 echo optimize=\$optimize
227 echo perltype=\$perltype
228 echo optdebug=\$optdebug
f1387719
PP
229 `;
230 my($line);
231 foreach $line (@o){
232 chomp $line;
233 if ($line =~ /(.*?)=\s*(.*)\s*$/){
234 $cflags{$1} = $2;
235 print STDOUT " $1 = $2\n" if $Verbose;
236 } else {
237 print STDOUT "Unrecognised result from hint: '$line'\n";
238 }
239 }
240 }
1e44e2bf 241
f1387719
PP
242 if ($optdebug) {
243 $cflags{optimize} = $optdebug;
244 }
1e44e2bf 245
5869b1f1 246 for (qw(ccflags optimize perltype)) {
e0678a30 247 $cflags{$_} ||= '';
f1387719
PP
248 $cflags{$_} =~ s/^\s+//;
249 $cflags{$_} =~ s/\s+/ /g;
250 $cflags{$_} =~ s/\s+$//;
2d7e68ed 251 $self->{uc $_} ||= $cflags{$_};
f1387719 252 }
1e44e2bf 253
2aea4d40
JD
254 if ($self->{POLLUTE}) {
255 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
256 }
257
ee13e175
JH
258 my $pollute = '';
259 if ($Config{usemymalloc} and not $Config{bincompat5005}
260 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
261 and $self->{PERL_MALLOC_OK}) {
262 $pollute = '$(PERL_MALLOC_DEF)';
263 }
264
fa048ccd 265 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS});
9b475917 266 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE});
ac25e0e7 267
f1387719
PP
268 return $self->{CFLAGS} = qq{
269CCFLAGS = $self->{CCFLAGS}
270OPTIMIZE = $self->{OPTIMIZE}
271PERLTYPE = $self->{PERLTYPE}
ee13e175 272MPOLLUTE = $pollute
f1387719 273};
1e44e2bf 274
1e44e2bf
PP
275}
276
479d2113 277
f1387719 278=item const_cccmd (o)
1e44e2bf 279
f1387719
PP
280Returns the full compiler call for C programs and stores the
281definition in CONST_CCCMD.
1e44e2bf
PP
282
283=cut
284
f1387719
PP
285sub const_cccmd {
286 my($self,$libperl)=@_;
287 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
288 return '' unless $self->needs_linking();
289 return $self->{CONST_CCCMD} =
071e6b84 290 q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
289e7e34 291 $(CCFLAGS) $(OPTIMIZE) \\
5869b1f1 292 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
f1387719 293 $(XS_DEFINE_VERSION)};
1e44e2bf
PP
294}
295
f1387719 296=item const_config (o)
1e44e2bf 297
f1387719
PP
298Defines a couple of constants in the Makefile that are imported from
299%Config.
1e44e2bf
PP
300
301=cut
302
f1387719
PP
303sub const_config {
304# --- Constants Sections ---
305
306 my($self) = shift;
307 my(@m,$m);
308 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
309 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
310 my(%once_only);
311 foreach $m (@{$self->{CONFIG}}){
312 # SITE*EXP macros are defined in &constants; avoid duplicates here
479d2113 313 next if $once_only{$m};
f8968d56
JH
314 $self->{uc $m} = quote_paren($self->{uc $m});
315 push @m, uc($m) , ' = ' , $self->{uc $m}, "\n";
f1387719
PP
316 $once_only{$m} = 1;
317 }
318 join('', @m);
1e44e2bf
PP
319}
320
f1387719 321=item const_loadlibs (o)
1e44e2bf 322
f1387719
PP
323Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
324L<ExtUtils::Liblist> for details.
1e44e2bf
PP
325
326=cut
327
f1387719
PP
328sub const_loadlibs {
329 my($self) = shift;
330 return "" unless $self->needs_linking;
331 my @m;
332 push @m, qq{
333# $self->{NAME} might depend on some other libraries:
334# See ExtUtils::Liblist for details
335#
336};
337 my($tmp);
338 for $tmp (qw/
0a0461ad 339 EXTRALIBS LDLOADLIBS BSLOADLIBS
f1387719
PP
340 /) {
341 next unless defined $self->{$tmp};
342 push @m, "$tmp = $self->{$tmp}\n";
343 }
0a0461ad
RGS
344 # don't set LD_RUN_PATH if empty
345 for $tmp (qw/
346 LD_RUN_PATH
347 /) {
348 next unless $self->{$tmp};
349 push @m, "$tmp = $self->{$tmp}\n";
350 }
f1387719 351 return join "", @m;
1e44e2bf
PP
352}
353
f1387719 354=item constants (o)
1e44e2bf 355
479d2113
MS
356 my $make_frag = $mm->constants;
357
358Prints out macros for lots of constants.
1e44e2bf
PP
359
360=cut
361
f1387719 362sub constants {
1e44e2bf 363 my($self) = @_;
479d2113 364 my @m = ();
1e44e2bf 365
7292dc67
RGS
366 $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use
367
5e719f03 368 for my $macro (qw(
1e44e2bf 369
7292dc67 370 AR_STATIC_ARGS DIRFILESEP DFSEP
479d2113
MS
371 NAME NAME_SYM
372 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
373 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
374 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
5e719f03
MS
375 INST_MAN1DIR INST_MAN3DIR
376 MAN1EXT MAN3EXT
7292dc67 377 INSTALLDIRS INSTALLBASE DESTDIR PREFIX
479d2113 378 PERLPREFIX SITEPREFIX VENDORPREFIX
5e719f03
MS
379 ),
380 (map { ("INSTALL".$_,
381 "DESTINSTALL".$_)
382 } $self->installvars),
383 qw(
479d2113
MS
384 PERL_LIB
385 PERL_ARCHLIB
5c161494 386 LIBPERL_A MYEXTLIB
479d2113
MS
387 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
388 PERLMAINCC PERL_SRC PERL_INC
389 PERL FULLPERL ABSPERL
390 PERLRUN FULLPERLRUN ABSPERLRUN
391 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
392 PERL_CORE
393 PERM_RW PERM_RWX
1e44e2bf 394
5e719f03 395 ) )
5c161494 396 {
479d2113 397 next unless defined $self->{$macro};
e0678a30
MS
398
399 # pathnames can have sharp signs in them; escape them so
400 # make doesn't think it is a comment-start character.
479d2113
MS
401 $self->{$macro} =~ s/#/\\#/g;
402 push @m, "$macro = $self->{$macro}\n";
1e44e2bf
PP
403 }
404
f1387719 405 push @m, qq{
479d2113
MS
406MAKEMAKER = $self->{MAKEMAKER}
407MM_VERSION = $self->{MM_VERSION}
408MM_REVISION = $self->{MM_REVISION}
f1387719 409};
1e44e2bf 410
f1387719
PP
411 push @m, q{
412# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
413# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
f1387719
PP
414# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
415# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
416};
1e44e2bf 417
479d2113 418 for my $macro (qw/
7292dc67 419 MAKE
f1387719 420 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
7292dc67 421 LDFROM LINKTYPE BOOTDEP
5c161494
MS
422 / )
423 {
479d2113
MS
424 next unless defined $self->{$macro};
425 push @m, "$macro = $self->{$macro}\n";
f1387719 426 }
1e44e2bf 427
f1387719
PP
428 push @m, "
429# Handy lists of source code files:
479d2113
MS
430XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
431C_FILES = ".$self->wraplist(@{$self->{C}})."
432O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."
433H_FILES = ".$self->wraplist(@{$self->{H}})."
434MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
435MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
f1387719 436";
1e44e2bf 437
2366100d 438
f1387719 439 push @m, q{
479d2113 440# Where is the Config information that we are using/depend on
7292dc67 441CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
479d2113 442};
1e44e2bf 443
1e44e2bf 444
479d2113
MS
445 push @m, qq{
446# Where to build things
447INST_LIBDIR = $self->{INST_LIBDIR}
448INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
1e44e2bf 449
479d2113
MS
450INST_AUTODIR = $self->{INST_AUTODIR}
451INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
1e44e2bf 452
479d2113
MS
453INST_STATIC = $self->{INST_STATIC}
454INST_DYNAMIC = $self->{INST_DYNAMIC}
455INST_BOOT = $self->{INST_BOOT}
dbc738d9 456};
1e44e2bf 457
1e44e2bf 458
479d2113
MS
459 push @m, qq{
460# Extra linker info
461EXPORT_LIST = $self->{EXPORT_LIST}
462PERL_ARCHIVE = $self->{PERL_ARCHIVE}
463PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
f1387719 464};
1e44e2bf 465
5ba48348 466 push @m, "
1e44e2bf 467
479d2113 468TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."
1e44e2bf 469
479d2113
MS
470PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}})."
471";
1e44e2bf 472
f1387719
PP
473 join('',@m);
474}
1e44e2bf 475
479d2113 476
f1387719 477=item depend (o)
1e44e2bf 478
f1387719 479Same as macro for the depend attribute.
1e44e2bf 480
f1387719 481=cut
1e44e2bf 482
f1387719
PP
483sub depend {
484 my($self,%attribs) = @_;
485 my(@m,$key,$val);
486 while (($key,$val) = each %attribs){
487 last unless defined $key;
f6c40018 488 push @m, "$key : $val\n";
1e44e2bf 489 }
f1387719
PP
490 join "", @m;
491}
1e44e2bf 492
af7522e5 493
5e719f03
MS
494=item init_DEST
495
496 $mm->init_DEST
497
498Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
499
500=cut
501
502sub init_DEST {
503 my $self = shift;
504
505 # Initialize DESTDIR
506 $self->{DESTDIR} ||= '';
507
508 # Make DEST variables.
509 foreach my $var ($self->installvars) {
510 my $destvar = 'DESTINSTALL'.$var;
511 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
512 }
513}
514
515
479d2113
MS
516=item init_dist
517
518 $mm->init_dist;
1e44e2bf 519
f1387719 520Defines a lot of macros for distribution support.
1e44e2bf 521
479d2113
MS
522 macro description default
523
524 TAR tar command to use tar
525 TARFLAGS flags to pass to TAR cvf
526
527 ZIP zip command to use zip
528 ZIPFLAGS flags to pass to ZIP -r
529
530 COMPRESS compression command to gzip --best
531 use for tarfiles
532 SUFFIX suffix to put on .gz
533 compressed files
534
535 SHAR shar command to use shar
536
537 PREOP extra commands to run before
538 making the archive
539 POSTOP extra commands to run after
540 making the archive
541
542 TO_UNIX a command to convert linefeeds
543 to Unix style in your archive
544
545 CI command to checkin your ci -u
546 sources to version control
547 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
548 just after CI is run
549
550 DIST_CP $how argument to manicopy() best
551 when the distdir is created
552
553 DIST_DEFAULT default target to use to tardist
554 create a distribution
555
556 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
557 (minus suffixes)
558
559=cut
560
561sub init_dist {
562 my $self = shift;
563
564 $self->{TAR} ||= 'tar';
565 $self->{TARFLAGS} ||= 'cvf';
566 $self->{ZIP} ||= 'zip';
567 $self->{ZIPFLAGS} ||= '-r';
568 $self->{COMPRESS} ||= 'gzip --best';
569 $self->{SUFFIX} ||= '.gz';
570 $self->{SHAR} ||= 'shar';
571 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
572 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
573 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
574
575 $self->{CI} ||= 'ci -u';
576 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
577 $self->{DIST_CP} ||= 'best';
578 $self->{DIST_DEFAULT} ||= 'tardist';
579
580 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
581 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
582
583}
584
585=item dist (o)
586
587 my $dist_macros = $mm->dist(%overrides);
588
589Generates a make fragment defining all the macros initialized in
590init_dist.
591
592%overrides can be used to override any of the above.
593
f1387719 594=cut
1e44e2bf 595
f1387719
PP
596sub dist {
597 my($self, %attribs) = @_;
1e44e2bf 598
f6d6199c 599 my $make = '';
479d2113
MS
600 foreach my $key (qw(
601 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
602 PREOP POSTOP TO_UNIX
603 CI RCS_LABEL DIST_CP DIST_DEFAULT
604 DISTNAME DISTVNAME
605 ))
606 {
607 my $value = $attribs{$key} || $self->{$key};
608 $make .= "$key = $value\n";
f6d6199c
MS
609 }
610
611 return $make;
1e44e2bf
PP
612}
613
f1387719 614=item dist_basics (o)
1e44e2bf 615
2edbd6da 616Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
1e44e2bf
PP
617
618=cut
619
f1387719
PP
620sub dist_basics {
621 my($self) = shift;
f6d6199c
MS
622
623 return <<'MAKE_FRAG';
f1387719 624distclean :: realclean distcheck
f6d6199c 625 $(NOECHO) $(NOOP)
1e44e2bf 626
f1387719 627distcheck :
f6d6199c 628 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
1e44e2bf 629
f1387719 630skipcheck :
f6d6199c 631 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
1e44e2bf 632
f1387719 633manifest :
f6d6199c 634 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
2edbd6da 635
2edbd6da
JH
636veryclean : realclean
637 $(RM_F) *~ *.orig */*~ */*.orig
f6d6199c
MS
638
639MAKE_FRAG
640
1e44e2bf
PP
641}
642
f1387719 643=item dist_ci (o)
1e44e2bf 644
f1387719 645Defines a check in target for RCS.
1e44e2bf
PP
646
647=cut
648
f1387719 649sub dist_ci {
1e44e2bf 650 my($self) = shift;
479d2113 651 return q{
f1387719 652ci :
f6d6199c 653 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\
479d2113 654 -e "@all = keys %{ maniread() };" \\
431b0fc4
MS
655 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\
656 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
f1387719 657};
f1387719 658}
1e44e2bf 659
f1387719 660=item dist_core (o)
1e44e2bf 661
479d2113
MS
662 my $dist_make_fragment = $MM->dist_core;
663
664Puts the targets necessary for 'make dist' together into one make
665fragment.
1e44e2bf 666
f1387719 667=cut
1e44e2bf 668
f1387719
PP
669sub dist_core {
670 my($self) = shift;
479d2113
MS
671
672 my $make_frag = '';
673 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
674 shdist))
675 {
676 my $method = $target.'_target';
677 $make_frag .= "\n";
678 $make_frag .= $self->$method();
679 }
680
681 return $make_frag;
682}
683
684
685=item B<dist_target>
686
687 my $make_frag = $MM->dist_target;
688
689Returns the 'dist' target to make an archive for distribution. This
690target simply checks to make sure the Makefile is up-to-date and
691depends on $(DIST_DEFAULT).
692
693=cut
694
695sub dist_target {
696 my($self) = shift;
697
698 my $date_check = $self->oneliner(<<'CODE', ['-l']);
699print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
ad2f23df 700 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
479d2113
MS
701CODE
702
703 return sprintf <<'MAKE_FRAG', $date_check;
2530b651 704dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
479d2113
MS
705 $(NOECHO) %s
706MAKE_FRAG
707}
708
709=item B<tardist_target>
1e44e2bf 710
479d2113
MS
711 my $make_frag = $MM->tardist_target;
712
713Returns the 'tardist' target which is simply so 'make tardist' works.
714The real work is done by the dynamically named tardistfile_target()
715method, tardist should have that as a dependency.
716
717=cut
718
719sub tardist_target {
720 my($self) = shift;
721
722 return <<'MAKE_FRAG';
f1387719 723tardist : $(DISTVNAME).tar$(SUFFIX)
479d2113
MS
724 $(NOECHO) $(NOOP)
725MAKE_FRAG
726}
727
728=item B<zipdist_target>
729
730 my $make_frag = $MM->zipdist_target;
731
732Returns the 'zipdist' target which is simply so 'make zipdist' works.
733The real work is done by the dynamically named zipdistfile_target()
734method, zipdist should have that as a dependency.
735
736=cut
737
738sub zipdist_target {
739 my($self) = shift;
1e44e2bf 740
479d2113 741 return <<'MAKE_FRAG';
f1387719 742zipdist : $(DISTVNAME).zip
479d2113
MS
743 $(NOECHO) $(NOOP)
744MAKE_FRAG
745}
746
747=item B<tarfile_target>
748
749 my $make_frag = $MM->tarfile_target;
750
751The name of this target is the name of the tarball generated by
752tardist. This target does the actual work of turning the distdir into
753a tarball.
1e44e2bf 754
479d2113
MS
755=cut
756
757sub tarfile_target {
758 my($self) = shift;
759
760 return <<'MAKE_FRAG';
f1387719
PP
761$(DISTVNAME).tar$(SUFFIX) : distdir
762 $(PREOP)
763 $(TO_UNIX)
764 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
765 $(RM_RF) $(DISTVNAME)
766 $(COMPRESS) $(DISTVNAME).tar
767 $(POSTOP)
479d2113
MS
768MAKE_FRAG
769}
770
771=item zipfile_target
1e44e2bf 772
479d2113
MS
773 my $make_frag = $MM->zipfile_target;
774
775The name of this target is the name of the zip file generated by
776zipdist. This target does the actual work of turning the distdir into
777a zip file.
778
779=cut
780
781sub zipfile_target {
782 my($self) = shift;
783
784 return <<'MAKE_FRAG';
f1387719
PP
785$(DISTVNAME).zip : distdir
786 $(PREOP)
787 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
788 $(RM_RF) $(DISTVNAME)
789 $(POSTOP)
479d2113
MS
790MAKE_FRAG
791}
792
793=item uutardist_target
794
795 my $make_frag = $MM->uutardist_target;
796
797Converts the tarfile into a uuencoded file
798
799=cut
800
801sub uutardist_target {
802 my($self) = shift;
1e44e2bf 803
479d2113 804 return <<'MAKE_FRAG';
f1387719 805uutardist : $(DISTVNAME).tar$(SUFFIX)
479d2113
MS
806 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
807MAKE_FRAG
808}
809
810
811=item shdist_target
812
813 my $make_frag = $MM->shdist_target;
814
815Converts the distdir into a shell archive.
816
817=cut
818
819sub shdist_target {
820 my($self) = shift;
f4ae0f5e 821
479d2113 822 return <<'MAKE_FRAG';
f1387719
PP
823shdist : distdir
824 $(PREOP)
825 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
826 $(RM_RF) $(DISTVNAME)
827 $(POSTOP)
479d2113 828MAKE_FRAG
f4ae0f5e
PP
829}
830
1e44e2bf 831
f1387719 832=item dlsyms (o)
1e44e2bf 833
7292dc67
RGS
834Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files.
835
836Normally just returns an empty string.
1e44e2bf
PP
837
838=cut
839
f1387719 840sub dlsyms {
7292dc67 841 return '';
f1387719 842}
1e44e2bf 843
1e44e2bf 844
f1387719 845=item dynamic_bs (o)
1e44e2bf 846
f1387719 847Defines targets for bootstrap files.
1e44e2bf 848
f1387719 849=cut
1e44e2bf 850
f1387719
PP
851sub dynamic_bs {
852 my($self, %attribs) = @_;
853 return '
854BOOTSTRAP =
855' unless $self->has_link_code();
1e44e2bf 856
7292dc67
RGS
857 my $target = $Is_VMS ? '$(MMS$TARGET)' : '$@';
858
859 return sprintf <<'MAKE_FRAG', ($target) x 5;
479d2113 860BOOTSTRAP = $(BASEEXT).bs
1e44e2bf 861
f1387719
PP
862# As Mkbootstrap might not write a file (if none is required)
863# we use touch to prevent make continually trying to remake it.
864# The DynaLoader only reads a non-empty file.
7292dc67 865$(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
479d2113
MS
866 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
867 $(NOECHO) $(PERLRUN) \
f6d6199c 868 "-MExtUtils::Mkbootstrap" \
479d2113 869 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
7292dc67
RGS
870 $(NOECHO) $(TOUCH) %s
871 $(CHMOD) $(PERM_RW) %s
1e44e2bf 872
7292dc67
RGS
873$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
874 $(NOECHO) $(RM_RF) %s
875 - $(CP) $(BOOTSTRAP) %s
876 $(CHMOD) $(PERM_RW) %s
479d2113 877MAKE_FRAG
f1387719 878}
1e44e2bf 879
f1387719 880=item dynamic_lib (o)
1e44e2bf 881
f1387719
PP
882Defines how to produce the *.so (or equivalent) files.
883
884=cut
885
886sub dynamic_lib {
887 my($self, %attribs) = @_;
888 return '' unless $self->needs_linking(); #might be because of a subdir
1e44e2bf 889
f1387719 890 return '' unless $self->has_link_code;
f4ae0f5e 891
f1387719
PP
892 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
893 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
894 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
895 my($ldfrom) = '$(LDFROM)';
479d2113 896 $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':');
f1387719 897 my(@m);
f07bc2fb 898 my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
dedf98bc 899 my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : '';
f1387719
PP
900 push(@m,'
901# This section creates the dynamically loadable $(INST_DYNAMIC)
902# from $(OBJECT) and possibly $(MYEXTLIB).
903ARMAYBE = '.$armaybe.'
f07bc2fb 904OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
f1387719 905INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
dedf98bc 906INST_DYNAMIC_FIX = '.$ld_fix.'
f4ae0f5e 907
7292dc67 908$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
f1387719
PP
909');
910 if ($armaybe ne ':'){
911 $ldfrom = 'tmp$(LIB_EXT)';
912 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
913 push(@m,' $(RANLIB) '."$ldfrom\n");
914 }
479d2113 915 $ldfrom = "-all $ldfrom -none" if $Is_OSF;
ff0cee69 916
7f0187cb 917 # The IRIX linker doesn't use LD_RUN_PATH
479d2113 918 my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ?
e0678a30 919 qq{-rpath "$self->{LD_RUN_PATH}"} : '';
491527d0 920
a84e0cef
JH
921 # For example in AIX the shared objects/libraries from previous builds
922 # linger quite a while in the shared dynalinker cache even when nobody
923 # is using them. This is painful if one for instance tries to restart
924 # a failed build because the link command will fail unnecessarily 'cos
925 # the shared object/library is 'busy'.
926 push(@m,' $(RM_F) $@
927');
928
30afd0dc 929 my $libs = '$(LDLOADLIBS)';
ea5fc951 930
0c52c6a9 931 if (($Is_NetBSD || $Is_Interix) && $Config{'useshrplib'}) {
ea5fc951
JH
932 # Use nothing on static perl platforms, and to the flags needed
933 # to link against the shared libperl library on shared perl
934 # platforms. We peek at lddlflags to see if we need -Wl,-R
935 # or -R to add paths to the run-time library search path.
a7d1454b 936 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
af7522e5 937 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
a7d1454b 938 } elsif ($Config{'lddlflags'} =~ /-R/) {
af7522e5 939 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
a7d1454b 940 }
ea5fc951
JH
941 }
942
0a0461ad
RGS
943 my $ld_run_path_shell = "";
944 if ($self->{LD_RUN_PATH} ne "") {
945 $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
946 }
5dca256e
RGS
947
948 push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs;
949 %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
950 $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
951 $(INST_DYNAMIC_FIX)
952MAKE
953
954 push @m, <<'MAKE';
2366100d 955 $(CHMOD) $(PERM_RWX) $@
5dca256e 956MAKE
1e44e2bf 957
5dca256e 958 return join('',@m);
1e44e2bf
PP
959}
960
f1387719 961=item exescan
1e44e2bf 962
f1387719 963Deprecated method. Use libscan instead.
1e44e2bf
PP
964
965=cut
966
f1387719
PP
967sub exescan {
968 my($self,$path) = @_;
969 $path;
1e44e2bf
PP
970}
971
f1387719 972=item extliblist
1e44e2bf 973
f1387719
PP
974Called by init_others, and calls ext ExtUtils::Liblist. See
975L<ExtUtils::Liblist> for details.
1e44e2bf
PP
976
977=cut
978
f1387719
PP
979sub extliblist {
980 my($self,$libs) = @_;
981 require ExtUtils::Liblist;
982 $self->ext($libs, $Verbose);
983}
f4ae0f5e 984
f1387719 985=item find_perl
1e44e2bf 986
f1387719 987Finds the executables PERL and FULLPERL
1e44e2bf 988
f1387719 989=cut
1e44e2bf 990
f1387719
PP
991sub find_perl {
992 my($self, $ver, $names, $dirs, $trace) = @_;
993 my($name, $dir);
994 if ($trace >= 2){
479d2113 995 print "Looking for perl $ver by these names:
f1387719
PP
996@$names
997in these dirs:
998@$dirs
999";
1000 }
479d2113
MS
1001
1002 my $stderr_duped = 0;
1003 local *STDERR_COPY;
2530b651
MS
1004 unless ($Is_BSD) {
1005 if( open(STDERR_COPY, '>&STDERR') ) {
1006 $stderr_duped = 1;
1007 }
1008 else {
1009 warn <<WARNING;
479d2113
MS
1010find_perl() can't dup STDERR: $!
1011You might see some garbage while we search for Perl
1012WARNING
c4a9c615 1013 }
479d2113
MS
1014 }
1015
ec751b0b 1016 foreach $name (@$names){
479d2113
MS
1017 foreach $dir (@$dirs){
1018 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1019 my ($abs, $val);
1020 if ($self->file_name_is_absolute($name)) { # /foo/bar
1021 $abs = $name;
1022 } elsif ($self->canonpath($name) eq
1023 $self->canonpath(basename($name))) { # foo
1024 $abs = $self->catfile($dir, $name);
1025 } else { # foo/bar
1026 $abs = $self->catfile($Curdir, $name);
1027 }
1028 print "Checking $abs\n" if ($trace >= 2);
1029 next unless $self->maybe_command($abs);
1030 print "Executing $abs\n" if ($trace >= 2);
1031
03c94fc2 1032 my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"};
2530b651 1033 # To avoid using the unportable 2>&1 to supress STDERR,
c4a9c615
AE
1034 # we close it before running the command.
1035 # However, thanks to a thread library bug in many BSDs
1036 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1037 # we cannot use the fancier more portable way in here
1038 # but instead need to use the traditional 2>&1 construct.
2530b651
MS
1039 if ($Is_BSD) {
1040 $val = `$version_check 2>&1`;
c4a9c615
AE
1041 } else {
1042 close STDERR if $stderr_duped;
1043 $val = `$version_check`;
1044 open STDERR, '>&STDERR_COPY' if $stderr_duped;
1045 }
479d2113
MS
1046
1047 if ($val =~ /^VER_OK/) {
1048 print "Using PERL=$abs\n" if $trace;
1049 return $abs;
1050 } elsif ($trace >= 2) {
1051 print "Result: '$val'\n";
1052 }
1053 }
1e44e2bf 1054 }
f1387719
PP
1055 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1056 0; # false and not empty
1057}
1e44e2bf 1058
f4ae0f5e 1059
84902520
TB
1060=item fixin
1061
e0678a30
MS
1062 $mm->fixin(@files);
1063
1064Inserts the sharpbang or equivalent magic number to a set of @files.
84902520
TB
1065
1066=cut
1067
1068sub fixin { # stolen from the pink Camel book, more or less
e0678a30
MS
1069 my($self, @files) = @_;
1070
1071 my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1072 for my $file (@files) {
dedf98bc
MS
1073 my $file_new = "$file.new";
1074 my $file_bak = "$file.bak";
1075
84902520
TB
1076 local(*FIXIN);
1077 local(*FIXOUT);
45bc4d3a 1078 open(FIXIN, $file) or croak "Can't process '$file': $!";
84902520
TB
1079 local $/ = "\n";
1080 chomp(my $line = <FIXIN>);
1081 next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
1082 # Now figure out the interpreter name.
1083 my($cmd,$arg) = split ' ', $line, 2;
1084 $cmd =~ s!^.*/!!;
1085
1086 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
e0678a30 1087 my $interpreter;
84902520 1088 if ($cmd eq "perl") {
fb73857a
PP
1089 if ($Config{startperl} =~ m,^\#!.*/perl,) {
1090 $interpreter = $Config{startperl};
1091 $interpreter =~ s,^\#!,,;
1092 } else {
1093 $interpreter = $Config{perlpath};
1094 }
84902520 1095 } else {
479d2113 1096 my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path;
84902520
TB
1097 $interpreter = '';
1098 my($dir);
1099 foreach $dir (@absdirs) {
1100 if ($self->maybe_command($cmd)) {
1101 warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter;
479d2113 1102 $interpreter = $self->catfile($dir,$cmd);
84902520
TB
1103 }
1104 }
1105 }
1106 # Figure out how to invoke interpreter on this machine.
1107
1108 my($shb) = "";
1109 if ($interpreter) {
1110 print STDOUT "Changing sharpbang in $file to $interpreter" if $Verbose;
f5cd9d9c 1111 # this is probably value-free on DOSISH platforms
84902520
TB
1112 if ($does_shbang) {
1113 $shb .= "$Config{'sharpbang'}$interpreter";
1114 $shb .= ' ' . $arg if defined $arg;
1115 $shb .= "\n";
1116 }
1117 $shb .= qq{
1118eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
90248788 1119 if 0; # not running under some shell
f5cd9d9c 1120} unless $Is_Win32; # this won't work on win32, so don't
84902520
TB
1121 } else {
1122 warn "Can't find $cmd in PATH, $file unchanged"
1123 if $Verbose;
1124 next;
1125 }
1126
dedf98bc 1127 unless ( open(FIXOUT,">$file_new") ) {
84902520
TB
1128 warn "Can't create new $file: $!\n";
1129 next;
1130 }
84902520
TB
1131
1132 # Print out the new #! line (or equivalent).
1133 local $\;
1134 undef $/;
1135 print FIXOUT $shb, <FIXIN>;
1136 close FIXIN;
1137 close FIXOUT;
985777a9 1138
dedf98bc
MS
1139 chmod 0666, $file_bak;
1140 unlink $file_bak;
7292dc67 1141 unless ( _rename($file, $file_bak) ) {
dedf98bc 1142 warn "Can't rename $file to $file_bak: $!";
f5cd9d9c
GS
1143 next;
1144 }
7292dc67 1145 unless ( _rename($file_new, $file) ) {
dedf98bc 1146 warn "Can't rename $file_new to $file: $!";
7292dc67 1147 unless ( _rename($file_bak, $file) ) {
dedf98bc
MS
1148 warn "Can't rename $file_bak back to $file either: $!";
1149 warn "Leaving $file renamed as $file_bak\n";
f5cd9d9c
GS
1150 }
1151 next;
1152 }
dedf98bc 1153 unlink $file_bak;
84902520 1154 } continue {
985777a9 1155 close(FIXIN) if fileno(FIXIN);
84902520
TB
1156 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
1157 }
1158}
1159
7292dc67
RGS
1160
1161sub _rename {
1162 my($old, $new) = @_;
1163
1164 foreach my $file ($old, $new) {
1165 if( $Is_VMS and basename($file) !~ /\./ ) {
1166 # rename() in 5.8.0 on VMS will not rename a file if it
1167 # does not contain a dot yet it returns success.
1168 $file = "$file.";
1169 }
1170 }
1171
1172 return rename($old, $new);
1173}
1174
1175
f1387719
PP
1176=item force (o)
1177
7292dc67 1178Writes an empty FORCE: target.
f1387719
PP
1179
1180=cut
1e44e2bf 1181
f1387719
PP
1182sub force {
1183 my($self) = shift;
1184 '# Phony target to force checking subdirectories.
1185FORCE:
479d2113 1186 $(NOECHO) $(NOOP)
f1387719 1187';
1e44e2bf
PP
1188}
1189
f1387719 1190=item guess_name
1e44e2bf 1191
f1387719
PP
1192Guess the name of this package by examining the working directory's
1193name. MakeMaker calls this only if the developer has not supplied a
1194NAME attribute.
1e44e2bf 1195
f1387719 1196=cut
f4ae0f5e 1197
f1387719
PP
1198# ';
1199
1200sub guess_name {
1201 my($self) = @_;
1202 use Cwd 'cwd';
1203 my $name = basename(cwd());
4f44ac69 1204 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
f1387719
PP
1205 # strip minus or underline
1206 # followed by a float or some such
1207 print "Warning: Guessing NAME [$name] from current directory name.\n";
1208 $name;
1209}
1210
1211=item has_link_code
1212
1213Returns true if C, XS, MYEXTLIB or similar objects exist within this
1214object that need a compiler. Does not descend into subdirectories as
1215needs_linking() does.
f4ae0f5e
PP
1216
1217=cut
1218
f1387719
PP
1219sub has_link_code {
1220 my($self) = shift;
1221 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1222 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1223 $self->{HAS_LINK_CODE} = 1;
1224 return 1;
f4ae0f5e 1225 }
f1387719 1226 return $self->{HAS_LINK_CODE} = 0;
f4ae0f5e
PP
1227}
1228
cae6c631 1229
f1387719 1230=item init_dirscan
f4ae0f5e 1231
479d2113
MS
1232Scans the directory structure and initializes DIR, XS, XS_FILES, PM,
1233C, C_FILES, O_FILES, H, H_FILES, PL_FILES, MAN*PODS, EXE_FILES.
1234
1235Called by init_main.
f1387719
PP
1236
1237=cut
1238
1239sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1240 my($self) = @_;
5dca256e 1241 my($name, %dir, %xs, %c, %h, %pl_files, %manifypods);
e3aa3ecb 1242 my %pm;
e0678a30 1243
5dca256e 1244 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
e0678a30
MS
1245
1246 # ignore the distdir
1247 $Is_VMS ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1248 : $ignore{$self->{DISTVNAME}} = 1;
1249
1250 @ignore{map lc, keys %ignore} = values %ignore if $Is_VMS;
1251
f6d6199c 1252 foreach $name ($self->lsdir($Curdir)){
4ecf31dc 1253 next if $name =~ /\#/;
f6d6199c 1254 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
f1387719
PP
1255 next unless $self->libscan($name);
1256 if (-d $name){
760ac839 1257 next if -l $name; # We do not support symlinks at all
5e719f03 1258 next if $self->{NORECURS};
479d2113 1259 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
4f44ac69
GS
1260 } elsif ($name =~ /\.xs\z/){
1261 my($c); ($c = $name) =~ s/\.xs\z/.c/;
f1387719
PP
1262 $xs{$name} = $c;
1263 $c{$c} = 1;
4f44ac69 1264 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
f1387719
PP
1265 $c{$name} = 1
1266 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
4f44ac69 1267 } elsif ($name =~ /\.h\z/i){
f1387719 1268 $h{$name} = 1;
4f44ac69
GS
1269 } elsif ($name =~ /\.PL\z/) {
1270 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
933fea7f 1271 } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
918c0b2d 1272 # case-insensitive filesystem, one dot per name, so foo.h.PL
933fea7f 1273 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
6ee623d5
GS
1274 local($/); open(PL,$name); my $txt = <PL>; close PL;
1275 if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
4f44ac69 1276 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
6ee623d5 1277 }
f6d6199c 1278 else {
479d2113 1279 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
f6d6199c 1280 }
4f44ac69 1281 } elsif ($name =~ /\.(p[ml]|pod)\z/){
479d2113 1282 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
f1387719
PP
1283 }
1284 }
f4ae0f5e 1285
f1387719
PP
1286 # Some larger extensions often wish to install a number of *.pm/pl
1287 # files into the library in various locations.
f4ae0f5e 1288
f1387719
PP
1289 # The attribute PMLIBDIRS holds an array reference which lists
1290 # subdirectories which we should search for library files to
1291 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1292 # recursively search through the named directories (skipping any
1293 # which don't exist or contain Makefile.PL files).
f4ae0f5e 1294
f1387719
PP
1295 # For each *.pm or *.pl file found $self->libscan() is called with
1296 # the default installation path in $_[1]. The return value of
1297 # libscan defines the actual installation location. The default
1298 # libscan function simply returns the path. The file is skipped
1299 # if libscan returns false.
f4ae0f5e 1300
f1387719
PP
1301 # The default installation location passed to libscan in $_[1] is:
1302 #
1303 # ./*.pm => $(INST_LIBDIR)/*.pm
1304 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1305 # ./lib/... => $(INST_LIB)/...
1306 #
1307 # In this way the 'lib' directory is seen as the root of the actual
1308 # perl library whereas the others are relative to INST_LIBDIR
1309 # (which includes PARENT_NAME). This is a subtle distinction but one
1310 # that's important for nested modules.
1e44e2bf 1311
479d2113
MS
1312 unless( $self->{PMLIBDIRS} ) {
1313 if( $Is_VMS ) {
1314 # Avoid logical name vs directory collisions
1315 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1316 }
1317 else {
1318 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1319 }
d71e5ff2 1320 }
1e44e2bf 1321
f1387719 1322 #only existing directories that aren't in $dir are allowed
1e44e2bf 1323
f1387719
PP
1324 # Avoid $_ wherever possible:
1325 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1326 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1327 my ($pmlibdir);
1328 @{$self->{PMLIBDIRS}} = ();
1329 foreach $pmlibdir (@pmlibdirs) {
1330 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1e44e2bf 1331 }
1e44e2bf 1332
f1387719
PP
1333 if (@{$self->{PMLIBDIRS}}){
1334 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1335 if ($Verbose >= 2);
1336 require File::Find;
e0678a30
MS
1337 File::Find::find(sub {
1338 if (-d $_){
479d2113 1339 unless ($self->libscan($_)){
e0678a30
MS
1340 $File::Find::prune = 1;
1341 }
1342 return;
1343 }
1344 return if /\#/;
f6d6199c 1345 return if /~$/; # emacs temp files
431b0fc4 1346 return if /,v$/; # RCS files
f6d6199c
MS
1347
1348 my $path = $File::Find::name;
1349 my $prefix = $self->{INST_LIBDIR};
1350 my $striplibpath;
1351
1352 $prefix = $self->{INST_LIB}
1353 if ($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i;
1354
479d2113 1355 my($inst) = $self->catfile($prefix,$striplibpath);
f1387719
PP
1356 local($_) = $inst; # for backwards compatibility
1357 $inst = $self->libscan($inst);
1358 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1359 return unless $inst;
1360 $pm{$path} = $inst;
1361 }, @{$self->{PMLIBDIRS}});
1362 }
1e44e2bf 1363
479d2113
MS
1364 $self->{PM} ||= \%pm;
1365 $self->{PL_FILES} ||= \%pl_files;
1366
1367 $self->{DIR} ||= [sort keys %dir];
1368
1369 $self->{XS} ||= \%xs;
1370 $self->{C} ||= [sort keys %c];
1371 my @o_files = @{$self->{C}};
1372 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
1373
1374 $self->{H} ||= [sort keys %h];
1e44e2bf 1375
f1387719 1376 # Set up names of manual pages to generate from pods
cae6c631 1377 my %pods;
f6d6199c 1378 foreach my $man (qw(MAN1 MAN3)) {
cae6c631
JD
1379 unless ($self->{"${man}PODS"}) {
1380 $self->{"${man}PODS"} = {};
e0678a30
MS
1381 $pods{$man} = 1 unless
1382 $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/;
cae6c631
JD
1383 }
1384 }
1385
f6d6199c 1386 if ($pods{MAN1}) {
f1387719
PP
1387 if ( exists $self->{EXE_FILES} ) {
1388 foreach $name (@{$self->{EXE_FILES}}) {
f1387719
PP
1389 local *FH;
1390 my($ispod)=0;
f1387719 1391 if (open(FH,"<$name")) {
f1387719 1392 while (<FH>) {
479d2113 1393 if (/^=(?:head\d+|item|pod)\b/) {
f1387719
PP
1394 $ispod=1;
1395 last;
1396 }
1397 }
f1387719
PP
1398 close FH;
1399 } else {
1400 # If it doesn't exist yet, we assume, it has pods in it
1401 $ispod = 1;
1e44e2bf 1402 }
cae6c631 1403 next unless $ispod;
cae6c631
JD
1404 if ($pods{MAN1}) {
1405 $self->{MAN1PODS}->{$name} =
479d2113 1406 $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)");
1e44e2bf 1407 }
f1387719 1408 }
1e44e2bf
PP
1409 }
1410 }
f6d6199c 1411 if ($pods{MAN3}) {
f1387719
PP
1412 my %manifypods = (); # we collect the keys first, i.e. the files
1413 # we have to convert to pod
1414 foreach $name (keys %{$self->{PM}}) {
4f44ac69 1415 if ($name =~ /\.pod\z/ ) {
f1387719 1416 $manifypods{$name} = $self->{PM}{$name};
4f44ac69 1417 } elsif ($name =~ /\.p[ml]\z/ ) {
f1387719
PP
1418 local *FH;
1419 my($ispod)=0;
f1387719 1420 if (open(FH,"<$name")) {
f1387719 1421 while (<FH>) {
479d2113 1422 if (/^=head1\s+\w+/) {
f1387719
PP
1423 $ispod=1;
1424 last;
1425 }
1426 }
f1387719
PP
1427 close FH;
1428 } else {
1429 $ispod = 1;
1430 }
1431 if( $ispod ) {
1432 $manifypods{$name} = $self->{PM}{$name};
1433 }
1434 }
1435 }
1436
1437 # Remove "Configure.pm" and similar, if it's not the only pod listed
e0678a30
MS
1438 # To force inclusion, just name it "Configure.pod", or override
1439 # MAN3PODS
f1387719 1440 foreach $name (keys %manifypods) {
40b90ac3 1441 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
f1387719
PP
1442 delete $manifypods{$name};
1443 next;
1444 }
1445 my($manpagename) = $name;
4f44ac69 1446 $manpagename =~ s/\.p(od|m|l)\z//;
479d2113 1447 # everything below lib is ok
431b0fc4 1448 unless($manpagename =~ s!^\W*lib\W+!!s) {
479d2113
MS
1449 $manpagename = $self->catfile(
1450 split(/::/,$self->{PARENT_NAME}),$manpagename
1451 );
f1387719 1452 }
cae6c631
JD
1453 if ($pods{MAN3}) {
1454 $manpagename = $self->replace_manpage_separator($manpagename);
1455 $self->{MAN3PODS}->{$name} =
479d2113 1456 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
cae6c631 1457 }
1e44e2bf
PP
1458 }
1459 }
f1387719 1460}
1e44e2bf 1461
479d2113
MS
1462=item init_DIRFILESEP
1463
1464Using / for Unix. Called by init_main.
1465
1466=cut
1467
1468sub init_DIRFILESEP {
1469 my($self) = shift;
1470
1471 $self->{DIRFILESEP} = '/';
1472}
1473
1474
f1387719 1475=item init_main
1e44e2bf 1476
cf346138 1477Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
75e2e551 1478EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
30361541 1479INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
75e2e551 1480OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
e0678a30 1481PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
479d2113 1482VERSION_SYM, XS_VERSION.
f4ae0f5e 1483
f1387719 1484=cut
1e44e2bf 1485
f1387719
PP
1486sub init_main {
1487 my($self) = @_;
1e44e2bf 1488
f1387719 1489 # --- Initialize Module Name and Paths
1e44e2bf 1490
f1387719
PP
1491 # NAME = Foo::Bar::Oracle
1492 # FULLEXT = Foo/Bar/Oracle
1493 # BASEEXT = Oracle
f1387719
PP
1494 # PARENT_NAME = Foo::Bar
1495### Only UNIX:
1496### ($self->{FULLEXT} =
1497### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
479d2113 1498 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1e44e2bf 1499
1e44e2bf 1500
f1387719 1501 # Copied from DynaLoader:
1e44e2bf 1502
f1387719
PP
1503 my(@modparts) = split(/::/,$self->{NAME});
1504 my($modfname) = $modparts[-1];
1e44e2bf 1505
f1387719
PP
1506 # Some systems have restrictions on files names for DLL's etc.
1507 # mod2fname returns appropriate file base name (typically truncated)
1508 # It may also edit @modparts if required.
1509 if (defined &DynaLoader::mod2fname) {
1510 $modfname = &DynaLoader::mod2fname(\@modparts);
bab2b58e 1511 }
1e44e2bf 1512
4f44ac69 1513 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
e0678a30 1514 $self->{PARENT_NAME} ||= '';
f1387719 1515
760ac839 1516 if (defined &DynaLoader::mod2fname) {
f1387719
PP
1517 # As of 5.001m, dl_os2 appends '_'
1518 $self->{DLBASE} = $modfname;
1519 } else {
1520 $self->{DLBASE} = '$(BASEEXT)';
1521 }
1522
1e44e2bf 1523
e0678a30 1524 # --- Initialize PERL_LIB, PERL_SRC
1e44e2bf 1525
f1387719
PP
1526 # *Real* information: where did we get these two from? ...
1527 my $inc_config_dir = dirname($INC{'Config.pm'});
1528 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1e44e2bf 1529
f1387719
PP
1530 unless ($self->{PERL_SRC}){
1531 my($dir);
f6d6199c 1532 foreach $dir ($Updir,
479d2113
MS
1533 $self->catdir($Updir,$Updir),
1534 $self->catdir($Updir,$Updir,$Updir),
1535 $self->catdir($Updir,$Updir,$Updir,$Updir),
1536 $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir))
f6d6199c 1537 {
f1387719 1538 if (
479d2113 1539 -f $self->catfile($dir,"config_h.SH")
f1387719 1540 &&
479d2113 1541 -f $self->catfile($dir,"perl.h")
f1387719 1542 &&
479d2113 1543 -f $self->catfile($dir,"lib","Exporter.pm")
f1387719
PP
1544 ) {
1545 $self->{PERL_SRC}=$dir ;
1546 last;
1547 }
1548 }
1549 }
e0678a30
MS
1550
1551 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1552 $self->{PERL_CORE} and !$self->{PERL_SRC};
1553
f1387719 1554 if ($self->{PERL_SRC}){
479d2113 1555 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1e44e2bf 1556
57b1a898
MS
1557 if (defined $Cross::platform) {
1558 $self->{PERL_ARCHLIB} =
479d2113 1559 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
57b1a898 1560 $self->{PERL_INC} =
479d2113 1561 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
57b1a898
MS
1562 $Is_Win32?("CORE"):());
1563 }
1564 else {
1565 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1566 $self->{PERL_INC} = ($Is_Win32) ?
479d2113 1567 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
57b1a898 1568 }
e2a02c1e 1569
137443ea 1570 # catch a situation that has occurred a few times in the past:
bab2b58e 1571 unless (
479d2113 1572 -s $self->catfile($self->{PERL_SRC},'cflags')
bab2b58e
AK
1573 or
1574 $Is_VMS
1575 &&
479d2113 1576 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
bab2b58e 1577 or
137443ea 1578 $Is_Win32
bab2b58e
AK
1579 ){
1580 warn qq{
f1387719
PP
1581You cannot build extensions below the perl source tree after executing
1582a 'make clean' in the perl source tree.
1e44e2bf 1583
f1387719
PP
1584To rebuild extensions distributed with the perl source you should
1585simply Configure (to include those extensions) and then build perl as
1586normal. After installing perl the source tree can be deleted. It is
1587not needed for building extensions by running 'perl Makefile.PL'
1588usually without extra arguments.
1e44e2bf 1589
f1387719
PP
1590It is recommended that you unpack and build additional extensions away
1591from the perl source tree.
bab2b58e
AK
1592};
1593 }
f1387719
PP
1594 } else {
1595 # we should also consider $ENV{PERL5LIB} here
23614c1f 1596 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
e0678a30
MS
1597 $self->{PERL_LIB} ||= $Config{privlibexp};
1598 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
479d2113 1599 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
f1387719 1600 my $perl_h;
23614c1f 1601
479d2113 1602 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
23614c1f
JH
1603 and not $old){
1604 # Maybe somebody tries to build an extension with an
1605 # uninstalled Perl outside of Perl build tree
1606 my $found;
1607 for my $dir (@INC) {
479d2113 1608 $found = $dir, last if -e $self->catdir($dir, "Config.pm");
23614c1f
JH
1609 }
1610 if ($found) {
1611 my $inc = dirname $found;
479d2113 1612 if (-e $self->catdir($inc, "perl.h")) {
23614c1f
JH
1613 $self->{PERL_LIB} = $found;
1614 $self->{PERL_ARCHLIB} = $found;
1615 $self->{PERL_INC} = $inc;
1616 $self->{UNINSTALLED_PERL} = 1;
1617 print STDOUT <<EOP;
1618... Detected uninstalled Perl. Trying to continue.
1619EOP
1620 }
1621 }
a7d1454b 1622 }
f1387719 1623 }
1e44e2bf 1624
f1387719
PP
1625 # We get SITELIBEXP and SITEARCHEXP directly via
1626 # Get_from_Config. When we are running standard modules, these
1627 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1628 # set it to "site". I prefer that INSTALLDIRS be set from outside
1629 # MakeMaker.
1630 $self->{INSTALLDIRS} ||= "site";
1e44e2bf 1631
e0678a30
MS
1632 $self->{MAN1EXT} ||= $Config{man1ext};
1633 $self->{MAN3EXT} ||= $Config{man3ext};
f1387719 1634
f1387719
PP
1635 # Get some stuff out of %Config if we haven't yet done so
1636 print STDOUT "CONFIG must be an array ref\n"
1637 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1638 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1639 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
e0678a30 1640 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
479d2113
MS
1641 my(%once_only);
1642 foreach my $m (@{$self->{CONFIG}}){
f1387719
PP
1643 next if $once_only{$m};
1644 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
e0678a30
MS
1645 unless exists $Config{$m};
1646 $self->{uc $m} ||= $Config{$m};
f1387719 1647 $once_only{$m} = 1;
1e44e2bf 1648 }
1e44e2bf 1649
f1387719
PP
1650# This is too dangerous:
1651# if ($^O eq "next") {
1652# $self->{AR} = "libtool";
1653# $self->{AR_STATIC_ARGS} = "-o";
1654# }
1655# But I leave it as a placeholder
1e44e2bf 1656
f1387719 1657 $self->{AR_STATIC_ARGS} ||= "cr";
1e44e2bf 1658
f1387719 1659 # These should never be needed
f1387719
PP
1660 $self->{OBJ_EXT} ||= '.o';
1661 $self->{LIB_EXT} ||= '.a';
1662
1663 $self->{MAP_TARGET} ||= "perl";
1664
1665 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1666
1667 # make a simple check if we find Exporter
1668 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1669 (Exporter.pm not found)"
479d2113 1670 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
f1387719 1671 $self->{NAME} eq "ExtUtils::MakeMaker";
1e44e2bf
PP
1672}
1673
f1387719 1674=item init_others
1e44e2bf 1675
60537fc0 1676Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
479d2113
MS
1677OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1678FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
e3aa3ecb 1679TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1e44e2bf
PP
1680
1681=cut
1682
f1387719 1683sub init_others { # --- Initialize Other Attributes
1e44e2bf 1684 my($self) = shift;
1e44e2bf 1685
60537fc0 1686 $self->{LD} ||= 'ld';
30361541 1687
f1387719
PP
1688 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1689 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1690 # undefined. In any case we turn it into an anon array:
1e44e2bf 1691
f1387719 1692 # May check $Config{libs} too, thus not empty.
479d2113 1693 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
f4ae0f5e 1694
479d2113 1695 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
f1387719
PP
1696 $self->{LD_RUN_PATH} = "";
1697 my($libs);
1698 foreach $libs ( @{$self->{LIBS}} ){
1699 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1700 my(@libs) = $self->extliblist($libs);
1701 if ($libs[0] or $libs[1] or $libs[2]){
1702 # LD_RUN_PATH now computed by ExtUtils::Liblist
e0678a30
MS
1703 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1704 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
f1387719
PP
1705 last;
1706 }
1707 }
f4ae0f5e 1708
f1387719
PP
1709 if ( $self->{OBJECT} ) {
1710 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1711 } else {
1712 # init_dirscan should have found out, if we have C files
1713 $self->{OBJECT} = "";
1714 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1e44e2bf 1715 }
f1387719
PP
1716 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1717 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1718 $self->{PERLMAINCC} ||= '$(CC)';
1719 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1e44e2bf 1720
f1387719
PP
1721 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1722 # the 'dynamic' section of MM. We don't have this problem with
1723 # 'static', since we either must use it (%Config says we can't
1724 # use dynamic loading) or the caller asked for it explicitly.
1725 if (!$self->{LINKTYPE}) {
1726 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1727 ? 'static'
e0678a30 1728 : ($Config{usedl} ? 'dynamic' : 'static');
f1387719
PP
1729 };
1730
479d2113
MS
1731 $self->{NOOP} ||= '$(SHELL) -c true';
1732 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1733
7292dc67 1734 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
a7d1454b
RGS
1735 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1736 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1737 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
479d2113 1738
7292dc67
RGS
1739 # Some makes require a wrapper around macros passed in on the command
1740 # line.
1741 $self->{MACROSTART} ||= '';
1742 $self->{MACROEND} ||= '';
1743
1744 # Not everybody uses -f to indicate "use this Makefile instead"
1745 $self->{USEMAKEFILE} ||= '-f';
1746
479d2113
MS
1747 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1748
1749 $self->{ECHO} ||= 'echo';
e3aa3ecb 1750 $self->{ECHO_N} ||= 'echo -n';
479d2113
MS
1751 $self->{RM_F} ||= "rm -f";
1752 $self->{RM_RF} ||= "rm -rf";
1753 $self->{TOUCH} ||= "touch";
1754 $self->{TEST_F} ||= "test -f";
1755 $self->{CP} ||= "cp";
1756 $self->{MV} ||= "mv";
1757 $self->{CHMOD} ||= "chmod";
5dca256e 1758 $self->{MKPATH} ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
479d2113 1759 $self->{EQUALIZE_TIMESTAMP} ||=
5dca256e 1760 '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
479d2113
MS
1761
1762 $self->{UNINST} ||= 0;
1763 $self->{VERBINST} ||= 0;
1764 $self->{MOD_INSTALL} ||=
1765 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1766install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1767CODE
7292dc67 1768 $self->{DOC_INSTALL} ||=
5dca256e 1769 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
7292dc67 1770 $self->{UNINSTALL} ||=
5dca256e 1771 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
479d2113 1772 $self->{WARN_IF_OLD_PACKLIST} ||=
5dca256e 1773 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
7292dc67
RGS
1774 $self->{FIXIN} ||=
1775 q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
479d2113
MS
1776
1777 $self->{UMASK_NULL} ||= "umask 0";
1778 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1779
1780 return 1;
1e44e2bf
PP
1781}
1782
e0678a30 1783
479d2113
MS
1784=item init_linker
1785
1786Unix has no need of special linker flags.
1787
1788=cut
1789
1790sub init_linker {
1791 my($self) = shift;
1792 $self->{PERL_ARCHIVE} ||= '';
1793 $self->{PERL_ARCHIVE_AFTER} ||= '';
1794 $self->{EXPORT_LIST} ||= '';
1795}
1796
1797
45bc4d3a
JH
1798=begin _protected
1799
1800=item init_lib2arch
1801
1802 $mm->init_lib2arch
1803
1804=end _protected
1805
1806=cut
1807
1808sub init_lib2arch {
1809 my($self) = shift;
1810
1811 # The user who requests an installation directory explicitly
1812 # should not have to tell us an architecture installation directory
1813 # as well. We look if a directory exists that is named after the
1814 # architecture. If not we take it as a sign that it should be the
1815 # same as the requested installation directory. Otherwise we take
1816 # the found one.
1817 for my $libpair ({l=>"privlib", a=>"archlib"},
1818 {l=>"sitelib", a=>"sitearch"},
1819 {l=>"vendorlib", a=>"vendorarch"},
1820 )
1821 {
1822 my $lib = "install$libpair->{l}";
1823 my $Lib = uc $lib;
1824 my $Arch = uc "install$libpair->{a}";
1825 if( $self->{$Lib} && ! $self->{$Arch} ){
1826 my($ilib) = $Config{$lib};
1827
1828 $self->prefixify($Arch,$ilib,$self->{$Lib});
1829
1830 unless (-d $self->{$Arch}) {
1831 print STDOUT "Directory $self->{$Arch} not found\n"
1832 if $Verbose;
1833 $self->{$Arch} = $self->{$Lib};
1834 }
1835 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1836 }
1837 }
1838}
1839
5c161494 1840
75e2e551
MS
1841=item init_PERL
1842
e0678a30 1843 $mm->init_PERL;
75e2e551 1844
e0678a30
MS
1845Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1846*PERLRUN* permutations.
75e2e551
MS
1847
1848 PERL is allowed to be miniperl
1849 FULLPERL must be a complete perl
479d2113 1850
e0678a30 1851 ABSPERL is PERL converted to an absolute path
75e2e551
MS
1852
1853 *PERLRUN contains everything necessary to run perl, find it's
1854 libraries, etc...
1855
1856 *PERLRUNINST is *PERLRUN + everything necessary to find the
1857 modules being built.
1858
1859=cut
1860
1861sub init_PERL {
1862 my($self) = shift;
1863
1864 my @defpath = ();
1865 foreach my $component ($self->{PERL_SRC}, $self->path(),
e0678a30 1866 $Config{binexp})
75e2e551
MS
1867 {
1868 push @defpath, $component if defined $component;
1869 }
1870
1871 # Build up a set of file names (not command names).
479d2113 1872 my $thisperl = $self->canonpath($^X);
30361541
JH
1873 $thisperl .= $Config{exe_ext} unless
1874 # VMS might have a file version # at the end
1875 $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
1876 : $thisperl =~ m/$Config{exe_ext}$/i;
479d2113
MS
1877
1878 # We need a relative path to perl when in the core.
1879 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
1880
75e2e551
MS
1881 my @perls = ($thisperl);
1882 push @perls, map { "$_$Config{exe_ext}" }
1883 ('perl', 'perl5', "perl$Config{version}");
1884
1885 # miniperl has priority over all but the cannonical perl when in the
1886 # core. Otherwise its a last resort.
1887 my $miniperl = "miniperl$Config{exe_ext}";
1888 if( $self->{PERL_CORE} ) {
1889 splice @perls, 1, 0, $miniperl;
1890 }
1891 else {
1892 push @perls, $miniperl;
1893 }
1894
1895 $self->{PERL} ||=
1896 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
1897 # don't check if perl is executable, maybe they have decided to
1898 # supply switches with perl
1899
30361541
JH
1900 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
1901 my $perl_name = 'perl';
1902 $perl_name = 'ndbgperl' if $Is_VMS &&
1903 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
1904
1905 # XXX This logic is flawed. If "miniperl" is anywhere in the path
1906 # it will get confused. It should be fixed to work only on the filename.
75e2e551 1907 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
30361541 1908 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
75e2e551
MS
1909 unless $self->{FULLPERL};
1910
e0678a30
MS
1911 # Little hack to get around VMS's find_perl putting "MCR" in front
1912 # sometimes.
1913 $self->{ABSPERL} = $self->{PERL};
1914 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
479d2113 1915 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
e0678a30
MS
1916 $self->{ABSPERL} = '$(PERL)';
1917 }
1918 else {
479d2113 1919 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
e0678a30
MS
1920 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
1921 }
1922
75e2e551 1923 # Are we building the core?
6383bd23
SH
1924 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1925 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
75e2e551
MS
1926
1927 # How do we run perl?
e0678a30 1928 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
479d2113
MS
1929 my $run = $perl.'RUN';
1930
1931 $self->{$run} = "\$($perl)";
75e2e551
MS
1932
1933 # Make sure perl can find itself before it's installed.
479d2113 1934 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
75e2e551
MS
1935 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
1936
1937 $self->{$perl.'RUNINST'} =
e0678a30 1938 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
75e2e551
MS
1939 }
1940
1941 return 1;
1942}
1943
479d2113 1944
7292dc67 1945=item init_platform
479d2113 1946
7292dc67 1947=item platform_constants
479d2113 1948
7292dc67 1949Add MM_Unix_VERSION.
479d2113
MS
1950
1951=cut
1952
1953sub init_platform {
1954 my($self) = shift;
1955
1956 $self->{MM_Unix_VERSION} = $VERSION;
1957 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
1958 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
1959 '-Dcalloc=Perl_calloc';
1960
1961}
1962
1963sub platform_constants {
1964 my($self) = shift;
1965 my $make_frag = '';
1966
1967 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
1968 {
1969 next unless defined $self->{$macro};
1970 $make_frag .= "$macro = $self->{$macro}\n";
1971 }
1972
1973 return $make_frag;
1974}
1975
1976
e0678a30
MS
1977=item init_PERM
1978
1979 $mm->init_PERM
1980
1981Called by init_main. Initializes PERL_*
1982
1983=cut
1984
1985sub init_PERM {
1986 my($self) = shift;
1987
479d2113
MS
1988 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
1989 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
e0678a30
MS
1990
1991 return 1;
1992}
479d2113
MS
1993
1994
1995=item init_xs
1996
1997 $mm->init_xs
1998
1999Sets up macros having to do with XS code. Currently just INST_STATIC,
2000INST_DYNAMIC and INST_BOOT.
2001
2002=cut
2003
2004sub init_xs {
2005 my $self = shift;
2006
2007 if ($self->has_link_code()) {
2008 $self->{INST_STATIC} =
2009 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2010 $self->{INST_DYNAMIC} =
2011 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2012 $self->{INST_BOOT} =
2013 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2014 } else {
2015 $self->{INST_STATIC} = '';
2016 $self->{INST_DYNAMIC} = '';
2017 $self->{INST_BOOT} = '';
2018 }
2019}
75e2e551 2020
f1387719 2021=item install (o)
1e44e2bf 2022
f1387719 2023Defines the install target.
1e44e2bf
PP
2024
2025=cut
2026
f1387719
PP
2027sub install {
2028 my($self, %attribs) = @_;
1e44e2bf 2029 my(@m);
a5f75d66 2030
f1387719
PP
2031 push @m, q{
2032install :: all pure_install doc_install
7292dc67 2033 $(NOECHO) $(NOOP)
1e44e2bf 2034
f1387719 2035install_perl :: all pure_perl_install doc_perl_install
7292dc67 2036 $(NOECHO) $(NOOP)
1e44e2bf 2037
f1387719 2038install_site :: all pure_site_install doc_site_install
7292dc67 2039 $(NOECHO) $(NOOP)
1e44e2bf 2040
5c161494 2041install_vendor :: all pure_vendor_install doc_vendor_install
7292dc67 2042 $(NOECHO) $(NOOP)
5c161494 2043
f1387719 2044pure_install :: pure_$(INSTALLDIRS)_install
7292dc67 2045 $(NOECHO) $(NOOP)
1e44e2bf 2046
f1387719 2047doc_install :: doc_$(INSTALLDIRS)_install
7292dc67 2048 $(NOECHO) $(NOOP)
1e44e2bf 2049
f1387719 2050pure__install : pure_site_install
479d2113 2051 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1e44e2bf 2052
f1387719 2053doc__install : doc_site_install
479d2113 2054 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1e44e2bf 2055
f1387719 2056pure_perl_install ::
479d2113
MS
2057 $(NOECHO) $(MOD_INSTALL) \
2058 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
5e719f03
MS
2059 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2060 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2061 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2062 $(INST_BIN) $(DESTINSTALLBIN) \
2063 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2064 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2065 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
479d2113
MS
2066 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2067 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
1e44e2bf 2068
1e44e2bf 2069
f1387719 2070pure_site_install ::
479d2113
MS
2071 $(NOECHO) $(MOD_INSTALL) \
2072 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
5e719f03
MS
2073 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2074 $(INST_LIB) $(DESTINSTALLSITELIB) \
2075 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2076 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2077 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2078 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2079 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
479d2113
MS
2080 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2081 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
1e44e2bf 2082
5c161494 2083pure_vendor_install ::
479d2113
MS
2084 $(NOECHO) $(MOD_INSTALL) \
2085 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
5e719f03
MS
2086 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2087 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2088 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2089 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2090 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2091 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2092 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
5c161494 2093
f1387719 2094doc_perl_install ::
5e719f03
MS
2095 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2096 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
479d2113 2097 -$(NOECHO) $(DOC_INSTALL) \
dbc738d9 2098 "Module" "$(NAME)" \
f1387719
PP
2099 "installed into" "$(INSTALLPRIVLIB)" \
2100 LINKTYPE "$(LINKTYPE)" \
2101 VERSION "$(VERSION)" \
2102 EXE_FILES "$(EXE_FILES)" \
5e719f03 2103 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
1e44e2bf 2104
f1387719 2105doc_site_install ::
5e719f03
MS
2106 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2107 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
479d2113 2108 -$(NOECHO) $(DOC_INSTALL) \
dbc738d9 2109 "Module" "$(NAME)" \
f1387719
PP
2110 "installed into" "$(INSTALLSITELIB)" \
2111 LINKTYPE "$(LINKTYPE)" \
2112 VERSION "$(VERSION)" \
2113 EXE_FILES "$(EXE_FILES)" \
5e719f03 2114 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
5c161494
MS
2115
2116doc_vendor_install ::
5e719f03
MS
2117 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2118 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
479d2113
MS
2119 -$(NOECHO) $(DOC_INSTALL) \
2120 "Module" "$(NAME)" \
2121 "installed into" "$(INSTALLVENDORLIB)" \
2122 LINKTYPE "$(LINKTYPE)" \
2123 VERSION "$(VERSION)" \
2124 EXE_FILES "$(EXE_FILES)" \
5e719f03 2125 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
1e44e2bf 2126
f1387719 2127};
1e44e2bf 2128
f1387719
PP
2129 push @m, q{
2130uninstall :: uninstall_from_$(INSTALLDIRS)dirs
7292dc67 2131 $(NOECHO) $(NOOP)
f4ae0f5e 2132
f1387719 2133uninstall_from_perldirs ::
479d2113 2134 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
1e44e2bf 2135
f1387719 2136uninstall_from_sitedirs ::
479d2113
MS
2137 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2138
2139uninstall_from_vendordirs ::
2140 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
f1387719 2141};
1e44e2bf 2142
f1387719
PP
2143 join("",@m);
2144}
1e44e2bf 2145
f1387719 2146=item installbin (o)
1e44e2bf 2147
85fe4bb3 2148Defines targets to make and to install EXE_FILES.
1e44e2bf 2149
f1387719 2150=cut
1e44e2bf 2151
f1387719
PP
2152sub installbin {
2153 my($self) = shift;
7292dc67 2154
f1387719 2155 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
7292dc67
RGS
2156 my @exefiles = @{$self->{EXE_FILES}};
2157 return "" unless @exefiles;
2158
2159 @exefiles = map vmsify($_), @exefiles if $Is_VMS;
2160
2161 my %fromto;
2162 for my $from (@exefiles) {
479d2113 2163 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
7292dc67 2164
f1387719 2165 local($_) = $path; # for backwards compatibility
7292dc67 2166 my $to = $self->libscan($path);
f1387719 2167 print "libscan($from) => '$to'\n" if ($Verbose >=2);
64964e6d 2168
7292dc67
RGS
2169 $to = vmsify($to) if $Is_VMS;
2170 $fromto{$from} = $to;
64964e6d 2171 }
7292dc67 2172 my @to = values %fromto;
64964e6d 2173
7292dc67 2174 my @m;
84902520 2175 push(@m, qq{
7292dc67 2176EXE_FILES = @exefiles
64964e6d 2177
85fe4bb3 2178pure_all :: @to
479d2113 2179 \$(NOECHO) \$(NOOP)
1e44e2bf 2180
f1387719 2181realclean ::
84902520 2182});
1e44e2bf 2183
7292dc67
RGS
2184 # realclean can get rather large.
2185 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2186 push @m, "\n";
2187
2188
2189 # A target for each exe file.
2190 while (my($from,$to) = each %fromto) {
f1387719 2191 last unless defined $from;
7292dc67
RGS
2192
2193 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
2194%s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2195 $(NOECHO) $(RM_F) %s
2196 $(CP) %s %s
2197 $(FIXIN) %s
2198 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
2199
2200MAKE
2201
1e44e2bf 2202 }
7292dc67 2203
f1387719
PP
2204 join "", @m;
2205}
1e44e2bf 2206
1e44e2bf 2207
f4ae0f5e 2208=item linkext (o)
1e44e2bf 2209
f4ae0f5e 2210Defines the linkext target which in turn defines the LINKTYPE.
1e44e2bf
PP
2211
2212=cut
2213
2214sub linkext {
2215 my($self, %attribs) = @_;
1e44e2bf
PP
2216 # LINKTYPE => static or dynamic or ''
2217 my($linktype) = defined $attribs{LINKTYPE} ?
2218 $attribs{LINKTYPE} : '$(LINKTYPE)';
2219 "
2220linkext :: $linktype
479d2113 2221 \$(NOECHO) \$(NOOP)
1e44e2bf
PP
2222";
2223}
2224
f1387719 2225=item lsdir
1e44e2bf 2226
f1387719
PP
2227Takes as arguments a directory name and a regular expression. Returns
2228all entries in the directory that match the regular expression.
1e44e2bf
PP
2229
2230=cut
2231
f1387719
PP
2232sub lsdir {
2233 my($self) = shift;
2234 my($dir, $regex) = @_;
2235 my(@ls);
2236 my $dh = new DirHandle;
2237 $dh->open($dir || ".") or return ();
2238 @ls = $dh->read;
2239 $dh->close;
2240 @ls = grep(/$regex/, @ls) if $regex;
2241 @ls;
2242}
2243
2244=item macro (o)
2245
2246Simple subroutine to insert the macros defined by the macro attribute
2247into the Makefile.
2248
2249=cut
2250
2251sub macro {
1e44e2bf 2252 my($self,%attribs) = @_;
f1387719
PP
2253 my(@m,$key,$val);
2254 while (($key,$val) = each %attribs){
2255 last unless defined $key;
2256 push @m, "$key = $val\n";
1e44e2bf 2257 }
f1387719
PP
2258 join "", @m;
2259}
1e44e2bf 2260
f1387719 2261=item makeaperl (o)
1e44e2bf 2262
f1387719
PP
2263Called by staticmake. Defines how to write the Makefile to produce a
2264static new perl.
2265
55497cff
PP
2266By default the Makefile produced includes all the static extensions in
2267the perl library. (Purified versions of library files, e.g.,
2268DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2269
f1387719
PP
2270=cut
2271
2272sub makeaperl {
2273 my($self, %attribs) = @_;
2274 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2275 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
1e44e2bf 2276 my(@m);
f1387719
PP
2277 push @m, "
2278# --- MakeMaker makeaperl section ---
2279MAP_TARGET = $target
2280FULLPERL = $self->{FULLPERL}
2281";
2282 return join '', @m if $self->{PARENT};
1e44e2bf 2283
f1387719 2284 my($dir) = join ":", @{$self->{DIR}};
1e44e2bf 2285
f1387719
PP
2286 unless ($self->{MAKEAPERL}) {
2287 push @m, q{
2288$(MAP_TARGET) :: static $(MAKE_APERL_FILE)
7292dc67 2289 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
1e44e2bf 2290
7292dc67 2291$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
479d2113
MS
2292 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2293 $(NOECHO) $(PERLRUNINST) \
f1387719 2294 Makefile.PL DIR=}, $dir, q{ \
2530b651 2295 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
f1387719 2296 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
1e44e2bf 2297
f1387719
PP
2298 foreach (@ARGV){
2299 if( /\s/ ){
2300 s/=(.*)/='$1'/;
2301 }
2302 push @m, " \\\n\t\t$_";
2303 }
2304# push @m, map( " \\\n\t\t$_", @ARGV );
2305 push @m, "\n";
1e44e2bf 2306
f1387719
PP
2307 return join '', @m;
2308 }
1e44e2bf 2309
1e44e2bf 2310
1e44e2bf 2311
f1387719 2312 my($cccmd, $linkcmd, $lperl);
1e44e2bf 2313
1e44e2bf 2314
f1387719
PP
2315 $cccmd = $self->const_cccmd($libperl);
2316 $cccmd =~ s/^CCCMD\s*=\s*//;
f6d6199c 2317 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
e0678a30
MS
2318 $cccmd .= " $Config{cccdlflags}"
2319 if ($Config{useshrplib} eq 'true');
f1387719 2320 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
1e44e2bf 2321
f1387719
PP
2322 # The front matter of the linkcommand...
2323 $linkcmd = join ' ', "\$(CC)",
5869b1f1 2324 grep($_, @Config{qw(ldflags ccdlflags)});
f1387719 2325 $linkcmd =~ s/\s+/ /g;
93f9cb4b 2326 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
1e44e2bf 2327
f1387719 2328 # Which *.a files could we make use of...
5dca256e 2329 my %static;
f1387719
PP
2330 require File::Find;
2331 File::Find::find(sub {
2332 return unless m/\Q$self->{LIB_EXT}\E$/;
5dca256e
RGS
2333
2334 # Skip perl's libraries.
2335 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2336
2337 # Skip purified versions of libraries
2338 # (e.g., DynaLoader_pure_p1_c0_032.a)
55497cff 2339 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
1e44e2bf 2340
f1387719
PP
2341 if( exists $self->{INCLUDE_EXT} ){
2342 my $found = 0;
2343 my $incl;
2344 my $xx;
2345
4f44ac69 2346 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
f1387719
PP
2347 $xx =~ s,/?$_,,;
2348 $xx =~ s,/,::,g;
2349
2350 # Throw away anything not explicitly marked for inclusion.
2351 # DynaLoader is implied.
2352 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2353 if( $xx eq $incl ){
2354 $found++;
2355 last;
2356 }
2357 }
2358 return unless $found;
2359 }
2360 elsif( exists $self->{EXCLUDE_EXT} ){
2361 my $excl;
2362 my $xx;
1e44e2bf 2363
4f44ac69 2364 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
f1387719
PP
2365 $xx =~ s,/?$_,,;
2366 $xx =~ s,/,::,g;
1e44e2bf 2367
f1387719
PP
2368 # Throw away anything explicitly marked for exclusion
2369 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2370 return if( $xx eq $excl );
2371 }
2372 }
2373
2374 # don't include the installed version of this extension. I
2375 # leave this line here, although it is not necessary anymore:
2376 # I patched minimod.PL instead, so that Miniperl.pm won't
2377 # enclude duplicates
2378
2379 # Once the patch to minimod.PL is in the distribution, I can
2380 # drop it
4f44ac69 2381 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
f1387719
PP
2382 use Cwd 'cwd';
2383 $static{cwd() . "/" . $_}++;
2384 }, grep( -d $_, @{$searchdirs || []}) );
2385
2386 # We trust that what has been handed in as argument, will be buildable
2387 $static = [] unless $static;
2388 @static{@{$static}} = (1) x @{$static};
2389
2390 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2391 for (sort keys %static) {
4f44ac69 2392 next unless /\Q$self->{LIB_EXT}\E\z/;
f1387719
PP
2393 $_ = dirname($_) . "/extralibs.ld";
2394 push @$extra, $_;
1e44e2bf 2395 }
1e44e2bf 2396
f6d6199c 2397 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
1e44e2bf 2398
f6d6199c
MS
2399 $target ||= "perl";
2400 $tmp ||= ".";
1e44e2bf 2401
f1387719
PP
2402# MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2403# regenerate the Makefiles, MAP_STATIC and the dependencies for
2404# extralibs.all are computed correctly
2405 push @m, "
2406MAP_LINKCMD = $linkcmd
2407MAP_PERLINC = @{$perlinc || []}
2408MAP_STATIC = ",
2409join(" \\\n\t", reverse sort keys %static), "
1e44e2bf 2410
e0678a30 2411MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
f1387719
PP
2412";
2413
2414 if (defined $libperl) {
2415 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2416 }
2417 unless ($libperl && -f $lperl) { # Ilya's code...
2418 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
3f73c567 2419 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
f1387719
PP
2420 $libperl ||= "libperl$self->{LIB_EXT}";
2421 $libperl = "$dir/$libperl";
2422 $lperl ||= "libperl$self->{LIB_EXT}";
2423 $lperl = "$dir/$lperl";
ff0cee69
PP
2424
2425 if (! -f $libperl and ! -f $lperl) {
2426 # We did not find a static libperl. Maybe there is a shared one?
479d2113 2427 if ($Is_SunOS) {
e0678a30 2428 $lperl = $libperl = "$dir/$Config{libperl}";
ff0cee69 2429 # SUNOS ld does not take the full path to a shared library
479d2113 2430 $libperl = '' if $Is_SunOS4;
ff0cee69
PP
2431 }
2432 }
2433
f1387719
PP
2434 print STDOUT "Warning: $libperl not found
2435 If you're going to build a static perl binary, make sure perl is installed
2436 otherwise ignore this warning\n"
2437 unless (-f $lperl || defined($self->{PERL_SRC}));
2438 }
1e44e2bf 2439
e0678a30
MS
2440 # SUNOS ld does not take the full path to a shared library
2441 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2442
f1387719
PP
2443 push @m, "
2444MAP_LIBPERL = $libperl
e0678a30 2445LLIBPERL = $llibperl
f1387719 2446";
1e44e2bf 2447
7292dc67
RGS
2448 push @m, '
2449$(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
479d2113
MS
2450 $(NOECHO) $(RM_F) $@
2451 $(NOECHO) $(TOUCH) $@
2452';
1e44e2bf 2453
f1387719
PP
2454 my $catfile;
2455 foreach $catfile (@$extra){
2456 push @m, "\tcat $catfile >> \$\@\n";
1e44e2bf 2457 }
1e44e2bf 2458
ff0cee69 2459push @m, "
f1387719 2460\$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
e0678a30 2461 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
479d2113 2462 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
7292dc67 2463 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
479d2113 2464 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
7292dc67 2465 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
1e44e2bf 2466
f1387719
PP
2467$tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2468";
7292dc67 2469 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
1e44e2bf 2470
f1387719
PP
2471 push @m, qq{
2472$tmp/perlmain.c: $makefilename}, q{
479d2113
MS
2473 $(NOECHO) $(ECHO) Writing $@
2474 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
4f44ac69 2475 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
1e44e2bf 2476
f1387719 2477};
479d2113 2478 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
39e571d4
ML
2479} if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2480
1e44e2bf 2481
f1387719
PP
2482 push @m, q{
2483doc_inst_perl:
5e719f03
MS
2484 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2485 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
479d2113 2486 -$(NOECHO) $(DOC_INSTALL) \
dbc738d9 2487 "Perl binary" "$(MAP_TARGET)" \
f1387719
PP
2488 MAP_STATIC "$(MAP_STATIC)" \
2489 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2490 MAP_LIBPERL "$(MAP_LIBPERL)" \
5e719f03 2491 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
1e44e2bf 2492
f1387719 2493};
1e44e2bf 2494
f1387719
PP
2495 push @m, q{
2496inst_perl: pure_inst_perl doc_inst_perl
1e44e2bf 2497
f1387719 2498pure_inst_perl: $(MAP_TARGET)
5e719f03 2499 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
1e44e2bf 2500
f1387719
PP
2501clean :: map_clean
2502
2503map_clean :
2504 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2505};
2506
2507 join '', @m;
1e44e2bf
PP
2508}
2509
f1387719 2510=item makefile (o)
1e44e2bf 2511
f1387719 2512Defines how to rewrite the Makefile.
1e44e2bf
PP
2513
2514=cut
2515
f1387719
PP
2516sub makefile {
2517 my($self) = shift;
7292dc67 2518 my $m;
f1387719
PP
2519 # We do not know what target was originally specified so we
2520 # must force a manual rerun to be sure. But as it should only
2521 # happen very rarely it is not a significant problem.
7292dc67 2522 $m = '
f1387719 2523$(OBJECT) : $(FIRST_MAKEFILE)
7292dc67 2524
f1387719 2525' if $self->{OBJECT};
1e44e2bf 2526
7292dc67
RGS
2527 my $newer_than_target = $Is_VMS ? '$(MMS$SOURCE_LIST)' : '$?';
2528 my $mpl_args = join " ", map qq["$_"], @ARGV;
2529
2530 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
e3aa3ecb 2531# We take a very conservative approach here, but it's worth it.
f1387719 2532# We move Makefile to Makefile.old here to avoid gnu make looping.
dedf98bc 2533$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
7292dc67 2534 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
479d2113 2535 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
03c94fc2
RGS
2536 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2537 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
7292dc67
RGS
2538 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2539 $(PERLRUN) Makefile.PL %s
479d2113 2540 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
7292dc67 2541 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
68dc0745 2542 false
1e44e2bf 2543
7292dc67 2544MAKE_FRAG
1e44e2bf 2545
7292dc67 2546 return $m;
1e44e2bf
PP
2547}
2548
1e44e2bf 2549
f1387719 2550=item maybe_command
1e44e2bf 2551
f1387719 2552Returns true, if the argument is likely to be a command.
1e44e2bf
PP
2553
2554=cut
2555
f1387719
PP
2556sub maybe_command {
2557 my($self,$file) = @_;
2558 return $file if -x $file && ! -d $file;
2559 return;
1e44e2bf
PP
2560}
2561
1e44e2bf 2562
f1387719 2563=item needs_linking (o)
1e44e2bf 2564
f1387719
PP
2565Does this module need linking? Looks into subdirectory objects (see
2566also has_link_code())
1e44e2bf
PP
2567
2568=cut
2569
f1387719
PP
2570sub needs_linking {
2571 my($self) = shift;
2572 my($child,$caller);
2573 $caller = (caller(0))[3];
479d2113 2574 confess("needs_linking called too early") if
45bc4d3a 2575 $caller =~ /^ExtUtils::MakeMaker::/;
f1387719
PP
2576 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2577 if ($self->has_link_code or $self->{MAKEAPERL}){
2578 $self->{NEEDS_LINKING} = 1;
2579 return 1;
1e44e2bf 2580 }
f1387719
PP
2581 foreach $child (keys %{$self->{CHILDREN}}) {
2582 if ($self->{CHILDREN}->{$child}->needs_linking) {
2583 $self->{NEEDS_LINKING} = 1;
2584 return 1;
2585 }
1e44e2bf 2586 }
f1387719 2587 return $self->{NEEDS_LINKING} = 0;
1e44e2bf
PP
2588}
2589
f1387719 2590=item nicetext
1e44e2bf 2591
f1387719
PP
2592misnamed method (will have to be changed). The MM_Unix method just
2593returns the argument without further processing.
2594
2595On VMS used to insure that colons marking targets are preceded by
2596space - most Unix Makes don't need this, but it's necessary under VMS
2597to distinguish the target delimiter from a colon appearing as part of
2598a filespec.
1e44e2bf
PP
2599
2600=cut
2601
f1387719
PP
2602sub nicetext {
2603 my($self,$text) = @_;
2604 $text;
2605}
1e44e2bf 2606
e0678a30
MS
2607=item parse_abstract
2608
2609parse a file and return what you think is the ABSTRACT
2610
2611=cut
2612
2613sub parse_abstract {
2614 my($self,$parsefile) = @_;
2615 my $result;
2616 local *FH;
2617 local $/ = "\n";
2618 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2619 my $inpod = 0;
2620 my $package = $self->{DISTNAME};
2621 $package =~ s/-/::/g;
2622 while (<FH>) {
2623 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2624 next if !$inpod;
2625 chop;
2626 next unless /^($package\s-\s)(.*)/;
2627 $result = $2;
2628 last;
2629 }
2630 close FH;
2631 return $result;
2632}
2633
f1387719 2634=item parse_version
1e44e2bf 2635
5a5fd53e
GS
2636parse a file and return what you think is $VERSION in this file set to.
2637It will return the string "undef" if it can't figure out what $VERSION
afa6035d
T
2638is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
2639are okay, but my $VERSION is not.
1e44e2bf 2640
f1387719
PP
2641=cut
2642
2643sub parse_version {
2644 my($self,$parsefile) = @_;
2645 my $result;
2646 local *FH;
2647 local $/ = "\n";
a7d1454b 2648 local $_;
f1387719
PP
2649 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2650 my $inpod = 0;
2651 while (<FH>) {
2652 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
f05db7a1 2653 next if $inpod || /^\s*#/;
f1387719 2654 chop;
2530b651 2655 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
dbc738d9
PP
2656 my $eval = qq{
2657 package ExtUtils::MakeMaker::_version;
a1f8e286 2658 no strict;
bab2b58e 2659
84902520
TB
2660 local $1$2;
2661 \$$2=undef; do {
bab2b58e 2662 $_
84902520 2663 }; \$$2
dbc738d9 2664 };
57b1a898 2665 local $^W = 0;
84902520 2666 $result = eval($eval);
5a5fd53e 2667 warn "Could not eval '$eval' in $parsefile: $@" if $@;
f1387719
PP
2668 last;
2669 }
2670 close FH;
45bc4d3a
JH
2671
2672 $result = "undef" unless defined $result;
f1387719 2673 return $result;
1e44e2bf
PP
2674}
2675
1e44e2bf 2676
f1387719
PP
2677=item pasthru (o)
2678
2679Defines the string that is passed to recursive make calls in
2680subdirectories.
1e44e2bf
PP
2681
2682=cut
2683
f1387719 2684sub pasthru {
1e44e2bf 2685 my($self) = shift;
f1387719 2686 my(@m,$key);
1e44e2bf 2687
f1387719 2688 my(@pasthru);
bbce6d69
PP
2689 my($sep) = $Is_VMS ? ',' : '';
2690 $sep .= "\\\n\t";
1e44e2bf 2691
7292dc67
RGS
2692 foreach $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
2693 PREFIX INSTALLBASE)
2694 )
2695 {
5dca256e 2696 next unless defined $self->{$key};
071e6b84 2697 push @pasthru, "$key=\"\$($key)\"";
f1387719 2698 }
f4ae0f5e 2699
289e7e34 2700 foreach $key (qw(DEFINE INC)) {
5dca256e 2701 next unless defined $self->{$key};
289e7e34
JH
2702 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
2703 }
2704
bbce6d69 2705 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
f1387719
PP
2706 join "", @m;
2707}
1e44e2bf 2708
f1387719 2709=item perl_script
1e44e2bf 2710
f1387719
PP
2711Takes one argument, a file name, and returns the file name, if the
2712argument is likely to be a perl script. On MM_Unix this is true for
2713any ordinary, readable file.
1e44e2bf
PP
2714
2715=cut
2716
f1387719
PP
2717sub perl_script {
2718 my($self,$file) = @_;
2719 return $file if -r $file && -f _;
2720 return;
1e44e2bf
PP
2721}
2722
f1387719 2723=item perldepend (o)
1e44e2bf 2724
f1387719
PP
2725Defines the dependency from all *.h files that come with the perl
2726distribution.
1e44e2bf
PP
2727
2728=cut
2729
f1387719 2730sub perldepend {
1e44e2bf 2731 my($self) = shift;
f1387719 2732 my(@m);
7292dc67
RGS
2733
2734 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
2735
2736 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
f1387719
PP
2737# Check for unpropogated config.sh changes. Should never happen.
2738# We do NOT just update config.h because that is not sufficient.
2739# An out of date config.h is not fatal but complains loudly!
2740$(PERL_INC)/config.h: $(PERL_SRC)/config.sh
479d2113 2741 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
f1387719
PP
2742
2743$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
479d2113 2744 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
7292dc67
RGS
2745 %s
2746MAKE_FRAG
f1387719
PP
2747
2748 return join "", @m unless $self->needs_linking;
2749
1e44e2bf 2750 push @m, q{
f1387719 2751PERL_HDRS = \
54fc9134
GS
2752 $(PERL_INC)/EXTERN.h \
2753 $(PERL_INC)/INTERN.h \
2754 $(PERL_INC)/XSUB.h \
2755 $(PERL_INC)/av.h \
2756 $(PERL_INC)/cc_runtime.h \
2757 $(PERL_INC)/config.h \
2758 $(PERL_INC)/cop.h \
2759 $(PERL_INC)/cv.h \
2760 $(PERL_INC)/dosish.h \
2761 $(PERL_INC)/embed.h \
2762 $(PERL_INC)/embedvar.h \
2763 $(PERL_INC)/fakethr.h \
2764 $(PERL_INC)/form.h \
2765 $(PERL_INC)/gv.h \
2766 $(PERL_INC)/handy.h \
2767 $(PERL_INC)/hv.h \
2768 $(PERL_INC)/intrpvar.h \
2769 $(PERL_INC)/iperlsys.h \
2770 $(PERL_INC)/keywords.h \
2771 $(PERL_INC)/mg.h \
2772 $(PERL_INC)/nostdio.h \
54fc9134
GS
2773 $(PERL_INC)/op.h \
2774 $(PERL_INC)/opcode.h \
54fc9134
GS
2775 $(PERL_INC)/patchlevel.h \
2776 $(PERL_INC)/perl.h \
54fc9134
GS
2777 $(PERL_INC)/perlio.h \
2778 $(PERL_INC)/perlsdio.h \
2779 $(PERL_INC)/perlsfio.h \
2780 $(PERL_INC)/perlvars.h \
2781 $(PERL_INC)/perly.h \
2782 $(PERL_INC)/pp.h \
2783 $(PERL_INC)/pp_proto.h \
2784 $(PERL_INC)/proto.h \
2785 $(PERL_INC)/regcomp.h \
2786 $(PERL_INC)/regexp.h \
2787 $(PERL_INC)/regnodes.h \
2788 $(PERL_INC)/scope.h \
2789 $(PERL_INC)/sv.h \
2790 $(PERL_INC)/thrdvar.h \
2791 $(PERL_INC)/thread.h \
2792 $(PERL_INC)/unixish.h \
2530b651 2793 $(PERL_INC)/util.h
f1387719
PP
2794
2795$(OBJECT) : $(PERL_HDRS)
9b3032b7 2796} if $self->{OBJECT};
f1387719
PP
2797
2798 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2799
2800 join "\n", @m;
1e44e2bf
PP
2801}
2802
8f993c78 2803
2366100d
A
2804=item perm_rw (o)
2805
2806Returns the attribute C<PERM_RW> or the string C<644>.
2807Used as the string that is passed
2808to the C<chmod> command to set the permissions for read/writeable files.
32504223 2809MakeMaker chooses C<644> because it has turned out in the past that
de592821 2810relying on the umask provokes hard-to-track bug reports.
2366100d
A
2811When the return value is used by the perl function C<chmod>, it is
2812interpreted as an octal value.
2813
2814=cut
2815
2816sub perm_rw {
479d2113 2817 return shift->{PERM_RW};
2366100d
A
2818}
2819
2820=item perm_rwx (o)
2821
32504223 2822Returns the attribute C<PERM_RWX> or the string C<755>,
2366100d
A
2823i.e. the string that is passed
2824to the C<chmod> command to set the permissions for executable files.
2825See also perl_rw.
2826
2827=cut
2828
2829sub perm_rwx {
479d2113 2830 return shift->{PERM_RWX};
2366100d
A
2831}
2832
f1387719 2833=item pm_to_blib
1e44e2bf 2834
f1387719 2835Defines target that copies all files in the hash PM to their
55497cff 2836destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
1e44e2bf
PP
2837
2838=cut
2839
f1387719
PP
2840sub pm_to_blib {
2841 my $self = shift;
479d2113 2842 my($autodir) = $self->catdir('$(INST_LIB)','auto');
d2fa5cc0 2843 my $r = q{
7292dc67 2844pm_to_blib : $(TO_INST_PM)
1e44e2bf 2845};
479d2113
MS
2846
2847 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
2848pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
2849CODE
2850
2851 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
2852
2853 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
7292dc67 2854 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
479d2113
MS
2855
2856 return $r;
1e44e2bf
PP
2857}
2858
f1387719 2859=item post_constants (o)
1e44e2bf 2860
f1387719
PP
2861Returns an empty string per default. Dedicated to overrides from
2862within Makefile.PL after all constants have been defined.
1e44e2bf
PP
2863
2864=cut
2865
f1387719 2866sub post_constants{
f1387719
PP
2867 "";
2868}
1e44e2bf 2869
f1387719 2870=item post_initialize (o)
1e44e2bf 2871
1fef88e7 2872Returns an empty string per default. Used in Makefile.PLs to add some
f1387719 2873chunk of text to the Makefile after the object is initialized.
1e44e2bf 2874
f1387719 2875=cut
1e44e2bf 2876
f1387719 2877sub post_initialize {
f1387719
PP
2878 "";
2879}
1e44e2bf 2880
f1387719 2881=item postamble (o)
1e44e2bf 2882
f1387719
PP
2883Returns an empty string. Can be used in Makefile.PLs to write some
2884text to the Makefile at the end.
1e44e2bf 2885
f1387719 2886=cut
1e44e2bf 2887
f1387719 2888sub postamble {
f1387719
PP
2889 "";
2890}
1e44e2bf 2891
e0678a30
MS
2892=item ppd
2893
2894Defines target that creates a PPD (Perl Package Description) file
2895for a binary distribution.
2896
2897=cut
2898
2899sub ppd {
2900 my($self) = @_;
2901
2902 if ($self->{ABSTRACT_FROM}){
2903 $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
45bc4d3a
JH
2904 carp "WARNING: Setting ABSTRACT via file ".
2905 "'$self->{ABSTRACT_FROM}' failed\n";
e0678a30
MS
2906 }
2907
2908 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
2909
2910 my $abstract = $self->{ABSTRACT} || '';
2911 $abstract =~ s/\n/\\n/sg;
2912 $abstract =~ s/</&lt;/g;
2913 $abstract =~ s/>/&gt;/g;
2914
2915 my $author = $self->{AUTHOR} || '';
2916 $author =~ s/</&lt;/g;
2917 $author =~ s/>/&gt;/g;
e0678a30 2918
479d2113
MS
2919 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
2920<SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
2921 <TITLE>$(DISTNAME)</TITLE>
2922 <ABSTRACT>%s</ABSTRACT>
2923 <AUTHOR>%s</AUTHOR>
2924PPD_HTML
e0678a30 2925
479d2113 2926 $ppd_xml .= " <IMPLEMENTATION>\n";
e0678a30
MS
2927 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
2928 my $pre_req = $prereq;
2929 $pre_req =~ s/::/-/g;
2930 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
2931 (0) x 4) [0 .. 3];
479d2113
MS
2932 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
2933 <DEPENDENCY NAME="%s" VERSION="%s" />
e0678a30
MS
2934PPD_OUT
2935
479d2113 2936 }
e0678a30 2937
479d2113
MS
2938 $ppd_xml .= sprintf <<'PPD_OUT', $Config{archname};
2939 <OS NAME="$(OSNAME)" />
2940 <ARCHITECTURE NAME="%s" />
2941PPD_OUT
e0678a30
MS
2942
2943 if ($self->{PPM_INSTALL_SCRIPT}) {
2944 if ($self->{PPM_INSTALL_EXEC}) {
479d2113 2945 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
e0678a30
MS
2946 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
2947 }
2948 else {
479d2113 2949 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
e0678a30
MS
2950 $self->{PPM_INSTALL_SCRIPT};
2951 }
2952 }
2953
2954 my ($bin_location) = $self->{BINARY_LOCATION} || '';
2955 $bin_location =~ s/\\/\\\\/g;
2956
479d2113
MS
2957 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
2958 <CODEBASE HREF="%s" />
2959 </IMPLEMENTATION>
2960</SOFTPKG>
2961PPD_XML
2962
2963 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
e0678a30 2964
479d2113
MS
2965 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
2966# Creates a PPD (Perl Package Description) for a binary distribution.
2967ppd:
2968 %s
2969PPD_OUT
e0678a30 2970
e0678a30
MS
2971}
2972
f1387719 2973=item prefixify
1e44e2bf 2974
e0678a30 2975 $MM->prefixify($var, $prefix, $new_prefix, $default);
f6d6199c 2976
e0678a30 2977Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
479d2113
MS
2978replace it's $prefix with a $new_prefix.
2979
2980Should the $prefix fail to match I<AND> a PREFIX was given as an
2981argument to WriteMakefile() it will set it to the $new_prefix +
2982$default. This is for systems whose file layouts don't neatly fit into
2983our ideas of prefixes.
1e44e2bf 2984
e0678a30
MS
2985This is for heuristics which attempt to create directory structures
2986that mirror those of the installed perl.
2987
2988For example:
2989
2990 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
2991
2992this will attempt to remove '/usr' from the front of the
2993$MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
2994if necessary) and replace it with '/home/foo'. If this fails it will
2995simply use '/home/foo/man/man1'.
1e44e2bf 2996
f1387719 2997=cut
1e44e2bf 2998
f1387719 2999sub prefixify {
e0678a30
MS
3000 my($self,$var,$sprefix,$rprefix,$default) = @_;
3001
5c161494 3002 my $path = $self->{uc $var} ||
45bc4d3a 3003 $Config_Override{lc $var} || $Config{lc $var} || '';
e0678a30 3004
1b0fc073
JH
3005 $rprefix .= '/' if $sprefix =~ m|/$|;
3006
45bc4d3a
JH
3007 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3008 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
e0678a30 3009
a7d1454b
RGS
3010 if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) &&
3011 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3012 {
e0678a30 3013
5c161494
MS
3014 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3015 print STDERR " no default!\n" if !$default && $Verbose >= 2;
e0678a30 3016
479d2113 3017 $path = $self->catdir($rprefix, $default) if $default;
e0678a30
MS
3018 }
3019
5c161494 3020 print " now $path\n" if $Verbose >= 2;
e0678a30 3021 return $self->{uc $var} = $path;
f1387719 3022}
1e44e2bf 3023
f6d6199c 3024
f1387719 3025=item processPL (o)
1e44e2bf 3026
f1387719 3027Defines targets to run *.PL files.
1e44e2bf 3028
f1387719 3029=cut
1e44e2bf 3030
f1387719 3031sub processPL {
7292dc67
RGS
3032 my $self = shift;
3033 my $pl_files = $self->{PL_FILES};
3034
3035 return "" unless $pl_files;
3036
3037 my $m = '';
3038 foreach my $plfile (sort keys %$pl_files) {
3039 my $list = ref($pl_files->{$plfile})
3040 ? $pl_files->{$plfile}
3041 : [$pl_files->{$plfile}];
3042
3043 foreach my $target (@$list) {
3044 if( $Is_VMS ) {
3045 $plfile = vmsify($plfile);
3046 $target = vmsify($target);
3047 }
3048
4325052d
RGS
3049 # Normally a .PL file runs AFTER pm_to_blib so it can have
3050 # blib in its @INC and load the just built modules. BUT if
3051 # the generated module is something in $(TO_INST_PM) which
3052 # pm_to_blib depends on then it can't depend on pm_to_blib
3053 # else we have a dependency loop.
3054 my $pm_dep;
3055 my $perlrun;
3056 if( defined $self->{PM}{$target} ) {
3057 $pm_dep = '';
3058 $perlrun = 'PERLRUN';
3059 }
3060 else {
3061 $pm_dep = 'pm_to_blib';
3062 $perlrun = 'PERLRUNINST';
3063 }
7292dc67 3064
4325052d
RGS
3065 $m .= <<MAKE_FRAG;
3066
3067all :: $target
3068 \$(NOECHO) \$(NOOP)
7292dc67 3069
4325052d
RGS
3070$target :: $plfile $pm_dep
3071 \$($perlrun) $plfile $target
7292dc67 3072MAKE_FRAG
1e44e2bf 3073
3aa35033 3074 }
f1387719 3075 }
7292dc67
RGS
3076
3077 return $m;
1e44e2bf
PP
3078}
3079
fa048ccd
JH
3080=item quote_paren
3081
3082Backslashes parentheses C<()> in command line arguments.
3083Doesn't handle recursive Makefile C<$(...)> constructs,
3084but handles simple ones.
3085
3086=cut
3087
3088sub quote_paren {
479d2113 3089 my $arg = shift;
7292dc67
RGS
3090 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3091 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3092 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
479d2113 3093 return $arg;
fa048ccd
JH
3094}
3095
f1387719 3096=item replace_manpage_separator
1e44e2bf 3097
f6d6199c
MS
3098 my $man_name = $MM->replace_manpage_separator($file_path);
3099
f1387719 3100Takes the name of a package, which may be a nested package, in the
f6d6199c
MS
3101form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3102safe for a man page file name. Returns the replacement.
1e44e2bf
PP
3103
3104=cut
3105
f1387719
PP
3106sub replace_manpage_separator {
3107 my($self,$man) = @_;
f6d6199c
MS
3108
3109 $man =~ s,/+,::,g;
3110 return $man;
f1387719 3111}
1e44e2bf 3112
479d2113 3113
7292dc67
RGS
3114=item cd
3115
3116=cut
3117
3118sub cd {
3119 my($self, $dir, @cmds) = @_;
3120
3121 # No leading tab and no trailing newline makes for easier embedding
3122 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3123
3124 return $make_frag;
3125}
3126
3127=item oneliner
479d2113
MS
3128
3129=cut
3130
3131sub oneliner {
3132 my($self, $cmd, $switches) = @_;
3133 $switches = [] unless defined $switches;
3134
3135 # Strip leading and trailing newlines
3136 $cmd =~ s{^\n+}{};
3137 $cmd =~ s{\n+$}{};
3138
ad2f23df 3139 my @cmds = split /\n/, $cmd;
7292dc67 3140 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
479d2113
MS
3141 $cmd = $self->escape_newlines($cmd);
3142
3143 $switches = join ' ', @$switches;
3144
5dca256e 3145 return qq{\$(ABSPERLRUN) $switches -e $cmd};
479d2113
MS
3146}
3147
3148
3149=item quote_literal
3150
3151=cut
3152
3153sub quote_literal {
3154 my($self, $text) = @_;
3155
3156 # I think all we have to quote is single quotes and I think
3157 # this is a safe way to do it.
3158 $text =~ s{'}{'\\''}g;
3159
3160 return "'$text'";
3161}
3162
3163
3164=item escape_newlines
3165
3166=cut
3167
3168sub escape_newlines {
3169 my($self, $text) = @_;
3170
3171 $text =~ s{\n}{\\\n}g;
3172
3173 return $text;
3174}
3175
3176
3177=item max_exec_len
3178
3179Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3180
3181=cut
3182
3183sub max_exec_len {
3184 my $self = shift;
3185
3186 if (!defined $self->{_MAX_EXEC_LEN}) {
3187 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3188 $self->{_MAX_EXEC_LEN} = $arg_max;
3189 }
3190 else { # POSIX minimum exec size
3191 $self->{_MAX_EXEC_LEN} = 4096;
3192 }
3193 }
3194
3195 return $self->{_MAX_EXEC_LEN};
3196}
3197
3198
f1387719 3199=item static (o)
1e44e2bf 3200
f1387719 3201Defines the static target.
1e44e2bf 3202
f1387719 3203=cut
1e44e2bf 3204
f1387719
PP
3205sub static {
3206# --- Static Loading Sections ---
1e44e2bf 3207
f1387719
PP
3208 my($self) = shift;
3209 '
3210## $(INST_PM) has been moved to the all: target.
3211## It remains here for awhile to allow for old usage: "make static"
479d2113
MS
3212static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3213 $(NOECHO) $(NOOP)
f1387719 3214';
1e44e2bf
PP
3215}
3216
f1387719 3217=item static_lib (o)
1e44e2bf 3218
f1387719 3219Defines how to produce the *.a (or equivalent) files.
1e44e2bf
PP
3220
3221=cut
3222
f1387719
PP
3223sub static_lib {
3224 my($self) = @_;
f1387719
PP
3225 return '' unless $self->has_link_code;
3226
3227 my(@m);
3228 push(@m, <<'END');
479d2113 3229
7292dc67 3230$(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
760ac839 3231 $(RM_RF) $@
f1387719 3232END
479d2113 3233
022735b4 3234 # If this extension has its own library (eg SDBM_File)
f1387719 3235 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
479d2113
MS
3236 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3237 $(CP) $(MYEXTLIB) $@
3238MAKE_FRAG
f4ae0f5e 3239
9f7ff21b
JH
3240 my $ar;
3241 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3242 # Prefer the absolute pathed ar if available so that PATH
3243 # doesn't confuse us. Perl itself is built with the full_ar.
3244 $ar = 'FULL_AR';
3245 } else {
3246 $ar = 'AR';
3247 }
479d2113
MS
3248 push @m, sprintf <<'MAKE_FRAG', $ar;
3249 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3250 $(CHMOD) $(PERM_RWX) $@
3251 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3252MAKE_FRAG
3253
0328fe61 3254 # Old mechanism - still available:
479d2113
MS
3255 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3256 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3257MAKE_FRAG
f1387719 3258
479d2113 3259 join('', @m);
1e44e2bf
PP
3260}
3261
f4ae0f5e 3262=item staticmake (o)
1e44e2bf 3263
f4ae0f5e 3264Calls makeaperl.
1e44e2bf
PP
3265
3266=cut
3267
3268sub staticmake {
3269 my($self, %attribs) = @_;
1e44e2bf
PP
3270 my(@static);
3271
3272 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3273
3274 # And as it's not yet built, we add the current extension
3275 # but only if it has some C code (or XS code, which implies C code)
3276 if (@{$self->{C}}) {
479d2113 3277 @static = $self->catfile($self->{INST_ARCHLIB},
f4ae0f5e
PP
3278 "auto",
3279 $self->{FULLEXT},
3280 "$self->{BASEEXT}$self->{LIB_EXT}"
3281 );
1e44e2bf
PP
3282 }
3283
3284 # Either we determine now, which libraries we will produce in the
3285 # subdirectories or we do it at runtime of the make.
3286
3287 # We could ask all subdir objects, but I cannot imagine, why it
3288 # would be necessary.
3289
3290 # Instead we determine all libraries for the new perl at
3291 # runtime.
3292 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3293
3294 $self->makeaperl(MAKE => $self->{MAKEFILE},
3295 DIRS => \@searchdirs,
3296 STAT => \@static,
3297 INCL => \@perlinc,
3298 TARGET => $self->{MAP_TARGET},
3299 TMP => "",
3300 LIBPERL => $self->{LIBPERL_A}
3301 );
3302}
3303
f1387719
PP
3304=item subdir_x (o)
3305
3306Helper subroutine for subdirs
3307
3308=cut
3309
3310sub subdir_x {
3311 my($self, $subdir) = @_;
7292dc67
RGS
3312
3313 my $subdir_cmd = $self->cd($subdir,
3314 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3315 );
3316 return sprintf <<'EOT', $subdir_cmd;
f1387719
PP
3317
3318subdirs ::
7292dc67 3319 $(NOECHO) %s
882a4479 3320EOT
7292dc67 3321
f1387719
PP
3322}
3323
3324=item subdirs (o)
3325
3326Defines targets to process subdirectories.
3327
3328=cut
3329
3330sub subdirs {
3331# --- Sub-directory Sections ---
3332 my($self) = shift;
3333 my(@m,$dir);
3334 # This method provides a mechanism to automatically deal with
3335 # subdirectories containing further Makefile.PL scripts.
3336 # It calls the subdir_x() method for each subdirectory.
3337 foreach $dir (@{$self->{DIR}}){
3338 push(@m, $self->subdir_x($dir));
3339#### print "Including $dir subdirectory\n";
3340 }
3341 if (@m){
3342 unshift(@m, "
3343# The default clean, realclean and test targets in this Makefile
3344# have automatically been given entries for each subdir.
3345
3346");
3347 } else {
3348 push(@m, "\n# none")
3349 }
3350 join('',@m);
3351}
3352
f4ae0f5e 3353=item test (o)
1e44e2bf 3354
f4ae0f5e 3355Defines the test targets.
1e44e2bf
PP
3356
3357=cut
3358
3359sub test {
3360# --- Test and Installation Sections ---
3361
3362 my($self, %attribs) = @_;
e0678a30 3363 my $tests = $attribs{TESTS} || '';
96e4d5b1 3364 if (!$tests && -d 't') {
45bc4d3a 3365 $tests = $self->find_tests;
96e4d5b1 3366 }