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