Re: Debugger in beta3
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Unix.pm
CommitLineData
1e44e2bf 1package ExtUtils::MM_Unix;
2
3use Config;
4use File::Basename;
5use Cwd;
6use DirHandle;
7require File::Find;
8require Exporter;
9require ExtUtils::MakeMaker; # for $Is_OS2 and FileHandle
10require ExtUtils::Liblist;
11require File::Find;
12
13Exporter::import('ExtUtils::MakeMaker',
14 qw( $Verbose &neatvalue));
15
16if ($Is_VMS = $Config::Config{osname} eq 'VMS') {
17 require VMS::Filespec;
18 import VMS::Filespec qw( &vmsify );
19}
20
21$Is_OS2 = $ExtUtils::MakeMaker::Is_OS2;
22
23=head1 NAME
24
25ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
26
27=head1 SYNOPSIS
28
29C<require ExtUtils::MM_Unix;>
30
31=head1 DESCRIPTION
32
33The methods provided by this package are designed to be used in
34conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
35Makefile, it creates one or more objects that inherit their methods
36from a package C<MM>. MM itself doesn't provide any methods, but it
37ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
38specific packages take the responsibility for all the methods provided
39by MM_Unix. We are trying to reduce the number of the necessary
40overrides by defining rather primitive operations within
41ExtUtils::MM_Unix.
42
43If you are going to write a platform specific MM package, please try
44to limit the necessary overrides to primitiv methods, and if it is not
45possible to do so, let's work it out how to achieve that gain.
46
47=head1 METHODS
48
49The following description of methods is still under
50development. Please refer to the code for not suitably documented
51sections and complain loudly to the makemaker mailing list.
52
53=head2 Preloaded methods
54
55=over 2
56
57=item catdir
58
59Concatenate two or more directory names to form a complete path ending
60with a directory
61
62=cut
63
64# ';
65
66sub catdir {
67 shift;
68 my $result = join('/',@_,'/');
69 $result =~ s:/\./:/:g;
70 $result =~ s:/+:/:g;
71 $result;
72}
73
74=item catfile
75
76Concatenate two or more directory names and a filename to form a
77complete path ending with a filename
78
79=cut
80
81sub catfile {
82 shift;
83 my $result = join('/',@_);
84 $result =~ s:/\./:/:g;
85 $result =~ s:/+:/:g;
86 $result;
87}
88
89=item nicetext
90
91misnamed method (will have to be changed). The MM_Unix method just
92returns the argument without further processing.
93
94On VMS used to insure that colons marking targets are preceded by
95space - most Unix Makes don't need this, but it's necessary under VMS
96to distinguish the target delimiter from a colon appearing as part of
97a filespec.
98
99=cut
100
101sub nicetext {
102 my($self,$text) = @_;
103 unless (ref $self){
104 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
105 $self = $ExtUtils::MakeMaker::Parent[-1];
106 }
107 $text;
108}
109
110=item libscan
111
112Takes a path to a file that is found by init_dirscan and returns false
113if we don't want to include this file in the library. Mainly used to
114exclude RCS, CVS, and SCCS directories from installation.
115
116=cut
117
118# ';
119
120sub libscan {
121 my($self,$path) = @_;
122 return '' if $path =~ m:/(RCS|CVS|SCCS)/: ;
123 $path;
124}
125
126=item exescan
127
128Deprecated method. Use libscan instead.
129
130=cut
131
132sub exescan {
133 my($self,$path) = @_;
134 $path;
135}
136
137=item lsdir
138
139Takes as arguments a directory name and a regular expression. Returns
140all entries in the directory that match the regular expression.
141
142=cut
143
144sub lsdir {
145 my($self) = shift;
146 my($dir, $regex) = @_;
147 my(@ls);
148 my $dh = new DirHandle;
149 $dh->open($dir || ".") or return ();
150 @ls = $dh->read;
151 $dh->close;
152 @ls = grep(/$regex/, @ls) if $regex;
153 @ls;
154}
155
156=item path
157
158Takes no argument, returns the environment variable PATH as an array.
159
160=cut
161
162sub path {
163 my($self) = @_;
164 my $path_sep = $Is_OS2 ? ";" : $Is_VMS ? "/" : ":";
165 my $path = $ENV{PATH};
166 $path =~ s:\\:/:g if $Is_OS2;
167 my @path = split $path_sep, $path;
168}
169
170=item replace_manpage_separator
171
172Takes the name of a package, which may be a nested package, in the
173form Foo/Bar and replaces the slash with C<::>. Returns the replacement.
174
175=cut
176
177sub replace_manpage_separator {
178 my($self,$man) = @_;
179 $man =~ s,/+,::,g;
180 $man;
181}
182
183=item file_name_is_absolute
184
185Takes as argument a path and returns true, it it is an absolute path.
186
187=cut
188
189sub file_name_is_absolute {
190 my($self,$file) = @_;
191 $file =~ m:^/: ;
192}
193
194=item prefixify
195
196Check a path variable in $self from %Config, if it contains a prefix,
197and replace it with another one.
198
199Takes as arguments an attribute name, a search prefix and a
200replacement prefix. Changes the attribute in the object.
201
202=cut
203
204sub prefixify {
205 my($self,$var,$sprefix,$rprefix) = @_;
206 $self->{uc $var} ||= $Config{lc $var};
207 $self->{uc $var} = VMS::Filespec::unixpath($self->{uc $var}) if $Is_VMS;
208 $self->{uc $var} =~ s/\Q$sprefix\E/$rprefix/;
209}
210
211=item maybe_command_in_dirs
212
213method under development. Not yet used. Ask Ilya :-)
214
215=cut
216
217sub maybe_command_in_dirs { # $ver is optional argument if looking for perl
218# Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here
219 my($self, $names, $dirs, $trace, $ver) = @_;
220 my($name, $dir);
221 foreach $dir (@$dirs){
222 next unless defined $dir; # $self->{PERL_SRC} may be undefined
223 foreach $name (@$names){
224 my($abs,$tryabs);
225 if ($self->file_name_is_absolute($name)) {
226 $abs = $name;
227 } elsif ($name =~ m|/|) {
228 $abs = $self->catfile(".", $name); # not absolute
229 } else {
230 $abs = $self->catfile($dir, $name);
231 }
232 print "Checking $abs for $name\n" if ($trace >= 2);
233 next unless $tryabs = $self->maybe_command($abs);
234 print "Substituting $tryabs instead of $abs\n"
235 if ($trace >= 2 and $tryabs ne $abs);
236 $abs = $tryabs;
237 if (defined $ver) {
238 print "Executing $abs\n" if ($trace >= 2);
239 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
240 print "Using PERL=$abs\n" if $trace;
241 return $abs;
242 }
243 } else { # Do not look for perl
244 return $abs;
245 }
246 }
247 }
248}
249
250=item maybe_command
251
252Returns true, if the argument is likely to be a command.
253
254=cut
255
256sub maybe_command {
257 my($self,$file) = @_;
258 return $file if -x $file && ! -d $file;
259 return;
260}
261
262=item perl_script
263
264Returns true, if we the argument is likely to be a perl script. On
265MM_Unix this is true for any ordinary, readable file.
266
267=cut
268
269sub perl_script {
270 my($self,$file) = @_;
271 return 1 if -r $file && ! -d $file;
272 return;
273}
274
275# use SelfLoader;
276# sub ExtUtils::MM_Unix::guess_name ;
277# sub ExtUtils::MM_Unix::init_main ;
278# sub ExtUtils::MM_Unix::init_dirscan ;
279# sub ExtUtils::MM_Unix::init_others ;
280# sub ExtUtils::MM_Unix::find_perl ;
281# sub ExtUtils::MM_Unix::post_initialize ;
282# sub ExtUtils::MM_Unix::const_config ;
283# sub ExtUtils::MM_Unix::constants ;
284# sub ExtUtils::MM_Unix::const_loadlibs ;
285# sub ExtUtils::MM_Unix::const_cccmd ;
286# sub ExtUtils::MM_Unix::tool_autosplit ;
287# sub ExtUtils::MM_Unix::tool_xsubpp ;
288# sub ExtUtils::MM_Unix::xsubpp_version ;
289# sub ExtUtils::MM_Unix::tools_other ;
290# sub ExtUtils::MM_Unix::dist ;
291# sub ExtUtils::MM_Unix::macro ;
292# sub ExtUtils::MM_Unix::depend ;
293# sub ExtUtils::MM_Unix::post_constants ;
294# sub ExtUtils::MM_Unix::pasthru ;
295# sub ExtUtils::MM_Unix::c_o ;
296# sub ExtUtils::MM_Unix::xs_c ;
297# sub ExtUtils::MM_Unix::xs_o ;
298# sub ExtUtils::MM_Unix::top_targets ;
299# sub ExtUtils::MM_Unix::linkext ;
300# sub ExtUtils::MM_Unix::dlsyms ;
301# sub ExtUtils::MM_Unix::dynamic ;
302# sub ExtUtils::MM_Unix::dynamic_bs ;
303# sub ExtUtils::MM_Unix::dynamic_lib ;
304# sub ExtUtils::MM_Unix::static ;
305# sub ExtUtils::MM_Unix::static_lib ;
306# sub ExtUtils::MM_Unix::installpm ;
307# sub ExtUtils::MM_Unix::installpm_x ;
308# sub ExtUtils::MM_Unix::manifypods ;
309# sub ExtUtils::MM_Unix::processPL ;
310# sub ExtUtils::MM_Unix::installbin ;
311# sub ExtUtils::MM_Unix::subdirs ;
312# sub ExtUtils::MM_Unix::subdir_x ;
313# sub ExtUtils::MM_Unix::clean ;
314# sub ExtUtils::MM_Unix::realclean ;
315# sub ExtUtils::MM_Unix::dist_basics ;
316# sub ExtUtils::MM_Unix::dist_core ;
317# sub ExtUtils::MM_Unix::dist_dir ;
318# sub ExtUtils::MM_Unix::dist_test ;
319# sub ExtUtils::MM_Unix::dist_ci ;
320# sub ExtUtils::MM_Unix::install ;
321# sub ExtUtils::MM_Unix::force ;
322# sub ExtUtils::MM_Unix::perldepend ;
323# sub ExtUtils::MM_Unix::makefile ;
324# sub ExtUtils::MM_Unix::staticmake ;
325# sub ExtUtils::MM_Unix::test ;
326# sub ExtUtils::MM_Unix::test_via_harness ;
327# sub ExtUtils::MM_Unix::test_via_script ;
328# sub ExtUtils::MM_Unix::postamble ;
329# sub ExtUtils::MM_Unix::makeaperl ;
330# sub ExtUtils::MM_Unix::extliblist ;
331# sub ExtUtils::MM_Unix::dir_target ;
332# sub ExtUtils::MM_Unix::needs_linking ;
333# sub ExtUtils::MM_Unix::has_link_code ;
334# sub ExtUtils::MM_Unix::writedoc ;
335#
336# 1;
337#
338# __DATA__
339
340# Without SelfLoader we need
3411;
342
343=head2 SelfLoaded methods
344
345=item guess_name
346
347Guess the name of this package by examining the working directory's
348name. MakeMaker calls this only if the developer has not supplied a
349NAME attribute.
350
351=cut
352
353# ';
354
355sub guess_name {
356 my($self) = @_;
357 my $name = fastcwd();
358 $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
359 $name =~ s#/#::#g;
360 $name =~ s#[\-_][\d.\-]+$##; # this is new with MM 5.00
361 $name;
362}
363
364=item init_main
365
366
367
368=cut
369
370sub init_main {
371 my($self) = @_;
372 unless (ref $self){
373 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
374 $self = $ExtUtils::MakeMaker::Parent[-1];
375 }
376
377 # --- Initialize Module Name and Paths
378
379 # NAME = The perl module name for this extension (eg DBD::Oracle).
380 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
381 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
382 # ROOTEXT = Directory part of FULLEXT with leading /.
383 ($self->{FULLEXT} =
384 $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
385
386 # Copied from DynaLoader:
387
388 my(@modparts) = split(/::/,$self->{NAME});
389 my($modfname) = $modparts[-1];
390
391 # Some systems have restrictions on files names for DLL's etc.
392 # mod2fname returns appropriate file base name (typically truncated)
393 # It may also edit @modparts if required.
394 if (defined &DynaLoader::mod2fname) {
395 $modfname = &DynaLoader::mod2fname(\@modparts);
396 } elsif ($Is_OS2) { # Need manual correction if run with miniperl:-(
397 $modfname = substr($modfname, 0, 7) . '_';
398 }
399
400
401 ($self->{BASEEXT} =
402 $self->{NAME}) =~ s!.*::!! ; #eg. Socket
403
404 if (defined &DynaLoader::mod2fname or $Is_OS2) {
405 # As of 5.001m, dl_os2 appends '_'
406 $self->{DLBASE} = $modfname; #eg. Socket_
407 } else {
408 $self->{DLBASE} = '$(BASEEXT)';
409 }
410
411 ($self->{ROOTEXT} =
412 $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ; #eg. /BSD/Foo
413
414 $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};
415
416
417 # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
418
419 # *Real* information: where did we get these two from? ...
420 my $inc_config_dir = dirname($INC{'Config.pm'});
421 my $inc_carp_dir = dirname($INC{'Carp.pm'});
422
423 unless ($self->{PERL_SRC}){
424 my($dir);
425 foreach $dir (qw(.. ../.. ../../..)){
426 if ( -f "$dir/config.sh"
427 && -f "$dir/perl.h"
428 && -f "$dir/lib/Exporter.pm") {
429 $self->{PERL_SRC}=$dir ;
430 last;
431 }
432 }
433 }
434 if ($self->{PERL_SRC}){
435 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
436 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
437 $self->{PERL_INC} = $self->{PERL_SRC};
438 # catch a situation that has occurred a few times in the past:
439 warn <<EOM unless -s "$self->{PERL_SRC}/cflags";
440You cannot build extensions below the perl source tree after executing
441a 'make clean' in the perl source tree.
442
443To rebuild extensions distributed with the perl source you should
444simply Configure (to include those extensions) and then build perl as
445normal. After installing perl the source tree can be deleted. It is
446not needed for building extensions by running 'perl Makefile.PL'
447usually without extra arguments.
448
449It is recommended that you unpack and build additional extensions away
450from the perl source tree.
451EOM
452 } else {
453 # we should also consider $ENV{PERL5LIB} here
454 $self->{PERL_LIB} ||= $Config::Config{privlibexp};
455 $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};
456 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
457 my $perl_h;
458 die <<EOM unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h")));
459Error: Unable to locate installed Perl libraries or Perl source code.
460
461It is recommended that you install perl in a standard location before
462building extensions. You can say:
463
464 $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory
465
466if you have not yet installed perl but still want to build this
467extension now.
468(You get this message, because MakeMaker could not find "$perl_h")
469EOM
470
471# print STDOUT "Using header files found in $self->{PERL_INC}\n"
472# if $Verbose && $self->needs_linking();
473
474 }
475
476 # We get SITELIBEXP and SITEARCHEXP directly via
477 # Get_from_Config. When we are running standard modules, these
478 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
479 # set it to "site". I prefer that INSTALLDIRS be set from outside
480 # MakeMaker.
481 $self->{INSTALLDIRS} ||= "site";
482
483 # INST_LIB typically pre-set if building an extension after
484 # perl has been built and installed. Setting INST_LIB allows
485 # you to build directly into, say $Config::Config{privlibexp}.
486 unless ($self->{INST_LIB}){
487
488
489 ##### XXXXX We have to change this nonsense
490
491 if (defined $self->{PERL_SRC} and $self->{INSTALLDIRS} eq "perl") {
492 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
493 } else {
494 $self->{INST_LIB} = $self->catdir(".","blib","lib");
495 }
496 }
497 $self->{INST_ARCHLIB} ||= $self->catdir(".","blib","arch");
498 $self->{INST_EXE} ||= $self->catdir('.','blib','bin');
499
500 # The user who requests an installation directory explicitly
501 # should not have to tell us a architecture installation directory
502 # as well We look if a directory exists that is named after the
503 # architecture. If not we take it as a sign that it should be the
504 # same as the requested installation directory. Otherwise we take
505 # the found one.
506 # We do the same thing twice: for privlib/archlib and for sitelib/sitearch
507 my($libpair);
508 for $libpair ({l=>"privlib", a=>"archlib"}, {l=>"sitelib", a=>"sitearch"}) {
509 my $lib = "install$libpair->{l}";
510 my $Lib = uc $lib;
511 my $Arch = uc "install$libpair->{a}";
512 if( $self->{$Lib} && ! $self->{$Arch} ){
513 my($ilib) = $Config{$lib};
514 $ilib = VMS::Filespec::unixify($ilib) if $Is_VMS;
515
516 $self->prefixify($Arch,$ilib,$self->{$Lib});
517
518 unless (-d $self->{$Arch}) {
519 print STDOUT "Directory $self->{$Arch} not found, thusly\n" if $Verbose;
520 $self->{$Arch} = $self->{$Lib};
521 }
522 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
523 }
524 }
525
526 # we have to look at the relation between $Config{prefix} and the
527 # requested values. We're going to set the $Config{prefix} part of
528 # all the installation path variables to literally $(PREFIX), so
529 # the user can still say make PREFIX=foo
530 my($prefix) = $Config{'prefix'};
531 $prefix = VMS::Filespec::unixify($prefix) if $Is_VMS;
532 unless ($self->{PREFIX}){
533 $self->{PREFIX} = $prefix;
534 }
535 my($install_variable);
536 for $install_variable (qw/INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN INSTALLMAN1DIR
537 INSTALLMAN3DIR INSTALLSITELIB INSTALLSITEARCH/) {
538 $self->prefixify($install_variable,$prefix,q[$(PREFIX)]);
539 }
540
541
542 # Now we head at the manpages. Maybe they DO NOT want manpages
543 # installed
544 $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir}
545 unless defined $self->{INSTALLMAN1DIR};
546 unless (defined $self->{INST_MAN1DIR}){
547 if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){
548 $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR};
549 } else {
550 $self->{INST_MAN1DIR} = $self->catdir('.','blib','man1');
551 }
552 }
553 $self->{MAN1EXT} ||= $Config::Config{man1ext};
554
555 $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir}
556 unless defined $self->{INSTALLMAN3DIR};
557 unless (defined $self->{INST_MAN3DIR}){
558 if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){
559 $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR};
560 } else {
561 $self->{INST_MAN3DIR} = $self->catdir('.','blib','man3');
562 }
563 }
564 $self->{MAN3EXT} ||= $Config::Config{man3ext};
565
566
567 # Get some stuff out of %Config if we haven't yet done so
568 print STDOUT "CONFIG must be an array ref\n"
569 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
570 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
571 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
572 push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags};
573 my(%once_only,$m);
574 foreach $m (@{$self->{CONFIG}}){
575 next if $once_only{$m};
576 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
577 unless exists $Config::Config{$m};
578 $self->{uc $m} ||= $Config::Config{$m};
579 $once_only{$m} = 1;
580 }
581
582# This is too dangerous:
583# if ($Config{osname} eq "next") {
584# $self->{AR} = "libtool";
585# $self->{AR_STATIC_ARGS} = "-o";
586# }
587# But I leave it as a placeholder
588
589 $self->{AR_STATIC_ARGS} ||= "cr";
590
591 # These should never be needed
592 $self->{LD} ||= 'ld';
593 $self->{OBJ_EXT} ||= '.o';
594 $self->{LIB_EXT} ||= '.a';
595
596 $self->{MAP_TARGET} ||= "perl";
597
598 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
599
600 # make a simple check if we find Exporter
601 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
602 (Exporter.pm not found)"
603 unless (-f $self->catfile("$self->{PERL_LIB}","Exporter.pm"));
604
605 # Determine VERSION and VERSION_FROM
606 ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME};
607 if ($self->{VERSION_FROM}){
608 my $fh = new FileHandle;
609 $fh->open($self->{VERSION_FROM}) or die "Could not open '$self->{VERSION_FROM}' (attribute VERSION_FROM): $!";
610 while (<$fh>) {
611 chop;
612 next unless /\$([\w:]*\bVERSION)\b.*=/;
613 local $ExtUtils::MakeMaker::module_version_variable = $1;
614 my($eval) = "$_;";
615 eval $eval;
616 die "Could not eval '$eval': $@" if $@;
617 if ($self->{VERSION} = $ {$ExtUtils::MakeMaker::module_version_variable}){
618 print "$self->{NAME} VERSION is $self->{VERSION} (from $self->{VERSION_FROM})\n" if $Verbose;
619 } else {
620 # XXX this should probably croak
621 print "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n";
622 }
623 last;
624 }
625 close $fh;
626 }
627
628 # if your FOO.pm says
629 # $VERSION = substr(q$Revision: 1.4 $, 10);
630 # then MM says something like
631 # -DXS_VERSION=\"n.nn \"
632 if ($self->{VERSION}) {
633 $self->{VERSION} =~ s/^\s+//;
634 $self->{VERSION} =~ s/\s+$//;
635 }
636
637 $self->{VERSION} = "0.10" unless $self->{VERSION};
638 ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
639
640
641 # Graham Barr and Paul Marquess had some ideas how to ensure
642 # version compatibility between the *.pm file and the
643 # corresponding *.xs file. The bottomline was, that we need an
644 # XS_VERSION macro that defaults to VERSION:
645 $self->{XS_VERSION} ||= $self->{VERSION};
646
647 # --- Initialize Perl Binary Locations
648
649 # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
650 # will be working versions of perl 5. miniperl has priority over perl
651 # for PERL to ensure that $(PERL) is usable while building ./ext/*
652 my ($component,@defpath);
653 foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
654 push @defpath, $component if defined $component;
655 }
656 $self->{PERL} =
657 $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ],
658 \@defpath, $Verbose ) unless ($self->{PERL});
659 # don't check if perl is executable, maybe they have decided to
660 # supply switches with perl
661
662 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
663 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
664 unless ($self->{FULLPERL});
665}
666
667=item init_dirscan
668
669
670
671=cut
672
673sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
674 my($self) = @_;
675 unless (ref $self){
676 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
677 $self = $ExtUtils::MakeMaker::Parent[-1];
678 }
679 my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
680 local(%pm); #the sub in find() has to see this hash
681 $ignore{'test.pl'} = 1;
682 $ignore{'makefile.pl'} = 1 if $Is_VMS;
683 foreach $name ($self->lsdir(".")){
684 next if ($name =~ /^\./ or $ignore{$name});
685 next unless $self->libscan($name);
686 if (-d $name){
687 $dir{$name} = $name if (-f "$name/Makefile.PL");
688 } elsif ($name =~ /\.xs$/){
689 my($c); ($c = $name) =~ s/\.xs$/.c/;
690 $xs{$name} = $c;
691 $c{$c} = 1;
692 } elsif ($name =~ /\.c$/i){
693 $c{$name} = 1
694 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
695 } elsif ($name =~ /\.h$/i){
696 $h{$name} = 1;
697 } elsif ($name =~ /\.(p[ml]|pod)$/){
698 $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);
699 } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
700 ($pl_files{$name} = $name) =~ s/\.PL$// ;
701 } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' &&
702 $name ne 'test.pl') { # case-insensitive filesystem
703 ($pl_files{$name} = $name) =~ s/\.pl$// ;
704 }
705 }
706
707 # Some larger extensions often wish to install a number of *.pm/pl
708 # files into the library in various locations.
709
710 # The attribute PMLIBDIRS holds an array reference which lists
711 # subdirectories which we should search for library files to
712 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
713 # recursively search through the named directories (skipping any
714 # which don't exist or contain Makefile.PL files).
715
716 # For each *.pm or *.pl file found $self->libscan() is called with
717 # the default installation path in $_[1]. The return value of
718 # libscan defines the actual installation location. The default
719 # libscan function simply returns the path. The file is skipped
720 # if libscan returns false.
721
722 # The default installation location passed to libscan in $_[1] is:
723 #
724 # ./*.pm => $(INST_LIBDIR)/*.pm
725 # ./xyz/... => $(INST_LIBDIR)/xyz/...
726 # ./lib/... => $(INST_LIB)/...
727 #
728 # In this way the 'lib' directory is seen as the root of the actual
729 # perl library whereas the others are relative to INST_LIBDIR
730 # (which includes ROOTEXT). This is a subtle distinction but one
731 # that's important for nested modules.
732
733 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]
734 unless $self->{PMLIBDIRS};
735
736 #only existing directories that aren't in $dir are allowed
737
738 # Avoid $_ wherever possible:
739 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
740 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
741 my ($pmlibdir);
742 @{$self->{PMLIBDIRS}} = ();
743 foreach $pmlibdir (@pmlibdirs) {
744 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
745 }
746
747 if (@{$self->{PMLIBDIRS}}){
748 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
749 if ($Verbose >= 2);
750 File::Find::find(sub {
751 if (-d $_){
752 if ($_ eq "CVS" || $_ eq "RCS"){
753 $File::Find::prune = 1;
754 }
755 return;
756 }
757 my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
758 my($striplibpath,$striplibname);
759 $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:);
760 ($striplibname,$striplibpath) = fileparse($striplibpath);
761 my($inst) = $self->catfile($prefix,$striplibpath,$striplibname);
762 local($_) = $inst; # for backwards compatibility
763 $inst = $self->libscan($inst);
764 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
765 return unless $inst;
766 $pm{$path} = $inst;
767 }, @{$self->{PMLIBDIRS}});
768 }
769
770 $self->{DIR} = [sort keys %dir] unless $self->{DIR};
771 $self->{XS} = \%xs unless $self->{XS};
772 $self->{PM} = \%pm unless $self->{PM};
773 $self->{C} = [sort keys %c] unless $self->{C};
774 my(@o_files) = @{$self->{C}};
775 $self->{O_FILES} = [grep s/\.c$/$self->{OBJ_EXT}/i, @o_files] ;
776 $self->{H} = [sort keys %h] unless $self->{H};
777 $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
778
779 # Set up names of manual pages to generate from pods
780 if ($self->{MAN1PODS}) {
781 } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) {
782 $self->{MAN1PODS} = {};
783 } else {
784 my %manifypods = ();
785 if ( exists $self->{EXE_FILES} ) {
786 foreach $name (@{$self->{EXE_FILES}}) {
787 my $fh = new FileHandle;
788 my($ispod)=0;
789 # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?)
790 if ($fh->open("<$name")) {
791 my $testpodline;
792 while ($testpodline = <$fh>) {
793 if($testpodline =~ /^=head1\s+\w+/) {
794 $ispod=1;
795 last;
796 }
797 }
798 $fh->close;
799 } else {
800 # If it doesn't exist yet, we assume, it has pods in it
801 $ispod = 1;
802 }
803 if( $ispod ) {
804 $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)');
805 }
806 }
807 }
808 $self->{MAN1PODS} = \%manifypods;
809 }
810 if ($self->{MAN3PODS}) {
811 } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) {
812 $self->{MAN3PODS} = {};
813 } else {
814 my %manifypods = (); # we collect the keys first, i.e. the files
815 # we have to convert to pod
816 foreach $name (keys %{$self->{PM}}) {
817 if ($name =~ /\.pod$/ ) {
818 $manifypods{$name} = $self->{PM}{$name};
819 } elsif ($name =~ /\.p[ml]$/ ) {
820 my $fh = new FileHandle;
821 my($ispod)=0;
822 $fh->open("<$name");
823 my $testpodline;
824 while ($testpodline = <$fh>) {
825 if($testpodline =~ /^=head1\s+\w+/) {
826 $ispod=1;
827 last;
828 }
829 #Speculation on the future (K.A., not A.K. :)
830 #if(/^=don't\S+install/) { $ispod=0; last}
831 }
832 $fh->close;
833
834 if( $ispod ) {
835 $manifypods{$name} = $self->{PM}{$name};
836 }
837 }
838 }
839
840 # Remove "Configure.pm" and similar, if it's not the only pod listed
841 # To force inclusion, just name it "Configure.pod", or override MAN3PODS
842 foreach $name (keys %manifypods) {
843 if ($name =~ /(config|setup).*\.pm/i) {
844 delete $manifypods{$name};
845 next;
846 }
847 my($manpagename) = $name;
848 unless ($manpagename =~ s!^(\W*)lib\W!$1!) {
849 $manpagename = $self->catfile($self->{ROOTEXT},$manpagename);
850 }
851 $manpagename =~ s/\.p(od|m|l)$//;
852 # Strip leading slashes
853 $manpagename =~ s!^/+!!;
854 # Turn other slashes into colons
855# $manpagename =~ s,/+,::,g;
856 $manpagename = $self->replace_manpage_separator($manpagename);
857 $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)");
858 }
859 $self->{MAN3PODS} = \%manifypods;
860 }
861}
862
863=item init_others
864
865
866
867=cut
868
869sub init_others { # --- Initialize Other Attributes
870 my($self) = shift;
871 unless (ref $self){
872 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
873 $self = $ExtUtils::MakeMaker::Parent[-1];
874 }
875
876 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
877 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
878 # undefined. In any case we turn it into an anon array:
879
880 # May check $Config{libs} too, thus not empty.
881 $self->{LIBS}=[''] unless $self->{LIBS};
882
883 $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq SCALAR;
884 $self->{LD_RUN_PATH} = "";
885 my($libs);
886 foreach $libs ( @{$self->{LIBS}} ){
887 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
888 my(@libs) = $self->extliblist($libs);
889 if ($libs[0] or $libs[1] or $libs[2]){
890 # LD_RUN_PATH now computed by ExtUtils::Liblist
891 ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
892 last;
893 }
894 }
895
896 unless ( $self->{OBJECT} ){
897 # init_dirscan should have found out, if we have C files
898 $self->{OBJECT} = "";
899 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
900 }
901 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
902 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
903 $self->{PERLMAINCC} ||= '$(CC)';
904 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
905
906 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
907 # the 'dynamic' section of MM. We don't have this problem with
908 # 'static', since we either must use it (%Config says we can't
909 # use dynamic loading) or the caller asked for it explicitly.
910 if (!$self->{LINKTYPE}) {
911 $self->{LINKTYPE} = grep(/dynamic/,@{$self->{SKIP} || []})
912 ? 'static'
913 : ($Config::Config{usedl} ? 'dynamic' : 'static');
914 };
915
916 # These get overridden for VMS and maybe some other systems
917 $self->{NOOP} ||= "";
918 $self->{FIRST_MAKEFILE} ||= "Makefile";
919 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
920 $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
921 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
922 $self->{RM_F} ||= "rm -f";
923 $self->{RM_RF} ||= "rm -rf";
924 $self->{TOUCH} ||= "touch";
925 $self->{CP} ||= "cp";
926 $self->{MV} ||= "mv";
927 $self->{CHMOD} ||= "chmod";
928 $self->{UMASK_NULL} ||= "umask 0";
929}
930
931=item find_perl
932
933
934
935=cut
936
937sub find_perl {
938 my($self, $ver, $names, $dirs, $trace) = @_;
939 unless (ref $self){
940 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
941 $self = $ExtUtils::MakeMaker::Parent[-1];
942 }
943 my($name, $dir);
944 if ($trace >= 2){
945 print "Looking for perl $ver by these names:
946@$names
947in these dirs:
948@$dirs
949";
950 }
951 foreach $dir (@$dirs){
952 next unless defined $dir; # $self->{PERL_SRC} may be undefined
953 foreach $name (@$names){
954 my $abs;
955 if ($self->file_name_is_absolute($name)) {
956 $abs = $name;
957 } elsif (($name =~ m|/|) && ($name !~ m|^\.{1,2}/|)) {
958 # name is a path that does not begin with dot or dotdot
959 $abs = $self->catfile(".", $name);
960 } else {
961 $abs = $self->catfile($dir, $name);
962 }
963 print "Checking $abs\n" if ($trace >= 2);
964 next unless $self->maybe_command($abs);
965 print "Executing $abs\n" if ($trace >= 2);
966 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
967 print "Using PERL=$abs\n" if $trace;
968 return $abs;
969 }
970 }
971 }
972 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
973 0; # false and not empty
974}
975
976=head2 Methods to actually produce chunks of text for the Makefile
977
978The methods here are called in the order specified by
979@ExtUtils::MakeMaker::MM_Sections. This manpage reflects the order as
980well as possible. Some methods call each other, so in doubt refer to
981the code.
982
983=item post_initialize
984
985Returns an ampty string per default. Used in Makefile.PLs to add some
986chunk of text to the Makefile after the object is initialized.
987
988=cut
989
990sub post_initialize {
991 my($self) = shift;
992 unless (ref $self){
993 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
994 $self = $ExtUtils::MakeMaker::Parent[-1];
995 }
996 "";
997}
998
999=item const_config
1000
1001
1002
1003=cut
1004
1005sub const_config {
1006# --- Constants Sections ---
1007
1008 my($self) = shift;
1009 unless (ref $self){
1010 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1011 $self = $ExtUtils::MakeMaker::Parent[-1];
1012 }
1013 my(@m,$m);
1014 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
1015 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
1016 my(%once_only);
1017 foreach $m (@{$self->{CONFIG}}){
1018 next if $once_only{$m};
1019 push @m, "\U$m\E = ".$self->{uc $m}."\n";
1020 $once_only{$m} = 1;
1021 }
1022 join('', @m);
1023}
1024
1025=item constants
1026
1027
1028
1029=cut
1030
1031sub constants {
1032 my($self) = @_;
1033 unless (ref $self){
1034 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1035 $self = $ExtUtils::MakeMaker::Parent[-1];
1036 }
1037 my(@m,$tmp);
1038
1039 for $tmp (qw/
1040 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION VERSION_SYM XS_VERSION
1041 INST_LIB INST_ARCHLIB INST_EXE PREFIX INSTALLDIRS INSTALLPRIVLIB
1042 INSTALLARCHLIB INSTALLSITELIB INSTALLSITEARCH INSTALLBIN PERL_LIB
1043 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
1044 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_INC PERL FULLPERL
1045 / ) {
1046 next unless defined $self->{$tmp};
1047 push @m, "$tmp = $self->{$tmp}\n";
1048 }
1049
1050 push @m, qq{
1051VERSION_MACRO = VERSION
1052DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
1053XS_VERSION_MACRO = XS_VERSION
1054XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
1055};
1056
1057 push @m, qq{
1058MAKEMAKER = \$(PERL_LIB)/ExtUtils/MakeMaker.pm
1059MM_VERSION = $ExtUtils::MakeMaker::VERSION
1060MM_REVISION = $Revision
1061};
1062
1063 push @m, q{
1064# FULLEXT = Pathname for extension directory (eg DBD/Oracle).
1065# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
1066# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
1067# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
1068};
1069
1070 for $tmp (qw/
1071 FULLEXT BASEEXT ROOTEXT DLBASE VERSION_FROM INC DEFINE OBJECT OBJECT
1072 LDFROM LINKTYPE
1073 / ) {
1074 next unless defined $self->{$tmp};
1075 push @m, "$tmp = $self->{$tmp}\n";
1076 }
1077
1078 push @m, "
1079# Handy lists of source code files:
1080XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
1081C_FILES = ".join(" \\\n\t", @{$self->{C}})."
1082O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
1083H_FILES = ".join(" \\\n\t", @{$self->{H}})."
1084MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
1085MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
1086";
1087
1088 for $tmp (qw/
1089 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
1090 /) {
1091 next unless defined $self->{$tmp};
1092 push @m, "$tmp = $self->{$tmp}\n";
1093 }
1094
1095 push @m, "
1096# work around a famous dec-osf make(1) feature(?):
1097makemakerdflt: all
1098
1099.SUFFIXES: .xs .c .C \$(OBJ_EXT)
1100
1101# Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
1102# some make implementations will delete the Makefile when we rebuild it. Because
1103# we call false(1) when we rebuild it. So make(1) is not completely wrong when it
1104# does so. Our milage may vary.
1105# .PRECIOUS: Makefile # seems to be not necessary anymore
1106
1107.PHONY: all config static dynamic test linkext manifest
1108
1109# Where is the Config information that we are using/depend on
1110CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h \$(VERSION_FROM)
1111";
1112
1113 push @m, '
1114# Where to put things:
1115INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
1116INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
1117
1118INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
1119INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
1120';
1121
1122 if ($self->has_link_code()) {
1123 push @m, '
1124INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
1125INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
1126INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
1127';
1128 } else {
1129 push @m, '
1130INST_STATIC =
1131INST_DYNAMIC =
1132INST_BOOT =
1133';
1134 }
1135
1136 if ($Is_OS2) {
1137 $tmp = "$self->{BASEEXT}.def";
1138 } else {
1139 $tmp = "";
1140 }
1141 push @m, "
1142EXPORT_LIST = $tmp
1143";
1144
1145 if ($Is_OS2) {
1146 $tmp = "\$(PERL_INC)/libperl.lib";
1147 } else {
1148 $tmp = "";
1149 }
1150 push @m, "
1151PERL_ARCHIVE = $tmp
1152";
1153
1154 push @m, '
1155INST_PM = '.join(" \\\n\t", sort values %{$self->{PM}}).'
1156';
1157
1158 join('',@m);
1159}
1160
1161=item const_loadlibs
1162
1163
1164
1165=cut
1166
1167sub const_loadlibs {
1168 my($self) = shift;
1169 unless (ref $self){
1170 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1171 $self = $ExtUtils::MakeMaker::Parent[-1];
1172 }
1173 return "" unless $self->needs_linking;
1174 # This description can be deleted after ExtUtils::Liblist is in
1175 # the perl dist with pods
1176 "
1177# $self->{NAME} might depend on some other libraries:
1178# (These comments may need revising:)
1179#
1180# Dependent libraries can be linked in one of three ways:
1181#
1182# 1. (For static extensions) by the ld command when the perl binary
1183# is linked with the extension library. See EXTRALIBS below.
1184#
1185# 2. (For dynamic extensions) by the ld command when the shared
1186# object is built/linked. See LDLOADLIBS below.
1187#
1188# 3. (For dynamic extensions) by the DynaLoader when the shared
1189# object is loaded. See BSLOADLIBS below.
1190#
1191# EXTRALIBS = List of libraries that need to be linked with when
1192# linking a perl binary which includes this extension
1193# Only those libraries that actually exist are included.
1194# These are written to a file and used when linking perl.
1195#
1196# LDLOADLIBS = List of those libraries which can or must be linked into
1197# the shared library when created using ld. These may be
1198# static or dynamic libraries.
1199# LD_RUN_PATH is a colon separated list of the directories
1200# in LDLOADLIBS. It is passed as an environment variable to
1201# the process that links the shared library.
1202#
1203# BSLOADLIBS = List of those libraries that are needed but can be
1204# linked in dynamically at run time on this platform.
1205# SunOS/Solaris does not need this because ld records
1206# the information (from LDLOADLIBS) into the object file.
1207# This list is used to create a .bs (bootstrap) file.
1208#
1209EXTRALIBS = $self->{EXTRALIBS}
1210LDLOADLIBS = $self->{LDLOADLIBS}
1211BSLOADLIBS = $self->{BSLOADLIBS}
1212LD_RUN_PATH= $self->{LD_RUN_PATH}
1213";
1214}
1215
1216=item const_cccmd
1217
1218
1219
1220=cut
1221
1222sub const_cccmd {
1223 my($self,$libperl)=@_;
1224 unless (ref $self){
1225 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1226 $self = $ExtUtils::MakeMaker::Parent[-1];
1227 }
1228 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
1229 return '' unless $self->needs_linking();
1230 $libperl or $libperl = $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
1231 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
1232 # This is implemented in the same manner as extliblist,
1233 # e.g., do both and compare results during the transition period.
1234 my($cc,$ccflags,$optimize,$large,$split, $shflags)
1235 = @Config{qw(cc ccflags optimize large split shellflags)};
1236 my($optdebug) = "";
1237
1238 $shflags = '' unless $shflags;
1239 my($prog, $uc, $perltype);
1240
1241 my(%map) = (
1242 D => '-DDEBUGGING',
1243 E => '-DEMBED',
1244 DE => '-DDEBUGGING -DEMBED',
1245 M => '-DEMBED -DMULTIPLICITY',
1246 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
1247 );
1248
1249 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
1250 $uc = uc($1);
1251 } else {
1252 $uc = ""; # avoid warning
1253 }
1254 $perltype = $map{$uc} ? $map{$uc} : "";
1255
1256 if ($uc =~ /^D/) {
1257 $optdebug = "-g";
1258 }
1259
1260
1261 my($name);
1262 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
1263 if ($prog = $Config::Config{$name}) {
1264 # Expand hints for this extension via the shell
1265 print STDOUT "Processing $name hint:\n" if $Verbose;
1266 my(@o)=`cc=\"$cc\"
1267 ccflags=\"$ccflags\"
1268 optimize=\"$optimize\"
1269 perltype=\"$perltype\"
1270 optdebug=\"$optdebug\"
1271 large=\"$large\"
1272 split=\"$split\"
1273 eval '$prog'
1274 echo cc=\$cc
1275 echo ccflags=\$ccflags
1276 echo optimize=\$optimize
1277 echo perltype=\$perltype
1278 echo optdebug=\$optdebug
1279 echo large=\$large
1280 echo split=\$split
1281 `;
1282 my(%cflags,$line);
1283 foreach $line (@o){
1284 chomp $line;
1285 if ($line =~ /(.*?)=\s*(.*)\s*$/){
1286 $cflags{$1} = $2;
1287 print STDOUT " $1 = $2\n" if $Verbose;
1288 } else {
1289 print STDOUT "Unrecognised result from hint: '$line'\n";
1290 }
1291 }
1292 ( $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split )=@cflags{
1293 qw( cc ccflags perltype optdebug optimize large split)};
1294 }
1295
1296 if ($optdebug) {
1297 $optimize = $optdebug;
1298 }
1299
1300 my($new) = "$cc -c \$(INC) $ccflags $optimize $perltype $large $split";
1301 $new =~ s/^\s+//; $new =~ s/\s+/ /g; $new =~ s/\s+$//;
1302
1303 my($cccmd) = $new;
1304 $cccmd =~ s/^\s*\Q$Config::Config{cc}\E\s/\$(CC) /;
1305 $cccmd .= " \$(DEFINE_VERSION) \$(XS_DEFINE_VERSION)";
1306 $self->{CONST_CCCMD} = "CCCMD = $cccmd\n";
1307}
1308
1309=item tool_autosplit
1310
1311
1312
1313=cut
1314
1315sub tool_autosplit {
1316# --- Tool Sections ---
1317
1318 my($self, %attribs) = @_;
1319 unless (ref $self){
1320 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1321 $self = $ExtUtils::MakeMaker::Parent[-1];
1322 }
1323 my($asl) = "";
1324 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
1325 q{
1326# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
1327AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
1328};
1329}
1330
1331=item tool_xsubpp
1332
1333
1334
1335=cut
1336
1337sub tool_xsubpp {
1338 my($self) = shift;
1339 unless (ref $self){
1340 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1341 $self = $ExtUtils::MakeMaker::Parent[-1];
1342 }
1343 my($xsdir) = "$self->{PERL_LIB}/ExtUtils";
1344 # drop back to old location if xsubpp is not in new location yet
1345 $xsdir = "$self->{PERL_SRC}/ext" unless (-f "$self->{PERL_LIB}/ExtUtils/xsubpp");
1346 my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
1347 if( $self->{TYPEMAPS} ){
1348 my $typemap;
1349 foreach $typemap (@{$self->{TYPEMAPS}}){
1350 if( ! -f $typemap ){
1351 warn "Typemap $typemap not found.\n";
1352 }
1353 else{
1354 push(@tmdeps, $typemap);
1355 }
1356 }
1357 }
1358 push(@tmdeps, "typemap") if -f "typemap";
1359 my(@tmargs) = map("-typemap $_", @tmdeps);
1360 if( exists $self->{XSOPT} ){
1361 unshift( @tmargs, $self->{XSOPT} );
1362 }
1363
1364 my $xsubpp_version = $self->xsubpp_version("$xsdir/xsubpp");
1365
1366 # What are the correct thresholds for version 1 && 2 Paul?
1367 if ( $xsubpp_version > 1.923 ){
1368 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
1369 } else {
1370 if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
1371 print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
1372 Your version of xsubpp is $xsubpp_version and cannot handle this.
1373 Please upgrade to a more recent version of xsubpp.
1374};
1375 } else {
1376 $self->{XSPROTOARG} = "";
1377 }
1378 }
1379
1380 "
1381XSUBPPDIR = $xsdir
1382XSUBPP = \$(XSUBPPDIR)/xsubpp
1383XSPROTOARG = $self->{XSPROTOARG}
1384XSUBPPDEPS = @tmdeps
1385XSUBPPARGS = @tmargs
1386";
1387};
1388
1389sub xsubpp_version
1390{
1391 my($self,$xsubpp) = @_;
1392 my ($version) ;
1393
1394 # try to figure out the version number of the xsubpp on the system
1395
1396 # first try the -v flag, introduced in 1.921 & 2.000a2
1397
1398 my $command = "$self->{PERL} $xsubpp -v 2>&1";
1399 print "Running $command\n" if $Verbose >= 2;
1400 $version = `$command` ;
1401 warn "Running '$command' exits with status " . ($?>>8) if $?;
1402 chop $version ;
1403
1404 return $1 if $version =~ /^xsubpp version (.*)/ ;
1405
1406 # nope, then try something else
1407
1408 my $counter = '000';
1409 my ($file) = 'temp' ;
1410 $counter++ while -e "$file$counter"; # don't overwrite anything
1411 $file .= $counter;
1412
1413 open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
1414 print F <<EOM ;
1415MODULE = fred PACKAGE = fred
1416
1417int
1418fred(a)
1419 int a;
1420EOM
1421
1422 close F ;
1423
1424 $command = "$self->{PERL} $xsubpp $file 2>&1";
1425 print "Running $command\n" if $Verbose >= 2;
1426 my $text = `$command` ;
1427 warn "Running '$command' exits with status " . ($?>>8) if $?;
1428 unlink $file ;
1429
1430 # gets 1.2 -> 1.92 and 2.000a1
1431 return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ;
1432
1433 # it is either 1.0 or 1.1
1434 return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
1435
1436 # none of the above, so 1.0
1437 return "1.0" ;
1438}
1439
1440=item tools_other
1441
1442
1443
1444=cut
1445
1446sub tools_other {
1447 my($self) = shift;
1448 unless (ref $self){
1449 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1450 $self = $ExtUtils::MakeMaker::Parent[-1];
1451 }
1452 "
1453SHELL = /bin/sh
1454LD = $self->{LD}
1455TOUCH = $self->{TOUCH}
1456CP = $self->{CP}
1457MV = $self->{MV}
1458RM_F = $self->{RM_F}
1459RM_RF = $self->{RM_RF}
1460CHMOD = $self->{CHMOD}
1461UMASK_NULL = $self->{UMASK_NULL}
1462".q{
1463# The following is a portable way to say mkdir -p
1464# To see which directories are created, change the if 0 to if 1
1465MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){' \\
1466-e 'next if -d $$p; my(@p); foreach(split(/\//,$$p)){' \\
1467-e 'push(@p,$$_); next if -d "@p/"; print "mkdir @p" if 0;' \\
1468-e 'mkdir("@p",0777)||die $$! } } exit 0;'
1469
1470# This helps us to minimize the effect of the .exists files A yet
1471# better solution would be to have a stable file in the perl
1472# distribution with a timestamp of zero. But this solution doesn't
1473# need any changes to the core distribution and works with older perls
1474EQUALIZE_TIMESTAMP = $(PERL) -we 'open F, ">$$ARGV[1]"; close F;' \\
1475-e 'utime ((stat("$$ARGV[0]"))[8,9], $$ARGV[1])'
1476
1477# Here we warn users that an old packlist file was found somewhere,
1478# and that they should call some uninstall routine
1479WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \\
1480-e 'print "WARNING: I have found an old package in\n";' \\
1481-e 'print "\t$$ARGV[0].\n";' \\
1482-e 'print "Please make sure the two installations are not conflicting\n";'
1483
1484MOD_INSTALL = $(PERL) -I$(INST_LIB) -MExtUtils::Install \
1485-e 'install({@ARGV},1);'
1486
1487DOC_INSTALL = $(PERL) -e '$$\="\n\n";print "=head3 ", scalar(localtime), ": C<", shift, ">";' \
1488-e 'print "=over 4";' \
1489-e 'while ($$key = shift and $$val = shift){print "=item *";print "C<$$key: $$val>";}' \
1490-e 'print "=back";'
1491
1492UNINSTALL = $(PERL) -MExtUtils::Install \
1493-e 'uninstall($$ARGV[0],1);'
1494
1495};
1496}
1497
1498=item dist
1499
1500
1501
1502=cut
1503
1504sub dist {
1505 my($self, %attribs) = @_;
1506 unless (ref $self){
1507 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1508 $self = $ExtUtils::MakeMaker::Parent[-1];
1509 }
1510 my(@m);
1511 # VERSION should be sanitised before use as a file name
1512 my($name) = $attribs{NAME} || '$(DISTVNAME)';
1513 my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar
1514 my($tarflags) = $attribs{TARFLAGS} || 'cvf';
1515 my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip
1516 my($suffix) = $attribs{SUFFIX} || 'Z'; # eg gz
1517 my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip"
1518 my($preop) = $attribs{PREOP} || "$self->{NOECHO}true"; # eg update MANIFEST
1519 my($postop) = $attribs{POSTOP} || "$self->{NOECHO}true"; # eg remove the distdir
1520 my($ci) = $attribs{CI} || 'ci -u';
1521 my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q';
1522 my($dist_cp) = $attribs{DIST_CP} || 'best';
1523 my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
1524
1525 push @m, "
1526DISTVNAME = \$(DISTNAME)-\$(VERSION)
1527TAR = $tar
1528TARFLAGS = $tarflags
1529COMPRESS = $compress
1530SUFFIX = $suffix
1531SHAR = $shar
1532PREOP = $preop
1533POSTOP = $postop
1534CI = $ci
1535RCS_LABEL = $rcs_label
1536DIST_CP = $dist_cp
1537DIST_DEFAULT = $dist_default
1538";
1539 join "", @m;
1540}
1541
1542=item macro
1543
1544
1545
1546=cut
1547
1548sub macro {
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(@m,$key,$val);
1555 while (($key,$val) = each %attribs){
1556 push @m, "$key = $val\n";
1557 }
1558 join "", @m;
1559}
1560
1561=item depend
1562
1563
1564
1565=cut
1566
1567sub depend {
1568 my($self,%attribs) = @_;
1569 unless (ref $self){
1570 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1571 $self = $ExtUtils::MakeMaker::Parent[-1];
1572 }
1573 my(@m,$key,$val);
1574 while (($key,$val) = each %attribs){
1575 push @m, "$key: $val\n";
1576 }
1577 join "", @m;
1578}
1579
1580=item post_constants
1581
1582
1583
1584=cut
1585
1586sub post_constants{
1587 my($self) = shift;
1588 unless (ref $self){
1589 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1590 $self = $ExtUtils::MakeMaker::Parent[-1];
1591 }
1592 "";
1593}
1594
1595=item pasthru
1596
1597
1598
1599=cut
1600
1601sub pasthru {
1602 my($self) = shift;
1603 unless (ref $self){
1604 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1605 $self = $ExtUtils::MakeMaker::Parent[-1];
1606 }
1607 my(@m,$key);
1608
1609 my(@pasthru);
1610
1611 foreach $key (qw(INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN
1612 INSTALLMAN1DIR INSTALLMAN3DIR LIBPERL_A
1613 LINKTYPE PREFIX INSTALLSITELIB
1614 INSTALLSITEARCH INSTALLDIRS)){
1615 push @pasthru, "$key=\"\$($key)\"";
1616 }
1617
1618 push @m, "\nPASTHRU = ", join ("\\\n\t", @pasthru), "\n";
1619 join "", @m;
1620}
1621
1622=item c_o
1623
1624
1625
1626=cut
1627
1628sub c_o {
1629# --- Translation Sections ---
1630
1631 my($self) = shift;
1632 unless (ref $self){
1633 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1634 $self = $ExtUtils::MakeMaker::Parent[-1];
1635 }
1636 return '' unless $self->needs_linking();
1637 my(@m);
1638 push @m, '
1639.c$(OBJ_EXT):
1640 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
1641
1642.C$(OBJ_EXT):
1643 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
1644';
1645 join "", @m;
1646}
1647
1648=item xs_c
1649
1650
1651
1652=cut
1653
1654sub xs_c {
1655 my($self) = shift;
1656 unless (ref $self){
1657 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1658 $self = $ExtUtils::MakeMaker::Parent[-1];
1659 }
1660 return '' unless $self->needs_linking();
1661 '
1662.xs.c:
1663 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
1664';
1665}
1666
1667=item xs_o
1668
1669
1670
1671=cut
1672
1673sub xs_o { # many makes are too dumb to use xs_c then c_o
1674 my($self) = shift;
1675 unless (ref $self){
1676 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1677 $self = $ExtUtils::MakeMaker::Parent[-1];
1678 }
1679 return '' unless $self->needs_linking();
1680 '
1681.xs$(OBJ_EXT):
1682 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
1683 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
1684';
1685}
1686
1687=item top_targets
1688
1689
1690
1691=cut
1692
1693sub top_targets {
1694# --- Target Sections ---
1695
1696 my($self) = shift;
1697 unless (ref $self){
1698 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1699 $self = $ExtUtils::MakeMaker::Parent[-1];
1700 }
1701 my(@m);
1702 push @m, '
1703all :: config $(INST_PM) subdirs linkext manifypods
1704
1705subdirs :: $(MYEXTLIB)
1706
1707'.$self->{NOOP}.'
1708
1709config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists
1710
1711config :: $(INST_ARCHAUTODIR)/.exists
1712
1713config :: $(INST_AUTODIR)/.exists
1714';
1715
1716 push @m, q{
1717config :: Version_check
1718
1719} unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl");
1720
1721 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
1722
1723 if (%{$self->{MAN1PODS}}) {
1724 push @m, q[
1725config :: $(INST_MAN1DIR)/.exists
1726
1727];
1728 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
1729 }
1730 if (%{$self->{MAN3PODS}}) {
1731 push @m, q[
1732config :: $(INST_MAN3DIR)/.exists
1733
1734];
1735 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
1736 }
1737
1738 push @m, '
1739$(O_FILES): $(H_FILES)
1740' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
1741
1742 push @m, q{
1743help:
1744 perldoc ExtUtils::MakeMaker
1745};
1746
1747 push @m, q{
1748Version_check:
1749 }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
1750 -MExtUtils::MakeMaker=Version_check \
1751 -e 'Version_check("$(MM_VERSION)")'
1752};
1753
1754 join('',@m);
1755}
1756
1757=item linkext
1758
1759
1760
1761=cut
1762
1763sub linkext {
1764 my($self, %attribs) = @_;
1765 unless (ref $self){
1766 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1767 $self = $ExtUtils::MakeMaker::Parent[-1];
1768 }
1769 # LINKTYPE => static or dynamic or ''
1770 my($linktype) = defined $attribs{LINKTYPE} ?
1771 $attribs{LINKTYPE} : '$(LINKTYPE)';
1772 "
1773linkext :: $linktype
1774$self->{NOOP}
1775";
1776}
1777
1778=item dlsyms
1779
1780
1781
1782=cut
1783
1784sub dlsyms {
1785 my($self,%attribs) = @_;
1786 unless (ref $self){
1787 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1788 $self = $ExtUtils::MakeMaker::Parent[-1];
1789 }
1790
1791 return '' unless ($Config::Config{osname} eq 'aix' && $self->needs_linking() );
1792
1793 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
1794 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
1795 my(@m);
1796
1797 push(@m,"
1798dynamic :: $self->{BASEEXT}.exp
1799
1800") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
1801
1802 push(@m,"
1803static :: $self->{BASEEXT}.exp
1804
1805") unless $self->{SKIPHASH}{'static'}; # we avoid a warning if we tick them
1806
1807 push(@m,"
1808$self->{BASEEXT}.exp: Makefile.PL
1809",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
1810 Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
1811 neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
1812');
1813
1814 join('',@m);
1815}
1816
1817=item dynamic
1818
1819
1820
1821=cut
1822
1823sub dynamic {
1824# --- Dynamic Loading Sections ---
1825
1826 my($self) = shift;
1827 unless (ref $self){
1828 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1829 $self = $ExtUtils::MakeMaker::Parent[-1];
1830 }
1831 '
1832# $(INST_PM) has been moved to the all: target.
1833# It remains here for awhile to allow for old usage: "make dynamic"
1834dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
1835'.$self->{NOOP}.'
1836';
1837}
1838
1839=item dynamic_bs
1840
1841
1842
1843=cut
1844
1845sub dynamic_bs {
1846 my($self, %attribs) = @_;
1847 unless (ref $self){
1848 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1849 $self = $ExtUtils::MakeMaker::Parent[-1];
1850 }
1851 return '
1852BOOTSTRAP =
1853' unless $self->has_link_code();
1854
1855 return '
1856BOOTSTRAP = '."$self->{BASEEXT}.bs".'
1857
1858# As Mkbootstrap might not write a file (if none is required)
1859# we use touch to prevent make continually trying to remake it.
1860# The DynaLoader only reads a non-empty file.
1861$(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists
1862 '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
1863 '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
1864 -e \'use ExtUtils::Mkbootstrap;\' \
1865 -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\'
1866 '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
1867 $(CHMOD) 644 $@
1868
1869$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
1870 '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
1871 -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
1872 $(CHMOD) 644 $@
1873';
1874}
1875
1876=item dynamic_lib
1877
1878
1879
1880=cut
1881
1882sub dynamic_lib {
1883 my($self, %attribs) = @_;
1884 unless (ref $self){
1885 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1886 $self = $ExtUtils::MakeMaker::Parent[-1];
1887 }
1888 return '' unless $self->needs_linking(); #might be because of a subdir
1889
1890 return '' unless $self->has_link_code;
1891
1892 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
1893 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
1894 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
1895 my($ldfrom) = '$(LDFROM)';
1896 my($osname) = $Config::Config{osname};
1897 $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':');
1898 my(@m);
1899 push(@m,'
1900# This section creates the dynamically loadable $(INST_DYNAMIC)
1901# from $(OBJECT) and possibly $(MYEXTLIB).
1902ARMAYBE = '.$armaybe.'
1903OTHERLDFLAGS = '.$otherldflags.'
1904INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
1905
1906$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
1907');
1908 if ($armaybe ne ':'){
1909 $ldfrom = 'tmp$(LIB_EXT)';
1910 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
1911 push(@m,' $(RANLIB) '."$ldfrom\n");
1912 }
1913 $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf');
1914 push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
1915 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS) $(EXPORT_LIST) $(PERL_ARCHIVE)');
1916 push @m, '
1917 $(CHMOD) 755 $@
1918';
1919
1920 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1921 join('',@m);
1922}
1923
1924=item static
1925
1926
1927
1928=cut
1929
1930sub static {
1931# --- Static Loading Sections ---
1932
1933 my($self) = shift;
1934 unless (ref $self){
1935 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1936 $self = $ExtUtils::MakeMaker::Parent[-1];
1937 }
1938 '
1939# $(INST_PM) has been moved to the all: target.
1940# It remains here for awhile to allow for old usage: "make static"
1941static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
1942'.$self->{NOOP}.'
1943';
1944}
1945
1946=item static_lib
1947
1948
1949
1950=cut
1951
1952sub static_lib {
1953 my($self) = @_;
1954 unless (ref $self){
1955 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1956 $self = $ExtUtils::MakeMaker::Parent[-1];
1957 }
1958# Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
1959# return '' unless $self->needs_linking(); #might be because of a subdir
1960
1961 return '' unless $self->has_link_code;
1962
1963 my(@m);
1964 push(@m, <<'END');
1965$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
1966END
1967 # If this extension has it's own library (eg SDBM_File)
1968 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
1969 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
1970
1971 push @m,
1972q{ $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
1973 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
1974 $(CHMOD) 755 $@
1975};
1976
1977# Old mechanism - still available:
1978
1979 push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs}."\n\n"
1980 if $self->{PERL_SRC};
1981
1982 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1983 join('', "\n",@m);
1984}
1985
1986=item installpm
1987
1988
1989
1990=cut
1991
1992sub installpm {
1993 my($self, %attribs) = @_;
1994 unless (ref $self){
1995 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
1996 $self = $ExtUtils::MakeMaker::Parent[-1];
1997 }
1998 # By default .pm files are split into the architecture independent
1999 # library. This is a good thing. If a specific module requires that
2000 # it's .pm files are split into the architecture specific library
2001 # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
2002 # Note that installperl currently interferes with this (Config.pm)
2003 # User can disable split by saying: installpm => {SPLITLIB=>''}
2004 my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
2005 $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
2006 my(@m, $dist);
2007 push @m, "inst_pm :: \$(INST_PM)\n\n";
2008 foreach $dist (sort keys %{$self->{PM}}){
2009 my($inst) = $self->{PM}->{$dist};
2010 push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
2011 push(@m, $self->installpm_x($dist, $inst, $splitlib));
2012 push(@m, "\n");
2013 }
2014 join('', @m);
2015}
2016
2017=item installpm_x
2018
2019
2020
2021=cut
2022
2023sub installpm_x { # called by installpm per file
2024 my($self, $dist, $inst, $splitlib) = @_;
2025 unless (ref $self){
2026 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2027 $self = $ExtUtils::MakeMaker::Parent[-1];
2028 }
2029 if ($inst =~ m,[:\#],){
2030 warn "Warning: 'make' would have problems processing this file: '$inst', SKIPPED\n";
2031 return '';
2032 }
2033 my($instdir) = $inst =~ m|(.*)/|;
2034 my(@m);
2035 push(@m,"
2036$inst: $dist $self->{MAKEFILE} $instdir/.exists \$(INST_ARCHAUTODIR)/.exists
2037 $self->{NOECHO}$self->{RM_F}".' $@
2038 $(UMASK_NULL) && '."$self->{CP} $dist".' $@
2039');
2040 push(@m, "\t$self->{NOECHO}\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
2041 if ($splitlib and $inst =~ m/\.pm$/);
2042
2043 push @m, $self->dir_target($instdir);
2044 join('', @m);
2045}
2046
2047=item manifypods
2048
2049
2050
2051=cut
2052
2053sub manifypods {
2054 my($self, %attribs) = @_;
2055 unless (ref $self){
2056 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2057 $self = $ExtUtils::MakeMaker::Parent[-1];
2058 }
2059 return "\nmanifypods :\n" unless %{$self->{MAN3PODS}};
2060 my($dist);
2061 my($pod2man_exe);
2062 if (defined $self->{PERL_SRC}) {
2063 $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
2064 } else {
2065 $pod2man_exe = $self->catfile($Config{bin},'pod2man');
2066 }
2067 unless ($self->perl_script($pod2man_exe)) {
2068 # No pod2man but some MAN3PODS to be installed
2069 print <<END;
2070
2071Warning: I could not locate your pod2man program. Please make sure,
2072 your pod2man program is in your PATH before you execute 'make'
2073
2074END
2075 $pod2man_exe = "-S pod2man";
2076 }
2077 my(@m);
2078 push @m,
2079qq[POD2MAN_EXE = $pod2man_exe\n],
2080q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\
2081-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\
2082-e 'print "Manifying $$m{$$_}\n";' \\
2083-e 'system("$$^X \\"-I$(PERL_ARCHLIB)\\" \\"-I$(PERL_LIB)\\" $(POD2MAN_EXE) $$_>$$m{$$_}")==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
2084-e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}'
2085];
2086 push @m, "\nmanifypods : ";
2087 push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
2088
2089 push(@m,"\n");
2090 if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
2091 push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
2092 push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
2093 }
2094 join('', @m);
2095}
2096
2097=item processPL
2098
2099
2100
2101=cut
2102
2103sub processPL {
2104 my($self) = shift;
2105 unless (ref $self){
2106 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2107 $self = $ExtUtils::MakeMaker::Parent[-1];
2108 }
2109 return "" unless $self->{PL_FILES};
2110 my(@m, $plfile);
2111 foreach $plfile (sort keys %{$self->{PL_FILES}}) {
2112 push @m, "
2113all :: $self->{PL_FILES}->{$plfile}
2114
2115$self->{PL_FILES}->{$plfile} :: $plfile
2116 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
2117";
2118 }
2119 join "", @m;
2120}
2121
2122=item installbin
2123
2124
2125
2126=cut
2127
2128sub installbin {
2129 my($self) = shift;
2130 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2131 return "" unless @{$self->{EXE_FILES}};
2132 my(@m, $from, $to, %fromto, @to);
2133 push @m, $self->dir_target(qw[$(INST_EXE)]);
2134 for $from (@{$self->{EXE_FILES}}) {
2135 my($path)= '$(INST_EXE)/' . basename($from);
2136 local($_) = $path; # for backwards compatibility
2137 $to = $self->libscan($path);
2138 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2139 $fromto{$from}=$to;
2140 }
2141 @to = values %fromto;
2142 push(@m, "
2143EXE_FILES = @{$self->{EXE_FILES}}
2144
2145all :: @to
2146
2147realclean ::
2148 $self->{RM_F} @to
2149");
2150
2151 while (($from,$to) = each %fromto) {
2152 my $todir = dirname($to);
2153 push @m, "
2154$to: $from $self->{MAKEFILE} $todir/.exists
2155 $self->{CP} $from $to
2156";
2157 }
2158 join "", @m;
2159}
2160
2161=item subdirs
2162
2163
2164
2165=cut
2166
2167sub subdirs {
2168# --- Sub-directory Sections ---
2169 my($self) = shift;
2170 unless (ref $self){
2171 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2172 $self = $ExtUtils::MakeMaker::Parent[-1];
2173 }
2174 my(@m,$dir);
2175 # This method provides a mechanism to automatically deal with
2176 # subdirectories containing further Makefile.PL scripts.
2177 # It calls the subdir_x() method for each subdirectory.
2178 foreach $dir (@{$self->{DIR}}){
2179 push(@m, $self->subdir_x($dir));
2180#### print "Including $dir subdirectory\n";
2181 }
2182 if (@m){
2183 unshift(@m, "
2184# The default clean, realclean and test targets in this Makefile
2185# have automatically been given entries for each subdir.
2186
2187");
2188 } else {
2189 push(@m, "\n# none")
2190 }
2191 join('',@m);
2192}
2193
2194=item subdir_x
2195
2196
2197
2198=cut
2199
2200sub subdir_x {
2201 my($self, $subdir) = @_;
2202 unless (ref $self){
2203 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2204 $self = $ExtUtils::MakeMaker::Parent[-1];
2205 }
2206 my(@m);
2207 qq{
2208
2209subdirs ::
2210 $self->{NOECHO}-cd $subdir && \$(MAKE) all \$(PASTHRU)
2211
2212};
2213}
2214
2215=item clean
2216
2217
2218
2219=cut
2220
2221sub clean {
2222# --- Cleanup and Distribution Sections ---
2223
2224 my($self, %attribs) = @_;
2225 unless (ref $self){
2226 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2227 $self = $ExtUtils::MakeMaker::Parent[-1];
2228 }
2229 my(@m,$dir);
2230 push(@m, '
2231# Delete temporary files but do not touch installed files. We don\'t delete
2232# the Makefile here so a later make realclean still has a makefile to use.
2233
2234clean ::
2235');
2236 # clean subdirectories first
2237 for $dir (@{$self->{DIR}}) {
2238 push @m, "\t-cd $dir && test -f $self->{MAKEFILE} && \$(MAKE) clean\n";
2239 }
2240
2241 my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
2242 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
2243 push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all
2244 perlmain.c mon.out core so_locations
2245 *~ */*~ */*/*~
2246 *$(OBJ_EXT) *$(LIB_EXT)
2247 perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp
2248 ]);
2249 push @m, "\t-$self->{RM_RF} @otherfiles\n";
2250 # See realclean and ext/utils/make_ext for usage of Makefile.old
2251 push(@m,
2252 "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old 2>/dev/null\n");
2253 push(@m,
2254 "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
2255 join("", @m);
2256}
2257
2258=item realclean
2259
2260
2261
2262=cut
2263
2264sub realclean {
2265 my($self, %attribs) = @_;
2266 unless (ref $self){
2267 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2268 $self = $ExtUtils::MakeMaker::Parent[-1];
2269 }
2270 my(@m);
2271 push(@m,'
2272# Delete temporary files (via clean) and also delete installed files
2273realclean purge :: clean
2274');
2275 # realclean subdirectories first (already cleaned)
2276 my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
2277 foreach(@{$self->{DIR}}){
2278 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
2279 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
2280 }
2281 push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
2282 push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
2283 push(@m, " $self->{RM_F} \$(INST_STATIC) \$(INST_PM)\n");
2284 my(@otherfiles) = ($self->{MAKEFILE},
2285 "$self->{MAKEFILE}.old"); # Makefiles last
2286 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
2287 push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles;
2288 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
2289 join("", @m);
2290}
2291
2292=item dist_basics
2293
2294
2295
2296=cut
2297
2298sub dist_basics {
2299 my($self) = shift;
2300 unless (ref $self){
2301 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2302 $self = $ExtUtils::MakeMaker::Parent[-1];
2303 }
2304 my @m;
2305 push @m, q{
2306distclean :: realclean distcheck
2307};
2308
2309 push @m, q{
2310distcheck :
2311 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\
2312 -e 'fullcheck();'
2313};
2314
2315 push @m, q{
2316skipcheck :
2317 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&skipcheck";' \\
2318 -e 'skipcheck();'
2319};
2320
2321 push @m, q{
2322manifest :
2323 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\
2324 -e 'mkmanifest();'
2325};
2326 join "", @m;
2327}
2328
2329=item dist_core
2330
2331
2332
2333=cut
2334
2335sub dist_core {
2336 my($self) = shift;
2337 unless (ref $self){
2338 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2339 $self = $ExtUtils::MakeMaker::Parent[-1];
2340 }
2341 my @m;
2342 push @m, q{
2343dist : $(DIST_DEFAULT)
2344
2345tardist : $(DISTVNAME).tar.$(SUFFIX)
2346
2347$(DISTVNAME).tar.$(SUFFIX) : distdir
2348 $(PREOP)
2349 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
2350 $(RM_RF) $(DISTVNAME)
2351 $(COMPRESS) $(DISTVNAME).tar
2352 $(POSTOP)
2353
2354uutardist : $(DISTVNAME).tar.$(SUFFIX)
2355 uuencode $(DISTVNAME).tar.$(SUFFIX) \\
2356 $(DISTVNAME).tar.$(SUFFIX) > \\
2357 $(DISTVNAME).tar.$(SUFFIX).uu
2358
2359shdist : distdir
2360 $(PREOP)
2361 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
2362 $(RM_RF) $(DISTVNAME)
2363 $(POSTOP)
2364};
2365 join "", @m;
2366}
2367
2368=item dist_dir
2369
2370
2371
2372=cut
2373
2374sub dist_dir {
2375 my($self) = shift;
2376 unless (ref $self){
2377 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2378 $self = $ExtUtils::MakeMaker::Parent[-1];
2379 }
2380 my @m;
2381 push @m, q{
2382distdir :
2383 $(RM_RF) $(DISTVNAME)
2384 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "/mani/";' \\
2385 -e 'manicopy(maniread(),"$(DISTVNAME)", "$(DIST_CP)");'
2386};
2387 join "", @m;
2388}
2389
2390=item dist_test
2391
2392
2393
2394=cut
2395
2396sub dist_test {
2397 my($self) = shift;
2398 unless (ref $self){
2399 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2400 $self = $ExtUtils::MakeMaker::Parent[-1];
2401 }
2402 my @m;
2403 push @m, q{
2404disttest : distdir
2405 cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
2406 cd $(DISTVNAME) && $(MAKE)
2407 cd $(DISTVNAME) && $(MAKE) test
2408};
2409 join "", @m;
2410}
2411
2412=item dist_ci
2413
2414
2415
2416=cut
2417
2418sub dist_ci {
2419 my($self) = shift;
2420 unless (ref $self){
2421 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2422 $self = $ExtUtils::MakeMaker::Parent[-1];
2423 }
2424 my @m;
2425 push @m, q{
2426ci :
2427 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\
2428 -e '@all = keys %{ maniread() };' \\
2429 -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
2430 -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
2431};
2432 join "", @m;
2433}
2434
2435=item install
2436
2437
2438
2439=cut
2440
2441sub install {
2442 my($self, %attribs) = @_;
2443 unless (ref $self){
2444 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2445 $self = $ExtUtils::MakeMaker::Parent[-1];
2446 }
2447 my(@m);
2448
2449 push @m, q{
2450install :: all pure_install doc_install
2451
2452install_perl :: pure_perl_install doc_perl_install
2453
2454install_site :: pure_site_install doc_site_install
2455
2456install_ :: install_site
2457 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2458
2459pure_install :: pure_$(INSTALLDIRS)_install
2460
2461doc_install :: doc_$(INSTALLDIRS)_install
2462 }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
2463
2464pure__install : pure_site_install
2465 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2466
2467doc__install : doc_site_install
2468 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2469
2470pure_perl_install ::
2471 }.$self->{NOECHO}.q{$(MOD_INSTALL) \
2472 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2473 write }.$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2474 $(INST_LIB) $(INSTALLPRIVLIB) \
2475 $(INST_ARCHLIB) $(INSTALLARCHLIB) \
2476 $(INST_EXE) $(INSTALLBIN) \
2477 $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
2478 $(INST_MAN3DIR) $(INSTALLMAN3DIR)
2479 }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
2480 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2481
2482
2483pure_site_install ::
2484 }.$self->{NOECHO}.q{$(MOD_INSTALL) \
2485 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2486 write }.$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2487 $(INST_LIB) $(INSTALLSITELIB) \
2488 $(INST_ARCHLIB) $(INSTALLSITEARCH) \
2489 $(INST_EXE) $(INSTALLBIN) \
2490 $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
2491 $(INST_MAN3DIR) $(INSTALLMAN3DIR)
2492 }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
2493 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2494
2495doc_perl_install ::
2496 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
2497 "$(NAME)" \
2498 "installed into" "$(INSTALLPRIVLIB)" \
2499 LINKTYPE "$(LINKTYPE)" \
2500 VERSION "$(VERSION)" \
2501 EXE_FILES "$(EXE_FILES)" \
2502 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
2503
2504doc_site_install ::
2505 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
2506 "Module $(NAME)" \
2507 "installed into" "$(INSTALLSITELIB)" \
2508 LINKTYPE "$(LINKTYPE)" \
2509 VERSION "$(VERSION)" \
2510 EXE_FILES "$(EXE_FILES)" \
2511 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
2512
2513};
2514
2515 push @m, q{
2516uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2517
2518uninstall_from_perldirs ::
2519 }.$self->{NOECHO}.
2520 q{$(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2521
2522uninstall_from_sitedirs ::
2523 }.$self->{NOECHO}.
2524 q{$(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2525};
2526
2527 join("",@m);
2528}
2529
2530=item force
2531
2532
2533
2534=cut
2535
2536sub force {
2537 my($self) = shift;
2538 unless (ref $self){
2539 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2540 $self = $ExtUtils::MakeMaker::Parent[-1];
2541 }
2542 '# Phony target to force checking subdirectories.
2543FORCE:
2544';
2545}
2546
2547=item perldepend
2548
2549
2550
2551=cut
2552
2553sub perldepend {
2554 my($self) = shift;
2555 unless (ref $self){
2556 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2557 $self = $ExtUtils::MakeMaker::Parent[-1];
2558 }
2559 my(@m);
2560 push(@m,'
2561PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
2562 $(PERL_INC)/XSUB.h $(PERL_INC)/av.h $(PERL_INC)/cop.h \
2563 $(PERL_INC)/cv.h $(PERL_INC)/dosish.h $(PERL_INC)/embed.h \
2564 $(PERL_INC)/form.h $(PERL_INC)/gv.h $(PERL_INC)/handy.h \
2565 $(PERL_INC)/hv.h $(PERL_INC)/keywords.h $(PERL_INC)/mg.h \
2566 $(PERL_INC)/op.h $(PERL_INC)/opcode.h $(PERL_INC)/patchlevel.h \
2567 $(PERL_INC)/perl.h $(PERL_INC)/perly.h $(PERL_INC)/pp.h \
2568 $(PERL_INC)/proto.h $(PERL_INC)/regcomp.h $(PERL_INC)/regexp.h \
2569 $(PERL_INC)/scope.h $(PERL_INC)/sv.h $(PERL_INC)/unixish.h \
2570 $(PERL_INC)/util.h $(PERL_INC)/config.h
2571
2572');
2573
2574 push @m, '
2575$(OBJECT) : $(PERL_HDRS)
2576' if $self->{OBJECT};
2577
2578 push(@m,'
2579# Check for unpropogated config.sh changes. Should never happen.
2580# We do NOT just update config.h because that is not sufficient.
2581# An out of date config.h is not fatal but complains loudly!
2582$(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2583 -'.$self->{NOECHO}.'echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2584
2585$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2586 '.$self->{NOECHO}.'echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2587 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
2588') if $self->{PERL_SRC};
2589
2590 push(@m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n")
2591 if %{$self->{XS}};
2592 join("\n",@m);
2593}
2594
2595=item makefile
2596
2597
2598
2599=cut
2600
2601sub makefile {
2602 my($self) = shift;
2603 unless (ref $self){
2604 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2605 $self = $ExtUtils::MakeMaker::Parent[-1];
2606 }
2607 my @m;
2608 # We do not know what target was originally specified so we
2609 # must force a manual rerun to be sure. But as it should only
2610 # happen very rarely it is not a significant problem.
2611 push @m, '
2612$(OBJECT) : $(FIRST_MAKEFILE)
2613' if $self->{OBJECT};
2614
2615 push @m, '
2616# We take a very conservative approach here, but it\'s worth it.
2617# We move Makefile to Makefile.old here to avoid gnu make looping.
2618'.$self->{MAKEFILE}.' : Makefile.PL $(CONFIGDEP)
2619 '.$self->{NOECHO}.'echo "Makefile out-of-date with respect to $?"
2620 '.$self->{NOECHO}.'echo "Cleaning current config before rebuilding Makefile..."
2621 -'.$self->{NOECHO}.'mv '."$self->{MAKEFILE} $self->{MAKEFILE}.old".'
2622 -$(MAKE) -f '.$self->{MAKEFILE}.'.old clean >/dev/null 2>&1 || true
2623 $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL '.join(" ",map(qq["$_"],@ARGV)).'
2624 '.$self->{NOECHO}.'echo ">>> Your Makefile has been rebuilt. <<<"
2625 '.$self->{NOECHO}.'echo ">>> Please rerun the make command. <<<"; false
2626';
2627
2628 join "", @m;
2629}
2630
2631=item staticmake
2632
2633
2634
2635=cut
2636
2637sub staticmake {
2638 my($self, %attribs) = @_;
2639 unless (ref $self){
2640 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2641 $self = $ExtUtils::MakeMaker::Parent[-1];
2642 }
2643 my(@static);
2644
2645 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
2646
2647 # And as it's not yet built, we add the current extension
2648 # but only if it has some C code (or XS code, which implies C code)
2649 if (@{$self->{C}}) {
2650 @static="$self->{INST_ARCHLIB}/auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}";
2651 }
2652
2653 # Either we determine now, which libraries we will produce in the
2654 # subdirectories or we do it at runtime of the make.
2655
2656 # We could ask all subdir objects, but I cannot imagine, why it
2657 # would be necessary.
2658
2659 # Instead we determine all libraries for the new perl at
2660 # runtime.
2661 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
2662
2663 $self->makeaperl(MAKE => $self->{MAKEFILE},
2664 DIRS => \@searchdirs,
2665 STAT => \@static,
2666 INCL => \@perlinc,
2667 TARGET => $self->{MAP_TARGET},
2668 TMP => "",
2669 LIBPERL => $self->{LIBPERL_A}
2670 );
2671}
2672
2673=item test
2674
2675
2676
2677=cut
2678
2679sub test {
2680# --- Test and Installation Sections ---
2681
2682 my($self, %attribs) = @_;
2683 unless (ref $self){
2684 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2685 $self = $ExtUtils::MakeMaker::Parent[-1];
2686 }
2687 my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
2688 my(@m);
2689 push(@m,"
2690TEST_VERBOSE=0
2691TEST_TYPE=test_\$(LINKTYPE)
2692
2693test :: \$(TEST_TYPE)
2694");
2695 push(@m, map("\t$self->{NOECHO}cd $_ && test -f $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
2696 @{$self->{DIR}}));
2697 push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n")
2698 unless $tests or -f "test.pl" or @{$self->{DIR}};
2699 push(@m, "\n");
2700
2701 push(@m, "test_dynamic :: all\n");
2702 push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
2703 push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
2704 push(@m, "\n");
2705
2706 # Occasionally we may face this degenerate target:
2707 push @m, "test_ : test_dynamic\n\n";
2708
2709 if ($self->needs_linking()) {
2710 push(@m, "test_static :: all \$(MAP_TARGET)\n");
2711 push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
2712 push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
2713 push(@m, "\n");
2714 } else {
2715 push @m, "test_static :: test_dynamic\n";
2716 }
2717 join("", @m);
2718}
2719
2720=item test_via_harness
2721
2722
2723
2724=cut
2725
2726sub test_via_harness {
2727 my($self, $perl, $tests) = @_;
2728 unless (ref $self){
2729 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2730 $self = $ExtUtils::MakeMaker::Parent[-1];
2731 }
2732 "\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";
2733}
2734
2735=item test_via_script
2736
2737
2738
2739=cut
2740
2741sub test_via_script {
2742 my($self, $perl, $script) = @_;
2743 unless (ref $self){
2744 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2745 $self = $ExtUtils::MakeMaker::Parent[-1];
2746 }
2747 qq{\tPERL_DL_NONLAZY=1 $perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script
2748};
2749}
2750
2751=item postamble
2752
2753Returns an empty string. Can be used in Makefile.PLs to write some
2754text to the Makefile at the end.
2755
2756=cut
2757
2758sub postamble {
2759 my($self) = shift;
2760 unless (ref $self){
2761 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2762 $self = $ExtUtils::MakeMaker::Parent[-1];
2763 }
2764 "";
2765}
2766
2767=item makeaperl
2768
2769Called by staticmake.
2770
2771=cut
2772
2773sub makeaperl {
2774 my($self, %attribs) = @_;
2775 unless (ref $self){
2776 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2777 $self = $ExtUtils::MakeMaker::Parent[-1];
2778 }
2779 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2780 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2781 my(@m);
2782 push @m, "
2783# --- MakeMaker makeaperl section ---
2784MAP_TARGET = $target
2785FULLPERL = $self->{FULLPERL}
2786";
2787 return join '', @m if $self->{PARENT};
2788
2789 my($dir) = join ":", @{$self->{DIR}};
2790
2791 unless ($self->{MAKEAPERL}) {
2792 push @m, q{
2793$(MAP_TARGET) :: $(MAKE_APERL_FILE)
2794 $(MAKE) -f $(MAKE_APERL_FILE) static $@
2795
2796$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2797 }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2798 }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
2799 Makefile.PL DIR=}, $dir, q{ \
2800 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2801 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2802
2803 push @m, map( " \\\n\t\t$_", @ARGV );
2804 push @m, "\n";
2805
2806 return join '', @m;
2807 }
2808
2809
2810
2811 my($cccmd, $linkcmd, $lperl);
2812
2813
2814 $cccmd = $self->const_cccmd($libperl);
2815 $cccmd =~ s/^CCCMD\s*=\s*//;
2816 $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /;
2817 $cccmd .= " $Config::Config{cccdlflags}" if ($Config::Config{d_shrplib});
2818 $cccmd =~ s/\n/ /g; # yes I've seen "\n", don't ask me where it came from. A.K.
2819 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2820
2821 # The front matter of the linkcommand...
2822 $linkcmd = join ' ', "\$(CC)",
2823 grep($_, @Config{qw(large split ldflags ccdlflags)});
2824 $linkcmd =~ s/\s+/ /g;
2825
2826 # Which *.a files could we make use of...
2827 local(%static);
2828 File::Find::find(sub {
2829 return unless m/\Q$self->{LIB_EXT}\E$/;
2830 return if m/^libperl/;
2831 # don't include the installed version of this extension. I
2832 # leave this line here, although it is not necessary anymore:
2833 # I patched minimod.PL instead, so that Miniperl.pm won't
2834 # enclude duplicates
2835
2836 # Once the patch to minimod.PL is in the distribution, I can
2837 # drop it
2838 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:;
2839 $static{fastcwd() . "/" . $_}++;
2840 }, grep( -d $_, @{$searchdirs || []}) );
2841
2842 # We trust that what has been handed in as argument, will be buildable
2843 $static = [] unless $static;
2844 @static{@{$static}} = (1) x @{$static};
2845
2846 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2847 for (sort keys %static) {
2848 next unless /\Q$self->{LIB_EXT}\E$/;
2849 $_ = dirname($_) . "/extralibs.ld";
2850 push @$extra, $_;
2851 }
2852
2853 grep(s/^/-I/, @{$perlinc || []});
2854
2855 $target = "perl" unless $target;
2856 $tmp = "." unless $tmp;
2857
2858# MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2859# regenerate the Makefiles, MAP_STATIC and the dependencies for
2860# extralibs.all are computed correctly
2861 push @m, "
2862MAP_LINKCMD = $linkcmd
2863MAP_PERLINC = @{$perlinc || []}
2864MAP_STATIC = ",
2865join(" \\\n\t", reverse sort keys %static), "
2866
2867MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
2868";
2869
2870 if (defined $libperl) {
2871 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2872 }
2873 unless ($libperl && -f $lperl) { # Ilya's code...
2874 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2875 $libperl ||= "libperl$self->{LIB_EXT}";
2876 $libperl = "$dir/$libperl";
2877 $lperl ||= "libperl$self->{LIB_EXT}";
2878 $lperl = "$dir/$lperl";
2879 print STDOUT "Warning: $libperl not found
2880 If you're going to build a static perl binary, make sure perl is installed
2881 otherwise ignore this warning\n"
2882 unless (-f $lperl || defined($self->{PERL_SRC}));
2883 }
2884
2885 push @m, "
2886MAP_LIBPERL = $libperl
2887";
2888
2889 push @m, "
2890\$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)."
2891 $self->{NOECHO}$self->{RM_F} \$\@
2892 $self->{NOECHO}\$(TOUCH) \$\@
2893";
2894
2895 my $catfile;
2896 foreach $catfile (@$extra){
2897 push @m, "\tcat $catfile >> \$\@\n";
2898 }
2899
2900 push @m, "
2901\$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2902 \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2903 $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
2904 $self->{NOECHO}echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2905 $self->{NOECHO}echo 'To remove the intermediate files say'
2906 $self->{NOECHO}echo ' make -f $makefilename map_clean'
2907
2908$tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2909";
2910 push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n";
2911
2912 push @m, qq{
2913$tmp/perlmain.c: $makefilename}, q{
2914 }.$self->{NOECHO}.q{echo Writing $@
2915 }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
2916 writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@
2917
2918};
2919
2920 push @m, q{
2921doc_inst_perl:
2922 }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
2923 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
2924 "Perl binary $(MAP_TARGET)" \
2925 MAP_STATIC "$(MAP_STATIC)" \
2926 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2927 MAP_LIBPERL "$(MAP_LIBPERL)" \
2928 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
2929
2930};
2931
2932 push @m, qq{
2933inst_perl: pure_inst_perl doc_inst_perl
2934
2935pure_inst_perl: \$(MAP_TARGET)
2936 $self->{CP} \$(MAP_TARGET) \$(INSTALLBIN)/\$(MAP_TARGET)
2937
2938clean :: map_clean
2939
2940map_clean :
2941 $self->{RM_F} $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2942};
2943
2944 join '', @m;
2945}
2946
2947=item extliblist
2948
2949Called by init_others.
2950
2951=cut
2952
2953sub extliblist {
2954 my($self,$libs) = @_;
2955 unless (ref $self){
2956 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2957 $self = $ExtUtils::MakeMaker::Parent[-1];
2958 }
2959 $self->ext($libs, $Verbose);
2960}
2961
2962=item dir_target
2963
2964Takes an array of directories that need to exist and returns a
2965Makefile entry for a .exists file in these directories. Returns
2966nothing, if the entry has already been processed. We're helpless
2967though, if the same directory comes as $(FOO) _and_ as "bar". Both of
2968them get an entry, that's why we use "::".
2969
2970=cut
2971
2972sub dir_target {
2973# --- Make-Directories section (internal method) ---
2974# dir_target(@array) returns a Makefile entry for the file .exists in each
2975# named directory. Returns nothing, if the entry has already been processed.
2976# We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
2977# Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
2978# prerequisite, because there has to be one, something that doesn't change
2979# too often :)
2980
2981 my($self,@dirs) = @_;
2982 unless (ref $self){
2983 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
2984 $self = $ExtUtils::MakeMaker::Parent[-1];
2985 }
2986 my(@m,$dir);
2987 foreach $dir (@dirs) {
2988 next if $self->{DIR_TARGET}{$self}{$dir}++;
2989 push @m, qq{
2990$dir/.exists :: }.$self->catfile($self->{PERL_INC},"perl.h").qq{
2991 $self->{NOECHO}\$(MKPATH) $dir
2992 $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) \$(PERL) $dir/.exists
2993 -$self->{NOECHO}\$(CHMOD) 755 $dir
2994};
2995 }
2996 join "", @m;
2997}
2998
2999=item needs_linking
3000
3001Does this module need linking? Looks into subdirectory objects (see
3002also has_link_code())
3003
3004=cut
3005
3006sub needs_linking {
3007 my($self) = shift;
3008 my($child,$caller);
3009 $caller = (caller(0))[3];
3010 unless (ref $self){
3011 ExtUtils::MakeMaker::TieAtt::warndirectuse($caller);
3012 $self = $ExtUtils::MakeMaker::Parent[-1];
3013 }
3014 Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/;
3015 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
3016 if ($self->has_link_code or $self->{MAKEAPERL}){
3017 $self->{NEEDS_LINKING} = 1;
3018 return 1;
3019 }
3020 foreach $child (keys %{$self->{CHILDREN}}) {
3021 if ($self->{CHILDREN}->{$child}->needs_linking) {
3022 $self->{NEEDS_LINKING} = 1;
3023 return 1;
3024 }
3025 }
3026 return $self->{NEEDS_LINKING} = 0;
3027}
3028
3029=item has_link_code
3030
3031Returns true if C, XS, MYEXTLIB or similar objects exist within this
3032object that need a compiler. Does not descend into subdirectories as
3033needs_linking() does.
3034
3035=cut
3036
3037sub has_link_code {
3038 my($self) = shift;
3039 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
3040 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
3041 $self->{HAS_LINK_CODE} = 1;
3042 return 1;
3043 }
3044 return $self->{HAS_LINK_CODE} = 0;
3045}
3046
3047=item writedoc
3048
3049Obsolete, depecated method.
3050
3051=cut
3052
3053sub writedoc {
3054# --- perllocal.pod section ---
3055 my($self,$what,$name,@attribs)=@_;
3056 unless (ref $self){
3057 ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]);
3058 $self = $ExtUtils::MakeMaker::Parent[-1];
3059 }
3060 my $time = localtime;
3061 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3062 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3063 print "\n\n=back\n\n";
3064}
3065
3066=head1 SEE ALSO
3067
3068L<ExtUtils::MakeMaker>
3069
3070=cut
3071
30721;
3073