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