This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactoring the /Can't return (?:array|hash) to scalar context/ croak
[perl5.git] / lib / Module / Build.pm
index cd0b8b5..6d6cfe9 100644 (file)
@@ -15,7 +15,7 @@ use Module::Build::Base;
 
 use vars qw($VERSION @ISA);
 @ISA = qw(Module::Build::Base);
-$VERSION = '0.27_09';
+$VERSION = '0.2808_02';
 $VERSION = eval $VERSION;
 
 # Okay, this is the brute-force method of finding out what kind of
@@ -26,6 +26,7 @@ my %OSTYPES = qw(
                 aix       Unix
                 bsdos     Unix
                 dgux      Unix
+                dragonfly Unix
                 dynixptx  Unix
                 freebsd   Unix
                 linux     Unix
@@ -33,6 +34,7 @@ my %OSTYPES = qw(
                 irix      Unix
                 darwin    Unix
                 machten   Unix
+                midnightbsd Unix
                 next      Unix
                 openbsd   Unix
                 netbsd    Unix
@@ -46,6 +48,7 @@ my %OSTYPES = qw(
                 sunos     Unix
                 cygwin    Unix
                 os2       Unix
+                interix   Unix
                 
                 dos       Windows
                 MSWin32   Windows
@@ -93,6 +96,10 @@ if (grep {-e File::Spec->catfile($_, qw(Module Build Platform), $^O) . '.pm'} @I
 
 sub os_type { $OSTYPES{$^O} }
 
+sub is_vmsish { return ((os_type() || '') eq 'VMS') }
+sub is_windowsish { return ((os_type() || '') eq 'Windows') }
+sub is_unixish { return ((os_type() || '') eq 'Unix') }
+
 1;
 
 __END__
@@ -149,22 +156,23 @@ This illustrates initial configuration and the running of three
 'actions'.  In this case the actions run are 'build' (the default
 action), 'test', and 'install'.  Other actions defined so far include:
 
-  build                          install     
-  clean                          manifest    
-  code                           manpages    
+  build                          manifest    
+  clean                          manpages    
+  code                           pardist     
   config_data                    ppd         
   diff                           ppmdist     
   dist                           prereq_report
   distcheck                      pure_install
   distclean                      realclean   
-  distdir                        skipcheck   
-  distmeta                       test        
-  distsign                       testcover   
-  disttest                       testdb      
-  docs                           testpod     
-  fakeinstall                    testpodcoverage
-  help                           versioninstall
-  html                                       
+  distdir                        retest      
+  distmeta                       skipcheck   
+  distsign                       test        
+  disttest                       testall     
+  docs                           testcover   
+  fakeinstall                    testdb      
+  help                           testpod     
+  html                           testpodcoverage
+  install                        versioninstall
 
 
 You can run the 'help' action for a complete list of actions.
@@ -185,14 +193,14 @@ scripts at the command line.
 
 =item Authoring Reference (L<Module::Build::Authoring>)
 
-This document describes the C<Module::Build> API for authors who are
+This document describes the structure and organization of
+C<Module::Build>, and the relevant concepts needed by authors who are
 writing F<Build.PL> scripts for a distribution or controlling
-C<Module::Build> processes programmatically.  It describes the
-methods available as well as providing general information on
-subclassing C<Module::Build> to alter and extend its behavior.  Also,
-there is a section on controlling the Build process from other
-scripts, including how to construct an object and how to invoke
-actions through it from an external script.
+C<Module::Build> processes programmatically.
+
+=item API Reference (L<Module::Build::API>)
+
+This is a reference to the C<Module::Build> API.
 
 =item Cookbook (L<Module::Build::Cookbook>)
 
@@ -219,10 +227,8 @@ C<Build test verbose=1>), in which case their values last only for the
 lifetime of that command.  Per-action command line parameters take
 precedence over parameters specified at C<perl Build.PL> time.
 
-The build process also relies heavily on the C<Config.pm> module, and
-all the key=value pairs in C<Config.pm> are available in
-
-C<< $self->{config} >>.  If the user wishes to override any of the
+The build process also relies heavily on the C<Config.pm> module.
+If the user wishes to override any of the
 values in C<Config.pm>, she may specify them like so:
 
   perl Build.PL --config cc=gcc --config ld=gcc
@@ -233,25 +239,25 @@ The following build actions are provided by default.
 
 =item build
 
+[version 0.01]
+
 If you run the C<Build> script without any arguments, it runs the
 C<build> action, which in turn runs the C<code> and C<docs> actions.
 
 This is analogous to the MakeMaker 'make all' target.
 
-=item testpodcoverage
-
-This checks the pod coverage of the distribution and 
-produces C<Test::Harness>-style output. If you are a module author,
-this is useful to run before creating a new release.
-
 =item clean
 
+[version 0.01]
+
 This action will clean up any files that the build process may have
 created, including the C<blib/> directory (but not including the
 C<_build/> directory and the C<Build> script itself).
 
 =item code
 
+[version 0.20]
+
 This action builds your codebase.
 
 By default it just creates a C<blib/> directory and copies any C<.pm>
@@ -270,10 +276,14 @@ with) will get copied correctly.
 
 =item config_data
 
+[version 0.26]
+
 ...
 
 =item diff
 
+[version 0.14]
+
 This action will compare the files about to be installed with their
 installed counterparts.  For .pm and .pod files, a diff will be shown
 (this currently requires a 'diff' program to be in your PATH).  For
@@ -288,6 +298,8 @@ parameters it will accept - a good one is C<-u>:
 
 =item dist
 
+[version 0.02]
+
 This action is helpful for module authors who want to package up their
 module for source distribution through a medium like CPAN.  It will create a
 tarball of the files listed in F<MANIFEST> and compress the tarball using
@@ -302,15 +314,21 @@ want by supplying an explicit C<tar> (and optional C<gzip>) parameter:
 
 =item distcheck
 
+[version 0.05]
+
 Reports which files are in the build directory but not in the
 F<MANIFEST> file, and vice versa.  (See L<manifest> for details.)
 
 =item distclean
 
+[version 0.05]
+
 Performs the 'realclean' action and then the 'distcheck' action.
 
 =item distdir
 
+[version 0.05]
+
 Creates a "distribution directory" named C<$dist_name-$dist_version>
 (if that directory already exists, it will be removed first), then
 copies all the files listed in the F<MANIFEST> file to that directory.
@@ -318,33 +336,45 @@ This directory is what the distribution tarball is created from.
 
 =item distmeta
 
+[version 0.21]
+
 Creates the F<META.yml> file that describes the distribution.
 
 F<META.yml> is a file containing various bits of "metadata" about the
 distribution.  The metadata includes the distribution name, version,
 abstract, prerequisites, license, and various other data about the
-distribution.  This file is created as F<META.yml> in YAML format, so
-the C<YAML> module must be installed in order to create it.  The
+distribution.  This file is created as F<META.yml> in YAML format.
+It is recommended that the C<YAML> module be installed to create it.
+If the C<YAML> module is not installed, an internal module supplied
+with Module::Build will be used to write the META.yml file, and this
+will most likely be fine.
+
 F<META.yml> file must also be listed in F<MANIFEST> - if it's not, a
 warning will be issued.
 
 The current version of the F<META.yml> specification can be found at
-L<http://module-build.sourceforge.net/META-spec-v1.2.html>
+L<http://module-build.sourceforge.net/META-spec-current.html>
 
 =item distsign
 
+[version 0.16]
+
 Uses C<Module::Signature> to create a SIGNATURE file for your
 distribution, and adds the SIGNATURE file to the distribution's
 MANIFEST.
 
 =item disttest
 
+[version 0.05]
+
 Performs the 'distdir' action, then switches into that directory and
 runs a C<perl Build.PL>, followed by the 'build' and 'test' actions in
 that directory.
 
 =item docs
 
+[version 0.20]
+
 This will generate documentation (e.g. Unix man pages and html
 documents) for any installable items under B<blib/> that
 contain POD.  If there are no C<bindoc> or C<libdoc> installation
@@ -355,12 +385,16 @@ taken for html documents.
 
 =item fakeinstall
 
+[version 0.02]
+
 This is just like the C<install> action, but it won't actually do
 anything, it will just report what it I<would> have done if you had
 actually run the C<install> action.
 
 =item help
 
+[version 0.03]
+
 This action will simply print out a message that is meant to help you
 use the build process.  It will show you a list of available build
 actions too.
@@ -371,6 +405,8 @@ find for that action.
 
 =item html
 
+[version 0.26]
+
 This will generate HTML documentation for any binary or library files
 under B<blib/> that contain POD.  The HTML documentation will only be
 installed if the install paths can be determined from values in
@@ -380,8 +416,10 @@ and/or C<libhtml> installation targets.
 
 =item install
 
+[version 0.01]
+
 This action will use C<ExtUtils::Install> to install the files from
-C<blib/> into the system.  See L<INSTALL PATHS>
+C<blib/> into the system.  See L<"INSTALL PATHS">
 for details about how Module::Build determines where to install
 things, and how to influence this process.
 
@@ -398,6 +436,8 @@ situation indeed.
 
 =item manifest
 
+[version 0.05]
+
 This is an action intended for use by module authors, not people
 installing modules.  It will bring the F<MANIFEST> up to date with the
 files currently present in the distribution.  You may use a
@@ -423,6 +463,8 @@ what the C<manifest> action would do, without actually doing anything.
 
 =item manpages
 
+[version 0.28]
+
 This will generate man pages for any binary or library files under
 B<blib/> that contain POD.  The man pages will only be installed if the
 install paths can be determined from values in C<Config.pm>.  You can
@@ -430,8 +472,19 @@ also supply or override install paths by specifying there values on
 the command line with the C<bindoc> and C<libdoc> installation
 targets.
 
+=item pardist
+
+[version 0.2806]
+
+Generates a PAR binary distribution for use with L<PAR> or L<PAR::Dist>.
+
+It requires that the PAR::Dist module (version 0.17 and up) is
+installed on your system.
+
 =item ppd
 
+[version 0.20]
+
 Build a PPD file for your distribution.
 
 This action takes an optional argument C<codebase> which is used in
@@ -445,6 +498,8 @@ Example:
 
 =item ppmdist
 
+[version 0.23]
+
 Generates a PPM binary distribution and a PPD description file.  This
 action also invokes the 'ppd' action, so it can accept the same
 C<codebase> argument described under that action.
@@ -455,6 +510,8 @@ the result.
 
 =item prereq_report
 
+[version 0.28]
+
 This action prints out a list of all prerequisites, the versions required, and
 the versions actually installed.  This can be useful for reviewing the
 configuration of your system prior to a build, or when compiling data to send
@@ -462,25 +519,44 @@ for a bug report.
 
 =item pure_install
 
+[version 0.28]
+
 This action is identical to the C<install> action.  In the future,
-though, if C<install> starts writing to the file file
+though, when C<install> starts writing to the file 
 F<$(INSTALLARCHLIB)/perllocal.pod>, C<pure_install> won't, and that
 will be the only difference between them.
 
 =item realclean
 
+[version 0.01]
+
 This action is just like the C<clean> action, but also removes the
 C<_build> directory and the C<Build> script.  If you run the
 C<realclean> action, you are essentially starting over, so you will
 have to re-create the C<Build> script again.
 
+=item retest
+
+[version 0.2806]
+
+This is just like the C<test> action, but doesn't actually build the
+distribution first, and doesn't add F<blib/> to the load path, and
+therefore will test against a I<previously> installed version of the
+distribution.  This can be used to verify that a certain installed
+distribution still works, or to see whether newer versions of a
+distribution still pass the old regression tests, and so on.
+
 =item skipcheck
 
+[version 0.05]
+
 Reports which files are skipped due to the entries in the
 F<MANIFEST.SKIP> file (See L<manifest> for details)
 
 =item test
 
+[version 0.01]
+
 This will use C<Test::Harness> to run any regression tests and report
 their results.  Tests can be defined in the standard places: a file
 called C<test.pl> in the top-level directory, or several files ending
@@ -512,8 +588,37 @@ or use a C<glob()>-style pattern:
 
   ./Build test --test_files 't/01-*.t'
 
+=item testall
+
+[verion 0.2807]
+
+[Note: the 'testall' action and the code snippets below are currently
+in alpha stage, see
+L<"http://www.nntp.perl.org/group/perl.module.build/2007/03/msg584.html"> ]
+
+Runs the C<test> action plus each of the C<test$type> actions defined by
+the keys of the C<test_types> parameter.
+
+Currently, you need to define the ACTION_test$type method yourself and
+enumerate them in the test_types parameter.
+
+  my $mb = Module::Build->subclass(
+    code => q(
+      sub ACTION_testspecial { shift->generic_test(type => 'special'); }
+      sub ACTION_testauthor  { shift->generic_test(type => 'author'); }
+    )
+  )->new(
+    ...
+    test_types  => {
+      special => '.st',
+      author  => '.at',
+    },
+    ...
+
 =item testcover
 
+[version 0.26]
+
 Runs the C<test> action using C<Devel::Cover>, generating a
 code-coverage report showing which parts of the code were actually
 exercised during the tests.
@@ -525,17 +630,31 @@ environment variable:
 
 =item testdb
 
+[version 0.05]
+
 This is a synonym for the 'test' action with the C<debugger=1>
 argument.
 
 =item testpod
 
+[version 0.25]
+
 This checks all the files described in the C<docs> action and 
 produces C<Test::Harness>-style output.  If you are a module author,
 this is useful to run before creating a new release.
 
+=item testpodcoverage
+
+[version 0.28]
+
+This checks the pod coverage of the distribution and 
+produces C<Test::Harness>-style output. If you are a module author,
+this is useful to run before creating a new release.
+
 =item versioninstall
 
+[version 0.16]
+
 ** Note: since C<only.pm> is so new, and since we just recently added
 support for it here too, this feature is to be considered
 experimental. **
@@ -594,13 +713,25 @@ false to prevent the custom resource file from being loaded.
 
 Display extra information about the Build on output.
 
+=item allow_mb_mismatch
+
+Suppresses the check upon startup that the version of Module::Build
+we're now running under is the same version that was initially invoked
+when building the distribution (i.e. when the C<Build.PL> script was
+first run).  Use with caution.
+
 =back
 
 
 =head2 Default Options File (F<.modulebuildrc>)
 
-When Module::Build starts up, it will look for a file,
-F<$ENV{HOME}/.modulebuildrc>.  If the file exists, the options
+[version 0.28]
+
+When Module::Build starts up, it will look first for a file,
+F<$ENV{HOME}/.modulebuildrc>.  If it's not found there, it will look
+in the the F<.modulebuildrc> file in the directories referred to by
+the environment variables C<HOMEDRIVE> + C<HOMEDIR>, C<USERPROFILE>,
+C<APPDATA>, C<WINDIR>, C<SYS$LOGIN>.  If the file exists, the options
 specified there will be used as defaults, as if they were typed on the
 command line.  The defaults can be overridden by specifying new values
 on the command line.
@@ -631,6 +762,8 @@ absolute path of the file containing your options.
 
 =head1 INSTALL PATHS
 
+[version 0.19]
+
 When you invoke Module::Build's C<build> action, it needs to figure
 out where to install things.  The nutshell version of how this works
 is that default installation locations are determined from
@@ -768,8 +901,7 @@ system, you'll install as follows:
   libhtml => /home/ken/html
 
 Note that this is I<different> from how MakeMaker's C<PREFIX>
-parameter works.  See L</"Why PREFIX is not recommended"> for more
-details.  C<install_base> just gives you a default layout under the
+parameter works.  C<install_base> just gives you a default layout under the
 directory you specify, which may have little to do with the
 C<installdirs=site> layout.
 
@@ -794,110 +926,29 @@ This will effectively install to "/tmp/foo/$sitelib",
 C<File::Spec> to make the pathnames work correctly on whatever
 platform you're installing on.
 
-=back
-
-=head2 About PREFIX Support
-
-First, it is necessary to understand the original idea behind
-C<PREFIX>.  If, for example, the default installation locations for
-your machine are F</usr/local/lib/perl5/5.8.5> for modules,
-F</usr/local/bin> for executables, F</usr/local/man/man1> and
-F</usr/local/man/man3> for manual pages, etc., then they all share the
-same "prefix" F</usr/local>.  MakeMaker's C<PREFIX> mechanism was
-intended as a way to change an existing prefix that happened to occur
-in all those paths - essentially a C<< s{/usr/local}{/foo/bar} >> for
-each path.
-
-However, the real world is more complicated than that.  The C<PREFIX>
-idea is fundamentally broken when your machine doesn't jibe with
-C<PREFIX>'s worldview.
+=item prefix
 
+Provided for compatibility with ExtUtils::MakeMaker's PREFIX argument.
+C<prefix> should be used when you wish Module::Build to install your
+modules, documentation and scripts in the same place
+ExtUtils::MakeMaker does.
 
-=over 4
-
-=item Why PREFIX is not recommended
-
-=over 4
+The following are equivalent.
 
-=item *
+    perl Build.PL --prefix /tmp/foo
+    perl Makefile.PL PREFIX=/tmp/foo
 
-Many systems have Perl configs that make little sense with PREFIX.
-For example, OS X, where core modules go in
-F</System/Library/Perl/...>, user-installed modules go in
-F</Library/Perl/...>, and man pages go in F</usr/share/man/...>.  The
-PREFIX is thus set to F</>.  Install L<Foo::Bar> on OS X with
-C<PREFIX=/home/spurkis> and you get things like
-F</home/spurkis/Library/Perl/5.8.1/Foo/Bar.pm> and
-F</home/spurkis/usr/share/man/man3/Foo::Bar.3pm>.  Not too pretty.
-
-The problem is not limited to Unix-like platforms, either - on Windows
-builds (e.g. ActiveState perl 5.8.0), we have user-installed modules
-going in F<C:\Perl\site\lib>, user-installed executables going in
-F<C:\Perl\bin>, and PREFIX=F<C:\Perl\site>.  The prefix just doesn't
-apply neatly to the executables.
+Because of the very complex nature of the prefixification logic, the
+behavior of PREFIX in MakeMaker has changed subtly over time.
+Module::Build's --prefix logic is equivalent to the PREFIX logic found
+in ExtUtils::MakeMaker 6.30.
 
-=item *
+If you do not need to retain compatibility with ExtUtils::MakeMaker or
+are starting a fresh Perl installation we recommand you use
+C<install_base> instead (and C<INSTALL_BASE> in ExtUtils::MakeMaker).
+See L<Module::Build::Cookbook/Instaling in the same location as
+ExtUtils::MakeMaker> for further information.
 
-The PREFIX logic is too complicated and hard to predict for the user.
-It's hard to document what exactly is going to happen.  You can't give
-a user simple instructions like "run perl Makefile.PL PREFIX=~ and
-then set PERL5LIB=~/lib/perl5".
-
-=item *
-
-The results from PREFIX will change if your configuration of Perl
-changes (for example, if you upgrade Perl).  This means your modules
-will end up in different places.
-
-=item *
-
-The results from PREFIX can change with different releases of
-MakeMaker.  The logic of PREFIX is subtle and it has been altered in
-the past (mostly to limit damage in the many "edge cases" when its
-behavior was undesirable).
-
-=item *
-
-PREFIX imposes decisions made by the person who configured Perl onto
-the person installing a module.  The person who configured Perl could
-have been you or it could have been some guy at Redhat.
-
-=back
-
-
-=item Alternatives to PREFIX
-
-Module::Build offers L</install_base> as a simple, predictable, and
-user-configurable alternative to ExtUtils::MakeMaker's C<PREFIX>.
-What's more, MakeMaker will soon accept C<INSTALL_BASE> -- we strongly
-urge you to make the switch.
-
-Here's a quick comparison of the two when installing modules to your
-home directory on a unix box:
-
-MakeMaker [*]:
-
-  % perl Makefile.PL PREFIX=/home/spurkis
-  PERL5LIB=/home/spurkis/lib/perl5/5.8.5:/home/spurkis/lib/perl5/site_perl/5.8.5
-  PATH=/home/spurkis/bin
-  MANPATH=/home/spurkis/man
-
-Module::Build:
-
-  % perl Build.PL install_base=/home/spurkis
-  PERL5LIB=/home/spurkis/lib/perl5
-  PATH=/home/spurkis/bin
-  MANPATH=/home/spurkis/man
-
-[*] Note that MakeMaker's behaviour cannot be guaranteed in even this
-common scenario, and differs among different versions of MakeMaker.
-
-In short, using C<install_base> is similar to the following MakeMaker usage:
-
-  perl Makefile.PL PREFIX=/home/spurkis LIB=/home/spurkis/lib/perl5
-
-See L</INSTALL PATHS> for details on other
-installation options available and how to configure them.
 
 =back
 
@@ -988,19 +1039,18 @@ signature or the like, if available.  See C<cons> for an example.
 Ken Williams <kwilliams@cpan.org>
 
 Development questions, bug reports, and patches should be sent to the
-Module-Build mailing list at <module-build-general@lists.sourceforge.net>.
+Module-Build mailing list at <module-build@perl.org>.
 
 Bug reports are also welcome at
 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Build>.
 
-An anonymous CVS repository containing the latest development version
-is available; see <http://sourceforge.net/cvs/?group_id=45731> for the
-details of how to access it.
+The latest development version is available from the Subversion
+repository at <https://svn.perl.org/modules/Module-Build/trunk/>
 
 
 =head1 COPYRIGHT
 
-Copyright (c) 2001-2005 Ken Williams.  All rights reserved.
+Copyright (c) 2001-2006 Ken Williams.  All rights reserved.
 
 This library is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.
@@ -1008,12 +1058,14 @@ modify it under the same terms as Perl itself.
 
 =head1 SEE ALSO
 
-perl(1), Module::Build::Cookbook(3), Module::Build::Authoring(3),
-ExtUtils::MakeMaker(3), YAML(3)
+perl(1), L<Module::Build::Cookbook>, L<Module::Build::Authoring>,
+L<Module::Build::API>, L<ExtUtils::MakeMaker>, L<YAML>
 
 F<META.yml> Specification:
-L<http://module-build.sourceforge.net/META-spec-v1.2.html>
+L<http://module-build.sourceforge.net/META-spec-current.html>
 
 L<http://www.dsmit.com/cons/>
 
+L<http://search.cpan.org/dist/PerlBuildSystem/>
+
 =cut