1 package ExtUtils::MM_Any;
4 our $VERSION = '6.53_02';
9 BEGIN { our @ISA = qw(File::Spec); }
12 use ExtUtils::MakeMaker qw($Verbose);
14 use ExtUtils::MakeMaker::Config;
17 # So we don't have to keep calling the methods over and over again,
18 # we have these globals to cache the values. Faster and shrtr.
19 my $Curdir = __PACKAGE__->curdir;
20 my $Rootdir = __PACKAGE__->rootdir;
21 my $Updir = __PACKAGE__->updir;
26 ExtUtils::MM_Any - Platform-agnostic MM methods
30 FOR INTERNAL USE ONLY!
32 package ExtUtils::MM_SomeOS;
34 # Temporarily, you have to subclass both. Put MM_Any first.
35 require ExtUtils::MM_Any;
36 require ExtUtils::MM_Unix;
37 @ISA = qw(ExtUtils::MM_Any ExtUtils::Unix);
41 B<FOR INTERNAL USE ONLY!>
43 ExtUtils::MM_Any is a superclass for the ExtUtils::MM_* set of
44 modules. It contains methods which are either inherently
45 cross-platform or are written in a cross-platform manner.
47 Subclass off of ExtUtils::MM_Any I<and> ExtUtils::MM_Unix. This is a
50 B<THIS MAY BE TEMPORARY!>
55 Any methods marked I<Abstract> must be implemented by subclasses.
58 =head2 Cross-platform helper methods
60 These are methods which help writing cross-platform code.
64 =head3 os_flavor I<Abstract>
66 my @os_flavor = $mm->os_flavor;
68 @os_flavor is the style of operating system this is, usually
69 corresponding to the MM_*.pm file we're using.
71 The first element of @os_flavor is the major family (ie. Unix,
72 Windows, VMS, OS/2, etc...) and the rest are sub families.
76 Cygwin98 ('Unix', 'Cygwin', 'Cygwin9x')
77 Windows NT ('Win32', 'WinNT')
78 Win98 ('Win32', 'Win9x')
79 Linux ('Unix', 'Linux')
80 MacOS X ('Unix', 'Darwin', 'MacOS', 'MacOS X')
83 This is used to write code for styles of operating system.
84 See os_flavor_is() for use.
89 my $is_this_flavor = $mm->os_flavor_is($this_flavor);
90 my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
92 Checks to see if the current operating system is one of the given flavors.
94 This is useful for code like:
96 if( $mm->os_flavor_is('Unix') ) {
107 my %flavors = map { ($_ => 1) } $self->os_flavor;
108 return (grep { $flavors{$_} } @_) ? 1 : 0;
114 my $can_load_xs = $self->can_load_xs;
116 Returns true if we have the ability to load XS.
118 This is important because miniperl, used to build XS modules in the
119 core, can not load XS.
124 return defined &DynaLoader::boot_DynaLoader ? 1 : 0;
130 my @cmds = $MM->split_command($cmd, @args);
132 Most OS have a maximum command length they can execute at once. Large
133 modules can easily generate commands well past that limit. Its
134 necessary to split long commands up into a series of shorter commands.
136 C<split_command> will return a series of @cmds each processing part of
137 the args. Collectively they will process all the arguments. Each
138 individual line in @cmds will not be longer than the
139 $self->max_exec_len being careful to take into account macro expansion.
141 $cmd should include any switches and repeated initial arguments.
143 If no @args are given, no @cmds will be returned.
145 Pairs of arguments will always be preserved in a single command, this
146 is a heuristic for things like pm_to_blib and pod2man which work on
147 pairs of arguments. This makes things like this safe:
149 $self->split_command($cmd, %pod2man);
155 my($self, $cmd, @args) = @_;
158 return(@cmds) unless @args;
160 # If the command was given as a here-doc, there's probably a trailing
164 # set aside 30% for macro expansion.
165 my $len_left = int($self->max_exec_len * 0.70);
166 $len_left -= length $self->_expand_macros($cmd);
171 while( @next_args = splice(@args, 0, 2) ) {
172 # Two at a time to preserve pairs.
173 my $next_arg_str = "\t ". join ' ', @next_args, "\n";
175 if( !length $arg_str ) {
176 $arg_str .= $next_arg_str
178 elsif( length($arg_str) + length($next_arg_str) > $len_left ) {
179 unshift @args, @next_args;
183 $arg_str .= $next_arg_str;
188 push @cmds, $self->escape_newlines("$cmd \n$arg_str");
196 my($self, $cmd) = @_;
198 $cmd =~ s{\$\((\w+)\)}{
199 defined $self->{$1} ? $self->{$1} : "\$($1)"
207 my @commands = $MM->echo($text);
208 my @commands = $MM->echo($text, $file);
209 my @commands = $MM->echo($text, $file, $appending);
211 Generates a set of @commands which print the $text to a $file.
213 If $file is not given, output goes to STDOUT.
215 If $appending is true the $file will be appended to rather than
221 my($self, $text, $file, $appending) = @_;
224 my @cmds = map { '$(NOECHO) $(ECHO) '.$self->quote_literal($_) }
227 my $redirect = $appending ? '>>' : '>';
228 $cmds[0] .= " $redirect $file";
229 $_ .= " >> $file" foreach @cmds[1..$#cmds];
238 my $args = $mm->wraplist(@list);
240 Takes an array of items and turns them into a well-formatted list of
241 arguments. In most cases this is simply something like:
251 return join " \\\n\t", @_;
255 =head3 maketext_filter
257 my $filter_make_text = $mm->maketext_filter($make_text);
259 The text of the Makefile is run through this method before writing to
260 disk. It allows systems a chance to make portability fixes to the
263 By default it does nothing.
265 This method is protected and not intended to be called outside of
270 sub maketext_filter { return $_[1] }
273 =head3 cd I<Abstract>
275 my $subdir_cmd = $MM->cd($subdir, @cmds);
277 This will generate a make fragment which runs the @cmds in the given
278 $dir. The rough equivalent to this, except cross platform.
282 Currently $dir can only go down one level. "foo" is fine. "foo/bar" is
283 not. "../foo" is right out.
285 The resulting $subdir_cmd has no leading tab nor trailing newline. This
286 makes it easier to embed in a make string. For example.
288 my $make = sprintf <<'CODE', $subdir_cmd;
296 =head3 oneliner I<Abstract>
298 my $oneliner = $MM->oneliner($perl_code);
299 my $oneliner = $MM->oneliner($perl_code, \@switches);
301 This will generate a perl one-liner safe for the particular platform
302 you're on based on the given $perl_code and @switches (a -e is
303 assumed) suitable for using in a make target. It will use the proper
304 shell quoting and escapes.
306 $(PERLRUN) will be used as perl.
308 Any newlines in $perl_code will be escaped. Leading and trailing
309 newlines will be stripped. Makes this idiom much easier:
311 my $code = $MM->oneliner(<<'CODE', [...switches...]);
316 Usage might be something like:
319 $oneliner = $MM->oneliner('print "Foo\n"');
320 $make = '$oneliner > somefile';
322 All dollar signs must be doubled in the $perl_code if you expect them
323 to be interpreted normally, otherwise it will be considered a make
324 macro. Also remember to quote make macros else it might be used as a
325 bareword. For example:
327 # Assign the value of the $(VERSION_FROM) make macro to $vf.
328 $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');
330 Its currently very simple and may be expanded sometime in the figure
331 to include more flexible code and switches.
334 =head3 quote_literal I<Abstract>
336 my $safe_text = $MM->quote_literal($text);
338 This will quote $text so it is interpreted literally in the shell.
340 For example, on Unix this would escape any single-quotes in $text and
341 put single-quotes around the whole thing.
344 =head3 escape_newlines I<Abstract>
346 my $escaped_text = $MM->escape_newlines($text);
348 Shell escapes newlines in $text.
351 =head3 max_exec_len I<Abstract>
353 my $max_exec_len = $MM->max_exec_len;
355 Calculates the maximum command size the OS can exec. Effectively,
356 this is the max size of a shell command line.
359 $self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes.
364 my $make = $MM->make;
366 Returns the make variant we're generating the Makefile for. This attempts
367 to do some normalization on the information from %Config or the user.
374 my $make = lc $self->{MAKE};
376 # Truncate anything like foomake6 to just foomake.
377 $make =~ s/^(\w+make).*/$1/;
379 # Turn gnumake into gmake.
388 These are methods which produce make targets.
393 Generate the default target 'all'.
408 =head3 blibdirs_target
410 my $make_frag = $mm->blibdirs_target;
412 Creates the blibdirs target which creates all the directories we use
415 The blibdirs.ts target is deprecated. Depend on blibdirs instead.
420 sub blibdirs_target {
423 my @dirs = map { uc "\$(INST_$_)" } qw(libdir archlib
429 my @exists = map { $_.'$(DFSEP).exists' } @dirs;
431 my $make = sprintf <<'MAKE', join(' ', @exists);
435 # Backwards compat with 6.18 through 6.25
436 blibdirs.ts : blibdirs
441 $make .= $self->dir_target(@dirs);
449 Defines the clean target.
454 # --- Cleanup and Distribution Sections ---
456 my($self, %attribs) = @_;
459 # Delete temporary files but do not touch installed files. We don\'t delete
460 # the Makefile here so a later make realclean still has a makefile to use.
462 clean :: clean_subdirs
465 my @files = values %{$self->{XS}}; # .c files from *.xs files
468 # Normally these are all under blib but they might have been
470 # XXX normally this would be a good idea, but the Perl core sets
471 # INST_LIB = ../../lib rather than actually installing the files.
472 # So a "make clean" in an ext/ directory would blow away lib.
473 # Until the core is adjusted let's leave this out.
474 # push @dirs, qw($(INST_ARCHLIB) $(INST_LIB)
475 # $(INST_BIN) $(INST_SCRIPT)
476 # $(INST_MAN1DIR) $(INST_MAN3DIR)
477 # $(INST_LIBDIR) $(INST_ARCHLIBDIR) $(INST_AUTODIR)
478 # $(INST_STATIC) $(INST_DYNAMIC) $(INST_BOOT)
482 if( $attribs{FILES} ) {
483 # Use @dirs because we don't know what's in here.
484 push @dirs, ref $attribs{FILES} ?
486 split /\s+/, $attribs{FILES} ;
489 push(@files, qw[$(MAKE_APERL_FILE)
490 perlmain.c tmon.out mon.out so_locations
491 blibdirs.ts pm_to_blib pm_to_blib.ts
492 *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT)
493 $(BOOTSTRAP) $(BASEEXT).bso
494 $(BASEEXT).def lib$(BASEEXT).def
495 $(BASEEXT).exp $(BASEEXT).x
498 push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
499 push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
502 push(@files, qw[core core.*perl.*.? *perl.core]);
503 push(@files, map { "core." . "[0-9]"x$_ } (1..5));
505 # OS specific things to clean up. Use @dirs since we don't know
506 # what might be in here.
507 push @dirs, $self->extra_clean_files;
509 # Occasionally files are repeated several times from different sources
510 { my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
511 { my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; }
513 push @m, map "\t$_\n", $self->split_command('- $(RM_F)', @files);
514 push @m, map "\t$_\n", $self->split_command('- $(RM_RF)', @dirs);
516 # Leave Makefile.old around for realclean
518 - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
521 push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
527 =head3 clean_subdirs_target
529 my $make_frag = $MM->clean_subdirs_target;
531 Returns the clean_subdirs target. This is used by the clean target to
532 call clean on any subdirectories which contain Makefiles.
536 sub clean_subdirs_target {
539 # No subdirectories, no cleaning.
540 return <<'NOOP_FRAG' unless @{$self->{DIR}};
546 my $clean = "clean_subdirs :\n";
548 for my $dir (@{$self->{DIR}}) {
549 my $subclean = $self->oneliner(sprintf <<'CODE', $dir);
550 chdir '%s'; system '$(MAKE) clean' if -f '$(FIRST_MAKEFILE)';
553 $clean .= "\t$subclean\n";
562 my $make_frag = $mm->dir_target(@directories);
564 Generates targets to create the specified directories and set its
565 permission to PERM_DIR.
567 Because depending on a directory to just ensure it exists doesn't work
568 too well (the modified time changes too often) dir_target() creates a
569 .exists file in the created directory. It is this you should depend on.
570 For portability purposes you should use the $(DIRFILESEP) macro rather
571 than a '/' to seperate the directory from the file.
573 yourdirectory$(DIRFILESEP).exists
578 my($self, @dirs) = @_;
581 foreach my $dir (@dirs) {
582 $make .= sprintf <<'MAKE', ($dir) x 7;
583 %s$(DFSEP).exists :: Makefile.PL
584 $(NOECHO) $(MKPATH) %s
585 $(NOECHO) $(CHMOD) $(PERM_DIR) %s
586 $(NOECHO) $(TOUCH) %s$(DFSEP).exists
598 Defines the scratch directory target that will hold the distribution
599 before tar-ing (or shar-ing).
603 # For backwards compatibility.
604 *dist_dir = *distdir;
609 my $meta_target = $self->{NO_META} ? '' : 'distmeta';
610 my $sign_target = !$self->{SIGN} ? '' : 'distsignature';
612 return sprintf <<'MAKE_FRAG', $meta_target, $sign_target;
614 $(RM_RF) $(DISTVNAME)
615 $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
616 -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
618 distdir : create_distdir %s %s
628 Defines a target that produces the distribution in the
629 scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
637 my $mpl_args = join " ", map qq["$_"], @ARGV;
639 my $test = $self->cd('$(DISTVNAME)',
640 '$(ABSPERLRUN) Makefile.PL '.$mpl_args,
641 '$(MAKE) $(PASTHRU)',
642 '$(MAKE) test $(PASTHRU)'
645 return sprintf <<'MAKE_FRAG', $test;
657 Defines the dynamic target.
662 # --- Dynamic Loading Sections ---
666 dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
672 =head3 makemakerdflt_target
674 my $make_frag = $mm->makemakerdflt_target
676 Returns a make fragment with the makemakerdeflt_target specified.
677 This target is the first target in the Makefile, is the default target
678 and simply points off to 'all' just in case any make variant gets
679 confused or something gets snuck in before the real 'all' target.
683 sub makemakerdflt_target {
684 return <<'MAKE_FRAG';
692 =head3 manifypods_target
694 my $manifypods_target = $self->manifypods_target;
696 Generates the manifypods target. This target generates man pages from
697 all POD files in MAN1PODS and MAN3PODS.
701 sub manifypods_target {
706 my $dependencies = '';
708 # populate manXpods & dependencies:
709 foreach my $name (keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}) {
710 $dependencies .= " \\\n\t$name";
714 manifypods : pure_all $dependencies
718 foreach my $section (qw(1 3)) {
719 my $pods = $self->{"MAN${section}PODS"};
720 push @man_cmds, $self->split_command(<<CMD, %$pods);
721 \$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)
725 $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
726 $manify .= join '', map { "$_\n" } @man_cmds;
732 =head3 metafile_target
734 my $target = $mm->metafile_target;
736 Generate the metafile target.
738 Writes the file META.yml YAML encoded meta-data about the module in
739 the distdir. The format follows Module::Build's as closely as
744 sub metafile_target {
747 return <<'MAKE_FRAG' if $self->{NO_META};
752 my @metadata = $self->metafile_data(
753 $self->{META_ADD} || {},
754 $self->{META_MERGE} || {},
756 my $meta = $self->metafile_file(@metadata);
757 my @write_meta = $self->echo($meta, 'META_new.yml');
759 return sprintf <<'MAKE_FRAG', join("\n\t", @write_meta);
760 metafile : create_distdir
761 $(NOECHO) $(ECHO) Generating META.yml
763 -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
773 my @pairs = _sort_pairs($sort_sub, \%hash);
775 Sorts the pairs of a hash based on keys ordered according
785 return map { $_ => $pairs->{$_} }
791 # Taken from Module::Build::Base
793 my ($self, $h, $k, $v) = @_;
794 if (ref $h->{$k} eq 'ARRAY') {
795 push @{$h->{$k}}, ref $v ? @$v : $v;
796 } elsif (ref $h->{$k} eq 'HASH') {
797 $self->_hash_merge($h->{$k}, $_, $v->{$_}) foreach keys %$v;
806 my @metadata_pairs = $mm->metafile_data(\%meta_add, \%meta_merge);
808 Returns the data which MakeMaker turns into the META.yml file.
810 Values of %meta_add will overwrite any existing metadata in those
811 keys. %meta_merge will be merged with them.
817 my($meta_add, $meta_merge) = @_;
819 # The order in which standard meta keys should be written.
841 my $configure_requires;
842 if( $self->{CONFIGURE_REQUIRES} and ref($self->{CONFIGURE_REQUIRES}) eq 'HASH' ) {
843 $configure_requires = $self->{CONFIGURE_REQUIRES};
845 $configure_requires = {
846 'ExtUtils::MakeMaker' => 0,
851 name => $self->{DISTNAME},
852 version => $self->{VERSION},
853 abstract => $self->{ABSTRACT},
854 license => $self->{LICENSE} || 'unknown',
855 distribution_type => $self->{PM} ? 'module' : 'script',
857 configure_requires => $configure_requires,
860 'ExtUtils::MakeMaker' => 0
864 directory => [qw(t inc)]
867 generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
869 url => 'http://module-build.sourceforge.net/META-spec-v1.4.html',
874 # The author key is required and it takes a list.
875 $meta{author} = defined $self->{AUTHOR} ? [$self->{AUTHOR}] : [];
877 $meta{requires} = $self->{PREREQ_PM} if defined $self->{PREREQ_PM};
878 $meta{requires}{perl} = $self->{MIN_PERL_VERSION} if $self->{MIN_PERL_VERSION};
880 while( my($key, $val) = each %$meta_add ) {
884 while( my($key, $val) = each %$meta_merge ) {
885 $self->_hash_merge(\%meta, $key, $val);
890 # Put the standard keys first in the proper order.
891 for my $key (@meta_order) {
892 next unless exists $meta{$key};
894 push @meta_pairs, $key, delete $meta{$key};
897 # Then tack everything else onto the end, alpha sorted.
898 for my $key (sort {lc $a cmp lc $b} keys %meta) {
899 push @meta_pairs, $key, $meta{$key};
909 $yaml = _dump_hash(\%options, %hash);
911 Implements a fake YAML dumper for a hash given
912 as a list of pairs. No quoting/escaping is done. Keys
913 are supposed to be strings. Values are undef, strings,
914 hash refs or array refs of strings.
916 Supported options are:
918 delta => STR - indentation delta
919 use_header => BOOL - whether to include a YAML header
920 indent => STR - a string of spaces
923 max_key_length => INT - maximum key length used to align
924 keys and values of the same hash
926 key_sort => CODE - a sort sub
927 It may be undef, which means no sorting by keys
928 default: sub { lc $a cmp lc $b }
930 customs => HASH - special options for certain keys
931 (whose values are hashes themselves)
932 may contain: max_key_length, key_sort, customs
939 croak "first argument should be a hash ref" unless ref $_[0] eq 'HASH';
943 # Use a list to preserve order.
947 = exists $options->{key_sort} ? $options->{key_sort}
948 : sub { lc $a cmp lc $b };
950 croak "'key_sort' should be a coderef" unless ref $k_sort eq 'CODE';
951 @pairs = _sort_pairs($k_sort, \%hash);
952 } else { # list of pairs, no sorting
956 my $yaml = $options->{use_header} ? "--- #YAML:1.0\n" : '';
957 my $indent = $options->{indent} || '';
959 ($options->{max_key_length} || 20),
960 max(map { length($_) + 1 } grep { !ref $hash{$_} } keys %hash)
962 my $customs = $options->{customs} || {};
964 # printf format for key
965 my $k_format = "%-${k_length}s";
968 my($key, $val) = splice @pairs, 0, 2;
969 $val = '~' unless defined $val;
970 if(ref $val eq 'HASH') {
972 my %k_options = ( # options for recursive call
973 delta => $options->{delta},
975 indent => $indent . $options->{delta},
977 if (exists $customs->{$key}) {
978 my %k_custom = %{$customs->{$key}};
979 foreach my $k qw(key_sort max_key_length customs) {
980 $k_options{$k} = $k_custom{$k} if exists $k_custom{$k};
983 $yaml .= $indent . "$key:\n"
984 . _dump_hash(\%k_options, %$val);
987 $yaml .= $indent . "$key: {}\n";
990 elsif (ref $val eq 'ARRAY') {
992 $yaml .= $indent . "$key:\n";
995 croak "only nested arrays of non-refs are supported" if ref $_;
996 $yaml .= $indent . $options->{delta} . "- $_\n";
1000 $yaml .= $indent . "$key: []\n";
1003 elsif( ref $val and !blessed($val) ) {
1004 croak "only nested hashes, arrays and objects are supported";
1006 else { # if it's an object, just stringify it
1007 $yaml .= $indent . sprintf "$k_format %s\n", "$key:", $val;
1016 return eval { $_[0]->isa("UNIVERSAL"); };
1020 return (sort { $b <=> $a } @_)[0];
1024 return (sort { $a <=> $b } @_)[0];
1027 =head3 metafile_file
1029 my $meta_yml = $mm->metafile_file(@metadata_pairs);
1031 Turns the @metadata_pairs into YAML.
1033 This method does not implement a complete YAML dumper, being limited
1034 to dump a hash with values which are strings, undef's or nested hashes
1035 and arrays of strings. No quoting/escaping is done.
1042 my %dump_options = (
1047 return _dump_hash(\%dump_options, @_);
1052 =head3 distmeta_target
1054 my $make_frag = $mm->distmeta_target;
1056 Generates the distmeta target to add META.yml to the MANIFEST in the
1061 sub distmeta_target {
1064 my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
1065 eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) }
1066 or print "Could not add META.yml to MANIFEST: $${'@'}\n"
1069 my $add_meta_to_distdir = $self->cd('$(DISTVNAME)', $add_meta);
1071 return sprintf <<'MAKE', $add_meta_to_distdir;
1072 distmeta : create_distdir metafile
1080 =head3 realclean (o)
1082 Defines the realclean target.
1087 my($self, %attribs) = @_;
1089 my @dirs = qw($(DISTVNAME));
1090 my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD));
1092 # Special exception for the perl core where INST_* is not in blib.
1093 # This cleans up the files built from the ext/ directory (all XS).
1094 if( $self->{PERL_CORE} ) {
1095 push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR));
1096 push @files, values %{$self->{PM}};
1099 if( $self->has_link_code ){
1100 push @files, qw($(OBJECT));
1103 if( $attribs{FILES} ) {
1104 if( ref $attribs{FILES} ) {
1105 push @dirs, @{ $attribs{FILES} };
1108 push @dirs, split /\s+/, $attribs{FILES};
1112 # Occasionally files are repeated several times from different sources
1113 { my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
1114 { my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; }
1116 my $rm_cmd = join "\n\t", map { "$_" }
1117 $self->split_command('- $(RM_F)', @files);
1118 my $rmf_cmd = join "\n\t", map { "$_" }
1119 $self->split_command('- $(RM_RF)', @dirs);
1121 my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
1122 # Delete temporary files (via clean) and also delete dist files
1123 realclean purge :: clean realclean_subdirs
1128 $m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP};
1134 =head3 realclean_subdirs_target
1136 my $make_frag = $MM->realclean_subdirs_target;
1138 Returns the realclean_subdirs target. This is used by the realclean
1139 target to call realclean on any subdirectories which contain Makefiles.
1143 sub realclean_subdirs_target {
1146 return <<'NOOP_FRAG' unless @{$self->{DIR}};
1151 my $rclean = "realclean_subdirs :\n";
1153 foreach my $dir (@{$self->{DIR}}) {
1154 foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
1155 my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2);
1156 chdir '%s'; system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s';
1159 $rclean .= sprintf <<'RCLEAN', $subrclean;
1170 =head3 signature_target
1172 my $target = $mm->signature_target;
1174 Generate the signature target.
1176 Writes the file SIGNATURE with "cpansign -s".
1180 sub signature_target {
1183 return <<'MAKE_FRAG';
1191 =head3 distsignature_target
1193 my $make_frag = $mm->distsignature_target;
1195 Generates the distsignature target to add SIGNATURE to the MANIFEST in the
1200 sub distsignature_target {
1203 my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
1204 eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }
1205 or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n"
1208 my $sign_dist = $self->cd('$(DISTVNAME)' => 'cpansign -s');
1210 # cpansign -s complains if SIGNATURE is in the MANIFEST yet does not
1212 my $touch_sig = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE');
1213 my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign );
1215 return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_dist
1216 distsignature : create_distdir
1226 =head3 special_targets
1228 my $make_frag = $mm->special_targets
1230 Returns a make fragment containing any targets which have special
1231 meaning to make. For example, .SUFFIXES and .PHONY.
1235 sub special_targets {
1236 my $make_frag = <<'MAKE_FRAG';
1237 .SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
1239 .PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
1243 $make_frag .= <<'MAKE_FRAG' if $ENV{CLEARCASE_ROOT};
1244 .NO_CONFIG_REC: Makefile
1256 Methods which help initialize the MakeMaker object and macros.
1259 =head3 init_ABSTRACT
1268 if( $self->{ABSTRACT_FROM} and $self->{ABSTRACT} ) {
1269 warn "Both ABSTRACT_FROM and ABSTRACT are set. ".
1270 "Ignoring ABSTRACT_FROM.\n";
1274 if ($self->{ABSTRACT_FROM}){
1275 $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
1276 carp "WARNING: Setting ABSTRACT via file ".
1277 "'$self->{ABSTRACT_FROM}' failed\n";
1285 Called by init_main. Sets up all INST_* variables except those related
1286 to XS code. Those are handled in init_xs.
1293 $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
1294 $self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin');
1296 # INST_LIB typically pre-set if building an extension after
1297 # perl has been built and installed. Setting INST_LIB allows
1298 # you to build directly into, say $Config{privlibexp}.
1299 unless ($self->{INST_LIB}){
1300 if ($self->{PERL_CORE}) {
1301 if (defined $Cross::platform) {
1302 $self->{INST_LIB} = $self->{INST_ARCHLIB} =
1303 $self->catdir($self->{PERL_LIB},"..","xlib",
1307 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
1310 $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
1314 my @parentdir = split(/::/, $self->{PARENT_NAME});
1315 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir);
1316 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir);
1317 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto',
1319 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto',
1322 $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script');
1324 $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1');
1325 $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3');
1335 Called by init_main. Sets up all INSTALL_* variables (except
1336 INSTALLDIRS) and *PREFIX.
1343 if( $self->{ARGS}{INSTALL_BASE} and $self->{ARGS}{PREFIX} ) {
1344 die "Only one of PREFIX or INSTALL_BASE can be given. Not both.\n";
1347 if( $self->{ARGS}{INSTALL_BASE} ) {
1348 $self->init_INSTALL_from_INSTALL_BASE;
1351 $self->init_INSTALL_from_PREFIX;
1356 =head3 init_INSTALL_from_PREFIX
1358 $mm->init_INSTALL_from_PREFIX;
1362 sub init_INSTALL_from_PREFIX {
1365 $self->init_lib2arch;
1367 # There are often no Config.pm defaults for these new man variables so
1368 # we fall back to the old behavior which is to use installman*dir
1369 foreach my $num (1, 3) {
1370 my $k = 'installsiteman'.$num.'dir';
1372 $self->{uc $k} ||= uc "\$(installman${num}dir)"
1376 foreach my $num (1, 3) {
1377 my $k = 'installvendorman'.$num.'dir';
1379 unless( $Config{$k} ) {
1380 $self->{uc $k} ||= $Config{usevendorprefix}
1381 ? uc "\$(installman${num}dir)"
1386 $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)'
1387 unless $Config{installsitebin};
1388 $self->{INSTALLSITESCRIPT} ||= '$(INSTALLSCRIPT)'
1389 unless $Config{installsitescript};
1391 unless( $Config{installvendorbin} ) {
1392 $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix}
1393 ? $Config{installbin}
1396 unless( $Config{installvendorscript} ) {
1397 $self->{INSTALLVENDORSCRIPT} ||= $Config{usevendorprefix}
1398 ? $Config{installscript}
1403 my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
1404 $Config{prefixexp} || $Config{prefix} || '';
1405 my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : '';
1406 my $sprefix = $Config{siteprefixexp} || '';
1408 # 5.005_03 doesn't have a siteprefix.
1409 $sprefix = $iprefix unless $sprefix;
1412 $self->{PREFIX} ||= '';
1414 if( $self->{PREFIX} ) {
1415 @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
1419 $self->{PERLPREFIX} ||= $iprefix;
1420 $self->{SITEPREFIX} ||= $sprefix;
1421 $self->{VENDORPREFIX} ||= $vprefix;
1423 # Lots of MM extension authors like to use $(PREFIX) so we
1424 # put something sensible in there no matter what.
1425 $self->{PREFIX} = '$('.uc $self->{INSTALLDIRS}.'PREFIX)';
1428 my $arch = $Config{archname};
1429 my $version = $Config{version};
1432 my $libstyle = $Config{installstyle} || 'lib/perl5';
1435 if( $self->{LIBSTYLE} ) {
1436 $libstyle = $self->{LIBSTYLE};
1437 $manstyle = $self->{LIBSTYLE} eq 'lib/perl5' ? 'lib/perl5' : '';
1440 # Some systems, like VOS, set installman*dir to '' if they can't
1442 for my $num (1, 3) {
1443 $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
1444 unless $Config{'installman'.$num.'dir'};
1449 bin => { s => $iprefix,
1452 vendorbin => { s => $vprefix,
1455 sitebin => { s => $sprefix,
1458 script => { s => $iprefix,
1461 vendorscript=> { s => $vprefix,
1464 sitescript => { s => $sprefix,
1471 man1dir => { s => $iprefix,
1474 style => $manstyle, },
1475 siteman1dir => { s => $sprefix,
1478 style => $manstyle, },
1479 vendorman1dir => { s => $vprefix,
1482 style => $manstyle, },
1484 man3dir => { s => $iprefix,
1487 style => $manstyle, },
1488 siteman3dir => { s => $sprefix,
1491 style => $manstyle, },
1492 vendorman3dir => { s => $vprefix,
1495 style => $manstyle, },
1500 privlib => { s => $iprefix,
1503 style => $libstyle, },
1504 vendorlib => { s => $vprefix,
1507 style => $libstyle, },
1508 sitelib => { s => $sprefix,
1511 style => $libstyle, },
1513 archlib => { s => $iprefix,
1515 d => "$version/$arch",
1516 style => $libstyle },
1517 vendorarch => { s => $vprefix,
1519 d => "$version/$arch",
1520 style => $libstyle },
1521 sitearch => { s => $sprefix,
1523 d => "site_perl/$version/$arch",
1524 style => $libstyle },
1528 # Special case for LIB.
1529 if( $self->{LIB} ) {
1530 foreach my $var (keys %lib_layouts) {
1531 my $Installvar = uc "install$var";
1533 if( $var =~ /arch/ ) {
1534 $self->{$Installvar} ||=
1535 $self->catdir($self->{LIB}, $Config{archname});
1538 $self->{$Installvar} ||= $self->{LIB};
1543 my %type2prefix = ( perl => 'PERLPREFIX',
1544 site => 'SITEPREFIX',
1545 vendor => 'VENDORPREFIX'
1548 my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
1549 while( my($var, $layout) = each(%layouts) ) {
1550 my($s, $t, $d, $style) = @{$layout}{qw(s t d style)};
1551 my $r = '$('.$type2prefix{$t}.')';
1553 print STDERR "Prefixing $var\n" if $Verbose >= 2;
1555 my $installvar = "install$var";
1556 my $Installvar = uc $installvar;
1557 next if $self->{$Installvar};
1559 $d = "$style/$d" if $style;
1560 $self->prefixify($installvar, $s, $r, $d);
1562 print STDERR " $Installvar == $self->{$Installvar}\n"
1566 # Generate these if they weren't figured out.
1567 $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH};
1568 $self->{VENDORLIBEXP} ||= $self->{INSTALLVENDORLIB};
1574 =head3 init_from_INSTALL_BASE
1576 $mm->init_from_INSTALL_BASE
1581 lib => [qw(lib perl5)],
1582 arch => [('lib', 'perl5', $Config{archname})],
1584 man1dir => [qw(man man1)],
1585 man3dir => [qw(man man3)]
1587 $map{script} = $map{bin};
1589 sub init_INSTALL_from_INSTALL_BASE {
1592 @{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} =
1596 foreach my $thing (keys %map) {
1597 foreach my $dir (('', 'SITE', 'VENDOR')) {
1598 my $uc_thing = uc $thing;
1599 my $key = "INSTALL".$dir.$uc_thing;
1602 $self->catdir('$(INSTALL_BASE)', @{$map{$thing}});
1606 # Adjust for variable quirks.
1607 $install{INSTALLARCHLIB} ||= delete $install{INSTALLARCH};
1608 $install{INSTALLPRIVLIB} ||= delete $install{INSTALLLIB};
1610 foreach my $key (keys %install) {
1611 $self->{$key} ||= $install{$key};
1618 =head3 init_VERSION I<Abstract>
1622 Initialize macros representing versions of MakeMaker and other tools
1624 MAKEMAKER: path to the MakeMaker module.
1626 MM_VERSION: ExtUtils::MakeMaker Version
1628 MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards
1631 VERSION: version of your module
1633 VERSION_MACRO: which macro represents the version (usually 'VERSION')
1635 VERSION_SYM: like version but safe for use as an RCS revision number
1637 DEFINE_VERSION: -D line to set the module version when compiling
1639 XS_VERSION: version in your .xs file. Defaults to $(VERSION)
1641 XS_VERSION_MACRO: which macro represents the XS version.
1643 XS_DEFINE_VERSION: -D line to set the xs version when compiling.
1645 Called by init_main.
1652 $self->{MAKEMAKER} = $ExtUtils::MakeMaker::Filename;
1653 $self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION;
1654 $self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision;
1655 $self->{VERSION_FROM} ||= '';
1657 if ($self->{VERSION_FROM}){
1658 $self->{VERSION} = $self->parse_version($self->{VERSION_FROM});
1659 if( $self->{VERSION} eq 'undef' ) {
1660 carp("WARNING: Setting VERSION via file ".
1661 "'$self->{VERSION_FROM}' failed\n");
1666 if (defined $self->{VERSION}) {
1667 $self->{VERSION} =~ s/^\s+//;
1668 $self->{VERSION} =~ s/\s+$//;
1671 $self->{VERSION} = '';
1675 $self->{VERSION_MACRO} = 'VERSION';
1676 ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
1677 $self->{DEFINE_VERSION} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
1680 # Graham Barr and Paul Marquess had some ideas how to ensure
1681 # version compatibility between the *.pm file and the
1682 # corresponding *.xs file. The bottomline was, that we need an
1683 # XS_VERSION macro that defaults to VERSION:
1684 $self->{XS_VERSION} ||= $self->{VERSION};
1686 $self->{XS_VERSION_MACRO} = 'XS_VERSION';
1687 $self->{XS_DEFINE_VERSION} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
1696 Initializes the macro definitions used by tools_other() and places them
1699 If there is no description, its the same as the parameter to
1700 WriteMakefile() documented in ExtUtils::MakeMaker.
1702 Defines at least these macros.
1707 NOECHO Tell make not to display the command itself
1712 MAKE_APERL_FILE File used by MAKE_APERL
1714 SHELL Program used to run shell commands
1716 ECHO Print text adding a newline on the end
1718 RM_RF Remove a directory
1719 TOUCH Update a file's timestamp
1720 TEST_F Test for a file's existence
1723 CHMOD Change permissions on a file
1724 FALSE Exit with non-zero
1727 UMASK_NULL Nullify umask
1728 DEV_NULL Suppress all command output
1735 $self->{ECHO} ||= $self->oneliner('print qq{@ARGV}', ['-l']);
1736 $self->{ECHO_N} ||= $self->oneliner('print qq{@ARGV}');
1738 $self->{TOUCH} ||= $self->oneliner('touch', ["-MExtUtils::Command"]);
1739 $self->{CHMOD} ||= $self->oneliner('chmod', ["-MExtUtils::Command"]);
1740 $self->{RM_F} ||= $self->oneliner('rm_f', ["-MExtUtils::Command"]);
1741 $self->{RM_RF} ||= $self->oneliner('rm_rf', ["-MExtUtils::Command"]);
1742 $self->{TEST_F} ||= $self->oneliner('test_f', ["-MExtUtils::Command"]);
1743 $self->{FALSE} ||= $self->oneliner('exit 1');
1744 $self->{TRUE} ||= $self->oneliner('exit 0');
1746 $self->{MKPATH} ||= $self->oneliner('mkpath', ["-MExtUtils::Command"]);
1748 $self->{CP} ||= $self->oneliner('cp', ["-MExtUtils::Command"]);
1749 $self->{MV} ||= $self->oneliner('mv', ["-MExtUtils::Command"]);
1751 $self->{MOD_INSTALL} ||=
1752 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1753 install([ from_to => {@ARGV}, verbose => '$(VERBINST)', uninstall_shadows => '$(UNINST)', dir_mode => '$(PERM_DIR)' ]);
1755 $self->{DOC_INSTALL} ||= $self->oneliner('perllocal_install', ["-MExtUtils::Command::MM"]);
1756 $self->{UNINSTALL} ||= $self->oneliner('uninstall', ["-MExtUtils::Command::MM"]);
1757 $self->{WARN_IF_OLD_PACKLIST} ||=
1758 $self->oneliner('warn_if_old_packlist', ["-MExtUtils::Command::MM"]);
1759 $self->{FIXIN} ||= $self->oneliner('MY->fixin(shift)', ["-MExtUtils::MY"]);
1760 $self->{EQUALIZE_TIMESTAMP} ||= $self->oneliner('eqtime', ["-MExtUtils::Command"]);
1762 $self->{UNINST} ||= 0;
1763 $self->{VERBINST} ||= 0;
1765 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
1766 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1767 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1768 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1770 # Not everybody uses -f to indicate "use this Makefile instead"
1771 $self->{USEMAKEFILE} ||= '-f';
1773 # Some makes require a wrapper around macros passed in on the command
1775 $self->{MACROSTART} ||= '';
1776 $self->{MACROEND} ||= '';
1778 $self->{SHELL} ||= $Config{sh};
1780 # UMASK_NULL is not used by MakeMaker but some CPAN modules
1782 $self->{UMASK_NULL} ||= "umask 0";
1784 # Not the greatest default, but its something.
1785 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1787 $self->{NOOP} ||= '$(TRUE)';
1788 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1790 $self->{LD_RUN_PATH} = "";
1792 $self->{LIBS} = $self->_fix_libs($self->{LIBS});
1794 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1795 foreach my $libs ( @{$self->{LIBS}} ){
1796 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1797 my(@libs) = $self->extliblist($libs);
1798 if ($libs[0] or $libs[1] or $libs[2]){
1799 # LD_RUN_PATH now computed by ExtUtils::Liblist
1800 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1801 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1806 if ( $self->{OBJECT} ) {
1807 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1809 # init_dirscan should have found out, if we have C files
1810 $self->{OBJECT} = "";
1811 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1813 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1815 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1816 $self->{PERLMAINCC} ||= '$(CC)';
1817 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1819 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1820 # the 'dynamic' section of MM. We don't have this problem with
1821 # 'static', since we either must use it (%Config says we can't
1822 # use dynamic loading) or the caller asked for it explicitly.
1823 if (!$self->{LINKTYPE}) {
1824 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1826 : ($Config{usedl} ? 'dynamic' : 'static');
1833 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1834 # undefined. In any case we turn it into an anon array
1836 my($self, $libs) = @_;
1838 return !defined $libs ? [''] :
1839 !ref $libs ? [$libs] :
1840 !defined $libs->[0] ? [''] :
1847 my $make_frag = $MM->tools_other;
1849 Returns a make fragment containing definitions for the macros init_others()
1858 # We set PM_FILTER as late as possible so it can see all the earlier
1859 # on macro-order sensitive makes such as nmake.
1860 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
1861 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
1865 MOD_INSTALL DOC_INSTALL UNINSTALL
1866 WARN_IF_OLD_PACKLIST
1873 next unless defined $self->{$tool};
1874 push @m, "$tool = $self->{$tool}\n";
1881 =head3 init_DIRFILESEP I<Abstract>
1883 $MM->init_DIRFILESEP;
1884 my $dirfilesep = $MM->{DIRFILESEP};
1886 Initializes the DIRFILESEP macro which is the seperator between the
1887 directory and filename in a filepath. ie. / on Unix, \ on Win32 and
1892 # instead of $(INST_ARCHAUTODIR)/extralibs.ld
1893 $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
1895 Something of a hack but it prevents a lot of code duplication between
1898 Do not use this as a seperator between directories. Some operating
1899 systems use different seperators between subdirectories as between
1900 directories and filenames (for example: VOLUME:[dir1.dir2]file on VMS).
1902 =head3 init_linker I<Abstract>
1906 Initialize macros which have to do with linking.
1908 PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
1911 PERL_ARCHIVE_AFTER: path to a library which should be put on the
1912 linker command line I<after> the external libraries to be linked to
1913 dynamic extensions. This may be needed if the linker is one-pass, and
1914 Perl includes some overrides for C RTL functions, such as malloc().
1916 EXPORT_LIST: name of a file that is passed to linker to define symbols
1919 Some OSes do not need these in which case leave it blank.
1922 =head3 init_platform
1926 Initialize any macros which are for platform specific use only.
1928 A typical one is the version number of your OS specific mocule.
1929 (ie. MM_Unix_VERSION or MM_VMS_VERSION).
1942 Initialize MAKE from either a MAKE environment variable or $Config{make}.
1949 $self->{MAKE} ||= $ENV{MAKE} || $Config{make};
1955 A grab bag of methods to generate specific macros and commands.
1961 Defines targets and routines to translate the pods into manpages and
1962 put them into the INST_* directories.
1969 my $POD2MAN_macro = $self->POD2MAN_macro();
1970 my $manifypods_target = $self->manifypods_target();
1972 return <<END_OF_TARGET;
1983 =head3 POD2MAN_macro
1985 my $pod2man_macro = $self->POD2MAN_macro
1987 Returns a definition for the POD2MAN macro. This is a program
1988 which emulates the pod2man utility. You can add more switches to the
1989 command by simply appending them on the macro.
1993 $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
2000 # Need the trailing '--' so perl stops gobbling arguments and - happens
2001 # to be an alternative end of line seperator on VMS so we quote it
2002 return <<'END_OF_DEF';
2003 POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
2004 POD2MAN = $(POD2MAN_EXE)
2009 =head3 test_via_harness
2011 my $command = $mm->test_via_harness($perl, $tests);
2013 Returns a $command line which runs the given set of $tests with
2014 Test::Harness and the given $perl.
2016 Used on the t/*.t files.
2020 sub test_via_harness {
2021 my($self, $perl, $tests) = @_;
2023 return qq{\t$perl "-MExtUtils::Command::MM" }.
2024 qq{"-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
2027 =head3 test_via_script
2029 my $command = $mm->test_via_script($perl, $script);
2031 Returns a $command line which just runs a single test without
2032 Test::Harness. No checks are done on the results, they're just
2035 Used for test.pl, since they don't always follow Test::Harness
2040 sub test_via_script {
2041 my($self, $perl, $script) = @_;
2042 return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
2046 =head3 tool_autosplit
2048 Defines a simple perl call that runs autosplit. May be deprecated by
2053 sub tool_autosplit {
2054 my($self, %attribs) = @_;
2056 my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};'
2059 my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
2060 use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
2063 return sprintf <<'MAKE_FRAG', $asplit;
2064 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
2074 my $arch_ok = $mm->arch_check(
2076 File::Spec->catfile($Config{archlibexp}, "Config.pm")
2079 A sanity check that what Perl thinks the architecture is and what
2080 Config thinks the architecture is are the same. If they're not it
2081 will return false and show a diagnostic message.
2083 When building Perl it will always return true, as nothing is installed
2086 The interface is a bit odd because this is the result of a
2087 quick refactoring. Don't rely on it.
2093 my($pconfig, $cconfig) = @_;
2095 return 1 if $self->{PERL_SRC};
2097 my($pvol, $pthinks) = $self->splitpath($pconfig);
2098 my($cvol, $cthinks) = $self->splitpath($cconfig);
2100 $pthinks = $self->canonpath($pthinks);
2101 $cthinks = $self->canonpath($cthinks);
2104 if ($pthinks ne $cthinks) {
2105 print "Have $pthinks\n";
2106 print "Want $cthinks\n";
2110 my $arch = (grep length, $self->splitdir($pthinks))[-1];
2112 print STDOUT <<END unless $self->{UNINSTALLED_PERL};
2113 Your perl and your Config.pm seem to have different ideas about the
2114 architecture they are running on.
2115 Perl thinks: [$arch]
2116 Config says: [$Config{archname}]
2117 This may or may not cause problems. Please check your installation of perl
2118 if you have problems building this extension.
2127 =head2 File::Spec wrappers
2129 ExtUtils::MM_Any is a subclass of File::Spec. The methods noted here
2130 override File::Spec.
2136 File::Spec <= 0.83 has a bug where the file part of catfile is not
2137 canonicalized. This override fixes that bug.
2143 return $self->canonpath($self->SUPER::catfile(@_));
2150 Methods I can't really figure out where they should go yet.
2155 my $test = $mm->find_tests;
2157 Returns a string suitable for feeding to the shell to return all
2164 return -d 't' ? 't/*.t' : '';
2168 =head3 extra_clean_files
2170 my @files_to_clean = $MM->extra_clean_files;
2172 Returns a list of OS specific files to be removed in the clean target in
2173 addition to the usual set.
2177 # An empty method here tickled a perl 5.8.1 bug and would return its object.
2178 sub extra_clean_files {
2185 my @installvars = $mm->installvars;
2187 A list of all the INSTALL* variables without the INSTALL prefix. Useful
2188 for iteration or building related variable sets.
2193 return qw(PRIVLIB SITELIB VENDORLIB
2194 ARCHLIB SITEARCH VENDORARCH
2195 BIN SITEBIN VENDORBIN
2196 SCRIPT SITESCRIPT VENDORSCRIPT
2197 MAN1DIR SITEMAN1DIR VENDORMAN1DIR
2198 MAN3DIR SITEMAN3DIR VENDORMAN3DIR
2205 my $wanted = $self->libscan($path);
2207 Takes a path to a file or dir and returns an empty string if we don't
2208 want to include this file in the library. Otherwise it returns the
2209 the $path unchanged.
2211 Mainly used to exclude version control administrative directories from
2217 my($self,$path) = @_;
2218 my($dirs,$file) = ($self->splitpath($path))[1,2];
2219 return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/,
2220 $self->splitdir($dirs), $file;
2226 =head3 platform_constants
2228 my $make_frag = $mm->platform_constants
2230 Returns a make fragment defining all the macros initialized in
2231 init_platform() rather than put them in constants().
2235 sub platform_constants {
2242 Michael G Schwern <schwern@pobox.com> and the denizens of
2243 makemaker@perl.org with code from ExtUtils::MM_Unix and