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