MAN page from Fedora 6 perl-ExtUtils-MakeMaker-6.46-1.fc6.rf.noarch.rpm


Section: User Contributed Perl Documentation (3)
Updated: 2008-09-27


ExtUtils::MM_Any - Platform-agnostic MM methods 



  package ExtUtils::MM_SomeOS;

  # Temporarily, you have to subclass both.  Put MM_Any first.  require ExtUtils::MM_Any;  require ExtUtils::MM_Unix;  @ISA = qw(ExtUtils::MM_Any ExtUtils::Unix);



ExtUtils::MM_Any is a superclass for the ExtUtils::MM_* set ofmodules. It contains methods which are either inherentlycross-platform or are written in a cross-platform manner.

Subclass off of ExtUtils::MM_Any and ExtUtils::MM_Unix. This is atemporary solution.



Any methods marked Abstract must be implemented by subclasses. 

Cross-platform helper methods

These are methods which help writing cross-platform code.

os_flavor Abstract

    my @os_flavor = $mm->os_flavor;

@os_flavor is the style of operating system this is, usuallycorresponding to the MM_*.pm file we're using.

The first element of @os_flavor is the major family (ie. Unix,Windows, VMS, OS/2, etc...) and the rest are sub families.

Some examples:

    Cygwin98       ('Unix',  'Cygwin', 'Cygwin9x')    Windows NT     ('Win32', 'WinNT')    Win98          ('Win32', 'Win9x')    Linux          ('Unix',  'Linux')    MacOS X        ('Unix',  'Darwin', 'MacOS', 'MacOS X')    OS/2           ('OS/2')

This is used to write code for styles of operating system. See os_flavor_is() for use.


    my $is_this_flavor = $mm->os_flavor_is($this_flavor);    my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);

Checks to see if the current operating system is one of the given flavors.

This is useful for code like:

    if( $mm->os_flavor_is('Unix') ) {        $out = `foo 2>&1`;    }    else {        $out = `foo`;    }


    my @cmds = $MM->split_command($cmd, @args);

Most OS have a maximum command length they can execute at once. Largemodules can easily generate commands well past that limit. Itsnecessary to split long commands up into a series of shorter commands.

"split_command" will return a series of @cmds each processing part ofthe args. Collectively they will process all the arguments. Eachindividual line in @cmds will not be longer than the$self->max_exec_len being careful to take into account macro expansion.

$cmd should include any switches and repeated initial arguments.

If no @args are given, no @cmds will be returned.

Pairs of arguments will always be preserved in a single command, thisis a heuristic for things like pm_to_blib and pod2man which work onpairs of arguments. This makes things like this safe:

    $self->split_command($cmd, %pod2man);


    my @commands = $MM->echo($text);    my @commands = $MM->echo($text, $file);    my @commands = $MM->echo($text, $file, $appending);

Generates a set of @commands which print the $text to a $file.

If $file is not given, output goes to STDOUT.

If $appending is true the $file will be appended to rather thanoverwritten.


  my $args = $mm->wraplist(@list);

Takes an array of items and turns them into a well-formatted list ofarguments. In most cases this is simply something like:

    FOO \    BAR \    BAZ


    my $filter_make_text = $mm->maketext_filter($make_text);

The text of the Makefile is run through this method before writing todisk. It allows systems a chance to make portability fixes to theMakefile.

By default it does nothing.

This method is protected and not intended to be called outside ofMakeMaker.

cd Abstract

  my $subdir_cmd = $MM->cd($subdir, @cmds);

This will generate a make fragment which runs the @cmds in the given$dir. The rough equivalent to this, except cross platform.

  cd $subdir && $cmd

Currently $dir can only go down one level. ``foo'' is fine. ``foo/bar'' isnot. ``../foo'' is right out.

The resulting $subdir_cmd has no leading tab nor trailing newline. Thismakes it easier to embed in a make string. For example.

      my $make = sprintf <<'CODE', $subdir_cmd;  foo :      $(ECHO) what      %s      $(ECHO) mouche  CODE

oneliner Abstract

  my $oneliner = $MM->oneliner($perl_code);  my $oneliner = $MM->oneliner($perl_code, \@switches);

This will generate a perl one-liner safe for the particular platformyou're on based on the given $perl_code and @switches (a -e isassumed) suitable for using in a make target. It will use the propershell quoting and escapes.

$(PERLRUN) will be used as perl.

Any newlines in $perl_code will be escaped. Leading and trailingnewlines will be stripped. Makes this idiom much easier:

    my $code = $MM->oneliner(<<'CODE', [...switches...]);some code hereanother line hereCODE

