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