1 package ExtUtils
::MM_Any
;
4 use vars
qw($VERSION @ISA);
8 BEGIN { @ISA = qw(File::Spec); }
11 use ExtUtils
::MakeMaker
qw($Verbose);
13 use ExtUtils::MakeMaker::Config;
16 # So we don't have to keep calling the methods over and over again,
17 # we have these globals to cache the values. Faster and shrtr.
18 my $Curdir = __PACKAGE__->curdir;
19 my $Rootdir = __PACKAGE__->rootdir;
20 my $Updir = __PACKAGE__->updir;
25 ExtUtils::MM_Any - Platform-agnostic MM methods
29 FOR INTERNAL USE ONLY!
31 package ExtUtils::MM_SomeOS;
33 # Temporarily, you have to subclass both. Put MM_Any first.
34 require ExtUtils::MM_Any;
35 require ExtUtils::MM_Unix;
36 @ISA = qw(ExtUtils::MM_Any ExtUtils::Unix);
40 B<FOR INTERNAL USE ONLY!>
42 ExtUtils::MM_Any is a superclass for the ExtUtils::MM_* set of
43 modules. It contains methods which are either inherently
44 cross-platform or are written in a cross-platform manner.
46 Subclass off of ExtUtils::MM_Any I<and> ExtUtils::MM_Unix. This is a
49 B<THIS MAY BE TEMPORARY!>
54 Any methods marked I<Abstract> must be implemented by subclasses.
57 =head2 Cross-platform helper methods
59 These are methods which help writing cross-platform code.
63 =head3 os_flavor I<Abstract>
65 my @os_flavor = $mm->os_flavor;
67 @os_flavor is the style of operating system this is, usually
68 corresponding to the MM_*.pm file we're using.
70 The first element of @os_flavor is the major family (ie. Unix,
71 Windows, VMS, OS/2, etc...) and the rest are sub families.
75 Cygwin98 ('Unix', 'Cygwin', 'Cygwin9x')
76 Windows NT ('Win32', 'WinNT')
77 Win98 ('Win32', 'Win9x')
78 Linux ('Unix', 'Linux')
79 MacOS X ('Unix', 'Darwin', 'MacOS', 'MacOS X')
82 This is used to write code for styles of operating system.
83 See os_flavor_is() for use.
88 my $is_this_flavor = $mm->os_flavor_is($this_flavor);
89 my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
91 Checks to see if the current operating system is one of the given flavors.
93 This is useful for code like:
95 if( $mm->os_flavor_is('Unix') ) {
106 my %flavors = map { ($_ => 1) } $self->os_flavor;
107 return (grep { $flavors{$_} } @_) ?
1 : 0;
113 my @cmds = $MM->split_command($cmd, @args);
115 Most OS have a maximum command length they can execute at once. Large
116 modules can easily generate commands well past that limit. Its
117 necessary to split long commands up into a series of shorter commands.
119 C<split_command> will return a series of @cmds each processing part of
120 the args. Collectively they will process all the arguments. Each
121 individual line in @cmds will not be longer than the
122 $self->max_exec_len being careful to take into account macro expansion.
124 $cmd should include any switches and repeated initial arguments.
126 If no @args are given, no @cmds will be returned.
128 Pairs of arguments will always be preserved in a single command, this
129 is a heuristic for things like pm_to_blib and pod2man which work on
130 pairs of arguments. This makes things like this safe:
132 $self->split_command($cmd, %pod2man);
138 my($self, $cmd, @args) = @_;
141 return(@cmds) unless @args;
143 # If the command was given as a here-doc, there's probably a trailing
147 # set aside 20% for macro expansion.
148 my $len_left = int($self->max_exec_len * 0.80);
149 $len_left -= length $self->_expand_macros($cmd);
154 while( @next_args = splice(@args, 0, 2) ) {
155 # Two at a time to preserve pairs.
156 my $next_arg_str = "\t ". join ' ', @next_args, "\n";
158 if( !length $arg_str ) {
159 $arg_str .= $next_arg_str
161 elsif( length($arg_str) + length($next_arg_str) > $len_left ) {
162 unshift @args, @next_args;
166 $arg_str .= $next_arg_str;
171 push @cmds, $self->escape_newlines("$cmd \n$arg_str");
179 my($self, $cmd) = @_;
181 $cmd =~ s
{\
$\
((\w
+)\
)}{
182 defined $self->{$1} ?
$self->{$1} : "\$($1)"
190 my @commands = $MM->echo($text);
191 my @commands = $MM->echo($text, $file);
192 my @commands = $MM->echo($text, $file, $appending);
194 Generates a set of @commands which print the $text to a $file.
196 If $file is not given, output goes to STDOUT.
198 If $appending is true the $file will be appended to rather than
204 my($self, $text, $file, $appending) = @_;
207 my @cmds = map { '$(NOECHO) $(ECHO) '.$self->quote_literal($_) }
210 my $redirect = $appending ?
'>>' : '>';
211 $cmds[0] .= " $redirect $file";
212 $_ .= " >> $file" foreach @cmds[1..$#cmds];
221 my $args = $mm->wraplist(@list);
223 Takes an array of items and turns them into a well-formatted list of
224 arguments. In most cases this is simply something like:
234 return join " \\\n\t", @_;
238 =head3 cd I<Abstract>
240 my $subdir_cmd = $MM->cd($subdir, @cmds);
242 This will generate a make fragment which runs the @cmds in the given
243 $dir. The rough equivalent to this, except cross platform.
247 Currently $dir can only go down one level. "foo" is fine. "foo/bar" is
248 not. "../foo" is right out.
250 The resulting $subdir_cmd has no leading tab nor trailing newline. This
251 makes it easier to embed in a make string. For example.
253 my $make = sprintf <<'CODE', $subdir_cmd;
261 =head3 oneliner I<Abstract>
263 my $oneliner = $MM->oneliner($perl_code);
264 my $oneliner = $MM->oneliner($perl_code, \@switches);
266 This will generate a perl one-liner safe for the particular platform
267 you're on based on the given $perl_code and @switches (a -e is
268 assumed) suitable for using in a make target. It will use the proper
269 shell quoting and escapes.
271 $(PERLRUN) will be used as perl.
273 Any newlines in $perl_code will be escaped. Leading and trailing
274 newlines will be stripped. Makes this idiom much easier:
276 my $code = $MM->oneliner(<<'CODE', [...switches...]);
281 Usage might be something like:
284 $oneliner = $MM->oneliner('print "Foo\n"');
285 $make = '$oneliner > somefile';
287 All dollar signs must be doubled in the $perl_code if you expect them
288 to be interpreted normally, otherwise it will be considered a make
289 macro. Also remember to quote make macros else it might be used as a
290 bareword. For example:
292 # Assign the value of the $(VERSION_FROM) make macro to $vf.
293 $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');
295 Its currently very simple and may be expanded sometime in the figure
296 to include more flexible code and switches.
299 =head3 quote_literal I<Abstract>
301 my $safe_text = $MM->quote_literal($text);
303 This will quote $text so it is interpreted literally in the shell.
305 For example, on Unix this would escape any single-quotes in $text and
306 put single-quotes around the whole thing.
309 =head3 escape_newlines I<Abstract>
311 my $escaped_text = $MM->escape_newlines($text);
313 Shell escapes newlines in $text.
316 =head3 max_exec_len I<Abstract>
318 my $max_exec_len = $MM->max_exec_len;
320 Calculates the maximum command size the OS can exec. Effectively,
321 this is the max size of a shell command line.
324 $self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes.
332 These are methods which produce make targets.
337 Generate the default target 'all'.
352 =head3 blibdirs_target
354 my $make_frag = $mm->blibdirs_target;
356 Creates the blibdirs target which creates all the directories we use
359 The blibdirs.ts target is deprecated. Depend on blibdirs instead.
364 sub blibdirs_target {
367 my @dirs = map { uc "\$(INST_$_)" } qw(libdir archlib
373 my @exists = map { $_.'$(DFSEP).exists' } @dirs;
375 my $make = sprintf <<'MAKE', join(' ', @exists);
379 # Backwards compat with 6.18 through 6.25
380 blibdirs.ts : blibdirs
385 $make .= $self->dir_target(@dirs);
393 Defines the clean target.
398 # --- Cleanup and Distribution Sections ---
400 my($self, %attribs) = @_;
403 # Delete temporary files but do not touch installed files. We don\'t delete
404 # the Makefile here so a later make realclean still has a makefile to use.
406 clean :: clean_subdirs
409 my @files = values %{$self->{XS
}}; # .c files from *.xs files
412 # Normally these are all under blib but they might have been
414 # XXX normally this would be a good idea, but the Perl core sets
415 # INST_LIB = ../../lib rather than actually installing the files.
416 # So a "make clean" in an ext/ directory would blow away lib.
417 # Until the core is adjusted let's leave this out.
418 # push @dirs, qw($(INST_ARCHLIB) $(INST_LIB)
419 # $(INST_BIN) $(INST_SCRIPT)
420 # $(INST_MAN1DIR) $(INST_MAN3DIR)
421 # $(INST_LIBDIR) $(INST_ARCHLIBDIR) $(INST_AUTODIR)
422 # $(INST_STATIC) $(INST_DYNAMIC) $(INST_BOOT)
426 if( $attribs{FILES
} ) {
427 # Use @dirs because we don't know what's in here.
428 push @dirs, ref $attribs{FILES
} ?
430 split /\s+/, $attribs{FILES
} ;
433 push(@files, qw
[$(MAKE_APERL_FILE
)
434 perlmain
.c tmon
.out mon
.out so_locations
435 blibdirs
.ts pm_to_blib pm_to_blib
.ts
436 *$(OBJ_EXT
) *$(LIB_EXT
) perl
.exe perl perl
$(EXE_EXT
)
437 $(BOOTSTRAP
) $(BASEEXT
).bso
438 $(BASEEXT
).def lib
$(BASEEXT
).def
439 $(BASEEXT
).exp $(BASEEXT
).x
442 push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
443 push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
446 push(@files, qw
[core core
.*perl
.*.?
*perl
.core
]);
447 push(@files, map { "core." . "[0-9]"x
$_ } (1..5));
449 # OS specific things to clean up. Use @dirs since we don't know
450 # what might be in here.
451 push @dirs, $self->extra_clean_files;
453 # Occasionally files are repeated several times from different sources
454 { my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
455 { my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; }
457 push @m, map "\t$_\n", $self->split_command('- $(RM_F)', @files);
458 push @m, map "\t$_\n", $self->split_command('- $(RM_RF)', @dirs);
460 # Leave Makefile.old around for realclean
462 - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
465 push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP
};
471 =head3 clean_subdirs_target
473 my $make_frag = $MM->clean_subdirs_target;
475 Returns the clean_subdirs target. This is used by the clean target to
476 call clean on any subdirectories which contain Makefiles.
480 sub clean_subdirs_target
{
483 # No subdirectories, no cleaning.
484 return <<'NOOP_FRAG' unless @{$self->{DIR}};
490 my $clean = "clean_subdirs :\n";
492 for my $dir (@
{$self->{DIR
}}) {
493 my $subclean = $self->oneliner(sprintf <<'CODE', $dir);
494 chdir '%s'; system '$(MAKE) clean' if -f '$(FIRST_MAKEFILE)';
497 $clean .= "\t$subclean\n";
506 my $make_frag = $mm->dir_target(@directories);
508 Generates targets to create the specified directories and set its
511 Because depending on a directory to just ensure it exists doesn't work
512 too well (the modified time changes too often) dir_target() creates a
513 .exists file in the created directory. It is this you should depend on.
514 For portability purposes you should use the $(DIRFILESEP) macro rather
515 than a '/' to seperate the directory from the file.
517 yourdirectory$(DIRFILESEP).exists
522 my($self, @dirs) = @_;
525 foreach my $dir (@dirs) {
526 $make .= sprintf <<'MAKE', ($dir) x 7;
527 %s$(DFSEP).exists :: Makefile.PL
528 $(NOECHO) $(MKPATH) %s
529 $(NOECHO) $(CHMOD) 755 %s
530 $(NOECHO) $(TOUCH) %s$(DFSEP).exists
542 Defines the scratch directory target that will hold the distribution
543 before tar-ing (or shar-ing).
547 # For backwards compatibility.
548 *dist_dir
= *distdir
;
553 my $meta_target = $self->{NO_META
} ?
'' : 'distmeta';
554 my $sign_target = !$self->{SIGN
} ?
'' : 'distsignature';
556 return sprintf <<'MAKE_FRAG', $meta_target, $sign_target;
558 $(RM_RF) $(DISTVNAME)
559 $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
560 -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
562 distdir : create_distdir %s %s
572 Defines a target that produces the distribution in the
573 scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
581 my $mpl_args = join " ", map qq["$_"], @ARGV;
583 my $test = $self->cd('$(DISTVNAME)',
584 '$(ABSPERLRUN) Makefile.PL '.$mpl_args,
585 '$(MAKE) $(PASTHRU
)',
586 '$(MAKE
) test
$(PASTHRU
)'
589 return sprintf <<'MAKE_FRAG', $test;
601 Defines the dynamic target.
606 # --- Dynamic Loading Sections ---
610 dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
616 =head3 makemakerdflt_target
618 my $make_frag = $mm->makemakerdflt_target
620 Returns a make fragment with the makemakerdeflt_target specified.
621 This target is the first target in the Makefile, is the default target
622 and simply points off to 'all' just in case any make variant gets
623 confused or something gets snuck in before the real 'all' target.
627 sub makemakerdflt_target
{
628 return <<'MAKE_FRAG';
636 =head3 manifypods_target
638 my $manifypods_target = $self->manifypods_target;
640 Generates the manifypods target. This target generates man pages from
641 all POD files in MAN1PODS and MAN3PODS.
645 sub manifypods_target {
650 my $dependencies = '';
652 # populate manXpods & dependencies:
653 foreach my $name (keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}) {
654 $dependencies .= " \\\n\t$name";
657 foreach my $name (keys %{$self->{MAN3PODS}}) {
658 $dependencies .= " \\\n\t$name"
662 manifypods : pure_all $dependencies
666 foreach my $section (qw(1 3)) {
667 my $pods = $self->{"MAN${section}PODS"};
668 push @man_cmds, $self->split_command(<<CMD, %$pods);
669 \$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)
673 $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
674 $manify .= join '', map { "$_\n" } @man_cmds;
680 =head3 metafile_target
682 my $target = $mm->metafile_target;
684 Generate the metafile target.
686 Writes the file META.yml YAML encoded meta-data about the module in
687 the distdir. The format follows Module::Build's as closely as
688 possible. Additionally, we include:
695 sub metafile_target
{
698 return <<'MAKE_FRAG' if $self->{NO_META};
704 foreach my $mod ( sort { lc $a cmp lc $b } keys %{$self->{PREREQ_PM}} ) {
705 my $ver = $self->{PREREQ_PM}{$mod};
706 $prereq_pm .= sprintf " %-30s %s\n", "$mod:", $ver;
710 # http://module-build.sourceforge.net/META-spec.html
711 #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
712 name: $self->{DISTNAME}
713 version: $self->{VERSION}
714 version_from: $self->{VERSION_FROM}
715 installdirs: $self->{INSTALLDIRS}
718 distribution_type: module
719 generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
722 my @write_meta = $self->echo($meta, 'META_new.yml');
724 return sprintf <<'MAKE_FRAG', join("\n\t", @write_meta);
725 metafile : create_distdir
726 $(NOECHO) $(ECHO) Generating META.yml
728 -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
734 =head3 distmeta_target
736 my $make_frag = $mm->distmeta_target;
738 Generates the distmeta target to add META.yml to the MANIFEST in the
743 sub distmeta_target {
746 my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
747 eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) }
748 or print "Could not add META.yml to MANIFEST: $${'@'}\n"
751 my $add_meta_to_distdir = $self->cd('$(DISTVNAME)', $add_meta);
753 return sprintf <<'MAKE', $add_meta_to_distdir;
754 distmeta : create_distdir metafile
764 Defines the realclean target.
769 my($self, %attribs) = @_;
771 my @dirs = qw($(DISTVNAME));
772 my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD
));
774 # Special exception for the perl core where INST_* is not in blib.
775 # This cleans up the files built from the ext/ directory (all XS).
776 if( $self->{PERL_CORE
} ) {
777 push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR
));
778 push @files, values %{$self->{PM
}};
781 if( $self->has_link_code ){
782 push @files, qw($(OBJECT));
785 if( $attribs{FILES
} ) {
786 if( ref $attribs{FILES
} ) {
787 push @dirs, @
{ $attribs{FILES
} };
790 push @dirs, split /\s+/, $attribs{FILES
};
794 # Occasionally files are repeated several times from different sources
795 { my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
796 { my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; }
798 my $rm_cmd = join "\n\t", map { "$_" }
799 $self->split_command('- $(RM_F)', @files);
800 my $rmf_cmd = join "\n\t", map { "$_" }
801 $self->split_command('- $(RM_RF)', @dirs);
803 my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
804 # Delete temporary files (via clean) and also delete dist files
805 realclean purge :: clean realclean_subdirs
810 $m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP
};
816 =head3 realclean_subdirs_target
818 my $make_frag = $MM->realclean_subdirs_target;
820 Returns the realclean_subdirs target. This is used by the realclean
821 target to call realclean on any subdirectories which contain Makefiles.
825 sub realclean_subdirs_target
{
828 return <<'NOOP_FRAG' unless @{$self->{DIR}};
833 my $rclean = "realclean_subdirs :\n";
835 foreach my $dir (@
{$self->{DIR
}}) {
836 foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
837 my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2);
838 chdir '%s'; system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s';
841 $rclean .= sprintf <<'RCLEAN', $subrclean;
852 =head3 signature_target
854 my $target = $mm->signature_target;
856 Generate the signature target.
858 Writes the file SIGNATURE with "cpansign -s".
862 sub signature_target
{
865 return <<'MAKE_FRAG';
873 =head3 distsignature_target
875 my $make_frag = $mm->distsignature_target;
877 Generates the distsignature target to add SIGNATURE to the MANIFEST in the
882 sub distsignature_target {
885 my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
886 eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }
887 or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n"
890 my $sign_dist = $self->cd('$(DISTVNAME)' => 'cpansign -s');
892 # cpansign -s complains if SIGNATURE is in the MANIFEST yet does not
894 my $touch_sig = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE');
895 my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign );
897 return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_dist
898 distsignature : create_distdir
908 =head3 special_targets
910 my $make_frag = $mm->special_targets
912 Returns a make fragment containing any targets which have special
913 meaning to make. For example, .SUFFIXES and .PHONY.
917 sub special_targets
{
918 my $make_frag = <<'MAKE_FRAG';
919 .SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
921 .PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
925 $make_frag .= <<'MAKE_FRAG
' if $ENV{CLEARCASE_ROOT};
926 .NO_CONFIG_REC: Makefile
938 Methods which help initialize the MakeMaker object and macros.
945 Called by init_main. Sets up all INST_* variables except those related
946 to XS code. Those are handled in init_xs.
953 $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
954 $self->{INST_BIN} ||= $self->catdir($Curdir,'blib
','bin
');
956 # INST_LIB typically pre-set if building an extension after
957 # perl has been built and installed. Setting INST_LIB allows
958 # you to build directly into, say $Config{privlibexp}.
959 unless ($self->{INST_LIB}){
960 if ($self->{PERL_CORE}) {
961 if (defined $Cross::platform) {
962 $self->{INST_LIB} = $self->{INST_ARCHLIB} =
963 $self->catdir($self->{PERL_LIB},"..","xlib",
967 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
970 $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
974 my @parentdir = split(/::/, $self->{PARENT_NAME});
975 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB
)', @parentdir);
976 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB
)', @parentdir);
977 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB
)', 'auto
',
979 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB
)', 'auto
',
982 $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib
','script
');
984 $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib
','man1
');
985 $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib
','man3
');
995 Called by init_main. Sets up all INSTALL_* variables (except
996 INSTALLDIRS) and *PREFIX.
1003 if( $self->{ARGS}{INSTALLBASE} and $self->{ARGS}{PREFIX} ) {
1004 die "Only one of PREFIX or INSTALLBASE can be given. Not both.\n";
1007 if( $self->{ARGS}{INSTALLBASE} ) {
1008 $self->init_INSTALL_from_INSTALLBASE;
1011 $self->init_INSTALL_from_PREFIX;
1016 =head3 init_INSTALL_from_PREFIX
1018 $mm->init_INSTALL_from_PREFIX;
1022 sub init_INSTALL_from_PREFIX {
1025 $self->init_lib2arch;
1027 # There are often no Config.pm defaults for these new man variables so
1028 # we fall back to the old behavior which is to use installman*dir
1029 foreach my $num (1, 3) {
1030 my $k = 'installsiteman
'.$num.'dir
';
1032 $self->{uc $k} ||= uc "\$(installman${num}dir)"
1036 foreach my $num (1, 3) {
1037 my $k = 'installvendorman
'.$num.'dir
';
1039 unless( $Config{$k} ) {
1040 $self->{uc $k} ||= $Config{usevendorprefix}
1041 ? uc "\$(installman${num}dir)"
1046 $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN
)'
1047 unless $Config{installsitebin};
1049 unless( $Config{installvendorbin} ) {
1050 $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix}
1051 ? $Config{installbin}
1056 my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
1057 $Config{prefixexp} || $Config{prefix} || '';
1058 my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : '';
1059 my $sprefix = $Config{siteprefixexp} || '';
1061 # 5.005_03 doesn't have a siteprefix
.
1062 $sprefix = $iprefix unless $sprefix;
1065 $self->{PREFIX
} ||= '';
1067 if( $self->{PREFIX
} ) {
1068 @
{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
1072 $self->{PERLPREFIX
} ||= $iprefix;
1073 $self->{SITEPREFIX
} ||= $sprefix;
1074 $self->{VENDORPREFIX
} ||= $vprefix;
1076 # Lots of MM extension authors like to use $(PREFIX) so we
1077 # put something sensible in there no matter what.
1078 $self->{PREFIX
} = '$('.uc $self->{INSTALLDIRS
}.'PREFIX)';
1081 my $arch = $Config{archname
};
1082 my $version = $Config{version
};
1085 my $libstyle = $Config{installstyle
} || 'lib/perl5';
1088 if( $self->{LIBSTYLE
} ) {
1089 $libstyle = $self->{LIBSTYLE
};
1090 $manstyle = $self->{LIBSTYLE
} eq 'lib/perl5' ?
'lib/perl5' : '';
1093 # Some systems, like VOS, set installman*dir to '' if they can't
1095 for my $num (1, 3) {
1096 $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
1097 unless $Config{'installman'.$num.'dir'};
1102 bin
=> { s
=> $iprefix,
1105 vendorbin
=> { s
=> $vprefix,
1108 sitebin
=> { s
=> $sprefix,
1111 script
=> { s
=> $iprefix,
1118 man1dir
=> { s
=> $iprefix,
1121 style
=> $manstyle, },
1122 siteman1dir
=> { s
=> $sprefix,
1125 style
=> $manstyle, },
1126 vendorman1dir
=> { s
=> $vprefix,
1129 style
=> $manstyle, },
1131 man3dir
=> { s
=> $iprefix,
1134 style
=> $manstyle, },
1135 siteman3dir
=> { s
=> $sprefix,
1138 style
=> $manstyle, },
1139 vendorman3dir
=> { s
=> $vprefix,
1142 style
=> $manstyle, },
1147 privlib
=> { s
=> $iprefix,
1150 style
=> $libstyle, },
1151 vendorlib
=> { s
=> $vprefix,
1154 style
=> $libstyle, },
1155 sitelib
=> { s
=> $sprefix,
1158 style
=> $libstyle, },
1160 archlib
=> { s
=> $iprefix,
1162 d
=> "$version/$arch",
1163 style
=> $libstyle },
1164 vendorarch
=> { s
=> $vprefix,
1166 d
=> "$version/$arch",
1167 style
=> $libstyle },
1168 sitearch
=> { s
=> $sprefix,
1170 d
=> "site_perl/$version/$arch",
1171 style
=> $libstyle },
1175 # Special case for LIB.
1176 if( $self->{LIB
} ) {
1177 foreach my $var (keys %lib_layouts) {
1178 my $Installvar = uc "install$var";
1180 if( $var =~ /arch/ ) {
1181 $self->{$Installvar} ||=
1182 $self->catdir($self->{LIB
}, $Config{archname
});
1185 $self->{$Installvar} ||= $self->{LIB
};
1190 my %type2prefix = ( perl
=> 'PERLPREFIX',
1191 site
=> 'SITEPREFIX',
1192 vendor
=> 'VENDORPREFIX'
1195 my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
1196 while( my($var, $layout) = each(%layouts) ) {
1197 my($s, $t, $d, $style) = @
{$layout}{qw(s t d style)};
1198 my $r = '$('.$type2prefix{$t}.')';
1200 print STDERR
"Prefixing $var\n" if $Verbose >= 2;
1202 my $installvar = "install$var";
1203 my $Installvar = uc $installvar;
1204 next if $self->{$Installvar};
1206 $d = "$style/$d" if $style;
1207 $self->prefixify($installvar, $s, $r, $d);
1209 print STDERR
" $Installvar == $self->{$Installvar}\n"
1213 # Generate these if they weren't figured out.
1214 $self->{VENDORARCHEXP
} ||= $self->{INSTALLVENDORARCH
};
1215 $self->{VENDORLIBEXP
} ||= $self->{INSTALLVENDORLIB
};
1221 =head3 init_from_INSTALLBASE
1223 $mm->init_from_INSTALLBASE
1228 lib
=> [qw(lib perl5)],
1229 arch
=> [('lib', 'perl5', $Config{archname
})],
1231 man1dir
=> [qw(man man1)],
1232 man3dir
=> [qw(man man3)]
1234 $map{script
} = $map{bin
};
1236 sub init_INSTALL_from_INSTALLBASE
{
1239 @
{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} =
1243 foreach my $thing (keys %map) {
1244 foreach my $dir (('', 'SITE', 'VENDOR')) {
1245 my $uc_thing = uc $thing;
1246 my $key = "INSTALL".$dir.$uc_thing;
1249 $self->catdir('$(INSTALLBASE)', @
{$map{$thing}});
1253 # Adjust for variable quirks.
1254 $install{INSTALLARCHLIB
} ||= delete $install{INSTALLARCH
};
1255 $install{INSTALLPRIVLIB
} ||= delete $install{INSTALLLIB
};
1256 delete @install{qw(INSTALLVENDORSCRIPT INSTALLSITESCRIPT)};
1258 foreach my $key (keys %install) {
1259 $self->{$key} ||= $install{$key};
1266 =head3 init_VERSION I<Abstract>
1270 Initialize macros representing versions of MakeMaker and other tools
1272 MAKEMAKER: path to the MakeMaker module.
1274 MM_VERSION: ExtUtils::MakeMaker Version
1276 MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards
1279 VERSION: version of your module
1281 VERSION_MACRO: which macro represents the version (usually 'VERSION')
1283 VERSION_SYM: like version but safe for use as an RCS revision number
1285 DEFINE_VERSION: -D line to set the module version when compiling
1287 XS_VERSION: version in your .xs file. Defaults to $(VERSION)
1289 XS_VERSION_MACRO: which macro represents the XS version.
1291 XS_DEFINE_VERSION: -D line to set the xs version when compiling.
1293 Called by init_main.
1300 $self->{MAKEMAKER
} = $ExtUtils::MakeMaker
::Filename
;
1301 $self->{MM_VERSION
} = $ExtUtils::MakeMaker
::VERSION
;
1302 $self->{MM_REVISION
}= $ExtUtils::MakeMaker
::Revision
;
1303 $self->{VERSION_FROM
} ||= '';
1305 if ($self->{VERSION_FROM
}){
1306 $self->{VERSION
} = $self->parse_version($self->{VERSION_FROM
});
1307 if( $self->{VERSION
} eq 'undef' ) {
1309 Carp
::carp
("WARNING: Setting VERSION via file ".
1310 "'$self->{VERSION_FROM}' failed\n");
1315 if (defined $self->{VERSION
}) {
1316 $self->{VERSION
} =~ s/^\s+//;
1317 $self->{VERSION
} =~ s/\s+$//;
1320 $self->{VERSION
} = '';
1324 $self->{VERSION_MACRO
} = 'VERSION';
1325 ($self->{VERSION_SYM
} = $self->{VERSION
}) =~ s/\W/_/g;
1326 $self->{DEFINE_VERSION
} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
1329 # Graham Barr and Paul Marquess had some ideas how to ensure
1330 # version compatibility between the *.pm file and the
1331 # corresponding *.xs file. The bottomline was, that we need an
1332 # XS_VERSION macro that defaults to VERSION:
1333 $self->{XS_VERSION
} ||= $self->{VERSION
};
1335 $self->{XS_VERSION_MACRO
} = 'XS_VERSION';
1336 $self->{XS_DEFINE_VERSION
} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
1341 =head3 init_others I<Abstract>
1345 Initializes the macro definitions used by tools_other() and places them
1348 If there is no description, its the same as the parameter to
1349 WriteMakefile() documented in ExtUtils::MakeMaker.
1351 Defines at least these macros.
1356 NOECHO Tell make not to display the command itself
1361 MAKE_APERL_FILE File used by MAKE_APERL
1363 SHELL Program used to run
1366 ECHO Print text adding a newline on the end
1368 RM_RF Remove a directory
1369 TOUCH Update a file's timestamp
1370 TEST_F Test for a file's existence
1373 CHMOD Change permissions on a
1376 UMASK_NULL Nullify umask
1377 DEV_NULL Supress all command output
1380 =head3 init_DIRFILESEP I<Abstract>
1382 $MM->init_DIRFILESEP;
1383 my $dirfilesep = $MM->{DIRFILESEP};
1385 Initializes the DIRFILESEP macro which is the seperator between the
1386 directory and filename in a filepath. ie. / on Unix, \ on Win32 and
1391 # instead of $(INST_ARCHAUTODIR)/extralibs.ld
1392 $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
1394 Something of a hack but it prevents a lot of code duplication between
1397 Do not use this as a seperator between directories. Some operating
1398 systems use different seperators between subdirectories as between
1399 directories and filenames (for example: VOLUME:[dir1.dir2]file on VMS).
1401 =head3 init_linker I<Abstract>
1405 Initialize macros which have to do with linking.
1407 PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
1410 PERL_ARCHIVE_AFTER: path to a library which should be put on the
1411 linker command line I<after> the external libraries to be linked to
1412 dynamic extensions. This may be needed if the linker is one-pass, and
1413 Perl includes some overrides for C RTL functions, such as malloc().
1415 EXPORT_LIST: name of a file that is passed to linker to define symbols
1418 Some OSes do not need these in which case leave it blank.
1421 =head3 init_platform
1425 Initialize any macros which are for platform specific use only.
1427 A typical one is the version number of your OS specific mocule.
1428 (ie. MM_Unix_VERSION or MM_VMS_VERSION).
1442 A grab bag of methods to generate specific macros and commands.
1448 Defines targets and routines to translate the pods into manpages and
1449 put them into the INST_* directories.
1456 my $POD2MAN_macro = $self->POD2MAN_macro();
1457 my $manifypods_target = $self->manifypods_target();
1459 return <<END_OF_TARGET;
1470 =head3 POD2MAN_macro
1472 my $pod2man_macro = $self->POD2MAN_macro
1474 Returns a definition for the POD2MAN macro. This is a program
1475 which emulates the pod2man utility. You can add more switches to the
1476 command by simply appending them on the macro.
1480 $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
1487 # Need the trailing '--' so perl stops gobbling arguments and - happens
1488 # to be an alternative end of line seperator on VMS so we quote it
1489 return <<'END_OF_DEF';
1490 POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
1491 POD2MAN = $(POD2MAN_EXE)
1496 =head3 test_via_harness
1498 my $command = $mm->test_via_harness($perl, $tests);
1500 Returns a $command line which runs the given set of $tests with
1501 Test::Harness and the given $perl.
1503 Used on the t/*.t files.
1507 sub test_via_harness {
1508 my($self, $perl, $tests) = @_;
1510 return qq{\t$perl "-MExtUtils::Command::MM" }.
1511 qq{"-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
1514 =head3 test_via_script
1516 my $command = $mm->test_via_script($perl, $script);
1518 Returns a $command line which just runs a single test without
1519 Test::Harness. No checks are done on the results, they're just
1522 Used for test.pl, since they don't always follow Test::Harness
1527 sub test_via_script {
1528 my($self, $perl, $script) = @_;
1529 return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
1533 =head3 tool_autosplit
1535 Defines a simple perl call that runs autosplit. May be deprecated by
1540 sub tool_autosplit {
1541 my($self, %attribs) = @_;
1543 my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};'
1546 my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
1547 use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
1550 return sprintf <<'MAKE_FRAG', $asplit;
1551 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
1561 =head2 File::Spec wrappers
1563 ExtUtils::MM_Any is a subclass of File::Spec. The methods noted here
1564 override File::Spec.
1570 File::Spec <= 0.83 has a bug where the file part of catfile is not
1571 canonicalized. This override fixes that bug.
1577 return $self->canonpath($self->SUPER::catfile(@_));
1584 Methods I can't really figure out where they should go yet.
1589 my $test = $mm->find_tests;
1591 Returns a string suitable for feeding to the shell to return all
1598 return -d 't' ? 't/*.t' : '';
1602 =head3 extra_clean_files
1604 my @files_to_clean = $MM->extra_clean_files;
1606 Returns a list of OS specific files to be removed in the clean target in
1607 addition to the usual set.
1611 # An empty method here tickled a perl 5.8.1 bug and would return its object.
1612 sub extra_clean_files {
1619 my @installvars = $mm->installvars;
1621 A list of all the INSTALL* variables without the INSTALL prefix. Useful
1622 for iteration or building related variable sets.
1627 return qw(PRIVLIB SITELIB VENDORLIB
1628 ARCHLIB SITEARCH VENDORARCH
1629 BIN SITEBIN VENDORBIN
1631 MAN1DIR SITEMAN1DIR VENDORMAN1DIR
1632 MAN3DIR SITEMAN3DIR VENDORMAN3DIR
1639 my $wanted = $self->libscan($path);
1641 Takes a path to a file or dir and returns an empty string if we don't
1642 want to include this file in the library. Otherwise it returns the
1643 the $path unchanged.
1645 Mainly used to exclude version control administrative directories from
1651 my($self,$path) = @_;
1652 my($dirs,$file) = ($self->splitpath($path))[1,2];
1653 return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/,
1654 $self->splitdir($dirs), $file;
1660 =head3 platform_constants
1662 my $make_frag = $mm->platform_constants
1664 Returns a make fragment defining all the macros initialized in
1665 init_platform() rather than put them in constants().
1669 sub platform_constants
{
1676 Michael G Schwern <schwern@pobox.com> and the denizens of
1677 makemaker@perl.org with code from ExtUtils::MM_Unix and