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