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