Usage might be something like:

    # an echo emulation    $oneliner = $MM->oneliner('print "Foo\n"');    $make = '$oneliner > somefile';

All dollar signs must be doubled in the $perl_code if you expect themto be interpreted normally, otherwise it will be considered a makemacro. Also remember to quote make macros else it might be used as abareword. For example:

    # Assign the value of the $(VERSION_FROM) make macro to $vf.    $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');

Its currently very simple and may be expanded sometime in the figureto include more flexible code and switches.

quote_literal Abstract

    my $safe_text = $MM->quote_literal($text);

This will quote $text so it is interpreted literally in the shell.

For example, on Unix this would escape any single-quotes in $text andput single-quotes around the whole thing.

escape_newlines Abstract

    my $escaped_text = $MM->escape_newlines($text);

Shell escapes newlines in $text.

max_exec_len Abstract

    my $max_exec_len = $MM->max_exec_len;

Calculates the maximum command size the OS can exec. Effectively,this is the max size of a shell command line.


    my $make = $MM->make;

Returns the make variant we're generating the Makefile for. This attemptsto do some normalization on the information from %Config or the user. 


These are methods which produce make targets.


Generate the default target 'all'.


    my $make_frag = $mm->blibdirs_target;

Creates the blibdirs target which creates all the directories we usein blib/.

The blibdirs.ts target is deprecated. Depend on blibdirs instead.

clean (o)

Defines the clean target.


  my $make_frag = $MM->clean_subdirs_target;

Returns the clean_subdirs target. This is used by the clean target tocall clean on any subdirectories which contain Makefiles.


    my $make_frag = $mm->dir_target(@directories);

Generates targets to create the specified directories and set itspermission to 0755.

Because depending on a directory to just ensure it exists doesn't worktoo well (the modified time changes too often) dir_target() creates a.exists file in the created directory. It is this you should depend on.For portability purposes you should use the $(DIRFILESEP) macro ratherthan a '/' to seperate the directory from the file.



Defines the scratch directory target that will hold the distributionbefore tar-ing (or shar-ing).


Defines a target that produces the distribution in thescratchdirectory, and runs 'perl Makefile.PL; make ;make test' in thatsubdirectory.

dynamic (o)

Defines the dynamic target.


  my $make_frag = $mm->makemakerdflt_target

Returns a make fragment with the makemakerdeflt_target specified.This target is the first target in the Makefile, is the default targetand simply points off to 'all' just in case any make variant getsconfused or something gets snuck in before the real 'all' target.


  my $manifypods_target = $self->manifypods_target;

Generates the manifypods target. This target generates man pages fromall POD files in MAN1PODS and MAN3PODS.


    my $target = $mm->metafile_target;

Generate the metafile target.

Writes the file META.yml YAML encoded meta-data about the module inthe distdir. The format follows Module::Build's as closely aspossible.


    my @metadata_pairs = $mm->metafile_data(\%meta_add, \%meta_merge);

Returns the data which MakeMaker turns into the META.yml file.

Values of %meta_add will overwrite any existing metadata in thosekeys. %meta_merge will be merged with them.


    my $meta_yml = $mm->metafile_file(@metadata_pairs);

Turns the @metadata_pairs into YAML.

This method does not implement a complete YAML dumper, being limitedto dump a hash with values which are strings, undef's or nested hashesand arrays of strings. No quoting/escaping is done.


    my $make_frag = $mm->distmeta_target;

Generates the distmeta target to add META.yml to the MANIFEST in thedistdir.

realclean (o)

Defines the realclean target.


  my $make_frag = $MM->realclean_subdirs_target;

Returns the realclean_subdirs target. This is used by the realcleantarget to call realclean on any subdirectories which contain Makefiles.


    my $target = $mm->signature_target;

Generate the signature target.

Writes the file SIGNATURE with ``cpansign -s''.


    my $make_frag = $mm->distsignature_target;

Generates the distsignature target to add SIGNATURE to the MANIFEST in thedistdir.


  my $make_frag = $mm->special_targets

Returns a make fragment containing any targets which have specialmeaning to make. For example, .SUFFIXES and .PHONY. 

Init methods

Methods which help initialize the MakeMaker object and macros.





Called by init_main. Sets up all INST_* variables except those relatedto XS code. Those are handled in init_xs.



Called by init_main. Sets up all INSTALL_* variables (exceptINSTALLDIRS) and *PREFIX.





init_VERSION Abstract


Initialize macros representing versions of MakeMaker and other tools

MAKEMAKER: path to the MakeMaker module.

MM_VERSION: ExtUtils::MakeMaker Version

MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards

VERSION: version of your module

VERSION_MACRO: which macro represents the version (usually 'VERSION')

VERSION_SYM: like version but safe for use as an RCS revision number

DEFINE_VERSION: -D line to set the module version when compiling

XS_VERSION: version in your .xs file. Defaults to $(VERSION)

XS_VERSION_MACRO: which macro represents the XS version.

XS_DEFINE_VERSION: -D line to set the xs version when compiling.

Called by init_main.

init_others Abstract


Initializes the macro definitions used by tools_other() and places themin the $MM object.

If there is no description, its the same as the parameter toWriteMakefile() documented in ExtUtils::MakeMaker.

Defines at least these macros.

  Macro             Description

  NOOP              Do nothing  NOECHO            Tell make not to display the command itself


  SHELL             Program used to run shell commands

  ECHO              Print text adding a newline on the end  RM_F              Remove a file   RM_RF             Remove a directory            TOUCH             Update a file's timestamp     TEST_F            Test for a file's existence   CP                Copy a file                   MV                Move a file                   CHMOD             Change permissions on a                         file

  UMASK_NULL        Nullify umask  DEV_NULL          Suppress all command output

init_DIRFILESEP Abstract

  $MM->init_DIRFILESEP;  my $dirfilesep = $MM->{DIRFILESEP};

Initializes the DIRFILESEP macro which is the seperator between thedirectory and filename in a filepath. ie. / on Unix, \ on Win32 andnothing on VMS.

For example:

    # instead of $(INST_ARCHAUTODIR)/extralibs.ld    $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld

Something of a hack but it prevents a lot of code duplication betweenMM_* variants.

Do not use this as a seperator between directories. Some operatingsystems use different seperators between subdirectories as betweendirectories and filenames (for example: VOLUME:[dir1.dir2]file on VMS).

init_linker Abstract


Initialize macros which have to do with linking.

PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamicextensions.

PERL_ARCHIVE_AFTER: path to a library which should be put on thelinker command line after the external libraries to be linked todynamic extensions. This may be needed if the linker is one-pass, andPerl includes some overrides for C RTL functions, such as malloc().

EXPORT_LIST: name of a file that is passed to linker to define symbolsto be exported.

Some OSes do not need these in which case leave it blank.



Initialize any macros which are for platform specific use only.

A typical one is the version number of your OS specific mocule.(ie. MM_Unix_VERSION or MM_VMS_VERSION).



Initialize MAKE from either a MAKE environment variable or $Config{make}. 


A grab bag of methods to generate specific macros and commands.


Defines targets and routines to translate the pods into manpages andput them into the INST_* directories.


  my $pod2man_macro = $self->POD2MAN_macro

Returns a definition for the POD2MAN macro. This is a programwhich emulates the pod2man utility. You can add more switches to thecommand by simply appending them on the macro.

Typical usage:

    $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...


  my $command = $mm->test_via_harness($perl, $tests);

Returns a $command line which runs the given set of $tests withTest::Harness and the given $perl.

Used on the t/*.t files.


  my $command = $mm->test_via_script($perl, $script);

Returns a $command line which just runs a single test withoutTest::Harness. No checks are done on the results, they're justprinted.

Used for, since they don't always follow Test::Harnessformatting.


Defines a simple perl call that runs autosplit. May be deprecated bypm_to_blib soon. 

File::Spec wrappers

ExtUtils::MM_Any is a subclass of File::Spec. The methods noted hereoverride File::Spec.


File::Spec <= 0.83 has a bug where the file part of catfile is notcanonicalized. This override fixes that bug. 


Methods I can't really figure out where they should go yet.


  my $test = $mm->find_tests;

Returns a string suitable for feeding to the shell to return alltests in t/*.t.


    my @files_to_clean = $MM->extra_clean_files;

Returns a list of OS specific files to be removed in the clean target inaddition to the usual set.


    my @installvars = $mm->installvars;

A list of all the INSTALL* variables without the INSTALL prefix. Usefulfor iteration or building related variable sets.


  my $wanted = $self->libscan($path);

Takes a path to a file or dir and returns an empty string if we don'twant to include this file in the library. Otherwise it returns thethe $path unchanged.

Mainly used to exclude version control administrative directories frominstallation.


    my $make_frag = $mm->platform_constants

Returns a make fragment defining all the macros initialized ininit_platform() rather than put them in constants(). 


Michael G Schwern <> and the denizens with code from ExtUtils::MM_Unix andExtUtils::MM_Win32.



Cross-platform helper methods
Init methods
File::Spec wrappers

This document was created byman2html,using the manual pages.