1 package ExtUtils::MM_Any;
4 our $VERSION = '6.55_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')
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 # Check the original args so we can tell between the user setting it
842 # to an empty hash and it just being initialized.
843 my $configure_requires;
844 if( $self->{ARGS}{CONFIGURE_REQUIRES} ) {
845 $configure_requires = $self->{CONFIGURE_REQUIRES};
847 $configure_requires = {
848 'ExtUtils::MakeMaker' => 0,
852 if( $self->{ARGS}{BUILD_REQUIRES} ) {
853 $build_requires = $self->{BUILD_REQUIRES};
856 'ExtUtils::MakeMaker' => 0,
861 name => $self->{DISTNAME},
862 version => $self->{VERSION},
863 abstract => $self->{ABSTRACT},
864 license => $self->{LICENSE} || 'unknown',
865 distribution_type => $self->{PM} ? 'module' : 'script',
867 configure_requires => $configure_requires,
869 build_requires => $build_requires,
872 directory => [qw(t inc)]
875 generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
877 url => 'http://module-build.sourceforge.net/META-spec-v1.4.html',
882 # The author key is required and it takes a list.
883 $meta{author} = defined $self->{AUTHOR} ? [$self->{AUTHOR}] : [];
885 $meta{requires} = $self->{PREREQ_PM} if defined $self->{PREREQ_PM};
886 $meta{requires}{perl} = $self->{MIN_PERL_VERSION} if $self->{MIN_PERL_VERSION};
888 while( my($key, $val) = each %$meta_add ) {
892 while( my($key, $val) = each %$meta_merge ) {
893 $self->_hash_merge(\%meta, $key, $val);
898 # Put the standard keys first in the proper order.
899 for my $key (@meta_order) {
900 next unless exists $meta{$key};
902 push @meta_pairs, $key, delete $meta{$key};
905 # Then tack everything else onto the end, alpha sorted.
906 for my $key (sort {lc $a cmp lc $b} keys %meta) {
907 push @meta_pairs, $key, $meta{$key};
917 $yaml = _dump_hash(\%options, %hash);
919 Implements a fake YAML dumper for a hash given
920 as a list of pairs. No quoting/escaping is done. Keys
921 are supposed to be strings. Values are undef, strings,
922 hash refs or array refs of strings.
924 Supported options are:
926 delta => STR - indentation delta
927 use_header => BOOL - whether to include a YAML header
928 indent => STR - a string of spaces
931 max_key_length => INT - maximum key length used to align
932 keys and values of the same hash
934 key_sort => CODE - a sort sub
935 It may be undef, which means no sorting by keys
936 default: sub { lc $a cmp lc $b }
938 customs => HASH - special options for certain keys
939 (whose values are hashes themselves)
940 may contain: max_key_length, key_sort, customs
947 croak "first argument should be a hash ref" unless ref $_[0] eq 'HASH';
951 # Use a list to preserve order.
955 = exists $options->{key_sort} ? $options->{key_sort}
956 : sub { lc $a cmp lc $b };
958 croak "'key_sort' should be a coderef" unless ref $k_sort eq 'CODE';
959 @pairs = _sort_pairs($k_sort, \%hash);
960 } else { # list of pairs, no sorting
964 my $yaml = $options->{use_header} ? "--- #YAML:1.0\n" : '';
965 my $indent = $options->{indent} || '';
967 ($options->{max_key_length} || 20),
968 max(map { length($_) + 1 } grep { !ref $hash{$_} } keys %hash)
970 my $customs = $options->{customs} || {};
972 # printf format for key
973 my $k_format = "%-${k_length}s";
976 my($key, $val) = splice @pairs, 0, 2;
977 $val = '~' unless defined $val;
978 if(ref $val eq 'HASH') {
980 my %k_options = ( # options for recursive call
981 delta => $options->{delta},
983 indent => $indent . $options->{delta},
985 if (exists $customs->{$key}) {
986 my %k_custom = %{$customs->{$key}};
987 foreach my $k qw(key_sort max_key_length customs) {
988 $k_options{$k} = $k_custom{$k} if exists $k_custom{$k};
991 $yaml .= $indent . "$key:\n"
992 . _dump_hash(\%k_options, %$val);
995 $yaml .= $indent . "$key: {}\n";
998 elsif (ref $val eq 'ARRAY') {
1000 $yaml .= $indent . "$key:\n";
1003 croak "only nested arrays of non-refs are supported" if ref $_;
1004 $yaml .= $indent . $options->{delta} . "- $_\n";
1008 $yaml .= $indent . "$key: []\n";
1011 elsif( ref $val and !blessed($val) ) {
1012 croak "only nested hashes, arrays and objects are supported";
1014 else { # if it's an object, just stringify it
1015 $yaml .= $indent . sprintf "$k_format %s\n", "$key:", $val;
1024 return eval { $_[0]->isa("UNIVERSAL"); };
1028 return (sort { $b <=> $a } @_)[0];
1032 return (sort { $a <=> $b } @_)[0];
1035 =head3 metafile_file
1037 my $meta_yml = $mm->metafile_file(@metadata_pairs);
1039 Turns the @metadata_pairs into YAML.
1041 This method does not implement a complete YAML dumper, being limited
1042 to dump a hash with values which are strings, undef's or nested hashes
1043 and arrays of strings. No quoting/escaping is done.
1050 my %dump_options = (
1055 return _dump_hash(\%dump_options, @_);
1060 =head3 distmeta_target
1062 my $make_frag = $mm->distmeta_target;
1064 Generates the distmeta target to add META.yml to the MANIFEST in the
1069 sub distmeta_target {
1072 my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
1073 eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) }
1074 or print "Could not add META.yml to MANIFEST: $${'@'}\n"
1077 my $add_meta_to_distdir = $self->cd('$(DISTVNAME)', $add_meta);
1079 return sprintf <<'MAKE', $add_meta_to_distdir;
1080 distmeta : create_distdir metafile
1088 =head3 realclean (o)
1090 Defines the realclean target.
1095 my($self, %attribs) = @_;
1097 my @dirs = qw($(DISTVNAME));
1098 my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD));
1100 # Special exception for the perl core where INST_* is not in blib.
1101 # This cleans up the files built from the ext/ directory (all XS).
1102 if( $self->{PERL_CORE} ) {
1103 push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR));
1104 push @files, values %{$self->{PM}};
1107 if( $self->has_link_code ){
1108 push @files, qw($(OBJECT));
1111 if( $attribs{FILES} ) {
1112 if( ref $attribs{FILES} ) {
1113 push @dirs, @{ $attribs{FILES} };
1116 push @dirs, split /\s+/, $attribs{FILES};
1120 # Occasionally files are repeated several times from different sources
1121 { my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
1122 { my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; }
1124 my $rm_cmd = join "\n\t", map { "$_" }
1125 $self->split_command('- $(RM_F)', @files);
1126 my $rmf_cmd = join "\n\t", map { "$_" }
1127 $self->split_command('- $(RM_RF)', @dirs);
1129 my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
1130 # Delete temporary files (via clean) and also delete dist files
1131 realclean purge :: clean realclean_subdirs
1136 $m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP};
1142 =head3 realclean_subdirs_target
1144 my $make_frag = $MM->realclean_subdirs_target;
1146 Returns the realclean_subdirs target. This is used by the realclean
1147 target to call realclean on any subdirectories which contain Makefiles.
1151 sub realclean_subdirs_target {
1154 return <<'NOOP_FRAG' unless @{$self->{DIR}};
1159 my $rclean = "realclean_subdirs :\n";
1161 foreach my $dir (@{$self->{DIR}}) {
1162 foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
1163 my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2);
1164 chdir '%s'; system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s';
1167 $rclean .= sprintf <<'RCLEAN', $subrclean;
1178 =head3 signature_target
1180 my $target = $mm->signature_target;
1182 Generate the signature target.
1184 Writes the file SIGNATURE with "cpansign -s".
1188 sub signature_target {
1191 return <<'MAKE_FRAG';
1199 =head3 distsignature_target
1201 my $make_frag = $mm->distsignature_target;
1203 Generates the distsignature target to add SIGNATURE to the MANIFEST in the
1208 sub distsignature_target {
1211 my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
1212 eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }
1213 or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n"
1216 my $sign_dist = $self->cd('$(DISTVNAME)' => 'cpansign -s');
1218 # cpansign -s complains if SIGNATURE is in the MANIFEST yet does not
1220 my $touch_sig = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE');
1221 my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign );
1223 return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_dist
1224 distsignature : create_distdir
1234 =head3 special_targets
1236 my $make_frag = $mm->special_targets
1238 Returns a make fragment containing any targets which have special
1239 meaning to make. For example, .SUFFIXES and .PHONY.
1243 sub special_targets {
1244 my $make_frag = <<'MAKE_FRAG';
1245 .SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
1247 .PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
1251 $make_frag .= <<'MAKE_FRAG' if $ENV{CLEARCASE_ROOT};
1252 .NO_CONFIG_REC: Makefile
1264 Methods which help initialize the MakeMaker object and macros.
1267 =head3 init_ABSTRACT
1276 if( $self->{ABSTRACT_FROM} and $self->{ABSTRACT} ) {
1277 warn "Both ABSTRACT_FROM and ABSTRACT are set. ".
1278 "Ignoring ABSTRACT_FROM.\n";
1282 if ($self->{ABSTRACT_FROM}){
1283 $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
1284 carp "WARNING: Setting ABSTRACT via file ".
1285 "'$self->{ABSTRACT_FROM}' failed\n";
1293 Called by init_main. Sets up all INST_* variables except those related
1294 to XS code. Those are handled in init_xs.
1301 $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
1302 $self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin');
1304 # INST_LIB typically pre-set if building an extension after
1305 # perl has been built and installed. Setting INST_LIB allows
1306 # you to build directly into, say $Config{privlibexp}.
1307 unless ($self->{INST_LIB}){
1308 if ($self->{PERL_CORE}) {
1309 if (defined $Cross::platform) {
1310 $self->{INST_LIB} = $self->{INST_ARCHLIB} =
1311 $self->catdir($self->{PERL_LIB},"..","xlib",
1315 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
1318 $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
1322 my @parentdir = split(/::/, $self->{PARENT_NAME});
1323 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir);
1324 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir);
1325 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto',
1327 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto',
1330 $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script');
1332 $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1');
1333 $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3');
1343 Called by init_main. Sets up all INSTALL_* variables (except
1344 INSTALLDIRS) and *PREFIX.
1351 if( $self->{ARGS}{INSTALL_BASE} and $self->{ARGS}{PREFIX} ) {
1352 die "Only one of PREFIX or INSTALL_BASE can be given. Not both.\n";
1355 if( $self->{ARGS}{INSTALL_BASE} ) {
1356 $self->init_INSTALL_from_INSTALL_BASE;
1359 $self->init_INSTALL_from_PREFIX;
1364 =head3 init_INSTALL_from_PREFIX
1366 $mm->init_INSTALL_from_PREFIX;
1370 sub init_INSTALL_from_PREFIX {
1373 $self->init_lib2arch;
1375 # There are often no Config.pm defaults for these new man variables so
1376 # we fall back to the old behavior which is to use installman*dir
1377 foreach my $num (1, 3) {
1378 my $k = 'installsiteman'.$num.'dir';
1380 $self->{uc $k} ||= uc "\$(installman${num}dir)"
1384 foreach my $num (1, 3) {
1385 my $k = 'installvendorman'.$num.'dir';
1387 unless( $Config{$k} ) {
1388 $self->{uc $k} ||= $Config{usevendorprefix}
1389 ? uc "\$(installman${num}dir)"
1394 $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)'
1395 unless $Config{installsitebin};
1396 $self->{INSTALLSITESCRIPT} ||= '$(INSTALLSCRIPT)'
1397 unless $Config{installsitescript};
1399 unless( $Config{installvendorbin} ) {
1400 $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix}
1401 ? $Config{installbin}
1404 unless( $Config{installvendorscript} ) {
1405 $self->{INSTALLVENDORSCRIPT} ||= $Config{usevendorprefix}
1406 ? $Config{installscript}
1411 my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
1412 $Config{prefixexp} || $Config{prefix} || '';
1413 my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : '';
1414 my $sprefix = $Config{siteprefixexp} || '';
1416 # 5.005_03 doesn't have a siteprefix.
1417 $sprefix = $iprefix unless $sprefix;
1420 $self->{PREFIX} ||= '';
1422 if( $self->{PREFIX} ) {
1423 @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
1427 $self->{PERLPREFIX} ||= $iprefix;
1428 $self->{SITEPREFIX} ||= $sprefix;
1429 $self->{VENDORPREFIX} ||= $vprefix;
1431 # Lots of MM extension authors like to use $(PREFIX) so we
1432 # put something sensible in there no matter what.
1433 $self->{PREFIX} = '$('.uc $self->{INSTALLDIRS}.'PREFIX)';
1436 my $arch = $Config{archname};
1437 my $version = $Config{version};
1440 my $libstyle = $Config{installstyle} || 'lib/perl5';
1443 if( $self->{LIBSTYLE} ) {
1444 $libstyle = $self->{LIBSTYLE};
1445 $manstyle = $self->{LIBSTYLE} eq 'lib/perl5' ? 'lib/perl5' : '';
1448 # Some systems, like VOS, set installman*dir to '' if they can't
1450 for my $num (1, 3) {
1451 $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
1452 unless $Config{'installman'.$num.'dir'};
1457 bin => { s => $iprefix,
1460 vendorbin => { s => $vprefix,
1463 sitebin => { s => $sprefix,
1466 script => { s => $iprefix,
1469 vendorscript=> { s => $vprefix,
1472 sitescript => { s => $sprefix,
1479 man1dir => { s => $iprefix,
1482 style => $manstyle, },
1483 siteman1dir => { s => $sprefix,
1486 style => $manstyle, },
1487 vendorman1dir => { s => $vprefix,
1490 style => $manstyle, },
1492 man3dir => { s => $iprefix,
1495 style => $manstyle, },
1496 siteman3dir => { s => $sprefix,
1499 style => $manstyle, },
1500 vendorman3dir => { s => $vprefix,
1503 style => $manstyle, },
1508 privlib => { s => $iprefix,
1511 style => $libstyle, },
1512 vendorlib => { s => $vprefix,
1515 style => $libstyle, },
1516 sitelib => { s => $sprefix,
1519 style => $libstyle, },
1521 archlib => { s => $iprefix,
1523 d => "$version/$arch",
1524 style => $libstyle },
1525 vendorarch => { s => $vprefix,
1527 d => "$version/$arch",
1528 style => $libstyle },
1529 sitearch => { s => $sprefix,
1531 d => "site_perl/$version/$arch",
1532 style => $libstyle },
1536 # Special case for LIB.
1537 if( $self->{LIB} ) {
1538 foreach my $var (keys %lib_layouts) {
1539 my $Installvar = uc "install$var";
1541 if( $var =~ /arch/ ) {
1542 $self->{$Installvar} ||=
1543 $self->catdir($self->{LIB}, $Config{archname});
1546 $self->{$Installvar} ||= $self->{LIB};
1551 my %type2prefix = ( perl => 'PERLPREFIX',
1552 site => 'SITEPREFIX',
1553 vendor => 'VENDORPREFIX'
1556 my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
1557 while( my($var, $layout) = each(%layouts) ) {
1558 my($s, $t, $d, $style) = @{$layout}{qw(s t d style)};
1559 my $r = '$('.$type2prefix{$t}.')';
1561 print STDERR "Prefixing $var\n" if $Verbose >= 2;
1563 my $installvar = "install$var";
1564 my $Installvar = uc $installvar;
1565 next if $self->{$Installvar};
1567 $d = "$style/$d" if $style;
1568 $self->prefixify($installvar, $s, $r, $d);
1570 print STDERR " $Installvar == $self->{$Installvar}\n"
1574 # Generate these if they weren't figured out.
1575 $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH};
1576 $self->{VENDORLIBEXP} ||= $self->{INSTALLVENDORLIB};
1582 =head3 init_from_INSTALL_BASE
1584 $mm->init_from_INSTALL_BASE
1589 lib => [qw(lib perl5)],
1590 arch => [('lib', 'perl5', $Config{archname})],
1592 man1dir => [qw(man man1)],
1593 man3dir => [qw(man man3)]
1595 $map{script} = $map{bin};
1597 sub init_INSTALL_from_INSTALL_BASE {
1600 @{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} =
1604 foreach my $thing (keys %map) {
1605 foreach my $dir (('', 'SITE', 'VENDOR')) {
1606 my $uc_thing = uc $thing;
1607 my $key = "INSTALL".$dir.$uc_thing;
1610 $self->catdir('$(INSTALL_BASE)', @{$map{$thing}});
1614 # Adjust for variable quirks.
1615 $install{INSTALLARCHLIB} ||= delete $install{INSTALLARCH};
1616 $install{INSTALLPRIVLIB} ||= delete $install{INSTALLLIB};
1618 foreach my $key (keys %install) {
1619 $self->{$key} ||= $install{$key};
1626 =head3 init_VERSION I<Abstract>
1630 Initialize macros representing versions of MakeMaker and other tools
1632 MAKEMAKER: path to the MakeMaker module.
1634 MM_VERSION: ExtUtils::MakeMaker Version
1636 MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards
1639 VERSION: version of your module
1641 VERSION_MACRO: which macro represents the version (usually 'VERSION')
1643 VERSION_SYM: like version but safe for use as an RCS revision number
1645 DEFINE_VERSION: -D line to set the module version when compiling
1647 XS_VERSION: version in your .xs file. Defaults to $(VERSION)
1649 XS_VERSION_MACRO: which macro represents the XS version.
1651 XS_DEFINE_VERSION: -D line to set the xs version when compiling.
1653 Called by init_main.
1660 $self->{MAKEMAKER} = $ExtUtils::MakeMaker::Filename;
1661 $self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION;
1662 $self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision;
1663 $self->{VERSION_FROM} ||= '';
1665 if ($self->{VERSION_FROM}){
1666 $self->{VERSION} = $self->parse_version($self->{VERSION_FROM});
1667 if( $self->{VERSION} eq 'undef' ) {
1668 carp("WARNING: Setting VERSION via file ".
1669 "'$self->{VERSION_FROM}' failed\n");
1674 if (defined $self->{VERSION}) {
1675 $self->{VERSION} =~ s/^\s+//;
1676 $self->{VERSION} =~ s/\s+$//;
1679 $self->{VERSION} = '';
1683 $self->{VERSION_MACRO} = 'VERSION';
1684 ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
1685 $self->{DEFINE_VERSION} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
1688 # Graham Barr and Paul Marquess had some ideas how to ensure
1689 # version compatibility between the *.pm file and the
1690 # corresponding *.xs file. The bottomline was, that we need an
1691 # XS_VERSION macro that defaults to VERSION:
1692 $self->{XS_VERSION} ||= $self->{VERSION};
1694 $self->{XS_VERSION_MACRO} = 'XS_VERSION';
1695 $self->{XS_DEFINE_VERSION} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
1704 Initializes the macro definitions used by tools_other() and places them
1707 If there is no description, its the same as the parameter to
1708 WriteMakefile() documented in ExtUtils::MakeMaker.
1710 Defines at least these macros.
1715 NOECHO Tell make not to display the command itself
1720 MAKE_APERL_FILE File used by MAKE_APERL
1722 SHELL Program used to run shell commands
1724 ECHO Print text adding a newline on the end
1726 RM_RF Remove a directory
1727 TOUCH Update a file's timestamp
1728 TEST_F Test for a file's existence
1731 CHMOD Change permissions on a file
1732 FALSE Exit with non-zero
1735 UMASK_NULL Nullify umask
1736 DEV_NULL Suppress all command output
1743 $self->{ECHO} ||= $self->oneliner('print qq{@ARGV}', ['-l']);
1744 $self->{ECHO_N} ||= $self->oneliner('print qq{@ARGV}');
1746 $self->{TOUCH} ||= $self->oneliner('touch', ["-MExtUtils::Command"]);
1747 $self->{CHMOD} ||= $self->oneliner('chmod', ["-MExtUtils::Command"]);
1748 $self->{RM_F} ||= $self->oneliner('rm_f', ["-MExtUtils::Command"]);
1749 $self->{RM_RF} ||= $self->oneliner('rm_rf', ["-MExtUtils::Command"]);
1750 $self->{TEST_F} ||= $self->oneliner('test_f', ["-MExtUtils::Command"]);
1751 $self->{FALSE} ||= $self->oneliner('exit 1');
1752 $self->{TRUE} ||= $self->oneliner('exit 0');
1754 $self->{MKPATH} ||= $self->oneliner('mkpath', ["-MExtUtils::Command"]);
1756 $self->{CP} ||= $self->oneliner('cp', ["-MExtUtils::Command"]);
1757 $self->{MV} ||= $self->oneliner('mv', ["-MExtUtils::Command"]);
1759 $self->{MOD_INSTALL} ||=
1760 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1761 install([ from_to => {@ARGV}, verbose => '$(VERBINST)', uninstall_shadows => '$(UNINST)', dir_mode => '$(PERM_DIR)' ]);
1763 $self->{DOC_INSTALL} ||= $self->oneliner('perllocal_install', ["-MExtUtils::Command::MM"]);
1764 $self->{UNINSTALL} ||= $self->oneliner('uninstall', ["-MExtUtils::Command::MM"]);
1765 $self->{WARN_IF_OLD_PACKLIST} ||=
1766 $self->oneliner('warn_if_old_packlist', ["-MExtUtils::Command::MM"]);
1767 $self->{FIXIN} ||= $self->oneliner('MY->fixin(shift)', ["-MExtUtils::MY"]);
1768 $self->{EQUALIZE_TIMESTAMP} ||= $self->oneliner('eqtime', ["-MExtUtils::Command"]);
1770 $self->{UNINST} ||= 0;
1771 $self->{VERBINST} ||= 0;
1773 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
1774 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1775 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1776 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1778 # Not everybody uses -f to indicate "use this Makefile instead"
1779 $self->{USEMAKEFILE} ||= '-f';
1781 # Some makes require a wrapper around macros passed in on the command
1783 $self->{MACROSTART} ||= '';
1784 $self->{MACROEND} ||= '';
1786 $self->{SHELL} ||= $Config{sh};
1788 # UMASK_NULL is not used by MakeMaker but some CPAN modules
1790 $self->{UMASK_NULL} ||= "umask 0";
1792 # Not the greatest default, but its something.
1793 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1795 $self->{NOOP} ||= '$(TRUE)';
1796 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1798 $self->{LD_RUN_PATH} = "";
1800 $self->{LIBS} = $self->_fix_libs($self->{LIBS});
1802 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1803 foreach my $libs ( @{$self->{LIBS}} ){
1804 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1805 my(@libs) = $self->extliblist($libs);
1806 if ($libs[0] or $libs[1] or $libs[2]){
1807 # LD_RUN_PATH now computed by ExtUtils::Liblist
1808 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1809 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1814 if ( $self->{OBJECT} ) {
1815 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1817 # init_dirscan should have found out, if we have C files
1818 $self->{OBJECT} = "";
1819 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1821 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1823 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1824 $self->{PERLMAINCC} ||= '$(CC)';
1825 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1827 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1828 # the 'dynamic' section of MM. We don't have this problem with
1829 # 'static', since we either must use it (%Config says we can't
1830 # use dynamic loading) or the caller asked for it explicitly.
1831 if (!$self->{LINKTYPE}) {
1832 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1834 : ($Config{usedl} ? 'dynamic' : 'static');
1841 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1842 # undefined. In any case we turn it into an anon array
1844 my($self, $libs) = @_;
1846 return !defined $libs ? [''] :
1847 !ref $libs ? [$libs] :
1848 !defined $libs->[0] ? [''] :
1855 my $make_frag = $MM->tools_other;
1857 Returns a make fragment containing definitions for the macros init_others()
1866 # We set PM_FILTER as late as possible so it can see all the earlier
1867 # on macro-order sensitive makes such as nmake.
1868 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
1869 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
1873 MOD_INSTALL DOC_INSTALL UNINSTALL
1874 WARN_IF_OLD_PACKLIST
1881 next unless defined $self->{$tool};
1882 push @m, "$tool = $self->{$tool}\n";
1889 =head3 init_DIRFILESEP I<Abstract>
1891 $MM->init_DIRFILESEP;
1892 my $dirfilesep = $MM->{DIRFILESEP};
1894 Initializes the DIRFILESEP macro which is the seperator between the
1895 directory and filename in a filepath. ie. / on Unix, \ on Win32 and
1900 # instead of $(INST_ARCHAUTODIR)/extralibs.ld
1901 $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
1903 Something of a hack but it prevents a lot of code duplication between
1906 Do not use this as a seperator between directories. Some operating
1907 systems use different seperators between subdirectories as between
1908 directories and filenames (for example: VOLUME:[dir1.dir2]file on VMS).
1910 =head3 init_linker I<Abstract>
1914 Initialize macros which have to do with linking.
1916 PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
1919 PERL_ARCHIVE_AFTER: path to a library which should be put on the
1920 linker command line I<after> the external libraries to be linked to
1921 dynamic extensions. This may be needed if the linker is one-pass, and
1922 Perl includes some overrides for C RTL functions, such as malloc().
1924 EXPORT_LIST: name of a file that is passed to linker to define symbols
1927 Some OSes do not need these in which case leave it blank.
1930 =head3 init_platform
1934 Initialize any macros which are for platform specific use only.
1936 A typical one is the version number of your OS specific mocule.
1937 (ie. MM_Unix_VERSION or MM_VMS_VERSION).
1950 Initialize MAKE from either a MAKE environment variable or $Config{make}.
1957 $self->{MAKE} ||= $ENV{MAKE} || $Config{make};
1963 A grab bag of methods to generate specific macros and commands.
1969 Defines targets and routines to translate the pods into manpages and
1970 put them into the INST_* directories.
1977 my $POD2MAN_macro = $self->POD2MAN_macro();
1978 my $manifypods_target = $self->manifypods_target();
1980 return <<END_OF_TARGET;
1991 =head3 POD2MAN_macro
1993 my $pod2man_macro = $self->POD2MAN_macro
1995 Returns a definition for the POD2MAN macro. This is a program
1996 which emulates the pod2man utility. You can add more switches to the
1997 command by simply appending them on the macro.
2001 $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
2008 # Need the trailing '--' so perl stops gobbling arguments and - happens
2009 # to be an alternative end of line seperator on VMS so we quote it
2010 return <<'END_OF_DEF';
2011 POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
2012 POD2MAN = $(POD2MAN_EXE)
2017 =head3 test_via_harness
2019 my $command = $mm->test_via_harness($perl, $tests);
2021 Returns a $command line which runs the given set of $tests with
2022 Test::Harness and the given $perl.
2024 Used on the t/*.t files.
2028 sub test_via_harness {
2029 my($self, $perl, $tests) = @_;
2031 return qq{\t$perl "-MExtUtils::Command::MM" }.
2032 qq{"-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
2035 =head3 test_via_script
2037 my $command = $mm->test_via_script($perl, $script);
2039 Returns a $command line which just runs a single test without
2040 Test::Harness. No checks are done on the results, they're just
2043 Used for test.pl, since they don't always follow Test::Harness
2048 sub test_via_script {
2049 my($self, $perl, $script) = @_;
2050 return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
2054 =head3 tool_autosplit
2056 Defines a simple perl call that runs autosplit. May be deprecated by
2061 sub tool_autosplit {
2062 my($self, %attribs) = @_;
2064 my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};'
2067 my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
2068 use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
2071 return sprintf <<'MAKE_FRAG', $asplit;
2072 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
2082 my $arch_ok = $mm->arch_check(
2084 File::Spec->catfile($Config{archlibexp}, "Config.pm")
2087 A sanity check that what Perl thinks the architecture is and what
2088 Config thinks the architecture is are the same. If they're not it
2089 will return false and show a diagnostic message.
2091 When building Perl it will always return true, as nothing is installed
2094 The interface is a bit odd because this is the result of a
2095 quick refactoring. Don't rely on it.
2101 my($pconfig, $cconfig) = @_;
2103 return 1 if $self->{PERL_SRC};
2105 my($pvol, $pthinks) = $self->splitpath($pconfig);
2106 my($cvol, $cthinks) = $self->splitpath($cconfig);
2108 $pthinks = $self->canonpath($pthinks);
2109 $cthinks = $self->canonpath($cthinks);
2112 if ($pthinks ne $cthinks) {
2113 print "Have $pthinks\n";
2114 print "Want $cthinks\n";
2118 my $arch = (grep length, $self->splitdir($pthinks))[-1];
2120 print STDOUT <<END unless $self->{UNINSTALLED_PERL};
2121 Your perl and your Config.pm seem to have different ideas about the
2122 architecture they are running on.
2123 Perl thinks: [$arch]
2124 Config says: [$Config{archname}]
2125 This may or may not cause problems. Please check your installation of perl
2126 if you have problems building this extension.
2135 =head2 File::Spec wrappers
2137 ExtUtils::MM_Any is a subclass of File::Spec. The methods noted here
2138 override File::Spec.
2144 File::Spec <= 0.83 has a bug where the file part of catfile is not
2145 canonicalized. This override fixes that bug.
2151 return $self->canonpath($self->SUPER::catfile(@_));
2158 Methods I can't really figure out where they should go yet.
2163 my $test = $mm->find_tests;
2165 Returns a string suitable for feeding to the shell to return all
2172 return -d 't' ? 't/*.t' : '';
2176 =head3 extra_clean_files
2178 my @files_to_clean = $MM->extra_clean_files;
2180 Returns a list of OS specific files to be removed in the clean target in
2181 addition to the usual set.
2185 # An empty method here tickled a perl 5.8.1 bug and would return its object.
2186 sub extra_clean_files {
2193 my @installvars = $mm->installvars;
2195 A list of all the INSTALL* variables without the INSTALL prefix. Useful
2196 for iteration or building related variable sets.
2201 return qw(PRIVLIB SITELIB VENDORLIB
2202 ARCHLIB SITEARCH VENDORARCH
2203 BIN SITEBIN VENDORBIN
2204 SCRIPT SITESCRIPT VENDORSCRIPT
2205 MAN1DIR SITEMAN1DIR VENDORMAN1DIR
2206 MAN3DIR SITEMAN3DIR VENDORMAN3DIR
2213 my $wanted = $self->libscan($path);
2215 Takes a path to a file or dir and returns an empty string if we don't
2216 want to include this file in the library. Otherwise it returns the
2217 the $path unchanged.
2219 Mainly used to exclude version control administrative directories from
2225 my($self,$path) = @_;
2226 my($dirs,$file) = ($self->splitpath($path))[1,2];
2227 return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/,
2228 $self->splitdir($dirs), $file;
2234 =head3 platform_constants
2236 my $make_frag = $mm->platform_constants
2238 Returns a make fragment defining all the macros initialized in
2239 init_platform() rather than put them in constants().
2243 sub platform_constants {
2249 =head3 _PREREQ_PRINT
2251 $self->_PREREQ_PRINT;
2253 Implements PREREQ_PRINT.
2255 Refactored out of MakeMaker->new().
2264 require Data::Dumper;
2265 my @what = ('PREREQ_PM');
2266 push @what, 'MIN_PERL_VERSION' if $self->{MIN_PERL_VERSION};
2267 push @what, 'BUILD_REQUIRES' if $self->{BUILD_REQUIRES};
2268 print Data::Dumper->Dump([@{$self}{@what}], \@what);
2275 =head3 _PRINT_PREREQ
2279 Implements PRINT_PREREQ, a slightly different version of PREREQ_PRINT
2280 added by Redhat to, I think, support generating RPMs from Perl modules.
2282 Refactored out of MakeMaker->new().
2291 my $prereqs= $self->_all_prereqs;
2292 my @prereq = map { [$_, $prereqs->{$_}] } keys %$prereqs;
2294 if ( $self->{MIN_PERL_VERSION} ) {
2295 push @prereq, ['perl' => $self->{MIN_PERL_VERSION}];
2298 print join(" ", map { "perl($_->[0])>=$_->[1] " }
2299 sort { $a->[0] cmp $b->[0] } @prereq), "\n";
2308 my $prereqs = $self->_all_prereqs;
2310 Returns a hash ref of both PREREQ_PM and BUILD_REQUIRES.
2319 return { %{$self->{PREREQ_PM}}, %{$self->{BUILD_REQUIRES}} };
2325 Michael G Schwern <schwern@pobox.com> and the denizens of
2326 makemaker@perl.org with code from ExtUtils::MM_Unix and