lib/Memoize/t/tie_storable.t Memoize Storable interface test
lib/Memoize/t/tie.t Memoize tied file test
lib/Memoize/t/unmemoize.t Memoize 'unmemoize' function test
+lib/Module/Build/Authoring.pod Module::Build
+lib/Module/Build/Base.pm Module::Build
+lib/Module/Build/Changes Module::Build
+lib/Module/Build/Compat.pm Module::Build
+lib/Module/Build/ConfigData.pm Module::Build
+lib/Module/Build/Cookbook.pm Module::Build
+lib/Module/Build/ModuleInfo.pm Module::Build
+lib/Module/Build/Notes.pm Module::Build
+lib/Module/Build/Platform/aix.pm Module::Build
+lib/Module/Build/Platform/Amiga.pm Module::Build
+lib/Module/Build/Platform/cygwin.pm Module::Build
+lib/Module/Build/Platform/darwin.pm Module::Build
+lib/Module/Build/Platform/Default.pm Module::Build
+lib/Module/Build/Platform/EBCDIC.pm Module::Build
+lib/Module/Build/Platform/MacOS.pm Module::Build
+lib/Module/Build/Platform/MPEiX.pm Module::Build
+lib/Module/Build/Platform/os2.pm Module::Build
+lib/Module/Build/Platform/RiscOS.pm Module::Build
+lib/Module/Build/Platform/Unix.pm Module::Build
+lib/Module/Build/Platform/VMS.pm Module::Build
+lib/Module/Build/Platform/VOS.pm Module::Build
+lib/Module/Build/Platform/Windows.pm Module::Build
+lib/Module/Build/PodParser.pm Module::Build
+lib/Module/Build/PPMMaker.pm Module::Build
+lib/Module/Build/scripts/config_data Module::Build
+lib/Module/Build/t/basic.t Module::Build
+lib/Module/Build/t/compat.t Module::Build
+lib/Module/Build/t/destinations.t Module::Build
+lib/Module/Build/t/ext.t Module::Build
+lib/Module/Build/t/extend.t Module::Build
+lib/Module/Build/t/files.t Module::Build
+lib/Module/Build/t/install.t Module::Build
+lib/Module/Build/t/lib/DistGen.pm Module::Build
+lib/Module/Build/t/lib/MBTest.pm Module::Build
+lib/Module/Build/t/manifypods.t Module::Build
+lib/Module/Build/t/metadata.t Module::Build
+lib/Module/Build/t/metadata2.t Module::Build
+lib/Module/Build/t/moduleinfo.t Module::Build
+lib/Module/Build/t/notes.t Module::Build
+lib/Module/Build/t/parents.t Module::Build
+lib/Module/Build/t/pod_parser.t Module::Build
+lib/Module/Build/t/ppm.t Module::Build
+lib/Module/Build/t/runthrough.t Module::Build
+lib/Module/Build/t/signature.t Module::Build
+lib/Module/Build/t/tilde.t Module::Build
+lib/Module/Build/t/versions.t Module::Build
+lib/Module/Build/t/xs.t Module::Build
+lib/Module/Build/t/bundled/Tie/CPHash.pm Module::Build.pm
+lib/Module/Build.pm Module::Build
lib/Module/CoreList/bin/corelist Module::CoreList
lib/Module/CoreList.pm Module::CoreList
lib/Module/CoreList/t/corelist.t Module::CoreList
util.c Utility routines
util.h Dummy header
utils/c2ph.PL program to translate dbx stabs to perl
+utils/config_data.PL Module::Build tool
utils/corelist.PL Module::CoreList
utils/cpan.PL easily interact with CPAN from the command line
utils/dprofpp.PL Perl code profile post-processor
'CPAN' => 1,
},
+ 'Module::Build' =>
+ {
+ 'MAINTAINER' => 'kwilliams',
+ 'FILES' => q[lib/Module/Build lib/Module/Build.pm],
+ 'CPAN' => 1,
+ },
+
'Module::CoreList' =>
{
'MAINTAINER' => 'rclamp',
# ignore the cpan script in lib/CPAN/bin, the instmodsh and xsubpp
# scripts in lib/ExtUtils, the prove script in lib/Test/Harness,
# the corelist script from lib/Module/CoreList/bin and ptar* in
- # lib/Archive/Tar/bin
+ # lib/Archive/Tar/bin, the config_data script in lib/Module/Build/scripts
# (they're installed later with other utils)
- return if $name =~ /^(?:cpan|instmodsh|prove|corelist|ptar|ptardiff)\z/;
+ return if $name =~ /^(?:cpan|instmodsh|prove|corelist|ptar|ptardiff|config_data)\z/;
# ignore the Makefiles
return if $name =~ /^makefile$/i;
# ignore the test extensions
--- /dev/null
+package Module::Build;
+
+# This module doesn't do much of anything itself, it inherits from the
+# modules that do the real work. The only real thing it has to do is
+# figure out which OS-specific module to pull in. Many of the
+# OS-specific modules don't do anything either - most of the work is
+# done in Module::Build::Base.
+
+use strict;
+use File::Spec ();
+use File::Path ();
+use File::Basename ();
+
+use Module::Build::Base;
+
+use vars qw($VERSION @ISA);
+@ISA = qw(Module::Build::Base);
+$VERSION = '0.27_08';
+$VERSION = eval $VERSION;
+
+# Okay, this is the brute-force method of finding out what kind of
+# platform we're on. I don't know of a systematic way. These values
+# came from the latest (bleadperl) perlport.pod.
+
+my %OSTYPES = qw(
+ aix Unix
+ bsdos Unix
+ dgux Unix
+ dynixptx Unix
+ freebsd Unix
+ linux Unix
+ hpux Unix
+ irix Unix
+ darwin Unix
+ machten Unix
+ next Unix
+ openbsd Unix
+ netbsd Unix
+ dec_osf Unix
+ svr4 Unix
+ svr5 Unix
+ sco_sv Unix
+ unicos Unix
+ unicosmk Unix
+ solaris Unix
+ sunos Unix
+ cygwin Unix
+ os2 Unix
+
+ dos Windows
+ MSWin32 Windows
+
+ os390 EBCDIC
+ os400 EBCDIC
+ posix-bc EBCDIC
+ vmesa EBCDIC
+
+ MacOS MacOS
+ VMS VMS
+ VOS VOS
+ riscos RiscOS
+ amigaos Amiga
+ mpeix MPEiX
+ );
+
+# Inserts the given module into the @ISA hierarchy between
+# Module::Build and its immediate parent
+sub _interpose_module {
+ my ($self, $mod) = @_;
+ eval "use $mod";
+ die $@ if $@;
+
+ no strict 'refs';
+ my $top_class = $mod;
+ while (@{"${top_class}::ISA"}) {
+ last if ${"${top_class}::ISA"}[0] eq $ISA[0];
+ $top_class = ${"${top_class}::ISA"}[0];
+ }
+
+ @{"${top_class}::ISA"} = @ISA;
+ @ISA = ($mod);
+}
+
+if (grep {-e File::Spec->catfile($_, qw(Module Build Platform), $^O) . '.pm'} @INC) {
+ __PACKAGE__->_interpose_module("Module::Build::Platform::$^O");
+
+} elsif (exists $OSTYPES{$^O}) {
+ __PACKAGE__->_interpose_module("Module::Build::Platform::$OSTYPES{$^O}");
+
+} else {
+ warn "Unknown OS type '$^O' - using default settings\n";
+}
+
+sub os_type { $OSTYPES{$^O} }
+
+1;
+
+__END__
+
+
+=head1 NAME
+
+Module::Build - Build and install Perl modules
+
+
+=head1 SYNOPSIS
+
+Standard process for building & installing modules:
+
+ perl Build.PL
+ ./Build
+ ./Build test
+ ./Build install
+
+Or, if you're on a platform (like DOS or Windows) that doesn't require
+the "./" notation, you can do this:
+
+ perl Build.PL
+ Build
+ Build test
+ Build install
+
+
+=head1 DESCRIPTION
+
+C<Module::Build> is a system for building, testing, and installing
+Perl modules. It is meant to be an alternative to
+C<ExtUtils::MakeMaker>. Developers may alter the behavior of the
+module through subclassing in a much more straightforward way than
+with C<MakeMaker>. It also does not require a C<make> on your system
+- most of the C<Module::Build> code is pure-perl and written in a very
+cross-platform way. In fact, you don't even need a shell, so even
+platforms like MacOS (traditional) can use it fairly easily. Its only
+prerequisites are modules that are included with perl 5.6.0, and it
+works fine on perl 5.005 if you can install a few additional modules.
+
+See L<"MOTIVATIONS"> for more comparisons between C<ExtUtils::MakeMaker>
+and C<Module::Build>.
+
+To install C<Module::Build>, and any other module that uses
+C<Module::Build> for its installation process, do the following:
+
+ perl Build.PL # 'Build.PL' script creates the 'Build' script
+ ./Build # Need ./ to ensure we're using this "Build" script
+ ./Build test # and not another one that happens to be in the PATH
+ ./Build install
+
+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 html
+ clean install
+ code manifest
+ config_data manpages
+ diff ppd
+ dist ppmdist
+ distcheck prereq_report
+ distclean pure_install
+ distdir realclean
+ distmeta skipcheck
+ distsign test
+ disttest testcover
+ docs testdb
+ fakeinstall testpod
+ help versioninstall
+
+
+You can run the 'help' action for a complete list of actions.
+
+
+=head1 GUIDE TO DOCUMENTATION
+
+The documentation for C<Module::Build> is broken up into three sections:
+
+=over
+
+=item General Usage (L<Module::Build>)
+
+This is the document you are currently reading. It describes basic
+usage and background information. Its main purpose is to assist the
+user who wants to learn how to invoke and control C<Module::Build>
+scripts at the command line.
+
+=item Authoring Reference (L<Module::Build::Authoring>)
+
+This document describes the C<Module::Build> API for 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.
+
+=item Cookbook (L<Module::Build::Cookbook>)
+
+This document demonstrates how to accomplish many common tasks. It
+covers general command line usage and authoring of F<Build.PL>
+scripts. Includes working examples.
+
+=back
+
+
+=head1 ACTIONS
+
+There are some general principles at work here. First, each task when
+building a module is called an "action". These actions are listed
+above; they correspond to the building, testing, installing,
+packaging, etc., tasks.
+
+Second, arguments are processed in a very systematic way. Arguments
+are always key=value pairs. They may be specified at C<perl Build.PL>
+time (i.e. C<perl Build.PL destdir=/my/secret/place>), in which case
+their values last for the lifetime of the C<Build> script. They may
+also be specified when executing a particular action (i.e.
+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
+values in C<Config.pm>, she may specify them like so:
+
+ perl Build.PL --config cc=gcc --config ld=gcc
+
+The following build actions are provided by default.
+
+=over 4
+
+=item build
+
+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 clean
+
+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
+
+This action builds your codebase.
+
+By default it just creates a C<blib/> directory and copies any C<.pm>
+and C<.pod> files from your C<lib/> directory into the C<blib/>
+directory. It also compiles any C<.xs> files from C<lib/> and places
+them in C<blib/>. Of course, you need a working C compiler (probably
+the same one that built perl itself) for the compilation to work
+properly.
+
+The C<code> action also runs any C<.PL> files in your F<lib/>
+directory. Typically these create other files, named the same but
+without the C<.PL> ending. For example, a file F<lib/Foo/Bar.pm.PL>
+could create the file F<lib/Foo/Bar.pm>. The C<.PL> files are
+processed first, so any C<.pm> files (or other kinds that we deal
+with) will get copied correctly.
+
+=item config_data
+
+...
+
+=item diff
+
+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
+other files like compiled binary files, we simply report whether they
+differ.
+
+A C<flags> parameter may be passed to the action, which will be passed
+to the 'diff' program. Consult your 'diff' documentation for the
+parameters it will accept - a good one is C<-u>:
+
+ ./Build diff flags=-u
+
+=item dist
+
+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
+GZIP compression.
+
+By default, this action will use the external C<tar> and C<gzip>
+executables on Unix-like platforms, and the C<Archive::Tar> module
+elsewhere. However, you can force it to use whatever executable you
+want by supplying an explicit C<tar> (and optional C<gzip>) parameter:
+
+ ./Build dist --tar C:\path\to\tar.exe --gzip C:\path\to\zip.exe
+
+=item distcheck
+
+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
+
+Performs the 'realclean' action and then the 'distcheck' action.
+
+=item distdir
+
+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.
+This directory is what the distribution tarball is created from.
+
+=item distmeta
+
+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
+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>
+
+=item distsign
+
+Uses C<Module::Signature> to create a SIGNATURE file for your
+distribution, and adds the SIGNATURE file to the distribution's
+MANIFEST.
+
+=item disttest
+
+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
+
+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
+targets defined (as will be the case on systems that don't support
+Unix manpages) no action is taken for manpages. If there are no
+C<binhtml> or C<libhtml> installation targets defined no action is
+taken for html documents.
+
+=item fakeinstall
+
+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
+
+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.
+
+With an optional argument specifying an action name (e.g. C<Build help
+test>), the 'help' action will show you any POD documentation it can
+find for that action.
+
+=item html
+
+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
+C<Config.pm>. You can also supply or override install paths on the
+command line by specifying C<install_path> values for the C<binhtml>
+and/or C<libhtml> installation targets.
+
+=item install
+
+This action will use C<ExtUtils::Install> to install the files from
+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.
+
+If you want the installation process to look around in C<@INC> for
+other versions of the stuff you're installing and try to delete it,
+you can use the C<uninst> parameter, which tells C<ExtUtils::Install> to
+do so:
+
+ ./Build install uninst=1
+
+This can be a good idea, as it helps prevent multiple versions of a
+module from being present on your system, which can be a confusing
+situation indeed.
+
+=item manifest
+
+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
+F<MANIFEST.SKIP> file to exclude certain files or directories from
+inclusion in the F<MANIFEST>. F<MANIFEST.SKIP> should contain a bunch
+of regular expressions, one per line. If a file in the distribution
+directory matches any of the regular expressions, it won't be included
+in the F<MANIFEST>.
+
+The following is a reasonable F<MANIFEST.SKIP> starting point, you can
+add your own stuff to it:
+
+ ^_build
+ ^Build$
+ ^blib
+ ~$
+ \.bak$
+ ^MANIFEST\.SKIP$
+ CVS
+
+See the L<distcheck> and L<skipcheck> actions if you want to find out
+what the C<manifest> action would do, without actually doing anything.
+
+=item manpages
+
+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
+also supply or override install paths by specifying there values on
+the command line with the C<bindoc> and C<libdoc> installation
+targets.
+
+=item ppd
+
+Build a PPD file for your distribution.
+
+This action takes an optional argument C<codebase> which is used in
+the generated ppd file to specify the (usually relative) URL of the
+distribution. By default, this value is the distribution name without
+any path information.
+
+Example:
+
+ ./Build ppd --codebase "MSWin32-x86-multi-thread/Module-Build-0.21.tar.gz"
+
+=item ppmdist
+
+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.
+
+This uses the same mechanism as the C<dist> action to tar & zip its
+output, so you can supply C<tar> and/or C<gzip> parameters to affect
+the result.
+
+=item prereq_report
+
+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
+for a bug report.
+
+=item pure_install
+
+This action is identical to the C<install> action. In the future,
+though, if C<install> starts writing to the file file
+F<$(INSTALLARCHLIB)/perllocal.pod>, C<pure_install> won't, and that
+will be the only difference between them.
+
+=item realclean
+
+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 skipcheck
+
+Reports which files are skipped due to the entries in the
+F<MANIFEST.SKIP> file (See L<manifest> for details)
+
+=item test
+
+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
+with C<.t> in a C<t/> directory.
+
+If you want tests to be 'verbose', i.e. show details of test execution
+rather than just summary information, pass the argument C<verbose=1>.
+
+If you want to run tests under the perl debugger, pass the argument
+C<debugger=1>.
+
+In addition, if a file called C<visual.pl> exists in the top-level
+directory, this file will be executed as a Perl script and its output
+will be shown to the user. This is a good place to put speed tests or
+other tests that don't use the C<Test::Harness> format for output.
+
+To override the choice of tests to run, you may pass a C<test_files>
+argument whose value is a whitespace-separated list of test scripts to
+run. This is especially useful in development, when you only want to
+run a single test to see whether you've squashed a certain bug yet:
+
+ ./Build test --test_files t/something_failing.t
+
+You may also pass several C<test_files> arguments separately:
+
+ ./Build test --test_files t/one.t --test_files t/two.t
+
+or use a C<glob()>-style pattern:
+
+ ./Build test --test_files 't/01-*.t'
+
+=item testcover
+
+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.
+
+To pass options to C<Devel::Cover>, set the C<$DEVEL_COVER_OPTIONS>
+environment variable:
+
+ DEVEL_COVER_OPTIONS=-ignore,Build ./Build testcover
+
+=item testdb
+
+This is a synonym for the 'test' action with the C<debugger=1>
+argument.
+
+=item testpod
+
+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 versioninstall
+
+** 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. **
+
+If you have the C<only.pm> module installed on your system, you can
+use this action to install a module into the version-specific library
+trees. This means that you can have several versions of the same
+module installed and C<use> a specific one like this:
+
+ use only MyModule => 0.55;
+
+To override the default installation libraries in C<only::config>,
+specify the C<versionlib> parameter when you run the C<Build.PL> script:
+
+ perl Build.PL --versionlib /my/version/place/
+
+To override which version the module is installed as, specify the
+C<versionlib> parameter when you run the C<Build.PL> script:
+
+ perl Build.PL --version 0.50
+
+See the C<only.pm> documentation for more information on
+version-specific installs.
+
+=back
+
+
+=head1 OPTIONS
+
+=head2 Command Line Options
+
+The following options can be used during any invocation of C<Build.PL>
+or the Build script, during any action. For information on other
+options specific to an action, see the documentation for the
+respective action.
+
+NOTE: There is some preliminary support for options to use the more
+familiar long option style. Most options can be preceded with the
+C<--> long option prefix, and the underscores changed to dashes
+(e.g. --use-rcfile). Additionally, the argument to boolean options is
+optional, and boolean options can be negated by prefixing them with
+'no' or 'no-' (e.g. --noverbose or --no-verbose).
+
+=over 4
+
+=item quiet
+
+Suppress informative messages on output.
+
+=item use_rcfile
+
+Load the F<~/.modulebuildrc> option file. This option can be set to
+false to prevent the custom resource file from being loaded.
+
+=item verbose
+
+Display extra information about the Build on output.
+
+=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
+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.
+
+The action name must come at the beginning of the line, followed by any
+amount of whitespace and then the options. Options are given the same
+as they would be on the command line. They can be separated by any
+amount of whitespace, including newlines, as long there is whitespace at
+the beginning of each continued line. Anything following a hash mark (C<#>)
+is considered a comment, and is stripped before parsing. If more than
+one line begins with the same action name, those lines are merged into
+one set of options.
+
+Besides the regular actions, there are two special pseudo-actions: the
+key C<*> (asterisk) denotes any global options that should be applied
+to all actions, and the key 'Build_PL' specifies options to be applied
+when you invoke C<perl Build.PL>.
+
+ * verbose=1 # global options
+ diff flags=-u
+ install --install_base /home/ken
+ --install_path html=/home/ken/docs/html
+
+If you wish to locate your resource file in a different location, you
+can set the environment variable 'MODULEBUILDRC' to the complete
+absolute path of the file containing your options.
+
+
+=head1 INSTALL PATHS
+
+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
+F<Config.pm>, and they may be overridden by using the C<install_path>
+parameter. An C<install_base> parameter lets you specify an
+alternative installation root like F</home/foo>, and a C<destdir> lets
+you specify a temporary installation directory like F</tmp/install> in
+case you want to create bundled-up installable packages.
+
+Natively, Module::Build provides default installation locations for
+the following types of installable items:
+
+=over 4
+
+=item lib
+
+Usually pure-Perl module files ending in F<.pm>.
+
+=item arch
+
+"Architecture-dependent" module files, usually produced by compiling
+XS, Inline, or similar code.
+
+=item script
+
+Programs written in pure Perl. In order to improve reuse, try to make
+these as small as possible - put the code into modules whenever
+possible.
+
+=item bin
+
+"Architecture-dependent" executable programs, i.e. compiled C code or
+something. Pretty rare to see this in a perl distribution, but it
+happens.
+
+=item bindoc
+
+Documentation for the stuff in C<script> and C<bin>. Usually
+generated from the POD in those files. Under Unix, these are manual
+pages belonging to the 'man1' category.
+
+=item libdoc
+
+Documentation for the stuff in C<lib> and C<arch>. This is usually
+generated from the POD in F<.pm> files. Under Unix, these are manual
+pages belonging to the 'man3' category.
+
+=item binhtml
+
+This is the same as C<bindoc> above, but applies to html documents.
+
+=item libhtml
+
+This is the same as C<bindoc> above, but applies to html documents.
+
+=back
+
+Four other parameters let you control various aspects of how
+installation paths are determined:
+
+=over 4
+
+=item installdirs
+
+The default destinations for these installable things come from
+entries in your system's C<Config.pm>. You can select from three
+different sets of default locations by setting the C<installdirs>
+parameter as follows:
+
+ 'installdirs' set to:
+ core site vendor
+
+ uses the following defaults from Config.pm:
+
+ lib => installprivlib installsitelib installvendorlib
+ arch => installarchlib installsitearch installvendorarch
+ script => installscript installsitebin installvendorbin
+ bin => installbin installsitebin installvendorbin
+ bindoc => installman1dir installsiteman1dir installvendorman1dir
+ libdoc => installman3dir installsiteman3dir installvendorman3dir
+ binhtml => installhtml1dir installsitehtml1dir installvendorhtml1dir [*]
+ libhtml => installhtml3dir installsitehtml3dir installvendorhtml3dir [*]
+
+ * Under some OS (eg. MSWin32) the destination for html documents is
+ determined by the C<Config.pm> entry C<installhtmldir>.
+
+The default value of C<installdirs> is "site". If you're creating
+vendor distributions of module packages, you may want to do something
+like this:
+
+ perl Build.PL --installdirs vendor
+
+or
+
+ ./Build install --installdirs vendor
+
+If you're installing an updated version of a module that was included
+with perl itself (i.e. a "core module"), then you may set
+C<installdirs> to "core" to overwrite the module in its present
+location.
+
+(Note that the 'script' line is different from MakeMaker -
+unfortunately there's no such thing as "installsitescript" or
+"installvendorscript" entry in C<Config.pm>, so we use the
+"installsitebin" and "installvendorbin" entries to at least get the
+general location right. In the future, if C<Config.pm> adds some more
+appropriate entries, we'll start using those.)
+
+=item install_path
+
+Once the defaults have been set, you can override them.
+
+On the command line, that would look like this:
+
+ perl Build.PL --install_path lib=/foo/lib --install_path arch=/foo/lib/arch
+
+or this:
+
+ ./Build install --install_path lib=/foo/lib --install_path arch=/foo/lib/arch
+
+=item install_base
+
+You can also set the whole bunch of installation paths by supplying the
+C<install_base> parameter to point to a directory on your system. For
+instance, if you set C<install_base> to "/home/ken" on a Linux
+system, you'll install as follows:
+
+ lib => /home/ken/lib/perl5
+ arch => /home/ken/lib/perl5/i386-linux
+ script => /home/ken/bin
+ bin => /home/ken/bin
+ bindoc => /home/ken/man/man1
+ libdoc => /home/ken/man/man3
+ binhtml => /home/ken/html
+ 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
+directory you specify, which may have little to do with the
+C<installdirs=site> layout.
+
+The exact layout under the directory you specify may vary by system -
+we try to do the "sensible" thing on each platform.
+
+=item destdir
+
+If you want to install everything into a temporary directory first
+(for instance, if you want to create a directory tree that a package
+manager like C<rpm> or C<dpkg> could create a package from), you can
+use the C<destdir> parameter:
+
+ perl Build.PL --destdir /tmp/foo
+
+or
+
+ ./Build install --destdir /tmp/foo
+
+This will effectively install to "/tmp/foo/$sitelib",
+"/tmp/foo/$sitearch", and the like, except that it will use
+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.
+
+
+=over 4
+
+=item Why PREFIX is not recommended
+
+=over 4
+
+=item *
+
+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.
+
+=item *
+
+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
+
+
+=head1 MOTIVATIONS
+
+There are several reasons I wanted to start over, and not just fix
+what I didn't like about MakeMaker:
+
+=over 4
+
+=item *
+
+I don't like the core idea of MakeMaker, namely that C<make> should be
+involved in the build process. Here are my reasons:
+
+=over 4
+
+=item +
+
+When a person is installing a Perl module, what can you assume about
+their environment? Can you assume they have C<make>? No, but you can
+assume they have some version of Perl.
+
+=item +
+
+When a person is writing a Perl module for intended distribution, can
+you assume that they know how to build a Makefile, so they can
+customize their build process? No, but you can assume they know Perl,
+and could customize that way.
+
+=back
+
+For years, these things have been a barrier to people getting the
+build/install process to do what they want.
+
+=item *
+
+There are several architectural decisions in MakeMaker that make it
+very difficult to customize its behavior. For instance, when using
+MakeMaker you do C<use ExtUtils::MakeMaker>, but the object created in
+C<WriteMakefile()> is actually blessed into a package name that's
+created on the fly, so you can't simply subclass
+C<ExtUtils::MakeMaker>. There is a workaround C<MY> package that lets
+you override certain MakeMaker methods, but only certain explicitly
+preselected (by MakeMaker) methods can be overridden. Also, the method
+of customization is very crude: you have to modify a string containing
+the Makefile text for the particular target. Since these strings
+aren't documented, and I<can't> be documented (they take on different
+values depending on the platform, version of perl, version of
+MakeMaker, etc.), you have no guarantee that your modifications will
+work on someone else's machine or after an upgrade of MakeMaker or
+perl.
+
+=item *
+
+It is risky to make major changes to MakeMaker, since it does so many
+things, is so important, and generally works. C<Module::Build> is an
+entirely separate package so that I can work on it all I want, without
+worrying about backward compatibility.
+
+=item *
+
+Finally, Perl is said to be a language for system administration.
+Could it really be the case that Perl isn't up to the task of building
+and installing software? Even if that software is a bunch of stupid
+little C<.pm> files that just need to be copied from one place to
+another? My sense was that we could design a system to accomplish
+this in a flexible, extensible, and friendly manner. Or die trying.
+
+=back
+
+
+=head1 TO DO
+
+The current method of relying on time stamps to determine whether a
+derived file is out of date isn't likely to scale well, since it
+requires tracing all dependencies backward, it runs into problems on
+NFS, and it's just generally flimsy. It would be better to use an MD5
+signature or the like, if available. See C<cons> for an example.
+
+ - append to perllocal.pod
+ - add a 'plugin' functionality
+
+
+=head1 AUTHOR
+
+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>.
+
+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.
+
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001-2005 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.
+
+
+=head1 SEE ALSO
+
+perl(1), Module::Build::Cookbook(3), Module::Build::Authoring(3),
+ExtUtils::MakeMaker(3), YAML(3)
+
+F<META.yml> Specification:
+L<http://module-build.sourceforge.net/META-spec-v1.2.html>
+
+L<http://www.dsmit.com/cons/>
+
+=cut
--- /dev/null
+=head1 NAME
+
+Module::Build::Authoring - Authoring Module::Build modules
+
+
+=head1 DESCRIPTION
+
+When creating a C<Build.PL> script for a module, something like the
+following code will typically be used:
+
+ use Module::Build;
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ license => 'perl',
+ requires => {
+ 'perl' => '5.6.1',
+ 'Some::Module' => '1.23',
+ 'Other::Module' => '>= 1.2, != 1.5, < 2.0',
+ },
+ );
+ $build->create_build_script;
+
+A simple module could get away with something as short as this for its
+C<Build.PL> script:
+
+ use Module::Build;
+ Module::Build->new(
+ module_name => 'Foo::Bar',
+ license => 'perl',
+ )->create_build_script;
+
+The model used by C<Module::Build> is a lot like the C<MakeMaker>
+metaphor, with the following correspondences:
+
+ In Module::Build In ExtUtils::MakeMaker
+ --------------------------- ------------------------
+ Build.PL (initial script) Makefile.PL (initial script)
+ Build (a short perl script) Makefile (a long Makefile)
+ _build/ (saved state info) various config text in the Makefile
+
+Any customization can be done simply by subclassing C<Module::Build>
+and adding a method called (for example) C<ACTION_test>, overriding
+the default 'test' action. You could also add a method called
+C<ACTION_whatever>, and then you could perform the action C<Build
+whatever>.
+
+For information on providing compatibility with
+C<ExtUtils::MakeMaker>, see L<Module::Build::Compat> and
+L<http://www.makemaker.org/wiki/index.cgi?ModuleBuildConversionGuide>.
+
+
+=head1 API
+
+I list here some of the most important methods in C<Module::Build>.
+Normally you won't need to deal with these methods unless you want to
+subclass C<Module::Build>. But since one of the reasons I created
+this module in the first place was so that subclassing is possible
+(and easy), I will certainly write more docs as the interface
+stabilizes.
+
+
+=head2 CONSTRUCTORS
+
+
+=over 4
+
+=item current()
+
+This method returns a reasonable facsimile of the currently-executing
+C<Module::Build> object representing the current build. You can use
+this object to query its C<notes()> method, inquire about installed
+modules, and so on. This is a great way to share information between
+different parts of your build process. For instance, you can ask
+the user a question during C<perl Build.PL>, then use their answer
+during a regression test:
+
+ # In Build.PL:
+ my $color = $build->prompt("What is your favorite color?");
+ $build->notes(color => $color);
+
+ # In t/colortest.t:
+ use Module::Build;
+ my $build = Module::Build->current;
+ my $color = $build->notes('color');
+ ...
+
+The way the C<current()> method is currently implemented, there may be
+slight differences between the C<$build> object in Build.PL and the
+one in C<t/colortest.t>. It is our goal to minimize these differences
+in future releases of Module::Build, so please report any anomalies
+you find.
+
+One important caveat: in its current implementation, C<current()> will
+B<NOT> work correctly if you have changed out of the directory that
+C<Module::Build> was invoked from.
+
+=item new()
+
+Creates a new Module::Build object. Arguments to the new() method are
+listed below. Most arguments are optional, but you must provide
+either the C<module_name> argument, or C<dist_name> and one of
+C<dist_version> or C<dist_version_from>. In other words, you must
+provide enough information to determine both a distribution name and
+version.
+
+
+=over 4
+
+=item add_to_cleanup
+
+An array reference of files to be cleaned up when the C<clean> action
+is performed. See also the add_to_cleanup() method.
+
+=item auto_features
+
+This parameter supports the setting of features (see
+L<feature($name)>) automatically based on a set of prerequisites. For
+instance, for a module that could optionally use either MySQL or
+PostgreSQL databases, you might use C<auto_features> like this:
+
+ my $build = Module::Build->new
+ (
+ ...other stuff here...
+ auto_features => {
+ pg_support => {
+ description => "Interface with Postgres databases",
+ requires => { 'DBD::Pg' => 23.3,
+ 'DateTime::Format::Pg' => 0 },
+ },
+ mysql_support => {
+ description => "Interface with MySQL databases",
+ requires => { 'DBD::mysql' => 17.9,
+ 'DateTime::Format::MySQL' => 0 },
+ },
+ }
+ );
+
+For each feature named, the required prerequisites will be checked, and
+if there are no failures, the feature will be enabled (set to C<1>).
+Otherwise the failures will be displayed to the user and the feature
+will be disabled (set to C<0>).
+
+See the documentation for L<requires> for the details of how
+requirements can be specified.
+
+=item autosplit
+
+An optional C<autosplit> argument specifies a file which should be run
+through the C<Autosplit::autosplit()> function. If multiple files
+should be split, the argument may be given as an array of the files to
+split.
+
+In general I don't consider autosplitting a great idea, because it's
+not always clear that autosplitting achieves its intended performance
+benefits. It may even harm performance in environments like mod_perl,
+where as much as possible of a module's code should be loaded during
+startup.
+
+=item build_class
+
+The Module::Build class or subclass to use in the build
+script. Defaults to "Module::Build" or the class name passed to or
+created by a call to C<subclass()>. This property is useful if you're
+writing a custom Module::Build subclass and have a bootstrapping
+problem--that is, your subclass requires modules that may not be
+installed when C<perl Build.PL> is executed, but you've listed in
+C<build_requires> so that they should be available when C<./Build> is
+executed.
+
+=item build_requires
+
+Modules listed in this section are necessary to build and install the
+given module, but are not necessary for regular usage of it. This is
+actually an important distinction - it allows for tighter control over
+the body of installed modules, and facilitates correct dependency
+checking on binary/packaged distributions of the module.
+
+See the documentation for L<"PREREQUISITES"> for the details of how
+requirements can be specified.
+
+=item c_source
+
+An optional C<c_source> argument specifies a directory which contains
+C source files that the rest of the build may depend on. Any C<.c>
+files in the directory will be compiled to object files. The
+directory will be added to the search path during the compilation and
+linking phases of any C or XS files.
+
+=item conflicts
+
+Modules listed in this section conflict in some serious way with the
+given module. C<Module::Build> (or some higher-level tool) will
+refuse to install the given module if the given module/version is also
+installed.
+
+See the documentation for L<"PREREQUISITES"> for the details of how
+requirements can be specified.
+
+=item create_makefile_pl
+
+This parameter lets you use Module::Build::Compat during the
+C<distdir> (or C<dist>) action to automatically create a Makefile.PL
+for compatibility with ExtUtils::MakeMaker. The parameter's value
+should be one of the styles named in the Module::Build::Compat
+documentation.
+
+=item create_readme
+
+This parameter tells Module::Build to automatically create a F<README>
+file at the top level of your distribution. Currently it will simply
+use C<Pod::Text> (or C<Pod::Readme> if it's installed) on the file
+indicated by C<dist_version_from> and put the result in the F<README>
+file. This is by no means the only recommended style for writing a
+README, but it seems to be one common one used on the CPAN.
+
+If you generate a F<README> in this way, it's probably a good idea to
+create a separate F<INSTALL> file if that information isn't in the
+generated F<README>.
+
+=item dist_abstract
+
+This should be a short description of the distribution. This is used
+when generating metadata for F<META.yml> and PPD files. If it is not
+given then C<Module::Build> looks in the POD of the module from which
+it gets the distribution's version. It looks for the first line
+matching C<$package\s-\s(.+)>, and uses the captured text as the
+abstract.
+
+=item dist_author
+
+This should be something like "John Doe <jdoe@example.com>", or if
+there are multiple authors, an anonymous array of strings may be
+specified. This is used when generating metadata for F<META.yml> and
+PPD files. If this is not specified, then C<Module::Build> looks at
+the module from which it gets the distribution's version. If it finds
+a POD section marked "=head1 AUTHOR", then it uses the contents of
+this section.
+
+=item dist_name
+
+Specifies the name for this distribution. Most authors won't need to
+set this directly, they can use C<module_name> to set C<dist_name> to
+a reasonable default. However, some agglomerative distributions like
+C<libwww-perl> or C<bioperl> have names that don't correspond directly
+to a module name, so C<dist_name> can be set independently.
+
+=item dist_version
+
+Specifies a version number for the distribution. See C<module_name>
+or C<dist_version_from> for ways to have this set automatically from a
+C<$VERSION> variable in a module. One way or another, a version
+number needs to be set.
+
+=item dist_version_from
+
+Specifies a file to look for the distribution version in. Most
+authors won't need to set this directly, they can use C<module_name>
+to set it to a reasonable default.
+
+The version is extracted from the specified file according to the same
+rules as C<ExtUtils::MakeMaker> and C<CPAN.pm>. It involves finding
+the first line that matches the regular expression
+
+ /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/
+
+eval()-ing that line, then checking the value of the C<$VERSION>
+variable. Quite ugly, really, but all the modules on CPAN depend on
+this process, so there's no real opportunity to change to something
+better.
+
+=item dynamic_config
+
+A boolean flag indicating whether the F<Build.PL> file must be
+executed, or whether this module can be built, tested and installed
+solely from consulting its metadata file. The main reason to set this
+to a true value is that your module performs some dynamic
+configuration as part of its build/install process. If the flag is
+omitted, the F<META.yml> spec says that installation tools should
+treat it as 1 (true), because this is a safer way to behave.
+
+Currently C<Module::Build> doesn't actually do anything with this flag
+- it's up to higher-level tools like C<CPAN.pm> to do
+something useful with it. It can potentially bring lots of security,
+packaging, and convenience improvements.
+
+=item extra_compiler_flags
+
+=item extra_linker_flags
+
+These parameters can contain array references (or strings, in which
+case they will be split into arrays) to pass through to the compiler
+and linker phases when compiling/linking C code. For example, to tell
+the compiler that your code is C++, you might do:
+
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ extra_compiler_flags => ['-x', 'c++'],
+ );
+
+To link your XS code against glib you might write something like:
+
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ dynamic_config => 1,
+ extra_compiler_flags => scalar `glib-config --cflags`,
+ extra_linker_flags => scalar `glib-config --libs`,
+ );
+
+=item get_options
+
+You can pass arbitrary command line options to F<Build.PL> or
+F<Build>, and they will be stored in the Module::Build object and can
+be accessed via the C<args()> method. However, sometimes you want
+more flexibility out of your argument processing than this allows. In
+such cases, use the C<get_options> parameter to pass in a hash
+reference of argument specifications, and the list of arguments to
+F<Build.PL> or F<Build> will be processed according to those
+specifications before they're passed on to C<Module::Build>'s own
+argument processing.
+
+The supported option specification hash keys are:
+
+
+=over 4
+
+=item type
+
+The type of option. The types are those supported by Getopt::Long; consult
+its documentation for a complete list. Typical types are C<=s> for strings,
+C<+> for additive options, and C<!> for negatable options. If the
+type is not specified, it will be considered a boolean, i.e. no
+argument is taken and a value of 1 will be assigned when the option is
+encountered.
+
+=item store
+
+A reference to a scalar in which to store the value passed to the option.
+If not specified, the value will be stored under the option name in the
+hash returned by the C<args()> method.
+
+=item default
+
+A default value for the option. If no default value is specified and no option
+is passed, then the option key will not exist in the hash returned by
+C<args()>.
+
+=back
+
+
+You can combine references to your own variables or subroutines with
+unreferenced specifications, for which the result will also be stored in the
+hash returned by C<args()>. For example:
+
+ my $loud = 0;
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ get_options => {
+ loud => { store => \$loud },
+ dbd => { type => '=s' },
+ quantity => { type => '+' },
+ }
+ );
+
+ print STDERR "HEY, ARE YOU LISTENING??\n" if $loud;
+ print "We'll use the ", $build->args('dbd'), " DBI driver\n";
+ print "Are you sure you want that many?\n"
+ if $build->args('quantity') > 2;
+
+The arguments for such a specification can be called like so:
+
+ perl Build.PL --loud --dbd=DBD::pg --quantity --quantity --quantity
+
+B<WARNING:> Any option specifications that conflict with Module::Build's own
+options (defined by its properties) will throw an exception.
+
+Consult the Getopt::Long documentation for details on its usage.
+
+=item include_dirs
+
+Specifies any additional directories in which to search for C header
+files. May be given as a string indicating a single directory, or as
+a list reference indicating multiple directories.
+
+=item install_path
+
+You can set paths for individual installable elements by using the
+C<install_path> parameter:
+
+ my $build = Module::Build->new
+ (
+ ...other stuff here...
+ install_path => {
+ lib => '/foo/lib',
+ arch => '/foo/lib/arch',
+ }
+ );
+
+=item installdirs
+
+Determines where files are installed within the normal perl hierarchy
+as determined by F<Config.pm>. Valid values are: C<core>, C<site>,
+C<vendor>. The default is C<site>. See
+L<Module::Build/"INSTALL PATHS">
+
+=item license
+
+Specifies the licensing terms of your distribution. Valid options include:
+
+
+=over 4
+
+=item apache
+
+The distribution is licensed under the Apache Software License
+(http://opensource.org/licenses/apachepl.php).
+
+=item artistic
+
+The distribution is licensed under the Artistic License, as specified
+by the F<Artistic> file in the standard perl distribution.
+
+=item bsd
+
+The distribution is licensed under the BSD License
+(http://www.opensource.org/licenses/bsd-license.php).
+
+=item gpl
+
+The distribution is licensed under the terms of the Gnu General
+Public License (http://www.opensource.org/licenses/gpl-license.php).
+
+=item lgpl
+
+The distribution is licensed under the terms of the Gnu Lesser
+General Public License
+(http://www.opensource.org/licenses/lgpl-license.php).
+
+=item mit
+
+The distribution is licensed under the MIT License
+(http://opensource.org/licenses/mit-license.php).
+
+=item mozilla
+
+The distribution is licensed under the Mozilla Public
+License. (http://opensource.org/licenses/mozilla1.0.php or
+http://opensource.org/licenses/mozilla1.1.php)
+
+=item open_source
+
+The distribution is licensed under some other Open Source
+Initiative-approved license listed at
+http://www.opensource.org/licenses/ .
+
+=item perl
+
+The distribution may be copied and redistributed under the same terms
+as perl itself (this is by far the most common licensing option for
+modules on CPAN). This is a dual license, in which the user may
+choose between either the GPL or the Artistic license.
+
+=item restrictive
+
+The distribution may not be redistributed without special permission
+from the author and/or copyright holder.
+
+=item unrestricted
+
+The distribution is licensed under a license that is B<not> approved
+by www.opensource.org but that allows distribution without
+restrictions.
+
+=back
+
+
+Note that you must still include the terms of your license in your
+documentation - this field only lets automated tools figure out your
+licensing restrictions. Humans still need something to read. If you
+choose to provide this field, you should make sure that you keep it in
+sync with your written documentation if you ever change your licensing
+terms.
+
+It is a fatal error to use a license other than the ones mentioned
+above. This is not because I wish to impose licensing terms on you -
+please let me know if you would like another license option to be
+added to the list. You may also use a license type of C<unknown> if
+you don't wish to specify your terms (but this is usually not a good
+idea for you to do!).
+
+I just started out with a small set of licenses to keep things simple,
+figuring I'd let people with actual working knowledge in this area
+tell me what to do. So if that's you, drop me a line.
+
+=item meta_add
+
+A hash of key/value pairs that should be added to the F<META.yml> file
+during the C<distmeta> action. Any existing entries with the same
+names will be overridden.
+
+=item meta_merge
+
+A hash of key/value pairs that should be merged into the F<META.yml>
+file during the C<distmeta> action. Any existing entries with the
+same names will be overridden.
+
+The only difference between C<meta_add> and C<meta_merge> is their
+behavior on hash-valued and array-valued entries: C<meta_add> will
+completely blow away the existing hash or array value, but
+C<meta_merge> will merge the supplied data into the existing hash or
+array value.
+
+=item module_name
+
+The C<module_name> is a shortcut for setting default values of
+C<dist_name> and C<dist_version_from>, reflecting the fact that the
+majority of CPAN distributions are centered around one "main" module.
+For instance, if you set C<module_name> to C<Foo::Bar>, then
+C<dist_name> will default to C<Foo-Bar> and C<dist_version_from> will
+default to C<lib/Foo/Bar.pm>. C<dist_version_from> will in turn be
+used to set C<dist_version>.
+
+Setting C<module_name> won't override a C<dist_*> parameter you
+specify explicitly.
+
+=item PL_files
+
+An optional parameter specifying a set of C<.PL> files in your
+distribution. These will be run as Perl scripts prior to processing
+the rest of the files in your distribution. They are usually used as
+templates for creating other files dynamically, so that a file like
+C<lib/Foo/Bar.pm.PL> might create the file C<lib/Foo/Bar.pm>.
+
+The files are specified with the C<.PL> files as hash keys, and the
+file(s) they generate as hash values, like so:
+
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ ...
+ PL_files => { 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm' },
+ );
+
+Note that the path specifications are I<always> given in Unix-like
+format, not in the style of the local system.
+
+If your C<.PL> scripts don't create any files, or if they create files
+with unexpected names, or even if they create multiple files, you can
+indicate that so that Module::Build can properly handle these created
+files:
+
+ PL_files => {
+ 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm',
+ 'lib/something.PL' => ['/lib/something', '/lib/else'],
+ 'lib/funny.PL' => [],
+ }
+
+=item pm_files
+
+An optional parameter specifying the set of C<.pm> files in this
+distribution, specified as a hash reference whose keys are the files'
+locations in the distributions, and whose values are their logical
+locations based on their package name, i.e. where they would be found
+in a "normal" Module::Build-style distribution. This parameter is
+mainly intended to support alternative layouts of files.
+
+For instance, if you have an old-style MakeMaker distribution for a
+module called C<Foo::Bar> and a F<Bar.pm> file at the top level of the
+distribution, you could specify your layout in your C<Build.PL> like
+this:
+
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ ...
+ pm_files => { 'Bar.pm' => 'lib/Foo/Bar.pm' },
+ );
+
+Note that the values should include C<lib/>, because this is where
+they would be found in a "normal" Module::Build-style distribution.
+
+Note also that the path specifications are I<always> given in
+Unix-like format, not in the style of the local system.
+
+=item pod_files
+
+Just like C<pm_files>, but used for specifying the set of C<.pod>
+files in your distribution.
+
+=item recommends
+
+This is just like the C<requires> argument, except that modules listed
+in this section aren't essential, just a good idea. We'll just print
+a friendly warning if one of these modules aren't found, but we'll
+continue running.
+
+If a module is recommended but not required, all tests should still
+pass if the module isn't installed. This may mean that some tests
+may be skipped if recommended dependencies aren't present.
+
+Automated tools like CPAN.pm should inform the user when recommended
+modules aren't installed, and it should offer to install them if it
+wants to be helpful.
+
+See the documentation for L<"PREREQUISITES"> for the details of how
+requirements can be specified.
+
+=item requires
+
+An optional C<requires> argument specifies any module prerequisites
+that the current module depends on.
+
+One note: currently C<Module::Build> doesn't actually I<require> the
+user to have dependencies installed, it just strongly urges. In the
+future we may require it. There's also a C<recommends> section for
+things that aren't absolutely required.
+
+Automated tools like CPAN.pm should refuse to install a module if one
+of its dependencies isn't satisfied, unless a "force" command is given
+by the user. If the tools are helpful, they should also offer to
+install the dependencies.
+
+A synonym for C<requires> is C<prereq>, to help succour people
+transitioning from C<ExtUtils::MakeMaker>. The C<requires> term is
+preferred, but the C<prereq> term will remain valid in future
+distributions.
+
+See the documentation for L<"PREREQUISITES"> for the details of how
+requirements can be specified.
+
+=item script_files
+
+An optional parameter specifying a set of files that should be
+installed as executable perl scripts when the module is installed.
+May be given as an array reference of the files, or as a hash
+reference whose keys are the files (and whose values will currently be
+ignored).
+
+The default is to install no script files - in other words, there is
+no default location where Module::Build will look for script files to
+install.
+
+For backward compatibility, you may use the parameter C<scripts>
+instead of C<script_files>. Please consider this usage deprecated,
+though it will continue to exist for several version releases.
+
+=item sign
+
+If a true value is specified for this parameter, C<Module::Signature>
+will be used (via the 'distsign' action) to create a SIGNATURE file
+for your distribution during the 'distdir' action, and to add the
+SIGNATURE file to the MANIFEST (therefore, don't add it yourself).
+
+The default value is false. In the future, the default may change to
+true if you have C<Module::Signature> installed on your system.
+
+=item test_files
+
+An optional parameter specifying a set of files that should be used as
+C<Test::Harness>-style regression tests to be run during the C<test>
+action. May be given as an array reference of the files, or as a hash
+reference whose keys are the files (and whose values will currently be
+ignored). If the argument is given as a single string (not in an
+array reference), that string will be treated as a C<glob()> pattern
+specifying the files to use.
+
+The default is to look for a F<test.pl> script in the top-level
+directory of the distribution, and any files matching the glob pattern
+C<*.t> in the F<t/> subdirectory. If the C<recursive_test_files>
+property is true, then the C<t/> directory will be scanned recursively
+for C<*.t> files.
+
+=item xs_files
+
+Just like C<pm_files>, but used for specifying the set of C<.xs>
+files in your distribution.
+
+=back
+
+
+=item new_from_context(%args)
+
+When called from a directory containing a F<Build.PL> script and a
+F<META.yml> file (in other words, the base directory of a
+distribution), this method will run the F<Build.PL> and return the
+resulting C<Module::Build> object to the caller. Any key-value
+arguments given to C<new_from_context()> are essentially like
+command line arguments given to the F<Build.PL> script, so for example
+you could pass C<< verbose => 1 >> to this method to turn on
+verbosity.
+
+=item resume()
+
+You'll probably never call this method directly, it's only called from
+the auto-generated C<Build> script. The C<new()> method is only
+called once, when the user runs C<perl Build.PL>. Thereafter, when
+the user runs C<Build test> or another action, the C<Module::Build>
+object is created using the C<resume()> method to re-instantiate with
+the settings given earlier to C<new()>.
+
+=item subclass()
+
+This creates a new C<Module::Build> subclass on the fly, as described
+in the L<"SUBCLASSING"> section. The caller must provide either a
+C<class> or C<code> parameter, or both. The C<class> parameter
+indicates the name to use for the new subclass, and defaults to
+C<MyModuleBuilder>. The C<code> parameter specifies Perl code to use
+as the body of the subclass.
+
+=back
+
+
+=head2 METHODS
+
+
+=over 4
+
+=item add_build_element($type)
+
+Adds a new type of entry to the build process. Accepts a single
+string specifying its type-name. There must also be a method defined
+to process things of that type, e.g. if you add a build element called
+C<'foo'>, then you must also define a method called
+C<process_foo_files()>.
+
+See also L<Module::Build::Cookbook/"Adding new file types to the build process">.
+
+=item add_to_cleanup(@files)
+
+You may call C<< $self->add_to_cleanup(@patterns) >> to tell
+C<Module::Build> that certain files should be removed when the user
+performs the C<Build clean> action. The arguments to the method are
+patterns suitable for passing to Perl's C<glob()> function, specified
+in either Unix format or the current machine's native format. It's
+usually convenient to use Unix format when you hard-code the filenames
+(e.g. in F<Build.PL>) and the native format when the names are
+programmatically generated (e.g. in a testing script).
+
+I decided to provide a dynamic method of the C<$build> object, rather
+than just use a static list of files named in the F<Build.PL>, because
+these static lists can get difficult to manage. I usually prefer to
+keep the responsibility for registering temporary files close to the
+code that creates them.
+
+=item args()
+
+ my $args_href = $build->args;
+ my %args = $build->args;
+ my $arg_value = $build->args($key);
+ $build->args($key, $value);
+
+This method is the preferred interface for retrieving the arguments passed via
+command line options to F<Build.PL> or F<Build>, minus the Module-Build
+specific options.
+
+When called in in a scalar context with no arguments, this method returns a
+reference to the hash storing all of the arguments; in an array context, it
+returns the hash itself. When passed a single argument, it returns the value
+stored in the args hash for that option key. When called with two arguments,
+the second argument is assigned to the args hash under the key passed as the
+first argument.
+
+=item autosplit_file($from, $to)
+
+Invokes the C<AutoSplit> module on the C<$from> file, sending the
+output to the C<lib/auto> directory inside C<$to>. C<$to> is
+typically the C<blib/> directory.
+
+=item base_dir()
+
+Returns a string containing the root-level directory of this build,
+i.e. where the C<Build.PL> script and the C<lib> directory can be
+found. This is usually the same as the current working directory,
+because the C<Build> script will C<chdir()> into this directory as
+soon as it begins execution.
+
+=item build_requires()
+
+Returns a hash reference indicating the C<build_requires>
+prerequisites that were passed to the C<new()> method.
+
+=item check_installed_status($module, $version)
+
+This method returns a hash reference indicating whether a version
+dependency on a certain module is satisfied. The C<$module> argument
+is given as a string like C<"Data::Dumper"> or C<"perl">, and the
+C<$version> argument can take any of the forms described in L<requires>
+above. This allows very fine-grained version checking.
+
+The returned hash reference has the following structure:
+
+ {
+ ok => $whether_the_dependency_is_satisfied,
+ have => $version_already_installed,
+ need => $version_requested, # Same as incoming $version argument
+ message => $informative_error_message,
+ }
+
+If no version of C<$module> is currently installed, the C<have> value
+will be the string C<< "<none>" >>. Otherwise the C<have> value will
+simply be the version of the installed module. Note that this means
+that if C<$module> is installed but doesn't define a version number,
+the C<have> value will be C<undef> - this is why we don't use C<undef>
+for the case when C<$module> isn't installed at all.
+
+This method may be called either as an object method
+(C<< $build->check_installed_status($module, $version) >>)
+or as a class method
+(C<< Module::Build->check_installed_status($module, $version) >>).
+
+=item check_installed_version($module, $version)
+
+Like C<check_installed_status()>, but simply returns true or false
+depending on whether module C<$module> satisfies the dependency
+C<$version>.
+
+If the check succeeds, the return value is the actual version of
+C<$module> installed on the system. This allows you to do the
+following:
+
+ my $installed = $build->check_installed_version('DBI', '1.15');
+ if ($installed) {
+ print "Congratulations, version $installed of DBI is installed.\n";
+ } else {
+ die "Sorry, you must install DBI.\n";
+ }
+
+If the check fails, we return false and set C<$@> to an informative
+error message.
+
+If C<$version> is any non-true value (notably zero) and any version of
+C<$module> is installed, we return true. In this case, if C<$module>
+doesn't define a version, or if its version is zero, we return the
+special value "0 but true", which is numerically zero, but logically
+true.
+
+In general you might prefer to use C<check_installed_status> if you
+need detailed information, or this method if you just need a yes/no
+answer.
+
+=item compare_versions($v1, $op, $v2)
+
+Compares two module versions C<$v1> and C<$v2> using the operator
+C<$op>, which should be one of Perl's numeric operators like C<!=> or
+C<< >= >> or the like. We do at least a halfway-decent job of
+handling versions that aren't strictly numeric, like C<0.27_02>, but
+exotic stuff will likely cause problems.
+
+In the future, the guts of this method might be replaced with a call
+out to C<version.pm>.
+
+=item config()
+
+Returns a hash reference containing the C<Config.pm> hash, including
+any changes the author or user has specified. This is a reference to
+the actual internal hash we use, so you probably shouldn't modify
+stuff there.
+
+=item config_data($name)
+
+=item config_data($name => $value)
+
+With a single argument, returns the value of the configuration
+variable C<$name>. With two arguments, sets the given configuration
+variable to the given value. The value may be any perl scalar that's
+serializable with C<Data::Dumper>. For instance, if you write a
+module that can use a MySQL or PostgreSQL back-end, you might create
+configuration variables called C<mysql_connect> and
+C<postgres_connect>, and set each to an array of connection parameters
+for C<< DBI->connect() >>.
+
+Configuration values set in this way using the Module::Build object
+will be available for querying during the build/test process and after
+installation via the generated C<...::ConfigData> module, as
+C<< ...::ConfigData->config($name) >>.
+
+The C<feature()> and C<config_data()> methods represent
+Module::Build's main support for configuration of installed modules.
+See also L<SAVING CONFIGURATION INFORMATION>.
+
+=item conflicts()
+
+Returns a hash reference indicating the C<conflicts> prerequisites
+that were passed to the C<new()> method.
+
+=item contains_pod($file)
+
+[Deprecated] Please see L<Module::Build::ModuleInfo> instead.
+
+Returns true if the given file appears to contain POD documentation.
+Currently this checks whether the file has a line beginning with
+'=pod', '=head', or '=item', but the exact semantics may change in the
+future.
+
+=item copy_if_modified(%parameters)
+
+Takes the file in the C<from> parameter and copies it to the file in
+the C<to> parameter, or the directory in the C<to_dir> parameter, if
+the file has changed since it was last copied (or if it doesn't exist
+in the new location). By default the entire directory structure of
+C<from> will be copied into C<to_dir>; an optional C<flatten>
+parameter will copy into C<to_dir> without doing so.
+
+Returns the path to the destination file, or C<undef> if nothing
+needed to be copied.
+
+Any directories that need to be created in order to perform the
+copying will be automatically created.
+
+=item create_build_script()
+
+Creates an executable script called C<Build> in the current directory
+that will be used to execute further user actions. This script is
+roughly analogous (in function, not in form) to the Makefile created
+by C<ExtUtils::MakeMaker>. This method also creates some temporary
+data in a directory called C<_build/>. Both of these will be removed
+when the C<realclean> action is performed.
+
+=item current_action()
+
+Returns the name of the currently-running action, such as "build" or
+"test". This action is not necessarily the action that was originally
+invoked by the user. For example, if the user invoked the "test"
+action, current_action() would initially return "test". However,
+action "test" depends on action "code", so current_action() will
+return "code" while that dependency is being executed. Once that
+action has completed, current_action() will again return "test".
+
+If you need to know the name of the original action invoked by the
+user, see L<invoked_action()> below.
+
+=item depends_on(@actions)
+
+Invokes the named action or list of actions in sequence. Using this
+method is preferred to calling the action explicitly because it
+performs some internal record-keeping, and it ensures that the same
+action is not invoked multiple times (note: in future versions of
+Module::Build it's conceivable that this run-only-once mechanism will
+be changed to something more intelligent).
+
+Note that the name of this method is something of a misnomer; it
+should really be called something like
+C<invoke_actions_unless_already_invoked()> or something, but for
+better or worse (perhaps better!) we were still thinking in
+C<make>-like dependency terms when we created this method.
+
+See also C<dispatch()>. The main distinction between the two is that
+C<depends_on()> is meant to call an action from inside another action,
+whereas C<dispatch()> is meant to set the very top action in motion.
+
+=item dir_contains($first_dir, $second_dir)
+
+Returns true if the first directory logically contains the second
+directory. This is just a convenience function because C<File::Spec>
+doesn't really provide an easy way to figure this out (but
+C<Path::Class> does...).
+
+=item dispatch($action, %args)
+
+Invokes the build action C<$action>. Optionally, a list of options
+and their values can be passed in. This is equivalent to invoking an
+action at the command line, passing in a list of options.
+
+Custom options that have not been registered must be passed in as a
+hash reference in a key named "args":
+
+ $build->dispatch('foo', verbose => 1, args => { my_option => 'value' });
+
+This method is intended to be used to programmatically invoke build
+actions, e.g. by applications controlling Module::Build-based builds
+rather than by subclasses.
+
+See also C<depends_on()>. The main distinction between the two is that
+C<depends_on()> is meant to call an action from inside another action,
+whereas C<dispatch()> is meant to set the very top action in motion.
+
+=item dist_dir()
+
+Returns the name of the directory that will be created during the
+C<dist> action. The name is derived from the C<dist_name> and
+C<dist_version> properties.
+
+=item dist_name()
+
+Returns the name of the current distribution, as passed to the
+C<new()> method in a C<dist_name> or modified C<module_name>
+parameter.
+
+=item dist_version()
+
+Returns the version of the current distribution, as determined by the
+C<new()> method from a C<dist_version>, C<dist_version_from>, or
+C<module_name> parameter.
+
+=item do_system($cmd, @args)
+
+This is a fairly simple wrapper around Perl's C<system()> built-in
+command. Given a command and an array of optional arguments, this
+method will print the command to C<STDOUT>, and then execute it using
+Perl's C<system()>. It returns true or false to indicate success or
+failure (the opposite of how C<system()> works, but more intuitive).
+
+Note that if you supply a single argument to C<do_system()>, it
+will/may be processed by the systems's shell, and any special
+characters will do their special things. If you supply multiple
+arguments, no shell will get involved and the command will be executed
+directly.
+
+=item feature($name)
+
+=item feature($name => $value)
+
+With a single argument, returns true if the given feature is set.
+With two arguments, sets the given feature to the given boolean value.
+In this context, a "feature" is any optional functionality of an
+installed module. For instance, if you write a module that could
+optionally support a MySQL or PostgreSQL backend, you might create
+features called C<mysql_support> and C<postgres_support>, and set them
+to true/false depending on whether the user has the proper databases
+installed and configured.
+
+Features set in this way using the Module::Build object will be
+available for querying during the build/test process and after
+installation via the generated C<...::ConfigData> module, as
+C<< ...::ConfigData->feature($name) >>.
+
+The C<feature()> and C<config_data()> methods represent
+Module::Build's main support for configuration of installed modules.
+See also L<SAVING CONFIGURATION INFORMATION>.
+
+=item have_c_compiler()
+
+Returns true if the current system seems to have a working C compiler.
+We currently determine this by attempting to compile a simple C source
+file and reporting whether the attempt was successful.
+
+=item install_destination($type)
+
+Returns the directory in which items of type C<$type> (e.g. C<lib>,
+C<arch>, C<bin>, or anything else returned by the C<install_types()>
+method) will be installed during the C<install> action. Any settings
+for C<install_path>, C<install_base>, and C<prefix> are taken into
+account when determining the return value.
+
+=item install_types()
+
+Returns a list of installable types that this build knows about.
+These types each correspond to the name of a directory in F<blib/>,
+and the list usually includes items such as C<lib>, C<arch>, C<bin>,
+C<script>, C<libdoc>, C<bindoc>, and if HTML documentation is to be
+built, C<libhtml> and C<binhtml>. Other user-defined types may also
+exist.
+
+=item invoked_action()
+
+This is the name of the original action invoked by the user. This
+value is set when the user invokes F<Build.PL>, the F<Build> script,
+or programatically through the L<dispatch()> method. It does not
+change as sub-actions are executed as dependencies are evaluated.
+
+To get the name of the currently executing dependency, see
+L<current_action()> above.
+
+=item notes()
+
+=item notes($key)
+
+=item notes($key => $value)
+
+The C<notes()> value allows you to store your own persistent
+information about the build, and to share that information among
+different entities involved in the build. See the example in the
+C<current()> method.
+
+The C<notes()> method is essentally a glorified hash access. With no
+arguments, C<notes()> returns the entire hash of notes. With one argument,
+C<notes($key)> returns the value associated with the given key. With two
+arguments, C<notes($key, $value)> sets the value associated with the given key
+to C<$value> and returns the new value.
+
+The lifetime of the C<notes> data is for "a build" - that is, the
+C<notes> hash is created when C<perl Build.PL> is run (or when the
+C<new()> method is run, if the Module::Build Perl API is being used
+instead of called from a shell), and lasts until C<perl Build.PL> is
+run again or the C<clean> action is run.
+
+=item orig_dir()
+
+Returns a string containing the working directory that was in effect
+before the F<Build> script chdir()-ed into the C<base_dir>. This
+might be useful for writing wrapper tools that might need to chdir()
+back out.
+
+=item rscan_dir($dir, $pattern)
+
+Uses C<File::Find> to traverse the directory C<$dir>, returning a
+reference to an array of entries matching C<$pattern>. C<$pattern>
+may either be a regular expression (using C<qr//> or just a plain
+string), or a reference to a subroutine that will return true for
+wanted entries. If C<$pattern> is not given, all entries will be
+returned.
+
+Examples:
+
+ # All the *.pm files in lib/
+ $m->rscan_dir('lib', qr/\.pm$/)
+
+ # All the files in blib/ that aren't *.html files
+ $m->rscan_dir('blib', sub {-f $_ and not /\.html$/});
+
+ # All the files in t/
+ $m->rscan_dir('t');
+
+=item runtime_params()
+
+=item runtime_params($key)
+
+The C<runtime_params()> method stores the values passed on the command line
+for valid properties (that is, any command line options for which
+C<valid_property()> returns a true value). The value on the command line may
+override the default value for a property, as well as any value specified in a
+call to C<new()>. This allows you to programmatically tell if C<perl Build.PL>
+or any execution of C<./Build> had command line options specified that
+override valid properties.
+
+The C<runtime_params()> method is essentally a glorified read-only hash. With
+no arguments, C<runtime_params()> returns the entire hash of properties
+specified on the command line. With one argument, C<runtime_params($key)>
+returns the value associated with the given key.
+
+The lifetime of the C<runtime_params> data is for "a build" - that is, the
+C<runtime_params> hash is created when C<perl Build.PL> is run (or when the
+C<new()> method is called, if the Module::Build Perl API is being used instead
+of called from a shell), and lasts until C<perl Build.PL> is run again or the
+C<clean> action is run.
+
+=item os_type()
+
+If you're subclassing Module::Build and some code needs to alter its
+behavior based on the current platform, you may only need to know
+whether you're running on Windows, Unix, MacOS, VMS, etc., and not the
+fine-grained value of Perl's C<$^O> variable. The C<os_type()> method
+will return a string like C<Windows>, C<Unix>, C<MacOS>, C<VMS>, or
+whatever is appropriate. If you're running on an unknown platform, it
+will return C<undef> - there shouldn't be many unknown platforms
+though.
+
+=item prepare_metadata()
+
+This method is provided for authors to override to customize the
+fields of F<META.yml>. It is passed a YAML::Node node object which can
+be modified as desired and then returned. E.g.
+
+ package My::Builder;
+ use base 'Module::Build';
+
+ sub prepare_metadata {
+ my $self = shift;
+ my $node = $self->SUPER::prepare_metadata( shift );
+ $node->{custom_field} = 'foo';
+ return $node;
+ }
+
+=item prereq_failures()
+
+Returns a data structure containing information about any failed
+prerequisites (of any of the types described above), or C<undef> if
+all prerequisites are met.
+
+The data structure returned is a hash reference. The top level keys
+are the type of prerequisite failed, one of "requires",
+"build_requires", "conflicts", or "recommends". The associated values
+are hash references whose keys are the names of required (or
+conflicting) modules. The associated values of those are hash
+references indicating some information about the failure. For example:
+
+ {
+ have => '0.42',
+ need => '0.59',
+ message => 'Version 0.42 is installed, but we need version 0.59',
+ }
+
+or
+
+ {
+ have => '<none>',
+ need => '0.59',
+ message => 'Prerequisite Foo isn't installed',
+ }
+
+This hash has the same structure as the hash returned by the
+C<check_installed_status()> method, except that in the case of
+"conflicts" dependencies we change the "need" key to "conflicts" and
+construct a proper message.
+
+Examples:
+
+ # Check a required dependency on Foo::Bar
+ if ( $build->prereq_failures->{requires}{Foo::Bar} ) { ...
+
+ # Check whether there were any failures
+ if ( $build->prereq_failures ) { ...
+
+ # Show messages for all failures
+ my $failures = $build->prereq_failures;
+ while (my ($type, $list) = each %$failures) {
+ while (my ($name, $hash) = each %$list) {
+ print "Failure for $name: $hash->{message}\n";
+ }
+ }
+
+=item prereq_report()
+
+Returns a human-readable (table-form) string showing 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 for a bug
+report. The C<prereq_report> action is just a thin wrapper around the
+C<prereq_report()> method.
+
+=item prompt($message, $default)
+
+Asks the user a question and returns their response as a string. The
+first argument specifies the message to display to the user (for
+example, C<"Where do you keep your money?">). The second argument,
+which is optional, specifies a default answer (for example,
+C<"wallet">). The user will be asked the question once.
+
+If C<prompt()> detects that it is not running interactively and there
+is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
+is set to true, the $default will be used without prompting. This
+prevents automated processes from blocking on user input.
+
+If no $default is provided an empty string will be used instead.
+
+This method may be called as a class or object method.
+
+=item recommends()
+
+Returns a hash reference indicating the C<recommends> prerequisites
+that were passed to the C<new()> method.
+
+=item requires()
+
+Returns a hash reference indicating the C<requires> prerequisites that
+were passed to the C<new()> method.
+
+=item script_files()
+
+Returns a hash reference whose keys are the perl script files to be
+installed, if any. This corresponds to the C<script_files> parameter to the
+C<new()> method. With an optional argument, this parameter may be set
+dynamically.
+
+For backward compatibility, the C<scripts()> method does exactly the
+same thing as C<script_files()>. C<scripts()> is deprecated, but it
+will stay around for several versions to give people time to
+transition.
+
+=item up_to_date($source_file, $derived_file)
+
+=item up_to_date(\@source_files, \@derived_files)
+
+This method can be used to compare a set of source files to a set of
+derived files. If any of the source files are newer than any of the
+derived files, it returns false. Additionally, if any of the derived
+files do not exist, it returns false. Otherwise it returns true.
+
+The arguments may be either a scalar or an array reference of file
+names.
+
+=item y_n($message, $default)
+
+Asks the user a yes/no question using C<prompt()> and returns true or
+false accordingly. The user will be asked the question repeatedly
+until they give an answer that looks like "yes" or "no".
+
+The first argument specifies the message to display to the user (for
+example, C<"Shall I invest your money for you?">), and the second
+argument specifies the default answer (for example, C<"y">).
+
+Note that the default is specified as a string like C<"y"> or C<"n">,
+and the return value is a Perl boolean value like 1 or 0. I thought
+about this for a while and this seemed like the most useful way to do
+it.
+
+This method may be called as a class or object method.
+
+=back
+
+
+=head2 Autogenerated Accessors
+
+In addition to the aforementioned methods, there are also some get/set
+accessor methods for the following properties:
+
+=over 4
+
+=item PL_files()
+
+=item autosplit()
+
+=item base_dir()
+
+=item bindoc_dirs()
+
+=item blib()
+
+=item build_bat()
+
+=item build_class()
+
+=item build_elements()
+
+=item build_requires()
+
+=item build_script()
+
+=item c_source()
+
+=item config()
+
+=item config_dir()
+
+=item conflicts()
+
+=item create_makefile_pl()
+
+=item create_readme()
+
+=item debugger()
+
+=item destdir()
+
+=item dist_version_from()
+
+=item get_options()
+
+=item html_css()
+
+=item include_dirs()
+
+=item install_base()
+
+=item install_path()
+
+=item install_sets()
+
+=item installdirs()
+
+=item libdoc_dirs()
+
+=item license()
+
+=item magic_number()
+
+=item mb_version()
+
+=item meta_add()
+
+=item meta_merge()
+
+=item metafile()
+
+=item module_name()
+
+=item orig_dir()
+
+=item original_prefix()
+
+=item perl()
+
+=item pm_files()
+
+=item pod_files()
+
+=item pollute()
+
+=item prefix()
+
+=item prereq_action_types()
+
+=item quiet()
+
+=item recommends()
+
+=item recurse_into()
+
+=item recursive_test_files()
+
+=item requires()
+
+=item scripts()
+
+=item use_rcfile()
+
+=item verbose()
+
+=item xs_files()
+
+=back
+
+
+=head1 PREREQUISITES
+
+There are three basic types of prerequisites that can be defined: 1)
+"requires" - are versions of modules that are required for certain
+functionality to be available; 2) "recommends" - are versions of
+modules that are recommended to provide enhanced functionality; and 3)
+"conflicts" - are versions of modules that conflict with, and that can
+cause problems with the distribution.
+
+Each of the three types of prerequisites listed above can be applied
+to different aspects of the Build process. For the module distribution
+itself you simply define "requires", "recommends", or "conflicts". The
+types can also apply to other aspects of the Build process. Currently,
+only "build_requires" is defined which is used for modules which are
+required during the Build process.
+
+
+=head2 Format of prerequisites
+
+The prerequisites are given in a hash reference, where the keys are
+the module names and the values are version specifiers:
+
+ requires => {
+ Foo::Module => '2.4',
+ Bar::Module => 0,
+ Ken::Module => '>= 1.2, != 1.5, < 2.0',
+ perl => '5.6.0'
+ },
+
+These four version specifiers have different effects. The value
+C<'2.4'> means that B<at least> version 2.4 of C<Foo::Module> must be
+installed. The value C<0> means that B<any> version of C<Bar::Module>
+is acceptable, even if C<Bar::Module> doesn't define a version. The
+more verbose value C<'E<gt>= 1.2, != 1.5, E<lt> 2.0'> means that
+C<Ken::Module>'s version must be B<at least> 1.2, B<less than> 2.0,
+and B<not equal to> 1.5. The list of criteria is separated by commas,
+and all criteria must be satisfied.
+
+A special C<perl> entry lets you specify the versions of the Perl
+interpreter that are supported by your module. The same version
+dependency-checking semantics are available, except that we also
+understand perl's new double-dotted version numbers.
+
+
+=head1 SAVING CONFIGURATION INFORMATION
+
+Module::Build provides a very convenient way to save configuration
+information that your installed modules (or your regression tests) can
+access. If your Build process calls the C<feature()> or
+C<config_data()> methods, then a C<Foo::Bar::ConfigData> module will
+automatically be created for you, where C<Foo::Bar> is the
+C<module_name> parameter as passed to C<new()>. This module provides
+access to the data saved by these methods, and a way to update the
+values. There is also a utility script called C<config_data>
+distributed with Module::Build that provides a command line interface
+to this same functionality. See also the generated
+C<Foo::Bar::ConfigData> documentation, and the C<config_data>
+script's documentation, for more information.
+
+
+=head1 AUTOMATION
+
+One advantage of Module::Build is that since it's implemented as Perl
+methods, you can invoke these methods directly if you want to install
+a module non-interactively. For instance, the following Perl script
+will invoke the entire build/install procedure:
+
+ my $build = Module::Build->new(module_name => 'MyModule');
+ $build->dispatch('build');
+ $build->dispatch('test');
+ $build->dispatch('install');
+
+If any of these steps encounters an error, it will throw a fatal
+exception.
+
+You can also pass arguments as part of the build process:
+
+ my $build = Module::Build->new(module_name => 'MyModule');
+ $build->dispatch('build');
+ $build->dispatch('test', verbose => 1);
+ $build->dispatch('install', sitelib => '/my/secret/place/');
+
+Building and installing modules in this way skips creating the
+C<Build> script.
+
+
+=head1 STRUCTURE
+
+Module::Build creates a class hierarchy conducive to customization.
+Here is the parent-child class hierarchy in classy ASCII art:
+
+ /--------------------\
+ | Your::Parent | (If you subclass Module::Build)
+ \--------------------/
+ |
+ |
+ /--------------------\ (Doesn't define any functionality
+ | Module::Build | of its own - just figures out what
+ \--------------------/ other modules to load.)
+ |
+ |
+ /-----------------------------------\ (Some values of $^O may
+ | Module::Build::Platform::$^O | define specialized functionality.
+ \-----------------------------------/ Otherwise it's ...::Default, a
+ | pass-through class.)
+ |
+ /--------------------------\
+ | Module::Build::Base | (Most of the functionality of
+ \--------------------------/ Module::Build is defined here.)
+
+
+=head1 SUBCLASSING
+
+Right now, there are two ways to subclass Module::Build. The first
+way is to create a regular module (in a C<.pm> file) that inherits
+from Module::Build, and use that module's class instead of using
+Module::Build directly:
+
+ ------ in Build.PL: ----------
+ #!/usr/bin/perl
+
+ use lib q(/nonstandard/library/path);
+ use My::Builder; # Or whatever you want to call it
+
+ my $build = My::Builder->new
+ (
+ module_name => 'Foo::Bar', # All the regular args...
+ license => 'perl',
+ dist_author => 'A N Other <me@here.net.au>',
+ requires => { Carp => 0 }
+ );
+ $build->create_build_script;
+
+This is relatively straightforward, and is the best way to do things
+if your My::Builder class contains lots of code. The
+C<create_build_script()> method will ensure that the current value of
+C<@INC> (including the C</nonstandard/library/path>) is propogated to
+the Build script, so that My::Builder can be found when running build
+actions.
+
+For very small additions, Module::Build provides a C<subclass()>
+method that lets you subclass Module::Build more conveniently, without
+creating a separate file for your module:
+
+ ------ in Build.PL: ----------
+ #!/usr/bin/perl
+
+ use Module::Build;
+ my $class = Module::Build->subclass
+ (
+ class => 'My::Builder',
+ code => q{
+ sub ACTION_foo {
+ print "I'm fooing to death!\n";
+ }
+ },
+ );
+
+ my $build = $class->new
+ (
+ module_name => 'Foo::Bar', # All the regular args...
+ license => 'perl',
+ dist_author => 'A N Other <me@here.net.au>',
+ requires => { Carp => 0 }
+ );
+ $build->create_build_script;
+
+Behind the scenes, this actually does create a C<.pm> file, since the
+code you provide must persist after Build.PL is run if it is to be
+very useful.
+
+See also the documentation for the C<subclass()> method.
+
+
+=head1 STARTING MODULE DEVELOPMENT
+
+When starting development on a new module, it's rarely worth your time
+to create a tree of all the files by hand. Some automatic
+module-creators are available: the oldest is C<h2xs>, which has
+shipped with perl itself for a long time. Its name reflects the fact
+that modules were originally conceived of as a way to wrap up a C
+library (thus the C<h> part) into perl extensions (thus the C<xs>
+part).
+
+These days, C<h2xs> has largely been superseded by modules like
+C<ExtUtils::ModuleMaker>, C<Module::Starter>, and C<Module::Maker>.
+They have varying degrees of support for C<Module::Build>.
+
+
+=head1 MIGRATION
+
+Note that if you want to provide both a F<Makefile.PL> and a
+F<Build.PL> for your distribution, you probably want to add the
+following to C<WriteMakefile> in your F<Makefile.PL> so that MakeMaker
+doesn't try to run your F<Build.PL> as a normal F<.PL> file:
+
+ PL_FILES => {},
+
+You may also be interested in looking at the C<Module::Build::Compat>
+module, which can automatically create various kinds of F<Makefile.PL>
+compatibility layers.
+
+
+=head1 AUTHOR
+
+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 .
+
+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.
+
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), Module::Build::Cookbook(3),
+ExtUtils::MakeMaker(3), YAML(3)
+
+F<META.yml> Specification:
+L<http://module-build.sourceforge.net/META-spec-v1.2.html>
+
+L<http://www.dsmit.com/cons/>
+
+=cut
--- /dev/null
+package Module::Build::Base;
+
+use strict;
+BEGIN { require 5.00503 }
+use Config;
+use File::Copy ();
+use File::Find ();
+use File::Path ();
+use File::Basename ();
+use File::Spec 0.82 ();
+use File::Compare ();
+use Data::Dumper ();
+use IO::File ();
+use Text::ParseWords ();
+use Carp ();
+
+use Module::Build::ModuleInfo;
+use Module::Build::Notes;
+
+
+#################### Constructors ###########################
+sub new {
+ my $self = shift()->_construct(@_);
+
+ $self->{invoked_action} = $self->{action} ||= 'Build_PL';
+ $self->cull_args(@ARGV);
+
+ die "Too early to specify a build action '$self->{action}'. Do 'Build $self->{action}' instead.\n"
+ if $self->{action} && $self->{action} ne 'Build_PL';
+
+ $self->dist_name;
+ $self->dist_version;
+
+ $self->check_manifest;
+ $self->check_prereq;
+ $self->check_autofeatures;
+
+ $self->_set_install_paths;
+ $self->_find_nested_builds;
+
+ return $self;
+}
+
+sub resume {
+ my $package = shift;
+ my $self = $package->_construct(@_);
+ $self->read_config;
+
+ # If someone called Module::Build->current() or
+ # Module::Build->new_from_context() and the correct class to use is
+ # actually a *subclass* of Module::Build, we may need to load that
+ # subclass here and re-delegate the resume() method to it.
+ unless ( UNIVERSAL::isa($package, $self->build_class) ) {
+ my $build_class = $self->build_class;
+ my $config_dir = $self->config_dir || '_build';
+ my $build_lib = File::Spec->catdir( $config_dir, 'lib' );
+ unshift( @INC, $build_lib );
+ unless ( $build_class->can('new') ) {
+ eval "require $build_class; 1" or die "Failed to re-load '$build_class': $@";
+ }
+ return $build_class->resume(@_);
+ }
+
+ unless ($self->_perl_is_same($self->{properties}{perl})) {
+ my $perl = $self->find_perl_interpreter;
+ $self->log_warn(" * WARNING: Configuration was initially created with '$self->{properties}{perl}',\n".
+ " but we are now using '$perl'.\n");
+ }
+
+ my $mb_version = $Module::Build::VERSION;
+ die(" * ERROR: Configuration was initially created with Module::Build version '$self->{properties}{mb_version}',\n".
+ " but we are now using version '$mb_version'. Please re-run the Build.PL or Makefile.PL script.\n")
+ unless $mb_version eq $self->{properties}{mb_version};
+
+ $self->cull_args(@ARGV);
+ $self->{invoked_action} = $self->{action} ||= 'build';
+
+ return $self;
+}
+
+sub new_from_context {
+ my ($package, %args) = @_;
+
+ # XXX Read the META.yml and see whether we need to run the Build.PL?
+
+ # Run the Build.PL. We use do() rather than run_perl_script() so
+ # that it runs in this process rather than a subprocess, because we
+ # need to make sure that the environment is the same during Build.PL
+ # as it is during resume() (and thereafter).
+ {
+ local @ARGV = $package->unparse_args(\%args);
+ do 'Build.PL';
+ die $@ if $@;
+ }
+ return $package->resume;
+}
+
+sub current {
+ # hmm, wonder what the right thing to do here is
+ local @ARGV;
+ return shift()->resume;
+}
+
+sub _construct {
+ my ($package, %input) = @_;
+
+ my $args = delete $input{args} || {};
+ my $config = delete $input{config} || {};
+
+ my $self = bless {
+ args => {%$args},
+ config => {%Config, %$config},
+ properties => {
+ base_dir => $package->cwd,
+ mb_version => $Module::Build::VERSION,
+ %input,
+ },
+ phash => {},
+ }, $package;
+
+ $self->_set_defaults;
+ my ($p, $c, $ph) = ($self->{properties}, $self->{config}, $self->{phash});
+
+ foreach (qw(notes config_data features runtime_params cleanup auto_features)) {
+ my $file = File::Spec->catfile($self->config_dir, $_);
+ $ph->{$_} = Module::Build::Notes->new(file => $file);
+ $ph->{$_}->restore if -e $file;
+ if (exists $p->{$_}) {
+ my $vals = delete $p->{$_};
+ while (my ($k, $v) = each %$vals) {
+ $self->$_($k, $v);
+ }
+ }
+ }
+
+ # The following warning could be unnecessary if the user is running
+ # an embedded perl, but there aren't too many of those around, and
+ # embedded perls aren't usually used to install modules, and the
+ # installation process sometimes needs to run external scripts
+ # (e.g. to run tests).
+ $p->{perl} = $self->find_perl_interpreter
+ or $self->log_warn("Warning: Can't locate your perl binary");
+
+ my $blibdir = sub { File::Spec->catdir($p->{blib}, @_) };
+ $p->{bindoc_dirs} ||= [ $blibdir->("script") ];
+ $p->{libdoc_dirs} ||= [ $blibdir->("lib"), $blibdir->("arch") ];
+
+ $p->{dist_author} = [ $p->{dist_author} ] if defined $p->{dist_author} and not ref $p->{dist_author};
+
+ # Synonyms
+ $p->{requires} = delete $p->{prereq} if defined $p->{prereq};
+ $p->{script_files} = delete $p->{scripts} if defined $p->{scripts};
+
+ # Convert to arrays
+ for ('extra_compiler_flags', 'extra_linker_flags') {
+ $p->{$_} = [ $self->split_like_shell($p->{$_}) ] if exists $p->{$_};
+ }
+
+ $self->add_to_cleanup( @{delete $p->{add_to_cleanup}} )
+ if $p->{add_to_cleanup};
+
+ return $self;
+}
+
+################## End constructors #########################
+
+sub log_info { print @_ unless shift()->quiet }
+sub log_verbose { shift()->log_info(@_) if $_[0]->verbose }
+sub log_warn {
+ # Try to make our call stack invisible
+ shift;
+ if (@_ and $_[-1] !~ /\n$/) {
+ my (undef, $file, $line) = caller();
+ warn @_, " at $file line $line.\n";
+ } else {
+ warn @_;
+ }
+}
+
+
+sub _set_install_paths {
+ my $self = shift;
+ my $c = $self->config;
+ my $p = $self->{properties};
+
+ my @libstyle = $c->{installstyle} ?
+ File::Spec->splitdir($c->{installstyle}) : qw(lib perl5);
+ my $arch = $c->{archname};
+ my $version = $c->{version};
+
+ my $bindoc = $c->{installman1dir} || undef;
+ my $libdoc = $c->{installman3dir} || undef;
+
+ my $binhtml = $c->{installhtml1dir} || $c->{installhtmldir} || undef;
+ my $libhtml = $c->{installhtml3dir} || $c->{installhtmldir} || undef;
+
+ $p->{install_sets} =
+ {
+ core => {
+ lib => $c->{installprivlib},
+ arch => $c->{installarchlib},
+ bin => $c->{installbin},
+ script => $c->{installscript},
+ bindoc => $bindoc,
+ libdoc => $libdoc,
+ binhtml => $binhtml,
+ libhtml => $libhtml,
+ },
+ site => {
+ lib => $c->{installsitelib},
+ arch => $c->{installsitearch},
+ bin => $c->{installsitebin} || $c->{installbin},
+ script => $c->{installsitescript} ||
+ $c->{installsitebin} || $c->{installscript},
+ bindoc => $c->{installsiteman1dir} || $bindoc,
+ libdoc => $c->{installsiteman3dir} || $libdoc,
+ binhtml => $c->{installsitehtml1dir} || $binhtml,
+ libhtml => $c->{installsitehtml3dir} || $libhtml,
+ },
+ vendor => {
+ lib => $c->{installvendorlib},
+ arch => $c->{installvendorarch},
+ bin => $c->{installvendorbin} || $c->{installbin},
+ script => $c->{installvendorscript} ||
+ $c->{installvendorbin} || $c->{installscript},
+ bindoc => $c->{installvendorman1dir} || $bindoc,
+ libdoc => $c->{installvendorman3dir} || $libdoc,
+ binhtml => $c->{installvendorhtml1dir} || $binhtml,
+ libhtml => $c->{installvendorhtml3dir} || $libhtml,
+ },
+ };
+
+ $p->{original_prefix} =
+ {
+ core => $c->{installprefixexp} || $c->{installprefix} ||
+ $c->{prefixexp} || $c->{prefix} || '',
+ site => $c->{siteprefixexp},
+ vendor => $c->{usevendorprefix} ? $c->{vendorprefixexp} : '',
+ };
+ $p->{original_prefix}{site} ||= $p->{original_prefix}{core};
+
+ # Note: you might be tempted to use $Config{installstyle} here
+ # instead of hard-coding lib/perl5, but that's been considered and
+ # (at least for now) rejected. `perldoc Config` has some wisdom
+ # about it.
+ $p->{install_base_relpaths} =
+ {
+ lib => ['lib', 'perl5'],
+ arch => ['lib', 'perl5', $arch],
+ bin => ['bin'],
+ script => ['bin'],
+ bindoc => ['man', 'man1'],
+ libdoc => ['man', 'man3'],
+ binhtml => ['html'],
+ libhtml => ['html'],
+ };
+
+ $p->{prefix_relpaths} =
+ {
+ core => {
+ lib => [@libstyle],
+ arch => [@libstyle, $version, $arch],
+ bin => ['bin'],
+ script => ['bin'],
+ bindoc => ['man', 'man1'],
+ libdoc => ['man', 'man3'],
+ binhtml => ['html'],
+ libhtml => ['html'],
+ },
+ vendor => {
+ lib => [@libstyle],
+ arch => [@libstyle, $version, $arch],
+ bin => ['bin'],
+ script => ['bin'],
+ bindoc => ['man', 'man1'],
+ libdoc => ['man', 'man3'],
+ binhtml => ['html'],
+ libhtml => ['html'],
+ },
+ site => {
+ lib => [@libstyle, 'site_perl'],
+ arch => [@libstyle, 'site_perl', $version, $arch],
+ bin => ['bin'],
+ script => ['bin'],
+ bindoc => ['man', 'man1'],
+ libdoc => ['man', 'man3'],
+ binhtml => ['html'],
+ libhtml => ['html'],
+ },
+ };
+
+}
+
+sub _find_nested_builds {
+ my $self = shift;
+ my $r = $self->recurse_into or return;
+
+ my ($file, @r);
+ if (!ref($r) && $r eq 'auto') {
+ local *DH;
+ opendir DH, $self->base_dir
+ or die "Can't scan directory " . $self->base_dir . " for nested builds: $!";
+ while (defined($file = readdir DH)) {
+ my $subdir = File::Spec->catdir( $self->base_dir, $file );
+ next unless -d $subdir;
+ push @r, $subdir if -e File::Spec->catfile( $subdir, 'Build.PL' );
+ }
+ }
+
+ $self->recurse_into(\@r);
+}
+
+sub cwd {
+ require Cwd;
+ return Cwd::cwd();
+}
+
+sub _perl_is_same {
+ my ($self, $perl) = @_;
+ return `$perl -MConfig=myconfig -e print -e myconfig` eq Config->myconfig;
+}
+
+sub find_perl_interpreter {
+ return $^X if File::Spec->file_name_is_absolute($^X);
+ my $proto = shift;
+ my $c = ref($proto) ? $proto->config : \%Config::Config;
+ my $exe = $c->{exe_ext};
+
+ my $thisperl = $^X;
+ if ($proto->os_type eq 'VMS') {
+ # VMS might have a file version at the end
+ $thisperl .= $exe unless $thisperl =~ m/$exe(;\d+)?$/i;
+ } elsif (defined $exe) {
+ $thisperl .= $exe unless $thisperl =~ m/$exe$/i;
+ }
+
+ foreach my $perl ( $c->{perlpath},
+ map File::Spec->catfile($_, $thisperl), File::Spec->path()
+ ) {
+ return $perl if -f $perl and $proto->_perl_is_same($perl);
+ }
+ return;
+}
+
+sub _is_interactive {
+ return -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
+}
+
+sub prompt {
+ my $self = shift;
+ my ($mess, $def) = @_;
+ die "prompt() called without a prompt message" unless @_;
+
+ ($def, my $dispdef) = defined $def ? ($def, "[$def] ") : ('', ' ');
+
+ {
+ local $|=1;
+ print "$mess $dispdef";
+ }
+ my $ans;
+ if ( ! $ENV{PERL_MM_USE_DEFAULT} &&
+ ( $self->_is_interactive || ! eof STDIN ) ) {
+ $ans = <STDIN>;
+ if ( defined $ans ) {
+ chomp $ans;
+ } else { # user hit ctrl-D
+ print "\n";
+ }
+ }
+
+ unless (defined($ans) and length($ans)) {
+ print "$def\n";
+ $ans = $def;
+ }
+
+ return $ans;
+}
+
+sub y_n {
+ my $self = shift;
+ die "y_n() called without a prompt message" unless @_;
+ die "y_n() called without y or n default" unless ($_[1]||"")=~/^[yn]/i;
+
+ my $interactive = $self->_is_interactive;
+ my $answer;
+ while (1) {
+ $answer = $self->prompt(@_);
+ return 1 if $answer =~ /^y/i;
+ return 0 if $answer =~ /^n/i;
+ print "Please answer 'y' or 'n'.\n";
+ }
+}
+
+sub current_action { shift->{action} }
+sub invoked_action { shift->{invoked_action} }
+
+sub notes { shift()->{phash}{notes}->access(@_) }
+sub config_data { shift()->{phash}{config_data}->access(@_) }
+sub runtime_params { shift->{phash}{runtime_params}->read( @_ ? shift : () ) } # Read-only
+sub auto_features { shift()->{phash}{auto_features}->access(@_) }
+
+sub features {
+ my $self = shift;
+ my $ph = $self->{phash};
+
+ if (@_) {
+ my $key = shift;
+ if ($ph->{features}->exists($key)) {
+ return $ph->{features}->access($key, @_);
+ }
+
+ if (my $info = $ph->{auto_features}->access($key)) {
+ my $failures = $self->prereq_failures($info);
+ my $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
+ keys %$failures ) ? 1 : 0;
+ return !$disabled;
+ }
+
+ return $ph->{features}->access($key, @_);
+ }
+
+ # No args - get the auto_features & overlay the regular features
+ my %features;
+ my %auto_features = $ph->{auto_features}->access();
+ while (my ($name, $info) = each %auto_features) {
+ my $failures = $self->prereq_failures($info);
+ my $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
+ keys %$failures ) ? 1 : 0;
+ $features{$name} = $disabled ? 0 : 1;
+ }
+ %features = (%features, $ph->{features}->access());
+
+ return wantarray ? %features : \%features;
+}
+BEGIN { *feature = \&features }
+
+sub _mb_feature {
+ my $self = shift;
+
+ if (($self->module_name || '') eq 'Module::Build') {
+ # We're building Module::Build itself, so ...::ConfigData isn't
+ # valid, but $self->features() should be.
+ return $self->feature(@_);
+ } else {
+ require Module::Build::ConfigData;
+ return Module::Build::ConfigData->feature(@_);
+ }
+}
+
+
+sub add_build_element {
+ my ($self, $elem) = @_;
+ my $elems = $self->build_elements;
+ push @$elems, $elem unless grep { $_ eq $elem } @$elems;
+}
+
+sub ACTION_config_data {
+ my $self = shift;
+ return unless $self->has_config_data;
+
+ my $module_name = $self->module_name
+ or die "The config_data feature requires that 'module_name' be set";
+ my $notes_name = $module_name . '::ConfigData'; # TODO: Customize name ???
+ my $notes_pm = File::Spec->catfile($self->blib, 'lib', split /::/, "$notes_name.pm");
+
+ return if $self->up_to_date(['Build.PL',
+ $self->config_file('config_data'),
+ $self->config_file('features')
+ ], $notes_pm);
+
+ $self->log_info("Writing config notes to $notes_pm\n");
+ File::Path::mkpath(File::Basename::dirname($notes_pm));
+
+ Module::Build::Notes->write_config_data
+ (
+ file => $notes_pm,
+ module => $module_name,
+ config_module => $notes_name,
+ config_data => scalar $self->config_data,
+ feature => scalar $self->{phash}{features}->access(),
+ auto_features => scalar $self->auto_features,
+ );
+}
+
+{
+ my %valid_properties = ( __PACKAGE__, {} );
+ my %additive_properties;
+
+ sub _mb_classes {
+ my $class = ref($_[0]) || $_[0];
+ return ($class, $class->mb_parents);
+ }
+
+ sub valid_property {
+ my ($class, $prop) = @_;
+ return grep exists( $valid_properties{$_}{$prop} ), $class->_mb_classes;
+ }
+
+ sub valid_properties {
+ return keys %{ shift->valid_properties_defaults() };
+ }
+
+ sub valid_properties_defaults {
+ my %out;
+ for (reverse shift->_mb_classes) {
+ @out{ keys %{ $valid_properties{$_} } } = values %{ $valid_properties{$_} };
+ }
+ return \%out;
+ }
+
+ sub array_properties {
+ for (shift->_mb_classes) {
+ return @{$additive_properties{$_}->{ARRAY}}
+ if exists $additive_properties{$_}->{ARRAY};
+ }
+ }
+
+ sub hash_properties {
+ for (shift->_mb_classes) {
+ return @{$additive_properties{$_}->{'HASH'}}
+ if exists $additive_properties{$_}->{'HASH'};
+ }
+ }
+
+ sub add_property {
+ my ($class, $property, $default) = @_;
+ die "Property '$property' already exists" if $class->valid_property($property);
+
+ $valid_properties{$class}{$property} = $default;
+
+ my $type = ref $default;
+ if ($type) {
+ push @{$additive_properties{$class}->{$type}}, $property;
+ }
+
+ unless ($class->can($property)) {
+ no strict 'refs';
+ if ( $type eq 'HASH' ) {
+ *{"$class\::$property"} = sub {
+ my $self = shift;
+ my $x = ( $property eq 'config' ) ? $self : $self->{properties};
+ return $x->{$property} unless @_;
+
+ if ( defined($_[0]) && !ref($_[0]) ) {
+ if ( @_ == 1 ) {
+ return exists( $x->{$property}{$_[0]} ) ?
+ $x->{$property}{$_[0]} : undef;
+ } elsif ( @_ % 2 == 0 ) {
+ my %args = @_;
+ while ( my($k, $v) = each %args ) {
+ $x->{$property}{$k} = $v;
+ }
+ } else {
+ die "Unexpected arguments for property '$property'\n";
+ }
+ } else {
+ $x->{$property} = $_[0];
+ }
+ };
+
+ } else {
+ *{"$class\::$property"} = sub {
+ my $self = shift;
+ $self->{properties}{$property} = shift if @_;
+ return $self->{properties}{$property};
+ }
+ }
+
+ }
+ return $class;
+ }
+
+ sub _set_defaults {
+ my $self = shift;
+
+ # Set the build class.
+ $self->{properties}{build_class} ||= ref $self;
+
+ # If there was no orig_dir, set to the same as base_dir
+ $self->{properties}{orig_dir} ||= $self->{properties}{base_dir};
+
+ my $defaults = $self->valid_properties_defaults;
+
+ foreach my $prop (keys %$defaults) {
+ $self->{properties}{$prop} = $defaults->{$prop}
+ unless exists $self->{properties}{$prop};
+ }
+
+ # Copy defaults for arrays any arrays.
+ for my $prop ($self->array_properties) {
+ $self->{properties}{$prop} = [@{$defaults->{$prop}}]
+ unless exists $self->{properties}{$prop};
+ }
+ # Copy defaults for arrays any hashes.
+ for my $prop ($self->hash_properties) {
+ $self->{properties}{$prop} = {%{$defaults->{$prop}}}
+ unless exists $self->{properties}{$prop};
+ }
+ }
+
+}
+
+# Add the default properties.
+__PACKAGE__->add_property(blib => 'blib');
+__PACKAGE__->add_property(build_class => 'Module::Build');
+__PACKAGE__->add_property(build_elements => [qw(PL support pm xs pod script)]);
+__PACKAGE__->add_property(build_script => 'Build');
+__PACKAGE__->add_property(build_bat => 0);
+__PACKAGE__->add_property(config_dir => '_build');
+__PACKAGE__->add_property(include_dirs => []);
+__PACKAGE__->add_property(installdirs => 'site');
+__PACKAGE__->add_property(metafile => 'META.yml');
+__PACKAGE__->add_property(recurse_into => []);
+__PACKAGE__->add_property(use_rcfile => 1);
+
+{
+ my $Is_ActivePerl = eval {require ActivePerl::DocTools};
+ __PACKAGE__->add_property(html_css => $Is_ActivePerl ? 'Active.css' : '');
+}
+
+{
+ my @prereq_action_types = qw(requires build_requires conflicts recommends);
+ foreach my $type (@prereq_action_types) {
+ __PACKAGE__->add_property($type => {});
+ }
+ __PACKAGE__->add_property(prereq_action_types => \@prereq_action_types);
+}
+
+__PACKAGE__->add_property($_ => {}) for qw(
+ config
+ get_options
+ install_base_relpaths
+ install_path
+ install_sets
+ meta_add
+ meta_merge
+ original_prefix
+ prefix_relpaths
+);
+
+__PACKAGE__->add_property($_) for qw(
+ PL_files
+ autosplit
+ base_dir
+ bindoc_dirs
+ c_source
+ create_makefile_pl
+ create_readme
+ debugger
+ destdir
+ dist_abstract
+ dist_author
+ dist_name
+ dist_version
+ dist_version_from
+ extra_compiler_flags
+ extra_linker_flags
+ has_config_data
+ install_base
+ libdoc_dirs
+ license
+ magic_number
+ mb_version
+ module_name
+ orig_dir
+ perl
+ pm_files
+ pod_files
+ pollute
+ prefix
+ quiet
+ recursive_test_files
+ script_files
+ scripts
+ test_files
+ verbose
+ xs_files
+);
+
+
+sub mb_parents {
+ # Code borrowed from Class::ISA.
+ my @in_stack = (shift);
+ my %seen = ($in_stack[0] => 1);
+
+ my ($current, @out);
+ while (@in_stack) {
+ next unless defined($current = shift @in_stack)
+ && $current->isa('Module::Build::Base');
+ push @out, $current;
+ next if $current eq 'Module::Build::Base';
+ no strict 'refs';
+ unshift @in_stack,
+ map {
+ my $c = $_; # copy, to avoid being destructive
+ substr($c,0,2) = "main::" if substr($c,0,2) eq '::';
+ # Canonize the :: -> main::, ::foo -> main::foo thing.
+ # Should I ever canonize the Foo'Bar = Foo::Bar thing?
+ $seen{$c}++ ? () : $c;
+ } @{"$current\::ISA"};
+
+ # I.e., if this class has any parents (at least, ones I've never seen
+ # before), push them, in order, onto the stack of classes I need to
+ # explore.
+ }
+ shift @out;
+ return @out;
+}
+
+sub extra_linker_flags { shift->_list_accessor('extra_linker_flags', @_) }
+sub extra_compiler_flags { shift->_list_accessor('extra_compiler_flags', @_) }
+
+sub _list_accessor {
+ (my $self, local $_) = (shift, shift);
+ my $p = $self->{properties};
+ $p->{$_} = [@_] if @_;
+ $p->{$_} = [] unless exists $p->{$_};
+ return ref($p->{$_}) ? $p->{$_} : [$p->{$_}];
+}
+
+# XXX Problem - if Module::Build is loaded from a different directory,
+# it'll look for (and perhaps destroy/create) a _build directory.
+sub subclass {
+ my ($pack, %opts) = @_;
+
+ my $build_dir = '_build'; # XXX The _build directory is ostensibly settable by the user. Shouldn't hard-code here.
+ $pack->delete_filetree($build_dir) if -e $build_dir;
+
+ die "Must provide 'code' or 'class' option to subclass()\n"
+ unless $opts{code} or $opts{class};
+
+ $opts{code} ||= '';
+ $opts{class} ||= 'MyModuleBuilder';
+
+ my $filename = File::Spec->catfile($build_dir, 'lib', split '::', $opts{class}) . '.pm';
+ my $filedir = File::Basename::dirname($filename);
+ $pack->log_info("Creating custom builder $filename in $filedir\n");
+
+ File::Path::mkpath($filedir);
+ die "Can't create directory $filedir: $!" unless -d $filedir;
+
+ my $fh = IO::File->new("> $filename") or die "Can't create $filename: $!";
+ print $fh <<EOF;
+package $opts{class};
+use $pack;
+\@ISA = qw($pack);
+$opts{code}
+1;
+EOF
+ close $fh;
+
+ unshift @INC, File::Spec->catdir(File::Spec->rel2abs($build_dir), 'lib');
+ eval "use $opts{class}";
+ die $@ if $@;
+
+ return $opts{class};
+}
+
+sub dist_name {
+ my $self = shift;
+ my $p = $self->{properties};
+ return $p->{dist_name} if defined $p->{dist_name};
+
+ die "Can't determine distribution name, must supply either 'dist_name' or 'module_name' parameter"
+ unless $p->{module_name};
+
+ ($p->{dist_name} = $p->{module_name}) =~ s/::/-/g;
+
+ return $p->{dist_name};
+}
+
+sub _find_dist_version_from {
+ my ($self) = @_;
+ my $p = $self->{properties};
+ if ($self->module_name) {
+ return $p->{dist_version_from} ||=
+ join( '/', 'lib', split(/::/, $self->module_name) ) . '.pm';
+ } else {
+ return undef;
+ }
+}
+
+sub dist_version {
+ my ($self) = @_;
+ my $p = $self->{properties};
+
+ return $p->{dist_version} if defined $p->{dist_version};
+
+ $self->_find_dist_version_from;
+
+ if ( $p->{dist_version_from} ) {
+ my $version_from = File::Spec->catfile( split( qr{/}, $p->{dist_version_from} ) );
+ my $pm_info = Module::Build::ModuleInfo->new_from_file( $version_from )
+ or die "Can't find file $version_from to determine version";
+ $p->{dist_version} = $pm_info->version();
+ }
+
+ die ("Can't determine distribution version, must supply either 'dist_version',\n".
+ "'dist_version_from', or 'module_name' parameter")
+ unless $p->{dist_version};
+
+ return $p->{dist_version};
+}
+
+sub dist_author { shift->_pod_parse('author') }
+sub dist_abstract { shift->_pod_parse('abstract') }
+
+sub _pod_parse {
+ my ($self, $part) = @_;
+ my $p = $self->{properties};
+ my $member = "dist_$part";
+ return $p->{$member} if defined $p->{$member};
+
+ my $docfile = $self->_main_docfile
+ or return;
+ my $fh = IO::File->new($docfile)
+ or return;
+
+ require Module::Build::PodParser;
+ my $parser = Module::Build::PodParser->new(fh => $fh);
+ my $method = "get_$part";
+ return $p->{$member} = $parser->$method();
+}
+
+sub version_from_file { # Method provided for backwards compatability
+ return Module::Build::ModuleInfo->new_from_file($_[1])->version();
+}
+
+sub find_module_by_name { # Method provided for backwards compatability
+ return Module::Build::ModuleInfo->find_module_by_name(@_[1,2]);
+}
+
+sub add_to_cleanup {
+ my $self = shift;
+ my %files = map {$self->localize_file_path($_), 1} @_;
+ $self->{phash}{cleanup}->write(\%files);
+}
+
+sub cleanup {
+ my $self = shift;
+ my $all = $self->{phash}{cleanup}->read;
+ return keys %$all;
+}
+
+sub config_file {
+ my $self = shift;
+ return unless -d $self->config_dir;
+ return File::Spec->catfile($self->config_dir, @_);
+}
+
+sub read_config {
+ my ($self) = @_;
+
+ my $file = $self->config_file('build_params')
+ or die "No build_params?";
+ my $fh = IO::File->new($file) or die "Can't read '$file': $!";
+ my $ref = eval do {local $/; <$fh>};
+ die if $@;
+ ($self->{args}, $self->{config}, $self->{properties}) = @$ref;
+ close $fh;
+}
+
+sub has_config_data {
+ my $self = shift;
+ return scalar grep $self->{phash}{$_}->has_data(), qw(config_data features auto_features);
+}
+
+sub _write_data {
+ my ($self, $filename, $data) = @_;
+
+ my $file = $self->config_file($filename);
+ my $fh = IO::File->new("> $file") or die "Can't create '$file': $!";
+ local $Data::Dumper::Terse = 1;
+ print $fh ref($data) ? Data::Dumper::Dumper($data) : $data;
+}
+
+sub write_config {
+ my ($self) = @_;
+
+ File::Path::mkpath($self->{properties}{config_dir});
+ -d $self->{properties}{config_dir} or die "Can't mkdir $self->{properties}{config_dir}: $!";
+
+ my @items = @{ $self->prereq_action_types };
+ $self->_write_data('prereqs', { map { $_, $self->$_() } @items });
+ $self->_write_data('build_params', [$self->{args}, $self->{config}, $self->{properties}]);
+
+ # Set a new magic number and write it to a file
+ $self->_write_data('magicnum', $self->magic_number(int rand 1_000_000));
+
+ $self->{phash}{$_}->write() foreach qw(notes cleanup features auto_features config_data runtime_params);
+}
+
+sub check_autofeatures {
+ my ($self) = @_;
+ my $features = $self->auto_features;
+
+ return unless %$features;
+
+ $self->log_info("Checking features:\n");
+
+ my $max_name_len;
+ $max_name_len = ( length($_) > $max_name_len ) ?
+ length($_) : $max_name_len
+ for keys %$features;
+
+ while (my ($name, $info) = each %$features) {
+ $self->log_info(" $name" . '.' x ($max_name_len - length($name) + 4));
+
+ if ( my $failures = $self->prereq_failures($info) ) {
+ my $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
+ keys %$failures ) ? 1 : 0;
+ $self->log_info( $disabled ? "disabled\n" : "enabled\n" );
+
+ my $log_text;
+ while (my ($type, $prereqs) = each %$failures) {
+ while (my ($module, $status) = each %$prereqs) {
+ my $required =
+ ($type =~ /^(?:\w+_)?(?:requires|conflicts)$/) ? 1 : 0;
+ my $prefix = ($required) ? '-' : '*';
+ $log_text .= " $prefix $status->{message}\n";
+ }
+ }
+ $self->log_warn("$log_text") unless $self->quiet;
+ } else {
+ $self->log_info("enabled\n");
+ }
+ }
+
+ $self->log_warn("\n");
+}
+
+sub prereq_failures {
+ my ($self, $info) = @_;
+
+ my @types = @{ $self->prereq_action_types };
+ $info ||= {map {$_, $self->$_()} @types};
+
+ my $out;
+
+ foreach my $type (@types) {
+ my $prereqs = $info->{$type};
+ while ( my ($modname, $spec) = each %$prereqs ) {
+ my $status = $self->check_installed_status($modname, $spec);
+
+ if ($type =~ /^(?:\w+_)?conflicts$/) {
+ next if !$status->{ok};
+ $status->{conflicts} = delete $status->{need};
+ $status->{message} = "$modname ($status->{have}) conflicts with this distribution";
+
+ } elsif ($type =~ /^(?:\w+_)?recommends$/) {
+ next if $status->{ok};
+ $status->{message} = ($status->{have} eq '<none>'
+ ? "Optional prerequisite $modname is not installed"
+ : "$modname ($status->{have}) is installed, but we prefer to have $spec");
+ } else {
+ next if $status->{ok};
+ }
+
+ $out->{$type}{$modname} = $status;
+ }
+ }
+
+ return $out;
+}
+
+# returns a hash of defined prerequisites; i.e. only prereq types with values
+sub _enum_prereqs {
+ my $self = shift;
+ my %prereqs;
+ foreach my $type ( @{ $self->prereq_action_types } ) {
+ if ( $self->can( $type ) ) {
+ my $prereq = $self->$type() || {};
+ $prereqs{$type} = $prereq if %$prereq;
+ }
+ }
+ return \%prereqs;
+}
+
+sub check_prereq {
+ my $self = shift;
+
+ # If we have XS files, make sure we can process them.
+ my $xs_files = $self->find_xs_files;
+ if (keys %$xs_files && !$self->_mb_feature('C_support')) {
+ $self->log_warn("Warning: this distribution contains XS files, ".
+ "but Module::Build is not configured with C_support");
+ }
+
+ # Check to see if there are any prereqs to check
+ my $info = $self->_enum_prereqs;
+ return 1 unless $info;
+
+ $self->log_info("Checking prerequisites...\n");
+
+ my $failures = $self->prereq_failures($info);
+
+ if ( $failures ) {
+
+ while (my ($type, $prereqs) = each %$failures) {
+ while (my ($module, $status) = each %$prereqs) {
+ my $prefix = ($type =~ /^(?:\w+_)?recommends$/) ? '*' : '- ERROR:';
+ $self->log_warn(" $prefix $status->{message}\n");
+ }
+ }
+
+ $self->log_warn(<<EOF);
+
+ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions
+of the modules indicated above before proceeding with this installation
+
+EOF
+ return 0;
+
+ } else {
+
+ $self->log_info("Looks good\n\n");
+ return 1;
+
+ }
+}
+
+sub perl_version {
+ my ($self) = @_;
+ # Check the current perl interpreter
+ # It's much more convenient to use $] here than $^V, but 'man
+ # perlvar' says I'm not supposed to. Bloody tyrant.
+ return $^V ? $self->perl_version_to_float(sprintf "%vd", $^V) : $];
+}
+
+sub perl_version_to_float {
+ my ($self, $version) = @_;
+ $version =~ s/\./../;
+ $version =~ s/\.(\d+)/sprintf '%03d', $1/eg;
+ return $version;
+}
+
+sub _parse_conditions {
+ my ($self, $spec) = @_;
+
+ if ($spec =~ /^\s*([\w.]+)\s*$/) { # A plain number, maybe with dots, letters, and underscores
+ return (">= $spec");
+ } else {
+ return split /\s*,\s*/, $spec;
+ }
+}
+
+sub check_installed_status {
+ my ($self, $modname, $spec) = @_;
+ my %status = (need => $spec);
+
+ if ($modname eq 'perl') {
+ $status{have} = $self->perl_version;
+
+ } elsif (eval { no strict; $status{have} = ${"${modname}::VERSION"} }) {
+ # Don't try to load if it's already loaded
+
+ } else {
+ my $pm_info = Module::Build::ModuleInfo->new_from_module( $modname );
+ unless (defined( $pm_info )) {
+ @status{ qw(have message) } = ('<none>', "$modname is not installed");
+ return \%status;
+ }
+
+ $status{have} = $pm_info->version();
+ if ($spec and !$status{have}) {
+ @status{ qw(have message) } = (undef, "Couldn't find a \$VERSION in prerequisite $modname");
+ return \%status;
+ }
+ }
+
+ my @conditions = $self->_parse_conditions($spec);
+
+ foreach (@conditions) {
+ my ($op, $version) = /^\s* (<=?|>=?|==|!=) \s* ([\w.]+) \s*$/x
+ or die "Invalid prerequisite condition '$_' for $modname";
+
+ $version = $self->perl_version_to_float($version)
+ if $modname eq 'perl';
+
+ next if $op eq '>=' and !$version; # Module doesn't have to actually define a $VERSION
+
+ unless ($self->compare_versions( $status{have}, $op, $version )) {
+ $status{message} = "$modname ($status{have}) is installed, but we need version $op $version";
+ return \%status;
+ }
+ }
+
+ $status{ok} = 1;
+ return \%status;
+}
+
+sub compare_versions {
+ my $self = shift;
+ my ($v1, $op, $v2) = @_;
+
+ # for alpha versions - this doesn't cover all cases, but should work for most:
+ $v1 =~ s/_(\d+)\z/$1/;
+ $v2 =~ s/_(\d+)\z/$1/;
+
+ my $eval_str = "\$v1 $op \$v2";
+ my $result = eval $eval_str;
+ $self->log_warn("error comparing versions: '$eval_str' $@") if $@;
+
+ return $result;
+}
+
+# I wish I could set $! to a string, but I can't, so I use $@
+sub check_installed_version {
+ my ($self, $modname, $spec) = @_;
+
+ my $status = $self->check_installed_status($modname, $spec);
+
+ if ($status->{ok}) {
+ return $status->{have} if $status->{have} and $status->{have} ne '<none>';
+ return '0 but true';
+ }
+
+ $@ = $status->{message};
+ return 0;
+}
+
+sub make_executable {
+ # Perl's chmod() is mapped to useful things on various non-Unix
+ # platforms, so we use it in the base class even though it looks
+ # Unixish.
+
+ my $self = shift;
+ foreach (@_) {
+ my $current_mode = (stat $_)[2];
+ chmod $current_mode | 0111, $_;
+ }
+}
+
+sub _startperl { shift()->config('startperl') }
+
+# Return any directories in @INC which are not in the default @INC for
+# this perl. For example, stuff passed in with -I or loaded with "use lib".
+sub _added_to_INC {
+ my $self = shift;
+
+ my %seen;
+ $seen{$_}++ foreach $self->_default_INC;
+ return grep !$seen{$_}++, @INC;
+}
+
+# Determine the default @INC for this Perl
+{
+ my @default_inc; # Memoize
+ sub _default_INC {
+ my $self = shift;
+ return @default_inc if @default_inc;
+
+ local $ENV{PERL5LIB}; # this is not considered part of the default.
+
+ my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter;
+
+ my @inc = `$perl -le "print for \@INC"`;
+ chomp @inc;
+
+ return @default_inc = @inc;
+ }
+}
+
+sub print_build_script {
+ my ($self, $fh) = @_;
+
+ my $build_package = $self->build_class;
+
+ my $closedata="";
+
+ my %q = map {$_, $self->$_()} qw(config_dir base_dir);
+
+ my $case_tolerant = 0+(File::Spec->can('case_tolerant')
+ && File::Spec->case_tolerant);
+ $q{base_dir} = uc $q{base_dir} if $case_tolerant;
+ $q{base_dir} = Win32::GetShortPathName($q{base_dir}) if $^O eq 'MSWin32';
+
+ $q{magic_numfile} = $self->config_file('magicnum');
+
+ my @myINC = $self->_added_to_INC;
+ for (@myINC, values %q) {
+ $_ = File::Spec->canonpath( $_ );
+ s/([\\\'])/\\$1/g;
+ }
+
+ my $quoted_INC = join ",\n", map " '$_'", @myINC;
+ my $shebang = $self->_startperl;
+ my $magic_number = $self->magic_number;
+
+ print $fh <<EOF;
+$shebang
+
+use strict;
+use Cwd;
+use File::Basename;
+use File::Spec;
+
+sub magic_number_matches {
+ return 0 unless -e '$q{magic_numfile}';
+ local *FH;
+ open FH, '$q{magic_numfile}' or return 0;
+ my \$filenum = <FH>;
+ close FH;
+ return \$filenum == $magic_number;
+}
+
+my \$progname;
+my \$orig_dir;
+BEGIN {
+ \$^W = 1; # Use warnings
+ \$progname = basename(\$0);
+ \$orig_dir = Cwd::cwd();
+ my \$base_dir = '$q{base_dir}';
+ if (!magic_number_matches()) {
+ unless (chdir(\$base_dir)) {
+ die ("Couldn't chdir(\$base_dir), aborting\\n");
+ }
+ unless (magic_number_matches()) {
+ die ("Configuration seems to be out of date, please re-run 'perl Build.PL' again.\\n");
+ }
+ }
+ unshift \@INC,
+ (
+$quoted_INC
+ );
+}
+
+close(*DATA) unless eof(*DATA); # ensure no open handles to this script
+
+use $build_package;
+
+# Some platforms have problems setting \$^X in shebang contexts, fix it up here
+\$^X = Module::Build->find_perl_interpreter
+ unless File::Spec->file_name_is_absolute(\$^X);
+
+if (-e 'Build.PL' and not $build_package->up_to_date('Build.PL', \$progname)) {
+ warn "Warning: Build.PL has been altered. You may need to run 'perl Build.PL' again.\\n";
+}
+
+# This should have just enough arguments to be able to bootstrap the rest.
+my \$build = $build_package->resume (
+ properties => {
+ config_dir => '$q{config_dir}',
+ orig_dir => \$orig_dir,
+ },
+);
+
+\$build->dispatch;
+EOF
+}
+
+sub create_build_script {
+ my ($self) = @_;
+ $self->write_config;
+
+ my ($build_script, $dist_name, $dist_version)
+ = map $self->$_(), qw(build_script dist_name dist_version);
+
+ if ( $self->delete_filetree($build_script) ) {
+ $self->log_info("Removed previous script '$build_script'\n\n");
+ }
+
+ $self->log_info("Creating new '$build_script' script for ",
+ "'$dist_name' version '$dist_version'\n");
+ my $fh = IO::File->new(">$build_script") or die "Can't create '$build_script': $!";
+ $self->print_build_script($fh);
+ close $fh;
+
+ $self->make_executable($build_script);
+
+ return 1;
+}
+
+sub check_manifest {
+ my $self = shift;
+ return unless -e 'MANIFEST';
+
+ # Stolen nearly verbatim from MakeMaker. But ExtUtils::Manifest
+ # could easily be re-written into a modern Perl dialect.
+
+ require ExtUtils::Manifest; # ExtUtils::Manifest is not warnings clean.
+ local ($^W, $ExtUtils::Manifest::Quiet) = (0,1);
+
+ $self->log_info("Checking whether your kit is complete...\n");
+ if (my @missed = ExtUtils::Manifest::manicheck()) {
+ $self->log_warn("WARNING: the following files are missing in your kit:\n",
+ "\t", join("\n\t", @missed), "\n",
+ "Please inform the author.\n\n");
+ } else {
+ $self->log_info("Looks good\n\n");
+ }
+}
+
+sub dispatch {
+ my $self = shift;
+ local $self->{_completed_actions} = {};
+
+ if (@_) {
+ my ($action, %p) = @_;
+ my $args = $p{args} ? delete($p{args}) : {};
+
+ local $self->{invoked_action} = $action;
+ local $self->{args} = {%{$self->{args}}, %$args};
+ local $self->{properties} = {%{$self->{properties}}, %p};
+ return $self->_call_action($action);
+ }
+
+ die "No build action specified" unless $self->{action};
+ local $self->{invoked_action} = $self->{action};
+ $self->_call_action($self->{action});
+}
+
+sub _call_action {
+ my ($self, $action) = @_;
+
+ return if $self->{_completed_actions}{$action}++;
+
+ local $self->{action} = $action;
+ my $method = "ACTION_$action";
+ die "No action '$action' defined, try running the 'help' action.\n" unless $self->can($method);
+ return $self->$method();
+}
+
+sub cull_options {
+ my $self = shift;
+ my $specs = $self->get_options or return ({}, @_);
+ require Getopt::Long;
+ # XXX Should we let Getopt::Long handle M::B's options? That would
+ # be easy-ish to add to @specs right here, but wouldn't handle options
+ # passed without "--" as M::B currently allows. We might be able to
+ # get around this by setting the "prefix_pattern" Configure option.
+ my @specs;
+ my $args = {};
+ # Construct the specifications for GetOptions.
+ while (my ($k, $v) = each %$specs) {
+ # Throw an error if specs conflict with our own.
+ die "Option specification '$k' conflicts with a " . ref $self
+ . " option of the same name"
+ if $self->valid_property($k);
+ push @specs, $k . (defined $v->{type} ? $v->{type} : '');
+ push @specs, $v->{store} if exists $v->{store};
+ $args->{$k} = $v->{default} if exists $v->{default};
+ }
+
+ local @ARGV = @_; # No other way to dupe Getopt::Long
+
+ # Get the options values and return them.
+ # XXX Add option to allow users to set options?
+ if ( @specs ) {
+ Getopt::Long::Configure('pass_through');
+ Getopt::Long::GetOptions($args, @specs);
+ }
+
+ return $args, @ARGV;
+}
+
+sub unparse_args {
+ my ($self, $args) = @_;
+ my @out;
+ while (my ($k, $v) = each %$args) {
+ push @out, (UNIVERSAL::isa($v, 'HASH') ? map {+"--$k", "$_=$v->{$_}"} keys %$v :
+ UNIVERSAL::isa($v, 'ARRAY') ? map {+"--$k", $_} @$v :
+ ("--$k", $v));
+ }
+ return @out;
+}
+
+sub args {
+ my $self = shift;
+ return wantarray ? %{ $self->{args} } : $self->{args} unless @_;
+ my $key = shift;
+ $self->{args}{$key} = shift if @_;
+ return $self->{args}{$key};
+}
+
+sub _translate_option {
+ my $self = shift;
+ my $opt = shift;
+
+ (my $tr_opt = $opt) =~ tr/-/_/;
+
+ return $tr_opt if grep $tr_opt =~ /^(?:no_?)?$_$/, qw(
+ create_makefile_pl
+ create_readme
+ extra_compiler_flags
+ extra_linker_flags
+ html_css
+ install_base
+ install_path
+ meta_add
+ meta_merge
+ test_files
+ use_rcfile
+ ); # normalize only selected option names
+
+ return $opt;
+}
+
+sub _read_arg {
+ my ($self, $args, $key, $val) = @_;
+
+ $key = $self->_translate_option($key);
+
+ if ( exists $args->{$key} ) {
+ $args->{$key} = [ $args->{$key} ] unless ref $args->{$key};
+ push @{$args->{$key}}, $val;
+ } else {
+ $args->{$key} = $val;
+ }
+}
+
+sub _optional_arg {
+ my $self = shift;
+ my $opt = shift;
+ my $argv = shift;
+
+ $opt = $self->_translate_option($opt);
+
+ my @bool_opts = qw(
+ build_bat
+ create_readme
+ pollute
+ quiet
+ uninst
+ use_rcfile
+ verbose
+ );
+
+ # inverted boolean options; eg --noverbose or --no-verbose
+ # converted to proper name & returned with false value (verbose, 0)
+ if ( grep $opt =~ /^no[-_]?$_$/, @bool_opts ) {
+ $opt =~ s/^no-?//;
+ return ($opt, 0);
+ }
+
+ # non-boolean option; return option unchanged along with its argument
+ return ($opt, shift(@$argv)) unless grep $_ eq $opt, @bool_opts;
+
+ # we're punting a bit here, if an option appears followed by a digit
+ # we take the digit as the argument for the option. If there is
+ # nothing that looks like a digit, we pretent the option is a flag
+ # that is being set and has no argument.
+ my $arg = 1;
+ $arg = shift(@$argv) if @$argv && $argv->[0] =~ /^\d+$/;
+
+ return ($opt, $arg);
+}
+
+sub read_args {
+ my $self = shift;
+ my ($action, @argv);
+ (my $args, @_) = $self->cull_options(@_);
+ my %args = %$args;
+
+ my $opt_re = qr/[\w\-]+/;
+
+ while (@_) {
+ local $_ = shift;
+ if ( /^(?:--)?($opt_re)=(.*)$/ ) {
+ $self->_read_arg(\%args, $1, $2);
+ } elsif ( /^--($opt_re)$/ ) {
+ my($opt, $arg) = $self->_optional_arg($1, \@_);
+ $self->_read_arg(\%args, $opt, $arg);
+ } elsif ( /^($opt_re)$/ and !defined($action)) {
+ $action = $1;
+ } else {
+ push @argv, $_;
+ }
+ }
+ $args{ARGV} = \@argv;
+
+ # Hashify these parameters
+ for ($self->hash_properties) {
+ next unless exists $args{$_};
+ my %hash;
+ $args{$_} ||= [];
+ $args{$_} = [ $args{$_} ] unless ref $args{$_};
+ foreach my $arg ( @{$args{$_}} ) {
+ $arg =~ /(\w+)=(.*)/
+ or die "Malformed '$_' argument: '$arg' should be something like 'foo=bar'";
+ $hash{$1} = $2;
+ }
+ $args{$_} = \%hash;
+ }
+
+ # De-tilde-ify any path parameters
+ for my $key (qw(prefix install_base destdir)) {
+ next if !defined $args{$key};
+ $args{$key} = _detildefy($args{$key});
+ }
+
+ for my $key (qw(install_path)) {
+ next if !defined $args{$key};
+
+ for my $subkey (keys %{$args{$key}}) {
+ next if !defined $args{$key}{$subkey};
+ my $subkey_ext = _detildefy($args{$key}{$subkey});
+ if ( $subkey eq 'html' ) { # translate for compatability
+ $args{$key}{binhtml} = $subkey_ext;
+ $args{$key}{libhtml} = $subkey_ext;
+ } else {
+ $args{$key}{$subkey} = $subkey_ext;
+ }
+ }
+ }
+
+ if ($args{makefile_env_macros}) {
+ require Module::Build::Compat;
+ %args = (%args, Module::Build::Compat->makefile_to_build_macros);
+ }
+
+ return \%args, $action;
+}
+
+
+sub _detildefy {
+ my $arg = shift;
+
+ my($new_arg) = glob($arg) if $arg =~ /^~/;
+
+ return defined($new_arg) ? $new_arg : $arg;
+}
+
+
+# merge Module::Build argument lists that have already been parsed
+# by read_args(). Takes two references to option hashes and merges
+# the contents, giving priority to the first.
+sub _merge_arglist {
+ my( $self, $opts1, $opts2 ) = @_;
+
+ my %new_opts = %$opts1;
+ while (my ($key, $val) = each %$opts2) {
+ if ( exists( $opts1->{$key} ) ) {
+ if ( ref( $val ) eq 'HASH' ) {
+ while (my ($k, $v) = each %$val) {
+ $new_opts{$key}{$k} = $v unless exists( $opts1->{$key}{$k} );
+ }
+ }
+ } else {
+ $new_opts{$key} = $val
+ }
+ }
+
+ return %new_opts;
+}
+
+# Look for a home directory on various systems. CPANPLUS does something like this.
+sub _home_dir {
+ my @os_home_envs = qw( APPDATA HOME USERPROFILE WINDIR SYS$LOGIN );
+
+ foreach ( @os_home_envs ) {
+ return $ENV{$_} if exists $ENV{$_} && defined $ENV{$_} && length $ENV{$_} && -d $ENV{$_};
+ }
+
+ return;
+}
+
+# read ~/.modulebuildrc returning global options '*' and
+# options specific to the currently executing $action.
+sub read_modulebuildrc {
+ my( $self, $action ) = @_;
+
+ return () unless $self->use_rcfile;
+
+ my $modulebuildrc;
+ if ( exists($ENV{MODULEBUILDRC}) && $ENV{MODULEBUILDRC} eq 'NONE' ) {
+ return ();
+ } elsif ( exists($ENV{MODULEBUILDRC}) && -e $ENV{MODULEBUILDRC} ) {
+ $modulebuildrc = $ENV{MODULEBUILDRC};
+ } elsif ( exists($ENV{MODULEBUILDRC}) ) {
+ $self->log_warn("WARNING: Can't find resource file " .
+ "'$ENV{MODULEBUILDRC}' defined in environment.\n" .
+ "No options loaded\n");
+ return ();
+ } else {
+ my $home = $self->_home_dir;
+ return () unless defined $home;
+ $modulebuildrc = File::Spec->catfile( $home, '.modulebuildrc' );
+ return () unless -e $modulebuildrc;
+ }
+
+ my $fh = IO::File->new( $modulebuildrc )
+ or die "Can't open $modulebuildrc: $!";
+
+ my %options; my $buffer = '';
+ while (defined( my $line = <$fh> )) {
+ chomp( $line );
+ $line =~ s/#.*$//;
+ next unless length( $line );
+
+ if ( $line =~ /^\S/ ) {
+ if ( $buffer ) {
+ my( $action, $options ) = split( /\s+/, $buffer, 2 );
+ $options{$action} .= $options . ' ';
+ $buffer = '';
+ }
+ $buffer = $line;
+ } else {
+ $buffer .= $line;
+ }
+ }
+
+ if ( $buffer ) { # anything left in $buffer ?
+ my( $action, $options ) = split( /\s+/, $buffer, 2 );
+ $options{$action} .= $options . ' '; # merge if more than one line
+ }
+
+ my ($global_opts) =
+ $self->read_args( $self->split_like_shell( $options{'*'} || '' ) );
+ my ($action_opts) =
+ $self->read_args( $self->split_like_shell( $options{$action} || '' ) );
+
+ # specific $action options take priority over global options '*'
+ return $self->_merge_arglist( $action_opts, $global_opts );
+}
+
+# merge the relevant options in ~/.modulebuildrc into Module::Build's
+# option list where they do not conflict with commandline options.
+sub merge_modulebuildrc {
+ my( $self, $action, %cmdline_opts ) = @_;
+ my %rc_opts = $self->read_modulebuildrc( $action || $self->{action} || 'build' );
+ my %new_opts = $self->_merge_arglist( \%cmdline_opts, \%rc_opts );
+ $self->merge_args( $action, %new_opts );
+}
+
+sub merge_args {
+ my ($self, $action, %args) = @_;
+ $self->{action} = $action if defined $action;
+
+ my %additive = map { $_ => 1 } $self->hash_properties;
+
+ # Extract our 'properties' from $cmd_args, the rest are put in 'args'.
+ while (my ($key, $val) = each %args) {
+ $self->{phash}{runtime_params}->access( $key => $val )
+ if $self->valid_property($key);
+ my $add_to = ( $key eq 'config' ? $self->{config}
+ : $additive{$key} ? $self->{properties}{$key}
+ : $self->valid_property($key) ? $self->{properties}
+ : $self->{args});
+
+ if ($additive{$key}) {
+ $add_to->{$_} = $val->{$_} foreach keys %$val;
+ } else {
+ $add_to->{$key} = $val;
+ }
+ }
+}
+
+sub cull_args {
+ my $self = shift;
+ my ($args, $action) = $self->read_args(@_);
+ $self->merge_args($action, %$args);
+ $self->merge_modulebuildrc( $action, %$args );
+}
+
+sub super_classes {
+ my ($self, $class, $seen) = @_;
+ $class ||= ref($self) || $self;
+ $seen ||= {};
+
+ no strict 'refs';
+ my @super = grep {not $seen->{$_}++} $class, @{ $class . '::ISA' };
+ return @super, map {$self->super_classes($_,$seen)} @super;
+}
+
+sub known_actions {
+ my ($self) = @_;
+
+ my %actions;
+ no strict 'refs';
+
+ foreach my $class ($self->super_classes) {
+ foreach ( keys %{ $class . '::' } ) {
+ $actions{$1}++ if /^ACTION_(\w+)/;
+ }
+ }
+
+ return wantarray ? sort keys %actions : \%actions;
+}
+
+sub get_action_docs {
+ my ($self, $action, $actions) = @_;
+ $actions ||= $self->known_actions;
+ $@ = '';
+ ($@ = "No known action '$action'\n"), return
+ unless $actions->{$action};
+
+ my ($files_found, @docs) = (0);
+ foreach my $class ($self->super_classes) {
+ (my $file = $class) =~ s{::}{/}g;
+ $file = $INC{$file . '.pm'} or next;
+ my $fh = IO::File->new("< $file") or next;
+ $files_found++;
+
+ # Code below modified from /usr/bin/perldoc
+
+ # Skip to ACTIONS section
+ local $_;
+ while (<$fh>) {
+ last if /^=head1 ACTIONS\s/;
+ }
+
+ # Look for our action
+ my ($found, $inlist) = (0, 0);
+ while (<$fh>) {
+ if (/^=item\s+\Q$action\E\b/) {
+ $found = 1;
+ } elsif (/^=(item|back)/) {
+ last if $found > 1 and not $inlist;
+ }
+ next unless $found;
+ push @docs, $_;
+ ++$inlist if /^=over/;
+ --$inlist if /^=back/;
+ ++$found if /^\w/; # Found descriptive text
+ }
+ }
+
+ unless ($files_found) {
+ $@ = "Couldn't find any documentation to search";
+ return;
+ }
+ unless (@docs) {
+ $@ = "Couldn't find any docs for action '$action'";
+ return;
+ }
+
+ return join '', @docs;
+}
+
+sub ACTION_prereq_report {
+ my $self = shift;
+ $self->log_info( $self->prereq_report );
+}
+
+sub prereq_report {
+ my $self = shift;
+ my @types = @{ $self->prereq_action_types };
+ my $info = { map { $_ => $self->$_() } @types };
+
+ my $output = '';
+ foreach my $type (@types) {
+ my $prereqs = $info->{$type};
+ next unless %$prereqs;
+ $output .= "\n$type:\n";
+ my $mod_len = 2;
+ my $ver_len = 4;
+ my %mods;
+ while ( my ($modname, $spec) = each %$prereqs ) {
+ my $len = length $modname;
+ $mod_len = $len if $len > $mod_len;
+ $spec ||= '0';
+ $len = length $spec;
+ $ver_len = $len if $len > $ver_len;
+
+ my $mod = $self->check_installed_status($modname, $spec);
+ $mod->{name} = $modname;
+ $mod->{ok} ||= 0;
+ $mod->{ok} = ! $mod->{ok} if $type =~ /^(\w+_)?conflicts$/;
+
+ $mods{lc $modname} = $mod;
+ }
+
+ my $space = q{ } x ($mod_len - 3);
+ my $vspace = q{ } x ($ver_len - 3);
+ my $sline = q{-} x ($mod_len - 3);
+ my $vline = q{-} x ($ver_len - 3);
+ my $disposition = ($type =~ /^(\w+_)?conflicts$/) ?
+ 'Clash' : 'Need';
+ $output .=
+ " Module $space $disposition $vspace Have\n".
+ " ------$sline+------$vline-+----------\n";
+
+
+ for my $k (sort keys %mods) {
+ my $mod = $mods{$k};
+ my $space = q{ } x ($mod_len - length $k);
+ my $vspace = q{ } x ($ver_len - length $mod->{need});
+ my $f = $mod->{ok} ? ' ' : '!';
+ $output .=
+ " $f $mod->{name} $space $mod->{need} $vspace $mod->{have}\n";
+ }
+ }
+ return $output;
+}
+
+sub ACTION_help {
+ my ($self) = @_;
+ my $actions = $self->known_actions;
+
+ if (@{$self->{args}{ARGV}}) {
+ my $msg = $self->get_action_docs($self->{args}{ARGV}[0], $actions) || "$@\n";
+ print $msg;
+ return;
+ }
+
+ print <<EOF;
+
+ Usage: $0 <action> arg1=value arg2=value ...
+ Example: $0 test verbose=1
+
+ Actions defined:
+EOF
+
+ print $self->_action_listing($actions);
+
+ print "\nRun `Build help <action>` for details on an individual action.\n";
+ print "See `perldoc Module::Build` for complete documentation.\n";
+}
+
+sub _action_listing {
+ my ($self, $actions) = @_;
+
+ # Flow down columns, not across rows
+ my @actions = sort keys %$actions;
+ @actions = map $actions[($_ + ($_ % 2) * @actions) / 2], 0..$#actions;
+
+ my $out = '';
+ while (my ($one, $two) = splice @actions, 0, 2) {
+ $out .= sprintf(" %-12s %-12s\n", $one, $two||'');
+ }
+ return $out;
+}
+
+sub ACTION_test {
+ my ($self) = @_;
+ my $p = $self->{properties};
+ require Test::Harness;
+
+ $self->depends_on('code');
+
+ # Do everything in our power to work with all versions of Test::Harness
+ my @harness_switches = $p->{debugger} ? qw(-w -d) : ();
+ local $Test::Harness::switches = join ' ', grep defined, $Test::Harness::switches, @harness_switches;
+ local $Test::Harness::Switches = join ' ', grep defined, $Test::Harness::Switches, @harness_switches;
+ local $ENV{HARNESS_PERL_SWITCHES} = join ' ', grep defined, $ENV{HARNESS_PERL_SWITCHES}, @harness_switches;
+
+ $Test::Harness::switches = undef unless length $Test::Harness::switches;
+ $Test::Harness::Switches = undef unless length $Test::Harness::Switches;
+ delete $ENV{HARNESS_PERL_SWITCHES} unless length $ENV{HARNESS_PERL_SWITCHES};
+
+ local ($Test::Harness::verbose,
+ $Test::Harness::Verbose,
+ $ENV{TEST_VERBOSE},
+ $ENV{HARNESS_VERBOSE}) = ($p->{verbose} || 0) x 4;
+
+ # Make sure we test the module in blib/
+ local @INC = (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'),
+ File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'),
+ @INC);
+
+ # Filter out nonsensical @INC entries - some versions of
+ # Test::Harness will really explode the number of entries here
+ @INC = grep {ref() || -d} @INC if @INC > 100;
+
+ my $tests = $self->find_test_files;
+
+ if (@$tests) {
+ # Work around a Test::Harness bug that loses the particular perl
+ # we're running under. $self->perl is trustworthy, but $^X isn't.
+ local $^X = $self->perl;
+ Test::Harness::runtests(@$tests);
+ } else {
+ $self->log_info("No tests defined.\n");
+ }
+
+ # This will get run and the user will see the output. It doesn't
+ # emit Test::Harness-style output.
+ if (-e 'visual.pl') {
+ $self->run_perl_script('visual.pl', '-Mblib='.$self->blib);
+ }
+}
+
+sub test_files {
+ my $self = shift;
+ my $p = $self->{properties};
+ if (@_) {
+ return $p->{test_files} = (@_ == 1 ? shift : [@_]);
+ }
+ return $self->find_test_files;
+}
+
+sub expand_test_dir {
+ my ($self, $dir) = @_;
+ return sort @{$self->rscan_dir($dir, qr{^[^.].*\.t$})} if $self->recursive_test_files;
+ return sort glob File::Spec->catfile($dir, "*.t");
+}
+
+sub ACTION_testdb {
+ my ($self) = @_;
+ local $self->{properties}{debugger} = 1;
+ $self->depends_on('test');
+}
+
+sub ACTION_testcover {
+ my ($self) = @_;
+
+ unless (Module::Build::ModuleInfo->find_module_by_name('Devel::Cover')) {
+ warn("Cannot run testcover action unless Devel::Cover is installed.\n");
+ return;
+ }
+
+ $self->add_to_cleanup('coverage', 'cover_db');
+ $self->depends_on('code');
+
+ # See whether any of the *.pm files have changed since last time
+ # testcover was run. If so, start over.
+ if (-e 'cover_db') {
+ my $pm_files = $self->rscan_dir(File::Spec->catdir($self->blib, 'lib'), qr{\.pm$} );
+ my $cover_files = $self->rscan_dir('cover_db', sub {-f $_ and not /\.html$/});
+
+ $self->do_system(qw(cover -delete))
+ unless $self->up_to_date($pm_files, $cover_files);
+ }
+
+ local $Test::Harness::switches =
+ local $Test::Harness::Switches =
+ local $ENV{HARNESS_PERL_SWITCHES} = "-MDevel::Cover";
+
+ $self->depends_on('test');
+ $self->do_system('cover');
+}
+
+sub ACTION_code {
+ my ($self) = @_;
+
+ # All installable stuff gets created in blib/ .
+ # Create blib/arch to keep blib.pm happy
+ my $blib = $self->blib;
+ $self->add_to_cleanup($blib);
+ File::Path::mkpath( File::Spec->catdir($blib, 'arch') );
+
+ if (my $split = $self->autosplit) {
+ $self->autosplit_file($_, $blib) for ref($split) ? @$split : ($split);
+ }
+
+ foreach my $element (@{$self->build_elements}) {
+ my $method = "process_${element}_files";
+ $method = "process_files_by_extension" unless $self->can($method);
+ $self->$method($element);
+ }
+
+ $self->depends_on('config_data');
+}
+
+sub ACTION_build {
+ my $self = shift;
+ $self->depends_on('code');
+ $self->depends_on('docs');
+}
+
+sub process_files_by_extension {
+ my ($self, $ext) = @_;
+
+ my $method = "find_${ext}_files";
+ my $files = $self->can($method) ? $self->$method() : $self->_find_file_by_type($ext, 'lib');
+
+ while (my ($file, $dest) = each %$files) {
+ $self->copy_if_modified(from => $file, to => File::Spec->catfile($self->blib, $dest) );
+ }
+}
+
+sub process_support_files {
+ my $self = shift;
+ my $p = $self->{properties};
+ return unless $p->{c_source};
+
+ push @{$p->{include_dirs}}, $p->{c_source};
+
+ my $files = $self->rscan_dir($p->{c_source}, qr{\.c(pp)?$});
+ foreach my $file (@$files) {
+ push @{$p->{objects}}, $self->compile_c($file);
+ }
+}
+
+sub process_PL_files {
+ my ($self) = @_;
+ my $files = $self->find_PL_files;
+
+ while (my ($file, $to) = each %$files) {
+ unless ($self->up_to_date( $file, $to )) {
+ $self->run_perl_script($file, [], [@$to]);
+ $self->add_to_cleanup(@$to);
+ }
+ }
+}
+
+sub process_xs_files {
+ my $self = shift;
+ my $files = $self->find_xs_files;
+ while (my ($from, $to) = each %$files) {
+ unless ($from eq $to) {
+ $self->add_to_cleanup($to);
+ $self->copy_if_modified( from => $from, to => $to );
+ }
+ $self->process_xs($to);
+ }
+}
+
+sub process_pod_files { shift()->process_files_by_extension(shift()) }
+sub process_pm_files { shift()->process_files_by_extension(shift()) }
+
+sub process_script_files {
+ my $self = shift;
+ my $files = $self->find_script_files;
+ return unless keys %$files;
+
+ my $script_dir = File::Spec->catdir($self->blib, 'script');
+ File::Path::mkpath( $script_dir );
+
+ foreach my $file (keys %$files) {
+ my $result = $self->copy_if_modified($file, $script_dir, 'flatten') or next;
+ $self->fix_shebang_line($result);
+ $self->make_executable($result);
+ }
+}
+
+sub find_PL_files {
+ my $self = shift;
+ if (my $files = $self->{properties}{PL_files}) {
+ # 'PL_files' is given as a Unix file spec, so we localize_file_path().
+
+ if (UNIVERSAL::isa($files, 'ARRAY')) {
+ return { map {$_, [/^(.*)\.PL$/]}
+ map $self->localize_file_path($_),
+ @$files };
+
+ } elsif (UNIVERSAL::isa($files, 'HASH')) {
+ my %out;
+ while (my ($file, $to) = each %$files) {
+ $out{ $self->localize_file_path($file) } = [ map $self->localize_file_path($_),
+ ref $to ? @$to : ($to) ];
+ }
+ return \%out;
+
+ } else {
+ die "'PL_files' must be a hash reference or array reference";
+ }
+ }
+
+ return unless -d 'lib';
+ return { map {$_, [/^(.*)\.PL$/]} @{ $self->rscan_dir('lib', qr{\.PL$}) } };
+}
+
+sub find_pm_files { shift->_find_file_by_type('pm', 'lib') }
+sub find_pod_files { shift->_find_file_by_type('pod', 'lib') }
+sub find_xs_files { shift->_find_file_by_type('xs', 'lib') }
+
+sub find_script_files {
+ my $self = shift;
+ if (my $files = $self->script_files) {
+ # Always given as a Unix file spec. Values in the hash are
+ # meaningless, but we preserve if present.
+ return { map {$self->localize_file_path($_), $files->{$_}} keys %$files };
+ }
+
+ # No default location for script files
+ return {};
+}
+
+sub find_test_files {
+ my $self = shift;
+ my $p = $self->{properties};
+
+ if (my $files = $p->{test_files}) {
+ $files = [keys %$files] if UNIVERSAL::isa($files, 'HASH');
+ $files = [map { -d $_ ? $self->expand_test_dir($_) : $_ }
+ map glob,
+ $self->split_like_shell($files)];
+
+ # Always given as a Unix file spec.
+ return [ map $self->localize_file_path($_), @$files ];
+
+ } else {
+ # Find all possible tests in t/ or test.pl
+ my @tests;
+ push @tests, 'test.pl' if -e 'test.pl';
+ push @tests, $self->expand_test_dir('t') if -e 't' and -d _;
+ return \@tests;
+ }
+}
+
+sub _find_file_by_type {
+ my ($self, $type, $dir) = @_;
+
+ if (my $files = $self->{properties}{"${type}_files"}) {
+ # Always given as a Unix file spec
+ return { map $self->localize_file_path($_), %$files };
+ }
+
+ return {} unless -d $dir;
+ return { map {$_, $_}
+ map $self->localize_file_path($_),
+ grep !/\.\#/,
+ @{ $self->rscan_dir($dir, qr{\.$type$}) } };
+}
+
+sub localize_file_path {
+ my ($self, $path) = @_;
+ return File::Spec->catfile( split m{/}, $path );
+}
+
+sub localize_dir_path {
+ my ($self, $path) = @_;
+ return File::Spec->catdir( split m{/}, $path );
+}
+
+sub fix_shebang_line { # Adapted from fixin() in ExtUtils::MM_Unix 1.35
+ my ($self, @files) = @_;
+ my $c = $self->config;
+
+ my ($does_shbang) = $c->{sharpbang} =~ /^\s*\#\!/;
+ for my $file (@files) {
+ my $FIXIN = IO::File->new($file) or die "Can't process '$file': $!";
+ local $/ = "\n";
+ chomp(my $line = <$FIXIN>);
+ next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
+
+ my ($cmd, $arg) = (split(' ', $line, 2), '');
+ next unless $cmd =~ /perl/i;
+ my $interpreter = $self->{properties}{perl};
+
+ $self->log_verbose("Changing sharpbang in $file to $interpreter");
+ my $shb = '';
+ $shb .= "$c->{sharpbang}$interpreter $arg\n" if $does_shbang;
+
+ # I'm not smart enough to know the ramifications of changing the
+ # embedded newlines here to \n, so I leave 'em in.
+ $shb .= qq{
+eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
+ if 0; # not running under some shell
+} unless $self->os_type eq 'Windows'; # this won't work on win32, so don't
+
+ my $FIXOUT = IO::File->new(">$file.new")
+ or die "Can't create new $file: $!\n";
+
+ # Print out the new #! line (or equivalent).
+ local $\;
+ undef $/; # Was localized above
+ print $FIXOUT $shb, <$FIXIN>;
+ close $FIXIN;
+ close $FIXOUT;
+
+ rename($file, "$file.bak")
+ or die "Can't rename $file to $file.bak: $!";
+
+ rename("$file.new", $file)
+ or die "Can't rename $file.new to $file: $!";
+
+ unlink "$file.bak"
+ or $self->log_warn("Couldn't clean up $file.bak, leaving it there");
+
+ $self->do_system($c->{eunicefix}, $file) if $c->{eunicefix} ne ':';
+ }
+}
+
+
+sub ACTION_testpod {
+ my $self = shift;
+ $self->depends_on('docs');
+
+ eval q{use Test::Pod 0.95; 1}
+ or die "The 'testpod' action requires Test::Pod version 0.95";
+
+ my @files = sort keys %{$self->_find_pods($self->libdoc_dirs)},
+ keys %{$self->_find_pods($self->bindoc_dirs, exclude => [ qr/\.bat$/ ])}
+ or die "Couldn't find any POD files to test\n";
+
+ { package Module::Build::PodTester; # Don't want to pollute the main namespace
+ Test::Pod->import( tests => scalar @files );
+ pod_file_ok($_) foreach @files;
+ }
+}
+
+sub ACTION_docs {
+ my $self = shift;
+
+ $self->depends_on('code');
+ $self->depends_on('manpages', 'html');
+}
+
+# Given a file type, will return true if the file type would normally
+# be installed when neither install-base nor prefix has been set.
+# I.e. it will be true only if the path is set from Config.pm or
+# set explicitly by the user via install-path.
+sub _is_default_installable {
+ my $self = shift;
+ my $type = shift;
+ return ( $self->install_destination($type) &&
+ ( $self->install_path($type) ||
+ $self->install_sets($self->installdirs)->{$type} )
+ ) ? 1 : 0;
+}
+
+sub ACTION_manpages {
+ my $self = shift;
+
+ return unless $self->_mb_feature('manpage_support');
+
+ $self->depends_on('code');
+
+ foreach my $type ( qw(bin lib) ) {
+ my $files = $self->_find_pods( $self->{properties}{"${type}doc_dirs"},
+ exclude => [ qr/\.bat$/ ] );
+ next unless %$files;
+
+ my $sub = $self->can("manify_${type}_pods");
+ next unless defined( $sub );
+
+ if ( $self->invoked_action eq 'manpages' ) {
+ $self->$sub();
+ } elsif ( $self->_is_default_installable("${type}doc") ) {
+ $self->$sub();
+ }
+ }
+
+}
+
+sub manify_bin_pods {
+ my $self = shift;
+
+ my $files = $self->_find_pods( $self->{properties}{bindoc_dirs},
+ exclude => [ qr/\.bat$/ ] );
+ return unless keys %$files;
+
+ my $mandir = File::Spec->catdir( $self->blib, 'bindoc' );
+ File::Path::mkpath( $mandir, 0, 0777 );
+
+ require Pod::Man;
+ foreach my $file (keys %$files) {
+ # Pod::Simple based parsers only support one document per instance.
+ # This is expected to change in a future version (Pod::Simple > 3.03).
+ my $parser = Pod::Man->new( section => 1 ); # binaries go in section 1
+ my $manpage = $self->man1page_name( $file ) . '.' .
+ $self->config( 'man1ext' );
+ my $outfile = File::Spec->catfile($mandir, $manpage);
+ next if $self->up_to_date( $file, $outfile );
+ $self->log_info("Manifying $file -> $outfile\n");
+ $parser->parse_from_file( $file, $outfile );
+ $files->{$file} = $outfile;
+ }
+}
+
+sub manify_lib_pods {
+ my $self = shift;
+
+ my $files = $self->_find_pods($self->{properties}{libdoc_dirs});
+ return unless keys %$files;
+
+ my $mandir = File::Spec->catdir( $self->blib, 'libdoc' );
+ File::Path::mkpath( $mandir, 0, 0777 );
+
+ require Pod::Man;
+ while (my ($file, $relfile) = each %$files) {
+ # Pod::Simple based parsers only support one document per instance.
+ # This is expected to change in a future version (Pod::Simple > 3.03).
+ my $parser = Pod::Man->new( section => 3 ); # libraries go in section 3
+ my $manpage = $self->man3page_name( $relfile ) . '.' .
+ $self->config( 'man3ext' );
+ my $outfile = File::Spec->catfile( $mandir, $manpage);
+ next if $self->up_to_date( $file, $outfile );
+ $self->log_info("Manifying $file -> $outfile\n");
+ $parser->parse_from_file( $file, $outfile );
+ $files->{$file} = $outfile;
+ }
+}
+
+sub _find_pods {
+ my ($self, $dirs, %args) = @_;
+ my %files;
+ foreach my $spec (@$dirs) {
+ my $dir = $self->localize_dir_path($spec);
+ next unless -e $dir;
+ FILE: foreach my $file ( @{ $self->rscan_dir( $dir ) } ) {
+ foreach my $regexp ( @{ $args{exclude} } ) {
+ next FILE if $file =~ $regexp;
+ }
+ $files{$file} = File::Spec->abs2rel($file, $dir) if $self->contains_pod( $file )
+ }
+ }
+ return \%files;
+}
+
+sub contains_pod {
+ my ($self, $file) = @_;
+ return '' unless -T $file; # Only look at text files
+
+ my $fh = IO::File->new( $file ) or die "Can't open $file: $!";
+ while (my $line = <$fh>) {
+ return 1 if $line =~ /^\=(?:head|pod|item)/;
+ }
+
+ return '';
+}
+
+sub ACTION_html {
+ my $self = shift;
+
+ return unless $self->_mb_feature('HTML_support');
+
+ $self->depends_on('code');
+
+ foreach my $type ( qw(bin lib) ) {
+ my $files = $self->_find_pods( $self->{properties}{"${type}doc_dirs"},
+ exclude => [ qr/\.(?:bat|com|html)$/ ] );
+ next unless %$files;
+
+ if ( $self->invoked_action eq 'html' ) {
+ $self->htmlify_pods( $type );
+ } elsif ( $self->_is_default_installable("${type}html") ) {
+ $self->htmlify_pods( $type );
+ }
+ }
+
+}
+
+
+# 1) If it's an ActiveState perl install, we need to run
+# ActivePerl::DocTools->UpdateTOC;
+# 2) Links to other modules are not being generated
+sub htmlify_pods {
+ my $self = shift;
+ my $type = shift;
+ my $htmldir = shift || File::Spec->catdir($self->blib, "${type}html");
+
+ require Module::Build::PodParser;
+ require Pod::Html;
+
+ $self->add_to_cleanup('pod2htm*');
+
+ my $pods = $self->_find_pods( $self->{properties}{"${type}doc_dirs"},
+ exclude => [ qr/\.(?:bat|com|html)$/ ] );
+ next unless %$pods; # nothing to do
+
+ unless ( -d $htmldir ) {
+ File::Path::mkpath($htmldir, 0, 0755)
+ or die "Couldn't mkdir $htmldir: $!";
+ }
+
+ my @rootdirs = ($type eq 'bin') ? qw(bin) :
+ $self->installdirs eq 'core' ? qw(lib) : qw(site lib);
+
+ my $podpath = join ':',
+ map $_->[1],
+ grep -e $_->[0],
+ map [File::Spec->catdir($self->blib, $_), $_],
+ qw( script lib );
+
+ foreach my $pod ( keys %$pods ) {
+
+ my ($name, $path) = File::Basename::fileparse($pods->{$pod},
+ qr{\.(?:pm|plx?|pod)$});
+ my @dirs = File::Spec->splitdir( File::Spec->canonpath( $path ) );
+ pop( @dirs ) if $dirs[-1] eq File::Spec->curdir;
+
+ my $fulldir = File::Spec->catfile($htmldir, @rootdirs, @dirs);
+ my $outfile = File::Spec->catfile($fulldir, "${name}.html");
+ my $infile = File::Spec->abs2rel($pod);
+
+ next if $self->up_to_date($infile, $outfile);
+
+ unless ( -d $fulldir ){
+ File::Path::mkpath($fulldir, 0, 0755)
+ or die "Couldn't mkdir $fulldir: $!";
+ }
+
+ my $path2root = join( '/', ('..') x (@rootdirs+@dirs) );
+ my $htmlroot = join( '/',
+ ($path2root,
+ $self->installdirs eq 'core' ? () : qw(site) ) );
+
+ my $fh = IO::File->new($infile);
+ my $abstract = Module::Build::PodParser->new(fh => $fh)->get_abstract();
+
+ my $title = join( '::', (@dirs, $name) );
+ $title .= " - $abstract" if $abstract;
+
+ my @opts = (
+ '--flush',
+ "--title=$title",
+ "--podpath=$podpath",
+ "--infile=$infile",
+ "--outfile=$outfile",
+ '--podroot=' . $self->blib,
+ "--htmlroot=$htmlroot",
+ );
+
+ if ( eval{Pod::Html->VERSION(1.03)} ) {
+ push( @opts, ('--header', '--backlink=Back to Top') );
+ push( @opts, "--css=$path2root/" . $self->html_css) if $self->html_css;
+ }
+
+ $self->log_info("HTMLifying $infile -> $outfile\n");
+ $self->log_verbose("pod2html @opts\n");
+ Pod::Html::pod2html(@opts); # or warn "pod2html @opts failed: $!";
+ }
+
+}
+
+# Adapted from ExtUtils::MM_Unix
+sub man1page_name {
+ my $self = shift;
+ return File::Basename::basename( shift );
+}
+
+# Adapted from ExtUtils::MM_Unix and Pod::Man
+# Depending on M::B's dependency policy, it might make more sense to refactor
+# Pod::Man::begin_pod() to extract a name() methods, and use them...
+# -spurkis
+sub man3page_name {
+ my $self = shift;
+ my ($vol, $dirs, $file) = File::Spec->splitpath( shift );
+ my @dirs = File::Spec->splitdir( File::Spec->canonpath($dirs) );
+
+ # Remove known exts from the base name
+ $file =~ s/\.p(?:od|m|l)\z//i;
+
+ return join( $self->manpage_separator, @dirs, $file );
+}
+
+sub manpage_separator {
+ return '::';
+}
+
+# For systems that don't have 'diff' executable, should use Algorithm::Diff
+sub ACTION_diff {
+ my $self = shift;
+ $self->depends_on('build');
+ my $local_lib = File::Spec->rel2abs('lib');
+ my @myINC = grep {$_ ne $local_lib} @INC;
+
+ # The actual install destination might not be in @INC, so check there too.
+ push @myINC, map $self->install_destination($_), qw(lib arch);
+
+ my @flags = @{$self->{args}{ARGV}};
+ @flags = $self->split_like_shell($self->{args}{flags} || '') unless @flags;
+
+ my $installmap = $self->install_map;
+ delete $installmap->{read};
+ delete $installmap->{write};
+
+ my $text_suffix = qr{\.(pm|pod)$};
+
+ while (my $localdir = each %$installmap) {
+ my @localparts = File::Spec->splitdir($localdir);
+ my $files = $self->rscan_dir($localdir, sub {-f});
+
+ foreach my $file (@$files) {
+ my @parts = File::Spec->splitdir($file);
+ @parts = @parts[@localparts .. $#parts]; # Get rid of blib/lib or similar
+
+ my $installed = Module::Build::ModuleInfo->find_module_by_name(
+ join('::', @parts), \@myINC );
+ if (not $installed) {
+ print "Only in lib: $file\n";
+ next;
+ }
+
+ my $status = File::Compare::compare($installed, $file);
+ next if $status == 0; # Files are the same
+ die "Can't compare $installed and $file: $!" if $status == -1;
+
+ if ($file =~ $text_suffix) {
+ $self->do_system('diff', @flags, $installed, $file);
+ } else {
+ print "Binary files $file and $installed differ\n";
+ }
+ }
+ }
+}
+
+sub ACTION_pure_install {
+ shift()->depends_on('install');
+}
+
+sub ACTION_install {
+ my ($self) = @_;
+ require ExtUtils::Install;
+ $self->depends_on('build');
+ ExtUtils::Install::install($self->install_map, !$self->quiet, 0, $self->{args}{uninst}||0);
+}
+
+sub ACTION_fakeinstall {
+ my ($self) = @_;
+ require ExtUtils::Install;
+ $self->depends_on('build');
+ ExtUtils::Install::install($self->install_map, !$self->quiet, 1, $self->{args}{uninst}||0);
+}
+
+sub ACTION_versioninstall {
+ my ($self) = @_;
+
+ die "You must have only.pm 0.25 or greater installed for this operation: $@\n"
+ unless eval { require only; 'only'->VERSION(0.25); 1 };
+
+ $self->depends_on('build');
+
+ my %onlyargs = map {exists($self->{args}{$_}) ? ($_ => $self->{args}{$_}) : ()}
+ qw(version versionlib);
+ only::install::install(%onlyargs);
+}
+
+sub ACTION_clean {
+ my ($self) = @_;
+ foreach my $item (map glob($_), $self->cleanup) {
+ $self->delete_filetree($item);
+ }
+}
+
+sub ACTION_realclean {
+ my ($self) = @_;
+ $self->depends_on('clean');
+ $self->delete_filetree($self->config_dir, $self->build_script);
+}
+
+sub ACTION_ppd {
+ my ($self) = @_;
+ require Module::Build::PPMMaker;
+ my $ppd = Module::Build::PPMMaker->new();
+ my $file = $ppd->make_ppd(%{$self->{args}}, build => $self);
+ $self->add_to_cleanup($file);
+}
+
+sub ACTION_ppmdist {
+ my ($self) = @_;
+
+ $self->depends_on( 'build' );
+
+ my $ppm = $self->ppm_name;
+ $self->delete_filetree( $ppm );
+ $self->log_info( "Creating $ppm\n" );
+ $self->add_to_cleanup( $ppm, "$ppm.tar.gz" );
+
+ my %types = ( # translate types/dirs to those expected by ppm
+ lib => 'lib',
+ arch => 'arch',
+ bin => 'bin',
+ script => 'script',
+ bindoc => 'man1',
+ libdoc => 'man3',
+ binhtml => undef,
+ libhtml => undef,
+ );
+
+ foreach my $type ($self->install_types) {
+ next if exists( $types{$type} ) && !defined( $types{$type} );
+
+ my $dir = File::Spec->catdir( $self->blib, $type );
+ next unless -e $dir;
+
+ my $files = $self->rscan_dir( $dir );
+ foreach my $file ( @$files ) {
+ next unless -f $file;
+ my $rel_file =
+ File::Spec->abs2rel( File::Spec->rel2abs( $file ),
+ File::Spec->rel2abs( $dir ) );
+ my $to_file =
+ File::Spec->catdir( $ppm, 'blib',
+ exists( $types{$type} ) ? $types{$type} : $type,
+ $rel_file );
+ $self->copy_if_modified( from => $file, to => $to_file );
+ }
+ }
+
+ foreach my $type ( qw(bin lib) ) {
+ local $self->{properties}{html_css} = 'Active.css';
+ $self->htmlify_pods( $type, File::Spec->catdir($ppm, 'blib', 'html') );
+ }
+
+ # create a tarball;
+ # the directory tar'ed must be blib so we need to do a chdir first
+ my $start_wd = $self->cwd;
+ chdir( $ppm ) or die "Can't chdir to $ppm";
+ $self->make_tarball( 'blib', File::Spec->catfile( $start_wd, $ppm ) );
+ chdir( $start_wd ) or die "Can't chdir to $start_wd";
+
+ $self->depends_on( 'ppd' );
+
+ $self->delete_filetree( $ppm );
+}
+
+sub ACTION_dist {
+ my ($self) = @_;
+
+ $self->depends_on('distdir');
+
+ my $dist_dir = $self->dist_dir;
+
+ $self->make_tarball($dist_dir);
+ $self->delete_filetree($dist_dir);
+}
+
+sub ACTION_distcheck {
+ my ($self) = @_;
+
+ require ExtUtils::Manifest;
+ local $^W; # ExtUtils::Manifest is not warnings clean.
+ my ($missing, $extra) = ExtUtils::Manifest::fullcheck();
+ die "MANIFEST appears to be out of sync with the distribution\n"
+ if @$missing || @$extra;
+}
+
+sub _add_to_manifest {
+ my ($self, $manifest, $lines) = @_;
+ $lines = [$lines] unless ref $lines;
+
+ my $existing_files = $self->_read_manifest($manifest);
+ return unless defined( $existing_files );
+
+ @$lines = grep {!exists $existing_files->{$_}} @$lines
+ or return;
+
+ my $mode = (stat $manifest)[2];
+ chmod($mode | 0222, $manifest) or die "Can't make $manifest writable: $!";
+
+ my $fh = IO::File->new("< $manifest") or die "Can't read $manifest: $!";
+ my $last_line = (<$fh>)[-1] || "\n";
+ my $has_newline = $last_line =~ /\n$/;
+ $fh->close;
+
+ $fh = IO::File->new(">> $manifest") or die "Can't write to $manifest: $!";
+ print $fh "\n" unless $has_newline;
+ print $fh map "$_\n", @$lines;
+ close $fh;
+ chmod($mode, $manifest);
+
+ $self->log_info(map "Added to $manifest: $_\n", @$lines);
+}
+
+sub _sign_dir {
+ my ($self, $dir) = @_;
+
+ unless (eval { require Module::Signature; 1 }) {
+ $self->log_warn("Couldn't load Module::Signature for 'distsign' action:\n $@\n");
+ return;
+ }
+
+ # Add SIGNATURE to the MANIFEST
+ {
+ my $manifest = File::Spec->catfile($dir, 'MANIFEST');
+ die "Signing a distribution requires a MANIFEST file" unless -e $manifest;
+ $self->_add_to_manifest($manifest, "SIGNATURE Added here by Module::Build");
+ }
+
+ # We protect the signing with an eval{} to make sure we get back to
+ # the right directory after a signature failure. Would be nice if
+ # Module::Signature took a directory argument.
+
+ my $start_dir = $self->cwd;
+ chdir $dir or die "Can't chdir() to $dir: $!";
+ eval {local $Module::Signature::Quiet = 1; Module::Signature::sign()};
+ my @err = $@ ? ($@) : ();
+ chdir $start_dir or push @err, "Can't chdir() back to $start_dir: $!";
+ die join "\n", @err if @err;
+}
+
+sub ACTION_distsign {
+ my ($self) = @_;
+ {
+ local $self->{properties}{sign} = 0; # We'll sign it ourselves
+ $self->depends_on('distdir') unless -d $self->dist_dir;
+ }
+ $self->_sign_dir($self->dist_dir);
+}
+
+sub ACTION_skipcheck {
+ my ($self) = @_;
+
+ require ExtUtils::Manifest;
+ local $^W; # ExtUtils::Manifest is not warnings clean.
+ ExtUtils::Manifest::skipcheck();
+}
+
+sub ACTION_distclean {
+ my ($self) = @_;
+
+ $self->depends_on('realclean');
+ $self->depends_on('distcheck');
+}
+
+sub do_create_makefile_pl {
+ my $self = shift;
+ require Module::Build::Compat;
+ $self->delete_filetree('Makefile.PL');
+ $self->log_info("Creating Makefile.PL\n");
+ Module::Build::Compat->create_makefile_pl($self->create_makefile_pl, $self, @_);
+ $self->_add_to_manifest('MANIFEST', 'Makefile.PL');
+}
+
+sub do_create_readme {
+ my $self = shift;
+ $self->delete_filetree('README');
+
+ my $docfile = $self->_main_docfile;
+ unless ( $docfile ) {
+ $self->log_warn(<<EOF);
+Cannot create README: can't determine which file contains documentation;
+Must supply either 'dist_version_from', or 'module_name' parameter.
+EOF
+ return;
+ }
+
+ if ( eval {require Pod::Readme; 1} ) {
+ $self->log_info("Creating README using Pod::Readme\n");
+
+ my $parser = Pod::Readme->new;
+ $parser->parse_from_file($docfile, 'README', @_);
+
+ } elsif ( eval {require Pod::Text; 1} ) {
+ $self->log_info("Creating README using Pod::Text\n");
+
+ my $fh = IO::File->new('> README');
+ if ( defined($fh) ) {
+ local $^W = 0;
+ no strict "refs";
+
+ # work around bug in Pod::Text 3.01, which expects
+ # Pod::Simple::parse_file to take input and output filehandles
+ # when it actually only takes an input filehandle
+
+ my $old_parse_file;
+ $old_parse_file = \&{"Pod::Simple::parse_file"}
+ and
+ local *{"Pod::Simple::parse_file"} = sub {
+ my $self = shift;
+ $self->output_fh($_[1]) if $_[1];
+ $self->$old_parse_file($_[0]);
+ }
+ if $Pod::Text::VERSION
+ == 3.01; # Split line to avoid evil version-finder
+
+ Pod::Text::pod2text( $docfile, $fh );
+
+ $fh->close;
+ } else {
+ $self->log_warn(
+ "Cannot create 'README' file: Can't open file for writing\n" );
+ return;
+ }
+
+ } else {
+ $self->log_warn("Can't load Pod::Readme or Pod::Text to create README\n");
+ return;
+ }
+
+ $self->_add_to_manifest('MANIFEST', 'README');
+}
+
+sub _main_docfile {
+ my $self = shift;
+ $self->_find_dist_version_from;
+ if ( my $pm_file = $self->dist_version_from ) {
+ (my $pod_file = $pm_file) =~ s/.pm$/.pod/;
+ return (-e $pod_file ? $pod_file : $pm_file);
+ } else {
+ return undef;
+ }
+}
+
+sub ACTION_distdir {
+ my ($self) = @_;
+
+ $self->depends_on('distmeta');
+
+ my $dist_files = $self->_read_manifest('MANIFEST')
+ or die "Can't create distdir without a MANIFEST file - run 'manifest' action first";
+ delete $dist_files->{SIGNATURE}; # Don't copy, create a fresh one
+ die "No files found in MANIFEST - try running 'manifest' action?\n"
+ unless ($dist_files and keys %$dist_files);
+ my $metafile = $self->metafile;
+ $self->log_warn("*** Did you forget to add $metafile to the MANIFEST?\n")
+ unless exists $dist_files->{$metafile};
+
+ my $dist_dir = $self->dist_dir;
+ $self->delete_filetree($dist_dir);
+ $self->log_info("Creating $dist_dir\n");
+ $self->add_to_cleanup($dist_dir);
+
+ foreach my $file (keys %$dist_files) {
+ my $new = $self->copy_if_modified(from => $file, to_dir => $dist_dir, verbose => 0);
+ chmod +(stat $file)[2], $new
+ or $self->log_warn("Couldn't set permissions on $new: $!");
+ }
+
+ $self->_sign_dir($dist_dir) if $self->{properties}{sign};
+}
+
+sub ACTION_disttest {
+ my ($self) = @_;
+
+ $self->depends_on('distdir');
+
+ my $start_dir = $self->cwd;
+ my $dist_dir = $self->dist_dir;
+ chdir $dist_dir or die "Cannot chdir to $dist_dir: $!";
+ # XXX could be different names for scripts
+
+ $self->run_perl_script('Build.PL') # XXX Should this be run w/ --nouse-rcfile
+ or die "Error executing 'Build.PL' in dist directory: $!";
+ $self->run_perl_script('Build')
+ or die "Error executing 'Build' in dist directory: $!";
+ $self->run_perl_script('Build', [], ['test'])
+ or die "Error executing 'Build test' in dist directory";
+ chdir $start_dir;
+}
+
+sub _write_default_maniskip {
+ my $self = shift;
+ my $file = shift || 'MANIFEST.SKIP';
+ my $fh = IO::File->new("> $file")
+ or die "Can't open $file: $!";
+
+ # This is derived from MakeMaker's default MANIFEST.SKIP file with
+ # some new entries
+
+ print $fh <<'EOF';
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+\B\.cvsignore$
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+
+# Avoid Devel::Cover generated files
+\bcover_db
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\.#
+\.rej$
+
+# Avoid OS-specific files/dirs
+# Mac OSX metadata
+\B\.DS_Store
+# Mac OSX SMB mount metadata files
+\B\._
+# Avoid archives of this distribution
+EOF
+
+ # Skip, for example, 'Module-Build-0.27.tar.gz'
+ print $fh '\b'.$self->dist_name.'-[\d\.\_]+'."\n";
+
+ $fh->close();
+}
+
+sub ACTION_manifest {
+ my ($self) = @_;
+
+ my $maniskip = 'MANIFEST.SKIP';
+ unless ( -e 'MANIFEST' || -e $maniskip ) {
+ $self->log_warn("File '$maniskip' does not exist: Creating a default '$maniskip'\n");
+ $self->_write_default_maniskip($maniskip);
+ }
+
+ require ExtUtils::Manifest; # ExtUtils::Manifest is not warnings clean.
+ local ($^W, $ExtUtils::Manifest::Quiet) = (0,1);
+ ExtUtils::Manifest::mkmanifest();
+}
+
+sub dist_dir {
+ my ($self) = @_;
+ return "$self->{properties}{dist_name}-$self->{properties}{dist_version}";
+}
+
+sub ppm_name {
+ my $self = shift;
+ return 'PPM-' . $self->dist_dir;
+}
+
+sub _files_in {
+ my ($self, $dir) = @_;
+ return unless -d $dir;
+
+ local *DH;
+ opendir DH, $dir or die "Can't read directory $dir: $!";
+
+ my @files;
+ while (defined (my $file = readdir DH)) {
+ my $full_path = File::Spec->catfile($dir, $file);
+ next if -d $full_path;
+ push @files, $full_path;
+ }
+ return @files;
+}
+
+sub script_files {
+ my $self = shift;
+
+ for ($self->{properties}{script_files}) {
+ $_ = shift if @_;
+ next unless $_;
+
+ # Always coerce into a hash
+ return $_ if UNIVERSAL::isa($_, 'HASH');
+ return $_ = { map {$_,1} @$_ } if UNIVERSAL::isa($_, 'ARRAY');
+
+ die "'script_files' must be a hashref, arrayref, or string" if ref();
+
+ return $_ = { map {$_,1} $self->_files_in( $_ ) } if -d $_;
+ return $_ = {$_ => 1};
+ }
+
+ return $_ = { map {$_,1} $self->_files_in( File::Spec->catdir( $self->base_dir, 'bin' ) ) };
+}
+BEGIN { *scripts = \&script_files; }
+
+{
+ my %licenses =
+ (
+ perl => 'http://dev.perl.org/licenses/',
+ gpl => 'http://www.opensource.org/licenses/gpl-license.php',
+ apache => 'http://apache.org/licenses/LICENSE-2.0',
+ artistic => 'http://opensource.org/licenses/artistic-license.php',
+ lgpl => 'http://opensource.org/licenses/artistic-license.php',
+ bsd => 'http://www.opensource.org/licenses/bsd-license.php',
+ gpl => 'http://www.opensource.org/licenses/gpl-license.php',
+ mit => 'http://opensource.org/licenses/mit-license.php',
+ mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
+ open_source => undef,
+ unrestricted => undef,
+ restrictive => undef,
+ unknown => undef,
+ );
+ sub valid_licenses {
+ return \%licenses;
+ }
+}
+
+sub _hash_merge {
+ my ($self, $h, $k, $v) = @_;
+ if (ref $h->{$k} eq 'ARRAY') {
+ push @{$h->{$k}}, ref $v ? @$v : $v;
+ } elsif (ref $h->{$k} eq 'HASH') {
+ $h->{$k}{$_} = $v->{$_} foreach keys %$v;
+ } else {
+ $h->{$k} = $v;
+ }
+}
+
+sub _yaml_quote_string {
+ # XXX doesn't handle embedded newlines
+
+ my ($self, $string) = @_;
+ if ($string !~ /\"/) {
+ $string =~ s{\\}{\\\\}g;
+ return qq{"$string"};
+ } else {
+ $string =~ s{([\\'])}{\\$1}g;
+ return qq{'$string'};
+ }
+}
+
+sub _write_minimal_metadata {
+ my $self = shift;
+ my $p = $self->{properties};
+
+ my $file = $self->metafile;
+ my $fh = IO::File->new("> $file")
+ or die "Can't open $file: $!";
+
+ my @author = map $self->_yaml_quote_string($_), @{$self->dist_author};
+ my $abstract = $self->_yaml_quote_string($self->dist_abstract);
+
+ # XXX Add the meta_add & meta_merge stuff
+
+ print $fh <<"EOF";
+--- #YAML:1.0
+name: $p->{dist_name}
+version: $p->{dist_version}
+author:
+@{[ join "\n", map " - $_", @author ]}
+abstract: $abstract
+license: $p->{license}
+generated_by: Module::Build version $Module::Build::VERSION, without YAML.pm
+EOF
+}
+
+sub ACTION_distmeta {
+ my ($self) = @_;
+
+ $self->do_create_makefile_pl if $self->create_makefile_pl;
+ $self->do_create_readme if $self->create_readme;
+ $self->do_create_metafile;
+}
+
+sub do_create_metafile {
+ my $self = shift;
+ return if $self->{wrote_metadata};
+
+ my $p = $self->{properties};
+ my $metafile = $self->metafile;
+
+ unless ($p->{license}) {
+ $self->log_warn("No license specified, setting license = 'unknown'\n");
+ $p->{license} = 'unknown';
+ }
+ unless (exists $self->valid_licenses->{ $p->{license} }) {
+ die "Unknown license type '$p->{license}'";
+ }
+
+ # If we're in the distdir, the metafile may exist and be non-writable.
+ $self->delete_filetree($metafile);
+ $self->log_info("Creating $metafile\n");
+
+ # Since we're building ourself, we have to do some special stuff
+ # here: the ConfigData module is found in blib/lib.
+ local @INC = @INC;
+ if (($self->module_name || '') eq 'Module::Build') {
+ $self->depends_on('config_data');
+ push @INC, File::Spec->catdir($self->blib, 'lib');
+ }
+
+ $self->write_metafile;
+}
+
+sub write_metafile {
+ my $self = shift;
+ my $metafile = $self->metafile;
+
+ if ($self->_mb_feature('YAML_support')) {
+ require YAML;
+ require YAML::Node;
+
+ # We use YAML::Node to get the order nice in the YAML file.
+ $self->prepare_metadata( my $node = YAML::Node->new({}) );
+
+ # YAML API changed after version 0.30
+ my $yaml_sub = $YAML::VERSION le '0.30' ? \&YAML::StoreFile : \&YAML::DumpFile;
+ $self->{wrote_metadata} = $yaml_sub->($metafile, $node );
+
+ } else {
+ $self->log_warn(<<EOF);
+
+Couldn't load YAML.pm, generating a minimal META.yml without it.
+Please check and edit the generated metadata, or consider installing YAML.pm.
+
+EOF
+
+ $self->_write_minimal_metadata;
+ }
+
+ $self->_add_to_manifest('MANIFEST', $metafile);
+}
+
+sub prepare_metadata {
+ my ($self, $node) = @_;
+ my $p = $self->{properties};
+
+ foreach (qw(dist_name dist_version dist_author dist_abstract license)) {
+ (my $name = $_) =~ s/^dist_//;
+ $node->{$name} = $self->$_();
+ die "ERROR: Missing required field '$name' for META.yml\n"
+ unless defined($node->{$name}) && length($node->{$name});
+ }
+
+ if (defined( $self->license ) &&
+ defined( my $url = $self->valid_licenses->{ $self->license } )) {
+ $node->{resources}{license} = $url;
+ }
+
+ foreach ( @{$self->prereq_action_types} ) {
+ $node->{$_} = $p->{$_} if exists $p->{$_} and keys %{ $p->{$_} };
+ }
+
+ $node->{dynamic_config} = $p->{dynamic_config} if exists $p->{dynamic_config};
+ my $pkgs = eval { $self->find_dist_packages };
+ if ($@) {
+ $self->log_warn("WARNING: Possible missing or corrupt 'MANIFEST' file.\n" .
+ "Nothing to enter for 'provides' field in META.yml\n");
+ } else {
+ $node->{provides} = $pkgs if %$pkgs;
+ }
+;
+ $node->{no_index} = $p->{no_index} if exists $p->{no_index};
+
+ $node->{generated_by} = "Module::Build version $Module::Build::VERSION";
+
+ $node->{'meta-spec'} = {
+ version => '1.2',
+ url => 'http://module-build.sourceforge.net/META-spec-v1.2.html',
+ };
+
+
+ while (my($k, $v) = each %{$self->meta_add}) {
+ $node->{$k} = $v;
+ }
+
+ while (my($k, $v) = each %{$self->meta_merge}) {
+ $self->_hash_merge($node, $k, $v);
+ }
+
+ return $node;
+}
+
+sub _read_manifest {
+ my ($self, $file) = @_;
+ return undef unless -e $file;
+
+ require ExtUtils::Manifest; # ExtUtils::Manifest is not warnings clean.
+ local ($^W, $ExtUtils::Manifest::Quiet) = (0,1);
+ return scalar ExtUtils::Manifest::maniread($file);
+}
+
+sub find_dist_packages {
+ my $self = shift;
+
+ # Only packages in .pm files are candidates for inclusion here.
+ # Only include things in the MANIFEST, not things in developer's
+ # private stock.
+
+ my $manifest = $self->_read_manifest('MANIFEST')
+ or die "Can't find dist packages without a MANIFEST file - run 'manifest' action first";
+
+ # Localize
+ my %dist_files = map { $self->localize_file_path($_) => $_ }
+ keys %$manifest;
+
+ my @pm_files = grep {exists $dist_files{$_}} keys %{ $self->find_pm_files };
+
+ # First, we enumerate all packages & versions,
+ # seperating into primary & alternative candidates
+ my( %prime, %alt );
+ foreach my $file (@pm_files) {
+ next if $dist_files{$file} =~ m{^t/}; # Skip things in t/
+
+ my @path = split( /\//, $dist_files{$file} );
+ (my $prime_package = join( '::', @path[1..$#path] )) =~ s/\.pm$//;
+
+ my $pm_info = Module::Build::ModuleInfo->new_from_file( $file );
+
+ foreach my $package ( $pm_info->packages_inside ) {
+ next if $package eq 'main'; # main can appear numerous times, ignore
+ next if grep /^_/, split( /::/, $package ); # private package, ignore
+
+ my $version = $pm_info->version( $package );
+
+ if ( $package eq $prime_package ) {
+ if ( exists( $prime{$package} ) ) {
+ # M::B::ModuleInfo will handle this conflict
+ die "Unexpected conflict in '$package'; multiple versions found.\n";
+ } else {
+ $prime{$package}{file} = $dist_files{$file};
+ $prime{$package}{version} = $version if defined( $version );
+ }
+ } else {
+ push( @{$alt{$package}}, {
+ file => $dist_files{$file},
+ version => $version,
+ } );
+ }
+ }
+ }
+
+ # Then we iterate over all the packages found above, identifying conflicts
+ # and selecting the "best" candidate for recording the file & version
+ # for each package.
+ foreach my $package ( keys( %alt ) ) {
+ my $result = $self->_resolve_module_versions( $alt{$package} );
+
+ if ( exists( $prime{$package} ) ) { # primary package selected
+
+ if ( $result->{err} ) {
+ # Use the selected primary package, but there are conflicting
+ # errors amoung multiple alternative packages that need to be
+ # reported
+ $self->log_warn(
+ "Found conflicting versions for package '$package'\n" .
+ " $prime{$package}{file} ($prime{$package}{version})\n" .
+ $result->{err}
+ );
+
+ } elsif ( defined( $result->{version} ) ) {
+ # There is a primary package selected, and exactly one
+ # alternative package
+
+ if ( exists( $prime{$package}{version} ) &&
+ defined( $prime{$package}{version} ) ) {
+ # Unless the version of the primary package agrees with the
+ # version of the alternative package, report a conflict
+ if ( $self->compare_versions( $prime{$package}{version}, '!=',
+ $result->{version} ) ) {
+ $self->log_warn(
+ "Found conflicting versions for package '$package'\n" .
+ " $prime{$package}{file} ($prime{$package}{version})\n" .
+ " $result->{file} ($result->{version})\n"
+ );
+ }
+
+ } else {
+ # The prime package selected has no version so, we choose to
+ # use any alternative package that does have a version
+ $prime{$package}{file} = $result->{file};
+ $prime{$package}{version} = $result->{version};
+ }
+
+ } else {
+ # no alt package found with a version, but we have a prime
+ # package so we use it whether it has a version or not
+ }
+
+ } else { # No primary package was selected, use the best alternative
+
+ if ( $result->{err} ) {
+ $self->log_warn(
+ "Found conflicting versions for package '$package'\n" .
+ $result->{err}
+ );
+ }
+
+ # Despite possible conflicting versions, we choose to record
+ # something rather than nothing
+ $prime{$package}{file} = $result->{file};
+ $prime{$package}{version} = $result->{version}
+ if defined( $result->{version} );
+ }
+ }
+
+ return \%prime;
+}
+
+# seperate out some of the conflict resolution logic from
+# $self->find_dist_packages(), above, into a helper function.
+#
+sub _resolve_module_versions {
+ my $self = shift;
+
+ my $packages = shift;
+
+ my( $file, $version );
+ my $err = '';
+ foreach my $p ( @$packages ) {
+ if ( defined( $p->{version} ) ) {
+ if ( defined( $version ) ) {
+ if ( $self->compare_versions( $version, '!=', $p->{version} ) ) {
+ $err .= " $p->{file} ($p->{version})\n";
+ } else {
+ # same version declared multiple times, ignore
+ }
+ } else {
+ $file = $p->{file};
+ $version = $p->{version};
+ }
+ }
+ $file ||= $p->{file} if defined( $p->{file} );
+ }
+
+ if ( $err ) {
+ $err = " $file ($version)\n" . $err;
+ }
+
+ my %result = (
+ file => $file,
+ version => $version,
+ err => $err
+ );
+
+ return \%result;
+}
+
+sub make_tarball {
+ my ($self, $dir, $file) = @_;
+ $file ||= $dir;
+
+ $self->log_info("Creating $file.tar.gz\n");
+
+ if ($self->{args}{tar}) {
+ my $tar_flags = $self->verbose ? 'cvf' : 'cf';
+ $self->do_system($self->split_like_shell($self->{args}{tar}), $tar_flags, "$file.tar", $dir);
+ $self->do_system($self->split_like_shell($self->{args}{gzip}), "$file.tar") if $self->{args}{gzip};
+ } else {
+ require Archive::Tar;
+ # Archive::Tar versions >= 1.09 use the following to enable a compatibility
+ # hack so that the resulting archive is compatible with older clients.
+ $Archive::Tar::DO_NOT_USE_PREFIX = 0;
+ my $files = $self->rscan_dir($dir);
+ Archive::Tar->create_archive("$file.tar.gz", 1, @$files);
+ }
+}
+
+sub install_base_relpaths {
+ # Usage: install_base_relpaths('lib') or install_base_relpaths();
+ my $self = shift;
+ my $map = $self->{properties}{install_base_relpaths};
+ return $map unless @_;
+
+ my $type = shift;
+ return unless exists $map->{$type};
+ return File::Spec->catdir(@{$map->{$type}});
+}
+
+
+# Translated from ExtUtils::MM_Any::init_INSTALL_from_PREFIX
+sub prefix_relative {
+ my ($self, $type) = @_;
+ my $installdirs = $self->installdirs;
+
+ my $relpath = $self->install_sets($installdirs)->{$type};
+
+ return $self->_prefixify($relpath,
+ $self->original_prefix($installdirs),
+ $type,
+ );
+}
+
+
+# Defaults to use in case the config install paths cannot be prefixified.
+sub prefix_relpaths {
+ # Usage: prefix_relpaths('site', 'lib') or prefix_relpaths('site');
+ my $self = shift;
+ my $installdirs = shift || $self->installdirs;
+ my $map = $self->{properties}{prefix_relpaths}{$installdirs};
+ return $map unless @_;
+
+ my $type = shift;
+ return unless exists $map->{$type};
+ return File::Spec->catdir(@{$map->{$type}});
+}
+
+
+# Translated from ExtUtils::MM_Unix::prefixify()
+sub _prefixify {
+ my($self, $path, $sprefix, $type) = @_;
+
+ my $rprefix = $self->prefix;
+ $rprefix .= '/' if $sprefix =~ m|/$|;
+
+ $self->log_verbose(" prefixify $path from $sprefix to $rprefix\n")
+ if defined( $path ) && length( $path );
+
+ if( !defined( $path ) || ( length( $path ) == 0 ) ) {
+ $self->log_verbose(" no path to prefixify, falling back to default.\n");
+ return $self->_prefixify_default( $type, $rprefix );
+ } elsif( !File::Spec->file_name_is_absolute($path) ) {
+ $self->log_verbose(" path is relative, not prefixifying.\n");
+ } elsif( $sprefix eq $rprefix ) {
+ $self->log_verbose(" no new prefix.\n");
+ } elsif( $path !~ s{^\Q$sprefix\E\b}{}s ) {
+ $self->log_verbose(" cannot prefixify, falling back to default.\n");
+ return $self->_prefixify_default( $type, $rprefix );
+ }
+
+ $self->log_verbose(" now $path in $rprefix\n");
+
+ return $path;
+}
+
+sub _prefixify_default {
+ my $self = shift;
+ my $type = shift;
+ my $rprefix = shift;
+
+ my $default = $self->prefix_relpaths($self->installdirs, $type);
+ if( !$default ) {
+ $self->log_verbose(" no default install location for type '$type', using prefix '$rprefix'.\n");
+ return $rprefix;
+ } else {
+ return $default;
+ }
+}
+
+sub install_destination {
+ my ($self, $type) = @_;
+
+ return $self->install_path($type) if $self->install_path($type);
+
+ if ( $self->install_base ) {
+ my $relpath = $self->install_base_relpaths($type);
+ return $relpath ? File::Spec->catdir($self->install_base, $relpath) : undef;
+ }
+
+ if ( $self->prefix ) {
+ my $relpath = $self->prefix_relative($type);
+ return $relpath ? File::Spec->catdir($self->prefix, $relpath) : undef;
+ }
+
+ return $self->install_sets($self->installdirs)->{$type};
+}
+
+sub install_types {
+ my $self = shift;
+ my %types = (%{$self->install_path}, %{ $self->install_sets($self->installdirs) });
+ return sort keys %types;
+}
+
+sub install_map {
+ my ($self, $blib) = @_;
+ $blib ||= $self->blib;
+
+ my( %map, @skipping );
+ foreach my $type ($self->install_types) {
+ my $localdir = File::Spec->catdir( $blib, $type );
+ next unless -e $localdir;
+
+ if (my $dest = $self->install_destination($type)) {
+ $map{$localdir} = $dest;
+ } else {
+ push( @skipping, $type );
+ }
+ }
+
+ $self->log_warn(
+ "WARNING: Can't figure out install path for types: @skipping\n" .
+ "Files will not be installed.\n"
+ ) if @skipping;
+
+ # Write the packlist into the same place as ExtUtils::MakeMaker.
+ my $archdir = $self->install_destination('arch');
+ my @ext = split /::/, $self->module_name;
+ $map{write} = File::Spec->catdir($archdir, 'auto', @ext, '.packlist');
+
+ # Handle destdir
+ if (length(my $destdir = $self->destdir || '')) {
+ foreach (keys %map) {
+ # Need to remove volume from $map{$_} using splitpath, or else
+ # we'll create something crazy like C:\Foo\Bar\E:\Baz\Quux
+ my ($volume, $path) = File::Spec->splitpath( $map{$_}, 1 );
+ $map{$_} = File::Spec->catdir($destdir, $path);
+ }
+ }
+
+ $map{read} = ''; # To keep ExtUtils::Install quiet
+
+ return \%map;
+}
+
+sub depends_on {
+ my $self = shift;
+ foreach my $action (@_) {
+ $self->_call_action($action);
+ }
+}
+
+sub rscan_dir {
+ my ($self, $dir, $pattern) = @_;
+ my @result;
+ local $_; # find() can overwrite $_, so protect ourselves
+ my $subr = !$pattern ? sub {push @result, $File::Find::name} :
+ !ref($pattern) || (ref $pattern eq 'Regexp') ? sub {push @result, $File::Find::name if /$pattern/} :
+ ref($pattern) eq 'CODE' ? sub {push @result, $File::Find::name if $pattern->()} :
+ die "Unknown pattern type";
+
+ File::Find::find({wanted => $subr, no_chdir => 1}, $dir);
+ return \@result;
+}
+
+sub delete_filetree {
+ my $self = shift;
+ my $deleted = 0;
+ foreach (@_) {
+ next unless -e $_;
+ $self->log_info("Deleting $_\n");
+ File::Path::rmtree($_, 0, 0);
+ die "Couldn't remove '$_': $!\n" if -e $_;
+ $deleted++;
+ }
+ return $deleted;
+}
+
+sub autosplit_file {
+ my ($self, $file, $to) = @_;
+ require AutoSplit;
+ my $dir = File::Spec->catdir($to, 'lib', 'auto');
+ AutoSplit::autosplit($file, $dir);
+}
+
+sub _cbuilder {
+ # Returns a CBuilder object
+
+ my $self = shift;
+ my $p = $self->{properties};
+ return $p->{_cbuilder} if $p->{_cbuilder};
+ return unless $self->_mb_feature('C_support');
+
+ require ExtUtils::CBuilder;
+ return $p->{_cbuilder} = ExtUtils::CBuilder->new(config => $self->config);
+}
+
+sub have_c_compiler {
+ my ($self) = @_;
+
+ my $p = $self->{properties};
+ return $p->{have_compiler} if defined $p->{have_compiler};
+
+ $self->log_verbose("Checking if compiler tools configured... ");
+ my $b = $self->_cbuilder;
+ my $have = $b && $b->have_compiler;
+ $self->log_verbose($have ? "ok.\n" : "failed.\n");
+ return $p->{have_compiler} = $have;
+}
+
+sub compile_c {
+ my ($self, $file, %args) = @_;
+ my $b = $self->_cbuilder
+ or die "Module::Build is not configured with C_support";
+
+ my $obj_file = $b->object_file($file);
+ $self->add_to_cleanup($obj_file);
+ return $obj_file if $self->up_to_date($file, $obj_file);
+
+ $b->compile(source => $file,
+ defines => $args{defines},
+ object_file => $obj_file,
+ include_dirs => $self->include_dirs,
+ extra_compiler_flags => $self->extra_compiler_flags,
+ );
+
+ return $obj_file;
+}
+
+sub link_c {
+ my ($self, $to, $file_base) = @_;
+ my $p = $self->{properties}; # For convenience
+
+ my $spec = $self->_infer_xs_spec($file_base);
+
+ $self->add_to_cleanup($spec->{lib_file});
+
+ my $objects = $p->{objects} || [];
+
+ return $spec->{lib_file}
+ if $self->up_to_date([$spec->{obj_file}, @$objects],
+ $spec->{lib_file});
+
+ my $module_name = $self->module_name;
+ $module_name ||= $spec->{module_name};
+
+ my $b = $self->_cbuilder
+ or die "Module::Build is not configured with C_support";
+ $b->link(
+ module_name => $module_name,
+ objects => [$spec->{obj_file}, @$objects],
+ lib_file => $spec->{lib_file},
+ extra_linker_flags => $p->{extra_linker_flags} );
+
+ return $spec->{lib_file};
+}
+
+sub compile_xs {
+ my ($self, $file, %args) = @_;
+
+ $self->log_info("$file -> $args{outfile}\n");
+
+ if (eval {require ExtUtils::ParseXS; 1}) {
+
+ ExtUtils::ParseXS::process_file(
+ filename => $file,
+ prototypes => 0,
+ output => $args{outfile},
+ );
+ } else {
+ # Ok, I give up. Just use backticks.
+
+ my $xsubpp = Module::Build::ModuleInfo->find_module_by_name('ExtUtils::xsubpp')
+ or die "Can't find ExtUtils::xsubpp in INC (@INC)";
+
+ my @typemaps;
+ push @typemaps, Module::Build::ModuleInfo->find_module_by_name('ExtUtils::typemap', \@INC);
+ my $lib_typemap = Module::Build::ModuleInfo->find_module_by_name('typemap', ['lib']);
+ if (defined $lib_typemap and -e $lib_typemap) {
+ push @typemaps, 'typemap';
+ }
+ my $typemaps = join ' ', map qq{-typemap "$_"}, @typemaps;
+
+ my $cf = $self->config;
+ my $perl = $self->{properties}{perl};
+
+ my $command = (qq{$perl "-I$cf->{installarchlib}" "-I$cf->{installprivlib}" "$xsubpp" -noprototypes } .
+ qq{$typemaps "$file"});
+
+ $self->log_info("$command\n");
+ my $fh = IO::File->new("> $args{outfile}") or die "Couldn't write $args{outfile}: $!";
+ print $fh `$command`;
+ close $fh;
+ }
+}
+
+sub split_like_shell {
+ my ($self, $string) = @_;
+
+ return () unless defined($string);
+ return @$string if UNIVERSAL::isa($string, 'ARRAY');
+ $string =~ s/^\s+|\s+$//g;
+ return () unless length($string);
+
+ return Text::ParseWords::shellwords($string);
+}
+
+sub run_perl_script {
+ my ($self, $script, $preargs, $postargs) = @_;
+ foreach ($preargs, $postargs) {
+ $_ = [ $self->split_like_shell($_) ] unless ref();
+ }
+ return $self->run_perl_command([@$preargs, $script, @$postargs]);
+}
+
+sub run_perl_command {
+ # XXX Maybe we should accept @args instead of $args? Must resolve
+ # this before documenting.
+ my ($self, $args) = @_;
+ $args = [ $self->split_like_shell($args) ] unless ref($args);
+ my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter;
+
+ # Make sure our local additions to @INC are propagated to the subprocess
+ my $c = ref $self ? $self->config : \%Config::Config;
+ local $ENV{PERL5LIB} = join $c->{path_sep}, $self->_added_to_INC;
+
+ return $self->do_system($perl, @$args);
+}
+
+# Infer various data from the path of the input filename
+# that is needed to create output files.
+# The input filename is expected to be of the form:
+# lib/Module/Name.ext or Module/Name.ext
+sub _infer_xs_spec {
+ my $self = shift;
+ my $file = shift;
+
+ my $cf = $self->{config};
+
+ my %spec;
+
+ my( $v, $d, $f ) = File::Spec->splitpath( $file );
+ my @d = File::Spec->splitdir( $d );
+ (my $file_base = $f) =~ s/\.[^.]+$//i;
+
+ $spec{base_name} = $file_base;
+
+ $spec{src_dir} = File::Spec->catpath( $v, $d, '' );
+
+ # the module name
+ shift( @d ) while @d && ($d[0] eq 'lib' || $d[0] eq '');
+ pop( @d ) while @d && $d[-1] eq '';
+ $spec{module_name} = join( '::', (@d, $file_base) );
+
+ $spec{archdir} = File::Spec->catdir($self->blib, 'arch', 'auto',
+ @d, $file_base);
+
+ $spec{bs_file} = File::Spec->catfile($spec{archdir}, "${file_base}.bs");
+
+ $spec{lib_file} = File::Spec->catfile($spec{archdir},
+ "${file_base}.$cf->{dlext}");
+
+ $spec{c_file} = File::Spec->catfile( $spec{src_dir},
+ "${file_base}.c" );
+
+ $spec{obj_file} = File::Spec->catfile( $spec{src_dir},
+ "${file_base}$cf->{obj_ext}" );
+
+ return \%spec;
+}
+
+sub process_xs {
+ my ($self, $file) = @_;
+ my $cf = $self->config; # For convenience
+
+ my $spec = $self->_infer_xs_spec($file);
+
+ # File name, minus the suffix
+ (my $file_base = $file) =~ s/\.[^.]+$//;
+
+ # .xs -> .c
+ $self->add_to_cleanup($spec->{c_file});
+
+ unless ($self->up_to_date($file, $spec->{c_file})) {
+ $self->compile_xs($file, outfile => $spec->{c_file});
+ }
+
+ # .c -> .o
+ my $v = $self->dist_version;
+ $self->compile_c($spec->{c_file},
+ defines => {VERSION => qq{"$v"}, XS_VERSION => qq{"$v"}});
+
+ # archdir
+ File::Path::mkpath($spec->{archdir}, 0, 0777) unless -d $spec->{archdir};
+
+ # .xs -> .bs
+ $self->add_to_cleanup($spec->{bs_file});
+ unless ($self->up_to_date($file, $spec->{bs_file})) {
+ require ExtUtils::Mkbootstrap;
+ $self->log_info("ExtUtils::Mkbootstrap::Mkbootstrap('$spec->{bs_file}')\n");
+ ExtUtils::Mkbootstrap::Mkbootstrap($spec->{bs_file}); # Original had $BSLOADLIBS - what's that?
+ {my $fh = IO::File->new(">> $spec->{bs_file}")} # create
+ utime((time)x2, $spec->{bs_file}); # touch
+ }
+
+ # .o -> .(a|bundle)
+ $self->link_c($spec->{archdir}, $file_base);
+}
+
+sub do_system {
+ my ($self, @cmd) = @_;
+ $self->log_info("@cmd\n");
+ return !system(@cmd);
+}
+
+sub copy_if_modified {
+ my $self = shift;
+ my %args = (@_ > 3
+ ? ( @_ )
+ : ( from => shift, to_dir => shift, flatten => shift )
+ );
+ $args{verbose} = !$self->quiet
+ unless exists $args{verbose};
+
+ my $file = $args{from};
+ unless (defined $file and length $file) {
+ die "No 'from' parameter given to copy_if_modified";
+ }
+
+ my $to_path;
+ if (defined $args{to} and length $args{to}) {
+ $to_path = $args{to};
+ } elsif (defined $args{to_dir} and length $args{to_dir}) {
+ $to_path = File::Spec->catfile( $args{to_dir}, $args{flatten}
+ ? File::Basename::basename($file)
+ : $file );
+ } else {
+ die "No 'to' or 'to_dir' parameter given to copy_if_modified";
+ }
+
+ return if $self->up_to_date($file, $to_path); # Already fresh
+
+ # Create parent directories
+ File::Path::mkpath(File::Basename::dirname($to_path), 0, 0777);
+
+ $self->log_info("$file -> $to_path\n") if $args{verbose};
+ File::Copy::copy($file, $to_path) or die "Can't copy('$file', '$to_path'): $!";
+ return $to_path;
+}
+
+sub up_to_date {
+ my ($self, $source, $derived) = @_;
+ $source = [$source] unless ref $source;
+ $derived = [$derived] unless ref $derived;
+
+ return 0 if grep {not -e} @$derived;
+
+ my $most_recent_source = time / (24*60*60);
+ foreach my $file (@$source) {
+ unless (-e $file) {
+ $self->log_warn("Can't find source file $file for up-to-date check");
+ next;
+ }
+ $most_recent_source = -M _ if -M _ < $most_recent_source;
+ }
+
+ foreach my $derived (@$derived) {
+ return 0 if -M $derived > $most_recent_source;
+ }
+ return 1;
+}
+
+sub dir_contains {
+ my ($self, $first, $second) = @_;
+ # File::Spec doesn't have an easy way to check whether one directory
+ # is inside another, unfortunately.
+
+ ($first, $second) = map File::Spec->canonpath($_), ($first, $second);
+ my @first_dirs = File::Spec->splitdir($first);
+ my @second_dirs = File::Spec->splitdir($second);
+
+ return 0 if @second_dirs < @first_dirs;
+
+ my $is_same = ( File::Spec->case_tolerant
+ ? sub {lc(shift()) eq lc(shift())}
+ : sub {shift() eq shift()} );
+
+ while (@first_dirs) {
+ return 0 unless $is_same->(shift @first_dirs, shift @second_dirs);
+ }
+
+ return 1;
+}
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Base - Default methods for Module::Build
+
+=head1 SYNOPSIS
+
+ Please see the Module::Build documentation.
+
+=head1 DESCRIPTION
+
+The C<Module::Build::Base> module defines the core functionality of
+C<Module::Build>. Its methods may be overridden by any of the
+platform-dependent modules in the C<Module::Build::Platform::>
+namespace, but the intention here is to make this base module as
+platform-neutral as possible. Nicely enough, Perl has several core
+tools available in the C<File::> namespace for doing this, so the task
+isn't very difficult.
+
+Please see the C<Module::Build> documentation for more details.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001-2005 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.
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3)
+
+=cut
--- /dev/null
+Revision history for Perl extension Module::Build.
+
+0.27_08 Fri Mar 3 21:22:41 CST 2006
+
+ - Due to shell quoting issues and differences in syntax between
+ various flavors of Windows, the code for the 'pl2bat' utility
+ distributed with Perl has been incorporated into M::B::P::Windows.
+ [Thanks to Dr Bean and Ron Savage for help testing and isolating
+ the problem.]
+
+ - Modify add_build_element() so that it only adds elements if they
+ don't already exist. [David Wheeler]
+
+ - Fixed a bug in the 'pass-through' Makefile.PL in which we would die
+ if CPAN::Shell->install returned false, but apparently this return
+ value is unreliable. Now we only die if the module is actually
+ unavailable after installation.
+
+ - Fixed testing problems on VMS related to non-case-preserving
+ filesystems. We now bundle Tie::CPHash in the distribution (just
+ for testing purposes, it doesn't get installed) to help with
+ this. [Craig Berry and Yitzchak Scott-Thoennes]
+
+ - We incorrectly documented the 'dynamic_config' flag in the META.yml
+ file as having a default value of false, but according to the
+ META.yml spec (which, for heaven's sake, we wrote) its default
+ value is true. Fixed. [Spotted by Adam Kennedy]
+
+ - The have_c_compiler() method was dying if the ExtUtils::CBuilder
+ module wasn't around, which is obviously an unhelpful thing to do.
+ Now it just returns false. [Spotted by John Peacock]
+
+ - Fix detection of $VERSION expressions that are not
+ assignments. [Spotted by Chris Dolan]
+
+ - Obfuscate one of our constructs that uses a $VERSION variable,
+ because it was getting picked up by ExtUtils::MakeMaker's
+ version-finder. [Spotted by Randal Schwartz]
+
+ - The config_data script for querying and/or setting a module's
+ config data was forgetting to call write() after setting config
+ values (though setting feature values was working fine).
+ Fixed. [Brian Duggan]
+
+ - On Windows, remove the pl2bat generated 'Build.bat' script without
+ the annoying "The batch file cannot be found." error. [Solution
+ provided by RazTK and foxidrive on newsgroup alt.msdos.batch]
+
+ - Our version comparisons should now work correctly with modules that
+ use version.pm to delcare their versions (e.g. "our $VERSION =
+ version->new('1.0.0')"). [John Peacock and Ron Savage]
+
+ - We now create a Build.bat script on versions of Windows where it
+ makes sense. [Yves]
+
+ - Fixed the verbiage around choosing the correct make-alike on
+ different platforms to suggest using 'perl -V:make'. [Suggested by
+ anonymous user]
+
+0.27_07 Wed Feb 1 20:07:45 CST 2006
+
+ - The notes() method now returns the new value when called with two
+ arguments, just like when it's called with one argument. [Tyler
+ MacDonald]
+
+ - The notes() method now distinguishes among the values undef, 0, and
+ the empty string, where previously it didn't. [Tyler MacDonald]
+
+ - We now unshift(@INC) rather than push(@INC) for the directory where
+ a build subclass lives, so that we're sure to pick up the right
+ version and not some already-installed version. [perlmonkey]
+
+ - The SIGNATURE file for version 0.27_06 (and I'm sure for lots of
+ versions before that too!) was messed up, since we were modifying
+ some files after signing. This has been band-aided for the time
+ being by signing twice. [Reported by Chris Dolan]
+
+0.27_06 Mon Jan 23 21:44:54 CST 2006
+
+ - Fixed an undefined-variable warning when building the META.yml file
+ and the author hasn't used the 'module_name' mechanism. [Chris Dolan]
+
+ - We should now work with recent (> 0.49) versions of YAML.pm when
+ creating the META.yml file. [Yitzchak Scott-Thoennes]
+
+ - The y_n() method now requires the default parameter, and the
+ prompt() and y_n() methods have been improved with respect to
+ how they behave/detect when there is no user to ask. We're now
+ more consistent with MakeMaker, including respecting the
+ PERL_MM_USE_DEFAULT environment variable. [Tyler MacDonald and
+ Yitzchak Scott-Thoennes]
+
+ - When building a README file using Pod::Text, work around a bug in
+ Pod::Text 3.01, which expects Pod::Simple::parse_file to take input
+ and output filehandles when it actually only takes an input
+ filehandle. [Yitzchak Scott-Thoennes]
+
+0.27_05 Thu Jan 12 17:39:21 CST 2006
+
+ - In t/common.pl, we were attempting to let the user's installed
+ Test::More take precedence over ours, but getting thwarted by all
+ the test scripts' loading Test::More beforehand. Fixed. [Spotted
+ by Yitzchak Scott-Thoennes]
+
+ - In various test scripts, we were outputting some strings that
+ weren't strictly conformant with Test::Harness's expected input,
+ though it didn't actually cause problems. Now we're more
+ conformant, though not yet strict. [Spotted by Yitzchak
+ Scott-Thoennes]
+
+0.27_04 Fri Dec 23 10:43:34 CST 2005
+
+ - Removed experimental feature that extended the prerequisite system
+ to apply ('requires', 'recommends', and 'conflicts') prereqs to all
+ actions. Most of the internal extensiblity has been retained so
+ that prereq types can easily be added, more selectively.
+
+ - Added a 'prereq_report' action that shows the user a well-formatted
+ list of all prerequisites, the versions required, and the versions
+ actually installed. [David Wheeler]
+
+ - Clarified the directory name that's created during the 'distdir'
+ action. [Suggested by Tyler MacDonald]
+
+ - Fixed a bug when creating the META.yml file without the help of
+ YAML.pm - some common strings weren't quoted & escaped properly.
+ Now only some uncommon ones are. [Spotted by Joshua ben Jore]
+
+ - Fixed a bug in which an "UNINST=1" argument specified to a
+ passthrough Makefile's "make install" wasn't actually seen by
+ Module::Build.
+
+ - Rather than dying when the Build script is run from the wrong
+ directory, it now simply chdir()s into the right directory and
+ keeps going. [Suggested by Dominique Quatravaux]
+
+ - Added an "Examples on CPAN" section to the cookbook, with an
+ initial entry pointing to John Peacock's SVN-Notify-Mirror
+ distribution.
+
+ - Add an invoked_action() method to return the name of the original
+ action invoked by the user.
+
+ - Add 'meta-spec' field to the generated META.yml file, including the
+ version of the specification followed by the current Module::Build
+ and the url where the specification can be found.
+
+ - Introduced two actions, 'html' & 'manpages', that generate
+ documentation for POD when the respective feature is enabled. The
+ actions will generate the documents even if there is no set place
+ to install to. However, if the actions are invoked as a dependency
+ of another action (e.g. build), the documentation will only be
+ built when there is a default or user-specified place to install to.
+
+ - Added support for environment variable, 'MODULEBUILDRC', which can
+ be used to specify the full path to an option file to use instead
+ of the default location of ~/.modulebuildrc. A special undocumented
+ setting of 'NONE' tells Module::Build not to load any user settings,
+ so tests can be run without tainting from user options.
+
+ - Documented and improved preliminary support for more Getopt::Long
+ style options are supported, including boolean options (--verbose,
+ --no-verbose), and use of hyphens in option names in addition to
+ underscores.
+
+ - The option to disable/enable reading of the ~/.modulebuildrc file
+ is changed from 'skip_rcfile' to 'use_rcfile'
+
+ - Allow the 'distmeta' action to continue when 'MANIFEST' is missing,
+ omitting the generation of the 'provieds' field. [Steven Schubiger]
+
+ - Fixed some failing regex from generated MANIFEST.SKIP file.
+
+ - Fixed an edge case in $VERSION parsing where we thought a package()
+ declaration was happening but it wasn't. [David Golden]
+
+ - Added docs for the install_destination() and install_types() methods.
+
+0.27_03 (Beta for 0.28) Mon Oct 10 11:19:23 EDT 2005
+
+ - We now use ExtUtils::CBuilder to do all compiling of C code (for
+ example, when compiling XS modules). (This change actually
+ occurred in 0.27_01, but it was mistakenly omitted from the Changes
+ file.)
+
+ - Fixed an issue on Win32 (and other case-tolerant
+ non-case-preserving systems, possibly like VMS?) in which the
+ current working directory would sometimes be reported with
+ different case, fooling us into thinking that we were in the wrong
+ directory. [David Golden]
+
+ - The extra_compiler_flags setting was not actually being passed
+ along to ExtUtils::CBuilder so it could pass it along to the
+ compiler. Now it is.
+
+ - The synonyms 'scripts' and 'prereq' for 'script_files' and
+ 'requires' were broken in a previous version (0.27_01, probably),
+ but now they're fixed. [David Golden]
+
+ - Previously, we assumed that any custom subclass of Module::Build
+ was located in _build/lib/. This is only true if the author used
+ the subclass() method, though. We now use %INC to find where the
+ custom subclass really is, so that we can "use lib" it. We also
+ issue a warning if it seems to be outside the build directory.
+ [Spotted by Peter Tandler]
+
+ - Added a URL for each license type that we know about, which will
+ appear as resources=>license: in the generated META.yml file.
+
+ - If the user passes a no_index parameter to our constructor, we now
+ pass that through when building the META.yml file. [Richard
+ Soderberg, RT #9603]
+
+ - A few more status messages can now be suppressed by using 'quiet'
+ mode. [Dave Rolsky]
+
+ - Added some more entries to the default MANIFEST.SKIP file. [Chris
+ Dolan]
+
+ - Our POD parser will now accept "AUTHORS" as well as "AUTHOR" when
+ looking for the author list in a module. [David Wheeler]
+
+ - When looking for the POD to auto-generate a README file, or for the
+ AUTHOR or ABSTRACT for the distribution, we now also look for a
+ *.pod with the same name as the *.pm file specified by
+ 'version_from'. [David Golden]
+
+ - The recommended dependency on ExtUtils::ParseXS has been moved into
+ the "C_support" auto_feature.
+
+ - When building XS files, we now pass the -DVERSION and -DXS_VERSION
+ flags to the compiler. [Spotted by Jerry Hedden]
+
+ - If a distribution has XS files and Module::Build has not been
+ configured with the "C_support" feature, we now issue a
+ warning. [Suggested by Jerry Hedden]
+
+ - Added a dir_contains() method.
+
+ - Some versions of MakeMaker, CPANPLUS, and/or PAUSE thought that a
+ certain line of our code was declaring a $VERSION when we didn't
+ intend to. The line has been obscurified so they won't think that
+ anymore. [Jos Boumans, RT #14226]
+
+ - Added the Apache, MIT, and Mozilla licenses to the list of licenses
+ that this module knows about. [Bob Ippolito]
+
+ - Fixed a pretty significant typo in the documentation for
+ auto_features. [Spotted by Jonas B. Nielsen]
+
+ - In order to aid people who want to do customization of the META.yml
+ file, we've added a "metafile" property that can then be easily
+ overridden in subclasses, changed do_create_meta_yml() to
+ do_create_metafile(), and split out the code that actually
+ generates the YAML into a new method, write_metafile(). [David
+ Wheeler]
+
+ - Fixed a couple of non-helpful behaviors with extra_compiler_flags
+ and extra_linker_flags. These will automatically be run through
+ split_like_shell() when given to new() as strings.
+
+ - When the user doesn't have ExtUtils::ParseXS installed and we use
+ the old 'xsubpp', the displayed command line for creating the .c
+ file from the .xs file was missing its newline. Now it's got it.
+
+0.27_02 (Beta for 0.28) Fri Jul 15 07:34:58 CDT 2005
+
+ - Provided initial support for the --prefix installation parameter,
+ which acts like MakeMaker's PREFIX. It is still highly recommended
+ NOT to use it when you could reasonably use --install_base or
+ --install_path or --install_dest, but that's just because the way
+ --prefix is designed is weird and unpredictable. Ultimately the
+ choice rests with the installing user. [Patches by Michael Schwern
+ and Rob Kinyon]
+
+ - Fixed a bug in subclass() which prevented people from using it to
+ subclass subclasses of Module::Build. [Chris Dolan]
+
+ - Added a 'pure_install' action, which for the time being is
+ identical to the 'install' action. [Jos Boumans]
+
+ - Fixed a POD error in an L<http://...> tag. [Offer Kaye]
+
+ - Note several options for automatically creating a new module dev
+ tree. [Suggested by Eric Wilhelm]
+
+ - Removed some hard-coded references to File::Spec::Unix in the
+ creation of HTML docs, which should help that code work in more
+ places, and help people not to panic when they look at it. [Spotted
+ by Yves]
+
+ - We now use Pod::Readme by default (instead of Pod::Text) to
+ generate the README file when the 'create_readme' option is used.
+ If Pod::Readme is not installed, we will still fall back to using
+ Pod::Text. [Robert Rothenberg]
+
+ - The values of the "prefix", "install_base", "install_path", and
+ "install_dest" parameters can now begin with "~" or "~user", and
+ we'll de-tilde-ify them by using glob().
+
+ - The (optional) auto-creation of the README and Makefile.PL files
+ have been moved from the 'distdir' action to the 'distmeta'
+ action. [David Golden]
+
+ - When looking for a .modulebuildrc file, we now use a fancier method
+ of trying to find the home directory, because $ENV{HOME} isn't a
+ very cross-platform variable. [Robert Rothenberg]
+
+ - We now memoize the output of the internal _default_INC() method,
+ since it uses backticks and might be kind of slow.
+
+ - When processing XS files, we now look for a typemap in lib/ as well
+ as using the system's default typemap. [John Peacock]
+
+ - The DESTDIR, PREFIX, and INSTALL_BASE arguments to "make install"
+ are now supported for pass-through Makefiles (they've been
+ supported for quite a while as arguments to "perl
+ Makefile.PL"). [Requested by Guillaume Rousse]
+
+ - Test::Harness has changed its output format in recent versions,
+ which threw off one of our tests. We now allow for this different
+ format. [Reported by Scott Godin]
+
+ - Fixed an issue that prevented Module::Build from upgrading itself
+ using its own API (which is how CPANPLUS uses it). There are still
+ some issues with this solution, however. See ticket #13169 in
+ rt.cpan.org. [Reported by Jos Boumans]
+
+ - Fixed a fatal error that occurred when a distribution's author
+ could not be determined from its POD nor from the call to
+ Module::Build->new() in its Build.PL. See ticket #12318 in
+ rt.cpan.org. [Reported by Jos Boumans]
+
+ - Apparently on Windows and cygwin it's not possible to use the "-pi"
+ switch to perl without a backup extension, so now we use ".bak" and
+ remove the backup file when we're done. Thus the "dist" action for
+ Module::Build itself can now be run on those platforms. [Yitzchak
+ Scott-Thoennes]
+
+ - Improved the handling of auto_features in the config_data access
+ script. [Yitzchak Scott-Thoennes]
+
+0.27_01 (Beta for 0.28) Fri Apr 15 21:12:57 CDT 2005
+
+ Backward-incompatible (but better) changes:
+
+ * When using the 'install_base' option to choose a directory for
+ installing everything, perl modules now go into lib/perl5/ instead
+ of just lib/. It seems this is more consistent with people's
+ expectations, and the way I had it before was a bit peculiar to the
+ way I like things in my own home directory. [Michael Schwern]
+
+ * When the user is using the 'install_base' option, scripts will now
+ be installed by default in $install_base/bin/ rather than
+ $install_base/script/ . [Jan Hudec and Michael Schwern]
+
+ Major changes:
+
+ - The auto_features mechanism will now re-evaluate dependencies every
+ time feature() is called for an auto-feature, rather than freezing
+ the success/failure value during 'perl Build.PL' and using that
+ value for all eternity (or module update, whichever comes first).
+ This applies to both $build->feature() and
+ FooModule::ConfigData->feature() calls. [Requested by many]
+
+ - Added the meta_add and meta_merge mechanisms, which let the module
+ author add/merge arbitrary entries into the META.yml file.
+
+ - Now reads per-action default options from '$ENV{HOME}/.modulebuildrc'
+ if it exists. Command line options override anything set in the rc file.
+
+ - We now use ExtUtils::CBuilder to do all compiling of C code (for
+ example, when compiling XS modules).
+
+ - The creation of Unix man pages is no longer a strict necessity - it
+ has now been turned into an 'auto-feature' contingent on the
+ presence of Pod::Man and a location specified for man pages to go.
+
+ - A user-specified 'install_path' setting will now take precedence
+ over an 'install_base' setting. This allows the user to use
+ 'install_base' to set the base for all elements in one go, and then
+ use 'install_path' to override specific paths or add paths for
+ additional kinds of targets.
+
+ - Split the main documentation from 'Module/Build.pm' into two
+ sections. The user level documentation and overview remains in
+ 'Module/Build.pm', while a new document,
+ 'Module/Build/Authoring.pod', has been created for module authors.
+
+ Minor changes:
+
+ - new_from_context() was losing its arguments in some cases (and not
+ because of inadequate training in forensic debate) - we now pass its
+ arguments directly to the Build.PL script rather than merging them
+ in afterwards.
+
+ - Let resume() return an object blessed into the appropriate class
+ if the user has provided a subclass, as specified by the
+ 'build_class' property. This allows current() and new_from_context()
+ to behave more like factory methods returning objects of the correct
+ class based on context. [Ray Zimmerman]
+
+ - Refactored methods relating to parsing perl module files for
+ package, version, and pod data into a new class:
+ Module::Build::ModuleInfo. It should not be considered part of
+ Module::Build's API, because we may split it out entirely as a
+ separate CPAN module that we depend on.
+
+ - Added new method Module::Build::prepare_metadata() for authors to
+ override in order to add custom fields to META.yml.
+
+ - We now use Test::More for our regression tests. If the user
+ doesn't have it installed, we include a copy in t/lib/ that we can
+ use during testing.
+
+ - When copying files in the 'distdir' action, set permissions to match
+ the original files. [Julian Mehnle]
+
+ - When adding files like META.yml to the MANIFEST, we now tell the
+ user we're doing so by printing one of the "Added to MANIFEST: ..."
+ lines. [Ron Savage]
+
+ - Added a runtime_params() method, which lets a module author see
+ which parameters were overridden by the user on the command line
+ (or in whatever paradigm the user originally invoked Module::Build
+ from). [David Wheeler]
+
+ - Added the current_action() method, which, surprisingly, returns the
+ name of the currently running action. [David Wheeler]
+
+ - Added docs for run_perl_script().
+
+ - Added some stuff to the docs about why PREFIX is unsupported, and
+ what to use instead. [Steve Purkis]
+
+ - The simple get/set accessor methods for all the 'parameters' like
+ verbose(), license(), etc. now have auto-generated documentation in
+ Module/Build.pm.
+
+ - Created a Cookbook entry for 'Adding new elements to the install
+ process'
+
+ - We now add META.yml to the MANIFEST when META.yml is created, not
+ when MANIFEST is created. [Spotted by Ron Savage]
+
+ - Added some additional patterns to the suggested MANIFEST.SKIP
+ contents, and changed the docs so that we encourage the user to use
+ the MANIFEST.SKIP. [Ron Savage]
+
+ - Eliminated a redundant recipe from the Cookbook, now that there are
+ some more extensive recipes on how to add stuff to the
+ build/install sequences.
+
+ - Eliminated an undefined-variable warning when testing under perl 5.005
+
+ - When building HTML documentation, 'html_backlink' and 'html_css'
+ properties are now first-class properties, so they can be set from
+ the command line. [Suggested by Sagar R. Shah]
+
+ - Have script_files default to everything in bin. I believe this is
+ the least surprising behavior. [Suggested by Michael Schwern]
+
+ - If script_files is given a directory, consider each file in that
+ directory tree as a script to be installed. This avoids having to
+ remember to add to the script_files list every time you add a
+ program. [Suggested by Michael Schwern]
+
+ - We now only load Pod::Man when we actually need to build man pages.
+
+ - We now make Test::Harness use our carefully-selected path to a perl
+ executable regardless of Test::Harness's version. Previously we
+ let it figure stuff out for itself if it was a reasonably modern
+ version, but it's safer to make sure we're using the same perl
+ everywhere.
+
+0.2610 Fri Apr 15 08:25:01 CDT 2005
+
+ - new_from_context() was losing its arguments in some cases (and not
+ because of inadequate training in debate) - we now pass its
+ arguments directly to the Build.PL script rather than merging them
+ in afterwards. [Ray Zimmerman]
+
+ - Fixed a bug in which config_data and feature data were being
+ forgotten and no ConfigData.pm module would get written. [Ray
+ Zimmerman]
+
+ - Added a recipe to the cookbook showing how to run a single test
+ file from the command line. [William McKee]
+
+ - For command-line arguments, we now accept the syntax "--foo=bar" in
+ addition to "--foo bar" and "foo=bar". This seems to fit well with
+ what GNU getopt and Getopt::Long do, and with people's
+ expectations. [Adam Spiers]
+
+0.2609 Wed Mar 16 22:18:35 CST 2005
+
+ - The html docs that were created during the first invokation of
+ './Build' were being found and treated as pod that needed to be
+ converted to html during subsequent invokations. We now are more
+ specific about the directories we scan for pod that needs to be
+ converted, effectively avoiding blib/html. [Ray Zimmerman]
+
+ - If Pod::Man is not available, we now skip building man pages
+ (rather than dying) and tell the user why.
+
+ - We now write a .packlist file upon installation, in the same place
+ that ExtUtils::MakeMaker does. [Johnny Lam]
+
+ - On some Unix platforms (BSD derivatives, mostly) perl's $^X
+ variable isn't set to the full path of the perl executable, just
+ 'perl', when the 'Build' script is run as './Build' and not 'perl
+ ./Build'. This can lead to some other modules (maybe
+ Test::Harness, maybe IO::File, I dunno...) getting very confused
+ about where they are, and they try to load stuff from the wrong
+ perl lib, and big trouble ensues. To fix this, we now set $^X to
+ the value of Module::Build->find_perl_interpreter().
+
+ - The 'distcheck' action will now die() if it finds an error in the
+ MANIFEST, rather than just printing on STDOUT. [David Golden]
+
+ - When the README and/or Makefile.PL are autogenerated using
+ create_readme or create_makefile_pl, we now automatically make sure
+ they're also listed in the MANIFEST file. [Suggested by Michael
+ Schwern]
+
+ - Got rid of the t/MANIFEST file - it's superfluous, and it had
+ zero-length, which some versions of Tar don't like. [William
+ Underwood]
+
+ - Added a mention in the documentation that each property that new()
+ accepts also has a corresponding get/set accessor. (In the version
+ 0.27_0x series each accessor method is mentioned explicitly in the
+ docs.) [Omission spotted by Ian Langworth]
+
+0.2608 Wed Jan 26 19:46:09 CST 2005
+
+ - Add workaround for test files because Devel::Cover causes
+ require to fail when the argument to require is an expression
+ involving File::Spec. We now assign the result of the File::Spec
+ call to a variable and then call require with that variable.
+
+ - Tilde-expansion is now performed on arguments passed to a
+ compatibility-Makefile.PL [Spotted by Sam Vilain]
+
+ - We now run the 'gzip' and 'tar' values through split_like_shell()
+ when running the 'dist' action, so that e.g. the 'gzip' value can
+ be set to something like "gzip -f --best" and it'll work
+ correctly. [Spotted by Chris Dolan]
+
+ - Work around some bad mojo between Fedora Core [with its very long
+ @INC] and old versions of Test::Harness [with its propensity to
+ compound the number of @INC entries] that produced an "argument
+ list too long" error during testing. [assisted by Ville Skytta,
+ David Golden, & Randy Sims]
+
+ - Killed an infinite loop that would happen in y_n() in interactive
+ mode if the author provided no default value. [Max Maischein]
+
+0.2607 (Bug fix release in 0.26 series) Sat Dec 18 14:14:09 CST 2004
+
+ - Instead of freezing @INC in the 'Build' script to the value it had
+ when Build.PL was run, we now just add those additional values that
+ aren't part of the default compiled-in @INC. [Michael Schwern]
+
+ - The run_perl_script() method will now propagate any extra entries
+ in @INC (such as those added by "use lib" or the -I command-line
+ switch) to the subprocess. This helps situations in which you want
+ to tell the subprocess where to find a certain module, for
+ instance. [Michael Schwern]
+
+0.2606 (Bug fix release in 0.26 series) Tue Dec 7 22:33:11 CST 2004
+
+ - Fixed a linking bug on Win32, in which compiled C code object files
+ never got linked in with the modules being built. [Dominic
+ Mitchell]
+
+ - Fixed a bug in the new_from_context() method in which any arguments
+ passed made us die. [Spotted by Jos Boumans]
+
+0.2605 (Bug fix release in 0.26 series) Tue Nov 30 07:16:13 CST 2004
+
+ - Fixed a bug in which zero-length arguments for hash-valued
+ parameters (e.g. " --config foo= ") weren't being allowed.
+
+ - The tests now play better with environments in which version.pm is
+ pre-loaded, like in bleadperl. [John Peacock & Michael Schwern]
+
+ - Fixed a syntax error in one of the tests under perl 5.005.
+
+0.2604 (Bug fix release in 0.26 series) Wed Nov 17 14:32:42 CST 2004
+
+ - Fixed a split_like_shell() bug introduced in 0.2603 for Windows, in
+ which an array reference passed as an argument was returned as an
+ array reference, rather than as a list. [Spotted by Steve Hay]
+
+ - module_name() will now return '' instead of undef when module_name
+ is not set. This eliminates a couple uninitialized-value
+ warnings. [Suggested by Michael Schwern]
+
+ - The expand_test_dir() method will now skip dotfiles (like ._foo.t,
+ which sometimes gets automatically created on Mac systems) when
+ 'recursive_test_files' is in effect. [Tom Insam]
+
+0.2603 (Bug fix release in 0.26 series) Mon Nov 15 10:28:00 CST 2004
+
+ - Added documentation for the new_from_context() method.
+
+ - Completely rewrote the split_like_shell() method for the Windows
+ platform so it works like the command.com shell. [Randy Sims]
+
+0.2602 (Bug fix release in 0.26 series) Thu Nov 4 11:19:29 CST 2004
+
+ - The two bug fixes in 0.2601 gnashed against each other incorrectly,
+ resulting in a Win32 bug in split_like_shell(). Fixed. [Spotted
+ by Steve Hay & Randy Sims]
+
+ - Removed a couple of 'use warnings' statements from the code - they
+ were causing compile failures on 5.005_04, where warnings.pm isn't
+ available. [Blair Zajac]
+
+0.2601 (Bug fix release in 0.26 series) Wed Nov 3 20:09:27 CST 2004
+
+ - Fixed some backslash problems with split_like_shell() on
+ Win32. [Steve Hay]
+
+ - Fixed a bug in split_like_shell() in which leading whitespace was
+ creating an empty word, manifesting as something like "gcc - no
+ such file or directory" during tests. [Spotted by Warren L. Dodge]
+
+0.26 Sat Oct 9 17:51:01 CDT 2004
+
+ - Removed some language from the Module::Build::Compat documentation
+ that encouraged people to include a Build.PL without a Makefile.PL.
+ Also changed "a replacement for MakeMaker" to "an alternative to
+ MakeMaker" in the main documentation, which is basically what I
+ meant all along (i.e. a replacement for MakeMaker in your
+ particular build process - MakeMaker is never going to be fully
+ replaced in the perl world at large, of course), but some people
+ got the impression I was a little more truculent toward MakeMaker
+ than I really am.
+
+ - Added the formal concepts of "features" and "config data" for
+ distributions. This allows the module author to define a certain
+ set of features that the user can switch on and off (usually
+ according to whether they have the proper prerequisites for them),
+ and to save build-time configuration information in a standardized
+ format. See the main documentation of Module::Build for more
+ details. (Note that the name of this system was called
+ "BuildConfig" for a while in beta, but now it's called
+ "ConfigData".)
+
+ - Added an 'auto_features' capability, which simplifies the process
+ of defining features that depend on a set of prerequisites.
+
+ - Added the 'get_options' parameter, which lets module authors
+ declare certain command-line arguments their Build.PL can accept
+ [David Wheeler]
+
+ - Changed the split_like_shell() method to use the shellwords()
+ function from Text::ParseWords (a core module since 5.0), which
+ does a much better job than the split() we were using.
+
+ - Added a 'testpod' action, which checks the syntactic validity of
+ all POD files in the distribution using Test::Pod. This eliminates
+ the need for doing so in a regression test. [Initial patch by Mark
+ Stosberg]
+
+ - Added a process_files_by_extension() method, which generalizes the
+ kind of processing (essentially just copying) that happens for .pm
+ and .pod files, and makes it available to other user-defined types
+ of files. See the new cookbook entry.
+
+ - Improved compatibility with version.pm when authors are using
+ version objects as their $VERSION variables. Now
+ version_from_file() can deal with these objects. Currently we
+ stringify them right away, but perhaps in the future we will
+ preserve them as objects for a while.
+
+ - During 'distdir' and 'distmeta' actions, die a bit more gracefully
+ if there's no MANIFEST (i.e. explicitly say that a MANIFEST is
+ required). [Spotted by Adrian Howard]
+
+ - Eliminated a recursive dependency between creating the MANIFEST
+ file and creating the META.yml file. [Spotted by Dave Rolsky]
+
+ - On Win32, where a single directory might be known variously as
+ "Module-Build-0.25_03" or "MODULE~1.25_", we now use
+ Win32::GetShortPathName($cwd) to verify that the 'Build' script is
+ being run from the correct directory, rather than just a string
+ comparison.
+
+ - The add_to_cleanup() method will now accept glob()-style patterns
+ in addition to explicit filenames. Also documented the fact that
+ they can be specified in either Unix-style or native-style
+ notation.
+
+ - Passing a PREFIX value to a pass-through Makefile 'make install'
+ now has the same effect as passing it to 'perl Makefile.PL' (it
+ dies with a helpful message).
+
+ - Added the 'testcover' action, which runs a test suite using
+ Devel::Cover. [Dave Rolsky]
+
+ - Added the 'lib' and 'arch' installation directories to the search
+ path for the 'diff' action, since they won't necessarily (though
+ they usually will) be in @INC at installation time. [Suggested by
+ Kevin Baker]
+
+ - The "=head3" POD directive isn't supported in older podlators
+ (particularly Pod::Man), so we don't use it anymore.
+
+ - Fixed a typo & improved the docs in the SUBCLASSING section. [Ron
+ Savage]
+
+ - Added the '.tmp' suffix to the default MANIFEST.SKIP file, which
+ should avoid adding things like pod2htmi.tmp to the MANIFEST [Ron
+ Savage]
+
+ - Backup files from Emacs, containing the string '.#' in their names,
+ should no longer find their way into the blib/ directory (and from
+ there into installation directories).
+
+ - Worked around an unpleasant interaction between version.pm and the
+ version-checking code that makes sure Module::Build's version
+ hasn't changed during the lifetime of the 'Build' script. [Reported
+ by Trevor Schellhorn]
+
+ - Fixed a problem in htmlify_pods() that would produce test failures
+ on Cygwin (and probably elsewhere). [Yitzchak Scott-Thoennes]
+
+ - Fixed a test failure on Cygwin (and probably elsewhere) in
+ t/compat.t, resulting from empty environment variables being set to
+ the empty string (as opposed to simply being unset) by their mere
+ presence in the "EXPORT:" list.
+
+ - Fixed a fatal error that occurred when the author specified
+ 'dist_author' manually in their Build.PL script. [Spotted by Ron
+ Savage]
+
+ - The 'provides' section of the META.yml file wasn't being built
+ properly on Win32, because of a mismatch between URL-format and
+ native-format pathnames. Fixed. [Reported by Robert Rothenberg]
+
+ - The progress message "lib/Foo.xs -> lib/Foo.c" was previously being
+ output even when the Foo.c file wasn't being rebuilt. It's now
+ fixed.
+
+ - Fixed a couple of places in Compat.pm where it could have forgotten
+ which perl interpreter it had been run with ($^X isn't very
+ trustworthy).
+
+ - On some systems, the way we updated the timestamp on the
+ "lib/Foo.bs" file (one of the output files for XS-based modules)
+ was failing. It's been replaced by a simple call to utime().
+
+ - Fixed a problem in t/compat.t that prevented it from being run
+ individually using 'make test TEST_FILES=t/compat.t'. The problem
+ was that a couple environment variables (TEST_FILES, MAKEFLAGS)
+ were being passed through to subprocesses, and confused them.
+
+ - Fixed an important typo in the documentation for the 'install_base'
+ parameter ('libdoc' and 'bindoc' were switched). [Ray Zimmerman]
+
+ - The pass-through Makefiles (type 'small' or 'passthrough') now
+ support the TEST_FILES parameter to 'make test'.
+
+ - Fixed a fatal error that would occur on perl 5.005 when building
+ HTML documentation, because its version of Pod::Html was old and
+ didn't like some of the parameters we fed it. [Spotted by Blair
+ Zajac]
+
+ - The final line of the generated pass-through Makefile was missing
+ its trailing newline, which is now fixed. [Chip Salzenberg]
+
+ - We now depend on YAML version at least 0.35 and at most version
+ 0.49, so that we don't pick up a new (and backward-incompatible) beta
+ version from CPAN.
+
+ - Squashed a warning in t/basic.t about '"Foo::Module::VERSION" used
+ only once', and one in PPMMaker about $^V being undefined. [Blair
+ Zajac]
+
+ - Added a couple temporary output files from HTML documentation
+ generation to the cleanup list. [Toby Ovod-Everett]
+
+ - The PodParser module will now only extract paragraphs in the
+ 'AUTHOR' section of the pod if they contain an '@' character. This
+ tends to do a better job, heuristically speaking, of returning
+ relevant stuff.
+
+ - Added regression tests and a helper method ( add_build_elements() )
+ for adding new elements to the build process. Also some
+ documentation.
+
+ - Wrote a recipe in the Cookbook for adding new elements to the build
+ process, and a recipe for changing the order in which the steps in
+ the build process will occur.
+
+0.25 Sun Apr 25 11:12:36 CDT 2004
+
+ - During the 'distdir' action, if no MANIFEST.SKIP file exists, we
+ will now create a reasonable default one. [Randy Sims]
+
+ - In Makefile compatibility mode, some arguments (like UNINST,
+ TEST_VERBOSE, etc.) given to 'make' are now recognized and passed
+ through to Module::Build. [Randy Sims]
+
+ - The regression tests now make sure that several pass-through
+ Makefile.PL parameters are dealt with correctly.
+
+ - Added support for the 'LIB' parameter to passthrough
+ Makefile.PLs. [Spotted by Jesse Erlbaum]
+
+ - Passing a 'PREFIX' parameter to a passthrough Makefile.PL was
+ supposed to make it die with a helpful error message, but instead
+ it just ignored it and blindly tried to install to the wrong place.
+ This is now fixed. [Spotted by Jesse Erlbaum]
+
+ - Added an extra_compiler_flags() accessor method.
+
+ - If the 'recursive_test_files' option was turned on, the test files
+ weren't sorted, but returned in an apparently random order. Now
+ they're sorted. [Martyn Peck]
+
+ - Documented the 'tar' and 'gzip' parameters to the 'dist' and
+ 'ppmdist' actions.
+
+ - The generation of HTML documentation now works (it was accidentally
+ partially implemented with an itchy patch-application finger in
+ 0.24). [Randy Kobes]
+
+ - Fixed a fatal bug when building META.yml with YAML.pm and
+ 'dynamic_config' is set. [Reported by Jaap Karssenberg]
+
+ - Fixed some incorrect error messages that occurred when
+ compiling/linking C sources went awry.
+
+ - If the author uses a custom builder subclass, that subclass will
+ now be loaded correctly in the passthrough Makefile.PL if the
+ author uses the 'small' or 'passthrough' Makefile.PL options in
+ Module::Build::Compat. [Martyn Peck and Jaap Karssenberg]
+
+ - If the author uses a custom builder subclass created dynamically
+ through the subclass() method, passthrough Makefile.PLs (of type
+ 'passthrough' or 'small') didn't work properly, because the custom
+ builder module wouldn't be loaded at the right time. This has been
+ fixed. [Reported by Toby Ovod-Everett]
+
+ - In M::B-generated 'traditional' Makefile.PLs, the entries in
+ 'PREREQ_PM' are now sorted ASCIIbetically rather than randomly.
+
+ - The install_types() method will now return any additional types
+ given as 'install_path' arguments, as well as all elements of the
+ current 'install_sets' entry. This makes it easier to add new
+ types of installable objects to the mix.
+
+ - As a consequence of the previous change, there is no longer any
+ need to have an explicit 'install_types' data member, so it has
+ been removed.
+
+ - In the second example code for the Module::Build->subclass()
+ method, the Module::Build module needed to be loaded before calling
+ its methods. [John Peacock]
+
+ - Fixed minor error in the POD structure of Module::Build and
+ Module::Build::Platform::VMS docs.
+
+
+0.24 Wed Feb 25 15:57:00 CST 2004
+
+ - Fixed a problem with incude_dirs not being propagated to the 'ccs'
+ file when compiling XS files on Win32. [Randy Sims and Steve Hay]
+
+ - In 0.23, Module::Build::Compat->fake_makefile() started choking
+ when no 'build_class' parameter was supplied in the Makefile.PL.
+ Since these Makefile.PLs still exist on CPAN, we now default
+ 'build_class' to 'Module::Build', which was the old 0.22 behavior
+ anyway. [Reported by Martin Titz and Jeremy Seitz]
+
+ - Added documentation for the 'include_dirs' parameter to
+ new(). [Steve Hay]
+
+ - Changed the no-op command on Win32 from 'rem' to 'rem>nul' inside
+ pass-through Makefiles. [Randy Sims]
+
+ - The 'autosplit' parameter now accepts an array reference if
+ multiple files should be split. [Jaap Karssenberg]
+
+ - find_perl_interpreter() will now use $^X (if absolute), $ENV{PATH}
+ (if $^X isn't absolute), and $Config{perlpath}, in that order.
+ Also, we now make darn sure the result is the same version of perl,
+ by checking Config::myconfig() for a match against the current
+ perl. [Reported by Edward Sabol]
+
+ - Fixed a fatal error on Win32 (and any other platform that doesn't
+ define an installation location for Unix-style man pages) during
+ installation.
+
+0.23 Sun Feb 8 22:01:18 CST 2004
+
+ - Fixed a compatibility problem in pass-through Makefiles (created by
+ Module::Build::Compat). Some 'make' utilities (for example, BSD
+ make) didn't like a '@' by itself on a line, so we stole some
+ 'NOOP' code from MakeMaker to fix it. [Reported by Mathieu Arnold]
+
+ - Added a 'ppm_dist' action, which just makes the PPD file and then
+ makes a tarball out of the blib/ directory. [Randy Sims]
+
+ - The @INC of the parent process is now propagated to child processes
+ when processing *.PL files. [Reported by Jaap Karssenberg]
+
+ - We now only attempt to fix the shebang line on a script if the
+ shebang line matches the regex /perl/i . This fixes some instances
+ where people put shell scripts in their distributions. [Jaap
+ Karssenberg]
+
+ - We no longer generate a 'requires', 'recommends', 'conflicts',
+ etc. entry in the META.yml file if there's no data to go in it.
+
+ - Added a documentation reference to Michael Schwern's wiki for tips
+ on conversion from MakeMaker to M::B. [Randy Sims]
+
+ - If there are script_files, we now add EXE_FILES to the
+ 'traditional' Makefile.PL generated by M::B::Compat. [Suggested by
+ Yuval Kogman]
+
+ - Documented the 'test_files' parameter to new(). [Reported by Tony
+ Bowden]
+
+ - Fixed a problem in "Build help <action>", which didn't find the
+ correct help chunk if <action> was the final element in a POD
+ list. [Jaap Karssenberg]
+
+ - Fixed a problem in the get_action_docs() method which gave
+ incorrect results if the method was called more than once in the
+ same program.
+
+ - Fixed a problem in which actions defined by user subclasses
+ wouldn't be available via the pass-through Makefiles created by
+ Module::Build::Compat. [Reported by Jaap Karssenberg]
+
+ - We now use Data::Dumper instead of our own ad-hoc serialization
+ routines to create the 'traditional' Makefile.PL
+ arguments. [Suggested by Yuval Kojman]
+
+0.22 Sat Jan 10 22:05:39 CST 2004
+
+ - On Unixish platforms, the syntax "FOO=BAR /bin/baz arg arg" now
+ works when present in $Config{ld}. This solves a problem on Mac OS
+ X 10.3. [Reported by Adam Foxson]
+
+ - The have_c_compiler() now also tests whether the linker seems to
+ work too.
+
+ - Fixed a problem with creating the distribution tarball in which
+ permissions would usually be all read-only. We now use our own
+ file-copying routines rather than those in ExtUtils::Manifest,
+ because those do some annoying extra permissions-setting stuff for
+ no apparent reason. It makes me happy that this was a very very
+ easy patch to make. [Reported by Thomas Klausner]
+
+ - The compile_c() method now includes $Config{cccdlflags} in its
+ command invocation. It's usually empty, but not always, so we
+ didn't notice for a while. [Richard Clamp]
+
+ - On some platforms it's common to have a $Config{make} defined, but
+ no 'make' utility actually available. We now detect this and skip
+ some 'make' compatibility tests. [Randy Sims]
+
+ - Fixed a spurious testing failure on non-Unix platforms that
+ happened because we accidentally call localize_file_path() on empty
+ strings in the test suite. [Spotted by Randy Sims on Windows]
+
+ - Made the 'name', 'abstract', 'author', and 'version' properties
+ required when building a PPD file. [Spotted by Randy Sims, Dave
+ Rolsky, & Glenn Linderman]
+
+ - When building a 'traditional' Makefile.PL with
+ Module::Build::Compat, we now use 'VERSION_FROM' when possible,
+ rather than always using 'VERSION'. This way the Makefile.PL
+ doesn't have to get modified every release.
+
+ - Made some fixups to the 'PPM' info-file, improving compatibility
+ with ActiveState's PPM tools. [Randy Sims, Glenn Linderman]
+
+ - The 'dist_author' property can now accept multiple authors, see the
+ docs for more info. [Randy Sims]
+
+ - If the user doesn't have YAML.pm installed during ACTION_dist, we
+ now create a minimal YAML.pm anyway, without any dependency
+ information.
+
+ - The 'distribution_type' field is no longer created in META.yml
+ files, in accordance with the finding made at the London CLPAN
+ meeting that it's essentially meaningless and ill-defined.
+
+ - The 'dist' action now accepts an optional 'tar' parameter to use a
+ system utility for building the tarball, and a 'gzip' parameter for
+ compressing it. If these are used, Archive::Tar won't be invoked.
+ This was added because Archive::Tar is producing some very
+ non-cross-platform tarballs that many tar utilities can't handle.
+
+ - During testing, if YAML.pm isn't installed, then we won't try
+ making a tarball either, since this would invoke YAML to create the
+ META.yml file.
+
+ - Fixed a problem with chmod() being called incorrectly on MacOS
+ (i.e. MacPerl, not Mac OS X). [Spotted by Paul Sanford Toney]
+
+ - Fixed a problem with the --config flag not being treated properly
+ (essentially ignored) on the command line for 'perl Build.PL' or
+ 'Build <action>'. [Spotted by Jakub Bogusz]
+
+ - Added a new config() method to get at the Build object's notion of
+ the %Config hash.
+
+ - Test::Harness is starting to contend for the Most Crotchety Module
+ Award. Work around a few of its nits when setting harness
+ switches. [Spotted by Diab Jerius]
+
+ - Now the Build script will die() if we're run from the wrong
+ directory, rather than trying to chdir() to what it thinks is the
+ right directory and do its work there. See
+ https://rt.cpan.org/Ticket/Display.html?id=4039 . [Chris Dolan]
+
+ - Changed the manpage separator on OS/2 to '.'. [Ilya Zakharevich]
+
+ - On OS/2, disable C compilation, since apparently it isn't working
+ there. [Reported by Ilya Zakharevich]
+
+ - Inserted a comment into auto-generated Makefile.PLs saying it was
+ auto-generated. [Randy Sims]
+
+ - Fixed some annoying behavior in generated passthrough Makefile.PLs
+ when the user chose not to install Module::Build, or if
+ installation failed. [Reported by Ilya Zakharevich and Richard
+ Clamp]
+
+ - Moved the documentation for 'codebase' to the section where it's
+ relevant. [Randy Sims, Glenn Linderman]
+
+ - Fixed a have_c_compiler() failure on some platforms, we now define
+ a boot_compilet() function (since we're compiling a library, not an
+ executable). [Randy Sims]
+
+ - Added a recipe to the Module::Build::Cookbook describing how to
+ maintain compatibility with older versions of CPAN.pm [Jim Cromie]
+
+ - Removed caveat about "looking for alternatives" in how hashes are
+ specified on the command line, since an alternative has been found.
+
+ - Previously most warnings about optional prerequisites looked like
+ they were actually error messages about required prerequisites.
+ This has been corrected. [Reported again by Sagar Shah]
+
+ - Added support for building XS (and C in general) stuff on AIX.
+ This was done by a small reorganization of prelink_c() method from
+ Windows.pm to Build.pm, and it is only invoked for the platforms
+ that need it invoked. AIX also massages some very naughty bits
+ (MakeMaker macro variables) in $Config{lddlflags} that should never
+ have been put there, but alas, they're there, so we find & resolve
+ them.
+
+ - Added OS/2 ($^O = 'os2') to the list of Unix-like platforms. This
+ basically means that most platform-specific operations will be done
+ in a Unix-like manner.
+
+ - Pass-through Makefiles will now die() when they're given a PREFIX
+ parameter, and suggest using 'destdir' or 'install_base' instead.
+ Previously they just ignored the parameter and tried to install to
+ the default location, which is clearly not what the user wanted.
+
+ - Updated my email address in the documentation to a more recent
+ variant.
+
+ - Add NetBSD to the list of Unix-like systems. [Adrian Bunk]
+
+ - Add SVR5 to the list of Unix-like systems. [Rafael Garcia-Suarez]
+
+ - We now use Pod::Parser to find the ABSTRACT and AUTHOR when it's
+ available on the system. [initial patch by Randy Sims]
+
+ - Fixed a little scalar/list buglet in a documentation example.
+
+0.21 Wed Oct 15 20:47:05 CDT 2003
+
+ - Added a have_c_compiler() method.
+
+ - Added documentation for the requires(), recommends(),
+ build_requires(), and conflicts() methods.
+
+ - On Unix platforms, we now create the "Build" script with a #! line
+ matching the perl interpreter that was used to invoke the Build.PL
+ script, rather than whatever is in $Config{startperl}. This avoids
+ a potential warning about the interpreters not matching. [Spotted
+ by Ken Y. Clark]
+
+ - The Unix version now uses the safer multi-argument form of system()
+ when building distribution tarballs.
+
+ - Added a regression test for the 'dist' action to the t/runthrough.t
+ test.
+
+ - Fixed a problem with File::Spec usage when creating the names of
+ 'libdoc' manual pages - the code wasn't dealing with the volume or
+ file portions correctly on certain platforms.
+
+ - When creating the names of the 'libdoc' manual pages, we no longer
+ assume that pods are under the hard-coded paths 'blib/lib' or
+ 'blib/arch'.
+
+ - Fixed a crashing bug that could sometimes occur when the
+ distribution contained no 'lib' directory. [Chris Dolan]
+
+ - Fixed a crashing bug that happened when the user had .PL files in
+ the lib/ directory and didn't explicitly name them in a hash
+ reference to the new() constructor. [Chris Reinhardt, bug #4036]
+
+ - .PL files are now passed the names of their target file(s) on the
+ command line when they run.
+
+ - When YAML.pm wasn't installed, t/runthrough.t wasn't properly
+ skipping some tests that required YAML. This is now fixed.
+ [Stephen J. Smith]
+
+ - Added documentation for the dist_version() and dist_name()
+ methods. [Spotted by Johan Vromans]
+
+ - Existing values in $ENV{HARNESS_PERL_SWITCHES} are now respected
+ and not squashed when we run the 'test' action. [Paul Johnson]
+
+ - On cygwin, the separator string for manual page names has been set
+ to '.'. Previously it was '::', inherited from Unix. [Yitzchak
+ Scott-Thoennes]
+
+ - Avoid a warning when Build.PL is run (i.e. when the new() method is
+ called) and no MANIFEST file exists. [Michael Schwern and Kevin
+ Ruscoe]
+
+ - Added documentation for the 'code' and 'docs' actions. [Steve
+ Purkis and Mark Stosberg]
+
+ - The internal method compile_support_files() has been renamed to
+ process_support_files() in order to make it consistent with other
+ processing methods. Note that it was never documented using the
+ old name. It's still not documented, actually. Maybe later.
+
+ - Skip the 'write' pseudo-entry in the 'diff' action's installation
+ map. [Chris Dolan]
+
+ - Fixed a bug in which notes() set in the Build.PL before
+ create_build_script() was called would get lost unless more notes()
+ were also set afterwards. [Spotted by Dave Rolsky]
+
+ - The process of building elements of the distribution is now driven
+ by a list of build elements, paving the way for letting people add
+ their own types of build elements in future versions of
+ Module::Build (or in the current version with some difficulty).
+
+ - Fixed some linking errors on Cygwin. [Randy Sims, Terrence Brannon]
+
+ - Fixed a line-ending problem with detecting the dist_abstract
+ properly on Cygwin. [Randy Sims]
+
+ - Fixed a problem with signatures that occurred if 'distsign' was
+ called before 'distdir' - the signature would be generated twice.
+
+ - Added a 'create_readme' parameter to new(), which will use
+ Pod::Text to generate a README from the main (dist_version_from)
+ module file during the 'distdir' action.
+
+ - We now refuse to run the 'Build' script if it was created using a
+ different version of Module::Build. This has caused a couple of
+ nasty bugs in the past, I don't want to know what it would cause in
+ the future.
+
+ - Documentation for do_system() has been added. [Dave Rolsky]
+
+ - run_perl_script() is now available as a class method, though it
+ will need to (re-)find the perl interpreter in this case.
+
+ - Added a new_from_context() method that authors of automated tools
+ like CPANPLUS and CPAN can use instead of running all tasks as
+ sub-processes. We also use it in the regression tests for
+ Module::Build itself. ** Note that this method is currently
+ undocumented because its name may change in the future. **
+
+ - When signing distributions with Module::Signature, we now
+ automatically add the SIGNATURE file to the MANIFEST, avoiding an
+ unpleasant chicken/egg problem for the module author.
+ [unpleasantness spotted by sungo]
+
+ - In Module::Build::Compat, added support for the 'verbose' parameter
+ to Makefile.PL [spotted by Soren Andersen, fixed by Michael
+ Schwern]
+
+ - The Module::Build distribution now has a cryptographic 'SIGNATURE'
+ file created by Module::Signature.
+
+ - Added proper documentation for the subclass() method. [spotted by
+ Jonathan Steinert]
+
+ - Worked around a Config.pm bug in Red Hat 9 which prevented man
+ pages from being installed in the correct places. [spotted by Ville
+ Skytta]
+
+ - Fixed a Module::Build::Compat bug in which setting INSTALLDIRS
+ caused a crash. [spotted by Ilya Martynov]
+
+0.20 Tue Aug 26 14:34:07 CDT 2003
+
+ - Separated the 'build' action into two separate actions, 'code' and
+ 'docs'. This is similar to MakeMaker's separation of the 'all'
+ target into 'pure_all' and 'manifypods'. This fixes a permissions
+ hassle in which doing 'sudo Build install' would often create local
+ doc files that needed superuser permissions to delete.
+
+ - Enhanced the 'help' action - 'Build help foo' will now show the POD
+ documentation for the 'foo' action.
+
+ - Added a notes() feature, which helps share data transparently
+ between the Build.PL and t/*.t scripts.
+
+ - The installation process will now create man(1) and man(3) pages
+ from POD in modules & scripts, and install them. We don't build
+ man pages when there's nowhere to install them, such as on some
+ Win32 or most Mac systems. [large patch by Steve Purkis, 5.005 fix
+ by Mathieu Arnold]
+
+ - The 'distdir' action now copies files to the distribution
+ directory, rather than making them hard links to the original
+ files. This allows authors to do last-minute alterations of the
+ files without affecting the originals. [Dave Rolsky]
+
+ - If the author uses XS files in nonstandard locations, the copied
+ versions of those files will now be cleaned up properly.
+
+ - In invoking the 'test' action or invoking 'xsubpp', we now use the
+ same perl executable as we use everywhere else, rather than blindly
+ using $^X or $Config{perlpath} (neither of which are very
+ reliable).
+
+ - Fixed a problem with the 'install_path' parameter given to
+ 'Build.PL' being lost in subsequent actions. [Reported by Mathieu
+ Arnold]
+
+ - Fixed yet another bug with installation directories, in which the
+ 'install_base' parameter wasn't being respected on the command
+ line. [Spotted by Jonathan Swartz]
+
+ - Changed the way the depends_on() method works inside action
+ subroutines - now each action will only run once per dispatch()
+ invocation (similar to how perl's require() function works). This
+ helps avoid some difficult problems with dependency loops.
+
+ - Changed the documentation for the 'autosplit' parameter to give
+ reasons why it may not be a good idea to use, but no longer
+ threaten to remove it. [Suggested by Martyn J. Pearce]
+
+ - Improved the formatting of the 'traditional' Makefile.PL generated
+ by Module::Build::Compat->create_makefile_pl. [Michael Schwern]
+
+ - The 'traditional' Makefile.PL will now use the 'module_name'
+ parameter (as NAME) if it's available, otherwise it will continue
+ to use the 'dist_name' (as DISTNAME). [Michael Schwern]
+
+ - Created read/write accessor methods for all our 'properties'.
+ [Michael Schwern]
+
+ - The 'test_files' parameter can now be specified using glob() syntax
+ (i.e. 't/*.t'), and the corresponding test_files() method is now a
+ read/write accessor.
+
+ - The location of the 'blib' directory is now a property of the Build
+ object - nobody is likely to notice this change, with any luck, but
+ it makes the design and code cleaner.
+
+ - The 'disttest' and 'distsign' methods now chdir() back to the
+ directory where they started, rather than to the base_dir of the
+ build.
+
+ - Improved comparisons of version strings containing underscore
+ characters (indicating "beta" status). [Steve Purkis]
+
+ - Added documentation for the 'dist_author', 'dist_abstract', and
+ 'codebase' parameters to new(), and for the 'ppd' action. [Dave
+ Rolsky]
+
+ - Added documentation for the up_to_date() and contains_pod()
+ methods. [Dave Rolsky]
+
+ - 'traditional' pass-through Makefile.PLs will now contain an
+ INSTALLDIRS parameter matching the Build.PL's 'installdirs'
+ setting.
+
+ - version_from_file() now ignores $VERSION variables that are defined
+ in POD or comments. It can still be tricked by $VERSIONs in string
+ literals, though. [Steve Purkis]
+
+ - The code to find packages in module files now uses Steve's scanning
+ method (above) to skip package-declaration-lookalikes in POD or
+ comments.
+
+ - The 'disttest' action will now propagate its @INC settings to its
+ subprocesses.
+
+0.19 Wed Jul 9 22:34:02 CDT 2003
+
+ - Added support for the 'install_path' parameter, which allows custom
+ specification of where things should be installed. This is a major
+ improvement to Module::Build's functionality.
+
+ - Added the 'install_base' parameter. Provides an easy way to
+ install to local or alternative directory trees.
+
+ - We now install scripts by default to $Config{installsitebin}
+ instead of $Config{installscript}. Neither is a great choice, but
+ the former is likely to be [analogous to] /usr/local/bin, and the
+ latter is likely to be [something like] /usr/bin . If/when there's
+ a $Config{installsitescript}, we'll start using that automatically.
+
+ - Fixed a problem on Win32 in which C and XS files wouldn't be
+ compiled properly, and the user would see an error about 'Can't
+ locate object method "format_compiler_cmd"'.
+ (http://rt.cpan.org/Ticket/Display.html?id=2391)
+
+ - We now use the correct perl interpreter (via
+ Module::Build->find_perl_interpreter) in pass-through makefiles.
+
+ - The t/compat.t test now uses $Config{make} instead of just 'make'
+ to test makefile compatibility. This fixes some failures on Win32.
+ We also skip this test entirely if no make utility is available.
+
+ - Alternative distribution layouts are now supported via the
+ 'pm_files', 'pod_files', 'xs_files', 'PL_files', and 'script_files'
+ parameters to new(). This should help people transition from
+ MakeMaker, and might even help us write an automatic transition
+ tool.
+
+ - Added tests to t/runthrough.t that check to see installation is
+ happening correctly.
+
+ - Added experimental code to build a .ppd file, in support of
+ ActiveState's "Perl Package Manager". [original patch by Dave
+ Rolsky]
+
+ - For authors who use Module::Signature to sign their distributions,
+ we now create the SIGNATURE file right in the distribution
+ directory, rather than creating it in the top-level directory and
+ copying it into place. This solves problems related to having
+ files get out of date with respect to their signatures.
+
+ - We now don't depend on Module::Info to scan for packages during the
+ 'dist' action anymore, because it's way too aggressive about
+ loading other modules that you may not want loaded. We now just
+ (ick, yuck) scan the .pm files with a regular expression to find
+ "package Foo::Bar;" statements.
+
+ - Silenced some annoying copyright/logo output from Microsoft 'nmake'
+ during Makefile compatibility testing. [Randy W. Sims]
+
+ - Command-line arguments may now either be specified using the syntax
+ '--foo foovalue' as well as the traditional syntax 'foo=foovalue'.
+ The former is often more convenient for shell tab-completion when
+ the value is a filename (as in 'Build test --test_files t/basic.t').
+
+ - Command-line arguments may now include non-named parameters, which
+ make some actions more natural. For instance, the 'diff' action
+ may now be invoked as 'Build diff -u' rather than as
+ 'Build diff flags=-u'.
+
+ - Pass-through Makefile.PLs now convert unknown Makefile.PL
+ parameters to lower-case and hand them to Build.PL, rather than
+ ignoring them. This means we only have to account for the
+ differences in the interface, not the entire interface, in
+ translating parameters.
+
+ - We now issue a warning & don't proceed if asked to make a distdir
+ and there's no MANIFEST or it's empty.
+
+ - Moved INSTALL to INSTALL.txt to increase compatibility with various
+ odd versions of 'make' during 'make install' on case-insensitive
+ filesystems (like nmake on Win32, often). Only affects the
+ Makefile compatibility layer. [reported by Andrew Savige]
+
+ - Module::Build->known_actions() now works as a class method.
+
+ - Pass-through makefiles now list each action individually rather
+ than using a ".DEFAULT" catch-all. This improves compatibility
+ with 'nmake' on Win32, and probably some other less common 'make'
+ dialects. [Andrew Savige]
+
+ - We're now more aggressive about testing the pass-through makefiles,
+ e.g. making sure they can run 'all' and 'test' targets, and making
+ sure the Makefile itself actually exists.
+
+ - Fixed a problem with check_installed_status() when installed
+ version contains non-numeric characters like underscores.
+
+ - Fixed a problem with a bareword 'File::Spec' in one of the test
+ scripts that caused it not to compile under 5.8.0 (but is fine
+ under 5.6).
+
+ - Fixed a problem with the 'destdir' installation parameter on
+ platforms that have volume identifiers in path names (like "C:" on
+ Win32). The identifier is now stripped from installation
+ directories before prepending the destdir path. The destdir path
+ may still have a volume identifier on it.
+
+ - Added an 'add_to_cleanup' parameter to new() that calls
+ add_to_cleanup() immediately for the given files.
+
+ - The distribution directory (e.g. Sample-Module-0.13/ ) will now be
+ deleted during the 'clean' or 'realclean' actions.
+
+ - During testing of modules, blib/lib and blib/arch are now added as
+ absolute paths, not relative. This helps tests that load the
+ modules at runtime and may change the current working directory
+ (like Module::Build itself does during testing).
+
+ - The $Config{cc} entry on some people's systems is something like
+ 'ccache gcc', so we now split that string using split_like_shell().
+ [Richard Clamp]
+
+ - Added documentation for 'extra_linker_flags' parameter, and added a
+ corresponding 'extra_compiler_flags' parameter. [original patch by
+ Richard Clamp]
--- /dev/null
+package Module::Build::Compat;
+
+use strict;
+use vars qw($VERSION);
+$VERSION = '0.03';
+
+use File::Spec;
+use IO::File;
+use Config;
+use Module::Build;
+use Module::Build::ModuleInfo;
+use Data::Dumper;
+
+my %makefile_to_build =
+ (
+ TEST_VERBOSE => 'verbose',
+ VERBINST => 'verbose',
+ INC => sub { map {('--extra_compiler_flags', "-I$_")} Module::Build->split_like_shell(shift) },
+ POLLUTE => sub { ('--extra_compiler_flags', '-DPERL_POLLUTE') },
+ INSTALLDIRS => sub {local $_ = shift; 'installdirs=' . (/^perl$/ ? 'core' : $_) },
+ LIB => sub { ('--install_path', 'lib='.shift()) },
+
+ # Some names they have in common
+ map {$_, lc($_)} qw(DESTDIR PREFIX INSTALL_BASE UNINST),
+ );
+
+
+
+sub create_makefile_pl {
+ my ($package, $type, $build, %args) = @_;
+
+ die "Don't know how to build Makefile.PL of type '$type'"
+ unless $type =~ /^(small|passthrough|traditional)$/;
+
+ my $fh;
+ if ($args{fh}) {
+ $fh = $args{fh};
+ } else {
+ $args{file} ||= 'Makefile.PL';
+ $fh = IO::File->new("> $args{file}") or die "Can't write $args{file}: $!";
+ }
+
+ print {$fh} "# Note: this file was auto-generated by ", __PACKAGE__, " version $VERSION\n";
+
+ # If a custom subclass is being used, make sure we add its directory to @INC
+ my $subclass_load = '';
+ if (ref($build) ne "Module::Build") {
+ my $subclass_dir = $package->subclass_dir($build);
+
+ if (File::Spec->file_name_is_absolute($subclass_dir)) {
+ my $base_dir = $build->base_dir;
+
+ if ($build->dir_contains($base_dir, $subclass_dir)) {
+ $subclass_dir = File::Spec->abs2rel($subclass_dir, $base_dir);
+ } else {
+ $build->log_warn("Warning: builder subclass " . ref($build) .
+ " doesn't seem to have been loaded from within $base_dir");
+ }
+ }
+ $subclass_load = "use lib '$subclass_dir';";
+ }
+
+ if ($type eq 'small') {
+ printf {$fh} <<'EOF', $subclass_load, ref($build), ref($build);
+ use Module::Build::Compat 0.02;
+ %s
+ Module::Build::Compat->run_build_pl(args => \@ARGV);
+ require %s;
+ Module::Build::Compat->write_makefile(build_class => '%s');
+EOF
+
+ } elsif ($type eq 'passthrough') {
+ printf {$fh} <<'EOF', $subclass_load, ref($build), ref($build);
+
+ unless (eval "use Module::Build::Compat 0.02; 1" ) {
+ print "This module requires Module::Build to install itself.\n";
+
+ require ExtUtils::MakeMaker;
+ my $yn = ExtUtils::MakeMaker::prompt
+ (' Install Module::Build now from CPAN?', 'y');
+
+ unless ($yn =~ /^y/i) {
+ die " *** Cannot install without Module::Build. Exiting ...\n";
+ }
+
+ require Cwd;
+ require File::Spec;
+ require CPAN;
+
+ # Save this 'cause CPAN will chdir all over the place.
+ my $cwd = Cwd::cwd();
+
+ # There seems to be no way to determine if this install was successful
+ CPAN::Shell->install('Module::Build::Compat');
+
+ chdir $cwd or die "Cannot chdir() back to $cwd: $!";
+ }
+ eval "use Module::Build::Compat 0.02; 1" or die $@;
+ %s
+ Module::Build::Compat->run_build_pl(args => \@ARGV);
+ require %s;
+ Module::Build::Compat->write_makefile(build_class => '%s');
+EOF
+
+ } elsif ($type eq 'traditional') {
+
+ my (%MM_Args, %prereq);
+ if (eval "use Tie::IxHash; 1") {
+ tie %MM_Args, 'Tie::IxHash'; # Don't care if it fails here
+ tie %prereq, 'Tie::IxHash'; # Don't care if it fails here
+ }
+
+ my %name = ($build->module_name
+ ? (NAME => $build->module_name)
+ : (DISTNAME => $build->dist_name));
+
+ my %version = ($build->dist_version_from
+ ? (VERSION_FROM => $build->dist_version_from)
+ : (VERSION => $build->dist_version)
+ );
+ %MM_Args = (%name, %version);
+
+ %prereq = ( %{$build->requires}, %{$build->build_requires} );
+ %prereq = map {$_, $prereq{$_}} sort keys %prereq;
+
+ delete $prereq{perl};
+ $MM_Args{PREREQ_PM} = \%prereq;
+
+ $MM_Args{INSTALLDIRS} = $build->installdirs eq 'core' ? 'perl' : $build->installdirs;
+
+ $MM_Args{EXE_FILES} = [ sort keys %{$build->script_files} ] if $build->script_files;
+
+ $MM_Args{PL_FILES} = {};
+
+ local $Data::Dumper::Terse = 1;
+ my $args = Data::Dumper::Dumper(\%MM_Args);
+ $args =~ s/\{(.*)\}/($1)/s;
+
+ print $fh <<"EOF";
+use ExtUtils::MakeMaker;
+WriteMakefile
+$args;
+EOF
+ }
+}
+
+
+sub subclass_dir {
+ my ($self, $build) = @_;
+
+ return (Module::Build::ModuleInfo->find_module_dir_by_name(ref $build)
+ || File::Spec->catdir($build->config_dir, 'lib'));
+}
+
+sub makefile_to_build_args {
+ shift;
+ my @out;
+ foreach my $arg (@_) {
+ next if $arg eq '';
+
+ my ($key, $val) = ($arg =~ /^(\w+)=(.+)/ ? ($1, $2) :
+ die "Malformed argument '$arg'");
+
+ # Do tilde-expansion if it looks like a tilde prefixed path
+ ( $val ) = glob( $val ) if $val =~ /^~/;
+
+ if (exists $makefile_to_build{$key}) {
+ my $trans = $makefile_to_build{$key};
+ push @out, ref($trans) ? $trans->($val) : ("--$trans", $val);
+ } elsif (exists $Config{lc($key)}) {
+ push @out, '--config', lc($key) . "=$val";
+ } else {
+ # Assume M::B can handle it in lowercase form
+ push @out, "--\L$key", $val;
+ }
+ }
+ return @out;
+}
+
+sub makefile_to_build_macros {
+ my @out;
+ while (my ($macro, $trans) = each %makefile_to_build) {
+ # On some platforms (e.g. Cygwin with 'make'), the mere presence
+ # of "EXPORT: FOO" in the Makefile will make $ENV{FOO} defined.
+ # Therefore we check length() too.
+ next unless exists $ENV{$macro} && length $ENV{$macro};
+ my $val = $ENV{$macro};
+ push @out, ref($trans) ? $trans->($val) : ($trans => $val);
+ }
+ return @out;
+}
+
+sub run_build_pl {
+ my ($pack, %in) = @_;
+ $in{script} ||= 'Build.PL';
+ my @args = $in{args} ? $pack->makefile_to_build_args(@{$in{args}}) : ();
+ print "# running $in{script} @args\n";
+ Module::Build->run_perl_script($in{script}, [], \@args) or die "Couldn't run $in{script}: $!";
+}
+
+sub fake_makefile {
+ my ($self, %args) = @_;
+ unless (exists $args{build_class}) {
+ warn "Unknown 'build_class', defaulting to 'Module::Build'\n";
+ $args{build_class} = 'Module::Build';
+ }
+
+ my $perl = $args{build_class}->find_perl_interpreter;
+ my $os_type = $args{build_class}->os_type;
+ my $noop = ($os_type eq 'Windows' ? 'rem>nul' :
+ $os_type eq 'VMS' ? 'Continue' :
+ 'true');
+ my $Build = 'Build --makefile_env_macros 1';
+
+ # Start with a couple special actions
+ my $maketext = <<"EOF";
+all : force_do_it
+ $perl $Build
+realclean : force_do_it
+ $perl $Build realclean
+ $perl -e unlink -e shift $args{makefile}
+
+force_do_it :
+ @ $noop
+EOF
+
+ foreach my $action ($args{build_class}->known_actions) {
+ next if $action =~ /^(all|realclean|force_do_it)$/; # Don't double-define
+ $maketext .= <<"EOF";
+$action : force_do_it
+ $perl $Build $action
+EOF
+ }
+
+ $maketext .= "\n.EXPORT : " . join(' ', keys %makefile_to_build) . "\n\n";
+
+ return $maketext;
+}
+
+sub fake_prereqs {
+ my $file = File::Spec->catfile('_build', 'prereqs');
+ my $fh = IO::File->new("< $file") or die "Can't read $file: $!";
+ my $prereqs = eval do {local $/; <$fh>};
+ close $fh;
+
+ my @prereq;
+ foreach my $section (qw/build_requires requires/) {
+ foreach (keys %{$prereqs->{$section}}) {
+ next if $_ eq 'perl';
+ push @prereq, "$_=>q[$prereqs->{$section}{$_}]";
+ }
+ }
+
+ return unless @prereq;
+ return "# PREREQ_PM => { " . join(", ", @prereq) . " }\n\n";
+}
+
+
+sub write_makefile {
+ my ($pack, %in) = @_;
+ $in{makefile} ||= 'Makefile';
+ open MAKE, "> $in{makefile}" or die "Cannot write $in{makefile}: $!";
+ print MAKE $pack->fake_prereqs;
+ print MAKE $pack->fake_makefile(%in);
+ close MAKE;
+}
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Compat - Compatibility with ExtUtils::MakeMaker
+
+
+=head1 SYNOPSIS
+
+ # In a Build.PL :
+ use Module::Build;
+ my $build = Module::Build->new
+ ( module_name => 'Foo::Bar',
+ license => 'perl',
+ create_makefile_pl => 'passthrough' );
+ ...
+
+
+=head1 DESCRIPTION
+
+Because ExtUtils::MakeMaker has been the standard way to distribute
+modules for a long time, many tools (CPAN.pm, or your system
+administrator) may expect to find a working Makefile.PL in every
+distribution they download from CPAN. If you want to throw them a
+bone, you can use Module::Build::Compat to automatically generate a
+Makefile.PL for you, in one of several different styles.
+
+Module::Build::Compat also provides some code that helps out the
+Makefile.PL at runtime.
+
+
+=head1 METHODS
+
+=over 4
+
+=item create_makefile_pl($style, $build)
+
+Creates a Makefile.PL in the current directory in one of several
+styles, based on the supplied Module::Build object C<$build>. This is
+typically controlled by passing the desired style as the
+C<create_makefile_pl> parameter to Module::Build's C<new()> method;
+the Makefile.PL will then be automatically created during the
+C<distdir> action.
+
+The currently supported styles are:
+
+=over 4
+
+=item small
+
+A small Makefile.PL will be created that passes all functionality
+through to the Build.PL script in the same directory. The user must
+already have Module::Build installed in order to use this, or else
+they'll get a module-not-found error.
+
+=item passthrough
+
+This is just like the C<small> option above, but if Module::Build is
+not already installed on the user's system, the script will offer to
+use C<CPAN.pm> to download it and install it before continuing with
+the build.
+
+=item traditional
+
+A Makefile.PL will be created in the "traditional" style, i.e. it will
+use C<ExtUtils::MakeMaker> and won't rely on C<Module::Build> at all.
+In order to create the Makefile.PL, we'll include the C<requires> and
+C<build_requires> dependencies as the C<PREREQ_PM> parameter.
+
+You don't want to use this style if during the C<perl Build.PL> stage
+you ask the user questions, or do some auto-sensing about the user's
+environment, or if you subclass Module::Build to do some
+customization, because the vanilla Makefile.PL won't do any of that.
+
+=back
+
+=item run_build_pl(args => \@ARGV)
+
+This method runs the Build.PL script, passing it any arguments the
+user may have supplied to the C<perl Makefile.PL> command. Because
+ExtUtils::MakeMaker and Module::Build accept different arguments, this
+method also performs some translation between the two.
+
+C<run_build_pl()> accepts the following named parameters:
+
+=over 4
+
+=item args
+
+The C<args> parameter specifies the parameters that would usually
+appear on the command line of the C<perl Makefile.PL> command -
+typically you'll just pass a reference to C<@ARGV>.
+
+=item script
+
+This is the filename of the script to run - it defaults to C<Build.PL>.
+
+=back
+
+=item write_makefile()
+
+This method writes a 'dummy' Makefile that will pass all commands
+through to the corresponding Module::Build actions.
+
+C<write_makefile()> accepts the following named parameters:
+
+=over 4
+
+=item makefile
+
+The name of the file to write - defaults to the string C<Makefile>.
+
+=back
+
+=back
+
+
+=head1 SCENARIOS
+
+So, some common scenarios are:
+
+=over 4
+
+=item 1.
+
+Just include a Build.PL script (without a Makefile.PL
+script), and give installation directions in a README or INSTALL
+document explaining how to install the module. In particular, explain
+that the user must install Module::Build before installing your
+module.
+
+Note that if you do this, you may make things easier for yourself, but
+harder for people with older versions of CPAN or CPANPLUS on their
+system, because those tools generally only understand the
+F<Makefile.PL>/C<ExtUtils::MakeMaker> way of doing things.
+
+=item 2.
+
+Include a Build.PL script and a "traditional" Makefile.PL,
+created either manually or with C<create_makefile_pl()>. Users won't
+ever have to install Module::Build if they use the Makefile.PL, but
+they won't get to take advantage of Module::Build's extra features
+either.
+
+If you go this route, make sure you explicitly set C<PL_FILES> in the
+call to C<WriteMakefile()> (probably to an empty hash reference), or
+else MakeMaker will mistakenly run the Build.PL and you'll get an
+error message about "Too early to run Build script" or something. For
+good measure, of course, test both the F<Makefile.PL> and the
+F<Build.PL> before shipping.
+
+=item 3.
+
+Include a Build.PL script and a "pass-through" Makefile.PL
+built using Module::Build::Compat. This will mean that people can
+continue to use the "old" installation commands, and they may never
+notice that it's actually doing something else behind the scenes. It
+will also mean that your installation process is compatible with older
+versions of tools like CPAN and CPANPLUS.
+
+=back
+
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001-2005 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.
+
+
+=head1 SEE ALSO
+
+Module::Build(3), ExtUtils::MakeMaker(3)
+
+
+=cut
--- /dev/null
+package Module::Build::ConfigData;
+use strict;
+my $arrayref = eval do {local $/; <DATA>}
+ or die "Couldn't load ConfigData data: $@";
+close DATA;
+my ($config, $features, $auto_features) = @$arrayref;
+
+sub config { $config->{$_[1]} }
+
+sub set_config { $config->{$_[1]} = $_[2] }
+sub set_feature { $features->{$_[1]} = 0+!!$_[2] } # Constrain to 1 or 0
+
+sub auto_feature_names { grep !exists $features->{$_}, keys %$auto_features }
+
+sub feature_names {
+ my @features = (keys %$features, auto_feature_names());
+ @features;
+}
+
+sub config_names { keys %$config }
+
+sub write {
+ my $me = __FILE__;
+ require IO::File;
+ require Data::Dumper;
+
+ my $mode_orig = (stat $me)[2] & 07777;
+ chmod($mode_orig | 0222, $me); # Make it writeable
+ my $fh = IO::File->new($me, 'r+') or die "Can't rewrite $me: $!";
+ seek($fh, 0, 0);
+ while (<$fh>) {
+ last if /^__DATA__$/;
+ }
+ die "Couldn't find __DATA__ token in $me" if eof($fh);
+
+ local $Data::Dumper::Terse = 1;
+ seek($fh, tell($fh), 0);
+ $fh->print( Data::Dumper::Dumper([$config, $features, $auto_features]) );
+ truncate($fh, tell($fh));
+ $fh->close;
+
+ chmod($mode_orig, $me)
+ or warn "Couldn't restore permissions on $me: $!";
+}
+
+sub feature {
+ my ($package, $key) = @_;
+ return $features->{$key} if exists $features->{$key};
+
+ my $info = $auto_features->{$key} or return 0;
+
+ # Under perl 5.005, each(%$foo) isn't working correctly when $foo
+ # was reanimated with Data::Dumper and eval(). Not sure why, but
+ # copying to a new hash seems to solve it.
+ my %info = %$info;
+
+ require Module::Build; # XXX should get rid of this
+ while (my ($type, $prereqs) = each %info) {
+ next if $type eq 'description' || $type eq 'recommends';
+
+ my %p = %$prereqs; # Ditto here.
+ while (my ($modname, $spec) = each %p) {
+ my $status = Module::Build->check_installed_status($modname, $spec);
+ if ((!$status->{ok}) xor ($type =~ /conflicts$/)) { return 0; }
+ }
+ }
+ return 1;
+}
+
+
+=head1 NAME
+
+Module::Build::ConfigData - Configuration for Module::Build
+
+
+=head1 SYNOPSIS
+
+ use Module::Build::ConfigData;
+ $value = Module::Build::ConfigData->config('foo');
+ $value = Module::Build::ConfigData->feature('bar');
+
+ @names = Module::Build::ConfigData->config_names;
+ @names = Module::Build::ConfigData->feature_names;
+
+ Module::Build::ConfigData->set_config(foo => $new_value);
+ Module::Build::ConfigData->set_feature(bar => $new_value);
+ Module::Build::ConfigData->write; # Save changes
+
+
+=head1 DESCRIPTION
+
+This module holds the configuration data for the C<Module::Build>
+module. It also provides a programmatic interface for getting or
+setting that configuration data. Note that in order to actually make
+changes, you'll have to have write access to the C<Module::Build::ConfigData>
+module, and you should attempt to understand the repercussions of your
+actions.
+
+
+=head1 METHODS
+
+=over 4
+
+=item config($name)
+
+Given a string argument, returns the value of the configuration item
+by that name, or C<undef> if no such item exists.
+
+=item feature($name)
+
+Given a string argument, returns the value of the feature by that
+name, or C<undef> if no such feature exists.
+
+=item set_config($name, $value)
+
+Sets the configuration item with the given name to the given value.
+The value may be any Perl scalar that will serialize correctly using
+C<Data::Dumper>. This includes references, objects (usually), and
+complex data structures. It probably does not include transient
+things like filehandles or sockets.
+
+=item set_feature($name, $value)
+
+Sets the feature with the given name to the given boolean value. The
+value will be converted to 0 or 1 automatically.
+
+=item config_names()
+
+Returns a list of all the names of config items currently defined in
+C<Module::Build::ConfigData>, or in scalar context the number of items.
+
+=item feature_names()
+
+Returns a list of all the names of features currently defined in
+C<Module::Build::ConfigData>, or in scalar context the number of features.
+
+=item auto_feature_names()
+
+Returns a list of all the names of features whose availability is
+dynamically determined, or in scalar context the number of such
+features. Does not include such features that have later been set to
+a fixed value.
+
+=item write()
+
+Commits any changes from C<set_config()> and C<set_feature()> to disk.
+Requires write access to the C<Module::Build::ConfigData> module.
+
+=back
+
+
+=head1 AUTHOR
+
+C<Module::Build::ConfigData> was automatically created using C<Module::Build>.
+C<Module::Build> was written by Ken Williams, but he holds no
+authorship claim or copyright claim to the contents of C<Module::Build::ConfigData>.
+
+=cut
+
+__DATA__
+
+[
+ {},
+ {},
+ {
+ 'YAML_support' => {
+ 'requires' => {
+ 'YAML' => ' >= 0.35, != 0.49_01 '
+ },
+ 'description' => 'Can write fully-functional META.yml files'
+ },
+ 'manpage_support' => {
+ 'requires' => {
+ 'Pod::Man' => 0
+ },
+ 'description' => 'Can create Unix man pages'
+ },
+ 'C_support' => {
+ 'requires' => {
+ 'ExtUtils::CBuilder' => '0.15'
+ },
+ 'recommends' => {
+ 'ExtUtils::ParseXS' => '1.02'
+ },
+ 'description' => 'Can compile/link C & XS code'
+ },
+ 'HTML_support' => {
+ 'requires' => {
+ 'Pod::Html' => 0
+ },
+ 'description' => 'Can create HTML documentation'
+ }
+ }
+ ]
--- /dev/null
+package Module::Build::Cookbook;
+
+
+=head1 NAME
+
+Module::Build::Cookbook - Examples of Module::Build Usage
+
+
+=head1 DESCRIPTION
+
+C<Module::Build> isn't conceptually very complicated, but examples are
+always helpful. I got the idea for writing this cookbook when
+attending Brian Ingerson's "Extreme Programming Tools for Module
+Authors" presentation at YAPC 2003, when he said, straightforwardly,
+"Write A Cookbook."
+
+The definitional of how stuff works is in the main C<Module::Build>
+documentation. It's best to get familiar with that too.
+
+
+=head1 BASIC RECIPES
+
+
+=head2 The basic installation recipe for modules that use Module::Build
+
+In most cases, you can just issue the following commands:
+
+ perl Build.PL
+ ./Build
+ ./Build test
+ ./Build install
+
+There's nothing complicated here - first you're running a script
+called F<Build.PL>, then you're running a (newly-generated) script
+called F<Build> and passing it various arguments.
+
+The exact commands may vary a bit depending on how you invoke perl
+scripts on your system. For instance, if you have multiple versions
+of perl installed, you can install to one particular perl's library
+directories like so:
+
+ /usr/bin/perl5.8.1 Build.PL
+ ./Build
+ ./Build test
+ ./Build install
+
+If you're on Windows where the current directory is always searched
+first for scripts, you'll probably do something like this:
+
+ perl Build.PL
+ Build
+ Build test
+ Build install
+
+On the old Mac OS (version 9 or lower) using MacPerl, you can
+double-click on the F<Build.PL> script to create the F<Build> script,
+then double-click on the F<Build> script to run its C<build>, C<test>,
+and C<install> actions.
+
+The F<Build> script knows what perl was used to run C<Build.PL>, so
+you don't need to re-invoke the F<Build> script with the complete perl
+path each time. If you invoke it with the I<wrong> perl path, you'll
+get a warning or a fatal error.
+
+
+=head2 Making a CPAN.pm-compatible distribution
+
+New versions of CPAN.pm understand how to use a F<Build.PL> script,
+but old versions don't. If you want to help users who have old
+versions, do the following:
+
+Create a file in your distribution named F<Makefile.PL>, with the
+following contents:
+
+ use Module::Build::Compat;
+ Module::Build::Compat->run_build_pl(args => \@ARGV);
+ Module::Build::Compat->write_makefile();
+
+Now CPAN will work as usual, i.e.: `perl Makefile.PL`, `make`, `make
+test`, and `make install`, provided the end-user already has
+C<Module::Build> installed.
+
+If the end-user might not have C<Module::Build> installed, it's
+probably best to supply a "traditional" F<Makefile.PL>. The
+C<Module::Build::Compat> module has some very helpful tools for
+keeping a F<Makefile.PL> in sync with a F<Build.PL>. See its
+documentation, and also the C<create_makefile_pl> parameter to the
+C<< Module::Build->new() >> method.
+
+
+=head2 Installing modules using the programmatic interface
+
+If you need to build, test, and/or install modules from within some
+other perl code (as opposed to having the user type installation
+commands at the shell), you can use the programmatic interface.
+Create a Module::Build object (or an object of a custom Module::Build
+subclass) and then invoke its C<dispatch()> method to run various
+actions.
+
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ license => 'perl',
+ requires => { 'Some::Module' => '1.23' },
+ );
+ $build->dispatch('build');
+ $build->dispatch('test', verbose => 1);
+ $build->dispatch('install');
+
+The first argument to C<dispatch()> is the name of the action, and any
+following arguments are named parameters.
+
+This is the interface we use to test Module::Build itself in the
+regression tests.
+
+
+=head2 Installing to a temporary directory
+
+To create packages for package managers like RedHat's C<rpm> or
+Debian's C<deb>, you may need to install to a temporary directory
+first and then create the package from that temporary installation.
+To do this, specify the C<destdir> parameter to the C<install> action:
+
+ ./Build install --destdir /tmp/my-package-1.003
+
+This essentially just prepends all the installation paths with the
+F</tmp/my-package-1.003> directory.
+
+=head2 Installing to a non-standard directory
+
+To install to a non-standard directory (for example, if you don't have
+permission to install in the system-wide directories), you can use the
+C<install_base> or C<prefix> parameters:
+
+ ./Build install --install_base /foo/bar
+ or
+ ./Build install --prefix /foo/bar
+
+Note that these have somewhat different effects - C<prefix> is an
+emulation of C<ExtUtils::MakeMaker>'s old C<PREFIX> setting, and
+inherits all its nasty gotchas. C<install_base> is more predictable,
+and newer versions of C<ExtUtils::MakeMaker> also support it, so it's
+often your best choice.
+
+See L<Module::Build/"INSTALL PATHS"> for a much more complete
+discussion of how installation paths are determined.
+
+=head2 Running a single test file
+
+C<Module::Builde> supports running a single test, which enables you to
+track down errors more quickly. Use the following format:
+
+ ./Build test --test_files t/mytest.t
+
+In addition, you may want to run the test in verbose mode to get more
+informative output:
+
+ ./Build test --test_files t/mytest.t --verbose 1
+
+I run this so frequently that I actually define the following shell alias:
+
+ alias t './Build test --verbose 1 --test_files'
+
+So then I can just execute C<t t/mytest.t> to run a single test.
+
+
+=head1 ADVANCED RECIPES
+
+
+=head2 Changing the order of the build process
+
+The C<build_elements> property specifies the steps C<Module::Build>
+will take when building a distribution. To change the build order,
+change the order of the entries in that property:
+
+ # Process pod files first
+ my @e = @{$build->build_elements};
+ my $i = grep {$e[$_] eq 'pod'} 0..$#e;
+ unshift @e, splice @e, $i, 1;
+
+Currently, C<build_elements> has the following default value:
+
+ [qw( PL support pm xs pod script )]
+
+Do take care when altering this property, since there may be
+non-obvious (and non-documented!) ordering dependencies in the
+C<Module::Build> code.
+
+
+=head2 Adding new file types to the build process
+
+Sometimes you might have extra types of files that you want to install
+alongside the standard types like F<.pm> and F<.pod> files. For
+instance, you might have a F<Bar.dat> file containing some data
+related to the C<Foo::Bar> module. Assuming the data doesn't need to
+be created on the fly, the best place for it to end up is probably as
+F<Foo/Bar.dat> somewhere in perl's C<@INC> path so C<Foo::Bar> can
+access it easily at runtime. The following code from a sample
+C<Build.PL> file demonstrates how to accomplish this:
+
+ use Module::Build;
+ my $build = Module::Build->new
+ (
+ module_name => 'Foo::Bar',
+ ...other stuff here...
+ );
+ $build->add_build_element('dat');
+ $build->create_build_script;
+
+This will find all F<.dat> files in the F<lib/> directory, copy them
+to the F<blib/lib/> directory during the C<build> action, and install
+them during the C<install> action.
+
+If your extra files aren't in the C<lib/> directory, you can
+explicitly say where they are, just as you'd do with F<.pm> or F<.pod>
+files:
+
+ use Module::Build;
+ my $build = new Module::Build
+ (
+ module_name => 'Foo::Bar',
+ dat_files => {'some/dir/Bar.dat' => 'lib/Foo/Bar.dat'},
+ ...other stuff here...
+ );
+ $build->add_build_element('dat');
+ $build->create_build_script;
+
+If your extra files actually need to be created on the user's machine,
+or if they need some other kind of special processing, you'll probably
+want to create a special method to do so, named
+C<process_${kind}_files()>:
+
+ use Module::Build;
+ my $class = Module::Build->subclass(code => <<'EOF');
+ sub process_dat_files {
+ my $self = shift;
+ ... locate and process *.dat files,
+ ... and create something in blib/lib/
+ }
+ EOF
+ my $build = $class->new
+ (
+ module_name => 'Foo::Bar',
+ ...other stuff here...
+ );
+ $build->add_build_element('dat');
+ $build->create_build_script;
+
+If your extra files don't go in F<lib/> but in some other place, see
+L<"Adding new elements to the install process"> for how to actually
+get them installed.
+
+Please note that these examples use some capabilities of Module::Build
+that first appeared in version 0.26. Before that it could certainly
+still be done, but the simple cases took a bit more work.
+
+
+=head2 Adding new elements to the install process
+
+By default, Module::Build creates seven subdirectories of the F<blib/>
+directory during the build process: F<lib/>, F<arch/>, F<bin/>,
+F<script/>, F<bindoc/>, F<libdoc/>, and F<html/> (some of these may be
+missing or empty if there's nothing to go in them). Anything copied
+to these directories during the build will eventually be installed
+during the C<install> action (see L<Module::Build/"INSTALL PATHS">.
+
+If you need to create a new type of installable element, e.g. C<conf>,
+then you need to tell Module::Build where things in F<blib/conf/>
+should be installed. To do this, use the C<install_path> parameter to
+the C<new()> method:
+
+ my $build = Module::Build->new
+ (
+ ...other stuff here...
+ install_path => { conf => $installation_path }
+ );
+
+Or you can call the C<install_path()> method later:
+
+ $build->install_path->{conf} || $installation_path;
+
+(Sneakily, or perhaps uglily, C<install_path()> returns a reference to
+a hash of install paths, and you can modify that hash to your heart's
+content.)
+
+The user may also specify the path on the command line:
+
+ perl Build.PL --install_path conf=/foo/path/etc
+
+The important part, though, is that I<somehow> the install path needs
+to be set, or else nothing in the F<blib/conf/> directory will get
+installed.
+
+See also L<"Adding new file types to the build process"> for how to
+create the stuff in F<blib/conf/> in the first place.
+
+
+=head1 EXAMPLES ON CPAN
+
+Several distributions on CPAN are making good use of various features
+of Module::Build. They can serve as real-world examples for others.
+
+
+=head2 SVN-Notify-Mirror
+
+L<http://search.cpan.org/~jpeacock/SVN-Notify-Mirror/>
+
+John Peacock, author of the C<SVN-Notify-Mirror> distribution, says:
+
+=over 4
+
+=item 1. Using C<auto_features>, I check to see whether two optional
+modules are available - SVN::Notify::Config and Net::SSH;
+
+=item 2. If the S::N::Config module is loaded, I automatically
+generate testfiles for it during Build (using the C<PL_files>
+property).
+
+=item 3. If the C<ssh_feature> is available, I ask if the user wishes
+to perform the ssh tests (since it requires a little preliminary
+setup);
+
+=item 4. Only if the user has C<ssh_feature> and answers yes to the
+testing, do I generate a test file.
+
+I'm sure I could not have handled this complexity with EU::MM, but it
+was very easy to do with M::B.
+
+=back 4
+
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001-2005 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.
+
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3)
+
+=cut
--- /dev/null
+package Module::Build::ModuleInfo;
+
+# This module provides routines to gather information about
+# perl modules (assuming this may be expanded in the distant
+# parrot future to look at other types of modules).
+
+use strict;
+
+use File::Spec;
+use IO::File;
+
+
+my $PKG_REGEXP = qr/ # match a package declaration
+ ^[\s\{;]* # intro chars on a line
+ package # the word 'package'
+ \s+ # whitespace
+ ([\w:]+) # a package name
+ \s* # optional whitespace
+ ; # semicolon line terminator
+/x;
+
+my $VARNAME_REGEXP = qr/ # match fully-qualified VERSION name
+ ([\$*]) # sigil - $ or *
+ (
+ ( # optional leading package name
+ (?:::|\')? # possibly starting like just :: (ala $::VERSION)
+ (?:\w+(?:::|\'))* # Foo::Bar:: ...
+ )?
+ VERSION
+ )\b
+/x;
+
+my $VERS_REGEXP = qr/ # match a VERSION definition
+ (?:
+ \(\s*$VARNAME_REGEXP\s*\) # with parens
+ |
+ $VARNAME_REGEXP # without parens
+ )
+ \s*
+ =[^=~] # = but not ==, nor =~
+/x;
+
+
+sub new_from_file {
+ my $package = shift;
+ my $filename = File::Spec->rel2abs( shift );
+ return undef unless defined( $filename ) && -f $filename;
+ return $package->_init( undef, $filename, @_ );
+}
+
+sub new_from_module {
+ my $package = shift;
+ my $module = shift;
+ my %props = @_;
+ $props{inc} ||= \@INC;
+ my $filename = $package->find_module_by_name( $module, $props{inc} );
+ return undef unless defined( $filename ) && -f $filename;
+ return $package->_init( $module, $filename, %props );
+}
+
+sub _init {
+ my $package = shift;
+ my $module = shift;
+ my $filename = shift;
+
+ my %props = @_;
+ my( %valid_props, @valid_props );
+ @valid_props = qw( collect_pod inc );
+ @valid_props{@valid_props} = delete( @props{@valid_props} );
+ warn "Unknown properties: @{[keys %props]}\n" if scalar( %props );
+
+ my %data = (
+ module => $module,
+ filename => $filename,
+ version => undef,
+ packages => [],
+ versions => {},
+ pod => {},
+ pod_headings => [],
+ collect_pod => 0,
+
+ %valid_props,
+ );
+
+ my $self = bless( \%data, $package );
+
+ $self->_parse_file();
+
+ unless ( $self->{module} && length( $self->{module} ) ) {
+ my( $v, $d, $f ) = File::Spec->splitpath( $self->{filename} );
+ if ( $f =~ /\.pm$/ ) {
+ $f =~ s/\..+$//;
+ my @candidates = grep /$f$/, @{$self->{packages}};
+ $self->{module} = shift( @candidates ); # punt
+ } else {
+ if ( grep /main/, @{$self->{packages}} ) {
+ $self->{module} = 'main';
+ } else {
+ $self->{module} = $self->{packages}[0] || '';
+ }
+ }
+ }
+
+ $self->{version} = $self->{versions}{$self->{module}}
+ if defined( $self->{module} );
+
+ return $self;
+}
+
+# class method
+sub _do_find_module {
+ my $package = shift;
+ my $module = shift || die 'find_module_by_name() requires a package name';
+ my $dirs = shift || \@INC;
+
+ my $file = File::Spec->catfile(split( /::/, $module));
+ foreach my $dir ( @$dirs ) {
+ my $testfile = File::Spec->catfile($dir, $file);
+ return [ File::Spec->rel2abs( $testfile ), $dir ]
+ if -e $testfile and !-d _; # For stuff like ExtUtils::xsubpp
+ return [ File::Spec->rel2abs( "$testfile.pm" ), $dir ]
+ if -e "$testfile.pm";
+ }
+ return;
+}
+
+# class method
+sub find_module_by_name {
+ my $found = shift()->_do_find_module(@_) or return;
+ return $found->[0];
+}
+
+# class method
+sub find_module_dir_by_name {
+ my $found = shift()->_do_find_module(@_) or return;
+ return $found->[1];
+}
+
+
+# given a line of perl code, attempt to parse it if it looks like a
+# $VERSION assignment, returning sigil, full name, & package name
+sub _parse_version_expression {
+ my $self = shift;
+ my $line = shift;
+
+ my( $sig, $var, $pkg );
+ if ( $line =~ $VERS_REGEXP ) {
+ ( $sig, $var, $pkg ) = $2 ? ( $1, $2, $3 ) : ( $4, $5, $6 );
+ if ( $pkg ) {
+ $pkg = ($pkg eq '::') ? 'main' : $pkg;
+ $pkg =~ s/::$//;
+ }
+ }
+
+ return ( $sig, $var, $pkg );
+}
+
+sub _parse_file {
+ my $self = shift;
+
+ my $filename = $self->{filename};
+ my $fh = IO::File->new( $filename )
+ or die( "Can't open '$filename': $!" );
+
+ my( $in_pod, $seen_end, $need_vers ) = ( 0, 0, 0 );
+ my( @pkgs, %vers, %pod, @pod );
+ my $pkg = 'main';
+ my $pod_sect = '';
+ my $pod_data = '';
+
+ while (defined( my $line = <$fh> )) {
+
+ chomp( $line );
+ next if $line =~ /^\s*#/;
+
+ $in_pod = ($line =~ /^=(?!cut)/) ? 1 : ($line =~ /^=cut/) ? 0 : $in_pod;
+
+ if ( $in_pod || $line =~ /^=cut/ ) {
+
+ if ( $line =~ /^=head\d\s+(.+)\s*$/ ) {
+ push( @pod, $1 );
+ if ( $self->{collect_pod} && length( $pod_data ) ) {
+ $pod{$pod_sect} = $pod_data;
+ $pod_data = '';
+ }
+ $pod_sect = $1;
+
+
+ } elsif ( $self->{collect_pod} ) {
+ $pod_data .= "$line\n";
+
+ }
+
+ } else {
+
+ $pod_sect = '';
+ $pod_data = '';
+
+ # parse $line to see if it's a $VERSION declaration
+ my( $vers_sig, $vers_fullname, $vers_pkg ) =
+ $self->_parse_version_expression( $line );
+
+ if ( $line =~ $PKG_REGEXP ) {
+ $pkg = $1;
+ push( @pkgs, $pkg ) unless grep( $pkg eq $_, @pkgs );
+ $vers{$pkg} = undef unless exists( $vers{$pkg} );
+ $need_vers = 1;
+
+ # VERSION defined with full package spec, i.e. $Module::VERSION
+ } elsif ( $vers_fullname && $vers_pkg ) {
+ push( @pkgs, $vers_pkg ) unless grep( $vers_pkg eq $_, @pkgs );
+ $need_vers = 0 if $vers_pkg eq $pkg;
+
+ my $v =
+ $self->_evaluate_version_line( $vers_sig, $vers_fullname, $line );
+ unless ( defined $vers{$vers_pkg} && length $vers{$vers_pkg} ) {
+ $vers{$vers_pkg} = $v;
+ } else {
+ warn <<"EOM";
+Package '$vers_pkg' already declared with version '$vers{$vers_pkg}'
+ignoring new version '$v'.
+EOM
+ }
+
+ # first non-comment line in undeclared package main is VERSION
+ } elsif ( !exists($vers{main}) && $pkg eq 'main' && $vers_fullname ) {
+ $need_vers = 0;
+ my $v =
+ $self->_evaluate_version_line( $vers_sig, $vers_fullname, $line );
+ $vers{$pkg} = $v;
+ push( @pkgs, 'main' );
+
+ # first non-comement line in undeclared packge defines package main
+ } elsif ( !exists($vers{main}) && $pkg eq 'main' && $line =~ /\w+/ ) {
+ $need_vers = 1;
+ $vers{main} = '';
+ push( @pkgs, 'main' );
+
+ # only keep if this is the first $VERSION seen
+ } elsif ( $vers_fullname && $need_vers ) {
+ $need_vers = 0;
+ my $v =
+ $self->_evaluate_version_line( $vers_sig, $vers_fullname, $line );
+
+
+ unless ( defined $vers{$pkg} && length $vers{$pkg} ) {
+ $vers{$pkg} = $v;
+ } else {
+ warn <<"EOM";
+Package '$pkg' already declared with version '$vers{$pkg}'
+ignoring new version '$v'.
+EOM
+ }
+
+ }
+
+ }
+
+ }
+
+ if ( $self->{collect_pod} && length($pod_data) ) {
+ $pod{$pod_sect} = $pod_data;
+ }
+
+ $self->{versions} = \%vers;
+ $self->{packages} = \@pkgs;
+ $self->{pod} = \%pod;
+ $self->{pod_headings} = \@pod;
+}
+
+sub _evaluate_version_line {
+ my $self = shift;
+ my( $sigil, $var, $line ) = @_;
+
+ # Some of this code came from the ExtUtils:: hierarchy.
+
+ my $eval = qq{q# Hide from _packages_inside()
+ #; package Module::Build::ModuleInfo::_version;
+ no strict;
+
+ local $sigil$var;
+ \$$var=undef; do {
+ $line
+ }; \$$var
+ };
+ local $^W;
+
+ # version.pm will change the ->VERSION method, so we mitigate the
+ # potential effects here. Unfortunately local(*UNIVERSAL::VERSION)
+ # will crash perl < 5.8.1. We also use * Foo::VERSION instead of
+ # *Foo::VERSION so that old versions of CPAN.pm, etc. with a
+ # too-permissive regex don't think we're actually declaring a
+ # version.
+
+ my $old_version = \&UNIVERSAL::VERSION;
+ eval {require version};
+ my $result = eval $eval;
+ * UNIVERSAL::VERSION = $old_version;
+ warn "Error evaling version line '$eval' in $self->{filename}: $@\n" if $@;
+
+ # Unbless it if it's a version.pm object
+ $result = $result->numify if UNIVERSAL::isa($result, 'version');
+
+ return $result;
+}
+
+
+############################################################
+
+# accessors
+sub name { $_[0]->{module} }
+
+sub filename { $_[0]->{filename} }
+sub packages_inside { @{$_[0]->{packages}} }
+sub pod_inside { @{$_[0]->{pod_headings}} }
+sub contains_pod { $#{$_[0]->{pod_headings}} }
+
+sub version {
+ my $self = shift;
+ my $mod = shift || $self->{module};
+ my $vers;
+ if ( defined( $mod ) && length( $mod ) &&
+ exists( $self->{versions}{$mod} ) ) {
+ return $self->{versions}{$mod};
+ } else {
+ return undef;
+ }
+}
+
+sub pod {
+ my $self = shift;
+ my $sect = shift;
+ if ( defined( $sect ) && length( $sect ) &&
+ exists( $self->{pod}{$sect} ) ) {
+ return $self->{pod}{$sect};
+ } else {
+ return undef;
+ }
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+ModuleInfo - Gather package and POD information from a perl module files
+
+
+=head1 DESCRIPTION
+
+=over 4
+
+=item new_from_file($filename, collect_pod => 1)
+
+Construct a ModuleInfo object given the path to a file. Takes an optional
+arguement C<collect_pod> which is a boolean that determines whether
+POD data is collected and stored for reference. POD data is not
+collected by default. POD headings are always collected.
+
+=item new_from_module($module, collect_pod => 1, inc => \@dirs)
+
+Construct a ModuleInfo object given a module or package name. In addition
+to accepting the C<collect_pod> argument as described above, this
+method accepts a C<inc> arguemnt which is a reference to an array of
+of directories to search for the module. If none are given, the
+default is @INC.
+
+=item name()
+
+Returns the name of the package represented by this module. If there
+are more than one packages, it makes a best guess based on the
+filename. If it's a script (i.e. not a *.pm) the package name is
+'main'.
+
+=item version($package)
+
+Returns the version as defined by the $VERSION variable for the
+package as returned by the C<name> method if no arguments are
+given. If given the name of a package it will attempt to return the
+version of that package if it is specified in the file.
+
+=item filename()
+
+Returns the absolute path to the file.
+
+=item packages_inside()
+
+Returns a list of packages.
+
+=item pod_inside()
+
+Returns a list of POD sections.
+
+=item contains_pod()
+
+Returns true if there is any POD in the file.
+
+=item pod($section)
+
+Returns the POD data in the given section.
+
+=item find_module_by_name($module, \@dirs)
+
+Returns the path to a module given the module or package name. A list
+of directories can be passed in as an optional paramater, otherwise
+@INC is searched.
+
+Can be called as either an object or a class method.
+
+=item find_module_dir_by_name($module, \@dirs)
+
+Returns the entry in C<@dirs> (or C<@INC> by default) that contains
+the module C<$module>. A list of directories can be passed in as an
+optional paramater, otherwise @INC is searched.
+
+Can be called as either an object or a class method.
+
+=back
+
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>, Randy W. Sims <RandyS@ThePierianSpring.org>
+
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001-2005 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.
+
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3)
+
+=cut
+
--- /dev/null
+package Module::Build::Notes;
+
+# A class for persistent hashes
+
+use strict;
+use Data::Dumper;
+use IO::File;
+
+use Carp; BEGIN{ $SIG{__DIE__} = \&carp::confess }
+
+sub new {
+ my ($class, %args) = @_;
+ my $file = delete $args{file} or die "Missing required parameter 'file' to new()";
+ my $self = bless {
+ disk => {},
+ new => {},
+ file => $file,
+ %args,
+ }, $class;
+}
+
+sub restore {
+ my $self = shift;
+
+ my $fh = IO::File->new("< $self->{file}") or die "Can't read $self->{file}: $!";
+ $self->{disk} = eval do {local $/; <$fh>};
+ die $@ if $@;
+ $self->{new} = {};
+}
+
+sub access {
+ my $self = shift;
+ return $self->read() unless @_;
+
+ my $key = shift;
+ return $self->read($key) unless @_;
+
+ my $value = shift;
+ $self->write({ $key => $value });
+ return $self->read($key);
+}
+
+sub has_data {
+ my $self = shift;
+ return keys %{$self->read()} > 0;
+}
+
+sub exists {
+ my ($self, $key) = @_;
+ return exists($self->{new}{$key}) || exists($self->{disk}{$key});
+}
+
+sub read {
+ my $self = shift;
+
+ if (@_) {
+ # Return 1 key as a scalar
+ my $key = shift;
+ return $self->{new}{$key} if exists $self->{new}{$key};
+ return $self->{disk}{$key};
+ }
+
+ # Return all data
+ my $out = (keys %{$self->{new}}
+ ? {%{$self->{disk}}, %{$self->{new}}}
+ : $self->{disk});
+ return wantarray ? %$out : $out;
+}
+
+sub _same {
+ my ($self, $x, $y) = @_;
+ return 1 if !defined($x) and !defined($y);
+ return 0 if !defined($x) or !defined($y);
+ return $x eq $y;
+}
+
+sub write {
+ my ($self, $href) = @_;
+ $href ||= {};
+
+ @{$self->{new}}{ keys %$href } = values %$href; # Merge
+
+ # Do some optimization to avoid unnecessary writes
+ foreach my $key (keys %{ $self->{new} }) {
+ next if ref $self->{new}{$key};
+ next if ref $self->{disk}{$key} or !exists $self->{disk}{$key};
+ delete $self->{new}{$key} if $self->_same($self->{new}{$key}, $self->{disk}{$key});
+ }
+
+ if (my $file = $self->{file}) {
+ my ($vol, $dir, $base) = File::Spec->splitpath($file);
+ $dir = File::Spec->catpath($vol, $dir, '');
+ return unless -e $dir && -d $dir; # The user needs to arrange for this
+
+ return if -e $file and !keys %{ $self->{new} }; # Nothing to do
+
+ @{$self->{disk}}{ keys %{$self->{new}} } = values %{$self->{new}}; # Merge
+ $self->_dump($file, $self->{disk});
+
+ $self->{new} = {};
+ }
+ return $self->read;
+}
+
+sub _dump {
+ my ($self, $file, $data) = @_;
+
+ my $fh = IO::File->new("> $file") or die "Can't create '$file': $!";
+ local $Data::Dumper::Terse = 1;
+ print $fh Data::Dumper::Dumper($data);
+}
+
+sub write_config_data {
+ my ($self, %args) = @_;
+
+ my $fh = IO::File->new("> $args{file}") or die "Can't create '$args{file}': $!";
+
+ printf $fh <<'EOF', $args{config_module};
+package %s;
+use strict;
+my $arrayref = eval do {local $/; <DATA>}
+ or die "Couldn't load ConfigData data: $@";
+close DATA;
+my ($config, $features, $auto_features) = @$arrayref;
+
+sub config { $config->{$_[1]} }
+
+sub set_config { $config->{$_[1]} = $_[2] }
+sub set_feature { $features->{$_[1]} = 0+!!$_[2] } # Constrain to 1 or 0
+
+sub auto_feature_names { grep !exists $features->{$_}, keys %%$auto_features }
+
+sub feature_names {
+ my @features = (keys %%$features, auto_feature_names());
+ @features;
+}
+
+sub config_names { keys %%$config }
+
+sub write {
+ my $me = __FILE__;
+ require IO::File;
+ require Data::Dumper;
+
+ my $mode_orig = (stat $me)[2] & 07777;
+ chmod($mode_orig | 0222, $me); # Make it writeable
+ my $fh = IO::File->new($me, 'r+') or die "Can't rewrite $me: $!";
+ seek($fh, 0, 0);
+ while (<$fh>) {
+ last if /^__DATA__$/;
+ }
+ die "Couldn't find __DATA__ token in $me" if eof($fh);
+
+ local $Data::Dumper::Terse = 1;
+ seek($fh, tell($fh), 0);
+ $fh->print( Data::Dumper::Dumper([$config, $features, $auto_features]) );
+ truncate($fh, tell($fh));
+ $fh->close;
+
+ chmod($mode_orig, $me)
+ or warn "Couldn't restore permissions on $me: $!";
+}
+
+sub feature {
+ my ($package, $key) = @_;
+ return $features->{$key} if exists $features->{$key};
+
+ my $info = $auto_features->{$key} or return 0;
+
+ # Under perl 5.005, each(%%$foo) isn't working correctly when $foo
+ # was reanimated with Data::Dumper and eval(). Not sure why, but
+ # copying to a new hash seems to solve it.
+ my %%info = %%$info;
+
+ require Module::Build; # XXX should get rid of this
+ while (my ($type, $prereqs) = each %%info) {
+ next if $type eq 'description' || $type eq 'recommends';
+
+ my %%p = %%$prereqs; # Ditto here.
+ while (my ($modname, $spec) = each %%p) {
+ my $status = Module::Build->check_installed_status($modname, $spec);
+ if ((!$status->{ok}) xor ($type =~ /conflicts$/)) { return 0; }
+ }
+ }
+ return 1;
+}
+
+EOF
+
+ my ($module_name, $notes_name) = ($args{module}, $args{config_module});
+ printf $fh <<"EOF", $notes_name, $module_name;
+
+=head1 NAME
+
+$notes_name - Configuration for $module_name
+
+
+=head1 SYNOPSIS
+
+ use $notes_name;
+ \$value = $notes_name->config('foo');
+ \$value = $notes_name->feature('bar');
+
+ \@names = $notes_name->config_names;
+ \@names = $notes_name->feature_names;
+
+ $notes_name->set_config(foo => \$new_value);
+ $notes_name->set_feature(bar => \$new_value);
+ $notes_name->write; # Save changes
+
+
+=head1 DESCRIPTION
+
+This module holds the configuration data for the C<$module_name>
+module. It also provides a programmatic interface for getting or
+setting that configuration data. Note that in order to actually make
+changes, you'll have to have write access to the C<$notes_name>
+module, and you should attempt to understand the repercussions of your
+actions.
+
+
+=head1 METHODS
+
+=over 4
+
+=item config(\$name)
+
+Given a string argument, returns the value of the configuration item
+by that name, or C<undef> if no such item exists.
+
+=item feature(\$name)
+
+Given a string argument, returns the value of the feature by that
+name, or C<undef> if no such feature exists.
+
+=item set_config(\$name, \$value)
+
+Sets the configuration item with the given name to the given value.
+The value may be any Perl scalar that will serialize correctly using
+C<Data::Dumper>. This includes references, objects (usually), and
+complex data structures. It probably does not include transient
+things like filehandles or sockets.
+
+=item set_feature(\$name, \$value)
+
+Sets the feature with the given name to the given boolean value. The
+value will be converted to 0 or 1 automatically.
+
+=item config_names()
+
+Returns a list of all the names of config items currently defined in
+C<$notes_name>, or in scalar context the number of items.
+
+=item feature_names()
+
+Returns a list of all the names of features currently defined in
+C<$notes_name>, or in scalar context the number of features.
+
+=item auto_feature_names()
+
+Returns a list of all the names of features whose availability is
+dynamically determined, or in scalar context the number of such
+features. Does not include such features that have later been set to
+a fixed value.
+
+=item write()
+
+Commits any changes from C<set_config()> and C<set_feature()> to disk.
+Requires write access to the C<$notes_name> module.
+
+=back
+
+
+=head1 AUTHOR
+
+C<$notes_name> was automatically created using C<Module::Build>.
+C<Module::Build> was written by Ken Williams, but he holds no
+authorship claim or copyright claim to the contents of C<$notes_name>.
+
+=cut
+
+__DATA__
+
+EOF
+
+ local $Data::Dumper::Terse = 1;
+ print $fh Data::Dumper::Dumper([$args{config_data}, $args{feature}, $args{auto_features}]);
+}
+
+1;
--- /dev/null
+package Module::Build::PPMMaker;
+
+use strict;
+
+# This code is mostly borrowed from ExtUtils::MM_Unix 6.10_03, with a
+# few tweaks based on the PPD spec at
+# http://www.xav.com/perl/site/lib/XML/PPD.html
+
+# The PPD spec is based on <http://www.w3.org/TR/NOTE-OSD>
+
+sub new {
+ my $package = shift;
+ return bless {@_}, $package;
+}
+
+sub make_ppd {
+ my ($self, %args) = @_;
+ my $build = delete $args{build};
+
+ my @codebase;
+ if (exists $args{codebase}) {
+ @codebase = ref $args{codebase} ? @{$args{codebase}} : ($args{codebase});
+ } else {
+ my $distfile = $build->ppm_name . '.tar.gz';
+ print "Using default codebase '$distfile'\n";
+ @codebase = ($distfile);
+ }
+
+ my %dist;
+ foreach my $info (qw(name author abstract version)) {
+ my $method = "dist_$info";
+ $dist{$info} = $build->$method() or die "Can't determine distribution's $info\n";
+ }
+ $dist{version} = $self->_ppd_version($dist{version});
+
+ $self->_simple_xml_escape($_) foreach $dist{abstract}, @{$dist{author}};
+
+ # TODO: could add <LICENSE HREF=...> tag if we knew what the URLs were for
+ # various licenses
+ my $ppd = <<"PPD";
+<SOFTPKG NAME=\"$dist{name}\" VERSION=\"$dist{version}\">
+ <TITLE>$dist{name}</TITLE>
+ <ABSTRACT>$dist{abstract}</ABSTRACT>
+@{[ join "\n", map " <AUTHOR>$_</AUTHOR>", @{$dist{author}} ]}
+ <IMPLEMENTATION>
+PPD
+
+ # TODO: We could set <IMPLTYPE VALUE="PERL" /> or maybe
+ # <IMPLTYPE VALUE="PERL/XS" /> ???
+
+ # We don't include recommended dependencies because PPD has no way
+ # to distinguish them from normal dependencies. We don't include
+ # build_requires dependencies because the PPM installer doesn't
+ # build or test before installing. And obviously we don't include
+ # conflicts either.
+
+ foreach my $type (qw(requires)) {
+ my $prereq = $build->$type();
+ while (my ($modname, $spec) = each %$prereq) {
+ next if $modname eq 'perl';
+
+ my $min_version = '0.0';
+ foreach my $c ($build->_parse_conditions($spec)) {
+ my ($op, $version) = $c =~ /^\s* (<=?|>=?|==|!=) \s* ([\w.]+) \s*$/x;
+
+ # This is a nasty hack because it fails if there is no >= op
+ if ($op eq '>=') {
+ $min_version = $version;
+ last;
+ }
+ }
+
+ # Another hack - dependencies are on modules, but PPD expects
+ # them to be on distributions (I think).
+ $modname =~ s/::/-/g;
+
+ $ppd .= sprintf(<<'EOF', $modname, $self->_ppd_version($min_version));
+ <DEPENDENCY NAME="%s" VERSION="%s" />
+EOF
+
+ }
+ }
+
+ # We only include these tags if this module involves XS, on the
+ # assumption that pure Perl modules will work on any OS. PERLCORE,
+ # unfortunately, seems to indicate that a module works with _only_
+ # that version of Perl, and so is only appropriate when a module
+ # uses XS.
+ if (keys %{$build->find_xs_files}) {
+ my $perl_version = $self->_ppd_version($build->perl_version);
+ $ppd .= sprintf(<<'EOF', $perl_version, $^O, $self->_varchname($build->config) );
+ <PERLCORE VERSION="%s" />
+ <OS NAME="%s" />
+ <ARCHITECTURE NAME="%s" />
+EOF
+ }
+
+ foreach my $codebase (@codebase) {
+ $self->_simple_xml_escape($codebase);
+ $ppd .= sprintf(<<'EOF', $codebase);
+ <CODEBASE HREF="%s" />
+EOF
+ }
+
+ $ppd .= <<'EOF';
+ </IMPLEMENTATION>
+</SOFTPKG>
+EOF
+
+ my $ppd_file = "$dist{name}.ppd";
+ my $fh = IO::File->new(">$ppd_file")
+ or die "Cannot write to $ppd_file: $!";
+ print $fh $ppd;
+ close $fh;
+
+ return $ppd_file;
+}
+
+sub _ppd_version {
+ my ($self, $version) = @_;
+
+ # generates something like "0,18,0,0"
+ return join ',', (split(/\./, $version), (0)x4)[0..3];
+}
+
+sub _varchname { # Copied from PPM.pm
+ my ($self, $config) = @_;
+ my $varchname = $config->{archname};
+ # Append "-5.8" to architecture name for Perl 5.8 and later
+ if (defined($^V) && ord(substr($^V,1)) >= 8) {
+ $varchname .= sprintf("-%d.%d", ord($^V), ord(substr($^V,1)));
+ }
+ return $varchname;
+}
+
+{
+ my %escapes = (
+ "\n" => "\\n",
+ '"' => '"',
+ '&' => '&',
+ '>' => '>',
+ '<' => '<',
+ );
+ my $rx = join '|', keys %escapes;
+
+ sub _simple_xml_escape {
+ $_[1] =~ s/($rx)/$escapes{$1}/go;
+ }
+}
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::PPMMaker - Perl Package Manager file creation
+
+
+=head1 SYNOPSIS
+
+ On the command line, builds a .ppd file:
+ ./Build ppd
+
+
+=head1 DESCRIPTION
+
+This package contains the code that builds F<.ppd> "Perl Package
+Description" files, in support of ActiveState's "Perl Package
+Manager". Details are here:
+L<http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/>
+
+
+=head1 AUTHOR
+
+Dave Rolsky <autarch@urth.org>, Ken Williams <ken@cpan.org>
+
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001-2005 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.
+
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::Amiga;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::Amiga - Builder class for Amiga platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base>. Please see the L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::Default;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::Default - Stub class for unknown platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base>. Please see the L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::EBCDIC;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::EBCDIC - Builder class for EBCDIC platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base>. Please see the L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::MPEiX;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::MPEiX - Builder class for MPEiX platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base>. Please see the L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::MacOS;
+
+use strict;
+use Module::Build::Base;
+use base qw(Module::Build::Base);
+
+use ExtUtils::Install;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new(@_);
+
+ # $Config{sitelib} and $Config{sitearch} are, unfortunately, missing.
+ $self->{config}{sitelib} ||= $self->{config}{installsitelib};
+ $self->{config}{sitearch} ||= $self->{config}{installsitearch};
+
+ # For some reason $Config{startperl} is filled with a bunch of crap.
+ $self->{config}{startperl} =~ s/.*Exit \{Status\}\s//;
+
+ return $self;
+}
+
+sub make_executable {
+ my $self = shift;
+ require MacPerl;
+ foreach (@_) {
+ MacPerl::SetFileInfo('McPL', 'TEXT', $_);
+ }
+}
+
+sub dispatch {
+ my $self = shift;
+
+ if( !@_ and !@ARGV ) {
+ require MacPerl;
+
+ # What comes first in the action list.
+ my @action_list = qw(build test install);
+ my %actions = map {+($_, 1)} $self->known_actions;
+ delete @actions{@action_list};
+ push @action_list, sort { $a cmp $b } keys %actions;
+
+ my %toolserver = map {+$_ => 1} qw(test disttest diff testdb);
+ foreach (@action_list) {
+ $_ .= ' *' if $toolserver{$_};
+ }
+
+ my $cmd = MacPerl::Pick("What build command? ('*' requires ToolServer)", @action_list);
+ return unless defined $cmd;
+ $cmd =~ s/ \*$//;
+ $ARGV[0] = ($cmd);
+
+ my $args = MacPerl::Ask('Any extra arguments? (ie. verbose=1)', '');
+ return unless defined $args;
+ push @ARGV, $self->split_like_shell($args);
+ }
+
+ $self->SUPER::dispatch(@_);
+}
+
+sub ACTION_realclean {
+ my $self = shift;
+ chmod 0666, $self->{properties}{build_script};
+ $self->SUPER::ACTION_realclean;
+}
+
+# ExtUtils::Install has a hard-coded '.' directory in versions less
+# than 1.30. We use a sneaky trick to turn that into ':'.
+#
+# Note that we do it here in a cross-platform way, so this code could
+# actually go in Module::Build::Base. But we put it here to be less
+# intrusive for other platforms.
+
+sub ACTION_install {
+ my $self = shift;
+
+ return $self->SUPER::ACTION_install(@_)
+ if eval {ExtUtils::Install->VERSION('1.30'); 1};
+
+ local $^W = 0; # Avoid a 'redefine' warning
+ local *ExtUtils::Install::find = sub {
+ my ($code, @dirs) = @_;
+
+ @dirs = map { $_ eq '.' ? File::Spec->curdir : $_ } @dirs;
+
+ return File::Find::find($code, @dirs);
+ };
+
+ return $self->SUPER::ACTION_install(@_);
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Module::Build::Platform::MacOS - Builder class for MacOS platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base> and override a few methods. Please see
+L<Module::Build> for the docs.
+
+=head2 Overriden Methods
+
+=over 4
+
+=item new()
+
+MacPerl doesn't define $Config{sitelib} or $Config{sitearch} for some
+reason, but $Config{installsitelib} and $Config{installsitearch} are
+there. So we copy the install variables to the other location
+
+=item make_executable()
+
+On MacOS we set the file type and creator to MacPerl so it will run
+with a double-click.
+
+=item dispatch()
+
+Because there's no easy way to say "./Build test" on MacOS, if
+dispatch is called with no arguments and no @ARGV a dialog box will
+pop up asking what action to take and any extra arguments.
+
+Default action is "test".
+
+=item ACTION_realclean()
+
+Need to unlock the Build program before deleting.
+
+=back
+
+=head1 AUTHOR
+
+Michael G Schwern <schwern@pobox.com>
+
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::RiscOS;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::RiscOS - Builder class for RiscOS platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base>. Please see the L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::Unix;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+sub make_tarball {
+ my $self = shift;
+ $self->{args}{tar} ||= ['tar'];
+ $self->{args}{gzip} ||= ['gzip'];
+ $self->SUPER::make_tarball(@_);
+}
+
+sub _startperl { "#! " . shift()->perl }
+
+sub _construct {
+ my $self = shift()->SUPER::_construct(@_);
+
+ # perl 5.8.1-RC[1-3] had some broken %Config entries, and
+ # unfortunately Red Hat 9 shipped it like that. Fix 'em up here.
+ my $c = $self->{config};
+ for (qw(siteman1 siteman3 vendorman1 vendorman3)) {
+ $c->{"install${_}dir"} ||= $c->{"install${_}"};
+ }
+
+ return $self;
+}
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::Unix - Builder class for Unix platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base>. Please see the L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::VMS;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+
+
+=head1 NAME
+
+Module::Build::Platform::VMS - Builder class for VMS platforms
+
+=head1 DESCRIPTION
+
+This module inherits from C<Module::Build::Base> and alters a few
+minor details of its functionality. Please see L<Module::Build> for
+the general docs.
+
+=head2 Overridden Methods
+
+=over 4
+
+=item new
+
+Change $self->{build_script} to 'Build.com' so @Build works.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new(@_);
+
+ $self->{properties}{build_script} = 'Build.com';
+
+ return $self;
+}
+
+
+=item cull_args
+
+'@Build foo' on VMS will not preserve the case of 'foo'. Rather than forcing
+people to write '@Build "foo"' we'll dispatch case-insensitively.
+
+=cut
+
+sub cull_args {
+ my $self = shift;
+ my($action, $args) = $self->SUPER::cull_args(@_);
+ my @possible_actions = grep { lc $_ eq lc $action } $self->known_actions;
+
+ die "Ambiguous action '$action'. Could be one of @possible_actions"
+ if @possible_actions > 1;
+
+ return ($possible_actions[0], $args);
+}
+
+
+=item manpage_separator
+
+Use '__' instead of '::'.
+
+=cut
+
+sub manpage_separator {
+ return '__';
+}
+
+
+=item prefixify
+
+Prefixify taking into account VMS' filepath syntax.
+
+=cut
+
+# Translated from ExtUtils::MM_VMS::prefixify()
+sub _prefixify {
+ my($self, $path, $sprefix, $type) = @_;
+ my $rprefix = $self->prefix;
+
+ $self->log_verbose(" prefixify $path from $sprefix to $rprefix\n");
+
+ # Translate $(PERLPREFIX) to a real path.
+ $rprefix = $self->eliminate_macros($rprefix);
+ $rprefix = VMS::Filespec::vmspath($rprefix) if $rprefix;
+ $sprefix = VMS::Filespec::vmspath($sprefix) if $sprefix;
+
+ $self->log_verbose(" rprefix translated to $rprefix\n".
+ " sprefix translated to $sprefix\n");
+
+ if( length $path == 0 ) {
+ $self->log_verbose(" no path to prefixify.\n")
+ }
+ elsif( !File::Spec->file_name_is_absolute($path) ) {
+ $self->log_verbose(" path is relative, not prefixifying.\n");
+ }
+ elsif( $sprefix eq $rprefix ) {
+ $self->log_verbose(" no new prefix.\n");
+ }
+ else {
+ my($path_vol, $path_dirs) = File::Spec->splitpath( $path );
+ my $vms_prefix = $self->config->{vms_prefix};
+ if( $path_vol eq $vms_prefix.':' ) {
+ $self->log_verbose(" $vms_prefix: seen\n");
+
+ $path_dirs =~ s{^\[}{\[.} unless $path_dirs =~ m{^\[\.};
+ $path = $self->_catprefix($rprefix, $path_dirs);
+ }
+ else {
+ $self->log_verbose(" cannot prefixify.\n");
+ return $self->prefix_relpaths($self->installdirs, $type);
+ }
+ }
+
+ $self->log_verbose(" now $path\n");
+
+ return $path;
+}
+
+
+=back
+
+=head1 AUTHOR
+
+Michael G Schwern <schwern@pobox.com>, Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
+
+1;
+__END__
--- /dev/null
+package Module::Build::Platform::VOS;
+
+use strict;
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::VOS - Builder class for VOS platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base>. Please see the L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::Windows;
+
+use strict;
+
+use Config;
+use File::Basename;
+use File::Spec;
+use IO::File;
+
+use Module::Build::Base;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Base);
+
+
+sub manpage_separator {
+ return '.';
+}
+
+sub ACTION_realclean {
+ my ($self) = @_;
+
+ $self->SUPER::ACTION_realclean();
+
+ my $basename = basename($0);
+ $basename =~ s/(?:\.bat)?$//i;
+
+ if ( $basename eq $self->build_script ) {
+ if ( $self->build_bat ) {
+ my $full_progname = $0;
+ $full_progname =~ s/(?:\.bat)?$/.bat/i;
+
+ # Vodoo required to have a batch file delete itself without error;
+ # Syntax differs between 9x & NT: the later requires a null arg (???)
+ require Win32;
+ my $null_arg = (Win32::IsWinNT()) ? '""' : '';
+ my $cmd = qq(start $null_arg /min "\%comspec\%" /c del "$full_progname");
+
+ my $fh = IO::File->new(">> $basename.bat")
+ or die "Can't create $basename.bat: $!";
+ print $fh $cmd;
+ close $fh ;
+ } else {
+ $self->delete_filetree($self->build_script . '.bat');
+ }
+ }
+}
+
+sub make_executable {
+ my $self = shift;
+
+ $self->SUPER::make_executable(@_);
+
+ foreach my $script (@_) {
+ my %opts = ();
+ if ( $script eq $self->build_script ) {
+ $opts{ntargs} = q(-x -S %0 --build_bat %*);
+ $opts{otherargs} = q(-x -S "%0" --build_bat %1 %2 %3 %4 %5 %6 %7 %8 %9);
+ }
+
+ my $out = eval {$self->pl2bat(in => $script, update => 1, %opts)};
+ if ( $@ ) {
+ $self->log_warn("WARNING: Unable to convert file '$script' to an executable script:\n$@");
+ } else {
+ $self->SUPER::make_executable($out);
+ }
+ }
+}
+
+# This routine was copied almost verbatim from the 'pl2bat' utility
+# distributed with perl. It requires too much vodoo with shell quoting
+# differences and shortcomings between the various flavors of Windows
+# to reliably shell out
+sub pl2bat {
+ my $self = shift;
+ my %opts = @_;
+
+ # NOTE: %0 is already enclosed in doublequotes by cmd.exe, as appropriate
+ $opts{ntargs} = '-x -S %0 %*' unless exists $opts{ntargs};
+ $opts{otherargs} = '-x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9' unless exists $opts{otherargs};
+
+ $opts{stripsuffix} = '/\\.plx?/' unless exists $opts{stripsuffix};
+ $opts{stripsuffix} = ($opts{stripsuffix} =~ m{^/([^/]*[^/\$]|)\$?/?$} ? $1 : "\Q$opts{stripsuffix}\E");
+
+ unless (exists $opts{out}) {
+ $opts{out} = $opts{in};
+ $opts{out} =~ s/$opts{stripsuffix}$//oi;
+ $opts{out} .= '.bat' unless $opts{in} =~ /\.bat$/i or $opts{in} =~ /^-$/;
+ }
+
+ my $head = <<EOT;
+ \@rem = '--*-Perl-*--
+ \@echo off
+ if "%OS%" == "Windows_NT" goto WinNT
+ perl $opts{otherargs}
+ goto endofperl
+ :WinNT
+ perl $opts{ntargs}
+ if NOT "%COMSPEC%" == "%SystemRoot%\\system32\\cmd.exe" goto endofperl
+ if %errorlevel% == 9009 echo You do not have Perl in your PATH.
+ if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
+ goto endofperl
+ \@rem ';
+EOT
+
+ $head =~ s/^\s+//gm;
+ my $headlines = 2 + ($head =~ tr/\n/\n/);
+ my $tail = "\n__END__\n:endofperl\n";
+
+ my $linedone = 0;
+ my $taildone = 0;
+ my $linenum = 0;
+ my $skiplines = 0;
+
+ my $start = $Config{startperl};
+ $start = "#!perl" unless $start =~ /^#!.*perl/;
+
+ my $in = IO::File->new("< $opts{in}") or die "Can't open $opts{in}: $!";
+ my @file = <$in>;
+ $in->close;
+
+ foreach my $line ( @file ) {
+ $linenum++;
+ if ( $line =~ /^:endofperl\b/ ) {
+ if (!exists $opts{update}) {
+ warn "$opts{in} has already been converted to a batch file!\n";
+ return;
+ }
+ $taildone++;
+ }
+ if ( not $linedone and $line =~ /^#!.*perl/ ) {
+ if (exists $opts{update}) {
+ $skiplines = $linenum - 1;
+ $line .= "#line ".(1+$headlines)."\n";
+ } else {
+ $line .= "#line ".($linenum+$headlines)."\n";
+ }
+ $linedone++;
+ }
+ if ( $line =~ /^#\s*line\b/ and $linenum == 2 + $skiplines ) {
+ $line = "";
+ }
+ }
+
+ my $out = IO::File->new("> $opts{out}") or die "Can't open $opts{out}: $!";
+ print $out $head;
+ print $out $start, ( $opts{usewarnings} ? " -w" : "" ),
+ "\n#line ", ($headlines+1), "\n" unless $linedone;
+ print $out @file[$skiplines..$#file];
+ print $out $tail unless $taildone;
+ $out->close;
+
+ return $opts{out};
+}
+
+
+sub split_like_shell {
+ # As it turns out, Windows command-parsing is very different from
+ # Unix command-parsing. Double-quotes mean different things,
+ # backslashes don't necessarily mean escapes, and so on. So we
+ # can't use Text::ParseWords::shellwords() to break a command string
+ # into words. The algorithm below was bashed out by Randy and Ken
+ # (mostly Randy), and there are a lot of regression tests, so we
+ # should feel free to adjust if desired.
+
+ (my $self, local $_) = @_;
+
+ return @$_ if defined() && UNIVERSAL::isa($_, 'ARRAY');
+
+ my @argv;
+ return @argv unless defined() && length();
+
+ my $arg = '';
+ my( $i, $quote_mode ) = ( 0, 0 );
+
+ while ( $i < length() ) {
+
+ my $ch = substr( $_, $i , 1 );
+ my $next_ch = substr( $_, $i+1, 1 );
+
+ if ( $ch eq '\\' && $next_ch eq '"' ) {
+ $arg .= '"';
+ $i++;
+ } elsif ( $ch eq '\\' && $next_ch eq '\\' ) {
+ $arg .= '\\';
+ $i++;
+ } elsif ( $ch eq '"' && $next_ch eq '"' && $quote_mode ) {
+ $quote_mode = !$quote_mode;
+ $arg .= '"';
+ $i++;
+ } elsif ( $ch eq '"' && $next_ch eq '"' && !$quote_mode &&
+ ( $i + 2 == length() ||
+ substr( $_, $i + 2, 1 ) eq ' ' )
+ ) { # for cases like: a"" => [ 'a' ]
+ push( @argv, $arg );
+ $arg = '';
+ $i += 2;
+ } elsif ( $ch eq '"' ) {
+ $quote_mode = !$quote_mode;
+ } elsif ( $ch eq ' ' && !$quote_mode ) {
+ push( @argv, $arg ) if $arg;
+ $arg = '';
+ ++$i while substr( $_, $i + 1, 1 ) eq ' ';
+ } else {
+ $arg .= $ch;
+ }
+
+ $i++;
+ }
+
+ push( @argv, $arg ) if defined( $arg ) && length( $arg );
+ return @argv;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Module::Build::Platform::Windows - Builder class for Windows platforms
+
+=head1 DESCRIPTION
+
+The sole purpose of this module is to inherit from
+C<Module::Build::Base> and override a few methods. Please see
+L<Module::Build> for the docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>, Randy W. Sims <RandyS@ThePierianSpring.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::aix;
+
+use strict;
+use Module::Build::Platform::Unix;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Platform::Unix);
+
+# This class isn't necessary anymore, but we can't delete it, because
+# some people might still have the old copy in their @INC, containing
+# code we don't want to execute, so we have to make sure an upgrade
+# will replace it with this empty subclass.
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::aix - Builder class for AIX platform
+
+=head1 DESCRIPTION
+
+This module provides some routines very specific to the AIX
+platform.
+
+Please see the L<Module::Build> for the general docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::cygwin;
+
+use strict;
+use Module::Build::Platform::Unix;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Platform::Unix);
+
+sub manpage_separator {
+ '.'
+}
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::cygwin - Builder class for Cygwin platform
+
+=head1 DESCRIPTION
+
+This module provides some routines very specific to the cygwin
+platform.
+
+Please see the L<Module::Build> for the general docs.
+
+=head1 AUTHOR
+
+Initial stub by Yitzchak Scott-Thoennes <sthoenna@efn.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::darwin;
+
+use strict;
+use Module::Build::Platform::Unix;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Platform::Unix);
+
+# This class isn't necessary anymore, but we can't delete it, because
+# some people might still have the old copy in their @INC, containing
+# code we don't want to execute, so we have to make sure an upgrade
+# will replace it with this empty subclass.
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::darwin - Builder class for Mac OS X platform
+
+=head1 DESCRIPTION
+
+This module provides some routines very specific to the Mac OS X
+platform.
+
+Please see the L<Module::Build> for the general docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::Platform::os2;
+
+use strict;
+use Module::Build::Platform::Unix;
+
+use vars qw(@ISA);
+@ISA = qw(Module::Build::Platform::Unix);
+
+sub manpage_separator { '.' }
+
+1;
+__END__
+
+
+=head1 NAME
+
+Module::Build::Platform::os2 - Builder class for OS/2 platform
+
+=head1 DESCRIPTION
+
+This module provides some routines very specific to the OS/2
+platform.
+
+Please see the L<Module::Build> for the general docs.
+
+=head1 AUTHOR
+
+Ken Williams <ken@cpan.org>
+
+=head1 SEE ALSO
+
+perl(1), Module::Build(3), ExtUtils::MakeMaker(3)
+
+=cut
--- /dev/null
+package Module::Build::PodParser;
+
+use strict;
+use vars qw(@ISA);
+
+sub new {
+ # Perl is so fun.
+ my $package = shift;
+
+ my $self;
+
+ # Try using Pod::Parser first
+ if (eval{ require Pod::Parser; 1; }) {
+ @ISA = qw(Pod::Parser);
+ $self = $package->SUPER::new(@_);
+ $self->{have_pod_parser} = 1;
+ } else {
+ @ISA = ();
+ *parse_from_filehandle = \&_myparse_from_filehandle;
+ $self = bless {have_pod_parser => 0, @_}, $package;
+ }
+
+ unless ($self->{fh}) {
+ die "No 'file' or 'fh' parameter given" unless $self->{file};
+ $self->{fh} = IO::File->new($self->{file}) or die "Couldn't open $self->{file}: $!";
+ }
+
+ return $self;
+}
+
+sub _myparse_from_filehandle {
+ my ($self, $fh) = @_;
+
+ local $_;
+ while (<$fh>) {
+ next unless /^=(?!cut)/ .. /^=cut/; # in POD
+ last if ($self->{abstract}) = /^ (?: [a-z:]+ \s+ - \s+ ) (.*\S) /ix;
+ }
+
+ my @author;
+ while (<$fh>) {
+ next unless /^=head1\s+AUTHORS?/ ... /^=/;
+ next if /^=/;
+ push @author, $_ if /\@/;
+ }
+ return unless @author;
+ s/^\s+|\s+$//g foreach @author;
+
+ $self->{author} = \@author;
+
+ return;
+}
+
+sub get_abstract {
+ my $self = shift;
+ return $self->{abstract} if defined $self->{abstract};
+
+ $self->parse_from_filehandle($self->{fh});
+
+ return $self->{abstract};
+}
+
+sub get_author {
+ my $self = shift;
+ return $self->{author} if defined $self->{author};
+
+ $self->parse_from_filehandle($self->{fh});
+
+ return $self->{author} || [];
+}
+
+################## Pod::Parser overrides ###########
+sub initialize {
+ my $self = shift;
+ $self->{_head} = '';
+ $self->SUPER::initialize();
+}
+
+sub command {
+ my ($self, $cmd, $text) = @_;
+ if ( $cmd eq 'head1' ) {
+ $text =~ s/^\s+//;
+ $text =~ s/\s+$//;
+ $self->{_head} = $text;
+ }
+}
+
+sub textblock {
+ my ($self, $text) = @_;
+ $text =~ s/^\s+//;
+ $text =~ s/\s+$//;
+ if ($self->{_head} eq 'NAME') {
+ my ($name, $abstract) = split( /\s+-\s+/, $text, 2 );
+ $self->{abstract} = $abstract;
+ } elsif ($self->{_head} =~ /^AUTHORS?$/) {
+ push @{$self->{author}}, $text if $text =~ /\@/;
+ }
+}
+
+sub verbatim {}
+sub interior_sequence {}
+
+1;
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use Module::Build 0.25;
+use Getopt::Long;
+
+my %opt_defs = (
+ module => {type => '=s',
+ desc => 'The name of the module to configure (required)'},
+ feature => {type => ':s',
+ desc => 'Print the value of a feature or all features'},
+ config => {type => ':s',
+ desc => 'Print the value of a config option'},
+ set_feature => {type => '=s%',
+ desc => "Set a feature to 'true' or 'false'"},
+ set_config => {type => '=s%',
+ desc => 'Set a config option to the given value'},
+ eval => {type => '',
+ desc => 'eval() config values before setting'},
+ help => {type => '',
+ desc => 'Print a help message and exit'},
+ );
+
+my %opts;
+GetOptions( \%opts, map "$_$opt_defs{$_}{type}", keys %opt_defs ) or die usage(%opt_defs);
+print usage(%opt_defs) and exit(0)
+ if $opts{help};
+
+my @exclusive = qw(feature config set_feature set_config);
+die "Exactly one of the options '" . join("', '", @exclusive) . "' must be specified\n" . usage(%opt_defs)
+ unless grep(exists $opts{$_}, @exclusive) == 1;
+
+die "Option --module is required\n" . usage(%opt_defs)
+ unless $opts{module};
+
+my $cf = load_config($opts{module});
+
+if (exists $opts{feature}) {
+
+ if (length $opts{feature}) {
+ print $cf->feature($opts{feature});
+ } else {
+ my %auto;
+ # note: need to support older ConfigData.pm's
+ @auto{$cf->auto_feature_names} = () if $cf->can("auto_feature_names");
+
+ print " Features defined in $cf:\n";
+ foreach my $name (sort $cf->feature_names) {
+ print " $name => ", $cf->feature($name), (exists $auto{$name} ? " (dynamic)" : ""), "\n";
+ }
+ }
+
+} elsif (exists $opts{config}) {
+
+ require Data::Dumper;
+ local $Data::Dumper::Terse = 1;
+
+ if (length $opts{config}) {
+ print Data::Dumper::Dumper($cf->config($opts{config})), "\n";
+ } else {
+ print " Configuration defined in $cf:\n";
+ foreach my $name (sort $cf->config_names) {
+ print " $name => ", Data::Dumper::Dumper($cf->config($name)), "\n";
+ }
+ }
+
+} elsif (exists $opts{set_feature}) {
+ my %to_set = %{$opts{set_feature}};
+ while (my ($k, $v) = each %to_set) {
+ die "Feature value must be 0 or 1\n" unless $v =~ /^[01]$/;
+ $cf->set_feature($k, 0+$v); # Cast to a number, not a string
+ }
+ $cf->write;
+ print "Feature" . 's'x(keys(%to_set)>1) . " saved\n";
+
+} elsif (exists $opts{set_config}) {
+
+ my %to_set = %{$opts{set_config}};
+ while (my ($k, $v) = each %to_set) {
+ if ($opts{eval}) {
+ $v = eval($v);
+ die $@ if $@;
+ }
+ $cf->set_config($k, $v);
+ }
+ $cf->write;
+ print "Config value" . 's'x(keys(%to_set)>1) . " saved\n";
+}
+
+sub load_config {
+ my $mod = shift;
+
+ $mod =~ /^([\w:]+)$/
+ or die "Invalid module name '$mod'";
+
+ my $cf = $mod . "::ConfigData";
+ eval "require $cf";
+ die $@ if $@;
+
+ return $cf;
+}
+
+sub usage {
+ my %defs = @_;
+
+ my $out = "\nUsage: $0 [options]\n\n Options include:\n";
+
+ foreach my $name (sort keys %defs) {
+ $out .= " --$name";
+
+ for ($defs{$name}{type}) {
+ /^=s$/ and $out .= " <string>";
+ /^=s%$/ and $out .= " <string>=<value>";
+ }
+
+ pad_line($out, 35);
+ $out .= "$defs{$name}{desc}\n";
+ }
+
+ $out .= <<EOF;
+
+ Examples:
+ $0 --module Foo::Bar --feature bazzable
+ $0 --module Foo::Bar --config magic_number
+ $0 --module Foo::Bar --set_feature bazzable=1
+ $0 --module Foo::Bar --set_config magic_number=42
+
+EOF
+
+ return $out;
+}
+
+sub pad_line { $_[0] .= ' ' x ($_[1] - length($_[0]) + rindex($_[0], "\n")) }
+
+
+__END__
+
+=head1 NAME
+
+config_data - Query or change configuration of Perl modules
+
+=head1 SYNOPSIS
+
+ # Get config/feature values
+ config_data --module Foo::Bar --feature bazzable
+ config_data --module Foo::Bar --config magic_number
+
+ # Set config/feature values
+ config_data --module Foo::Bar --set_feature bazzable=1
+ config_data --module Foo::Bar --set_config magic_number=42
+
+ # Print a usage message
+ config_data --help
+
+=head1 DESCRIPTION
+
+The C<config_data> tool provides a command-line interface to the
+configuration of Perl modules. By "configuration", we mean something
+akin to "user preferences" or "local settings". This is a
+formalization and abstraction of the systems that people like Andreas
+Koenig (C<CPAN::Config>), Jon Swartz (C<HTML::Mason::Config>), Andy
+Wardley (C<Template::Config>), and Larry Wall (perl's own Config.pm)
+have developed independently.
+
+The configuration system emplyed here was developed in the context of
+C<Module::Build>. Under this system, configuration information for a
+module C<Foo>, for example, is stored in a module called
+C<Foo::ConfigData>) (I would have called it C<Foo::Config>, but that
+was taken by all those other systems mentioned in the previous
+paragraph...). These C<...::ConfigData> modules contain the
+configuration data, as well as publically accessible methods for
+querying and setting (yes, actually re-writing) the configuration
+data. The C<config_data> script (whose docs you are currently
+reading) is merely a front-end for those methods. If you wish, you
+may create alternate front-ends.
+
+The two types of data that may be stored are called C<config> values
+and C<feature> values. A C<config> value may be any perl scalar,
+including references to complex data structures. It must, however, be
+serializable using C<Data::Dumper>. A C<feature> is a boolean (1 or
+0) value.
+
+=head1 USAGE
+
+This script functions as a basic getter/setter wrapper around the
+configuration of a single module. On the command line, specify which
+module's configuration you're interested in, and pass options to get
+or set C<config> or C<feature> values. The following options are
+supported:
+
+=over 4
+
+=item module
+
+Specifies the name of the module to configure (required).
+
+=item feature
+
+When passed the name of a C<feature>, shows its value. The value will
+be 1 if the feature is enabled, 0 if the feature is not enabled, or
+empty if the feature is unknown. When no feature name is supplied,
+the names and values of all known features will be shown.
+
+=item config
+
+When passed the name of a C<config> entry, shows its value. The value
+will be displayed using C<Data::Dumper> (or similar) as perl code.
+When no config name is supplied, the names and values of all known
+config entries will be shown.
+
+=item set_feature
+
+Sets the given C<feature> to the given boolean value. Specify the value
+as either 1 or 0.
+
+=item set_config
+
+Sets the given C<config> entry to the given value.
+
+=item eval
+
+If the C<--eval> option is used, the values in C<set_config> will be
+evaluated as perl code before being stored. This allows moderately
+complicated data structures to be stored. For really complicated
+structures, you probably shouldn't use this command-line interface,
+just use the Perl API instead.
+
+=item help
+
+Prints a help message, including a few examples, and exits.
+
+=back
+
+=head1 AUTHOR
+
+Ken Williams, kwilliams@cpan.org
+
+=head1 COPYRIGHT
+
+Copyright (c) 1999, 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.
+
+=head1 SEE ALSO
+
+Module::Build(3), perl(1).
+
+=cut
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 55;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+#########################
+
+
+use_ok 'Module::Build';
+
+SKIP: {
+ skip "no blib in core", 1 if $ENV{PERL_CORE};
+ like $INC{'Module/Build.pm'}, qr/\bblib\b/, "Make sure Module::Build was loaded from blib/";
+}
+
+
+# Test object creation
+{
+ my $mb = Module::Build->new( module_name => $dist->name );
+ ok $mb;
+ is $mb->module_name, $dist->name;
+ is $mb->build_class, 'Module::Build';
+ is $mb->dist_name, $dist->name;
+
+ $mb = Module::Build->new( dist_name => $dist->name, dist_version => 7 );
+ ok $mb;
+ ok ! $mb->module_name; # Make sure it's defined
+ is $mb->dist_name, $dist->name;
+}
+
+# Make sure actions are defined, and known_actions works as class method
+{
+ my %actions = map {$_, 1} Module::Build->known_actions;
+ ok $actions{clean};
+ ok $actions{distdir};
+}
+
+# Test prerequisite checking
+{
+ local @INC = (File::Spec->catdir( $dist->dirname, 'lib' ), @INC);
+ my $flagged = 0;
+ local $SIG{__WARN__} = sub { $flagged = 1 if $_[0] =~ /@{[$dist->name]}/};
+ my $mb = Module::Build->new(
+ module_name => $dist->name,
+ requires => {$dist->name => 0},
+ );
+ ok ! $flagged;
+ ok ! $mb->prereq_failures;
+ $mb->dispatch('realclean');
+ $dist->clean;
+
+ $flagged = 0;
+ $mb = Module::Build->new(
+ module_name => $dist->name,
+ requires => {$dist->name => 3.14159265},
+ );
+ ok $flagged;
+ ok $mb->prereq_failures;
+ ok $mb->prereq_failures->{requires}{$dist->name};
+ is $mb->prereq_failures->{requires}{$dist->name}{have}, 0.01;
+ is $mb->prereq_failures->{requires}{$dist->name}{need}, 3.14159265;
+
+ $mb->dispatch('realclean');
+ $dist->clean;
+
+ # Make sure check_installed_status() works as a class method
+ my $info = Module::Build->check_installed_status('File::Spec', 0);
+ ok $info->{ok};
+ is $info->{have}, $File::Spec::VERSION;
+
+ # Make sure check_installed_status() works with an advanced spec
+ $info = Module::Build->check_installed_status('File::Spec', '> 0');
+ ok $info->{ok};
+
+ # Use 2 lines for this, to avoid a "used only once" warning
+ local $Foo::Module::VERSION;
+ $Foo::Module::VERSION = '1.01_02';
+
+ $info = Module::Build->check_installed_status('Foo::Module', '1.01_02');
+ ok $info->{ok} or diag($info->{message});
+}
+
+{
+ # Make sure the correct warning message is generated when an
+ # optional prereq isn't installed
+ my $flagged = 0;
+ local $SIG{__WARN__} = sub { $flagged = 1 if $_[0] =~ /ModuleBuildNonExistent is not installed/};
+
+ my $mb = Module::Build->new(
+ module_name => $dist->name,
+ recommends => {ModuleBuildNonExistent => 3},
+ );
+ ok $flagged;
+ $dist->clean;
+}
+
+# Test verbosity
+{
+ my $mb = Module::Build->new(module_name => $dist->name);
+
+ $mb->add_to_cleanup('save_out');
+ # Use uc() so we don't confuse the current test output
+ like uc(stdout_of( sub {$mb->dispatch('test', verbose => 1)} )), qr/^OK \d/m;
+ like uc(stdout_of( sub {$mb->dispatch('test', verbose => 0)} )), qr/\.\.OK/;
+
+ $mb->dispatch('realclean');
+ $dist->clean;
+}
+
+# Make sure 'config' entries are respected on the command line, and that
+# Getopt::Long specs work as expected.
+{
+ use Config;
+ $dist->change_file( 'Build.PL', <<"---" );
+use Module::Build;
+
+my \$build = Module::Build->new(
+ module_name => @{[$dist->name]},
+ license => 'perl',
+ get_options => { foo => {},
+ bar => { type => '+' },
+ bat => { type => '=s' },
+ dee => { type => '=s',
+ default => 'goo'
+ },
+ }
+);
+
+\$build->create_build_script;
+---
+
+ $dist->regen;
+ eval {Module::Build->run_perl_script('Build.PL', [], ['--nouse-rcfile', '--config', "foocakes=barcakes", '--foo', '--bar', '--bar', '-bat=hello', 'gee=whiz', '--any', 'hey', '--destdir', 'yo', '--verbose', '1'])};
+ is $@, '';
+
+ my $mb = Module::Build->resume;
+ is $mb->config('cc'), $Config{cc};
+ is $mb->config('foocakes'), 'barcakes';
+
+ # Test args().
+ is $mb->args('foo'), 1;
+ is $mb->args('bar'), 2, 'bar';
+ is $mb->args('bat'), 'hello', 'bat';
+ is $mb->args('gee'), 'whiz';
+ is $mb->args('any'), 'hey';
+ is $mb->args('dee'), 'goo';
+ is $mb->destdir, 'yo';
+ is $mb->runtime_params('destdir'), 'yo';
+ is $mb->runtime_params('verbose'), '1';
+ ok ! $mb->runtime_params('license');
+ ok my %runtime = $mb->runtime_params;
+ is scalar keys %runtime, 4;
+ is $runtime{destdir}, 'yo';
+ is $runtime{verbose}, '1';
+ ok $runtime{config};
+
+ ok my $argsref = $mb->args;
+ is $argsref->{foo}, 1;
+ $argsref->{doo} = 'hee';
+ is $mb->args('doo'), 'hee';
+ ok my %args = $mb->args;
+ is $args{foo}, 1;
+
+ # revert test distribution to pristine state because we modified a file
+ chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+ $dist->remove;
+ $dist = DistGen->new( dir => $tmp );
+ $dist->regen;
+ chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+}
+
+# Test author stuff
+{
+ my $mb = Module::Build->new(
+ module_name => $dist->name,
+ dist_author => 'Foo Meister <foo@example.com>',
+ build_class => 'My::Big::Fat::Builder',
+ );
+ ok $mb;
+ ok ref($mb->dist_author), 'dist_author converted to array if simple string';
+ is $mb->dist_author->[0], 'Foo Meister <foo@example.com>';
+ is $mb->build_class, 'My::Big::Fat::Builder';
+}
+
+# Test conversion of shell strings
+{
+ my $mb = Module::Build->new(
+ module_name => $dist->name,
+ dist_author => 'Foo Meister <foo@example.com>',
+ extra_compiler_flags => '-I/foo -I/bar',
+ extra_linker_flags => '-L/foo -L/bar',
+ );
+ ok $mb;
+ is_deeply $mb->extra_compiler_flags, ['-I/foo', '-I/bar'], "Should split shell string into list";
+ is_deeply $mb->extra_linker_flags, ['-L/foo', '-L/bar'], "Should split shell string into list";
+}
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#---------------------------------------------------------------------
+package Tie::CPHash;
+#
+# Copyright 1997 Christopher J. Madsen
+#
+# Author: Christopher J. Madsen <chris_madsen@geocities.com>
+# Created: 08 Nov 1997
+# Version: 1.001 (25-Oct-1998)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the same terms as Perl itself.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
+# GNU General Public License or the Artistic License for more details.
+#
+# Case preserving but case insensitive hash
+#---------------------------------------------------------------------
+
+require 5.000;
+use strict;
+use vars qw(@ISA $VERSION);
+
+@ISA = qw();
+
+#=====================================================================
+# Package Global Variables:
+
+BEGIN
+{
+ # Convert RCS revision number to d.ddd format:
+ $VERSION = sprintf('%d.%03d', '1.001 ' =~ /(\d+)\.(\d+)/);
+} # end BEGIN
+
+#=====================================================================
+# Tied Methods:
+#---------------------------------------------------------------------
+# TIEHASH classname
+# The method invoked by the command `tie %hash, classname'.
+# Associates a new hash instance with the specified class.
+
+sub TIEHASH
+{
+ bless {}, $_[0];
+} # end TIEHASH
+
+#---------------------------------------------------------------------
+# STORE this, key, value
+# Store datum *value* into *key* for the tied hash *this*.
+
+sub STORE
+{
+ $_[0]->{lc $_[1]} = [ $_[1], $_[2] ];
+} # end STORE
+
+#---------------------------------------------------------------------
+# FETCH this, key
+# Retrieve the datum in *key* for the tied hash *this*.
+
+sub FETCH
+{
+ my $v = $_[0]->{lc $_[1]};
+ ($v ? $v->[1] : undef);
+} # end FETCH
+
+#---------------------------------------------------------------------
+# FIRSTKEY this
+# Return the (key, value) pair for the first key in the hash.
+
+sub FIRSTKEY
+{
+ my $a = scalar keys %{$_[0]};
+ &NEXTKEY;
+} # end FIRSTKEY
+
+#---------------------------------------------------------------------
+# NEXTKEY this, lastkey
+# Return the next (key, value) pair for the hash.
+
+sub NEXTKEY
+{
+ my $v = (each %{$_[0]})[1];
+ ($v ? $v->[0] : undef );
+} # end NEXTKEY
+
+#---------------------------------------------------------------------
+# EXISTS this, key
+# Verify that *key* exists with the tied hash *this*.
+
+sub EXISTS
+{
+ exists $_[0]->{lc $_[1]};
+} # end EXISTS
+
+#---------------------------------------------------------------------
+# DELETE this, key
+# Delete the key *key* from the tied hash *this*.
+# Returns the old value, or undef if it didn't exist.
+
+sub DELETE
+{
+ my $v = delete $_[0]->{lc $_[1]};
+ ($v ? $v->[1] : undef);
+} # end DELETE
+
+#---------------------------------------------------------------------
+# CLEAR this
+# Clear all values from the tied hash *this*.
+
+sub CLEAR
+{
+ %{$_[0]} = ();
+} # end CLEAR
+
+#=====================================================================
+# Other Methods:
+#---------------------------------------------------------------------
+# Return the case of KEY.
+
+sub key
+{
+ my $v = $_[0]->{lc $_[1]};
+ ($v ? $v->[0] : undef);
+}
+
+#=====================================================================
+# Package Return Value:
+
+1;
+
+__END__
+
+=head1 NAME
+
+Tie::CPHash - Case preserving but case insensitive hash table
+
+=head1 SYNOPSIS
+
+ require Tie::CPHash;
+ tie %cphash, 'Tie::CPHash';
+
+ $cphash{'Hello World'} = 'Hi there!';
+ printf("The key `%s' was used to store `%s'.\n",
+ tied(%cphash)->key('HELLO WORLD'),
+ $cphash{'HELLO world'});
+
+=head1 DESCRIPTION
+
+The B<Tie::CPHash> provides a hash table that is case preserving but
+case insensitive. This means that
+
+ $cphash{KEY} $cphash{key}
+ $cphash{Key} $cphash{keY}
+
+all refer to the same entry. Also, the hash remembers which form of
+the key was last used to store the entry. The C<keys> and C<each>
+functions will return the key that was used to set the value.
+
+An example should make this clear:
+
+ tie %h, 'Tie::CPHash';
+ $h{Hello} = 'World';
+ print $h{HELLO}; # Prints 'World'
+ print keys(%h); # Prints 'Hello'
+ $h{HELLO} = 'WORLD';
+ print $h{hello}; # Prints 'WORLD'
+ print keys(%h); # Prints 'HELLO'
+
+The additional C<key> method lets you fetch the case of a specific key:
+
+ # When run after the previous example, this prints 'HELLO':
+ print tied(%h)->key('Hello');
+
+(The C<tied> function returns the object that C<%h> is tied to.)
+
+If you need a case insensitive hash, but don't need to preserve case,
+just use C<$hash{lc $key}> instead of C<$hash{$key}>. This has a lot
+less overhead than B<Tie::CPHash>.
+
+=head1 AUTHOR
+
+Christopher J. Madsen E<lt>F<chris_madsen@geocities.com>E<gt>
+
+=cut
+
+# Local Variables:
+# tmtrack-file-task: "Tie::CPHash.pm"
+# End:
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest;
+use File::Spec;
+use Config;
+
+# Don't let our own verbosity/test_file get mixed up with our subprocess's
+my @makefile_keys = qw(TEST_VERBOSE HARNESS_VERBOSE TEST_FILES MAKEFLAGS);
+local @ENV{@makefile_keys};
+delete @ENV{@makefile_keys};
+
+my @makefile_types = qw(small passthrough traditional);
+my $tests_per_type = 10;
+if ( $Config{make} && find_in_path($Config{make}) ) {
+ plan tests => 30 + @makefile_types*$tests_per_type;
+} else {
+ plan skip_all => "Don't know how to invoke 'make'";
+}
+ok(1); # Loaded
+
+
+#########################
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+#########################
+
+use Module::Build;
+use Module::Build::Compat;
+
+use Carp; $SIG{__WARN__} = \&Carp::cluck;
+
+my @make = $Config{make} eq 'nmake' ? ('nmake', '-nologo') : ($Config{make});
+
+#########################
+
+
+my $mb = Module::Build->new_from_context;
+ok $mb;
+
+foreach my $type (@makefile_types) {
+ Module::Build::Compat->create_makefile_pl($type, $mb);
+ test_makefile_creation($mb);
+
+ ok $mb->do_system(@make);
+
+ # Can't let 'test' STDOUT go to our STDOUT, or it'll confuse Test::Harness.
+ my $success;
+ my $output = stdout_of( sub {
+ $success = $mb->do_system(@make, 'test');
+ } );
+ ok $success;
+ like uc $output, qr{DONE\.|SUCCESS};
+
+ ok $mb->do_system(@make, 'realclean');
+
+ # Try again with some Makefile.PL arguments
+ test_makefile_creation($mb, [], 'INSTALLDIRS=vendor', 1);
+
+ 1 while unlink 'Makefile.PL';
+ ok ! -e 'Makefile.PL';
+}
+
+{
+ # Make sure fake_makefile() can run without 'build_class', as it may be
+ # in older-generated Makefile.PLs
+ my $warning = '';
+ local $SIG{__WARN__} = sub { $warning = shift; };
+ my $maketext = eval { Module::Build::Compat->fake_makefile(makefile => 'Makefile') };
+ is $@, '';
+ like $maketext, qr/^realclean/m;
+ like $warning, qr/build_class/;
+}
+
+{
+ # Make sure custom builder subclass is used in the created
+ # Makefile.PL - make sure it fails in the right way here.
+ local @Foo::Builder::ISA = qw(Module::Build);
+ my $foo_builder = Foo::Builder->new_from_context;
+ foreach my $style ('passthrough', 'small') {
+ Module::Build::Compat->create_makefile_pl($style, $foo_builder);
+ ok -e 'Makefile.PL';
+
+ # Should fail with "can't find Foo/Builder.pm"
+ my $warning = stderr_of
+ (sub {
+ my $result = $mb->run_perl_script('Makefile.PL');
+ ok ! $result;
+ });
+ like $warning, qr{Foo/Builder.pm};
+ }
+
+ # Now make sure it can actually work.
+ my $bar_builder = Module::Build->subclass( class => 'Bar::Builder' )->new_from_context;
+ foreach my $style ('passthrough', 'small') {
+ Module::Build::Compat->create_makefile_pl($style, $bar_builder);
+ ok -e 'Makefile.PL';
+ ok $mb->run_perl_script('Makefile.PL');
+ }
+}
+
+{
+ # Make sure various Makefile.PL arguments are supported
+ Module::Build::Compat->create_makefile_pl('passthrough', $mb);
+
+ my $libdir = File::Spec->catdir( $cwd, 't', 'libdir' );
+ my $result = $mb->run_perl_script('Makefile.PL', [],
+ [
+ "LIB=$libdir",
+ 'TEST_VERBOSE=1',
+ 'INSTALLDIRS=perl',
+ 'POLLUTE=1',
+ ]
+ );
+ ok $result;
+ ok -e 'Build.PL';
+
+ my $new_build = Module::Build->resume();
+ is $new_build->installdirs, 'core';
+ is $new_build->verbose, 1;
+ is $new_build->install_destination('lib'), $libdir;
+ is $new_build->extra_compiler_flags->[0], '-DPERL_POLLUTE';
+
+ # Make sure those switches actually had an effect
+ my ($ran_ok, $output);
+ $output = stdout_of( sub { $ran_ok = $new_build->do_system(@make, 'test') } );
+ ok $ran_ok;
+ $output =~ s/^/# /gm; # Don't confuse our own test output
+ like $output, qr/(?:# ok \d+\s+)+/, 'Should be verbose';
+
+ # Make sure various Makefile arguments are supported
+ $output = stdout_of( sub { $ran_ok = $mb->do_system(@make, 'test', 'TEST_VERBOSE=0') } );
+ ok $ran_ok;
+ $output =~ s/^/# /gm; # Don't confuse our own test output
+ like $output, qr/(?:# .+basic\.+ok\s+(?:[\d.]s\s*)?)+# All tests/,
+ 'Should be non-verbose';
+
+ $mb->delete_filetree($libdir);
+ ok ! -e $libdir, "Sample installation directory should be cleaned up";
+
+ $mb->do_system(@make, 'realclean');
+ ok ! -e 'Makefile', "Makefile shouldn't exist";
+
+ 1 while unlink 'Makefile.PL';
+ ok ! -e 'Makefile.PL';
+}
+
+{ # Make sure tilde-expansion works
+
+ # C<glob> on MSWin32 uses $ENV{HOME} if defined to do tilde-expansion
+ local $ENV{HOME} = 'C:/' if $^O =~ /MSWin/ && !exists( $ENV{HOME} );
+
+ Module::Build::Compat->create_makefile_pl('passthrough', $mb);
+
+ $mb->run_perl_script('Makefile.PL', [], ['INSTALL_BASE=~/foo']);
+ my $b2 = Module::Build->current;
+ ok $b2->install_base;
+ unlike $b2->install_base, qr/^~/, "Tildes should be expanded";
+
+ $mb->do_system(@make, 'realclean');
+ 1 while unlink 'Makefile.PL';
+}
+#########################################################
+
+sub test_makefile_creation {
+ my ($build, $preargs, $postargs, $cleanup) = @_;
+
+ my $result = $build->run_perl_script('Makefile.PL', $preargs, $postargs);
+ ok $result;
+ ok -e 'Makefile', "Makefile should exist";
+
+ if ($cleanup) {
+ $build->do_system(@make, 'realclean');
+ ok ! -e 'Makefile', "Makefile shouldn't exist";
+ }
+}
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 92;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+use Config;
+use File::Spec::Functions qw( catdir splitdir );
+
+#########################
+
+# We need to create a well defined environment to test install paths.
+# We do this by setting up appropriate Config entries.
+
+use Module::Build;
+my @installstyle = qw(lib perl5);
+my $mb = Module::Build->new_from_context(
+ installdirs => 'site',
+ config => {
+ installstyle => catdir(@installstyle),
+
+ installprivlib => catdir($tmp, @installstyle),
+ installarchlib => catdir($tmp, @installstyle,
+ @Config{qw(version archname)}),
+ installbin => catdir($tmp, 'bin'),
+ installscript => catdir($tmp, 'bin'),
+ installman1dir => catdir($tmp, 'man', 'man1'),
+ installman3dir => catdir($tmp, 'man', 'man3'),
+ installhtml1dir => catdir($tmp, 'html'),
+ installhtml3dir => catdir($tmp, 'html'),
+
+ installsitelib => catdir($tmp, 'site', @installstyle, 'site_perl'),
+ installsitearch => catdir($tmp, 'site', @installstyle, 'site_perl',
+ @Config{qw(version archname)}),
+ installsitebin => catdir($tmp, 'site', 'bin'),
+ installsitescript => catdir($tmp, 'site', 'bin'),
+ installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
+ installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
+ installsitehtml1dir => catdir($tmp, 'site', 'html'),
+ installsitehtml3dir => catdir($tmp, 'site', 'html'),
+ }
+);
+isa_ok( $mb, 'Module::Build::Base' );
+
+# Get us into a known state.
+$mb->install_base(undef);
+$mb->prefix(undef);
+
+
+# Check that we install into the proper default locations.
+{
+ is( $mb->installdirs, 'site' );
+ is( $mb->install_base, undef );
+ is( $mb->prefix, undef );
+
+ test_install_destinations( $mb, {
+ lib => catdir($tmp, 'site', @installstyle, 'site_perl'),
+ arch => catdir($tmp, 'site', @installstyle, 'site_perl',
+ @Config{qw(version archname)}),
+ bin => catdir($tmp, 'site', 'bin'),
+ script => catdir($tmp, 'site', 'bin'),
+ bindoc => catdir($tmp, 'site', 'man', 'man1'),
+ libdoc => catdir($tmp, 'site', 'man', 'man3'),
+ binhtml => catdir($tmp, 'site', 'html'),
+ libhtml => catdir($tmp, 'site', 'html'),
+ });
+}
+
+
+# Is installdirs honored?
+{
+ $mb->installdirs('core');
+ is( $mb->installdirs, 'core' );
+
+ test_install_destinations( $mb, {
+ lib => catdir($tmp, @installstyle),
+ arch => catdir($tmp, @installstyle, @Config{qw(version archname)}),
+ bin => catdir($tmp, 'bin'),
+ script => catdir($tmp, 'bin'),
+ bindoc => catdir($tmp, 'man', 'man1'),
+ libdoc => catdir($tmp, 'man', 'man3'),
+ binhtml => catdir($tmp, 'html'),
+ libhtml => catdir($tmp, 'html'),
+ });
+
+ $mb->installdirs('site');
+ is( $mb->installdirs, 'site' );
+}
+
+
+# Check install_base()
+{
+ my $install_base = catdir( 'foo', 'bar' );
+ $mb->install_base( $install_base );
+
+ is( $mb->prefix, undef );
+ is( $mb->install_base, $install_base );
+
+
+ test_install_destinations( $mb, {
+ lib => catdir( $install_base, 'lib', 'perl5' ),
+ arch => catdir( $install_base, 'lib', 'perl5', $Config{archname} ),
+ bin => catdir( $install_base, 'bin' ),
+ script => catdir( $install_base, 'bin' ),
+ bindoc => catdir( $install_base, 'man', 'man1'),
+ libdoc => catdir( $install_base, 'man', 'man3' ),
+ binhtml => catdir( $install_base, 'html' ),
+ libhtml => catdir( $install_base, 'html' ),
+ });
+}
+
+
+# Basic prefix test. Ensure everything is under the prefix.
+{
+ $mb->install_base( undef );
+ ok( !defined $mb->install_base );
+
+ my $prefix = catdir( qw( some prefix ) );
+ $mb->prefix( $prefix );
+ is( $mb->{properties}{prefix}, $prefix );
+
+ test_prefix($prefix, $mb->install_sets('site'));
+}
+
+
+# And now that prefix honors installdirs.
+{
+ $mb->installdirs('core');
+ is( $mb->installdirs, 'core' );
+
+ my $prefix = catdir( qw( some prefix ) );
+ test_prefix($prefix);
+
+ $mb->installdirs('site');
+ is( $mb->installdirs, 'site' );
+}
+
+
+# Try a config setting which would result in installation locations outside
+# the prefix. Ensure it doesn't.
+{
+ # Get the prefix defaults
+ my $defaults = $mb->prefix_relpaths('site');
+
+ # Create a configuration involving weird paths that are outside of
+ # the configured prefix.
+ my @prefixes = (
+ [qw(foo bar)],
+ [qw(biz)],
+ [],
+ );
+
+ my %test_config;
+ foreach my $type (keys %$defaults) {
+ my $prefix = shift @prefixes || [qw(foo bar)];
+ $test_config{$type} = catdir(File::Spec->rootdir, @$prefix,
+ @{$defaults->{$type}});
+ }
+
+ # Poke at the innards of MB to change the default install locations.
+ local $mb->install_sets->{site} = \%test_config;
+ $mb->config(siteprefixexp => catdir(File::Spec->rootdir,
+ 'wierd', 'prefix'));
+
+ my $prefix = catdir('another', 'prefix');
+ $mb->prefix($prefix);
+ test_prefix($prefix, \%test_config);
+}
+
+
+# Check that we can use install_base after setting prefix.
+{
+ my $install_base = catdir( 'foo', 'bar' );
+ $mb->install_base( $install_base );
+
+ test_install_destinations( $mb, {
+ lib => catdir( $install_base, 'lib', 'perl5' ),
+ arch => catdir( $install_base, 'lib', 'perl5', $Config{archname} ),
+ bin => catdir( $install_base, 'bin' ),
+ script => catdir( $install_base, 'bin' ),
+ bindoc => catdir( $install_base, 'man', 'man1'),
+ libdoc => catdir( $install_base, 'man', 'man3' ),
+ binhtml => catdir( $install_base, 'html' ),
+ libhtml => catdir( $install_base, 'html' ),
+ });
+}
+
+
+sub test_prefix {
+ my ($prefix, $test_config) = @_;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ foreach my $type (qw(lib arch bin script bindoc libdoc binhtml libhtml)) {
+ my $dest = $mb->install_destination( $type );
+ ok $mb->dir_contains($prefix, $dest), "$type prefixed";
+
+ SKIP: {
+ skip( "'$type' not configured", 1 )
+ unless $test_config && $test_config->{$type};
+
+ have_same_ending( $dest, $test_config->{$type},
+ " suffix correctish " .
+ "($test_config->{$type} + $prefix = $dest)" );
+ }
+ }
+}
+
+sub have_same_ending {
+ my ($dir1, $dir2, $message) = @_;
+
+ $dir1 =~ s{/$}{} if $^O eq 'cygwin'; # remove any trailing slash
+ my @dir1 = splitdir $dir1;
+
+ $dir2 =~ s{/$}{} if $^O eq 'cygwin'; # remove any trailing slash
+ my @dir2 = splitdir $dir2;
+
+ is $dir1[-1], $dir2[-1], $message;
+}
+
+sub test_install_destinations {
+ my($build, $expect) = @_;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ while( my($type, $expect) = each %$expect ) {
+ is( $build->install_destination($type), $expect, "$type destination" );
+ }
+}
+
+
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest;
+
+my @unix_splits =
+ (
+ { q{one t'wo th'ree f"o\"ur " "five" } => [ 'one', 'two three', 'fo"ur ', 'five' ] },
+ { q{ foo bar } => [ 'foo', 'bar' ] },
+ );
+
+my @win_splits =
+ (
+ { 'a" "b\\c" "d' => [ 'a b\c d' ] },
+ { '"a b\\c d"' => [ 'a b\c d' ] },
+ { '"a b"\\"c d"' => [ 'a b"c', 'd' ] },
+ { '"a b"\\\\"c d"' => [ 'a b\c d' ] },
+ { '"a"\\"b" "a\\"b"' => [ 'a"b a"b' ] },
+ { '"a"\\\\"b" "a\\\\"b"' => [ 'a\b', 'a\b' ] },
+ { '"a"\\"b a\\"b"' => [ 'a"b', 'a"b' ] },
+ { 'a"\\"b" "a\\"b' => [ 'a"b', 'a"b' ] },
+ { 'a"\\"b" "a\\"b' => [ 'a"b', 'a"b' ] },
+ { 'a b' => [ 'a', 'b' ] },
+ { 'a"\\"b a\\"b' => [ 'a"b a"b' ] },
+ { '"a""b" "a"b"' => [ 'a"b ab' ] },
+ { '\\"a\\"' => [ '"a"' ] },
+ { '"a"" "b"' => [ 'a"', 'b' ] },
+ { 'a"b' => [ 'ab' ] },
+ { 'a""b' => [ 'ab' ] },
+ { 'a"""b' => [ 'a"b' ] },
+ { 'a""""b' => [ 'a"b' ] },
+ { 'a"""""b' => [ 'a"b' ] },
+ { 'a""""""b' => [ 'a""b' ] },
+ { '"a"b"' => [ 'ab' ] },
+ { '"a""b"' => [ 'a"b' ] },
+ { '"a"""b"' => [ 'a"b' ] },
+ { '"a""""b"' => [ 'a"b' ] },
+ { '"a"""""b"' => [ 'a""b' ] },
+ { '"a""""""b"' => [ 'a""b' ] },
+ { '' => [ ] },
+ { ' ' => [ ] },
+ { '""' => [ '' ] },
+ { '" "' => [ ' ' ] },
+ { '""a' => [ 'a' ] },
+ { '""a b' => [ 'a', 'b' ] },
+ { 'a""' => [ 'a' ] },
+ { 'a"" b' => [ 'a', 'b' ] },
+ { '"" a' => [ '', 'a' ] },
+ { 'a ""' => [ 'a', '' ] },
+ { 'a "" b' => [ 'a', '', 'b' ] },
+ { 'a " " b' => [ 'a', ' ', 'b' ] },
+ { 'a " b " c' => [ 'a', ' b ', 'c' ] },
+);
+
+plan tests => 10 + 2*@unix_splits + 2*@win_splits;
+
+#########################
+
+use Module::Build;
+ok(1);
+
+# Should always return an array unscathed
+foreach my $platform ('', '::Platform::Unix', '::Platform::Windows') {
+ my $pkg = "Module::Build$platform";
+ my @result = $pkg->split_like_shell(['foo', 'bar', 'baz']);
+ is @result, 3, "Split using $pkg";
+ is "@result", "foo bar baz", "Split using $pkg";
+}
+
+use Module::Build::Platform::Unix;
+foreach my $test (@unix_splits) {
+ do_split_tests('Module::Build::Platform::Unix', $test);
+}
+
+use Module::Build::Platform::Windows;
+foreach my $test (@win_splits) {
+ do_split_tests('Module::Build::Platform::Windows', $test);
+}
+
+
+{
+ # Make sure read_args() functions properly as a class method
+ my @args = qw(foo=bar --food bard --foods=bards);
+ my ($args) = Module::Build->read_args(@args);
+ is_deeply($args, {foo => 'bar', food => 'bard', foods => 'bards', ARGV => []});
+}
+
+{
+ # Make sure data can make a round-trip through unparse_args() and read_args()
+ my %args = (foo => 'bar', food => 'bard', config => {a => 1, b => 2}, ARGV => []);
+ my ($args) = Module::Build->read_args( Module::Build->unparse_args(\%args) );
+ is_deeply($args, \%args);
+}
+
+{
+ # Make sure run_perl_script() propagates @INC
+ local @INC = ('whosiewhatzit', @INC);
+ my $output = stdout_of( sub { Module::Build->run_perl_script('', ['-le', 'print for @INC']) } );
+ like $output, qr{^whosiewhatzit}m;
+}
+
+##################################################################
+sub do_split_tests {
+ my ($package, $test) = @_;
+
+ my ($string, $expected) = %$test;
+ my @result = $package->split_like_shell($string);
+ is( 0 + grep( !defined(), @result ), # all defined
+ 0,
+ "'$string' result all defined" );
+ is_deeply(\@result, $expected);
+}
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 53;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+#########################
+
+use Module::Build;
+ok 1;
+
+# Here we make sure actions are only called once per dispatch()
+$::x = 0;
+my $mb = Module::Build->subclass
+ (
+ code => "sub ACTION_loop { die 'recursed' if \$::x++; shift->depends_on('loop'); }"
+ )->new( module_name => $dist->name );
+ok $mb;
+
+$mb->dispatch('loop');
+ok $::x;
+
+$mb->dispatch('realclean');
+
+# Make sure the subclass can be subclassed
+my $build2class = ref($mb)->subclass
+ (
+ code => "sub ACTION_loop2 {}",
+ class => 'MBB',
+ );
+can_ok( $build2class, 'ACTION_loop' );
+can_ok( $build2class, 'ACTION_loop2' );
+
+
+{ # Make sure globbing works in filenames
+ $dist->add_file( 'script', <<'---' );
+#!perl -w
+print "Hello, World!\n";
+---
+ $dist->regen;
+
+ $mb->test_files('*t*');
+ my $files = $mb->test_files;
+ ok grep {$_ eq 'script'} @$files;
+ ok grep {$_ eq File::Spec->catfile('t', 'basic.t')} @$files;
+ ok !grep {$_ eq 'Build.PL' } @$files;
+
+ # Make sure order is preserved
+ $mb->test_files('foo', 'bar');
+ $files = $mb->test_files;
+ is @$files, 2;
+ is $files->[0], 'foo';
+ is $files->[1], 'bar';
+
+ $dist->remove_file( 'script' );
+ $dist->regen( clean => 1 );
+}
+
+
+{
+ # Make sure we can add new kinds of stuff to the build sequence
+
+ $dist->add_file( 'test.foo', "content\n" );
+ $dist->regen;
+
+ my $mb = Module::Build->new( module_name => $dist->name,
+ foo_files => {'test.foo', 'lib/test.foo'} );
+ ok $mb;
+
+ $mb->add_build_element('foo');
+ $mb->add_build_element('foo');
+ is_deeply $mb->build_elements, [qw(PL support pm xs pod script foo)],
+ 'The foo element should be in build_elements only once';
+
+ $mb->dispatch('build');
+ ok -e File::Spec->catfile($mb->blib, 'lib', 'test.foo');
+
+ $mb->dispatch('realclean');
+
+ # revert distribution to a pristine state
+ $dist->remove_file( 'test.foo' );
+ $dist->regen( clean => 1 );
+}
+
+
+{
+ package MBSub;
+ use Test::More;
+ use vars qw($VERSION @ISA);
+ @ISA = qw(Module::Build);
+ $VERSION = 0.01;
+
+ # Add a new property.
+ ok(__PACKAGE__->add_property('foo'));
+ # Add a new property with a default value.
+ ok(__PACKAGE__->add_property('bar', 'hey'));
+ # Add a hash property.
+ ok(__PACKAGE__->add_property('hash', {}));
+
+
+ # Catch an exception adding an existing property.
+ eval { __PACKAGE__->add_property('module_name')};
+ like "$@", qr/already exists/;
+}
+
+{
+ package MBSub2;
+ use Test::More;
+ use vars qw($VERSION @ISA);
+ @ISA = qw(Module::Build);
+ $VERSION = 0.01;
+
+ # Add a new property with a different default value than MBSub has.
+ ok(__PACKAGE__->add_property('bar', 'yow'));
+}
+
+
+{
+ ok my $mb = MBSub->new( module_name => $dist->name );
+ isa_ok $mb, 'Module::Build';
+ isa_ok $mb, 'MBSub';
+ ok $mb->valid_property('foo');
+ can_ok $mb, 'module_name';
+
+ # Check foo property.
+ can_ok $mb, 'foo';
+ ok ! $mb->foo;
+ ok $mb->foo(1);
+ ok $mb->foo;
+
+ # Check bar property.
+ can_ok $mb, 'bar';
+ is $mb->bar, 'hey';
+ ok $mb->bar('you');
+ is $mb->bar, 'you';
+
+ # Check hash property.
+ ok $mb = MBSub->new(
+ module_name => $dist->name,
+ hash => { foo => 'bar', bin => 'foo'}
+ );
+
+ can_ok $mb, 'hash';
+ isa_ok $mb->hash, 'HASH';
+ is $mb->hash->{foo}, 'bar';
+ is $mb->hash->{bin}, 'foo';
+
+ # Check hash property passed via the command-line.
+ {
+ local @ARGV = (
+ '--hash', 'foo=bar',
+ '--hash', 'bin=foo',
+ );
+ ok $mb = MBSub->new( module_name => $dist->name );
+ }
+
+ can_ok $mb, 'hash';
+ isa_ok $mb->hash, 'HASH';
+ is $mb->hash->{foo}, 'bar';
+ is $mb->hash->{bin}, 'foo';
+
+ # Make sure that a different subclass with the same named property has a
+ # different default.
+ ok $mb = MBSub2->new( module_name => $dist->name );
+ isa_ok $mb, 'Module::Build';
+ isa_ok $mb, 'MBSub2';
+ ok $mb->valid_property('bar');
+ can_ok $mb, 'bar';
+ is $mb->bar, 'yow';
+}
+
+{
+ # Test the meta_add and meta_merge stuff
+ ok my $mb = Module::Build->new(
+ module_name => $dist->name,
+ license => 'perl',
+ meta_add => {foo => 'bar'},
+ conflicts => {'Foo::Barxx' => 0},
+ );
+ my %data;
+ $mb->prepare_metadata( \%data );
+ is $data{foo}, 'bar';
+
+ $mb->meta_merge(foo => 'baz');
+ $mb->prepare_metadata( \%data );
+ is $data{foo}, 'baz';
+
+ $mb->meta_merge(conflicts => {'Foo::Fooxx' => 0});
+ $mb->prepare_metadata( \%data );
+ is_deeply $data{conflicts}, {'Foo::Barxx' => 0, 'Foo::Fooxx' => 0};
+
+ $mb->meta_add(conflicts => {'Foo::Bazxx' => 0});
+ $mb->prepare_metadata( \%data );
+ is_deeply $data{conflicts}, {'Foo::Bazxx' => 0, 'Foo::Fooxx' => 0};
+}
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 6;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+use IO::File;
+
+
+use Module::Build;
+my $mb = Module::Build->new_from_context;
+my @files;
+
+{
+ # Make sure copy_if_modified() can handle spaces in filenames
+
+ my @tmp;
+ foreach (1..2) {
+ my $tmp = File::Spec->catdir('t', "tmp$_");
+ $mb->add_to_cleanup($tmp);
+ push @files, $tmp;
+ unless (-d $tmp) {
+ mkdir($tmp, 0777) or die "Can't create $tmp: $!";
+ }
+ ok -d $tmp;
+ $tmp[$_] = $tmp;
+ }
+
+ my $filename = 'file with spaces.txt';
+
+ my $file = File::Spec->catfile($tmp[1], $filename);
+ my $fh = IO::File->new($file, '>') or die "Can't create $file: $!";
+ print $fh "Foo\n";
+ $fh->close;
+ ok -e $file;
+
+
+ my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[2]);
+ ok $file2;
+ ok -e $file2;
+}
+
+{
+ # Try some dir_contains() combinations
+ my $first = File::Spec->catdir('', 'one', 'two');
+ my $second = File::Spec->catdir('', 'one', 'two', 'three');
+
+ ok( Module::Build->dir_contains($first, $second) );
+}
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 34;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+#########################
+
+use Module::Build;
+use Config;
+
+
+$dist->add_file( 'script', <<'---' );
+#!perl -w
+print "Hello, World!\n";
+---
+$dist->change_file( 'Build.PL', <<"---" );
+use Module::Build;
+
+my \$build = new Module::Build(
+ module_name => @{[$dist->name]},
+ scripts => [ 'script' ],
+ license => 'perl',
+ requires => { 'File::Spec' => 0 },
+);
+\$build->create_build_script;
+---
+$dist->regen;
+
+
+use File::Spec::Functions qw( catdir );
+
+my $mb = Module::Build->new_from_context(
+ # need default install paths to ensure manpages & HTML get generated
+ installdirs => 'site',
+ config => {
+ installman1dir => catdir($tmp, 'man', 'man1'),
+ installman3dir => catdir($tmp, 'man', 'man3'),
+ installhtml1dir => catdir($tmp, 'html'),
+ installhtml3dir => catdir($tmp, 'html'),
+
+ installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
+ installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
+ installsitehtml1dir => catdir($tmp, 'site', 'html'),
+ installsitehtml3dir => catdir($tmp, 'site', 'html'),
+ }
+
+);
+
+ok $mb;
+
+
+my $destdir = File::Spec->catdir($cwd, 't', 'install_test');
+$mb->add_to_cleanup($destdir);
+
+{
+ eval {$mb->dispatch('install', destdir => $destdir)};
+ is $@, '';
+
+ my $libdir = strip_volume( $mb->install_destination('lib') );
+ my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm';
+ file_exists($install_to);
+
+ local @INC = (@INC, File::Spec->catdir($destdir, $libdir));
+ eval "require @{[$dist->name]}";
+ is $@, '';
+
+ # Make sure there's a packlist installed
+ my $archdir = $mb->install_destination('arch');
+ my ($v, $d) = File::Spec->splitpath($archdir, 1);
+ my $packlist = File::Spec->catdir($destdir, $d, 'auto', $dist->name, '.packlist');
+ is -e $packlist, 1, "$packlist should be written";
+}
+
+{
+ eval {$mb->dispatch('install', installdirs => 'core', destdir => $destdir)};
+ is $@, '';
+ my $libdir = strip_volume( $Config{installprivlib} );
+ my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm';
+ file_exists($install_to);
+}
+
+{
+ my $libdir = File::Spec->catdir(File::Spec->rootdir, 'foo', 'bar');
+ eval {$mb->dispatch('install', install_path => {lib => $libdir}, destdir => $destdir)};
+ is $@, '';
+ my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm';
+ file_exists($install_to);
+}
+
+{
+ my $libdir = File::Spec->catdir(File::Spec->rootdir, 'foo', 'base');
+ eval {$mb->dispatch('install', install_base => $libdir, destdir => $destdir)};
+ is $@, '';
+ my $install_to = File::Spec->catfile($destdir, $libdir, 'lib', 'perl5', $dist->name ) . '.pm';
+ file_exists($install_to);
+}
+
+{
+ # Test the ConfigData stuff
+
+ $mb->config_data(foo => 'bar');
+ $mb->features(baz => 1);
+ $mb->auto_features(auto_foo => {requires => {'File::Spec' => 0}});
+ eval {$mb->dispatch('install', destdir => $destdir)};
+ is $@, '';
+
+ my $libdir = strip_volume( $mb->install_destination('lib') );
+ local @INC = (@INC, File::Spec->catdir($destdir, $libdir));
+ eval "require @{[$dist->name]}::ConfigData";
+
+ is $mb->feature('auto_foo'), 1;
+
+ SKIP: {
+ skip $@, 5 if @_;
+
+ # Make sure the values are present
+ my $config = $dist->name . '::ConfigData';
+ is( $config->config('foo'), 'bar' );
+ ok( $config->feature('baz') );
+ ok( $config->feature('auto_foo') );
+ ok( not $config->feature('nonexistent') );
+
+ # Add a new value to the config set
+ $config->set_config(floo => 'bhlar');
+ is( $config->config('floo'), 'bhlar' );
+
+ # Make sure it actually got written
+ $config->write;
+ delete $INC{"@{[$dist->name]}/ConfigData.pm"};
+ {
+ local $^W; # Avoid warnings for subroutine redefinitions
+ eval "require $config";
+ }
+ is( $config->config('floo'), 'bhlar' );
+ }
+}
+
+
+eval {$mb->dispatch('realclean')};
+is $@, '';
+
+{
+ # Try again by running the script rather than with programmatic interface
+ my $libdir = File::Spec->catdir('', 'foo', 'lib');
+ eval {$mb->run_perl_script('Build.PL', [], ['--install_path', "lib=$libdir"])};
+ is $@, '';
+
+ eval {$mb->run_perl_script('Build', [], ['install', '--destdir', $destdir])};
+ is $@, '';
+ my $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm';
+ file_exists($install_to);
+
+ my $basedir = File::Spec->catdir('', 'bar');
+ eval {$mb->run_perl_script('Build', [], ['install', '--destdir', $destdir,
+ '--install_base', $basedir])};
+ is $@, '';
+
+ $install_to = File::Spec->catfile($destdir, $libdir, $dist->name ) . '.pm';
+ is -e $install_to, 1, "Look for file at $install_to";
+
+ eval {$mb->dispatch('realclean')};
+ is $@, '';
+}
+
+{
+ # Make sure 'install_path' overrides 'install_base'
+ my $mb = Module::Build->new( module_name => $dist->name,
+ install_base => File::Spec->catdir('', 'foo'),
+ install_path => {
+ lib => File::Spec->catdir('', 'bar')
+ }
+ );
+ ok $mb;
+ is $mb->install_destination('lib'), File::Spec->catdir('', 'bar');
+}
+
+{
+ $dist->add_file( 'lib/Simple/Docs.pod', <<'---' );
+=head1 NAME
+
+Simple::Docs - Simple pod
+
+=head1 AUTHOR
+
+Simple Man <simple@example.com>
+
+=cut
+---
+ $dist->regen;
+
+ # _find_file_by_type() isn't a public method, but this is currently
+ # the only easy way to test that it works properly.
+ my $pods = $mb->_find_file_by_type('pod', 'lib');
+ is keys %$pods, 1;
+ my $expect = $mb->localize_file_path('lib/Simple/Docs.pod');
+ is $pods->{$expect}, $expect;
+
+ my $pms = $mb->_find_file_by_type('awefawef', 'lib');
+ ok $pms;
+ is keys %$pms, 0;
+
+ $pms = $mb->_find_file_by_type('pod', 'awefawef');
+ ok $pms;
+ is keys %$pms, 0;
+
+ # revert to pristine state
+ chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+ $dist->remove;
+ $dist = DistGen->new( dir => $tmp );
+ $dist->regen;
+ chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+}
+
+sub strip_volume {
+ my $dir = shift;
+ (undef, $dir) = File::Spec->splitpath( $dir, 1 );
+ return $dir;
+}
+
+sub file_exists {
+ my $file = shift;
+ ok -e $file or diag("Expected $file to exist, but it doesn't");
+}
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+package DistGen;
+
+use strict;
+
+use vars qw( $VERSION $VERBOSE );
+
+$VERSION = '0.01';
+$VERBOSE = 0;
+
+
+use Cwd ();
+use File::Basename ();
+use File::Find ();
+use File::Path ();
+use File::Spec ();
+use IO::File ();
+use Tie::CPHash;
+
+sub new {
+ my $package = shift;
+ my %options = @_;
+
+ $options{name} ||= 'Simple';
+ $options{dir} ||= Cwd::cwd();
+
+ my %data = (
+ skip_manifest => 0,
+ xs => 0,
+ %options,
+ );
+ my $self = bless( \%data, $package );
+
+ tie %{$self->{filedata}}, 'Tie::CPHash';
+
+ tie %{$self->{pending}{change}}, 'Tie::CPHash';
+
+ if ( -d $self->dirname ) {
+ warn "Warning: Removing existing directory '@{[$self->dirname]}'\n";
+ $self->remove;
+ }
+
+ $self->_gen_default_filedata();
+
+ return $self;
+}
+
+
+sub _gen_default_filedata {
+ my $self = shift;
+
+ $self->add_file( 'Build.PL', <<"---" ) unless $self->{filedata}{'Build.PL'};
+use strict;
+use Module::Build;
+
+my \$builder = Module::Build->new(
+ module_name => '$self->{name}',
+ license => 'perl',
+);
+
+\$builder->create_build_script();
+---
+
+ my $module_filename =
+ join( '/', ('lib', split(/::/, $self->{name})) ) . '.pm';
+
+ unless ( $self->{xs} ) {
+ $self->add_file( $module_filename, <<"---" ) unless $self->{filedata}{$module_filename};
+package $self->{name};
+
+use vars qw( \$VERSION );
+\$VERSION = '0.01';
+
+use strict;
+
+1;
+
+__END__
+
+=head1 NAME
+
+$self->{name} - Perl extension for blah blah blah
+
+=head1 DESCRIPTION
+
+Stub documentation for $self->{name}.
+
+=head1 AUTHOR
+
+A. U. Thor, a.u.thor\@a.galaxy.far.far.away
+
+=cut
+---
+
+ $self->add_file( 't/basic.t', <<"---" ) unless $self->{filedata}{'t/basic.t'};
+use Test::More tests => 1;
+use strict;
+
+use $self->{name};
+ok 1;
+---
+
+ } else {
+ $self->add_file( $module_filename, <<"---" ) unless $self->{filedata}{$module_filename};
+package $self->{name};
+
+\$VERSION = '0.01';
+
+require Exporter;
+require DynaLoader;
+
+\@ISA = qw(Exporter DynaLoader);
+\@EXPORT_OK = qw( okay );
+
+bootstrap $self->{name} \$VERSION;
+
+1;
+
+__END__
+
+=head1 NAME
+
+$self->{name} - Perl extension for blah blah blah
+
+=head1 DESCRIPTION
+
+Stub documentation for $self->{name}.
+
+=head1 AUTHOR
+
+A. U. Thor, a.u.thor\@a.galaxy.far.far.away
+
+=cut
+---
+
+ my $xs_filename =
+ join( '/', ('lib', split(/::/, $self->{name})) ) . '.xs';
+ $self->add_file( $xs_filename, <<"---" ) unless $self->{filedata}{$xs_filename};
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+MODULE = $self->{name} PACKAGE = $self->{name}
+
+SV *
+okay()
+ CODE:
+ RETVAL = newSVpv( "ok", 0 );
+ OUTPUT:
+ RETVAL
+
+char *
+xs_version()
+ CODE:
+ RETVAL = XS_VERSION;
+ OUTPUT:
+ RETVAL
+
+char *
+version()
+ CODE:
+ RETVAL = VERSION;
+ OUTPUT:
+ RETVAL
+---
+
+ $self->add_file( 't/basic.t', <<"---" ) unless $self->{filedata}{'t/basic.t'};
+use Test::More tests => 2;
+use strict;
+
+use $self->{name};
+ok 1;
+
+ok( $self->{name}::okay() eq 'ok' );
+---
+ }
+}
+
+sub _gen_manifest {
+ my $self = shift;
+ my $manifest = shift;
+
+ my $fh = IO::File->new( ">$manifest" ) or do {
+ $self->remove();
+ die "Can't write '$manifest'\n";
+ };
+
+ my @files = ( 'MANIFEST', keys %{$self->{filedata}} );
+ my $data = join( "\n", sort @files ) . "\n";
+ print $fh $data;
+ close( $fh );
+
+ $self->{filedata}{MANIFEST} = $data;
+ $self->{pending}{change}{MANIFEST} = 1;
+}
+
+sub name { shift()->{name} }
+
+sub dirname {
+ my $self = shift;
+ my $dist = join( '-', split( /::/, $self->{name} ) );
+ return File::Spec->catdir( $self->{dir}, $dist );
+}
+
+sub _real_filename {
+ my $self = shift;
+ my $filename = shift;
+ return File::Spec->catfile( split( /\//, $filename ) );
+}
+
+sub regen {
+ my $self = shift;
+ my %opts = @_;
+
+ my $dist_dirname = $self->dirname;
+
+ if ( $opts{clean} ) {
+ $self->clean() if -d $dist_dirname;
+ } else {
+ # TODO: This might leave dangling directories. Eg if the removed file
+ # is 'lib/Simple/Simon.pm', The directory 'lib/Simple' will be left
+ # even if there are no files left in it. However, clean() will remove it.
+ my @files = keys %{$self->{pending}{remove}};
+ foreach my $file ( @files ) {
+ my $real_filename = $self->_real_filename( $file );
+ my $fullname = File::Spec->catfile( $dist_dirname, $real_filename );
+ if ( -e $fullname ) {
+ 1 while unlink( $fullname );
+ }
+ print "Unlinking pending file '$file'\n" if $VERBOSE;
+ delete( $self->{pending}{remove}{$file} );
+ }
+ }
+
+ foreach my $file ( keys( %{$self->{filedata}} ) ) {
+ my $real_filename = $self->_real_filename( $file );
+ my $fullname = File::Spec->catfile( $dist_dirname, $real_filename );
+
+ if ( ! -e $fullname ||
+ ( -e $fullname && $self->{pending}{change}{$file} ) ) {
+
+ print "Changed file '$file'.\n" if $VERBOSE;
+
+ my $dirname = File::Basename::dirname( $fullname );
+ unless ( -d $dirname ) {
+ File::Path::mkpath( $dirname ) or do {
+ $self->remove();
+ die "Can't create '$dirname'\n";
+ };
+ }
+
+ if ( -e $fullname ) {
+ 1 while unlink( $fullname );
+ }
+
+ my $fh = IO::File->new(">$fullname") or do {
+ $self->remove();
+ die "Can't write '$fullname'\n";
+ };
+ print $fh $self->{filedata}{$file};
+ close( $fh );
+ }
+
+ delete( $self->{pending}{change}{$file} );
+ }
+
+ my $manifest = File::Spec->catfile( $dist_dirname, 'MANIFEST' );
+ unless ( $self->{skip_manifest} ) {
+ if ( -e $manifest ) {
+ 1 while unlink( $manifest );
+ }
+ $self->_gen_manifest( $manifest );
+ }
+}
+
+sub clean {
+ my $self = shift;
+
+ my $here = Cwd::abs_path();
+ my $there = File::Spec->rel2abs( $self->dirname() );
+
+ if ( -d $there ) {
+ chdir( $there ) or die "Can't change directory to '$there'\n";
+ } else {
+ die "Distribution not found in '$there'\n";
+ }
+
+ my %names;
+ tie %names, 'Tie::CPHash';
+ foreach my $file ( keys %{$self->{filedata}} ) {
+ my $filename = $self->_real_filename( $file );
+ my $dirname = File::Basename::dirname( $filename );
+
+ $names{$filename} = 0;
+
+ print "Splitting '$dirname'\n" if $VERBOSE;
+ my @dirs = File::Spec->splitdir( $dirname );
+ while ( @dirs ) {
+ my $dir = ( scalar(@dirs) == 1
+ ? $dirname
+ : File::Spec->catdir( @dirs ) );
+ if (length $dir) {
+ print "Setting directory name '$dir' in \%names\n" if $VERBOSE;
+ $names{$dir} = 0;
+ }
+ pop( @dirs );
+ }
+ }
+
+ File::Find::finddepth( sub {
+ my $name = File::Spec->canonpath( $File::Find::name );
+
+ $name =~ s/\.\z// if $^O eq 'VMS';
+
+ if ( not exists $names{$name} ) {
+ print "Removing '$name'\n" if $VERBOSE;
+ File::Path::rmtree( $_ );
+ }
+ }, ($^O eq "VMS" ? './' : File::Spec->curdir) );
+
+ chdir( $here );
+}
+
+sub remove {
+ my $self = shift;
+ File::Path::rmtree( $self->dirname );
+}
+
+sub revert {
+ my $self = shift;
+ die "Unimplemented.\n";
+}
+
+sub add_file {
+ my $self = shift;
+ $self->change_file( @_ );
+}
+
+sub remove_file {
+ my $self = shift;
+ my $file = shift;
+ unless ( exists $self->{filedata}{$file} ) {
+ warn "Can't remove '$file': It does not exist.\n" if $VERBOSE;
+ }
+ delete( $self->{filedata}{$file} );
+ $self->{pending}{remove}{$file} = 1;
+}
+
+sub change_file {
+ my $self = shift;
+ my $file = shift;
+ my $data = shift;
+ $self->{filedata}{$file} = $data;
+ $self->{pending}{change}{$file} = 1;
+}
+
+1;
+
+__END__
+
+
+=head1 NAME
+
+DistGen - Creates simple distributions for testing.
+
+
+=head1 DESCRIPTION
+
+
+
+=head1 API
+
+
+=head2 Constructor
+
+=head3 new()
+
+Create a new distribution generator. Does not actually write the
+contents.
+
+=over
+
+=item name
+
+The name of the module this distribution represents. The default is
+'Simple'.
+
+=item dir
+
+The directory in which to create the distribution directory. The
+default is File::Spec->curdir.
+
+=item xs
+
+Generates an XS based module.
+
+=back
+
+
+=head2 Manipulating the Distribution
+
+=head3 regen( [OPTIONS] )
+
+Regenerate all files that are missing or that have changed. If the
+optional C<clean> argument is given, it also removes any extraneous
+files that do not belong to the distribution.
+
+=over
+
+=item clean
+
+When true, removes any files not part of the distribution while
+regenerating.
+
+=back
+
+=head3 clean()
+
+Removes any files that are not part of the distribution.
+
+=head3 revert( [$filename] )
+
+[Unimplemented] Returns the object to its initial state, or given a
+$filename it returns that file to it's initial state if it is one of
+the built-in files.
+
+=head3 remove()
+
+Removes the complete distribution.
+
+
+=head2 Editing Files
+
+Note that all ${filename}s should be specified with unix-style paths,
+and are relative to the distribution root directory. Eg 'lib/Module.pm'
+
+=head3 add_file( $filename, $content )
+
+Add a $filename containg $content to the distribution. No action is
+performed until the distribution is regenerated.
+
+=head3 remove_file( $filename )
+
+Removes $filename from the distribution. No action is performed until
+the distribution is regenerated.
+
+=head3 change_file( $filename, $content )
+
+Changes the contents of $filename to $content. No action is performed
+until the distribution is regenerated.
+
+
+=head2 Properties
+
+=head3 name()
+
+Returns the name of the distribution.
+
+=head3 dirname()
+
+Returns the directory name where the distribution is created.
+
+=cut
--- /dev/null
+package MBTest;
+
+use strict;
+
+use File::Spec;
+
+BEGIN {
+ # Make sure none of our tests load the users ~/.modulebuildrc file
+ $ENV{MODULEBUILDRC} = 'NONE';
+
+ # In case the test wants to use Test::More or our other bundled
+ # modules, make sure they can be loaded. They'll still do "use
+ # Test::More" in the test script.
+ my $t_lib = File::Spec->catdir('t', 'bundled');
+
+ if (!$ENV{PERL_CORE}) {
+ push @INC, $t_lib; # Let user's installed version override
+ } else {
+ # We change directories, so expand @INC to absolute paths
+ # Also add .
+ @INC = (map(File::Spec->rel2abs($_), @INC), ".");
+
+ # we are in 't', go up a level so we don't create t/t/_tmp
+ chdir '..' or die "Couldn't chdir to ..";
+
+ push @INC, File::Spec->catdir(qw/lib Module Build/, $t_lib);
+
+ # make sure children get @INC pointing to uninstalled files
+ require Cwd;
+ $ENV{PERL5LIB} = File::Spec->catdir(Cwd::cwd(), 'lib');
+ }
+}
+
+use Exporter;
+use Test::More;
+use Config;
+
+# We pass everything through to Test::More
+use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO);
+$VERSION = 0.01;
+@ISA = qw(Test::More); # Test::More isa Exporter
+@EXPORT = @Test::More::EXPORT;
+%EXPORT_TAGS = %Test::More::EXPORT_TAGS;
+
+# We have a few extra exports, but Test::More has a special import()
+# that won't take extra additions.
+my @extra_exports = qw(stdout_of stderr_of slurp find_in_path check_compiler);
+push @EXPORT, @extra_exports;
+__PACKAGE__->export(scalar caller, @extra_exports);
+
+
+sub save_handle {
+ my ($handle, $subr) = @_;
+ my $outfile = 'save_out';
+
+ local *SAVEOUT;
+ open SAVEOUT, ">&" . fileno($handle) or die "Can't save output handle: $!";
+ open $handle, "> $outfile" or die "Can't create $outfile: $!";
+
+ eval {$subr->()};
+ open $handle, ">&SAVEOUT" or die "Can't restore output: $!";
+
+ my $ret = slurp($outfile);
+ 1 while unlink $outfile;
+ return $ret;
+}
+
+sub stdout_of { save_handle(\*STDOUT, @_) }
+sub stderr_of { save_handle(\*STDERR, @_) }
+
+sub slurp {
+ my $fh = IO::File->new($_[0]) or die "Can't open $_[0]: $!";
+ local $/;
+ return scalar <$fh>;
+}
+
+sub find_in_path {
+ my $thing = shift;
+
+ my @path = split $Config{path_sep}, $ENV{PATH};
+ my @exe_ext = $^O eq 'MSWin32' ? ('', # may have extension already
+ split($Config{path_sep}, $ENV{PATHEXT} || '.com;.exe;.bat')) :
+ ('');
+ foreach (@path) {
+ my $fullpath = File::Spec->catfile($_, $thing);
+ foreach my $ext ( @exe_ext ) {
+ return "$fullpath$ext" if -e "$fullpath$ext";
+ }
+ }
+ return;
+}
+
+# returns ($have_c_compiler, $C_support_feature);
+sub check_compiler {
+ return (1,1) if $ENV{PERL_CORE};
+
+ local $SIG{__WARN__} = sub {};
+
+ my $mb = Module::Build->current;
+ $mb->verbose( 0 );
+
+ my $have_c_compiler;
+ stderr_of( sub {$have_c_compiler = $mb->have_c_compiler} );
+
+ return ($have_c_compiler, $mb->feature('C_support'));
+}
+
+1;
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest;
+use Module::Build;
+use Module::Build::ConfigData;
+
+if ( Module::Build::ConfigData->feature('manpage_support') ) {
+ plan tests => 21;
+} else {
+ plan skip_all => 'manpage_support feature is not enabled';
+}
+
+#########################
+
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->add_file( 'bin/nopod.pl', <<'---' );
+#!perl -w
+print "sample script without pod to test manifypods action\n";
+---
+$dist->add_file( 'bin/haspod.pl', <<'---' );
+#!perl -w
+print "Hello, world";
+
+__END__
+
+=head1 NAME
+
+haspod.pl - sample script with pod to test manifypods action
+
+=cut
+---
+$dist->add_file( 'lib/Simple/NoPod.pm', <<'---' );
+package Simple::NoPod;
+1;
+---
+$dist->add_file( 'lib/Simple/AllPod.pod', <<'---' );
+=head1 NAME
+
+Simple::AllPod - Pure POD
+
+=head1 AUTHOR
+
+Simple Man <simple@example.com>
+
+=cut
+---
+$dist->regen;
+
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+use File::Spec::Functions qw( catdir );
+my $destdir = catdir($cwd, 't', 'install_test');
+
+
+my $mb = Module::Build->new(
+ module_name => $dist->name,
+ install_base => $destdir,
+ scripts => [ File::Spec->catfile( 'bin', 'nopod.pl' ),
+ File::Spec->catfile( 'bin', 'haspod.pl' ) ],
+
+ # need default install paths to ensure manpages & HTML get generated
+ installdirs => 'site',
+ config => {
+ installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
+ installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
+ installsitehtml1dir => catdir($tmp, 'site', 'html'),
+ installsitehtml3dir => catdir($tmp, 'site', 'html'),
+ }
+
+);
+
+$mb->add_to_cleanup($destdir);
+
+
+is( ref $mb->{properties}->{bindoc_dirs}, 'ARRAY', 'bindoc_dirs' );
+is( ref $mb->{properties}->{libdoc_dirs}, 'ARRAY', 'libdoc_dirs' );
+
+my %man = (
+ sep => $mb->manpage_separator,
+ dir1 => 'man1',
+ dir3 => 'man3',
+ ext1 => $mb->config('man1ext'),
+ ext3 => $mb->config('man3ext'),
+ );
+
+my %distro = (
+ 'bin/nopod.pl' => '',
+ 'bin/haspod.pl' => "haspod.pl.$man{ext1}",
+ 'lib/Simple.pm' => "Simple.$man{ext3}",
+ 'lib/Simple/NoPod.pm' => '',
+ 'lib/Simple/AllPod.pod' => "Simple$man{sep}AllPod.$man{ext3}",
+ );
+
+%distro = map {$mb->localize_file_path($_), $distro{$_}} keys %distro;
+
+$mb->dispatch('build');
+
+eval {$mb->dispatch('docs')};
+is $@, '';
+
+while (my ($from, $v) = each %distro) {
+ if (!$v) {
+ ok ! $mb->contains_pod($from), "$from should not contain POD";
+ next;
+ }
+
+ my $to = File::Spec->catfile('blib', ($from =~ /^lib/ ? 'libdoc' : 'bindoc'), $v);
+ ok $mb->contains_pod($from), "$from should contain POD";
+ ok -e $to, "Created $to manpage";
+}
+
+
+$mb->dispatch('install');
+
+while (my ($from, $v) = each %distro) {
+ next unless $v;
+ my $to = File::Spec->catfile($destdir, 'man', $man{($from =~ /^lib/ ? 'dir3' : 'dir1')}, $v);
+ ok -e $to, "Created $to manpage";
+}
+
+$mb->dispatch('realclean');
+
+
+# revert to a pristine state
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+$dist = DistGen->new( dir => $tmp );
+$dist->regen;
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+my $mb2 = Module::Build->new(
+ module_name => $dist->name,
+ libdoc_dirs => [qw( foo bar baz )],
+);
+
+is( $mb2->{properties}->{libdoc_dirs}->[0], 'foo', 'override libdoc_dirs' );
+
+# Make sure we can find our own action documentation
+ok $mb2->get_action_docs('build');
+ok !$mb2->get_action_docs('foo');
+
+# Make sure those docs are the correct ones
+foreach ('testcover', 'disttest') {
+ my $docs = $mb2->get_action_docs($_);
+ like $docs, qr/=item $_/;
+ unlike $docs, qr/\n=/, $docs;
+}
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 46;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+
+use Module::Build;
+use Module::Build::ConfigData;
+my $has_YAML = Module::Build::ConfigData->feature('YAML_support');
+
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->change_file( 'Build.PL', <<"---" );
+
+my \$builder = Module::Build->new(
+ module_name => '@{[$dist->name]}',
+ dist_version => '3.14159265',
+ dist_author => [ 'Simple Simon <ss\@somewhere.priv>' ],
+ dist_abstract => 'Something interesting',
+ license => 'perl',
+);
+
+\$builder->create_build_script();
+---
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+use Module::Build;
+my $mb = Module::Build->new_from_context;
+
+##################################################
+#
+# Test for valid META.yml
+
+SKIP: {
+ skip( 'YAML_support feature is not enabled', 8 ) unless $has_YAML;
+
+ require YAML;
+ require YAML::Node;
+ my $node = YAML::Node->new({});
+ $node = $mb->prepare_metadata( $node );
+
+ # exists() doesn't seem to work here
+ ok defined( $node->{name} ), "'name' field present in META.yml";
+ ok defined( $node->{version} ), "'version' field present in META.yml";
+ ok defined( $node->{abstract} ), "'abstract' field present in META.yml";
+ ok defined( $node->{author} ), "'author' field present in META.yml";
+ ok defined( $node->{license} ), "'license' field present in META.yml";
+ ok defined( $node->{generated_by} ),
+ "'generated_by' field present in META.yml";
+ ok defined( $node->{'meta-spec'}{version} ),
+ "'meta-spec' -> 'version' field present in META.yml";
+ ok defined( $node->{'meta-spec'}{url} ),
+ "'meta-spec' -> 'url' field present in META.yml";
+
+ # TODO : find a way to test for failure when above fields are not present
+}
+
+$dist->clean;
+
+
+##################################################
+#
+# Tests to ensure that the correct packages and versions are
+# recorded for the 'provides' field of META.yml
+
+my $provides; # Used a bunch of times below
+
+sub new_build { return Module::Build->new_from_context( quiet => 1, @_ ) }
+
+############################## Single Module
+
+# File with corresponding package (w/ or w/o version)
+# Simple.pm => Simple v1.23
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => {file => 'lib/Simple.pm',
+ version => '1.23'}});
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => {file => 'lib/Simple.pm'}});
+
+# File with no corresponding package (w/ or w/o version)
+# Simple.pm => Foo::Bar v1.23
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo::Bar;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Foo::Bar' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo::Bar;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Foo::Bar' => { file => 'lib/Simple.pm'}});
+
+
+# Single file with multiple differing packages (w/ or w/o version)
+# Simple.pm => Simple
+# Simple.pm => Foo::Bar
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+package Foo::Bar;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' },
+ 'Foo::Bar' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+
+
+# Single file with multiple differing packages, no corresponding package
+# Simple.pm => Foo
+# Simple.pm => Foo::Bar
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo;
+$VERSION = '1.23';
+package Foo::Bar;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Foo' => { file => 'lib/Simple.pm',
+ version => '1.23' },
+ 'Foo::Bar' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+
+
+# Single file with same package appearing multiple times, no version
+# only record a single instance
+# Simple.pm => Simple
+# Simple.pm => Simple
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+package Simple;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple.pm' }});
+
+
+# Single file with same package appearing multiple times, single
+# version 1st package:
+# Simple.pm => Simple v1.23
+# Simple.pm => Simple
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+package Simple;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+
+
+# Single file with same package appearing multiple times, single
+# version 2nd package
+# Simple.pm => Simple
+# Simple.pm => Simple v1.23
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+package Simple;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+
+
+# Single file with same package appearing multiple times, conflicting versions
+# Simple.pm => Simple v1.23
+# Simple.pm => Simple v2.34
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+package Simple;
+$VERSION = '2.34';
+---
+$dist->regen( clean => 1 );
+my $err = '';
+$err = stderr_of( sub { $mb = new_build() } );
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+is_deeply($provides,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }}); # XXX should be 2.34?
+like( $err, qr/already declared/, ' with conflicting versions reported' );
+
+
+# (Same as above three cases except with no corresponding package)
+# Simple.pm => Foo v1.23
+# Simple.pm => Foo v2.34
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo;
+$VERSION = '1.23';
+package Foo;
+$VERSION = '2.34';
+---
+$dist->regen( clean => 1 );
+$err = stderr_of( sub { $mb = new_build() } );
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+is_deeply($provides,
+ {'Foo' => { file => 'lib/Simple.pm',
+ version => '1.23' }}); # XXX should be 2.34?
+like( $err, qr/already declared/, ' with conflicting versions reported' );
+
+
+
+############################## Multiple Modules
+
+# Multiple files with same package, no version
+# Simple.pm => Simple
+# Simple2.pm => Simple
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Simple;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple.pm' }});
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package, single version in corresponding package
+# Simple.pm => Simple v1.23
+# Simple2.pm => Simple
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Simple;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package,
+# single version in non-corresponding package
+# Simple.pm => Simple
+# Simple2.pm => Simple v1.23
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple2.pm',
+ version => '1.23' }});
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package, conflicting versions
+# Simple.pm => Simple v1.23
+# Simple2.pm => Simple v2.34
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Simple;
+$VERSION = '2.34';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+is_deeply($provides,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+like( $err, qr/Found conflicting versions for package/,
+ ' with conflicting versions reported' );
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package, multiple agreeing versions
+# Simple.pm => Simple v1.23
+# Simple2.pm => Simple v1.23
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+is_deeply($provides,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+############################################################
+#
+# (Same as above five cases except with non-corresponding package)
+#
+
+# Multiple files with same package, no version
+# Simple.pm => Foo
+# Simple2.pm => Foo
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo;
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Foo;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+$provides = $mb->find_dist_packages;
+ok( exists( $provides->{Foo} ) ); # it exist, can't predict which file
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package, version in first file
+# Simple.pm => Foo v1.23
+# Simple2.pm => Foo
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Foo;
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Foo' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package, version in second file
+# Simple.pm => Foo
+# Simple2.pm => Foo v1.23
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo;
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Foo;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Foo' => { file => 'lib/Simple2.pm',
+ version => '1.23' }});
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package, conflicting versions
+# Simple.pm => Foo v1.23
+# Simple2.pm => Foo v2.34
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Foo;
+$VERSION = '2.34';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+# XXX Should 'Foo' exist ??? Can't predict values for file & version
+ok( exists( $provides->{Foo} ) );
+like( $err, qr/Found conflicting versions for package/,
+ ' with conflicting versions reported' );
+$dist->remove_file( 'lib/Simple2.pm' );
+
+
+# Multiple files with same package, multiple agreeing versions
+# Simple.pm => Foo v1.23
+# Simple2.pm => Foo v1.23
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Foo;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Foo;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+ok( exists( $provides->{Foo} ) );
+is( $provides->{Foo}{version}, '1.23' );
+ok( exists( $provides->{Foo}{file} ) ); # Can't predict which file
+is( $err, '', ' no conflicts reported' );
+$dist->remove_file( 'lib/Simple2.pm' );
+
+############################################################
+# Conflicts among primary & multiple alternatives
+
+# multiple files, conflicting version in corresponding file
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Simple;
+$VERSION = '2.34';
+---
+$dist->add_file( 'lib/Simple3.pm', <<'---' );
+package Simple;
+$VERSION = '2.34';
+---
+$dist->regen( clean => 1 );
+$err = stderr_of( sub {
+ $mb = new_build();
+} );
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+is_deeply($provides,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+like( $err, qr/Found conflicting versions for package/,
+ ' corresponding package conflicts with multiple alternatives' );
+$dist->remove_file( 'lib/Simple2.pm' );
+$dist->remove_file( 'lib/Simple3.pm' );
+
+# multiple files, conflicting version in non-corresponding file
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple2.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+---
+$dist->add_file( 'lib/Simple3.pm', <<'---' );
+package Simple;
+$VERSION = '2.34';
+---
+$dist->regen( clean => 1 );
+$err = stderr_of( sub {
+ $mb = new_build();
+} );
+$err = stderr_of( sub { $provides = $mb->find_dist_packages } );
+is_deeply($provides,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+like( $err, qr/Found conflicting versions for package/,
+ ' only one alternative conflicts with corresponding package' );
+$dist->remove_file( 'lib/Simple2.pm' );
+$dist->remove_file( 'lib/Simple3.pm' );
+
+
+############################################################
+# Don't record private packages (beginning with underscore)
+# Simple.pm => Simple::_private
+# Simple.pm => Simple::_private::too
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+package Simple::_private;
+$VERSION = '2.34';
+package Simple::_private::too;
+$VERSION = '3.45';
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages,
+ {'Simple' => { file => 'lib/Simple.pm',
+ version => '1.23' }});
+
+
+############################################################
+# Files with no packages?
+
+# Simple.pm => <empty>
+
+$dist->change_file( 'lib/Simple.pm', '' );
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply( $mb->find_dist_packages, {} );
+
+# Simple.pm => =pod..=cut (no package declaration)
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+=pod
+
+=head1 NAME
+
+Simple - Pure Documentation
+
+=head1 DESCRIPTION
+
+Doesn't do anything.
+
+=cut
+---
+$dist->regen( clean => 1 );
+$mb = new_build();
+is_deeply($mb->find_dist_packages, {});
+
+
+{
+ # Put our YAML escaper through a few tests. This isn't part of the M::B API.
+ my $yq = sub {Module::Build->_yaml_quote_string(@_)};
+ like $yq->(''), qr{^ (['"]) \1 $}x;
+ is $yq->('Foo "bar" baz'), q{'Foo "bar" baz'};
+ is $yq->("Foo 'bar' baz"), q{"Foo 'bar' baz"};
+}
+
+############################################################
+# cleanup
+chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 18;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use Module::Build;
+use Module::Build::ConfigData;
+use DistGen;
+
+
+############################## ACTION distmeta works without a MANIFEST file
+
+SKIP: {
+ skip( 'YAML_support feature is not enabled', 4 )
+ unless Module::Build::ConfigData->feature('YAML_support');
+
+ my $dist = DistGen->new( dir => $tmp, skip_manifest => 1 );
+ $dist->regen;
+
+ chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+ ok ! -e 'MANIFEST';
+
+ my $mb = Module::Build->new_from_context;
+
+ my $out;
+ $out = eval { stderr_of(sub{$mb->dispatch('distmeta')}) };
+ is $@, '';
+
+ like $out, qr/Nothing to enter for 'provides'/;
+
+ ok -e 'META.yml';
+
+ chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+ $dist->remove;
+}
+
+
+############################## Check generation of README file
+
+# TODO: We need to test faking the absence of Pod::Readme when present
+# so Pod::Text will be used. Also fake the absence of both to
+# test that we fail gracefully.
+
+my $provides; # Used a bunch of times below
+
+my $pod_text = <<'---';
+=pod
+
+=head1 NAME
+
+Simple - A simple module
+
+=head1 AUTHOR
+
+Simple Simon <simon@simple.sim>
+
+=cut
+---
+
+my $dist = DistGen->new( dir => $tmp );
+
+$dist->change_file( 'Build.PL', <<"---" );
+use Module::Build;
+my \$builder = Module::Build->new(
+ module_name => '@{[$dist->name]}',
+ dist_version => '3.14159265',
+ license => 'perl',
+ create_readme => 1,
+);
+
+\$builder->create_build_script();
+---
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+# .pm File with pod
+#
+
+$dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
+package Simple;
+$VERSION = '1.23';
+---
+$dist->regen( clean => 1 );
+ok( -e "lib/Simple.pm", "Creating Simple.pm" );
+my $mb = Module::Build->new_from_context;
+$mb->do_create_readme;
+like( slurp("README"), qr/NAME/,
+ "Generating README from .pm");
+is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
+ "Extracting AUTHOR from .pm");
+is( $mb->dist_abstract, "A simple module",
+ "Extracting abstract from .pm");
+
+# .pm File with pod in separate file
+#
+
+$dist->change_file( 'lib/Simple.pm', <<'---');
+package Simple;
+$VERSION = '1.23';
+---
+$dist->change_file( 'lib/Simple.pod', $pod_text );
+$dist->regen( clean => 1 );
+
+ok( -e "lib/Simple.pm", "Creating Simple.pm" );
+ok( -e "lib/Simple.pod", "Creating Simple.pod" );
+$mb = Module::Build->new_from_context;
+$mb->do_create_readme;
+like( slurp("README"), qr/NAME/, "Generating README from .pod");
+is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
+ "Extracting AUTHOR from .pod");
+is( $mb->dist_abstract, "A simple module",
+ "Extracting abstract from .pod");
+
+# .pm File with pod and separate pod file
+#
+
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+
+=pod
+
+=head1 DONT USE THIS FILE FOR POD
+
+=cut
+---
+$dist->change_file( 'lib/Simple.pod', $pod_text );
+$dist->regen( clean => 1 );
+ok( -e "lib/Simple.pm", "Creating Simple.pm" );
+ok( -e "lib/Simple.pod", "Creating Simple.pod" );
+$mb = Module::Build->new_from_context;
+$mb->do_create_readme;
+like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
+is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
+ "Extracting AUTHOR from .pod over .pm");
+is( $mb->dist_abstract, "A simple module",
+ "Extracting abstract from .pod over .pm");
+
+
+############################################################
+# cleanup
+chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 66;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+#########################
+
+
+use_ok( 'Module::Build::ModuleInfo' );
+
+# class method C<find_module_by_name>
+my $module = Module::Build::ModuleInfo->find_module_by_name(
+ 'Module::Build::ModuleInfo' );
+ok( -e $module, 'find_module_by_name() succeeds' );
+
+
+# fail on invalid module name
+my $pm_info = Module::Build::ModuleInfo->new_from_module(
+ 'Foo::Bar', inc => [] );
+ok( !defined( $pm_info ), 'fail if can\'t find module by module name' );
+
+
+# fail on invalid filename
+my $file = File::Spec->catfile( 'Foo', 'Bar.pm' );
+$pm_info = Module::Build::ModuleInfo->new_from_file( $file, inc => [] );
+ok( !defined( $pm_info ), 'fail if can\'t find module by file name' );
+
+
+# construct from module filename
+$file = File::Spec->catfile( 'lib', split( /::/, $dist->name ) ) . '.pm';
+$pm_info = Module::Build::ModuleInfo->new_from_file( $file );
+ok( defined( $pm_info ), 'new_from_file() succeeds' );
+
+# construct from module name, using custom include path
+$pm_info = Module::Build::ModuleInfo->new_from_module(
+ $dist->name, inc => [ 'lib', @INC ] );
+ok( defined( $pm_info ), 'new_from_module() succeeds' );
+
+
+# parse various module $VERSION lines
+my @modules = (
+ <<'---', # declared & defined on same line with 'our'
+package Simple;
+our $VERSION = '1.23';
+---
+ <<'---', # declared & defined on seperate lines with 'our'
+package Simple;
+our $VERSION;
+$VERSION = '1.23';
+---
+ <<'---', # use vars
+package Simple;
+use vars qw( $VERSION );
+$VERSION = '1.23';
+---
+ <<'---', # choose the right default package based on package/file name
+package Simple::_private;
+$VERSION = '0';
+package Simple;
+$VERSION = '1.23'; # this should be chosen for version
+---
+ <<'---', # just read the first $VERSION line
+package Simple;
+$VERSION = '1.23'; # we should see this line
+$VERSION = eval $VERSION; # and ignore this one
+---
+ <<'---', # just read the first $VERSION line in reopened package (1)
+package Simple;
+$VERSION = '1.23';
+package Error::Simple;
+$VERSION = '2.34';
+package Simple;
+---
+ <<'---', # just read the first $VERSION line in reopened package (2)
+package Simple;
+package Error::Simple;
+$VERSION = '2.34';
+package Simple;
+$VERSION = '1.23';
+---
+ <<'---', # mentions another module's $VERSION
+package Simple;
+$VERSION = '1.23';
+if ( $Other::VERSION ) {
+ # whatever
+}
+---
+ <<'---', # mentions another module's $VERSION in a different package
+package Simple;
+$VERSION = '1.23';
+package Simple2;
+if ( $Simple::VERSION ) {
+ # whatever
+}
+---
+ <<'---', # $VERSION checked only in assignments, not regexp ops
+package Simple;
+$VERSION = '1.23';
+if ( $VERSION =~ /1\.23/ ) {
+ # whatever
+}
+---
+ <<'---', # $VERSION checked only in assignments, not relational ops
+package Simple;
+$VERSION = '1.23';
+if ( $VERSION == 3.45 ) {
+ # whatever
+}
+---
+ <<'---', # $VERSION checked only in assignments, not relational ops
+package Simple;
+$VERSION = '1.23';
+package Simple2;
+if ( $Simple::VERSION == 3.45 ) {
+ # whatever
+}
+---
+ <<'---', # Fully qualified $VERSION declared in package
+package Simple;
+$Simple::VERSION = 1.23;
+---
+ <<'---', # Differentiate fully qualified $VERSION in a package
+package Simple;
+$Simple2::VERSION = '999';
+$Simple::VERSION = 1.23;
+---
+ <<'---', # Differentiate fully qualified $VERSION and unqualified
+package Simple;
+$Simple2::VERSION = '999';
+$VERSION = 1.23;
+---
+ <<'---', # $VERSION declared as package variable from within 'main' package
+$Simple::VERSION = '1.23';
+{
+ package Simple;
+ $x = $y, $cats = $dogs;
+}
+---
+ <<'---', # $VERSION wrapped in parens - space inside
+package Simple;
+( $VERSION ) = '1.23';
+---
+ <<'---', # $VERSION wrapped in parens - no space inside
+package Simple;
+($VERSION) = '1.23';
+---
+ <<'---', # $VERSION follows a spurious 'package' in a quoted construct
+package Simple;
+__PACKAGE__->mk_accessors(qw(
+ program socket proc
+ package filename line codeline subroutine finished));
+
+our $VERSION = "1.23";
+---
+);
+
+my( $i, $n ) = ( 1, scalar( @modules ) );
+foreach my $module ( @modules ) {
+ SKIP: {
+ skip( "No our() support until perl 5.6", 2 )
+ if $] < 5.006 && $module =~ /\bour\b/;
+
+ $dist->change_file( 'lib/Simple.pm', $module );
+ $dist->regen;
+
+ my $warnings = '';
+ local $SIG{__WARN__} = sub { $warnings .= $_ for @_ };
+ my $pm_info = Module::Build::ModuleInfo->new_from_file( $file );
+
+ is( $pm_info->version, '1.23',
+ "correct module version ($i of $n)" );
+ is( $warnings, '', 'no warnings from parsing' );
+ $i++;
+ }
+}
+
+# revert to pristine state
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+$dist = DistGen->new( dir => $tmp );
+$dist->regen;
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+# Find each package only once
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23';
+package Error::Simple;
+$VERSION = '2.34';
+package Simple;
+---
+
+$dist->regen;
+
+$pm_info = Module::Build::ModuleInfo->new_from_file( $file );
+
+my @packages = $pm_info->packages_inside;
+is( @packages, 2, 'record only one occurence of each package' );
+
+
+# Module 'Simple.pm' does not contain package 'Simple';
+# constructor should not complain, no default module name or version
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple::Not;
+$VERSION = '1.23';
+---
+
+$dist->regen;
+$pm_info = Module::Build::ModuleInfo->new_from_file( $file );
+
+is( $pm_info->name, undef, 'no default package' );
+is( $pm_info->version, undef, 'no version w/o default package' );
+
+
+# revert to pristine state
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+$dist = DistGen->new( dir => $tmp );
+$dist->regen;
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+# parse $VERSION lines scripts for package main
+my @scripts = (
+ <<'---', # package main declared
+#!perl -w
+package main;
+$VERSION = '0.01';
+---
+ <<'---', # on first non-comment line, non declared package main
+#!perl -w
+$VERSION = '0.01';
+---
+ <<'---', # after non-comment line
+#!perl -w
+use strict;
+$VERSION = '0.01';
+---
+ <<'---', # 1st declared package
+#!perl -w
+package main;
+$VERSION = '0.01';
+package _private;
+$VERSION = '999';
+---
+ <<'---', # 2nd declared package
+#!perl -w
+package _private;
+$VERSION = '999';
+package main;
+$VERSION = '0.01';
+---
+ <<'---', # split package
+#!perl -w
+package main;
+package _private;
+$VERSION = '999';
+package main;
+$VERSION = '0.01';
+---
+ <<'---', # define 'main' version from other package
+package _private;
+$::VERSION = 0.01;
+$VERSION = '999';
+---
+ <<'---', # define 'main' version from other package
+package _private;
+$VERSION = '999';
+$::VERSION = 0.01;
+---
+);
+
+( $i, $n ) = ( 1, scalar( @scripts ) );
+foreach my $script ( @scripts ) {
+ $dist->change_file( 'bin/simple.plx', $script );
+ $dist->regen;
+ $pm_info = Module::Build::ModuleInfo->new_from_file(
+ File::Spec->catfile( 'bin', 'simple.plx' ) );
+
+ is( $pm_info->version, '0.01', "correct script version ($i of $n)" );
+ $i++;
+}
+
+
+# examine properties of a module: name, pod, etc
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '0.01';
+package Simple::Ex;
+$VERSION = '0.02';
+=head1 NAME
+
+Simple - It's easy.
+
+=head1 AUTHOR
+
+Simple Simon
+
+=cut
+---
+$dist->regen;
+
+$pm_info = Module::Build::ModuleInfo->new_from_module(
+ $dist->name, inc => [ 'lib', @INC ] );
+
+is( $pm_info->name, 'Simple', 'found default package' );
+
+is( $pm_info->version, '0.01', 'version for default package' );
+
+# got correct version for secondary package
+is( $pm_info->version( 'Simple::Ex' ), '0.02',
+ 'version for secondary package' );
+
+my $filename = $pm_info->filename;
+ok( defined( $filename ) && -e $filename,
+ 'filename() returns valid path to module file' );
+
+@packages = $pm_info->packages_inside;
+is( @packages, 2, 'found correct number of packages' );
+is( $packages[0], 'Simple', 'packages stored in order found' );
+
+# we can detect presence of pod regardless of whether we are collecting it
+ok( $pm_info->contains_pod, 'contains_pod() succeeds' );
+
+my @pod = $pm_info->pod_inside;
+is_deeply( \@pod, [qw(NAME AUTHOR)], 'found all pod sections' );
+
+is( $pm_info->pod('NONE') , undef,
+ 'return undef() if pod section not present' );
+
+is( $pm_info->pod('NAME'), undef,
+ 'return undef() if pod section not collected' );
+
+
+# collect_pod
+$pm_info = Module::Build::ModuleInfo->new_from_module(
+ $dist->name, inc => [ 'lib', @INC ], collect_pod => 1 );
+
+my $name = $pm_info->pod('NAME');
+if ( $name ) {
+ $name =~ s/^\s+//;
+ $name =~ s/\s+$//;
+}
+is( $name, q|Simple - It's easy.|, 'collected pod section' );
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 11;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+use Module::Build;
+
+###################################
+$dist->change_file( 'Build.PL', <<"---" );
+use Module::Build;
+my \$build = Module::Build->new(
+ module_name => @{[$dist->name]},
+ license => 'perl'
+);
+\$build->create_build_script;
+\$build->notes(foo => 'bar');
+---
+
+$dist->regen;
+
+my $mb = Module::Build->new_from_context;
+
+is $mb->notes('foo'), 'bar';
+
+# Try setting & checking a new value
+$mb->notes(argh => 'new');
+is $mb->notes('argh'), 'new';
+
+# Change existing value
+$mb->notes(foo => 'foo');
+is $mb->notes('foo'), 'foo';
+
+# Change back so we can run this test again successfully
+$mb->notes(foo => 'bar');
+is $mb->notes('foo'), 'bar';
+
+# Check undef vs. 0 vs ''
+foreach my $val (undef, 0, '') {
+ $mb->notes(null => $val);
+ is $mb->notes('null'), $val;
+}
+
+
+###################################
+# Make sure notes set before create_build_script() get preserved
+$mb = Module::Build->new(module_name => $dist->name);
+ok $mb;
+$mb->notes(foo => 'bar');
+is $mb->notes('foo'), 'bar';
+
+$mb->create_build_script;
+
+$mb = Module::Build->resume;
+ok $mb;
+is $mb->notes('foo'), 'bar';
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 27;
+
+#########################
+
+use Module::Build;
+ok(1);
+
+package Foo;
+sub foo;
+
+package MySub1;
+use base 'Module::Build';
+
+package MySub2;
+use base 'MySub1';
+
+package MySub3;
+use base qw(MySub2 Foo);
+
+package MyTest;
+use base 'Module::Build';
+
+package MyBulk;
+use base qw(MySub2 MyTest);
+
+package main;
+
+ok my @parents = MySub1->mb_parents;
+# There will be at least one platform class in between.
+ok @parents >= 2;
+# They should all inherit from Module::Build::Base;
+ok ! grep { !$_->isa('Module::Build::Base') } @parents;
+is $parents[0], 'Module::Build';
+is $parents[-1], 'Module::Build::Base';
+
+ok @parents = MySub2->mb_parents;
+ok @parents >= 3;
+ok ! grep { !$_->isa('Module::Build::Base') } @parents;
+is $parents[0], 'MySub1';
+is $parents[1], 'Module::Build';
+is $parents[-1], 'Module::Build::Base';
+
+ok @parents = MySub3->mb_parents;
+ok @parents >= 4;
+ok ! grep { !$_->isa('Module::Build::Base') } @parents;
+is $parents[0], 'MySub2';
+is $parents[1], 'MySub1';
+is $parents[2], 'Module::Build';
+is $parents[-1], 'Module::Build::Base';
+
+ok @parents = MyBulk->mb_parents;
+ok @parents >= 5;
+ok ! grep { !$_->isa('Module::Build::Base') } @parents;
+is $parents[0], 'MySub2';
+is $parents[1], 'MySub1';
+is $parents[2], 'Module::Build';
+is $parents[-2], 'Module::Build::Base';
+is $parents[-1], 'MyTest';
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 7;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+
+#########################
+
+use_ok 'Module::Build::PodParser';
+
+{
+ package IO::StringBased;
+
+ sub TIEHANDLE {
+ my ($class, $string) = @_;
+ return bless {
+ data => [ map "$_\n", split /\n/, $string],
+ }, $class;
+ }
+
+ sub READLINE {
+ shift @{ shift()->{data} };
+ }
+}
+
+local *FH;
+tie *FH, 'IO::StringBased', <<'EOF';
+=head1 NAME
+
+Foo::Bar - Perl extension for blah blah blah
+
+=head1 AUTHOR
+
+C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.
+
+Home page: http://example.com/~eh/
+
+=cut
+EOF
+
+
+my $pp = Module::Build::PodParser->new(fh => \*FH);
+ok $pp, 'object created';
+
+is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.', 'author';
+is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
+
+
+{
+ # Try again without a valid author spec
+ untie *FH;
+ tie *FH, 'IO::StringBased', <<'EOF';
+=head1 NAME
+
+Foo::Bar - Perl extension for blah blah blah
+
+=cut
+EOF
+
+ my $pp = Module::Build::PodParser->new(fh => \*FH);
+ ok $pp, 'object created';
+
+ is_deeply $pp->get_author, [], 'author';
+ is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
+}
+
+
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest;
+use Module::Build;
+use Module::Build::ConfigData;
+
+my $manpage_support = Module::Build::ConfigData->feature('manpage_support');
+my $HTML_support = Module::Build::ConfigData->feature('HTML_support');
+
+
+{
+ my ($have_c_compiler, $C_support_feature) = check_compiler();
+ if (! $C_support_feature) {
+ plan skip_all => 'C_support not enabled';
+ } elsif ( ! $have_c_compiler ) {
+ plan skip_all => 'C_support enabled, but no compiler found';
+ } elsif ( ! eval {require Archive::Tar} ) {
+ plan skip_all => "Archive::Tar not installed to read archives.";
+ } elsif ( ! eval {IO::Zlib->VERSION(1.01)} ) {
+ plan skip_all => "IO::Zlib 1.01 required to read compressed archives.";
+ } else {
+ plan tests => 12;
+ }
+}
+
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp, xs => 1 );
+$dist->add_file( 'hello', <<'---' );
+#!perl -w
+print "Hello, World!\n";
+__END__
+
+=pod
+
+=head1 NAME
+
+hello
+
+=head1 DESCRIPTION
+
+Says "Hello"
+
+=cut
+---
+$dist->change_file( 'Build.PL', <<"---" );
+
+my \$build = new Module::Build(
+ module_name => @{[$dist->name]},
+ license => 'perl',
+ scripts => [ 'hello' ],
+);
+
+\$build->create_build_script;
+---
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+use File::Spec::Functions qw(catdir);
+
+use Module::Build;
+my @installstyle = qw(lib perl5);
+my $mb = Module::Build->new_from_context(
+ verbose => 0,
+ quiet => 1,
+
+ installdirs => 'site',
+ config => {
+ manpage_reset(), html_reset(),
+ ( $manpage_support ?
+ ( installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
+ installsiteman3dir => catdir($tmp, 'site', 'man', 'man3') ) : () ),
+ ( $HTML_support ?
+ ( installsitehtml1dir => catdir($tmp, 'site', 'html'),
+ installsitehtml3dir => catdir($tmp, 'site', 'html') ) : () ),
+ },
+);
+
+
+
+$mb->dispatch('ppd', args => {codebase => '/path/to/codebase-xs'});
+
+(my $dist_filename = $dist->name) =~ s/::/-/g;
+my $ppd = slurp($dist_filename . '.ppd');
+
+my $perl_version = Module::Build::PPMMaker->_ppd_version($mb->perl_version);
+my $varchname = Module::Build::PPMMaker->_varchname($mb->config);
+
+# This test is quite a hack since with XML you don't really want to
+# do a strict string comparison, but absent an XML parser it's the
+# best we can do.
+is $ppd, <<"---";
+<SOFTPKG NAME="$dist_filename" VERSION="0,01,0,0">
+ <TITLE>@{[$dist->name]}</TITLE>
+ <ABSTRACT>Perl extension for blah blah blah</ABSTRACT>
+ <AUTHOR>A. U. Thor, a.u.thor\@a.galaxy.far.far.away</AUTHOR>
+ <IMPLEMENTATION>
+ <PERLCORE VERSION="$perl_version" />
+ <OS NAME="$^O" />
+ <ARCHITECTURE NAME="$varchname" />
+ <CODEBASE HREF="/path/to/codebase-xs" />
+ </IMPLEMENTATION>
+</SOFTPKG>
+---
+
+
+
+$mb->dispatch('ppmdist');
+is $@, '';
+
+my $tar = Archive::Tar->new;
+
+my $tarfile = $mb->ppm_name . '.tar.gz';
+$tar->read( $tarfile, 1 );
+
+my $files = { map { $_ => 1 } $tar->list_files };
+
+exists_ok($files, 'blib/arch/auto/Simple/Simple.' . $mb->config('dlext'));
+exists_ok($files, 'blib/lib/Simple.pm');
+exists_ok($files, 'blib/script/hello');
+
+SKIP: {
+ skip( "manpage_support not enabled.", 2 ) unless $manpage_support;
+
+ exists_ok($files, 'blib/man3/Simple.' . $mb->config('man3ext'));
+ exists_ok($files, 'blib/man1/hello.' . $mb->config('man1ext'));
+}
+
+SKIP: {
+ skip( "HTML_support not enabled.", 2 ) unless $HTML_support;
+
+ exists_ok($files, 'blib/html/site/lib/Simple.html');
+ exists_ok($files, 'blib/html/bin/hello.html');
+}
+
+$tar->clear;
+undef( $tar );
+
+$mb->dispatch('realclean');
+$dist->clean;
+
+
+SKIP: {
+ skip( "HTML_support not enabled.", 3 ) unless $HTML_support;
+
+ # Make sure html documents are generated for the ppm distro even when
+ # they would not be built during a normal build.
+ $mb = Module::Build->new_from_context(
+ verbose => 0,
+ quiet => 1,
+
+ installdirs => 'site',
+ config => {
+ html_reset(),
+ installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
+ installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
+ },
+ );
+
+ $mb->dispatch('ppmdist');
+ is $@, '';
+
+ $tar = Archive::Tar->new;
+ $tar->read( $tarfile, 1 );
+
+ $files = {map { $_ => 1 } $tar->list_files};
+
+ exists_ok($files, 'blib/html/site/lib/Simple.html');
+ exists_ok($files, 'blib/html/bin/hello.html');
+
+ $tar->clear;
+
+ $mb->dispatch('realclean');
+ $dist->clean;
+}
+
+
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
+
+
+########################################
+
+sub exists_ok {
+ my $files = shift;
+ my $file = shift;
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ ok exists( $files->{$file} ) && $files->{$file}, $file;
+}
+
+# A hash of all Config.pm settings related to installing
+# manpages with values set to an empty string.
+sub manpage_reset {
+ return (
+ installman1dir => '',
+ installman3dir => '',
+ installsiteman1dir => '',
+ installsiteman3dir => '',
+ installvendorman1dir => '',
+ installvendorman3dir => '',
+ );
+}
+
+# A hash of all Config.pm settings related to installing
+# html documents with values set to an empty string.
+sub html_reset {
+ return (
+ installhtmldir => '',
+ installhtml1dir => '',
+ installhtml3dir => '',
+ installsitehtml1dir => '',
+ installsitehtml3dir => '',
+ installvendorhtml1dir => '',
+ installvendorhtml3dir => '',
+ );
+}
+
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 28;
+use Module::Build;
+use Module::Build::ConfigData;
+
+my $have_yaml = Module::Build::ConfigData->feature('YAML_support');
+
+#########################
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->remove_file( 't/basic.t' );
+$dist->change_file( 'Build.PL', <<'---' );
+use Module::Build;
+
+my $build = new Module::Build(
+ module_name => 'Simple',
+ scripts => [ 'script' ],
+ license => 'perl',
+ requires => { 'File::Spec' => 0 },
+);
+$build->create_build_script;
+---
+$dist->add_file( 'script', <<'---' );
+#!perl -w
+print "Hello, World!\n";
+---
+$dist->add_file( 'test.pl', <<'---' );
+#!/usr/bin/perl
+
+use Test;
+plan tests => 2;
+
+ok 1;
+
+require Module::Build;
+skip $ENV{PERL_CORE} && "no blib in core",
+ $INC{'Module/Build.pm'}, qr/blib/, 'Module::Build should be loaded from blib';
+
+print "# Cwd: ", Module::Build->cwd, "\n";
+print "# \@INC: (@INC)\n";
+print "Done.\n"; # t/compat.t looks for this
+---
+$dist->add_file( 'lib/Simple/Script.PL', <<'---' );
+#!perl -w
+
+my $filename = shift;
+open FH, "> $filename" or die "Can't create $filename: $!";
+print FH "Contents: $filename\n";
+close FH;
+---
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+#########################
+
+use Module::Build;
+ok(1);
+
+SKIP: {
+ skip "no blib in core", 1 if $ENV{PERL_CORE};
+ like $INC{'Module/Build.pm'}, qr/\bblib\b/, "Make sure version from blib/ is loaded";
+}
+
+#########################
+
+my $mb = Module::Build->new_from_context;
+ok $mb;
+is $mb->license, 'perl';
+
+# Make sure cleanup files added before create_build_script() get respected
+$mb->add_to_cleanup('before_script');
+
+eval {$mb->create_build_script};
+is $@, '';
+ok -e $mb->build_script;
+
+is $mb->dist_dir, 'Simple-0.01';
+
+# The 'cleanup' file doesn't exist yet
+ok grep {$_ eq 'before_script'} $mb->cleanup;
+
+$mb->add_to_cleanup('save_out');
+
+# The 'cleanup' file now exists
+ok grep {$_ eq 'before_script'} $mb->cleanup;
+ok grep {$_ eq 'save_out' } $mb->cleanup;
+
+{
+ # Make sure verbose=>1 works
+ my $all_ok = 1;
+ my $output = eval {
+ stdout_of( sub { $mb->dispatch('test', verbose => 1) } )
+ };
+ $all_ok &&= is($@, '');
+ $all_ok &&= like($output, qr/all tests successful/i);
+
+ # This is the output of lib/Simple/Script.PL
+ $all_ok &&= ok(-e $mb->localize_file_path('lib/Simple/Script'));
+
+ unless ($all_ok) {
+ # We use diag() so Test::Harness doesn't get confused.
+ diag("vvvvvvvvvvvvvvvvvvvvv Simple/test.pl output vvvvvvvvvvvvvvvvvvvvv");
+ diag($output);
+ diag("^^^^^^^^^^^^^^^^^^^^^ Simple/test.pl output ^^^^^^^^^^^^^^^^^^^^^");
+ }
+}
+
+SKIP: {
+ skip( 'YAML_support feature is not enabled', 7 ) unless $have_yaml;
+
+ my $output = eval {
+ stdout_of( sub { $mb->dispatch('disttest') } )
+ };
+ is $@, '';
+
+ # After a test, the distdir should contain a blib/ directory
+ ok -e File::Spec->catdir('Simple-0.01', 'blib');
+
+ eval {$mb->dispatch('distdir')};
+ is $@, '';
+
+ # The 'distdir' should contain a lib/ directory
+ ok -e File::Spec->catdir('Simple-0.01', 'lib');
+
+ # The freshly run 'distdir' should never contain a blib/ directory, or
+ # else it could get into the tarball
+ ok ! -e File::Spec->catdir('Simple-0.01', 'blib');
+
+ # Make sure all of the above was done by the new version of Module::Build
+ my $fh = IO::File->new(File::Spec->catfile($dist->dirname, 'META.yml'));
+ my $contents = do {local $/; <$fh>};
+ $contents =~ /Module::Build version ([0-9_.]+)/m;
+ cmp_ok $1, '==', $mb->VERSION, "Check version used to create META.yml: $1 == " . $mb->VERSION;
+
+ SKIP: {
+ skip( "not sure if we can create a tarball on this platform", 1 )
+ unless $mb->check_installed_status('Archive::Tar', 0) ||
+ $mb->isa('Module::Build::Platform::Unix');
+
+ $mb->add_to_cleanup($mb->dist_dir . ".tar.gz");
+ eval {$mb->dispatch('dist')};
+ is $@, '';
+ }
+
+}
+
+{
+ # Make sure the 'script' file was recognized as a script.
+ my $scripts = $mb->script_files;
+ ok $scripts->{script};
+
+ # Check that a shebang line is rewritten
+ my $blib_script = File::Spec->catdir( qw( blib script script ) );
+ ok -e $blib_script;
+
+ my $fh = IO::File->new($blib_script);
+ my $first_line = <$fh>;
+ isnt $first_line, "#!perl -w\n", "should rewrite the shebang line";
+}
+
+{
+ # Check PPD
+ $mb->dispatch('ppd', args => {codebase => '/path/to/codebase'});
+
+ my $ppd = slurp('Simple.ppd');
+
+ # This test is quite a hack since with XML you don't really want to
+ # do a strict string comparison, but absent an XML parser it's the
+ # best we can do.
+ is $ppd, <<'EOF';
+<SOFTPKG NAME="Simple" VERSION="0,01,0,0">
+ <TITLE>Simple</TITLE>
+ <ABSTRACT>Perl extension for blah blah blah</ABSTRACT>
+ <AUTHOR>A. U. Thor, a.u.thor@a.galaxy.far.far.away</AUTHOR>
+ <IMPLEMENTATION>
+ <DEPENDENCY NAME="File-Spec" VERSION="0,0,0,0" />
+ <CODEBASE HREF="/path/to/codebase" />
+ </IMPLEMENTATION>
+</SOFTPKG>
+EOF
+}
+
+
+eval {$mb->dispatch('realclean')};
+is $@, '';
+
+ok ! -e $mb->build_script;
+ok ! -e $mb->config_dir;
+ok ! -e $mb->dist_dir;
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest;
+
+if ( $ENV{TEST_SIGNATURE} ) {
+ if ( have_module( 'Module::Signature' ) ) {
+ plan tests => 7;
+ } else {
+ plan skip_all => '$ENV{TEST_SIGNATURE} is set, but Module::Signature not found';
+ }
+} else {
+ plan skip_all => '$ENV{TEST_SIGNATURE} is not set';
+}
+
+#########################
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->change_file( 'Build.PL', <<"---" );
+use Module::Build;
+
+my \$build = new Module::Build(
+ module_name => @{[$dist->name]},
+ license => 'perl',
+ sign => 1,
+);
+\$build->create_build_script;
+---
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+#########################
+
+use Module::Build;
+
+my $mb = Module::Build->new_from_context;
+
+
+{
+ eval {$mb->dispatch('distdir')};
+ is $@, '';
+ chdir( $mb->dist_dir ) or die "Can't chdir to '@{[$mb->dist_dir]}': $!";
+ ok -e 'SIGNATURE';
+
+ # Make sure the signature actually verifies
+ ok Module::Signature::verify() == Module::Signature::SIGNATURE_OK();
+ chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+}
+
+{
+ # Fake out Module::Signature and Module::Build - the first one to
+ # run should be distmeta.
+ my @run_order;
+ {
+ local $^W; # Skip 'redefined' warnings
+ local *Module::Signature::sign = sub { push @run_order, 'sign' };
+ local *Module::Build::Base::ACTION_distmeta = sub { push @run_order, 'distmeta' };
+ eval { $mb->dispatch('distdir') };
+ }
+ is $@, '';
+ is $run_order[0], 'distmeta';
+ is $run_order[1], 'sign';
+}
+
+eval { $mb->dispatch('realclean') };
+is $@, '';
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+# Test ~ expansion from command line arguments.
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 11;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+use Module::Build;
+
+sub run_sample {
+ my @args = @_;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ $dist->clean;
+
+ my $mb;
+ stdout_of( sub {
+ $mb = Module::Build->new_from_context( @args );
+ } );
+
+ return $mb;
+}
+
+
+{
+ local $ENV{HOME} = 'home';
+
+ my $mb;
+
+ $mb = run_sample( install_base => '~' );
+ is( $mb->install_base, $ENV{HOME} );
+
+ $mb = run_sample( install_base => '~/foo' );
+ is( $mb->install_base, "$ENV{HOME}/foo" );
+
+ $mb = run_sample( install_base => '~~' );
+ is( $mb->install_base, '~~' );
+
+ $mb = run_sample( install_base => 'foo~' );
+ is( $mb->install_base, 'foo~' );
+
+ $mb = run_sample( prefix => '~' );
+ is( $mb->prefix, $ENV{HOME} );
+
+ $mb = run_sample( install_path => { html => '~/html',
+ lib => '~/lib' }
+ );
+ is( $mb->install_destination('lib'), "$ENV{HOME}/lib" );
+ # 'html' is translated to 'binhtml' & 'libhtml'
+ is( $mb->install_destination('binhtml'), "$ENV{HOME}/html" );
+ is( $mb->install_destination('libhtml'), "$ENV{HOME}/html" );
+
+ $mb = run_sample( install_path => { lib => '~/lib' } );
+ is( $mb->install_destination('lib'), "$ENV{HOME}/lib" );
+
+ $mb = run_sample( destdir => '~' );
+ is( $mb->destdir, $ENV{HOME} );
+
+ $mb->install_base('~');
+ is( $mb->install_base, '~', 'API does not expand tildes' );
+}
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest tests => 2;
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp );
+$dist->regen;
+
+#########################
+
+use Module::Build;
+
+my @mod = split( /::/, $dist->name );
+my $file = File::Spec->catfile( $dist->dirname, 'lib', @mod ) . '.pm';
+is( Module::Build->version_from_file( $file ), '0.01', 'version_from_file' );
+
+ok( Module::Build->compare_versions( '1.01_01', '>', '1.01' ), 'compare: 1.0_01 > 1.0' );
+
+
+# cleanup
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
+use MBTest;
+use Module::Build;
+
+{
+ my ($have_c_compiler, $C_support_feature) = check_compiler();
+
+ if (! $C_support_feature) {
+ plan skip_all => 'C_support not enabled';
+ } elsif ( !$have_c_compiler ) {
+ plan skip_all => 'C_support enabled, but no compiler found';
+ } else {
+ plan tests => 22;
+ }
+}
+
+#########################
+
+
+use Cwd ();
+my $cwd = Cwd::cwd;
+my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
+
+use DistGen;
+my $dist = DistGen->new( dir => $tmp, xs => 1 );
+$dist->regen;
+
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+my $mb = Module::Build->new_from_context;
+
+
+eval {$mb->dispatch('clean')};
+is $@, '';
+
+eval {$mb->dispatch('build')};
+is $@, '';
+
+{
+ # Make sure it actually works: that we can call methods in the XS module
+
+ # Unfortunately, We must do this is a subprocess because some OS will not
+ # release the handle on a dynamic lib until the attaching process terminates
+
+ ok $mb->run_perl_command(['-Mblib', '-M'.$dist->name, '-e1']);
+
+ like stdout_of( sub {$mb->run_perl_command([
+ '-Mblib', '-M'.$dist->name,
+ '-we', "print @{[$dist->name]}::okay()"])}), qr/ok$/;
+
+ like stdout_of( sub {$mb->run_perl_command([
+ '-Mblib', '-M'.$dist->name,
+ '-we', "print @{[$dist->name]}::version()"])}), qr/0.01$/;
+
+ like stdout_of( sub {$mb->run_perl_command([
+ '-Mblib', '-M'.$dist->name,
+ '-we', "print @{[$dist->name]}::xs_version()"])}), qr/0.01$/;
+
+}
+
+{
+ # Try again in a subprocess
+ eval {$mb->dispatch('clean')};
+ is $@, '';
+
+ $mb->create_build_script;
+ ok -e 'Build';
+
+ eval {$mb->run_perl_script('Build')};
+ is $@, '';
+}
+
+# We can't be verbose in the sub-test, because Test::Harness will
+# think that the output is for the top-level test.
+eval {$mb->dispatch('test')};
+is $@, '';
+
+eval {$mb->dispatch('clean')};
+is $@, '';
+
+
+SKIP: {
+ skip( "skipping a Unixish-only tests", 1 )
+ unless $mb->os_type eq 'Unix';
+
+ local $mb->{config}{ld} = "FOO=BAR $mb->{config}{ld}";
+ eval {$mb->dispatch('build')};
+ is $@, '';
+}
+
+eval {$mb->dispatch('realclean')};
+is $@, '';
+
+# Make sure blib/ is gone after 'realclean'
+ok ! -e 'blib';
+
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+
+########################################
+
+# Try a XS distro with a deep namespace
+
+$dist = DistGen->new( name => 'Simple::With::Deep::Namespace',
+ dir => $tmp, xs => 1 );
+$dist->regen;
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+$mb = Module::Build->new_from_context;
+is $@, '';
+
+$mb->dispatch('build');
+is $@, '';
+
+$mb->dispatch('test');
+is $@, '';
+
+$mb->dispatch('realclean');
+is $@, '';
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+
+########################################
+
+# Try a XS distro using a flat directory structure
+# and a 'dist_name' instead of a 'module_name'
+
+$dist = DistGen->new( name => 'Dist-Name', dir => $tmp, xs => 1 );
+
+$dist->remove_file('lib/Dist-Name.pm');
+$dist->remove_file('lib/Dist-Name.xs');
+
+$dist->change_file('Build.PL', <<"---");
+use strict;
+use Module::Build;
+
+my \$builder = Module::Build->new(
+ dist_name => 'Dist-Name',
+ dist_version_from => 'Simple.pm',
+ pm_files => { 'Simple.pm' => 'lib/Simple.pm' },
+ xs_files => { 'Simple.xs' => 'lib/Simple.xs' },
+);
+
+\$builder->create_build_script();
+---
+$dist->add_file('Simple.xs', <<"---");
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+MODULE = Simple PACKAGE = Simple
+
+SV *
+okay()
+ CODE:
+ RETVAL = newSVpv( "ok", 0 );
+ OUTPUT:
+ RETVAL
+---
+
+$dist->add_file( 'Simple.pm', <<"---" );
+package Simple;
+
+\$VERSION = '0.01';
+
+require Exporter;
+require DynaLoader;
+
+\@ISA = qw( Exporter DynaLoader );
+\@EXPORT_OK = qw( okay );
+
+bootstrap Simple \$VERSION;
+
+1;
+
+__END__
+
+=head1 NAME
+
+Simple - Perl extension for blah blah blah
+
+=head1 DESCRIPTION
+
+Stub documentation for Simple.
+
+=head1 AUTHOR
+
+A. U. Thor, a.u.thor\@a.galaxy.far.far.away
+
+=cut
+---
+$dist->change_file('t/basic.t', <<"---");
+use Test::More tests => 2;
+use strict;
+
+use Simple;
+ok( 1 );
+
+ok( Simple::okay() eq 'ok' );
+---
+
+$dist->regen;
+chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+
+$mb = Module::Build->new_from_context;
+is $@, '';
+
+$mb->dispatch('build');
+is $@, '';
+
+$mb->dispatch('test');
+is $@, '';
+
+$mb->dispatch('realclean');
+is $@, '';
+
+# cleanup
+chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
+$dist->remove;
+
+use File::Path;
+rmtree( $tmp );
To display and change the libnet configuration run the libnetcfg command.
+=item L<config_data|config_data>
+
+Query or change configuration of Perl modules that use Module::Build-based
+configuration files for features and config data.
+
=back
=head2 Development
pod/podselect
utils/c2ph # link = utils/pstruct
utils/cpan
+utils/config_data
utils/corelist
utils/dprofpp
utils/enc2xs
# Files to be built with variable substitution after miniperl is
# available. Dependencies handled manually below (for now).
-pl = c2ph.PL cpan.PL corelist.PL h2ph.PL h2xs.PL instmodsh.PL perlbug.PL perldoc.PL perlivp.PL pl2pm.PL prove.PL ptar.PL ptardiff.PL shasum.PL splain.PL perlcc.PL dprofpp.PL libnetcfg.PL piconv.PL enc2xs.PL xsubpp.PL
-plextract = c2ph cpan corelist h2ph h2xs instmodsh perlbug perldoc perlivp pl2pm prove ptar ptardiff shasum splain perlcc dprofpp libnetcfg piconv enc2xs xsubpp
-plextractexe = ./c2ph ./cpan ./corelist ./h2ph ./h2xs ./instmodsh ./perlbug ./perldoc ./perlivp ./pl2pm ./prove ./ptar ./ptardiff ./shasum ./splain ./perlcc ./dprofpp ./libnetcfg ./piconv ./enc2xs ./xsubpp
+pl = c2ph.PL config_data.PL corelist.PL cpan.PL h2ph.PL h2xs.PL instmodsh.PL perlbug.PL perldoc.PL perlivp.PL pl2pm.PL prove.PL ptar.PL ptardiff.PL shasum.PL splain.PL perlcc.PL dprofpp.PL libnetcfg.PL piconv.PL enc2xs.PL xsubpp.PL
+plextract = c2ph config_data corelist cpan h2ph h2xs instmodsh perlbug perldoc perlivp pl2pm prove ptar ptardiff shasum splain perlcc dprofpp libnetcfg piconv enc2xs xsubpp
+plextractexe = ./c2ph ./config_data ./corelist ./cpan ./h2ph ./h2xs ./instmodsh ./perlbug ./perldoc ./perlivp ./pl2pm ./prove ./ptar ./ptardiff ./shasum ./splain ./perlcc ./dprofpp ./libnetcfg ./piconv ./enc2xs ./xsubpp
all: $(plextract)
cpan: cpan.PL ../config.sh
+config_data: config_data.PL ../config.sh
+
corelist: corelist.PL ../config.sh
h2ph: h2ph.PL ../config.sh
--- /dev/null
+#!/usr/local/bin/perl
+
+use Config;
+use File::Basename qw(&basename &dirname);
+use Cwd;
+
+# List explicitly here the variables you want Configure to
+# generate. Metaconfig only looks for shell variables, so you
+# have to mention them as if they were shell variables, not
+# %Config entries. Thus you write
+# $startperl
+# to ensure Configure will look for $Config{startperl}.
+
+# This forces PL files to create target in same directory as PL file.
+# This is so that make depend always knows where to find PL derivatives.
+my $origdir = cwd;
+chdir dirname($0);
+my $file = basename($0, '.PL');
+$file .= '.com' if $^O eq 'VMS';
+
+open OUT,">$file" or die "Can't create $file: $!";
+
+print "Extracting $file (with variable substitutions)\n";
+
+# In this section, perl variables will be expanded during extraction.
+# You can use $Config{...} to use Configure variables.
+
+print OUT <<"!GROK!THIS!";
+$Config{startperl}
+ eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+!GROK!THIS!
+
+use File::Spec;
+
+my $script = File::Spec->catfile(
+ File::Spec->catdir(
+ File::Spec->updir, qw[lib Module Build scripts]
+ ), "config_data");
+
+if (open(IN, $script)) {
+ print OUT <IN>;
+ close IN;
+} else {
+ die "$0: cannot find '$script'\n";
+}
+
+close OUT or die "Can't close $file: $!";
+chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
+exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;
utils1 = [.lib.pods]perldoc.com [.lib.ExtUtils]Miniperl.pm [.utils]c2ph.com [.utils]h2ph.com
utils2 = [.utils]h2xs.com [.utils]libnetcfg.com [.lib]perlbug.com [.lib]perlcc.com [.utils]dprofpp.com
utils3 = [.utils]perlivp.com [.lib]splain.com [.utils]pl2pm.com [.utils]xsubpp.com [.utils]instmodsh.com
-utils4 = [.utils]enc2xs.com [.utils]piconv.com [.utils]cpan.com [.utils]prove.com [.utils]ptar.com [.utils]ptardiff.com [.utils]shasum.com [.utils]corelist.com
+utils4 = [.utils]enc2xs.com [.utils]piconv.com [.utils]cpan.com [.utils]prove.com [.utils]ptar.com [.utils]ptardiff.com [.utils]shasum.com
+utils5 = [.utils]corelist.com [.utils]config_data.com
.ifdef NOX2P
all : base extras archcorefiles preplibrary perlpods
@ $(NOOP)
libmods : $(LIBPREREQ)
@ $(NOOP)
-utils : $(utils1) $(utils2) $(utils3) $(utils4)
+utils : $(utils1) $(utils2) $(utils3) $(utils4) $(utils5)
@ $(NOOP)
podxform : [.lib.pods]pod2text.com [.lib.pods]pod2html.com [.lib.pods]pod2latex.com [.lib.pods]pod2man.com [.lib.pods]podchecker.com [.lib.pods]pod2usage.com [.lib.pods]podselect.com
@ $(NOOP)
[.utils]shasum.com : [.utils]shasum.PL $(ARCHDIR)Config.pm
$(MINIPERL) -"I[-.lib]" $(MMS$SOURCE)
+[.utils]config_data.com : [.utils]config_data.PL $(ARCHDIR)Config.pm
+ $(MINIPERL) -"I[-.lib]" $(MMS$SOURCE)
+
[.utils]corelist.com : [.utils]corelist.PL $(ARCHDIR)Config.pm
$(MINIPERL) -"I[-.lib]" $(MMS$SOURCE)
..\utils\libnetcfg \
..\utils\enc2xs \
..\utils\piconv \
+ ..\utils\config_data \
..\utils\corelist \
..\utils\cpan \
..\utils\xsubpp \
podchecker podselect
-cd ..\utils && del /f h2ph splain perlbug pl2pm c2ph pstruct h2xs \
perldoc perlivp dprofpp perlcc libnetcfg enc2xs piconv cpan *.bat \
- xsubpp instmodsh prove ptar ptardiff shasum corelist
+ xsubpp instmodsh prove ptar ptardiff shasum corelist config_data
-cd ..\x2p && del /f find2perl s2p psed *.bat
-del /f ..\config.sh ..\splittree.pl perlmain.c dlutils.c config.h.new
-del /f $(CONFIGPM)
..\utils\libnetcfg \
..\utils\enc2xs \
..\utils\piconv \
+ ..\utils\config_data \
..\utils\corelist \
..\utils\cpan \
..\utils\xsubpp \
podchecker podselect
-cd ..\utils && del /f h2ph splain perlbug pl2pm c2ph pstruct h2xs \
perldoc perlivp dprofpp perlcc libnetcfg enc2xs piconv cpan *.bat \
- xsubpp instmodsh prove ptar ptardiff shasum corelist
+ xsubpp instmodsh prove ptar ptardiff shasum corelist config_data
-cd ..\x2p && del /f find2perl s2p psed *.bat
-del /f ..\config.sh ..\splittree.pl perlmain.c dlutils.c config.h.new
-del /f $(CONFIGPM)