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