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