This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Undo Tim's tainting patch from beta1h.
[perl5.git] / lib / ExtUtils / MakeMaker.pm
CommitLineData
8e07c86e
AD
1package ExtUtils::MakeMaker::TieAtt;
2# this package will go away again, when we don't have modules around
3# anymore that import %att It ties an empty %att and records in which
4# object this %att was tied. FETCH and STORE return/store-to the
5# appropriate value from %$self
005c1a0e 6
8e07c86e
AD
7# the warndirectuse method warns if somebody calls MM->something. It
8# has nothing to do with the tie'd %att.
005c1a0e 9
8e07c86e 10$Enough_limit = 5;
a0d0e21e 11
8e07c86e
AD
12sub TIEHASH {
13 bless { SECRETHASH => $_[1]};
005c1a0e 14}
42793c05 15
8e07c86e 16sub FETCH {
4633a7c4 17 print "Warning (non-fatal): Importing of %att is deprecated [$_[1]]
8e07c86e
AD
18 use \$self instead\n" unless ++$Enough>$Enough_limit;
19 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
20 $_[0]->{SECRETHASH}->{$_[1]};
1aef975c 21}
42793c05 22
8e07c86e 23sub STORE {
4633a7c4 24 print "Warning (non-fatal): Importing of %att is deprecated [$_[1]][$_[2]]
8e07c86e
AD
25 use \$self instead\n" unless ++$Enough>$Enough_limit;
26 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
27 $_[0]->{SECRETHASH}->{$_[1]} = $_[2];
28}
42793c05 29
8e07c86e 30sub FIRSTKEY {
4633a7c4 31 print "Warning (non-fatal): Importing of %att is deprecated [FIRSTKEY]
8e07c86e
AD
32 use \$self instead\n" unless ++$Enough>$Enough_limit;
33 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit;
34 each %{$_[0]->{SECRETHASH}};
35}
42793c05 36
8e07c86e
AD
37sub NEXTKEY {
38 each %{$_[0]->{SECRETHASH}};
39}
005c1a0e 40
8e07c86e
AD
41sub DESTROY {
42}
005c1a0e 43
8e07c86e
AD
44sub warndirectuse {
45 my($caller) = @_;
46 return if $Enough>$Enough_limit;
4633a7c4 47 print STDOUT "Warning (non-fatal): Direct use of class methods deprecated; use\n";
8e07c86e 48 my($method) = $caller =~ /.*:(\w+)$/;
864a5fa8 49 print STDOUT
8e07c86e 50' my $self = shift;
8e07c86e
AD
51 $self->MM::', $method, "();
52 instead\n";
53 print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n"
54 if ++$Enough==$Enough_limit;
55}
005c1a0e 56
8e07c86e 57package ExtUtils::MakeMaker;
005c1a0e 58
cb1a09d0
AD
59# Last edited $Date: 1995/12/10 23:38:09 $ by Andreas Koenig
60# $Id: MakeMaker.pm,v 1.116 1995/12/10 23:38:09 k Exp $
42793c05 61
cb1a09d0 62$Version = $VERSION = "5.12";
005c1a0e 63
8e07c86e
AD
64$ExtUtils::MakeMaker::Version_OK = 4.13; # Makefiles older than $Version_OK will die
65 # (Will be checked from MakeMaker version 4.13 onwards)
005c1a0e 66
8e07c86e
AD
67use Config;
68use Carp;
69use Cwd;
70require Exporter;
71require ExtUtils::Manifest;
72require ExtUtils::Liblist;
73#use strict qw(refs);
005c1a0e 74
8e07c86e
AD
75eval {require DynaLoader;}; # Get mod2fname, if defined. Will fail
76 # with miniperl.
005c1a0e 77
8e07c86e
AD
78# print join "**\n**", "", %INC, "";
79%NORMAL_INC = %INC;
005c1a0e 80
42793c05 81
42793c05 82
8e07c86e
AD
83@ISA = qw(Exporter);
84@EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
85@EXPORT_OK = qw($Version $VERSION &Version_check
86 &help &neatvalue &mkbootstrap &mksymlists
4633a7c4 87 %att ## Import of %att is deprecated, please use OO features!
8e07c86e 88);
42793c05 89
8e07c86e
AD
90$Is_VMS = $Config::Config{osname} eq 'VMS';
91require ExtUtils::MM_VMS if $Is_VMS;
4633a7c4 92$Is_OS2 = $Config::Config{osname} =~ m|^os/?2$|i ;
8e07c86e 93$ENV{EMXSHELL} = 'sh' if $Is_OS2; # to run `commands`
42793c05 94
864a5fa8 95$ExtUtils::MakeMaker::Verbose = 0 unless defined $ExtUtils::MakeMaker::Verbose;
8e07c86e
AD
96$^W=1;
97#$SIG{__DIE__} = sub { print @_, Carp::longmess(); die; };
98####$SIG{__WARN__} = sub { print Carp::longmess(); warn @_; };
864a5fa8
AD
99$SIG{__WARN__} = sub {
100 $_[0] =~ /^Use of uninitialized value/ && return;
101 $_[0] =~ /used only once/ && return;
102 $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
103 warn @_;
104};
75f92628 105
8e07c86e
AD
106# Setup dummy package:
107# MY exists for overriding methods to be defined within
108unshift(@MY::ISA, qw(MM));
42793c05 109
8e07c86e
AD
110# Dummy package MM inherits actual methods from OS-specific
111# default packages. We use this intermediate package so
112# MY::XYZ->func() can call MM->func() and get the proper
113# default routine without having to know under what OS
114# it's running.
4633a7c4
LW
115
116@MM::ISA = qw[MM_Unix ExtUtils::MakeMaker];
8e07c86e
AD
117unshift @MM::ISA, 'ExtUtils::MM_VMS' if $Is_VMS;
118unshift @MM::ISA, 'ExtUtils::MM_OS2' if $Is_OS2;
8e07c86e
AD
119
120
121@ExtUtils::MakeMaker::MM_Sections_spec = (
122 post_initialize => {},
123 const_config => {},
124 constants => {},
125 const_loadlibs => {},
126 const_cccmd => {}, # the last but one addition here (CONST_CCCMD)
127 tool_autosplit => {},
128 tool_xsubpp => {},
129 tools_other => {},
130 dist => {},
131 macro => {},
132 post_constants => {},
133 pasthru => {},
134 c_o => {},
135 xs_c => {},
136 xs_o => {},
137 top_targets => {}, # currently the last section that adds a key to $self (DIR_TARGET)
138 linkext => {},
139 dlsyms => {},
140 dynamic => {},
141 dynamic_bs => {},
142 dynamic_lib => {},
143 static => {},
144 static_lib => {},
145 installpm => {},
146 manifypods => {},
147 processPL => {},
148 installbin => {},
149 subdirs => {},
150 clean => {},
151 realclean => {},
152 dist_basics => {},
153 dist_core => {},
154 dist_dir => {},
155 dist_test => {},
156 dist_ci => {},
157 install => {},
158 force => {},
159 perldepend => {},
160 makefile => {},
161 staticmake => {}, # Sadly this defines more macros
162 test => {},
163 postamble => {}, # should always be last the user has hands on
164 selfdocument => {}, # well, he may override it, but he won't do it
165);
166# looses section ordering
167%ExtUtils::MakeMaker::MM_Sections = @ExtUtils::MakeMaker::MM_Sections_spec;
168# keeps order
169@ExtUtils::MakeMaker::MM_Sections = grep(!ref, @ExtUtils::MakeMaker::MM_Sections_spec);
42793c05 170
8e07c86e 171%ExtUtils::MakeMaker::Recognized_Att_Keys = %ExtUtils::MakeMaker::MM_Sections; # All sections are valid keys.
864a5fa8
AD
172
173@ExtUtils::MakeMaker::Get_from_Config = qw(
174ar
175cc
176cccdlflags
177ccdlflags
178dlext
179dlsrc
180ld
181lddlflags
182ldflags
183libc
184lib_ext
185obj_ext
186ranlib
187so
188);
189
190my $item;
191foreach $item (split(/\n/,attrib_help())){
192 next unless $item =~ m/^=item\s+(\w+)\s*$/;
8e07c86e
AD
193 $ExtUtils::MakeMaker::Recognized_Att_Keys{$1} = $2;
194 print "Attribute '$1' => '$2'\n" if ($ExtUtils::MakeMaker::Verbose >= 2);
195}
864a5fa8
AD
196foreach $item (@ExtUtils::MakeMaker::Get_from_Config) {
197 next unless $Config::Config{$item};
198 $ExtUtils::MakeMaker::Recognized_Att_Keys{uc $item} = $Config::Config{$item};
199 print "Attribute '\U$item\E' => '$Config::Config{$item}'\n"
200 if ($ExtUtils::MakeMaker::Verbose >= 2);
201}
42793c05 202
8e07c86e
AD
203%ExtUtils::MakeMaker::Prepend_dot_dot = qw(
204INST_LIB 1 INST_ARCHLIB 1 INST_EXE 1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1
4633a7c4 205PERL_SRC 1 PERL 1 FULLPERL 1
8e07c86e
AD
206);
207$PACKNAME = "PACK000";
42793c05 208
8e07c86e
AD
209sub writeMakefile {
210 die <<END;
232e078e 211
8e07c86e
AD
212The extension you are trying to build apparently is rather old and
213most probably outdated. We detect that from the fact, that a
214subroutine "writeMakefile" is called, and this subroutine is not
215supported anymore since about October 1994.
40000a8c 216
4633a7c4
LW
217Please contact the author or look into CPAN (details about CPAN can be
218found in the FAQ and at http:/www.perl.com) for a more recent version
219of the extension. If you're really desperate, you can try to change
220the subroutine name from writeMakefile to WriteMakefile and rerun
221'perl Makefile.PL', but you're most probably left alone, when you do
222so.
42793c05 223
8e07c86e 224The MakeMaker team
1aef975c 225
42793c05 226END
8e07c86e 227}
42793c05 228
8e07c86e
AD
229sub WriteMakefile {
230 Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
231 my %att = @_;
232 MM->new(\%att)->flush;
42793c05
TB
233}
234
8e07c86e
AD
235sub new {
236 my($class,$self) = @_;
237 my($key);
42793c05 238
8e07c86e
AD
239 print STDOUT "MakeMaker (v$ExtUtils::MakeMaker::VERSION)\n" if $ExtUtils::MakeMaker::Verbose;
240 if (-f "MANIFEST" && ! -f "Makefile"){
241 check_manifest();
1aef975c 242 }
42793c05 243
8e07c86e 244 $self = {} unless (defined $self);
005c1a0e 245
864a5fa8 246 check_hints($self);
4633a7c4 247
8e07c86e 248 my(%initial_att) = %$self; # record initial attributes
005c1a0e 249
8e07c86e
AD
250 if (defined $self->{CONFIGURE}) {
251 if (ref $self->{CONFIGURE} eq 'CODE') {
252 $self = { %$self, %{&{$self->{CONFIGURE}}}};
005c1a0e 253 } else {
8e07c86e 254 croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
005c1a0e
AD
255 }
256 }
a0d0e21e 257
8e07c86e
AD
258 # This is for old Makefiles written pre 5.00, will go away
259 if ( Carp::longmess("") =~ /runsubdirpl/s ){
260 $self->{Correct_relativ_directories}++;
261 } else {
262 $self->{Correct_relativ_directories}=0;
263 }
5d94fbed 264
8e07c86e
AD
265 my $class = ++$PACKNAME;
266 {
267# no strict;
268 print "Blessing Object into class [$class]\n" if $ExtUtils::MakeMaker::Verbose;
269 mv_all_methods("MY",$class);
270 bless $self, $class;
271######## tie %::att, ExtUtils::MakeMaker::TieAtt, $self;
272 push @ExtUtils::MakeMaker::Parent, $self;
273 @{"$class\:\:ISA"} = 'MM';
274 }
5d94fbed 275
8e07c86e
AD
276 if (defined $ExtUtils::MakeMaker::Parent[-2]){
277 $self->{PARENT} = $ExtUtils::MakeMaker::Parent[-2];
278 my $key;
279 for $key (keys %ExtUtils::MakeMaker::Prepend_dot_dot) {
4633a7c4 280 next unless defined $self->{PARENT}{$key};
8e07c86e
AD
281 $self->{$key} = $self->{PARENT}{$key};
282 $self->{$key} = $self->catdir("..",$self->{$key})
283 unless $self->{$key} =~ m!^/!;
284 }
285 $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT};
286 } else {
287 parse_args($self,@ARGV);
288 }
a0d0e21e 289
8e07c86e 290 $self->{NAME} ||= $self->guess_name;
a0d0e21e 291
8e07c86e 292 ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;
a0d0e21e 293
8e07c86e
AD
294 $self->init_main();
295
864a5fa8 296 if (! $self->{PERL_SRC} &&
8e07c86e 297 $INC{'Config.pm'} ne $self->catdir($Config::Config{archlibexp},'Config.pm')){
005c1a0e
AD
298 (my $pthinks = $INC{'Config.pm'}) =~ s!/Config\.pm$!!;
299 $pthinks =~ s!.*/!!;
300 print STDOUT <<END;
301Your perl and your Config.pm seem to have different ideas about the architecture
302they are running on.
8e07c86e
AD
303Perl thinks: [$pthinks]
304Config says: [$Config::Config{archname}]
005c1a0e
AD
305This may or may not cause problems. Please check your installation of perl if you
306have problems building this extension.
307END
308 }
309
8e07c86e
AD
310 $self->init_dirscan();
311 $self->init_others();
75f92628 312
8e07c86e
AD
313 push @{$self->{RESULT}}, <<END;
314# This Makefile is for the $self->{NAME} extension to perl.
315#
316# It was generated automatically by MakeMaker version $ExtUtils::MakeMaker::VERSION from the contents
317# of Makefile.PL. Don't edit this file, edit Makefile.PL instead.
318#
319# ANY CHANGES MADE HERE WILL BE LOST!
320#
321# MakeMaker Parameters:
322END
a0d0e21e 323
42793c05
TB
324 foreach $key (sort keys %initial_att){
325 my($v) = neatvalue($initial_att{$key});
8e07c86e 326 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
42793c05 327 $v =~ tr/\n/ /s;
8e07c86e 328 push @{$self->{RESULT}}, "# $key => $v";
42793c05 329 }
a0d0e21e 330
8e07c86e
AD
331 # turn the SKIP array into a SKIPHASH hash
332 my (%skip,$skip);
333 for $skip (@{$self->{SKIP} || []}) {
334 $self->{SKIPHASH}{$skip} = 1;
335 }
42793c05 336
8e07c86e
AD
337 # We run all the subdirectories now. They don't have much to query
338 # from the parent, but the parent has to query them: if they need linking!
339 my($dir);
340 unless ($self->{NORECURS}) {
341 foreach $dir (@{$self->{DIR}}){
342 chdir $dir;
4633a7c4 343 package main;
8e07c86e
AD
344 local *FH;
345 open FH, "Makefile.PL";
346 eval join "", <FH>;
347 close FH;
348 chdir "..";
42793c05
TB
349 }
350 }
a0d0e21e 351
8e07c86e
AD
352 tie %::att, ExtUtils::MakeMaker::TieAtt, $self;
353 my $section;
354 foreach $section ( @ExtUtils::MakeMaker::MM_Sections ){
355 print "Processing Makefile '$section' section\n" if ($ExtUtils::MakeMaker::Verbose >= 2);
356 my($skipit) = $self->skipcheck($section);
357 if ($skipit){
358 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit.";
4e68a208 359 } else {
8e07c86e
AD
360 my(%a) = %{$self->{$section} || {}};
361 push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
362 push @{$self->{RESULT}}, "# " . join ", ", %a if $ExtUtils::MakeMaker::Verbose && %a;
363 push @{$self->{RESULT}}, $self->nicetext($self->$section( %a ));
42793c05
TB
364 }
365 }
a0d0e21e 366
8e07c86e
AD
367 push @{$self->{RESULT}}, "\n# End.";
368######## untie %::att;
369 pop @ExtUtils::MakeMaker::Parent;
a0d0e21e 370
8e07c86e 371 $self;
a0d0e21e
LW
372}
373
8e07c86e
AD
374sub check_manifest {
375 eval {require ExtUtils::Manifest};
005c1a0e 376 if ($@){
8e07c86e
AD
377 print STDOUT "Warning: you have not installed the ExtUtils::Manifest
378 module -- skipping check of the MANIFEST file\n";
379 } else {
380 print STDOUT "Checking if your kit is complete...\n";
381 $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
382 my(@missed)=ExtUtils::Manifest::manicheck();
383 if (@missed){
384 print STDOUT "Warning: the following files are missing in your kit:\n";
385 print "\t", join "\n\t", @missed;
386 print STDOUT "\n";
387 print STDOUT "Please inform the author.\n";
388 } else {
389 print STDOUT "Looks good\n";
390 }
005c1a0e 391 }
005c1a0e
AD
392}
393
42793c05 394sub parse_args{
8e07c86e 395 my($self, @args) = @_;
42793c05 396 foreach (@args){
75f92628
AD
397 unless (m/(.*?)=(.*)/){
398 help(),exit 1 if m/^help$/;
8e07c86e 399 ++$ExtUtils::MakeMaker::Verbose if m/^verb/;
75f92628
AD
400 next;
401 }
402 my($name, $value) = ($1, $2);
403 if ($value =~ m/^~(\w+)?/){ # tilde with optional username
005c1a0e 404 $value =~ s [^~(\w*)]
864a5fa8
AD
405 [$1 ?
406 ((getpwnam($1))[7] || "~$1") :
005c1a0e
AD
407 (getpwuid($>))[7]
408 ]ex;
409 }
4633a7c4 410 # This may go away, in mid 1996
8e07c86e
AD
411 if ($self->{Correct_relativ_directories}){
412 $value = $self->catdir("..",$value)
4633a7c4 413 if $ExtUtils::MakeMaker::Prepend_dot_dot{$name} && ! $value =~ m!^/!;
75f92628 414 }
8e07c86e 415 $self->{$name} = $value;
42793c05 416 }
4633a7c4 417 # This may go away, in mid 1996
8e07c86e
AD
418 delete $self->{Correct_relativ_directories};
419
42793c05 420 # catch old-style 'potential_libs' and inform user how to 'upgrade'
8e07c86e
AD
421 if (defined $self->{potential_libs}){
422 my($msg)="'potential_libs' => '$self->{potential_libs}' should be";
423 if ($self->{potential_libs}){
424 print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n";
42793c05 425 } else {
fed7345c 426 print STDOUT "$msg deleted.\n";
42793c05 427 }
8e07c86e
AD
428 $self->{LIBS} = [$self->{potential_libs}];
429 delete $self->{potential_libs};
42793c05
TB
430 }
431 # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
8e07c86e
AD
432 if (defined $self->{ARMAYBE}){
433 my($armaybe) = $self->{ARMAYBE};
fed7345c 434 print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
42793c05 435 "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
8e07c86e
AD
436 my(%dl) = %{$self->{dynamic_lib} || {}};
437 $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe};
438 delete $self->{ARMAYBE};
42793c05 439 }
8e07c86e 440 if (defined $self->{LDTARGET}){
fed7345c 441 print STDOUT "LDTARGET should be changed to LDFROM\n";
8e07c86e
AD
442 $self->{LDFROM} = $self->{LDTARGET};
443 delete $self->{LDTARGET};
75f92628 444 }
4633a7c4
LW
445 # Turn a DIR argument on the command line into an array
446 if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') {
447 # So they can choose from the command line, which extensions they want
448 # the grep enables them to have some colons too much in case they
449 # have to build a list with the shell
450 $self->{DIR} = [grep $_, split ":", $self->{DIR}];
451 }
8e07c86e
AD
452 my $mmkey;
453 foreach $mmkey (sort keys %$self){
454 print STDOUT " $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $ExtUtils::MakeMaker::Verbose;
455 print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n"
456 unless exists $ExtUtils::MakeMaker::Recognized_Att_Keys{$mmkey};
457 }
458}
459
460sub check_hints {
461 my($self) = @_;
462 # We allow extension-specific hints files.
463
464 return unless -d "hints";
465
466 # First we look for the best hintsfile we have
467 my(@goodhints);
468 my($hint)="$Config::Config{osname}_$Config::Config{osvers}";
469 $hint =~ s/\./_/g;
470 $hint =~ s/_$//;
471 return unless $hint;
472
473 # Also try without trailing minor version numbers.
474 while (1) {
475 last if -f "hints/$hint.pl"; # found
476 } continue {
477 last unless $hint =~ s/_[^_]*$//; # nothing to cut off
42793c05 478 }
8e07c86e
AD
479 return unless -f "hints/$hint.pl"; # really there
480
481 # execute the hintsfile:
4633a7c4 482 local *HINTS;
8e07c86e
AD
483 open HINTS, "hints/$hint.pl";
484 @goodhints = <HINTS>;
485 close HINTS;
486 print STDOUT "Processing hints file hints/$hint.pl\n";
487 eval join('',@goodhints);
488 print STDOUT $@ if $@;
a0d0e21e
LW
489}
490
8e07c86e
AD
491sub mv_all_methods {
492 my($from,$to) = @_;
493 my($method);
494# no strict;
495
864a5fa8
AD
496 # Here you see the *current* list of methods that are overridable
497 # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm
498 # still trying to reduce the list to some reasonable minimum --
499 # because I want to make it easier for the user. A.K.
500
501 foreach $method (@ExtUtils::MakeMaker::MM_Sections, qw[ dir_target
502exescan fileparse fileparse_set_fstype installpm_x libscan makeaperl
503mksymlists needs_linking runsubdirpl subdir_x test_via_harness
504test_via_script writedoc ]) {
8e07c86e
AD
505
506 # We cannot say "next" here. Nick might call MY->makeaperl
507 # which isn't defined right now
508
509 # next unless defined &{"${from}::$method"};
510
511 *{"${to}::$method"} = \&{"${from}::$method"};
512 my $symtab = \%{"${from}::"};
513
514 # delete would do, if we were sure, nobody ever called
515 # MY->makeaperl directly
a0d0e21e 516
8e07c86e
AD
517 # delete $symtab->{$method};
518
519 # If we delete a method, then it will be undefined and cannot
520 # be called. But as long as we have Makefile.PLs that rely on
521 # %MY:: being intact, we have to fill the hole with an
522 # inheriting method:
523
524 eval "package MY; sub $method {local *$method; shift->MY::$method(\@_); }";
525
864a5fa8 526 }
8e07c86e
AD
527
528 # We have to clean out %INC also, because the current directory is
529 # changed frequently and Graham Barr prefers to get his version
530 # out of a History.pl file which is "required" so woudn't get
531 # loaded again in another extension requiring a History.pl
532
533 my $inc;
534 foreach $inc (keys %INC) {
535 next if $ExtUtils::MakeMaker::NORMAL_INC{$inc};
536 #warn "***$inc*** deleted";
537 delete $INC{$inc};
538 }
539
540}
541
542sub prompt {
543 my($mess,$def)=@_;
4633a7c4
LW
544 BEGIN { my $ISA_TTY = -t STDIN && -t STDOUT }
545 Carp::confess("prompt function called without an argument") unless defined $mess;
8e07c86e
AD
546 $def = "" unless defined $def;
547 my $dispdef = "[$def] ";
4633a7c4
LW
548 my $ans;
549 if ($ISA_TTY) {
550 local $|=1;
551 print "$mess $dispdef";
552 chop($ans = <STDIN>);
553 }
554 return $ans if defined $ans;
555 return $def;
8e07c86e
AD
556}
557
558sub attrib_help {
559 return $Attrib_Help if $Attrib_Help;
560 my $switch = 0;
561 my $help;
562 my $line;
563 local *POD;
564#### local $/ = ""; # bug in 5.001m
565 open POD, $INC{"ExtUtils/MakeMaker.pm"}
566 or die "Open $INC{'ExtUtils/MakeMaker.pm'}: $!";
567 while ($line = <POD>) {
864a5fa8 568 $switch ||= $line =~ /^=item C\s*$/;
8e07c86e
AD
569 next unless $switch;
570 last if $line =~ /^=cut/;
571 $help .= $line;
572 }
573 close POD;
574 $Attrib_Help = $help;
575}
576
577sub help {print &attrib_help, "\n";}
578
579sub skipcheck{
580 my($self) = shift;
581 my($section) = @_;
582 if ($section eq 'dynamic') {
583 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
584 "in skipped section 'dynamic_bs'\n"
585 if $self->{SKIPHASH}{dynamic_bs} && $ExtUtils::MakeMaker::Verbose;
586 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ",
587 "in skipped section 'dynamic_lib'\n"
588 if $self->{SKIPHASH}{dynamic_lib} && $ExtUtils::MakeMaker::Verbose;
589 }
590 if ($section eq 'dynamic_lib') {
591 print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ",
592 "targets in skipped section 'dynamic_bs'\n"
593 if $self->{SKIPHASH}{dynamic_bs} && $ExtUtils::MakeMaker::Verbose;
594 }
595 if ($section eq 'static') {
596 print STDOUT "Warning (non-fatal): Target 'static' depends on targets ",
597 "in skipped section 'static_lib'\n"
598 if $self->{SKIPHASH}{static_lib} && $ExtUtils::MakeMaker::Verbose;
599 }
600 return 'skipped' if $self->{SKIPHASH}{$section};
601 return '';
602}
603
604sub flush {
605 my $self = shift;
606 my($chunk);
607 local *MAKE;
608 print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n";
609
610 unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
611 open MAKE, ">MakeMaker.tmp" or die "Unable to open MakeMaker.tmp: $!";
612
613 for $chunk (@{$self->{RESULT}}) {
614 print MAKE "$chunk\n";
615 }
616
617 close MAKE;
618 my($finalname) = $Is_VMS ? "Descrip.MMS" : $self->{MAKEFILE};
619 rename("MakeMaker.tmp", $finalname);
620 chmod 0644, $finalname;
621 system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":";
622}
623
624sub Version_check {
625 my($checkversion) = @_;
626 die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
627Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
628changes in the meantime.
629Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
630 if $checkversion < $ExtUtils::MakeMaker::Version_OK;
4633a7c4 631 printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
8e07c86e
AD
632 $checkversion, "Current Version is", $ExtUtils::MakeMaker::VERSION
633 unless $checkversion == $ExtUtils::MakeMaker::VERSION;
634}
635
636sub mksymlists {
637 my $class = shift;
638 my $self = shift;
639 bless $self, $class;
640 tie %att, ExtUtils::MakeMaker::TieAtt, $self;
641 $self->parse_args(@ARGV);
642 $self->mksymlists(@_);
643}
644
645# The following mkbootstrap() is only for installations that are calling
646# the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
647# writes Makefiles, that use ExtUtils::Mkbootstrap directly.
648sub mkbootstrap {
649 die <<END;
650!!! Your Makefile has been built such a long time ago, !!!
651!!! that is unlikely to work with current MakeMaker. !!!
652!!! Please rebuild your Makefile !!!
653END
654}
655
656sub neatvalue {
42793c05 657 my($v) = @_;
fed7345c 658 return "undef" unless defined $v;
42793c05
TB
659 my($t) = ref $v;
660 return "'$v'" unless $t;
8e07c86e
AD
661 if ($t eq 'ARRAY') {
662 my(@m, $elem, @neat);
663 push @m, "[";
664 foreach $elem (@$v) {
665 push @neat, "'$elem'";
666 }
667 push @m, join ", ", @neat;
668 push @m, "]";
669 return join "", @m;
670 }
42793c05
TB
671 return "$v" unless $t eq 'HASH';
672 my(@m, $key, $val);
673 push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
674 return "{ ".join(', ',@m)." }";
675}
676
8e07c86e
AD
677sub selfdocument {
678 my($self) = @_;
679 my(@m);
680 if ($ExtUtils::MakeMaker::Verbose){
681 push @m, "\n# Full list of MakeMaker attribute values:";
682 foreach $key (sort keys %$self){
683 next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/;
684 my($v) = neatvalue($self->{$key});
685 $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
686 $v =~ tr/\n/ /s;
687 push @m, "# $key => $v";
688 }
689 }
690 join "\n", @m;
691}
692
693
694 # # # # # #
695 ## ## ## ## # # # # # # #
696 # # # # # # # # # # ## # # # #
697 # # # # # # # # # # # # ##
698 # # # # # # # # # # ##
699 # # # # # # # ## # # #
700 # # # # ####### ##### # # # # #
a0d0e21e 701
42793c05 702package MM_Unix;
a0d0e21e
LW
703
704use Config;
42793c05
TB
705use Cwd;
706use File::Basename;
a0d0e21e
LW
707require Exporter;
708
42793c05 709Exporter::import('ExtUtils::MakeMaker',
8e07c86e 710 qw( $Verbose));
a0d0e21e 711
42793c05
TB
712# These attributes cannot be overridden externally
713@Other_Att_Keys{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)} = (1) x 3;
a0d0e21e 714
8e07c86e 715if ($Is_VMS = $Config::Config{osname} eq 'VMS') {
748a9306
LW
716 require VMS::Filespec;
717 import VMS::Filespec 'vmsify';
a0d0e21e
LW
718}
719
8e07c86e
AD
720$Is_OS2 = $ExtUtils::MakeMaker::Is_OS2;
721
722sub guess_name { # Charles! That's something for MM_VMS
723 my($self) = @_;
724 my $name = fastcwd();
725 if ($Is_VMS) {
726 $name =~ s:.*?([^.\]]+)\]:$1: unless ($name =~ s:.*[.\[]ext\.(.*)\]:$1:i);
727 $name =~ s#[.\]]#::#g;
728 } else {
729 $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
730 $name =~ s#/#::#g;
731 $name =~ s#\-\d+\.\d+$##; # this is new with MM 5.00
732 }
733 $name;
734}
a0d0e21e 735
75f92628 736sub init_main {
005c1a0e 737 my($self) = @_;
8e07c86e
AD
738 unless (ref $self){
739 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
740 $self = $ExtUtils::MakeMaker::Parent[-1];
741 }
005c1a0e 742
005c1a0e
AD
743 # --- Initialize Module Name and Paths
744
745 # NAME = The perl module name for this extension (eg DBD::Oracle).
746 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
747 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
748 # ROOTEXT = Directory part of FULLEXT with leading /.
8e07c86e
AD
749 ($self->{FULLEXT} =
750 $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
751
752 # Copied from DynaLoader:
753
754 my(@modparts) = split(/::/,$self->{NAME});
755 my($modfname) = $modparts[-1];
756
757 # Some systems have restrictions on files names for DLL's etc.
758 # mod2fname returns appropriate file base name (typically truncated)
759 # It may also edit @modparts if required.
760 if (defined &DynaLoader::mod2fname) {
761 $modfname = &DynaLoader::mod2fname(\@modparts);
762 } elsif ($Is_OS2) { # Need manual correction if run with miniperl:-(
763 $modfname = substr($modfname, 0, 7) . '_';
764 }
765
766
767 ($self->{BASEEXT} =
768 $self->{NAME}) =~ s!.*::!! ; #eg. Socket
769
770 if (defined &DynaLoader::mod2fname or $Is_OS2) {
771 # As of 5.001m, dl_os2 appends '_'
772 $self->{DLBASE} = $modfname; #eg. Socket_
773 } else {
774 $self->{DLBASE} = '$(BASEEXT)';
005c1a0e 775 }
8e07c86e
AD
776
777 ($self->{ROOTEXT} =
778 $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ; #eg. /BSD/Foo
779
4633a7c4 780 $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};
42793c05 781
005c1a0e
AD
782
783 # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
784
785 # *Real* information: where did we get these two from? ...
786 my $inc_config_dir = dirname($INC{'Config.pm'});
787 my $inc_carp_dir = dirname($INC{'Carp.pm'});
788
789 # Typically PERL_* and INST_* will be identical but that need
790 # not be the case (e.g., installing into project libraries etc).
42793c05
TB
791
792 # Perl Macro: With source No source
e1666bf5 793 # PERL_SRC ../.. (undefined)
4e68a208
AD
794 # PERL_LIB PERL_SRC/lib $Config{privlibexp}
795 # PERL_ARCHLIB PERL_SRC/lib $Config{archlibexp}
42793c05 796
005c1a0e
AD
797 # INST Macro: For standard for any other
798 # modules module
4633a7c4
LW
799 # INST_LIB PERL_SRC/lib ./blib
800 # INST_ARCHLIB PERL_SRC/lib ./blib/<archname>
8e07c86e
AD
801
802 unless ($self->{PERL_SRC}){
803 my($dir);
4633a7c4 804 foreach $dir (qw(.. ../.. ../../..)){
864a5fa8
AD
805 if ( -f "$dir/config.sh"
806 && -f "$dir/perl.h"
8e07c86e
AD
807 && -f "$dir/lib/Exporter.pm") {
808 $self->{PERL_SRC}=$dir ;
232e078e
AD
809 last;
810 }
a0d0e21e 811 }
a0d0e21e 812 }
8e07c86e
AD
813 if ($self->{PERL_SRC}){
814 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
815 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
816 $self->{PERL_INC} = $self->{PERL_SRC};
817 # catch an situation that has occurred a few times in the past:
818 warn <<EOM unless -s "$self->{PERL_SRC}/cflags";
819You cannot build extensions below the perl source tree after executing
820a 'make clean' in the perl source tree.
821
822To rebuild extensions distributed with the perl source you should
823simply Configure (to include those extensions) and then build perl as
824normal. After installing perl the source tree can be deleted. It is not
825needed for building extensions.
826
827It is recommended that you unpack and build additional extensions away
828from the perl source tree.
829EOM
830 } else {
42793c05 831 # we should also consider $ENV{PERL5LIB} here
8e07c86e
AD
832 $self->{PERL_LIB} = $Config::Config{privlibexp} unless $self->{PERL_LIB};
833 $self->{PERL_ARCHLIB} = $Config::Config{archlibexp} unless $self->{PERL_ARCHLIB};
834 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
835 my $perl_h;
836 die <<EOM unless (-f ($perl_h = $self->catfile("$self->{PERL_INC}","perl.h")));
005c1a0e
AD
837Error: Unable to locate installed Perl libraries or Perl source code.
838
839It is recommended that you install perl in a standard location before
840building extensions. You can say:
841
842 $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory
843
844if you have not yet installed perl but still want to build this
845extension now.
8e07c86e 846(You get this message, because MakeMaker could not find "$perl_h")
005c1a0e
AD
847EOM
848
8e07c86e
AD
849# print STDOUT "Using header files found in $self->{PERL_INC}\n"
850# if $Verbose && $self->needs_linking();
232e078e 851
42793c05
TB
852 }
853
854 # INST_LIB typically pre-set if building an extension after
855 # perl has been built and installed. Setting INST_LIB allows
8e07c86e
AD
856 # you to build directly into, say $Config::Config{privlibexp}.
857 unless ($self->{INST_LIB}){
4633a7c4
LW
858
859
860 ##### XXXXX We have to change this nonsense
861
8e07c86e
AD
862 if (defined $self->{PERL_SRC}) {
863 $self->{INST_LIB} = $self->{PERL_LIB};
3edbfbe5 864 } else {
8e07c86e 865 $self->{INST_LIB} = $self->catdir(".","blib");
3edbfbe5
TB
866 }
867 }
42793c05 868 # Try to work out what INST_ARCHLIB should be if not set:
8e07c86e 869 unless ($self->{INST_ARCHLIB}){
42793c05 870 my(%archmap) = (
864a5fa8
AD
871 # our private build lib
872 $self->catdir(".","blib") =>
873 $self->catdir(".","blib",$Config::Config{archname}),
8e07c86e
AD
874 $self->{PERL_LIB} => $self->{PERL_ARCHLIB},
875 $Config::Config{privlibexp} => $Config::Config{archlibexp},
42793c05
TB
876 $inc_carp_dir => $inc_config_dir,
877 );
8e07c86e
AD
878 $self->{INST_ARCHLIB} = $archmap{$self->{INST_LIB}};
879 unless($self->{INST_ARCHLIB}){
75f92628 880 # Oh dear, we'll have to default it and warn the user
8e07c86e
AD
881 my($archname) = $Config::Config{archname};
882 if (-d "$self->{INST_LIB}/$archname"){
883 $self->{INST_ARCHLIB} = $self->catdir("$self->{INST_LIB}","$archname");
884 print STDOUT "Defaulting INST_ARCHLIB to $self->{INST_ARCHLIB}\n";
75f92628 885 } else {
8e07c86e 886 $self->{INST_ARCHLIB} = $self->{INST_LIB};
75f92628
AD
887 }
888 }
42793c05 889 }
8e07c86e 890 $self->{INST_EXE} ||= $self->catdir('.','blib',$Config::Config{archname});
42793c05 891
8e07c86e 892 if ($self->{PREFIX}){
4e68a208
AD
893# With perl5.002 it turns out, that we hardcoded some assumptions in here:
894# $self->{INSTALLPRIVLIB} = $self->catdir($self->{PREFIX},"lib","perl5");
895# $self->{INSTALLBIN} = $self->catdir($self->{PREFIX},"bin");
896# $self->{INSTALLMAN3DIR} = $self->catdir($self->{PREFIX},"perl5","man","man3")
897# unless defined $self->{INSTALLMAN3DIR};
898
899 # we have to look at the relation between $Config{prefix} and
900 # the requested values
901 ($self->{INSTALLPRIVLIB} = $Config{installprivlib})
902 =~ s/\Q$Config{prefix}\E/$self->{PREFIX}/;
903 ($self->{INSTALLBIN} = $Config{installbin})
904 =~ s/\Q$Config{prefix}\E/$self->{PREFIX}/;
905 ($self->{INSTALLMAN3DIR} = $Config{installman3dir})
906 =~ s/\Q$Config{prefix}\E/$self->{PREFIX}/;
8e07c86e
AD
907 }
908
909 if( $self->{INSTALLPRIVLIB} && ! $self->{INSTALLARCHLIB} ){
4e68a208
AD
910# Same as above here. With the unresolved versioned directory issue, we have to
911# be more careful to follow Configure
912# my($archname) = $Config::Config{archname};
913# if (-d $self->catdir($self->{INSTALLPRIVLIB},$archname)){
914# $self->{INSTALLARCHLIB} = $self->catdir($self->{INSTALLPRIVLIB},$archname);
915# print STDOUT "Defaulting INSTALLARCHLIB to $self->{INSTALLARCHLIB}\n";
916# } else {
917# $self->{INSTALLARCHLIB} = $self->{INSTALLPRIVLIB};
918# }
919 ($self->{INSTALLARCHLIB} = $Config{installarchlib})
920 =~ s/\Q$Config{installprivlib}\E/$self->{INSTALLPRIVLIB}/;
921 if (-d $self->{INSTALLARCHLIB}) {
8e07c86e 922 print STDOUT "Defaulting INSTALLARCHLIB to $self->{INSTALLARCHLIB}\n";
42793c05 923 } else {
8e07c86e 924 $self->{INSTALLARCHLIB} = $self->{INSTALLPRIVLIB};
42793c05
TB
925 }
926 }
4e68a208 927
8e07c86e
AD
928 $self->{INSTALLPRIVLIB} ||= $Config::Config{installprivlib};
929 $self->{INSTALLARCHLIB} ||= $Config::Config{installarchlib};
930 $self->{INSTALLBIN} ||= $Config::Config{installbin};
931
4633a7c4
LW
932 $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir}
933 unless defined $self->{INSTALLMAN1DIR};
934 unless (defined $self->{INST_MAN1DIR}){
935 if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){
936 $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR};
937 } else {
938 $self->{INST_MAN1DIR} = $self->catdir('.','blib','man','man1');
939 }
940 }
941 $self->{MAN1EXT} ||= $Config::Config{man1ext};
005c1a0e 942
4633a7c4
LW
943 $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir}
944 unless defined $self->{INSTALLMAN3DIR};
945 unless (defined $self->{INST_MAN3DIR}){
946 if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){
947 $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR};
948 } else {
949 $self->{INST_MAN3DIR} = $self->catdir('.','blib','man','man3');
950 }
951 }
952 $self->{MAN3EXT} ||= $Config::Config{man3ext};
8e07c86e 953
864a5fa8
AD
954 print STDOUT "CONFIG must be an array ref\n"
955 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
956 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
957 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
958 push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags};
959 my(%once_only,$m);
960 foreach $m (@{$self->{CONFIG}}){
961 next if $once_only{$m};
962 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
963 unless exists $Config::Config{$m};
964 $self->{uc $m} ||= $Config::Config{$m};
965 $once_only{$m} = 1;
966 }
967
968 # These should never be needed
969 $self->{LD} ||= 'ld';
970 $self->{OBJ_EXT} ||= '.o';
971 $self->{LIB_EXT} ||= '.a';
8e07c86e 972
864a5fa8 973 $self->{MAP_TARGET} ||= "perl";
8e07c86e
AD
974
975 unless ($self->{LIBPERL_A}){
976 if ($Is_VMS) {
977 $self->{LIBPERL_A} = 'libperl.olb';
978 } else {
4633a7c4 979 $self->{LIBPERL_A} = "libperl$self->{LIB_EXT}";
8e07c86e
AD
980 }
981 }
005c1a0e
AD
982
983 # make a few simple checks
8e07c86e 984 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
005c1a0e 985 (Exporter.pm not found)"
8e07c86e 986 unless (-f $self->catfile("$self->{PERL_LIB}","Exporter.pm"));
42793c05 987
8e07c86e
AD
988 ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME};
989 $self->{VERSION} = "0.10" unless $self->{VERSION};
990 ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
42793c05 991
4e68a208
AD
992 # Graham Barr and Paul Marquess had some ideas how to ensure
993 # version compatibility between the *.pm file and the
994 # corresponding *.xs file. The bottomline was, that we need an
995 # XS_VERSION macro that defaults to VERSION:
cb1a09d0 996 # $self->{XS_VERSION} ||= $self->{VERSION};
42793c05
TB
997
998 # --- Initialize Perl Binary Locations
999
1000 # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
75f92628
AD
1001 # will be working versions of perl 5. miniperl has priority over perl
1002 # for PERL to ensure that $(PERL) is usable while building ./ext/*
8e07c86e 1003 my ($component,@defpath);
4e68a208 1004 foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
8e07c86e
AD
1005 push @defpath, $component if defined $component;
1006 }
864a5fa8 1007 $self->{PERL} =
8e07c86e
AD
1008 $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ],
1009 \@defpath, $ExtUtils::MakeMaker::Verbose ) unless ($self->{PERL});
1010# don't check, if perl is executable, maybe they
1011# have decided to supply switches with perl
a0d0e21e 1012
42793c05 1013 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
8e07c86e
AD
1014 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
1015 unless ($self->{FULLPERL});
75f92628 1016}
42793c05 1017
4e68a208
AD
1018# Ilya's suggestion, will have to go into ExtUtils::MM_OS2 and MM_VMS
1019sub path {
1020 my($self) = @_;
1021 my $path_sep = $Is_OS2 ? ";" : $Is_VMS ? "/" : ":";
1022 my $path = $ENV{PATH};
1023 $path =~ s:\\:/:g if $Is_OS2;
1024 my @path = split $path_sep, $path;
1025}
1026
f06db76b 1027sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
8e07c86e
AD
1028 my($self) = @_;
1029 unless (ref $self){
1030 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1031 $self = $ExtUtils::MakeMaker::Parent[-1];
1032 }
1033 my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
75f92628
AD
1034 local(%pm); #the sub in find() has to see this hash
1035 $ignore{'test.pl'} = 1;
1036 $ignore{'makefile.pl'} = 1 if $Is_VMS;
8e07c86e 1037 foreach $name ($self->lsdir(".")){
75f92628
AD
1038 next if ($name =~ /^\./ or $ignore{$name});
1039 if (-d $name){
1040 $dir{$name} = $name if (-f "$name/Makefile.PL");
1041 } elsif ($name =~ /\.xs$/){
1042 my($c); ($c = $name) =~ s/\.xs$/.c/;
1043 $xs{$name} = $c;
1044 $c{$c} = 1;
864a5fa8 1045 } elsif ($name =~ /\.c$/i){
e50aee73
AD
1046 $c{$name} = 1
1047 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
864a5fa8 1048 } elsif ($name =~ /\.h$/i){
75f92628 1049 $h{$name} = 1;
f06db76b 1050 } elsif ($name =~ /\.(p[ml]|pod)$/){
8e07c86e 1051 $pm{$name} = $self->catfile('$(INST_LIBDIR)',"$name");
232e078e
AD
1052 } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
1053 ($pl_files{$name} = $name) =~ s/\.PL$// ;
3edbfbe5 1054 }
75f92628 1055 }
3edbfbe5 1056
75f92628
AD
1057 # Some larger extensions often wish to install a number of *.pm/pl
1058 # files into the library in various locations.
1059
1060 # The attribute PMLIBDIRS holds an array reference which lists
1061 # subdirectories which we should search for library files to
864a5fa8
AD
1062 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1063 # recursively search through the named directories (skipping any
1064 # which don't exist or contain Makefile.PL files).
75f92628 1065
8e07c86e
AD
1066 # For each *.pm or *.pl file found $self->libscan() is called with
1067 # the default installation path in $_[1]. The return value of
1068 # libscan defines the actual installation location. The default
1069 # libscan function simply returns the path. The file is skipped
1070 # if libscan returns false.
75f92628 1071
8e07c86e 1072 # The default installation location passed to libscan in $_[1] is:
75f92628
AD
1073 #
1074 # ./*.pm => $(INST_LIBDIR)/*.pm
1075 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1076 # ./lib/... => $(INST_LIB)/...
1077 #
1078 # In this way the 'lib' directory is seen as the root of the actual
1079 # perl library whereas the others are relative to INST_LIBDIR
1080 # (which includes ROOTEXT). This is a subtle distinction but one
1081 # that's important for nested modules.
1082
864a5fa8
AD
1083 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]
1084 unless $self->{PMLIBDIRS};
75f92628
AD
1085
1086 #only existing directories that aren't in $dir are allowed
75f92628 1087
8e07c86e
AD
1088 # Avoid $_ wherever possible:
1089 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1090 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1091 my ($pmlibdir);
1092 @{$self->{PMLIBDIRS}} = ();
1093 foreach $pmlibdir (@pmlibdirs) {
1094 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1095 }
1096
1097 if (@{$self->{PMLIBDIRS}}){
1098 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1099 if ($ExtUtils::MakeMaker::Verbose >= 2);
75f92628
AD
1100 use File::Find; # try changing to require !
1101 File::Find::find(sub {
8e07c86e
AD
1102 if (-d $_){
1103 if ($_ eq "CVS" || $_ eq "RCS"){
1104 $File::Find::prune = 1;
1105 }
1106 return;
1107 }
1108 my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
1109 my $striplibpath;
1110 $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^lib/::);
1111 my($inst) = $self->catdir($prefix,$striplibpath);
1112 local($_) = $inst; # for backwards compatibility
1113 $inst = $self->libscan($inst);
1114 print "libscan($path) => '$inst'\n" if ($ExtUtils::MakeMaker::Verbose >= 2);
1115 return unless $inst;
1116 $pm{$path} = $inst;
1117 }, @{$self->{PMLIBDIRS}});
1118 }
1119
1120 $self->{DIR} = [sort keys %dir] unless $self->{DIR};
1121 $self->{XS} = \%xs unless $self->{XS};
1122 $self->{PM} = \%pm unless $self->{PM};
1123 $self->{C} = [sort keys %c] unless $self->{C};
1124 my(@o_files) = @{$self->{C}};
864a5fa8 1125 $self->{O_FILES} = [grep s/\.c$/$self->{OBJ_EXT}/i, @o_files] ;
8e07c86e
AD
1126 $self->{H} = [sort keys %h] unless $self->{H};
1127 $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
864a5fa8 1128
8e07c86e 1129 # Set up names of manual pages to generate from pods
864a5fa8
AD
1130 if ($self->{MAN1PODS}) {
1131 } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) {
1132 $self->{MAN1PODS} = {};
1133 } else {
1134 my %manifypods = ();
cb1a09d0
AD
1135 if( exists $self->{EXE_FILES} ){
1136 foreach $name (@{$self->{EXE_FILES}}) {
1137 local(*TESTPOD);
1138 my($ispod)=0;
1139 if (open(TESTPOD,"<$name")) {
1140 my $testpodline;
1141 while ($testpodline = <TESTPOD>) {
1142 if($testpodline =~ /^=head/) {
1143 $ispod=1;
1144 last;
1145 }
1146 }
1147 close(TESTPOD);
1148 } else {
1149 # If it doesn't exist yet, we assume, it has pods in it
1150 $ispod = 1;
1151 }
1152 if( $ispod ) {
1153 $manifypods{$name} = $self->catdir('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)');
864a5fa8
AD
1154 }
1155 }
864a5fa8
AD
1156 }
1157
1158 $self->{MAN1PODS} = \%manifypods;
1159 }
1160 if ($self->{MAN3PODS}) {
8e07c86e 1161 } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) {
864a5fa8 1162 $self->{MAN3PODS} = {};
8e07c86e
AD
1163 } else {
1164 my %manifypods = (); # we collect the keys first, i.e. the files
1165 # we have to convert to pod
1166 foreach $name (keys %{$self->{PM}}) {
1167 if ($name =~ /\.pod$/ ) {
1168 $manifypods{$name} = $self->{PM}{$name};
1169 } elsif ($name =~ /\.p[ml]$/ ) {
1170 local(*TESTPOD);
1171 my($ispod)=0;
1172 open(TESTPOD,"<$name");
1173 my $testpodline;
1174 while ($testpodline = <TESTPOD>) {
1175 if($testpodline =~ /^=head/) {
1176 $ispod=1;
1177 last;
1178 }
1179 #Speculation on the future (K.A., not A.K. :)
1180 #if(/^=don't\S+install/) { $ispod=0; last}
1181 }
1182 close(TESTPOD);
1183
1184 if( $ispod ) {
1185 $manifypods{$name} = $self->{PM}{$name};
1186 }
1187 }
1188 }
1189
1190 # Remove "Configure.pm" and similar, if it's not the only pod listed
864a5fa8 1191 # To force inclusion, just name it "Configure.pod", or override MAN3PODS
8e07c86e
AD
1192 foreach $name (keys %manifypods) {
1193 if ($name =~ /(config|install|setup).*\.pm/i) {
1194 delete $manifypods{$name};
1195 next;
1196 }
1197 my($manpagename) = $name;
1198 unless ($manpagename =~ s!^lib/!!) {
1199 $manpagename = join("/",$self->{ROOTEXT},$manpagename);
1200 }
1201 $manpagename =~ s/\.p(od|m|l)$//;
1202 # Strip leading slashes
1203 $manpagename =~ s!^/+!!;
1204 # Turn other slashes into colons
1205# $manpagename =~ s,/+,::,g;
1206 $manpagename = $self->replace_manpage_seperator($manpagename);
1207 $manifypods{$name} = "\$(INST_MAN3DIR)/$manpagename.\$(MAN3EXT)";
1208 }
864a5fa8 1209 $self->{MAN3PODS} = \%manifypods;
8e07c86e
AD
1210 }
1211}
1212
1213sub lsdir {
1214 my($self) = shift;
1215 my($dir, $regex) = @_;
1216 local(*DIR, @ls);
1217 opendir(DIR, $dir || ".") or return ();
1218 @ls = readdir(DIR);
1219 closedir(DIR);
1220 @ls = grep(/$regex/, @ls) if $regex;
1221 @ls;
75f92628
AD
1222}
1223
8e07c86e
AD
1224sub replace_manpage_seperator {
1225 my($self,$man) = @_;
1226 $man =~ s,/+,::,g;
1227 $man;
1228}
75f92628
AD
1229
1230sub libscan {
8e07c86e
AD
1231 my($self,$path) = @_;
1232 return '' if $path =~ m:/RCS/: ;
1233 $path;
75f92628
AD
1234}
1235
75f92628 1236sub init_others { # --- Initialize Other Attributes
8e07c86e
AD
1237 my($self) = shift;
1238 unless (ref $self){
1239 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1240 $self = $ExtUtils::MakeMaker::Parent[-1];
a0d0e21e
LW
1241 }
1242
8e07c86e
AD
1243 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1244 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
42793c05 1245 # undefined. In any case we turn it into an anon array:
cb1a09d0
AD
1246
1247 # May check $Config{libs} too, thus not empty.
1248 $self->{LIBS}=[''] unless $self->{LIBS};
1249
8e07c86e
AD
1250 $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq SCALAR;
1251 $self->{LD_RUN_PATH} = "";
1252 my($libs);
1253 foreach $libs ( @{$self->{LIBS}} ){
1254 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1255 my(@libs) = $self->extliblist($libs);
42793c05 1256 if ($libs[0] or $libs[1] or $libs[2]){
4633a7c4
LW
1257 # LD_RUN_PATH now computed by ExtUtils::Liblist
1258 ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
42793c05
TB
1259 last;
1260 }
1261 }
a0d0e21e 1262
8e07c86e
AD
1263 unless ( $self->{OBJECT} ){
1264 # init_dirscan should have found out, if we have C files
4633a7c4 1265 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
a0d0e21e 1266 }
8e07c86e
AD
1267 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1268 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
4633a7c4 1269 $self->{PERLMAINCC} ||= '$(CC)';
8e07c86e
AD
1270 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1271
1aef975c
AD
1272 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1273 # the 'dynamic' section of MM. We don't have this problem with
1274 # 'static', since we either must use it (%Config says we can't
1275 # use dynamic loading) or the caller asked for it explicitly.
8e07c86e
AD
1276 if (!$self->{LINKTYPE}) {
1277 $self->{LINKTYPE} = grep(/dynamic/,@{$self->{SKIP} || []})
1aef975c 1278 ? 'static'
8e07c86e 1279 : ($Config::Config{usedl} ? 'dynamic' : 'static');
1aef975c 1280 };
42793c05 1281
3edbfbe5 1282 # These get overridden for VMS and maybe some other systems
8e07c86e 1283 $self->{NOOP} = "";
4633a7c4
LW
1284 $self->{FIRST_MAKEFILE} ||= "Makefile";
1285 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1286 $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
8e07c86e
AD
1287 $self->{RM_F} = "rm -f";
1288 $self->{RM_RF} = "rm -rf";
1289 $self->{TOUCH} = "touch";
1290 $self->{CP} = "cp";
1291 $self->{MV} = "mv";
1292 $self->{CHMOD} = "chmod";
1293 $self->{UMASK_NULL} = "umask 0";
42793c05
TB
1294}
1295
cb1a09d0 1296sub find_perl {
42793c05 1297 my($self, $ver, $names, $dirs, $trace) = @_;
8e07c86e
AD
1298 unless (ref $self){
1299 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1300 $self = $ExtUtils::MakeMaker::Parent[-1];
1301 }
42793c05 1302 my($name, $dir);
5d94fbed 1303 if ($trace >= 2){
8e07c86e
AD
1304 print "Looking for perl $ver by these names:
1305@$names
1306in these dirs:
1307@$dirs
1308";
fed7345c 1309 }
42793c05 1310 foreach $dir (@$dirs){
8e07c86e 1311 next unless defined $dir; # $self->{PERL_SRC} may be undefined
42793c05 1312 foreach $name (@$names){
8e07c86e 1313 my $abs;
cb1a09d0 1314 if ($self->file_name_is_absolute($name)) {
8e07c86e 1315 $abs = $name;
cb1a09d0
AD
1316 } elsif ($name =~ m|/|) { # file_name_contains_path
1317 $abs = $self->catfile(".", $name);
42793c05 1318 } else {
8e07c86e 1319 $abs = $self->catfile($dir, $name);
42793c05 1320 }
8e07c86e 1321 print "Checking $abs\n" if ($trace >= 2);
4633a7c4 1322 next unless $self->maybe_command($abs);
8e07c86e
AD
1323 print "Executing $abs\n" if ($trace >= 2);
1324 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
1325 print "Using PERL=$abs\n" if $trace;
1326 return $abs;
5d94fbed 1327 }
a0d0e21e
LW
1328 }
1329 }
fed7345c 1330 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
42793c05 1331 0; # false and not empty
a0d0e21e
LW
1332}
1333
4e68a208
AD
1334
1335# Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here
1336sub maybe_command_in_dirs { # $ver is optional argument if looking for perl
1337 my($self, $names, $dirs, $trace, $ver) = @_;
1338 my($name, $dir);
1339 foreach $dir (@$dirs){
1340 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1341 foreach $name (@$names){
1342 my($abs,$tryabs);
1343 if ($self->file_name_is_absolute($name)) {
1344 $abs = $name;
1345 } elsif ($name =~ m|/|) {
1346 $abs = $self->catfile(".", $name); # not absolute
1347 } else {
1348 $abs = $self->catfile($dir, $name);
1349 }
1350 print "Checking $abs for $name\n" if ($trace >= 2);
1351 next unless $tryabs = $self->maybe_command($abs);
1352 print "Substituting $tryabs instead of $abs\n"
1353 if ($trace >= 2 and $tryabs ne $abs);
1354 $abs = $tryabs;
1355 if (defined $ver) {
1356 print "Executing $abs\n" if ($trace >= 2);
1357 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
1358 print "Using PERL=$abs\n" if $trace;
1359 return $abs;
1360 }
1361 } else { # Do not look for perl
1362 return $abs;
1363 }
1364 }
1365 }
1366}
1367
4633a7c4
LW
1368sub maybe_command {
1369 my($self,$file) = @_;
4e68a208 1370 return $file if -x $file && ! -d $file;
4633a7c4
LW
1371 return;
1372}
1373
cb1a09d0
AD
1374sub perl_script {
1375 my($self,$file) = @_;
1376 return 1 if -r $file && ! -d $file;
1377 return;
1378}
1379
4e68a208
AD
1380# Ilya's suggestion, not yet used
1381sub file_name_is_absolute {
1382 my($self,$file) = @_;
1383 $file =~ m:^/: ;
1384}
1385
8e07c86e
AD
1386sub post_initialize {
1387 my($self) = shift;
1388 unless (ref $self){
1389 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1390 $self = $ExtUtils::MakeMaker::Parent[-1];
1391 }
a0d0e21e
LW
1392 "";
1393}
fed7345c 1394
8e07c86e
AD
1395# --- Constants Sections ---
1396
1397sub const_config {
1398 my($self) = shift;
1399 unless (ref $self){
1400 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1401 $self = $ExtUtils::MakeMaker::Parent[-1];
1402 }
1403 my(@m,$m);
1404 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
864a5fa8 1405 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
8e07c86e
AD
1406 my(%once_only);
1407 foreach $m (@{$self->{CONFIG}}){
1408 next if $once_only{$m};
864a5fa8 1409 push @m, "\U$m\E = ".$self->{uc $m}."\n";
8e07c86e
AD
1410 $once_only{$m} = 1;
1411 }
1412 join('', @m);
005c1a0e 1413}
a0d0e21e
LW
1414
1415sub constants {
005c1a0e 1416 my($self) = @_;
8e07c86e
AD
1417 unless (ref $self){
1418 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1419 $self = $ExtUtils::MakeMaker::Parent[-1];
1420 }
1421 unless (ref $self){
1422 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1423 $self = $ExtUtils::MakeMaker::Parent[-1];
1424 }
1425 my(@m,$tmp);
a0d0e21e 1426
a0d0e21e 1427 push @m, "
8e07c86e
AD
1428NAME = $self->{NAME}
1429DISTNAME = $self->{DISTNAME}
1430NAME_SYM = $self->{NAME_SYM}
1431VERSION = $self->{VERSION}
1432VERSION_SYM = $self->{VERSION_SYM}
1433VERSION_MACRO = VERSION
1434DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
cb1a09d0
AD
1435# XS_VERSION = $self->{XS_VERSION}
1436# XS_VERSION_MACRO = XS_VERSION
1437# XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
a0d0e21e 1438
005c1a0e
AD
1439# In which directory should we put this extension during 'make'?
1440# This is typically ./blib.
42793c05 1441# (also see INST_LIBDIR and relationship to ROOTEXT)
8e07c86e
AD
1442INST_LIB = $self->{INST_LIB}
1443INST_ARCHLIB = $self->{INST_ARCHLIB}
1444INST_EXE = $self->{INST_EXE}
42793c05 1445
005c1a0e
AD
1446# AFS users will want to set the installation directories for
1447# the final 'make install' early without setting INST_LIB,
1448# INST_ARCHLIB, and INST_EXE for the testing phase
8e07c86e
AD
1449INSTALLPRIVLIB = $self->{INSTALLPRIVLIB}
1450INSTALLARCHLIB = $self->{INSTALLARCHLIB}
1451INSTALLBIN = $self->{INSTALLBIN}
005c1a0e 1452
42793c05 1453# Perl library to use when building the extension
8e07c86e
AD
1454PERL_LIB = $self->{PERL_LIB}
1455PERL_ARCHLIB = $self->{PERL_ARCHLIB}
1456LIBPERL_A = $self->{LIBPERL_A}
005c1a0e
AD
1457
1458MAKEMAKER = \$(PERL_LIB)/ExtUtils/MakeMaker.pm
8e07c86e 1459MM_VERSION = $ExtUtils::MakeMaker::VERSION
4633a7c4
LW
1460FIRST_MAKEFILE = $self->{FIRST_MAKEFILE}
1461MAKE_APERL_FILE = $self->{MAKE_APERL_FILE}
42793c05 1462
4633a7c4 1463PERLMAINCC = $self->{PERLMAINCC}
8e07c86e 1464";
75f92628
AD
1465
1466 push @m, "
fed7345c 1467# Where is the perl source code located?
8e07c86e 1468PERL_SRC = $self->{PERL_SRC}\n" if $self->{PERL_SRC};
fed7345c
AD
1469
1470 push @m, "
42793c05 1471# Perl header files (will eventually be under PERL_LIB)
8e07c86e 1472PERL_INC = $self->{PERL_INC}
42793c05 1473# Perl binaries
8e07c86e
AD
1474PERL = $self->{PERL}
1475FULLPERL = $self->{FULLPERL}
75f92628
AD
1476";
1477 push @m, "
42793c05
TB
1478# FULLEXT = Pathname for extension directory (eg DBD/Oracle).
1479# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
1480# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
8e07c86e
AD
1481# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
1482FULLEXT = $self->{FULLEXT}
1483BASEEXT = $self->{BASEEXT}
1484ROOTEXT = $self->{ROOTEXT}
1485DLBASE = $self->{DLBASE}
75f92628
AD
1486";
1487 push @m, "
8e07c86e
AD
1488INC = $self->{INC}
1489DEFINE = $self->{DEFINE}
1490OBJECT = $self->{OBJECT}
1491LDFROM = $self->{LDFROM}
1492LINKTYPE = $self->{LINKTYPE}
a0d0e21e 1493
75f92628 1494# Handy lists of source code files:
8e07c86e
AD
1495XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
1496C_FILES = ".join(" \\\n\t", @{$self->{C}})."
1497O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
1498H_FILES = ".join(" \\\n\t", @{$self->{H}})."
864a5fa8
AD
1499MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
1500MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
a0d0e21e 1501
8e07c86e
AD
1502# Man installation stuff:
1503INST_MAN1DIR = $self->{INST_MAN1DIR}
1504INSTALLMAN1DIR = $self->{INSTALLMAN1DIR}
1505MAN1EXT = $self->{MAN1EXT}
a0d0e21e 1506
8e07c86e
AD
1507INST_MAN3DIR = $self->{INST_MAN3DIR}
1508INSTALLMAN3DIR = $self->{INSTALLMAN3DIR}
1509MAN3EXT = $self->{MAN3EXT}
1510
1511
1512# work around a famous dec-osf make(1) feature(?):
1513makemakerdflt: all
42793c05 1514
864a5fa8 1515.SUFFIXES: .xs .c .C \$(OBJ_EXT)
8e07c86e 1516
4633a7c4 1517# .PRECIOUS: Makefile # seems to be not necessary anymore
005c1a0e 1518
75f92628 1519.PHONY: all config static dynamic test linkext
42793c05
TB
1520
1521# This extension may link to it's own library (see SDBM_File)
8e07c86e 1522MYEXTLIB = $self->{MYEXTLIB}
42793c05 1523
75f92628
AD
1524# Where is the Config information that we are using/depend on
1525CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h
a0d0e21e
LW
1526";
1527
1528 push @m, '
1529# Where to put things:
42793c05
TB
1530INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
1531INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
1532
3edbfbe5
TB
1533INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
1534INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
1535';
42793c05 1536
8e07c86e 1537 if ($self->has_link_code()) {
005c1a0e 1538 push @m, '
4633a7c4 1539INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
8e07c86e 1540INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
75f92628 1541INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
005c1a0e
AD
1542';
1543 } else {
1544 push @m, '
1545INST_STATIC =
1546INST_DYNAMIC =
1547INST_BOOT =
1548';
1549 }
1550
8e07c86e
AD
1551 if ($Is_OS2) {
1552 $tmp = "$self->{BASEEXT}.def";
1553 } else {
1554 $tmp = "";
1555 }
1556 push @m, "
1557EXPORT_LIST = $tmp
1558";
864a5fa8 1559
8e07c86e
AD
1560 if ($Is_OS2) {
1561 $tmp = "\$(PERL_INC)/libperl.lib";
1562 } else {
1563 $tmp = "";
1564 }
1565 push @m, "
1566PERL_ARCHIVE = $tmp
1567";
1568
005c1a0e 1569 push @m, '
8e07c86e 1570INST_PM = '.join(" \\\n\t", sort values %{$self->{PM}}).'
42793c05
TB
1571';
1572
1573 join('',@m);
1574}
1575
8e07c86e
AD
1576sub const_loadlibs {
1577 my($self) = shift;
1578 unless (ref $self){
1579 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1580 $self = $ExtUtils::MakeMaker::Parent[-1];
1581 }
1582 return "" unless $self->needs_linking;
864a5fa8
AD
1583 # This description can be deleted after ExtUtils::Liblist is in
1584 # the perl dist with pods
8e07c86e
AD
1585 "
1586# $self->{NAME} might depend on some other libraries:
1587# (These comments may need revising:)
1588#
1589# Dependent libraries can be linked in one of three ways:
1590#
1591# 1. (For static extensions) by the ld command when the perl binary
1592# is linked with the extension library. See EXTRALIBS below.
1593#
1594# 2. (For dynamic extensions) by the ld command when the shared
1595# object is built/linked. See LDLOADLIBS below.
1596#
1597# 3. (For dynamic extensions) by the DynaLoader when the shared
1598# object is loaded. See BSLOADLIBS below.
1599#
1600# EXTRALIBS = List of libraries that need to be linked with when
1601# linking a perl binary which includes this extension
1602# Only those libraries that actually exist are included.
1603# These are written to a file and used when linking perl.
1604#
1605# LDLOADLIBS = List of those libraries which can or must be linked into
1606# the shared library when created using ld. These may be
1607# static or dynamic libraries.
1608# LD_RUN_PATH is a colon separated list of the directories
1609# in LDLOADLIBS. It is passed as an environment variable to
1610# the process that links the shared library.
1611#
1612# BSLOADLIBS = List of those libraries that are needed but can be
1613# linked in dynamically at run time on this platform.
1614# SunOS/Solaris does not need this because ld records
1615# the information (from LDLOADLIBS) into the object file.
1616# This list is used to create a .bs (bootstrap) file.
1617#
1618EXTRALIBS = $self->{EXTRALIBS}
1619LDLOADLIBS = $self->{LDLOADLIBS}
1620BSLOADLIBS = $self->{BSLOADLIBS}
1621LD_RUN_PATH= $self->{LD_RUN_PATH}
1622";
1623}
42793c05 1624
8e07c86e 1625sub const_cccmd {
40000a8c 1626 my($self,$libperl)=@_;
8e07c86e
AD
1627 unless (ref $self){
1628 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1629 $self = $ExtUtils::MakeMaker::Parent[-1];
1630 }
1631 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
1632 return '' unless $self->needs_linking();
4633a7c4
LW
1633 $libperl or $libperl = $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
1634 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
75f92628
AD
1635 # This is implemented in the same manner as extliblist,
1636 # e.g., do both and compare results during the transition period.
1637 my($cc,$ccflags,$optimize,$large,$split, $shflags)
1638 = @Config{qw(cc ccflags optimize large split shellflags)};
8e07c86e 1639 my($optdebug) = "";
232e078e 1640
75f92628 1641 $shflags = '' unless $shflags;
864a5fa8 1642 my($prog, $uc, $perltype);
e1666bf5 1643
40000a8c
AD
1644 my(%map) = (
1645 D => '-DDEBUGGING',
1646 E => '-DEMBED',
1647 DE => '-DDEBUGGING -DEMBED',
1648 M => '-DEMBED -DMULTIPLICITY',
1649 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
1650 );
1651
4633a7c4 1652 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
40000a8c
AD
1653 $uc = uc($1);
1654 } else {
1655 $uc = ""; # avoid warning
1656 }
1657 $perltype = $map{$uc} ? $map{$uc} : "";
1658
1659 if ($uc =~ /^D/) {
1660 $optdebug = "-g";
1661 }
1662
1663
1aef975c 1664 my($name);
8e07c86e
AD
1665 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
1666 if ($prog = $Config::Config{$name}) {
75f92628 1667 # Expand hints for this extension via the shell
8e07c86e 1668 print STDOUT "Processing $name hint:\n" if $ExtUtils::MakeMaker::Verbose;
75f92628
AD
1669 my(@o)=`cc=\"$cc\"
1670 ccflags=\"$ccflags\"
1671 optimize=\"$optimize\"
40000a8c
AD
1672 perltype=\"$perltype\"
1673 optdebug=\"$optdebug\"
75f92628
AD
1674 large=\"$large\"
1675 split=\"$split\"
1676 eval '$prog'
1677 echo cc=\$cc
1678 echo ccflags=\$ccflags
1679 echo optimize=\$optimize
40000a8c
AD
1680 echo perltype=\$perltype
1681 echo optdebug=\$optdebug
75f92628
AD
1682 echo large=\$large
1683 echo split=\$split
1684 `;
232e078e 1685 my(%cflags,$line);
75f92628
AD
1686 foreach $line (@o){
1687 chomp $line;
1688 if ($line =~ /(.*?)=\s*(.*)\s*$/){
1689 $cflags{$1} = $2;
8e07c86e 1690 print STDOUT " $1 = $2\n" if $ExtUtils::MakeMaker::Verbose;
75f92628 1691 } else {
fed7345c 1692 print STDOUT "Unrecognised result from hint: '$line'\n";
75f92628
AD
1693 }
1694 }
40000a8c
AD
1695 ( $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split )=@cflags{
1696 qw( cc ccflags perltype optdebug optimize large split)};
1697 }
1698
1699 if ($optdebug) {
1700 $optimize = $optdebug;
75f92628
AD
1701 }
1702
4633a7c4 1703 my($new) = "$cc -c \$(INC) $ccflags $optimize $perltype $large $split";
005c1a0e 1704 $new =~ s/^\s+//; $new =~ s/\s+/ /g; $new =~ s/\s+$//;
864a5fa8
AD
1705
1706 my($cccmd) = $new;
8e07c86e 1707 $cccmd =~ s/^\s*\Q$Config::Config{cc}\E\s/\$(CC) /;
4e68a208 1708 $cccmd .= " \$(DEFINE_VERSION) \$(XS_DEFINE_VERSION)";
8e07c86e 1709 $self->{CONST_CCCMD} = "CCCMD = $cccmd\n";
42793c05 1710}
a0d0e21e 1711
42793c05 1712# --- Tool Sections ---
a0d0e21e 1713
8e07c86e 1714sub tool_autosplit {
42793c05 1715 my($self, %attribs) = @_;
8e07c86e
AD
1716 unless (ref $self){
1717 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1718 $self = $ExtUtils::MakeMaker::Parent[-1];
1719 }
42793c05
TB
1720 my($asl) = "";
1721 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
1722 q{
42793c05 1723# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
005c1a0e 1724AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
42793c05
TB
1725};
1726}
a0d0e21e 1727
8e07c86e
AD
1728sub tool_xsubpp {
1729 my($self) = shift;
1730 unless (ref $self){
1731 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1732 $self = $ExtUtils::MakeMaker::Parent[-1];
1733 }
864a5fa8 1734 my($xsdir) = "$self->{PERL_LIB}/ExtUtils";
e1666bf5 1735 # drop back to old location if xsubpp is not in new location yet
864a5fa8 1736 $xsdir = "$self->{PERL_SRC}/ext" unless (-f "$self->{PERL_LIB}/ExtUtils/xsubpp");
e1666bf5 1737 my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
8e07c86e
AD
1738 if( $self->{TYPEMAPS} ){
1739 my $typemap;
1740 foreach $typemap (@{$self->{TYPEMAPS}}){
1741 if( ! -f $typemap ){
1742 warn "Typemap $typemap not found.\n";
1743 }
1744 else{
1745 push(@tmdeps, $typemap);
1746 }
1747 }
1748 }
42793c05
TB
1749 push(@tmdeps, "typemap") if -f "typemap";
1750 my(@tmargs) = map("-typemap $_", @tmdeps);
4633a7c4 1751 if( exists $self->{XSOPT} ){
864a5fa8
AD
1752 unshift( @tmargs, $self->{XSOPT} );
1753 }
1754
1755 my $xsubpp_version = $self->xsubpp_version("$xsdir/xsubpp");
1756
1757 # What are the correct thresholds for version 1 && 2 Paul?
1758 if ( $xsubpp_version > 1.923 ){
4e68a208 1759 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
864a5fa8
AD
1760 } else {
1761 if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
1762 print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
1763 Your version of xsubpp is $xsubpp_version and cannot handle this.
1764 Please upgrade to a more recent version of xsubpp.
1765};
1766 } else {
1767 $self->{XSPROTOARG} = "";
1768 }
4633a7c4 1769 }
864a5fa8 1770
42793c05 1771 "
e1666bf5
TB
1772XSUBPPDIR = $xsdir
1773XSUBPP = \$(XSUBPPDIR)/xsubpp
864a5fa8 1774XSPROTOARG = $self->{XSPROTOARG}
42793c05
TB
1775XSUBPPDEPS = @tmdeps
1776XSUBPPARGS = @tmargs
1777";
1778};
a0d0e21e 1779
864a5fa8
AD
1780sub xsubpp_version
1781{
1782 my($self,$xsubpp) = @_;
1783 my ($version) ;
1784
1785 # try to figure out the version number of the xsubpp on the system
1786
1787 # first try the -v flag, introduced in 1.921 & 2.000a2
1788
1789 my $command = "$self->{PERL} $xsubpp -v 2>&1";
1790 print "Running: $command\n" if $Verbose;
1791 $version = `$command` ;
4e68a208 1792 warn "Running '$command' exits with status " . ($?>>8) if $?;
864a5fa8
AD
1793 chop $version ;
1794
1795 return $1 if $version =~ /^xsubpp version (.*)/ ;
1796
1797 # nope, then try something else
1798
1799 my $counter = '000';
1800 my ($file) = 'temp' ;
1801 $counter++ while -e "$file$counter"; # don't overwrite anything
1802 $file .= $counter;
1803
1804 open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
1805 print F <<EOM ;
1806MODULE = fred PACKAGE = fred
1807
1808int
1809fred(a)
1810 int a;
1811EOM
1812
1813 close F ;
1814
1815 $command = "$self->{PERL} $xsubpp $file 2>&1";
1816 print "Running: $command\n" if $Verbose;
1817 my $text = `$command` ;
4e68a208 1818 warn "Running '$command' exits with status " . ($?>>8) if $?;
864a5fa8
AD
1819 unlink $file ;
1820
1821 # gets 1.2 -> 1.92 and 2.000a1
1822 return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ;
1823
1824 # it is either 1.0 or 1.1
1825 return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
1826
1827 # none of the above, so 1.0
1828 return "1.0" ;
1829}
1830
8e07c86e
AD
1831sub tools_other {
1832 my($self) = shift;
1833 unless (ref $self){
1834 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1835 $self = $ExtUtils::MakeMaker::Parent[-1];
1836 }
e1666bf5 1837 "
42793c05 1838SHELL = /bin/sh
8e07c86e
AD
1839LD = $self->{LD}
1840TOUCH = $self->{TOUCH}
1841CP = $self->{CP}
1842MV = $self->{MV}
1843RM_F = $self->{RM_F}
1844RM_RF = $self->{RM_RF}
1845CHMOD = $self->{CHMOD}
1846UMASK_NULL = $self->{UMASK_NULL}
e1666bf5 1847".q{
42793c05 1848# The following is a portable way to say mkdir -p
8e07c86e
AD
1849# To see which directories are created, change the if 0 to if 1
1850MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){' \\
1851-e 'next if -d $$p; my(@p); foreach(split(/\//,$$p)){' \\
1852-e 'push(@p,$$_); next if -d "@p/"; print "mkdir @p" if 0;' \\
1853-e 'mkdir("@p",0777)||die $$! } } exit 0;'
42793c05 1854};
a0d0e21e
LW
1855}
1856
8e07c86e
AD
1857sub dist {
1858 my($self, %attribs) = @_;
1859 unless (ref $self){
1860 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1861 $self = $ExtUtils::MakeMaker::Parent[-1];
1862 }
1863 my(@m);
1864 # VERSION should be sanitised before use as a file name
864a5fa8
AD
1865 my($name) = $attribs{NAME} || '$(DISTVNAME)';
1866 my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar
1867 my($tarflags) = $attribs{TARFLAGS} || 'cvf';
1868 my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip
1869 my($suffix) = $attribs{SUFFIX} || 'Z'; # eg gz
1870 my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip"
1871 my($preop) = $attribs{PREOP} || '@ true'; # eg update MANIFEST
8e07c86e
AD
1872 my($postop) = $attribs{POSTOP} || '@ true'; # eg remove the distdir
1873 my($ci) = $attribs{CI} || 'ci -u';
1874 my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q';
4633a7c4 1875 my($dist_cp) = $attribs{DIST_CP} || 'best';
8e07c86e 1876 my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
a0d0e21e 1877
8e07c86e
AD
1878 push @m, "
1879DISTVNAME = \$(DISTNAME)-\$(VERSION)
1880TAR = $tar
1881TARFLAGS = $tarflags
1882COMPRESS = $compress
1883SUFFIX = $suffix
1884SHAR = $shar
1885PREOP = $preop
1886POSTOP = $postop
1887CI = $ci
1888RCS_LABEL = $rcs_label
1889DIST_CP = $dist_cp
1890DIST_DEFAULT = $dist_default
1891";
1892 join "", @m;
a0d0e21e
LW
1893}
1894
005c1a0e
AD
1895sub macro {
1896 my($self,%attribs) = @_;
8e07c86e
AD
1897 unless (ref $self){
1898 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1899 $self = $ExtUtils::MakeMaker::Parent[-1];
1900 }
005c1a0e
AD
1901 my(@m,$key,$val);
1902 while (($key,$val) = each %attribs){
1903 push @m, "$key = $val\n";
1904 }
1905 join "", @m;
1906}
1907
8e07c86e
AD
1908sub post_constants{
1909 my($self) = shift;
1910 unless (ref $self){
1911 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1912 $self = $ExtUtils::MakeMaker::Parent[-1];
1913 }
1914 "";
1915}
1916
232e078e 1917sub pasthru {
8e07c86e
AD
1918 my($self) = shift;
1919 unless (ref $self){
1920 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1921 $self = $ExtUtils::MakeMaker::Parent[-1];
1922 }
005c1a0e 1923 my(@m,$key);
005c1a0e 1924
4633a7c4 1925 my(@pasthru);
005c1a0e 1926
864a5fa8 1927 foreach $key (qw(INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN
4633a7c4
LW
1928 INSTALLMAN1DIR INSTALLMAN3DIR LIBPERL_A
1929 LINKTYPE)){
8e07c86e 1930 push @pasthru, "$key=\"\$($key)\"";
232e078e 1931 }
005c1a0e 1932
8e07c86e 1933 push @m, "\nPASTHRU = ", join ("\\\n\t", @pasthru), "\n";
232e078e
AD
1934 join "", @m;
1935}
a0d0e21e 1936
42793c05 1937# --- Translation Sections ---
a0d0e21e 1938
42793c05 1939sub c_o {
8e07c86e
AD
1940 my($self) = shift;
1941 unless (ref $self){
1942 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1943 $self = $ExtUtils::MakeMaker::Parent[-1];
1944 }
1945 return '' unless $self->needs_linking();
40000a8c 1946 my(@m);
fed7345c 1947 push @m, '
4633a7c4
LW
1948.c$(OBJ_EXT):
1949 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
864a5fa8
AD
1950
1951.C$(OBJ_EXT):
1952 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
42793c05 1953';
fed7345c 1954 join "", @m;
a0d0e21e
LW
1955}
1956
42793c05 1957sub xs_c {
8e07c86e
AD
1958 my($self) = shift;
1959 unless (ref $self){
1960 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1961 $self = $ExtUtils::MakeMaker::Parent[-1];
1962 }
1963 return '' unless $self->needs_linking();
42793c05
TB
1964 '
1965.xs.c:
864a5fa8 1966 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
42793c05
TB
1967';
1968}
a0d0e21e 1969
42793c05 1970sub xs_o { # many makes are too dumb to use xs_c then c_o
8e07c86e
AD
1971 my($self) = shift;
1972 unless (ref $self){
1973 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1974 $self = $ExtUtils::MakeMaker::Parent[-1];
1975 }
1976 return '' unless $self->needs_linking();
a0d0e21e 1977 '
4633a7c4 1978.xs$(OBJ_EXT):
864a5fa8 1979 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
4633a7c4 1980 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
a0d0e21e
LW
1981';
1982}
1983
42793c05
TB
1984# --- Target Sections ---
1985
8e07c86e
AD
1986sub top_targets {
1987 my($self) = shift;
1988 unless (ref $self){
1989 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1990 $self = $ExtUtils::MakeMaker::Parent[-1];
1991 }
1992 unless (ref $self){
1993 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1994 $self = $ExtUtils::MakeMaker::Parent[-1];
1995 }
40000a8c 1996 my(@m);
fed7345c 1997 push @m, '
8e07c86e
AD
1998all :: config $(INST_PM) subdirs linkext manifypods
1999
2000subdirs :: $(MYEXTLIB)
2001
2002'.$self->{NOOP}.'
2003
2004config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists
42793c05 2005
8e07c86e
AD
2006config :: $(INST_ARCHAUTODIR)/.exists Version_check
2007
2008config :: $(INST_AUTODIR)/.exists
a0d0e21e 2009';
fed7345c 2010
864a5fa8 2011 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
8e07c86e 2012
864a5fa8
AD
2013 if (%{$self->{MAN1PODS}}) {
2014 push @m, q[
2015config :: $(INST_MAN1DIR)/.exists
8e07c86e 2016
864a5fa8
AD
2017];
2018 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
8e07c86e 2019 }
864a5fa8
AD
2020 if (%{$self->{MAN3PODS}}) {
2021 push @m, q[
2022config :: $(INST_MAN3DIR)/.exists
8e07c86e 2023
864a5fa8
AD
2024];
2025 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
2026 }
232e078e 2027
fed7345c
AD
2028 push @m, '
2029$(O_FILES): $(H_FILES)
8e07c86e 2030' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
005c1a0e
AD
2031
2032 push @m, q{
2033help:
8e07c86e 2034 perldoc ExtUtils::MakeMaker
005c1a0e
AD
2035};
2036
2037 push @m, q{
2038Version_check:
8e07c86e
AD
2039 @$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
2040 -e 'use ExtUtils::MakeMaker qw($$Version &Version_check);' \
4633a7c4 2041 -e '&Version_check("$(MM_VERSION)")'
005c1a0e
AD
2042};
2043
fed7345c 2044 join('',@m);
a0d0e21e
LW
2045}
2046
42793c05
TB
2047sub linkext {
2048 my($self, %attribs) = @_;
8e07c86e
AD
2049 unless (ref $self){
2050 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2051 $self = $ExtUtils::MakeMaker::Parent[-1];
2052 }
005c1a0e 2053 # LINKTYPE => static or dynamic or ''
864a5fa8 2054 my($linktype) = defined $attribs{LINKTYPE} ?
005c1a0e 2055 $attribs{LINKTYPE} : '$(LINKTYPE)';
42793c05
TB
2056 "
2057linkext :: $linktype
8e07c86e 2058$self->{NOOP}
42793c05
TB
2059";
2060}
2061
1aef975c
AD
2062sub dlsyms {
2063 my($self,%attribs) = @_;
8e07c86e
AD
2064 unless (ref $self){
2065 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2066 $self = $ExtUtils::MakeMaker::Parent[-1];
2067 }
1aef975c 2068
8e07c86e 2069 return '' if ($Config::Config{osname} ne 'aix');
1aef975c 2070
8e07c86e
AD
2071 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
2072 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
1aef975c
AD
2073 my(@m);
2074
2075 push(@m,"
8e07c86e 2076dynamic :: $self->{BASEEXT}.exp
1aef975c 2077
8e07c86e 2078") unless $self->{SKIPHASH}{dynamic};
1aef975c
AD
2079
2080 push(@m,"
8e07c86e 2081static :: $self->{BASEEXT}.exp
1aef975c 2082
8e07c86e 2083") unless $self->{SKIPHASH}{static};
1aef975c
AD
2084
2085 push(@m,"
8e07c86e 2086$self->{BASEEXT}.exp: Makefile.PL
005c1a0e 2087",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::MakeMaker qw(&mksymlists); \\
864a5fa8 2088 MM->new()->mksymlists({DL_FUNCS => ',
40000a8c 2089 %$funcs ? neatvalue($funcs) : '""',', DL_VARS => ',
4633a7c4 2090 @$vars ? neatvalue($vars) : '""', ", NAME => \"$self->{NAME}\"})'
fed7345c 2091");
1aef975c
AD
2092
2093 join('',@m);
2094}
42793c05
TB
2095
2096# --- Dynamic Loading Sections ---
a0d0e21e
LW
2097
2098sub dynamic {
8e07c86e
AD
2099 my($self) = shift;
2100 unless (ref $self){
2101 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2102 $self = $ExtUtils::MakeMaker::Parent[-1];
2103 }
a0d0e21e 2104 '
42793c05
TB
2105# $(INST_PM) has been moved to the all: target.
2106# It remains here for awhile to allow for old usage: "make dynamic"
8e07c86e
AD
2107dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
2108'.$self->{NOOP}.'
42793c05
TB
2109';
2110}
a0d0e21e 2111
42793c05
TB
2112sub dynamic_bs {
2113 my($self, %attribs) = @_;
8e07c86e
AD
2114 unless (ref $self){
2115 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2116 $self = $ExtUtils::MakeMaker::Parent[-1];
2117 }
2118 return '' unless $self->needs_linking();
42793c05 2119 '
8e07c86e 2120BOOTSTRAP = '."$self->{BASEEXT}.bs".'
a0d0e21e 2121
005c1a0e 2122# As Mkbootstrap might not write a file (if none is required)
42793c05
TB
2123# we use touch to prevent make continually trying to remake it.
2124# The DynaLoader only reads a non-empty file.
8e07c86e 2125$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".'
005c1a0e
AD
2126 @ echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
2127 @ $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
2128 -e \'use ExtUtils::Mkbootstrap;\' \
2129 -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\'
fed7345c 2130 @ $(TOUCH) $(BOOTSTRAP)
005c1a0e
AD
2131 $(CHMOD) 644 $@
2132 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
a0d0e21e
LW
2133
2134$(INST_BOOT): $(BOOTSTRAP)
8e07c86e
AD
2135 @ '.$self->{RM_RF}.' $(INST_BOOT)
2136 -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
005c1a0e
AD
2137 $(CHMOD) 644 $@
2138 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
a0d0e21e
LW
2139';
2140}
2141
42793c05
TB
2142sub dynamic_lib {
2143 my($self, %attribs) = @_;
8e07c86e
AD
2144 unless (ref $self){
2145 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2146 $self = $ExtUtils::MakeMaker::Parent[-1];
2147 }
2148 return '' unless $self->needs_linking(); #might be because of a subdir
2149
2150 return '
2151$(INST_DYNAMIC):
2152' unless ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB});
2153
42793c05 2154 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
8e07c86e 2155 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
3edbfbe5 2156 my($ldfrom) = '$(LDFROM)';
8e07c86e 2157 my($osname) = $Config::Config{osname};
75f92628 2158 $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':');
3edbfbe5
TB
2159 my(@m);
2160 push(@m,'
75f92628
AD
2161# This section creates the dynamically loadable $(INST_DYNAMIC)
2162# from $(OBJECT) and possibly $(MYEXTLIB).
42793c05
TB
2163ARMAYBE = '.$armaybe.'
2164OTHERLDFLAGS = '.$otherldflags.'
a0d0e21e 2165
8e07c86e 2166$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE)
3edbfbe5
TB
2167');
2168 if ($armaybe ne ':'){
4633a7c4 2169 $ldfrom = 'tmp$(LIB_EXT)';
3edbfbe5
TB
2170 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
2171 push(@m,' $(RANLIB) '."$ldfrom\n");
2172 }
75f92628 2173 $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf');
005c1a0e 2174 push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
8e07c86e 2175 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS) $(EXPORT_LIST) $(PERL_ARCHIVE)');
005c1a0e
AD
2176 push @m, '
2177 $(CHMOD) 755 $@
2178 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
2179';
232e078e 2180
8e07c86e 2181 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
3edbfbe5 2182 join('',@m);
a0d0e21e
LW
2183}
2184
42793c05
TB
2185# --- Static Loading Sections ---
2186
2187sub static {
8e07c86e
AD
2188 my($self) = shift;
2189 unless (ref $self){
2190 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2191 $self = $ExtUtils::MakeMaker::Parent[-1];
2192 }
a0d0e21e 2193 '
42793c05
TB
2194# $(INST_PM) has been moved to the all: target.
2195# It remains here for awhile to allow for old usage: "make static"
8e07c86e
AD
2196static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
2197'.$self->{NOOP}.'
a0d0e21e
LW
2198';
2199}
2200
8e07c86e 2201sub static_lib {
005c1a0e 2202 my($self) = @_;
8e07c86e
AD
2203 unless (ref $self){
2204 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2205 $self = $ExtUtils::MakeMaker::Parent[-1];
2206 }
2207 return '' unless $self->needs_linking(); #might be because of a subdir
2208
2209 return '
2210$(INST_DYNAMIC):
2211' unless ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB});
2212
42793c05
TB
2213 my(@m);
2214 push(@m, <<'END');
232e078e 2215$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
42793c05
TB
2216END
2217 # If this extension has it's own library (eg SDBM_File)
2218 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
8e07c86e 2219 push(@m, " $self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
42793c05
TB
2220
2221 push(@m, <<'END');
8e07c86e 2222 $(AR) cr $@ $(OBJECT) && $(RANLIB) $@
75f92628 2223 @echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
005c1a0e
AD
2224 $(CHMOD) 755 $@
2225 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
42793c05 2226END
fed7345c
AD
2227
2228# Old mechanism - still available:
2229
8e07c86e 2230 push(@m, <<'END') if $self->{PERL_SRC};
fed7345c 2231 @ echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
e1666bf5 2232END
005c1a0e 2233
8e07c86e 2234 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
42793c05
TB
2235 join('', "\n",@m);
2236}
2237
a0d0e21e 2238sub installpm {
42793c05 2239 my($self, %attribs) = @_;
8e07c86e
AD
2240 unless (ref $self){
2241 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2242 $self = $ExtUtils::MakeMaker::Parent[-1];
2243 }
42793c05
TB
2244 # By default .pm files are split into the architecture independent
2245 # library. This is a good thing. If a specific module requires that
2246 # it's .pm files are split into the architecture specific library
2247 # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
2248 # Note that installperl currently interferes with this (Config.pm)
2249 # User can disable split by saying: installpm => {SPLITLIB=>''}
2250 my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
2251 $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
2252 my(@m, $dist);
8e07c86e
AD
2253 push @m, "inst_pm :: \$(INST_PM)\n\n";
2254 foreach $dist (sort keys %{$self->{PM}}){
2255 my($inst) = $self->{PM}->{$dist};
42793c05 2256 push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
8e07c86e 2257 push(@m, $self->installpm_x($dist, $inst, $splitlib));
42793c05
TB
2258 push(@m, "\n");
2259 }
2260 join('', @m);
a0d0e21e
LW
2261}
2262
42793c05
TB
2263sub installpm_x { # called by installpm per file
2264 my($self, $dist, $inst, $splitlib) = @_;
8e07c86e
AD
2265 unless (ref $self){
2266 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2267 $self = $ExtUtils::MakeMaker::Parent[-1];
2268 }
005c1a0e
AD
2269 warn "Warning: Most probably 'make' will have problems processing this file: $inst\n"
2270 if $inst =~ m![:#]!;
42793c05
TB
2271 my($instdir) = $inst =~ m|(.*)/|;
2272 my(@m);
2273 push(@m,"
8e07c86e
AD
2274$inst: $dist $self->{MAKEFILE} $instdir/.exists
2275".' @ '.$self->{RM_F}.' $@
2276 $(UMASK_NULL) && '."$self->{CP} $dist".' $@
2277 @ echo $@ >> $(INST_ARCHAUTODIR)/.packlist
42793c05 2278');
40000a8c 2279 push(@m, "\t\@\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
42793c05 2280 if ($splitlib and $inst =~ m/\.pm$/);
232e078e 2281
8e07c86e
AD
2282 push @m, $self->dir_target($instdir);
2283 join('', @m);
2284}
2285
2286sub manifypods {
2287 my($self, %attribs) = @_;
2288 unless (ref $self){
2289 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2290 $self = $ExtUtils::MakeMaker::Parent[-1];
2291 }
864a5fa8 2292 return "\nmanifypods :\n" unless %{$self->{MAN3PODS}};
8e07c86e 2293 my($dist);
4633a7c4
LW
2294 my($pod2man_exe);
2295 if (defined $self->{PERL_SRC}) {
2296 $pod2man_exe = "$self->{PERL_SRC}/pod/pod2man";
2297 } else {
2298 $pod2man_exe = "$Config{bin}/pod2man";
2299 }
cb1a09d0 2300 unless ($self->perl_script($pod2man_exe)) {
864a5fa8 2301 # No pod2man but some MAN3PODS to be installed
4633a7c4
LW
2302 print <<END;
2303
2304Warning: I could not locate your pod2man program. Please make sure,
2305 your pod2man program is in your PATH before you execute 'make'
2306
2307END
2308 $pod2man_exe = "-S pod2man";
2309 }
8e07c86e 2310 my(@m);
4633a7c4
LW
2311 push @m,
2312qq[POD2MAN_EXE = $pod2man_exe\n],
8e07c86e 2313q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\
864a5fa8 2314-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\
8e07c86e 2315-e 'print "Installing $$m{$$_}\n";' \\
4633a7c4 2316-e 'system("$(PERL) $(POD2MAN_EXE) $$_>$$m{$$_}")==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
8e07c86e
AD
2317-e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}'
2318];
4e68a208
AD
2319 push @m, "\nmanifypods : ";
2320 push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
8e07c86e
AD
2321
2322 push(@m,"\n");
864a5fa8
AD
2323 if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
2324 push @m, "\t\@\$(POD2MAN) \\\n\t";
2325 push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
8e07c86e 2326 }
42793c05
TB
2327 join('', @m);
2328}
a0d0e21e 2329
232e078e 2330sub processPL {
8e07c86e
AD
2331 my($self) = shift;
2332 unless (ref $self){
2333 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2334 $self = $ExtUtils::MakeMaker::Parent[-1];
2335 }
2336 return "" unless $self->{PL_FILES};
232e078e 2337 my(@m, $plfile);
8e07c86e 2338 foreach $plfile (sort keys %{$self->{PL_FILES}}) {
232e078e 2339 push @m, "
8e07c86e 2340all :: $self->{PL_FILES}->{$plfile}
232e078e 2341
8e07c86e 2342$self->{PL_FILES}->{$plfile} :: $plfile
232e078e
AD
2343 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
2344";
2345 }
2346 join "", @m;
2347}
2348
40000a8c 2349sub installbin {
8e07c86e
AD
2350 my($self) = shift;
2351 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
cb1a09d0 2352 return "" unless @{$self->{EXE_FILES}};
40000a8c 2353 my(@m, $from, $to, %fromto, @to);
8e07c86e
AD
2354 push @m, $self->dir_target(qw[$(INST_EXE)]);
2355 for $from (@{$self->{EXE_FILES}}) {
2356 my($path)= '$(INST_EXE)/' . basename($from);
2357 local($_) = $path; # for backwards compatibility
2358 $to = $self->exescan($path);
2359 print "exescan($from) => '$to'\n" if ($ExtUtils::MakeMaker::Verbose >=2);
40000a8c
AD
2360 $fromto{$from}=$to;
2361 }
2362 @to = values %fromto;
2363 push(@m, "
8e07c86e 2364EXE_FILES = @{$self->{EXE_FILES}}
40000a8c
AD
2365
2366all :: @to
2367
2368realclean ::
8e07c86e 2369 $self->{RM_F} @to
40000a8c
AD
2370");
2371
2372 while (($from,$to) = each %fromto) {
005c1a0e 2373 my $todir = dirname($to);
40000a8c 2374 push @m, "
8e07c86e
AD
2375$to: $from $self->{MAKEFILE} $todir/.exists
2376 $self->{CP} $from $to
40000a8c
AD
2377";
2378 }
2379 join "", @m;
2380}
42793c05 2381
40000a8c 2382sub exescan {
8e07c86e
AD
2383 my($self,$path) = @_;
2384 $path;
40000a8c 2385}
42793c05
TB
2386# --- Sub-directory Sections ---
2387
2388sub subdirs {
8e07c86e
AD
2389 my($self) = shift;
2390 unless (ref $self){
2391 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2392 $self = $ExtUtils::MakeMaker::Parent[-1];
2393 }
2394 my(@m,$dir);
42793c05
TB
2395 # This method provides a mechanism to automatically deal with
2396 # subdirectories containing further Makefile.PL scripts.
2397 # It calls the subdir_x() method for each subdirectory.
8e07c86e
AD
2398 foreach $dir (@{$self->{DIR}}){
2399 push(@m, $self->subdir_x($dir));
4633a7c4 2400#### print "Including $dir subdirectory\n";
42793c05
TB
2401 }
2402 if (@m){
2403 unshift(@m, "
2404# The default clean, realclean and test targets in this Makefile
2405# have automatically been given entries for each subdir.
2406
42793c05
TB
2407");
2408 } else {
2409 push(@m, "\n# none")
2410 }
2411 join('',@m);
2412}
2413
2414sub runsubdirpl{ # Experimental! See subdir_x section
2415 my($self,$subdir) = @_;
8e07c86e
AD
2416 unless (ref $self){
2417 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2418 $self = $ExtUtils::MakeMaker::Parent[-1];
2419 }
42793c05 2420 chdir($subdir) or die "chdir($subdir): $!";
005c1a0e 2421 package main;
42793c05 2422 require "Makefile.PL";
a0d0e21e
LW
2423}
2424
42793c05
TB
2425sub subdir_x {
2426 my($self, $subdir) = @_;
8e07c86e
AD
2427 unless (ref $self){
2428 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2429 $self = $ExtUtils::MakeMaker::Parent[-1];
2430 }
42793c05 2431 my(@m);
42793c05 2432 qq{
42793c05
TB
2433
2434subdirs ::
4633a7c4 2435 \@-cd $subdir && \$(MAKE) all \$(PASTHRU)
42793c05
TB
2436
2437};
2438}
2439
42793c05
TB
2440# --- Cleanup and Distribution Sections ---
2441
2442sub clean {
2443 my($self, %attribs) = @_;
8e07c86e
AD
2444 unless (ref $self){
2445 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2446 $self = $ExtUtils::MakeMaker::Parent[-1];
2447 }
2448 my(@m,$dir);
42793c05
TB
2449 push(@m, '
2450# Delete temporary files but do not touch installed files. We don\'t delete
2451# the Makefile here so a later make realclean still has a makefile to use.
2452
2453clean ::
2454');
2455 # clean subdirectories first
8e07c86e
AD
2456 for $dir (@{$self->{DIR}}) {
2457 push @m, "\t-cd $dir && test -f $self->{MAKEFILE} && \$(MAKE) clean\n";
2458 }
2459
2460 my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
42793c05 2461 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
8e07c86e
AD
2462 push(@otherfiles, qw[./blib Makeaperlfile $(INST_ARCHAUTODIR)/extralibs.all
2463 perlmain.c mon.out core so_locations
864a5fa8 2464 *~ */*~ */*/*~
4633a7c4 2465 *$(OBJ_EXT) *$(LIB_EXT)
864a5fa8 2466 perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp
8e07c86e
AD
2467 ]);
2468 push @m, "\t-$self->{RM_RF} @otherfiles\n";
75f92628 2469 # See realclean and ext/utils/make_ext for usage of Makefile.old
8e07c86e
AD
2470 push(@m,
2471 "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old 2>/dev/null\n");
2472 push(@m,
2473 "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
42793c05
TB
2474 join("", @m);
2475}
a0d0e21e
LW
2476
2477sub realclean {
42793c05 2478 my($self, %attribs) = @_;
8e07c86e
AD
2479 unless (ref $self){
2480 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2481 $self = $ExtUtils::MakeMaker::Parent[-1];
2482 }
42793c05
TB
2483 my(@m);
2484 push(@m,'
2485# Delete temporary files (via clean) and also delete installed files
2486realclean purge :: clean
2487');
75f92628 2488 # realclean subdirectories first (already cleaned)
232e078e 2489 my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
8e07c86e
AD
2490 foreach(@{$self->{DIR}}){
2491 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
2492 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
2493 }
2494 push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
2495 push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
2496 push(@m, " $self->{RM_F} \$(INST_STATIC) \$(INST_PM)\n");
864a5fa8 2497 my(@otherfiles) = ($self->{MAKEFILE},
8e07c86e 2498 "$self->{MAKEFILE}.old"); # Makefiles last
42793c05 2499 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
8e07c86e 2500 push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles;
42793c05
TB
2501 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
2502 join("", @m);
2503}
a0d0e21e 2504
8e07c86e
AD
2505sub dist_basics {
2506 my($self) = shift;
2507 unless (ref $self){
2508 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2509 $self = $ExtUtils::MakeMaker::Parent[-1];
005c1a0e 2510 }
8e07c86e 2511 my @m;
005c1a0e
AD
2512 push @m, q{
2513distclean :: realclean distcheck
8e07c86e 2514};
005c1a0e 2515
8e07c86e 2516 push @m, q{
005c1a0e 2517distcheck :
8e07c86e 2518 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\
005c1a0e 2519 -e 'fullcheck();'
8e07c86e 2520};
005c1a0e 2521
8e07c86e 2522 push @m, q{
4633a7c4
LW
2523skipcheck :
2524 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&skipcheck";' \\
2525 -e 'skipcheck();'
2526};
2527
2528 push @m, q{
005c1a0e 2529manifest :
8e07c86e 2530 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\
005c1a0e 2531 -e 'mkmanifest();'
8e07c86e
AD
2532};
2533 join "", @m;
2534}
005c1a0e 2535
8e07c86e
AD
2536sub dist_core {
2537 my($self) = shift;
2538 unless (ref $self){
2539 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2540 $self = $ExtUtils::MakeMaker::Parent[-1];
2541 }
2542 my @m;
2543 push @m, q{
005c1a0e
AD
2544dist : $(DIST_DEFAULT)
2545
8e07c86e 2546tardist : $(DISTVNAME).tar.$(SUFFIX)
005c1a0e 2547
8e07c86e 2548$(DISTVNAME).tar.$(SUFFIX) : distdir
005c1a0e 2549 $(PREOP)
8e07c86e
AD
2550 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
2551 $(RM_RF) $(DISTVNAME)
2552 $(COMPRESS) $(DISTVNAME).tar
005c1a0e
AD
2553 $(POSTOP)
2554
8e07c86e
AD
2555uutardist : $(DISTVNAME).tar.$(SUFFIX)
2556 uuencode $(DISTVNAME).tar.$(SUFFIX) \\
2557 $(DISTVNAME).tar.$(SUFFIX) > \\
2558 $(DISTVNAME).tar.$(SUFFIX).uu
005c1a0e
AD
2559
2560shdist : distdir
2561 $(PREOP)
8e07c86e
AD
2562 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
2563 $(RM_RF) $(DISTVNAME)
005c1a0e 2564 $(POSTOP)
005c1a0e
AD
2565};
2566 join "", @m;
a0d0e21e
LW
2567}
2568
8e07c86e
AD
2569sub dist_dir {
2570 my($self) = shift;
2571 unless (ref $self){
2572 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2573 $self = $ExtUtils::MakeMaker::Parent[-1];
2574 }
2575 my @m;
2576 push @m, q{
2577distdir :
2578 $(RM_RF) $(DISTVNAME)
2579 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "/mani/";' \\
2580 -e 'manicopy(maniread(),"$(DISTVNAME)", "$(DIST_CP)");'
2581};
2582 join "", @m;
a0d0e21e
LW
2583}
2584
8e07c86e
AD
2585sub dist_test {
2586 my($self) = shift;
2587 unless (ref $self){
2588 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2589 $self = $ExtUtils::MakeMaker::Parent[-1];
2590 }
2591 my @m;
2592 push @m, q{
2593disttest : distdir
2594 cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
2595 cd $(DISTVNAME) && $(MAKE)
2596 cd $(DISTVNAME) && $(MAKE) test
2597};
2598 join "", @m;
e50aee73
AD
2599}
2600
8e07c86e
AD
2601sub dist_ci {
2602 my($self) = shift;
2603 unless (ref $self){
2604 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2605 $self = $ExtUtils::MakeMaker::Parent[-1];
2606 }
2607 my @m;
2608 push @m, q{
2609ci :
2610 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\
2611 -e '@all = keys %{ maniread() };' \\
2612 -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
2613 -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
2614};
2615 join "", @m;
e50aee73
AD
2616}
2617
a0d0e21e 2618sub install {
3edbfbe5 2619 my($self, %attribs) = @_;
8e07c86e
AD
2620 unless (ref $self){
2621 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2622 $self = $ExtUtils::MakeMaker::Parent[-1];
2623 }
3edbfbe5 2624 my(@m);
40000a8c
AD
2625 push @m, q{
2626doc_install ::
005c1a0e 2627 @ echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
40000a8c 2628 @ $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \\
8e07c86e 2629 -e "use ExtUtils::MakeMaker; MY->new({})->writedoc('Module', '$(NAME)', \\
cb1a09d0 2630 'LINKTYPE=$(LINKTYPE)', 'VERSION=$(VERSION)', \\
005c1a0e 2631 'EXE_FILES=$(EXE_FILES)')" >> $(INSTALLARCHLIB)/perllocal.pod
40000a8c
AD
2632};
2633
3edbfbe5 2634 push(@m, "
40000a8c
AD
2635install :: pure_install doc_install
2636
005c1a0e 2637pure_install ::
3edbfbe5
TB
2638");
2639 # install subdirectories first
8e07c86e
AD
2640 push(@m, map("\tcd $_ && test -f $self->{MAKEFILE} && \$(MAKE) install\n",
2641 @{$self->{DIR}}));
2642
2643 push(@m, "\t\@\$(PERL) \"-I\$(PERL_ARCHLIB)\" \"-I\$(PERL_LIB)\" -e 'require File::Path;' \\
2644 -e '\$\$message = q[ You do not have permissions to install into];' \\
2645 -e 'File::Path::mkpath(\@ARGV);' \\
2646 -e 'foreach (\@ARGV){ die qq{ \$\$message \$\$_\\n} unless -w \$\$_}' \\
2647 \$(INSTALLPRIVLIB) \$(INSTALLARCHLIB)
2648 \$(MAKE) INST_LIB=\$(INSTALLPRIVLIB) INST_ARCHLIB=\$(INSTALLARCHLIB) INST_EXE=\$(INSTALLBIN) INST_MAN1DIR=\$(INSTALLMAN1DIR) INST_MAN3DIR=\$(INSTALLMAN3DIR) all
3edbfbe5 2649");
a0d0e21e 2650
4e68a208
AD
2651# .packlist is not supported in this MakeMaker, because it needs a serious fix. -i.bak
2652# is not allowed in an environment, with afs, we have to read here, write there, and I
2653# don't have time to fix it today -> TODO
2654# The following line was executed with MMs up to 5.10:
2655# \@\$(PERL) -i.bak -lne 'print unless \$\$seen{ \$\$_ }++' \$(PERL_ARCHLIB)/auto/\$(FULLEXT)/.packlist
2656
2657
005c1a0e
AD
2658 push @m, '
2659#### UNINSTALL IS STILL EXPERIMENTAL ####
2660uninstall ::
2661';
2662
8e07c86e
AD
2663 push(@m, map("\tcd $_ && test -f $self->{MAKEFILE} && \$(MAKE) uninstall\n",
2664 @{$self->{DIR}}));
4e68a208 2665 push @m, "\t".'$(RM_RF) `cat $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist`
005c1a0e
AD
2666';
2667
3edbfbe5
TB
2668 join("",@m);
2669}
a0d0e21e 2670
8e07c86e 2671
42793c05 2672sub force {
8e07c86e
AD
2673 my($self) = shift;
2674 unless (ref $self){
2675 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2676 $self = $ExtUtils::MakeMaker::Parent[-1];
2677 }
42793c05
TB
2678 '# Phony target to force checking subdirectories.
2679FORCE:
a0d0e21e
LW
2680';
2681}
2682
2683
2684sub perldepend {
8e07c86e
AD
2685 my($self) = shift;
2686 unless (ref $self){
2687 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2688 $self = $ExtUtils::MakeMaker::Parent[-1];
2689 }
005c1a0e 2690 my(@m);
42793c05
TB
2691 push(@m,'
2692PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
2693 $(PERL_INC)/XSUB.h $(PERL_INC)/av.h $(PERL_INC)/cop.h \
2694 $(PERL_INC)/cv.h $(PERL_INC)/dosish.h $(PERL_INC)/embed.h \
2695 $(PERL_INC)/form.h $(PERL_INC)/gv.h $(PERL_INC)/handy.h \
2696 $(PERL_INC)/hv.h $(PERL_INC)/keywords.h $(PERL_INC)/mg.h \
2697 $(PERL_INC)/op.h $(PERL_INC)/opcode.h $(PERL_INC)/patchlevel.h \
2698 $(PERL_INC)/perl.h $(PERL_INC)/perly.h $(PERL_INC)/pp.h \
2699 $(PERL_INC)/proto.h $(PERL_INC)/regcomp.h $(PERL_INC)/regexp.h \
2700 $(PERL_INC)/scope.h $(PERL_INC)/sv.h $(PERL_INC)/unixish.h \
75f92628 2701 $(PERL_INC)/util.h $(PERL_INC)/config.h
42793c05 2702
42793c05 2703');
e1666bf5 2704
005c1a0e
AD
2705 push @m, '
2706$(OBJECT) : $(PERL_HDRS)
8e07c86e 2707' if $self->{OBJECT};
005c1a0e 2708
42793c05 2709 push(@m,'
75f92628
AD
2710# Check for unpropogated config.sh changes. Should never happen.
2711# We do NOT just update config.h because that is not sufficient.
2712# An out of date config.h is not fatal but complains loudly!
2713$(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2714 -@echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2715
75f92628 2716$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
1aef975c 2717 @echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
232e078e 2718 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
8e07c86e 2719') if $self->{PERL_SRC};
e1666bf5 2720
8e07c86e
AD
2721 push(@m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n")
2722 if %{$self->{XS}};
42793c05
TB
2723 join("\n",@m);
2724}
2725
42793c05 2726sub makefile {
8e07c86e
AD
2727 my($self) = shift;
2728 unless (ref $self){
2729 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2730 $self = $ExtUtils::MakeMaker::Parent[-1];
2731 }
005c1a0e 2732 my @m;
42793c05 2733 # We do not know what target was originally specified so we
75f92628 2734 # must force a manual rerun to be sure. But as it should only
42793c05 2735 # happen very rarely it is not a significant problem.
005c1a0e 2736 push @m, '
4633a7c4 2737$(OBJECT) : $(FIRST_MAKEFILE)
8e07c86e 2738' if $self->{OBJECT};
75f92628 2739
8e07c86e 2740 push @m, '
75f92628
AD
2741# We take a very conservative approach here, but it\'s worth it.
2742# We move Makefile to Makefile.old here to avoid gnu make looping.
8e07c86e 2743'.$self->{MAKEFILE}.' : Makefile.PL $(CONFIGDEP)
75f92628
AD
2744 @echo "Makefile out-of-date with respect to $?"
2745 @echo "Cleaning current config before rebuilding Makefile..."
8e07c86e
AD
2746 -@mv '."$self->{MAKEFILE} $self->{MAKEFILE}.old".'
2747 -$(MAKE) -f '.$self->{MAKEFILE}.'.old clean >/dev/null 2>&1 || true
005c1a0e 2748 $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL '."@ARGV".'
8e07c86e
AD
2749 @echo ">>> Your Makefile has been rebuilt. <<<"
2750 @echo ">>> Please rerun the make command. <<<"; false
a0d0e21e 2751';
005c1a0e
AD
2752
2753 join "", @m;
a0d0e21e
LW
2754}
2755
8e07c86e
AD
2756sub staticmake {
2757 my($self, %attribs) = @_;
2758 unless (ref $self){
2759 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2760 $self = $ExtUtils::MakeMaker::Parent[-1];
2761 }
2762 my(@static);
a0d0e21e 2763
8e07c86e
AD
2764 my(%searchdirs)=($self->{PERL_ARCHLIB} => 1, $self->{INST_ARCHLIB} => 1);
2765 my(@searchdirs)=keys %searchdirs;
232e078e 2766
8e07c86e
AD
2767 # And as it's not yet built, we add the current extension
2768 # but only if it has some C code (or XS code, which implies C code)
2769 if (@{$self->{C}}) {
4633a7c4 2770 @static="$self->{INST_ARCHLIB}/auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}";
232e078e 2771 }
8e07c86e
AD
2772
2773 # Either we determine now, which libraries we will produce in the
2774 # subdirectories or we do it at runtime of the make.
2775
2776 # We could ask all subdir objects, but I cannot imagine, why it
2777 # would be necessary.
2778
2779 # Instead we determine all libraries for the new perl at
2780 # runtime.
2781 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
2782
864a5fa8
AD
2783 $self->makeaperl(MAKE => $self->{MAKEFILE},
2784 DIRS => \@searchdirs,
2785 STAT => \@static,
8e07c86e
AD
2786 INCL => \@perlinc,
2787 TARGET => $self->{MAP_TARGET},
2788 TMP => "",
2789 LIBPERL => $self->{LIBPERL_A}
2790 );
232e078e
AD
2791}
2792
8e07c86e 2793# --- Test and Installation Sections ---
fed7345c 2794
8e07c86e 2795sub test {
fed7345c 2796 my($self, %attribs) = @_;
8e07c86e
AD
2797 unless (ref $self){
2798 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2799 $self = $ExtUtils::MakeMaker::Parent[-1];
2800 }
2801 my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
2802 my(@m);
2803 push(@m,"
2804TEST_VERBOSE=0
2805TEST_TYPE=test_\$(LINKTYPE)
fed7345c 2806
8e07c86e
AD
2807test :: \$(TEST_TYPE)
2808");
2809 push(@m, map("\t\@cd $_ && test -f $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
2810 @{$self->{DIR}}));
2811 push(@m, "\t\@echo 'No tests defined for \$(NAME) extension.'\n")
2812 unless $tests or -f "test.pl" or @{$self->{DIR}};
2813 push(@m, "\n");
2814
2815 push(@m, "test_dynamic :: all\n");
2816 push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
2817 push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
2818 push(@m, "\n");
2819
2820 # Occasionally we may face this degenerated target:
2821 push @m, "test_ : test_dynamic\n\n";
2822
2823 if ($self->needs_linking()) {
2824 push(@m, "test_static :: all \$(MAP_TARGET)\n");
2825 push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
2826 push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
2827 push(@m, "\n");
2828 } else {
2829 push @m, "test_static :: test_dynamic\n";
2830 }
2831 join("", @m);
2832}
2833
2834sub test_via_harness {
2835 my($self, $perl, $tests) = @_;
2836 unless (ref $self){
2837 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2838 $self = $ExtUtils::MakeMaker::Parent[-1];
2839 }
2840 "\tPERL_DL_NONLAZY=1 $perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
2841}
2842
2843sub test_via_script {
2844 my($self, $perl, $script) = @_;
2845 unless (ref $self){
2846 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2847 $self = $ExtUtils::MakeMaker::Parent[-1];
2848 }
2849 "\tPERL_DL_NONLAZY=1 $perl".' -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
2850';
2851}
2852
2853
2854sub postamble {
2855 my($self) = shift;
2856 unless (ref $self){
2857 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2858 $self = $ExtUtils::MakeMaker::Parent[-1];
2859 }
2860 "";
fed7345c
AD
2861}
2862
2863sub makeaperl {
2864 my($self, %attribs) = @_;
8e07c86e
AD
2865 unless (ref $self){
2866 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2867 $self = $ExtUtils::MakeMaker::Parent[-1];
2868 }
864a5fa8 2869 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
8e07c86e 2870 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
fed7345c 2871 my(@m);
8e07c86e
AD
2872 push @m, "
2873# --- MakeMaker makeaperl section ---
2874MAP_TARGET = $target
2875FULLPERL = $self->{FULLPERL}
2876";
2877 return join '', @m if $self->{PARENT};
2878
4633a7c4
LW
2879 my($dir) = join ":", @{$self->{DIR}};
2880
8e07c86e 2881 unless ($self->{MAKEAPERL}) {
4633a7c4
LW
2882 push @m, q{
2883$(MAP_TARGET) :: $(MAKE_APERL_FILE)
2884 $(MAKE) -f Makefile.aperl static $@
2885
2886$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2887 @ echo Writing \"Makefile.aperl\" for this $(MAP_TARGET)
2888 @ $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
2889 Makefile.PL DIR=}, $dir, q{ \
2890 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2891 MAKEAPERL=1 NORECURS=1};
2892
2893 push @m, map( " \\\n\t\t$_", @ARGV );
2894 push @m, "\n";
2895
8e07c86e
AD
2896 return join '', @m;
2897 }
2898
864a5fa8 2899
8e07c86e
AD
2900
2901 my($cccmd, $linkcmd, $lperl);
2902
fed7345c 2903
8e07c86e 2904 $cccmd = $self->const_cccmd($libperl);
fed7345c 2905 $cccmd =~ s/^CCCMD\s*=\s*//;
4633a7c4 2906 $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /;
8e07c86e
AD
2907 $cccmd .= " $Config::Config{cccdlflags}" if ($Config::Config{d_shrplib});
2908 $cccmd =~ s/\n/ /g; # yes I've seen "\n", don't ask me where it came from. A.K.
864a5fa8 2909 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
fed7345c
AD
2910
2911 # The front matter of the linkcommand...
5d94fbed 2912 $linkcmd = join ' ', "\$(CC)",
fed7345c
AD
2913 grep($_, @Config{qw(large split ldflags ccdlflags)});
2914 $linkcmd =~ s/\s+/ /g;
2915
2916 # Which *.a files could we make use of...
40000a8c 2917 local(%static);
fed7345c 2918 File::Find::find(sub {
4e68a208 2919 return unless m/\Q$self->{LIB_EXT}\E$/;
40000a8c 2920 return if m/^libperl/;
8e07c86e
AD
2921 # don't include the installed version of this extension. I
2922 # leave this line here, although it is not necessary anymore:
2923 # I patched minimod.PL instead, so that Miniperl.pm won't
2924 # enclude duplicates
2925
2926 # Once the patch to minimod.PL is in the distribution, I can
2927 # drop it
4633a7c4 2928 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:;
40000a8c 2929 $static{fastcwd() . "/" . $_}++;
fed7345c
AD
2930 }, grep( -d $_, @{$searchdirs || []}) );
2931
40000a8c
AD
2932 # We trust that what has been handed in as argument, will be buildable
2933 $static = [] unless $static;
2934 @static{@{$static}} = (1) x @{$static};
2935
fed7345c
AD
2936 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2937 for (sort keys %static) {
4e68a208 2938 next unless /\Q$self->{LIB_EXT}\E$/;
40000a8c 2939 $_ = dirname($_) . "/extralibs.ld";
5d94fbed 2940 push @$extra, $_;
fed7345c
AD
2941 }
2942
8e07c86e 2943 grep(s/^/-I/, @{$perlinc || []});
fed7345c
AD
2944
2945 $target = "perl" unless $target;
2946 $tmp = "." unless $tmp;
2947
8e07c86e
AD
2948# MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2949# regenerate the Makefiles, MAP_STATIC and the dependencies for
2950# extralibs.all are computed correctly
fed7345c 2951 push @m, "
fed7345c 2952MAP_LINKCMD = $linkcmd
8e07c86e 2953MAP_PERLINC = @{$perlinc || []}
fed7345c 2954MAP_STATIC = ",
4633a7c4 2955join(" \\\n\t", reverse sort keys %static), "
8e07c86e
AD
2956
2957MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
fed7345c 2958";
232e078e 2959
8e07c86e
AD
2960 if (defined $libperl) {
2961 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2962 }
2963 unless ($libperl && -f $lperl) { # Could quite follow your idea her, Ilya
2964 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
4633a7c4 2965 $libperl ||= "libperl$self->{LIB_EXT}";
8e07c86e 2966 $libperl = "$dir/$libperl";
4633a7c4 2967 $lperl ||= "libperl$self->{LIB_EXT}";
8e07c86e
AD
2968 $lperl = "$dir/$lperl";
2969 print STDOUT "Warning: $libperl not found
2970 If you're going to build a static perl binary, make sure perl is installed
2971 otherwise ignore this warning\n"
2972 unless (-f $lperl || defined($self->{PERL_SRC}));
40000a8c 2973 }
fed7345c 2974
40000a8c
AD
2975 push @m, "
2976MAP_LIBPERL = $libperl
fed7345c 2977";
fed7345c 2978
40000a8c 2979 push @m, "
8e07c86e
AD
2980\$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)."
2981 \@ $self->{RM_F} \$\@
5d94fbed
AD
2982 \@ \$(TOUCH) \$\@
2983";
2984
8e07c86e
AD
2985 my $catfile;
2986 foreach $catfile (@$extra){
2987 push @m, "\tcat $catfile >> \$\@\n";
5d94fbed
AD
2988 }
2989
2990 push @m, "
4633a7c4
LW
2991\$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2992 \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
40000a8c
AD
2993 @ echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
2994 @ echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2995 @ echo 'To remove the intermediate files say'
2996 @ echo ' make -f $makefilename map_clean'
2997
4633a7c4 2998$tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
40000a8c 2999";
4633a7c4 3000 push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n";
fed7345c
AD
3001
3002 push @m, qq{
3003$tmp/perlmain.c: $makefilename}, q{
40000a8c 3004 @ echo Writing $@
4633a7c4 3005 @ $(PERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
40000a8c
AD
3006 writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@
3007
3008};
fed7345c 3009
5d94fbed 3010# We write EXTRA outside the perl program to have it eval'd by the shell
40000a8c
AD
3011 push @m, q{
3012doc_inst_perl:
005c1a0e 3013 @ echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
8e07c86e 3014 @ $(FULLPERL) -e 'use ExtUtils::MakeMaker; MY->new->writedoc("Perl binary",' \\
232e078e 3015 -e '"$(MAP_TARGET)", "MAP_STATIC=$(MAP_STATIC)",' \\
005c1a0e 3016 -e '"MAP_EXTRA=@ARGV", "MAP_LIBPERL=$(MAP_LIBPERL)")' \\
8e07c86e 3017 -- `cat $(INST_ARCHAUTODIR)/extralibs.all` >> $(INSTALLARCHLIB)/perllocal.pod
fed7345c
AD
3018};
3019
3020 push @m, qq{
40000a8c
AD
3021inst_perl: pure_inst_perl doc_inst_perl
3022
3023pure_inst_perl: \$(MAP_TARGET)
8e07c86e 3024 $self->{CP} \$(MAP_TARGET) \$(INSTALLBIN)/\$(MAP_TARGET)
fed7345c 3025
e50aee73 3026clean :: map_clean
40000a8c
AD
3027
3028map_clean :
4633a7c4 3029 $self->{RM_F} $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
fed7345c
AD
3030};
3031
3032 join '', @m;
3033}
a0d0e21e 3034
005c1a0e
AD
3035sub extliblist {
3036 my($self,$libs) = @_;
8e07c86e
AD
3037 unless (ref $self){
3038 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3039 $self = $ExtUtils::MakeMaker::Parent[-1];
3040 }
005c1a0e 3041 require ExtUtils::Liblist;
8e07c86e 3042 ExtUtils::Liblist::ext($libs, $ExtUtils::MakeMaker::Verbose);
a0d0e21e
LW
3043}
3044
1aef975c
AD
3045sub mksymlists {
3046 my($self) = shift;
8e07c86e
AD
3047 unless (ref $self){
3048 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3049 $self = $ExtUtils::MakeMaker::Parent[-1];
3050 }
232e078e 3051 my($pkg);
1aef975c
AD
3052
3053 # only AIX requires a symbol list at this point
3054 # (so does VMS, but that's handled by the MM_VMS package)
8e07c86e 3055 return '' unless $Config::Config{osname} eq 'aix';
1aef975c 3056
8e07c86e
AD
3057 $self->init_main(@ARGV) unless defined $self->{BASEEXT};
3058 if (! $self->{DL_FUNCS}) {
40000a8c 3059 my($bootfunc);
8e07c86e
AD
3060 ($bootfunc = $self->{NAME}) =~ s/\W/_/g;
3061 $self->{DL_FUNCS} = {$self->{BASEEXT} => ["boot_$bootfunc"]};
1aef975c 3062 }
8e07c86e 3063 rename "$self->{BASEEXT}.exp", "$self->{BASEEXT}.exp_old";
1aef975c 3064
8e07c86e
AD
3065 open(EXP,">$self->{BASEEXT}.exp") or die $!;
3066 print EXP join("\n",@{$self->{DL_VARS}}, "\n") if $self->{DL_VARS};
3067 foreach $pkg (keys %{$self->{DL_FUNCS}}) {
1aef975c 3068 (my($prefix) = $pkg) =~ s/\W/_/g;
232e078e 3069 my $func;
8e07c86e 3070 foreach $func (@{$self->{DL_FUNCS}->{$pkg}}) {
1aef975c
AD
3071 $func = "XS_${prefix}_$func" unless $func =~ /^boot_/;
3072 print EXP "$func\n";
3073 }
3074 }
3075 close EXP;
3076}
42793c05 3077
8e07c86e
AD
3078# --- Make-Directories section (internal method) ---
3079# dir_target(@array) returns a Makefile entry for the file .exists in each
3080# named directory. Returns nothing, if the entry has already been processed.
3081# We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
864a5fa8
AD
3082# Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
3083# prerequisite, because there has to be one, something that doesn't change
8e07c86e
AD
3084# too often :)
3085
3086sub dir_target {
3087 my($self,@dirs) = @_;
3088 unless (ref $self){
3089 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3090 $self = $ExtUtils::MakeMaker::Parent[-1];
3091 }
3092 my(@m,$dir);
3093 foreach $dir (@dirs) {
3094 next if $self->{DIR_TARGET}{$self}{$dir}++;
3095 push @m, "
3096$dir/.exists :: \$(PERL)
3097 \@ \$(MKPATH) $dir
3098 \@ \$(TOUCH) $dir/.exists
3099 \@-\$(CHMOD) 755 $dir
3100";
3101 }
3102 join "", @m;
3103}
3104
42793c05 3105# --- Output postprocessing section ---
8e07c86e 3106# nicetext is included to make VMS support easier
42793c05
TB
3107sub nicetext { # Just return the input - no action needed
3108 my($self,$text) = @_;
8e07c86e
AD
3109 unless (ref $self){
3110 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3111 $self = $ExtUtils::MakeMaker::Parent[-1];
3112 }
42793c05
TB
3113 $text;
3114}
fed7345c 3115
8e07c86e
AD
3116sub needs_linking { # Does this module need linking? Looks into
3117 # subdirectory objects (see also has_link_code()
3118 my($self) = shift;
3119 my($child,$caller);
3120 $caller = (caller(0))[3];
3121 unless (ref $self){
3122 ExtUtils::MakeMaker::TieAtt::warndirectuse($caller);
3123 $self = $ExtUtils::MakeMaker::Parent[-1];
3124 }
3125 Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/;
3126 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
3127# print "DEBUG:\n";
3128# print Carp::longmess();
3129# print "EO_DEBUG\n";
4633a7c4 3130 if ($self->has_link_code or $self->{MAKEAPERL}){
8e07c86e
AD
3131 $self->{NEEDS_LINKING} = 1;
3132 return 1;
3133 }
3134 foreach $child (keys %{$self->{CHILDREN}}) {
3135 if ($self->{CHILDREN}->{$child}->needs_linking) {
3136 $self->{NEEDS_LINKING} = 1;
3137 return 1;
3138 }
3139 }
3140 return $self->{NEEDS_LINKING} = 0;
3141}
3142
3143sub has_link_code {
3144 my($self) = shift;
3145 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
4633a7c4 3146 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
8e07c86e
AD
3147 $self->{HAS_LINK_CODE} = 1;
3148 return 1;
3149 }
3150 return $self->{HAS_LINK_CODE} = 0;
3151}
3152
3153# --- perllocal.pod section ---
3154sub writedoc {
3155 my($self,$what,$name,@attribs)=@_;
3156 unless (ref $self){
3157 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3158 $self = $ExtUtils::MakeMaker::Parent[-1];
3159 }
3160 my($time);
3161 require "ctime.pl";
3162 chop($time = ctime(time));
3163 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3164 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3165 print "\n\n=back\n\n";
3166}
3167
3168sub catdir { shift; join('/',@_); }
3169sub catfile { shift; join('/',@_); }
3170
3171package ExtUtils::MM_OS2;
3172
3173#use Config;
3174#use Cwd;
3175#use File::Basename;
3176require Exporter;
3177
3178Exporter::import('ExtUtils::MakeMaker',
3179 qw( $Verbose));
3180
3181sub dlsyms {
3182 my($self,%attribs) = @_;
3183
3184 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
3185 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
3186 my(@m);
3187 (my $boot = $self->{NAME}) =~ s/:/_/g;
3188
3189 if (not $self->{SKIPHASH}{'dynamic'}) {
3190 push(@m,"
864a5fa8 3191$self->{BASEEXT}.def: Makefile.PL"
8e07c86e
AD
3192 . '
3193 echo "LIBRARY ' . "'$self->{DLBASE}'" . ' INITINSTANCE TERMINSTANCE" > $@ ; \\
3194 echo "CODE LOADONCALL" >> $@ ; \\
3195 echo "DATA LOADONCALL NONSHARED MULTIPLE" >> $@ ; \\
3196 echo "EXPORTS" >> $@ ; \\
3197 echo " ' . "boot_$boot" . '" >> $@');
3198 foreach $sym (keys %$funcs, @$vars) {
3199 push(@m, " ; \\
3200 echo \" $sym\" >> \$@");
3201 }
3202 push(@m,"\n");
3203 }
3204
3205 join('',@m);
40000a8c
AD
3206}
3207
8e07c86e
AD
3208sub replace_manpage_seperator {
3209 my($self,$man) = @_;
3210 $man =~ s,/+,.,g;
3211 $man;
3212}
005c1a0e 3213
4633a7c4
LW
3214sub maybe_command {
3215 my($self,$file) = @_;
4e68a208
AD
3216 return $file if -x $file && ! -d _;
3217 return "$file.exe" if -x "$file.exe" && ! -d _;
3218 return "$file.cmd" if -x "$file.cmd" && ! -d _;
4633a7c4
LW
3219 return;
3220}
3221
4e68a208
AD
3222sub file_name_is_absolute {
3223 my($self,$file) = @_;
3224 $file =~ m{^([a-z]:)?[\\/]}i ;
3225}
3226
3227
005c1a0e
AD
3228# the following keeps AutoSplit happy
3229package ExtUtils::MakeMaker;
32301;
3231
3232__END__
3233
3234=head1 NAME
3235
3236ExtUtils::MakeMaker - create an extension Makefile
3237
3238=head1 SYNOPSIS
3239
3240C<use ExtUtils::MakeMaker;>
3241
3242C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
3243
8e07c86e
AD
3244which is really
3245
3246C<MM-E<gt>new(\%att)-E<gt>flush;>
3247
005c1a0e
AD
3248=head1 DESCRIPTION
3249
3250This utility is designed to write a Makefile for an extension module
3251from a Makefile.PL. It is based on the Makefile.SH model provided by
3252Andy Dougherty and the perl5-porters.
3253
3254It splits the task of generating the Makefile into several subroutines
3255that can be individually overridden. Each subroutine returns the text
3256it wishes to have written to the Makefile.
3257
4633a7c4
LW
3258=head2 Hintsfile support
3259
005c1a0e 3260MakeMaker.pm uses the architecture specific information from
8e07c86e
AD
3261Config.pm. In addition it evaluates architecture specific hints files
3262in a C<hints/> directory. The hints files are expected to be named
3263like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file
3264name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by
3265MakeMaker within the WriteMakefile() subroutine, and can be used to
3266execute commands as well as to include special variables. The rules
3267which hintsfile is chosen are the same as in Configure.
3268
4633a7c4
LW
3269The hintsfile is eval()ed immediately after the arguments given to
3270WriteMakefile are stuffed into a hash reference $self but before this
3271reference becomes blessed. So if you want to do the equivalent to
3272override or create an attribute you would say something like
3273
3274 $self->{LIBS} = ['-ldbm -lucb -lc'];
3275
8e07c86e
AD
3276=head2 What's new in version 5 of MakeMaker
3277
3278MakeMaker 5 is pure object oriented. This allows us to write an
3279unlimited number of Makefiles with a single perl process. 'perl
3280Makefile.PL' with MakeMaker 5 goes through all subdirectories
3281immediately and evaluates any Makefile.PL found in the next level
3282subdirectories. The benefit of this approach comes in useful for both
3283single and multi directories extensions.
3284
3285Multi directory extensions have an immediately visible speed
3286advantage, because there's no startup penalty for any single
3287subdirectory Makefile.
3288
3289Single directory packages benefit from the much improved
3290needs_linking() method. As the main Makefile knows everything about
3291the subdirectories, a needs_linking() method can now query all
3292subdirectories if there is any linking involved down in the tree. The
3293speedup for PM-only Makefiles seems to be around 1 second on my
3294Indy 100 MHz.
3295
3296=head2 Incompatibilities between MakeMaker 5.00 and 4.23
3297
3298There are no incompatibilities in the short term, as all changes are
3299accompanied by short-term workarounds that guarantee full backwards
3300compatibility.
3301
4633a7c4 3302You are likely to face a few warnings that expose deprecations which
8e07c86e
AD
3303will result in incompatibilities in the long run:
3304
3305You should not use %att directly anymore. Instead any subroutine you
3306override in the MY package will be called by the object method, so you
3307can access all object attributes directly via the object in $_[0].
3308
3309You should not call the class methos MM->something anymore. Instead
3310you should call the superclass. Something like
3311
3312 sub MY::constants {
3313 my $self = shift;
8e07c86e
AD
3314 $self->MM::constants();
3315 }
3316
3317Especially the libscan() and exescan() methods should be altered
3318towards OO programming, that means do not expect that $_ to contain
3319the path but rather $_[1].
3320
3321You should program with more care. Watch out for any MakeMaker
3322variables. Do not try to alter them, somebody else might depend on
3323them. E.g. do not overwrite the ExtUtils::MakeMaker::VERSION variable
3324(this happens if you import it and then set it to the version number
3325of your package), do not expect that the INST_LIB variable will be
3326./blib (do not 'unshift @INC, "./blib" and do not use
3327"blib/FindBin.pm"). Do not croak in your Makefile.PL, let it fail with
3328a warning instead.
3329
3330Try to build several extensions simultanously to debug your
3331Makefile.PL. You can unpack a bunch of distributed packages, so your
3332directory looks like
3333
3334 Alias-1.00/ Net-FTP-1.01a/ Set-Scalar-0.001/
3335 ExtUtils-Peek-0.4/ Net-Ping-1.00/ SetDualVar-1.0/
3336 Filter-1.06/ NetTools-1.01a/ Storable-0.1/
3337 GD-1.00/ Religion-1.04/ Sys-Domain-1.05/
3338 MailTools-1.03/ SNMP-1.5b/ Term-ReadLine-0.7/
3339
3340and write a dummy Makefile.PL that contains nothing but
3341
3342 use ExtUtils::MakeMaker;
3343 WriteMakefile();
3344
3345That's actually fun to watch :)
3346
3347Final suggestion: Try to delete all of your MY:: subroutines and
3348watch, if you really still need them. MakeMaker might already do what
3349you want without them. That's all about it.
3350
005c1a0e
AD
3351
3352=head2 Default Makefile Behaviour
3353
3354The automatically generated Makefile enables the user of the extension
3355to invoke
3356
3357 perl Makefile.PL # optionally "perl Makefile.PL verbose"
3358 make
8e07c86e
AD
3359 make test # optionally set TEST_VERBOSE=1
3360 make install # See below
005c1a0e
AD
3361
3362The Makefile to be produced may be altered by adding arguments of the
3363form C<KEY=VALUE>. If the user wants to work with a different perl
8e07c86e 3364than the default, this can be achieved with
005c1a0e
AD
3365
3366 perl Makefile.PL PERL=/tmp/myperl5
3367
3368Other interesting targets in the generated Makefile are
3369
3370 make config # to check if the Makefile is up-to-date
8e07c86e
AD
3371 make clean # delete local temp files (Makefile gets renamed)
3372 make realclean # delete derived files (including ./blib)
005c1a0e
AD
3373 make dist # see below the Distribution Support section
3374
8e07c86e 3375=head2 Special case make install
005c1a0e 3376
8e07c86e
AD
3377make alone puts all relevant files into directories that are named by
3378the macros INST_LIB, INST_ARCHLIB, INST_EXE, INST_MAN1DIR, and
3379INST_MAN3DIR. All these default to ./blib or something below blib if
3380you are I<not> building below the perl source directory. If you I<are>
3381building below the perl source, INST_LIB and INST_ARCHLIB default to
4633a7c4 3382 ../../lib, and INST_EXE is not defined.
005c1a0e
AD
3383
3384The I<install> target of the generated Makefile is a recursive call to
3385make which sets
3386
3387 INST_LIB to INSTALLPRIVLIB
3388 INST_ARCHLIB to INSTALLARCHLIB
864a5fa8 3389 INST_EXE to INSTALLBIN
8e07c86e
AD
3390 INST_MAN1DIR to INSTALLMAN1DIR
3391 INST_MAN3DIR to INSTALLMAN3DIR
005c1a0e 3392
8e07c86e
AD
3393The INSTALL... macros in turn default to their %Config
3394($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts.
005c1a0e
AD
3395
3396The recommended way to proceed is to set only the INSTALL* macros, not
3397the INST_* targets. In doing so, you give room to the compilation
8e07c86e
AD
3398process without affecting important directories. Usually a make
3399test will succeed after the make, and a make install can finish
3400the game.
005c1a0e
AD
3401
3402MakeMaker gives you much more freedom than needed to configure
3403internal variables and get different results. It is worth to mention,
3404that make(1) also lets you configure most of the variables that are
3405used in the Makefile. But in the majority of situations this will not
3406be necessary, and should only be done, if the author of a package
3407recommends it.
3408
3409The usual relationship between INSTALLPRIVLIB and INSTALLARCHLIB is
3410that the latter is a subdirectory of the former with the name
8e07c86e 3411C<$Config{archname}>, MakeMaker supports the user who sets
005c1a0e
AD
3412INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then
3413MakeMaker defaults the latter to be INSTALLPRIVLIB/ARCHNAME if that
3414directory exists, otherwise it defaults to INSTALLPRIVLIB.
3415
005c1a0e 3416
8e07c86e 3417=head2 PREFIX attribute
005c1a0e 3418
864a5fa8
AD
3419The PREFIX attribute can be used to set the INSTALL* attributes
3420(except INSTALLMAN1DIR) in one go. The quickest way to install a
3421module in a non-standard place
005c1a0e 3422
8e07c86e 3423 perl Makefile.PL PREFIX=~
005c1a0e 3424
864a5fa8 3425is identical to
005c1a0e 3426
8e07c86e 3427 perl Makefile.PL INSTALLPRIVLIB=~/perl5/lib INSTALLBIN=~/bin \
864a5fa8 3428 INSTALLMAN3DIR=~/perl5/man/man3
005c1a0e
AD
3429
3430Note, that the tilde expansion is done by MakeMaker, not by perl by
8e07c86e 3431default, nor by make.
005c1a0e
AD
3432
3433It is important to know, that the INSTALL* macros should be absolute
3434paths, never relativ ones. Packages with multiple Makefile.PLs in
3435different directories get the contents of the INSTALL* macros
3436propagated verbatim. (The INST_* macros will be corrected, if they are
3437relativ paths, but not the INSTALL* macros.)
3438
3439If the user has superuser privileges, and is not working on AFS
3440(Andrew File System) or relatives, then the defaults for
8e07c86e 3441INSTALLPRIVLIB, INSTALLARCHLIB, INSTALLBIN, etc. will be appropriate,
005c1a0e
AD
3442and this incantation will be the best:
3443
3444 perl Makefile.PL; make; make test
3445 make install
3446
8e07c86e
AD