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