3 use if $] >= 5.019, 'deprecate';
5 # This module doesn't do much of anything itself, it inherits from the
6 # modules that do the real work. The only real thing it has to do is
7 # figure out which OS-specific module to pull in. Many of the
8 # OS-specific modules don't do anything either - most of the work is
9 # done in Module::Build::Base.
14 use File::Basename ();
17 use Module::Build::Base;
19 use vars qw($VERSION @ISA);
20 @ISA = qw(Module::Build::Base);
22 $VERSION = eval $VERSION;
24 # Inserts the given module into the @ISA hierarchy between
25 # Module::Build and its immediate parent
26 sub _interpose_module {
27 my ($self, $mod) = @_;
33 while (@{"${top_class}::ISA"}) {
34 last if ${"${top_class}::ISA"}[0] eq $ISA[0];
35 $top_class = ${"${top_class}::ISA"}[0];
38 @{"${top_class}::ISA"} = @ISA;
42 if (grep {-e File::Spec->catfile($_, qw(Module Build Platform), $^O) . '.pm'} @INC) {
43 __PACKAGE__->_interpose_module("Module::Build::Platform::$^O");
45 } elsif ( my $ostype = os_type() ) {
46 __PACKAGE__->_interpose_module("Module::Build::Platform::$ostype");
49 warn "Unknown OS type '$^O' - using default settings\n";
52 sub os_type { return Perl::OSType::os_type() }
54 sub is_vmsish { return Perl::OSType::is_os_type('VMS') }
55 sub is_windowsish { return Perl::OSType::is_os_type('Windows') }
56 sub is_unixish { return Perl::OSType::is_os_type('Unix') }
63 bindoc binhtml destdir distcheck distclean distdir distmeta distsign disttest
64 fakeinstall html installdirs installsitebin installsitescript installvendorbin
65 installvendorscript libdoc libhtml pardist ppd ppmdist realclean skipcheck
66 testall testcover testdb testpod testpodcoverage versioninstall
70 Module::Build - Build and install Perl modules
74 Standard process for building & installing modules:
81 Or, if you're on a platform (like DOS or Windows) that doesn't require
82 the "./" notation, you can do this:
92 C<Module::Build> is a system for building, testing, and installing
93 Perl modules. It is meant to be an alternative to
94 C<ExtUtils::MakeMaker>. Developers may alter the behavior of the
95 module through subclassing in a much more straightforward way than
96 with C<MakeMaker>. It also does not require a C<make> on your system
97 - most of the C<Module::Build> code is pure-perl and written in a very
100 See L<"MOTIVATIONS"> for more comparisons between C<ExtUtils::MakeMaker>
101 and C<Module::Build>.
103 To install C<Module::Build>, and any other module that uses
104 C<Module::Build> for its installation process, do the following:
106 perl Build.PL # 'Build.PL' script creates the 'Build' script
107 ./Build # Need ./ to ensure we're using this "Build" script
108 ./Build test # and not another one that happens to be in the PATH
111 This illustrates initial configuration and the running of three
112 'actions'. In this case the actions run are 'build' (the default
113 action), 'test', and 'install'. Other actions defined so far include:
121 distcheck prereq_data
122 distclean prereq_report
124 distinstall realclean
129 fakeinstall testcover
132 install testpodcoverage
133 installdeps versioninstall
135 You can run the 'help' action for a complete list of actions.
138 =head1 GUIDE TO DOCUMENTATION
140 The documentation for C<Module::Build> is broken up into sections:
144 =item General Usage (L<Module::Build>)
146 This is the document you are currently reading. It describes basic
147 usage and background information. Its main purpose is to assist the
148 user who wants to learn how to invoke and control C<Module::Build>
149 scripts at the command line.
151 =item Authoring Reference (L<Module::Build::Authoring>)
153 This document describes the structure and organization of
154 C<Module::Build>, and the relevant concepts needed by authors who are
155 writing F<Build.PL> scripts for a distribution or controlling
156 C<Module::Build> processes programmatically.
158 =item API Reference (L<Module::Build::API>)
160 This is a reference to the C<Module::Build> API.
162 =item Cookbook (L<Module::Build::Cookbook>)
164 This document demonstrates how to accomplish many common tasks. It
165 covers general command line usage and authoring of F<Build.PL>
166 scripts. Includes working examples.
173 There are some general principles at work here. First, each task when
174 building a module is called an "action". These actions are listed
175 above; they correspond to the building, testing, installing,
176 packaging, etc., tasks.
178 Second, arguments are processed in a very systematic way. Arguments
179 are always key=value pairs. They may be specified at C<perl Build.PL>
180 time (i.e. C<perl Build.PL destdir=/my/secret/place>), in which case
181 their values last for the lifetime of the C<Build> script. They may
182 also be specified when executing a particular action (i.e.
183 C<Build test verbose=1>), in which case their values last only for the
184 lifetime of that command. Per-action command line parameters take
185 precedence over parameters specified at C<perl Build.PL> time.
187 The build process also relies heavily on the C<Config.pm> module.
188 If the user wishes to override any of the
189 values in C<Config.pm>, she may specify them like so:
191 perl Build.PL --config cc=gcc --config ld=gcc
193 The following build actions are provided by default.
201 If you run the C<Build> script without any arguments, it runs the
202 C<build> action, which in turn runs the C<code> and C<docs> actions.
204 This is analogous to the C<MakeMaker> I<make all> target.
210 This action will clean up any files that the build process may have
211 created, including the C<blib/> directory (but not including the
212 C<_build/> directory and the C<Build> script itself).
218 This action builds your code base.
220 By default it just creates a C<blib/> directory and copies any C<.pm>
221 and C<.pod> files from your C<lib/> directory into the C<blib/>
222 directory. It also compiles any C<.xs> files from C<lib/> and places
223 them in C<blib/>. Of course, you need a working C compiler (probably
224 the same one that built perl itself) for the compilation to work
227 The C<code> action also runs any C<.PL> files in your F<lib/>
228 directory. Typically these create other files, named the same but
229 without the C<.PL> ending. For example, a file F<lib/Foo/Bar.pm.PL>
230 could create the file F<lib/Foo/Bar.pm>. The C<.PL> files are
231 processed first, so any C<.pm> files (or other kinds that we deal
232 with) will get copied correctly.
244 This action will compare the files about to be installed with their
245 installed counterparts. For .pm and .pod files, a diff will be shown
246 (this currently requires a 'diff' program to be in your PATH). For
247 other files like compiled binary files, we simply report whether they
250 A C<flags> parameter may be passed to the action, which will be passed
251 to the 'diff' program. Consult your 'diff' documentation for the
252 parameters it will accept - a good one is C<-u>:
254 ./Build diff flags=-u
260 This action is helpful for module authors who want to package up their
261 module for source distribution through a medium like CPAN. It will create a
262 tarball of the files listed in F<MANIFEST> and compress the tarball using
265 By default, this action will use the C<Archive::Tar> module. However, you can
266 force it to use binary "tar" and "gzip" executables by supplying an explicit
267 C<tar> (and optional C<gzip>) parameter:
269 ./Build dist --tar C:\path\to\tar.exe --gzip C:\path\to\zip.exe
275 Reports which files are in the build directory but not in the
276 F<MANIFEST> file, and vice versa. (See L<manifest> for details.)
282 Performs the 'realclean' action and then the 'distcheck' action.
288 Creates a "distribution directory" named C<$dist_name-$dist_version>
289 (if that directory already exists, it will be removed first), then
290 copies all the files listed in the F<MANIFEST> file to that directory.
291 This directory is what the distribution tarball is created from.
297 Performs the 'distdir' action, then switches into that directory and runs a
298 C<perl Build.PL>, followed by the 'build' and 'install' actions in that
299 directory. Use PERL_MB_OPT or F<.modulebuildrc> to set options that should be
300 applied during subprocesses
306 Creates the F<META.yml> file that describes the distribution.
308 F<META.yml> is a file containing various bits of I<metadata> about the
309 distribution. The metadata includes the distribution name, version,
310 abstract, prerequisites, license, and various other data about the
311 distribution. This file is created as F<META.yml> in a simplified YAML format.
313 F<META.yml> file must also be listed in F<MANIFEST> - if it's not, a
314 warning will be issued.
316 The current version of the F<META.yml> specification can be found
317 on CPAN as L<CPAN::Meta::Spec>.
323 Uses C<Module::Signature> to create a SIGNATURE file for your
324 distribution, and adds the SIGNATURE file to the distribution's
331 Performs the 'distdir' action, then switches into that directory and runs a
332 C<perl Build.PL>, followed by the 'build' and 'test' actions in that directory.
333 Use PERL_MB_OPT or F<.modulebuildrc> to set options that should be applied
341 This will generate documentation (e.g. Unix man pages and HTML
342 documents) for any installable items under B<blib/> that
343 contain POD. If there are no C<bindoc> or C<libdoc> installation
344 targets defined (as will be the case on systems that don't support
345 Unix manpages) no action is taken for manpages. If there are no
346 C<binhtml> or C<libhtml> installation targets defined no action is
347 taken for HTML documents.
353 This is just like the C<install> action, but it won't actually do
354 anything, it will just report what it I<would> have done if you had
355 actually run the C<install> action.
361 This action will simply print out a message that is meant to help you
362 use the build process. It will show you a list of available build
365 With an optional argument specifying an action name (e.g. C<Build help
366 test>), the 'help' action will show you any POD documentation it can
367 find for that action.
373 This will generate HTML documentation for any binary or library files
374 under B<blib/> that contain POD. The HTML documentation will only be
375 installed if the install paths can be determined from values in
376 C<Config.pm>. You can also supply or override install paths on the
377 command line by specifying C<install_path> values for the C<binhtml>
378 and/or C<libhtml> installation targets.
380 With an optional C<html_links> argument set to a false value, you can
381 skip the search for other documentation to link to, because that can
382 waste a lot of time if there aren't any links to generate anyway:
384 ./Build html --html_links 0
390 This action will use C<ExtUtils::Install> to install the files from
391 C<blib/> into the system. See L<"INSTALL PATHS">
392 for details about how Module::Build determines where to install
393 things, and how to influence this process.
395 If you want the installation process to look around in C<@INC> for
396 other versions of the stuff you're installing and try to delete it,
397 you can use the C<uninst> parameter, which tells C<ExtUtils::Install> to
400 ./Build install uninst=1
402 This can be a good idea, as it helps prevent multiple versions of a
403 module from being present on your system, which can be a confusing
410 This action will use the C<cpan_client> parameter as a command to install
411 missing prerequisites. You will be prompted whether to install
412 optional dependencies.
414 The C<cpan_client> option defaults to 'cpan' but can be set as an option or in
415 F<.modulebuildrc>. It must be a shell command that takes a list of modules to
416 install as arguments (e.g. 'cpanp -i' for CPANPLUS). If the program part is a
417 relative path (e.g. 'cpan' or 'cpanp'), it will be located relative to the perl
418 program that executed Build.PL.
420 /opt/perl/5.8.9/bin/perl Build.PL
421 ./Build installdeps --cpan_client 'cpanp -i'
428 This is an action intended for use by module authors, not people
429 installing modules. It will bring the F<MANIFEST> up to date with the
430 files currently present in the distribution. You may use a
431 F<MANIFEST.SKIP> file to exclude certain files or directories from
432 inclusion in the F<MANIFEST>. F<MANIFEST.SKIP> should contain a bunch
433 of regular expressions, one per line. If a file in the distribution
434 directory matches any of the regular expressions, it won't be included
437 The following is a reasonable F<MANIFEST.SKIP> starting point, you can
438 add your own stuff to it:
448 See the L<distcheck> and L<skipcheck> actions if you want to find out
449 what the C<manifest> action would do, without actually doing anything.
455 This is an action intended for use by module authors, not people
456 installing modules. It will generate a boilerplate MANIFEST.SKIP file
457 if one does not already exist.
463 This will generate man pages for any binary or library files under
464 B<blib/> that contain POD. The man pages will only be installed if the
465 install paths can be determined from values in C<Config.pm>. You can
466 also supply or override install paths by specifying there values on
467 the command line with the C<bindoc> and C<libdoc> installation
474 Generates a PAR binary distribution for use with L<PAR> or L<PAR::Dist>.
476 It requires that the PAR::Dist module (version 0.17 and up) is
477 installed on your system.
483 Build a PPD file for your distribution.
485 This action takes an optional argument C<codebase> which is used in
486 the generated PPD file to specify the (usually relative) URL of the
487 distribution. By default, this value is the distribution name without
488 any path information.
492 ./Build ppd --codebase "MSWin32-x86-multi-thread/Module-Build-0.21.tar.gz"
498 Generates a PPM binary distribution and a PPD description file. This
499 action also invokes the C<ppd> action, so it can accept the same
500 C<codebase> argument described under that action.
502 This uses the same mechanism as the C<dist> action to tar & zip its
503 output, so you can supply C<tar> and/or C<gzip> parameters to affect
510 This action prints out a Perl data structure of all prerequisites and the versions
511 required. The output can be loaded again using C<eval()>. This can be useful for
512 external tools that wish to query a Build script for prerequisites.
518 This action prints out a list of all prerequisites, the versions required, and
519 the versions actually installed. This can be useful for reviewing the
520 configuration of your system prior to a build, or when compiling data to send
527 This action is identical to the C<install> action. In the future,
528 though, when C<install> starts writing to the file
529 F<$(INSTALLARCHLIB)/perllocal.pod>, C<pure_install> won't, and that
530 will be the only difference between them.
536 This action is just like the C<clean> action, but also removes the
537 C<_build> directory and the C<Build> script. If you run the
538 C<realclean> action, you are essentially starting over, so you will
539 have to re-create the C<Build> script again.
545 This is just like the C<test> action, but doesn't actually build the
546 distribution first, and doesn't add F<blib/> to the load path, and
547 therefore will test against a I<previously> installed version of the
548 distribution. This can be used to verify that a certain installed
549 distribution still works, or to see whether newer versions of a
550 distribution still pass the old regression tests, and so on.
556 Reports which files are skipped due to the entries in the
557 F<MANIFEST.SKIP> file (See L<manifest> for details)
563 This will use C<Test::Harness> or C<TAP::Harness> to run any regression
564 tests and report their results. Tests can be defined in the standard
565 places: a file called C<test.pl> in the top-level directory, or several
566 files ending with C<.t> in a C<t/> directory.
568 If you want tests to be 'verbose', i.e. show details of test execution
569 rather than just summary information, pass the argument C<verbose=1>.
571 If you want to run tests under the perl debugger, pass the argument
574 If you want to have Module::Build find test files with different file
575 name extensions, pass the C<test_file_exts> argument with an array
576 of extensions, such as C<[qw( .t .s .z )]>.
578 If you want test to be run by C<TAP::Harness>, rather than C<Test::Harness>,
579 pass the argument C<tap_harness_args> as an array reference of arguments to
580 pass to the TAP::Harness constructor.
582 In addition, if a file called C<visual.pl> exists in the top-level
583 directory, this file will be executed as a Perl script and its output
584 will be shown to the user. This is a good place to put speed tests or
585 other tests that don't use the C<Test::Harness> format for output.
587 To override the choice of tests to run, you may pass a C<test_files>
588 argument whose value is a whitespace-separated list of test scripts to
589 run. This is especially useful in development, when you only want to
590 run a single test to see whether you've squashed a certain bug yet:
592 ./Build test --test_files t/something_failing.t
594 You may also pass several C<test_files> arguments separately:
596 ./Build test --test_files t/one.t --test_files t/two.t
598 or use a C<glob()>-style pattern:
600 ./Build test --test_files 't/01-*.t'
606 [Note: the 'testall' action and the code snippets below are currently
608 L<"http://www.nntp.perl.org/group/perl.module.build/2007/03/msg584.html"> ]
610 Runs the C<test> action plus each of the C<test$type> actions defined by
611 the keys of the C<test_types> parameter.
613 Currently, you need to define the ACTION_test$type method yourself and
614 enumerate them in the test_types parameter.
616 my $mb = Module::Build->subclass(
618 sub ACTION_testspecial { shift->generic_test(type => 'special'); }
619 sub ACTION_testauthor { shift->generic_test(type => 'author'); }
625 author => ['.at', '.pt' ],
633 Runs the C<test> action using C<Devel::Cover>, generating a
634 code-coverage report showing which parts of the code were actually
635 exercised during the tests.
637 To pass options to C<Devel::Cover>, set the C<$DEVEL_COVER_OPTIONS>
638 environment variable:
640 DEVEL_COVER_OPTIONS=-ignore,Build ./Build testcover
646 This is a synonym for the 'test' action with the C<debugger=1>
653 This checks all the files described in the C<docs> action and
654 produces C<Test::Harness>-style output. If you are a module author,
655 this is useful to run before creating a new release.
657 =item testpodcoverage
661 This checks the pod coverage of the distribution and
662 produces C<Test::Harness>-style output. If you are a module author,
663 this is useful to run before creating a new release.
669 ** Note: since C<only.pm> is so new, and since we just recently added
670 support for it here too, this feature is to be considered
673 If you have the C<only.pm> module installed on your system, you can
674 use this action to install a module into the version-specific library
675 trees. This means that you can have several versions of the same
676 module installed and C<use> a specific one like this:
678 use only MyModule => 0.55;
680 To override the default installation libraries in C<only::config>,
681 specify the C<versionlib> parameter when you run the C<Build.PL> script:
683 perl Build.PL --versionlib /my/version/place/
685 To override which version the module is installed as, specify the
686 C<version> parameter when you run the C<Build.PL> script:
688 perl Build.PL --version 0.50
690 See the C<only.pm> documentation for more information on
691 version-specific installs.
698 =head2 Command Line Options
700 The following options can be used during any invocation of C<Build.PL>
701 or the Build script, during any action. For information on other
702 options specific to an action, see the documentation for the
705 NOTE: There is some preliminary support for options to use the more
706 familiar long option style. Most options can be preceded with the
707 C<--> long option prefix, and the underscores changed to dashes
708 (e.g. C<--use-rcfile>). Additionally, the argument to boolean options is
709 optional, and boolean options can be negated by prefixing them with
710 C<no> or C<no-> (e.g. C<--noverbose> or C<--no-verbose>).
716 Suppress informative messages on output.
720 Display extra information about the Build on output. C<verbose> will
725 Sets the C<cpan_client> command for use with the C<installdeps> action.
726 See C<installdeps> for more details.
730 Load the F<~/.modulebuildrc> option file. This option can be set to
731 false to prevent the custom resource file from being loaded.
733 =item allow_mb_mismatch
735 Suppresses the check upon startup that the version of Module::Build
736 we're now running under is the same version that was initially invoked
737 when building the distribution (i.e. when the C<Build.PL> script was
738 first run). As of 0.3601, a mismatch results in a warning instead of
739 a fatal error, so this option effectively just suppresses the warning.
743 Prints Module::Build debugging information to STDOUT, such as a trace of
744 executed build actions.
748 =head2 Default Options File (F<.modulebuildrc>)
752 When Module::Build starts up, it will look first for a file,
753 F<$ENV{HOME}/.modulebuildrc>. If it's not found there, it will look
754 in the F<.modulebuildrc> file in the directories referred to by
755 the environment variables C<HOMEDRIVE> + C<HOMEDIR>, C<USERPROFILE>,
756 C<APPDATA>, C<WINDIR>, C<SYS$LOGIN>. If the file exists, the options
757 specified there will be used as defaults, as if they were typed on the
758 command line. The defaults can be overridden by specifying new values
761 The action name must come at the beginning of the line, followed by any
762 amount of whitespace and then the options. Options are given the same
763 as they would be on the command line. They can be separated by any
764 amount of whitespace, including newlines, as long there is whitespace at
765 the beginning of each continued line. Anything following a hash mark (C<#>)
766 is considered a comment, and is stripped before parsing. If more than
767 one line begins with the same action name, those lines are merged into
770 Besides the regular actions, there are two special pseudo-actions: the
771 key C<*> (asterisk) denotes any global options that should be applied
772 to all actions, and the key 'Build_PL' specifies options to be applied
773 when you invoke C<perl Build.PL>.
775 * verbose=1 # global options
777 install --install_base /home/ken
778 --install_path html=/home/ken/docs/html
779 installdeps --cpan_client 'cpanp -i'
781 If you wish to locate your resource file in a different location, you
782 can set the environment variable C<MODULEBUILDRC> to the complete
783 absolute path of the file containing your options.
785 =head2 Environment variables
793 Specifies an alternate location for a default options file as described above.
799 Command line options that are applied to Build.PL or any Build action. The
800 string is split as the shell would (e.g. whitespace) and the result is
801 prepended to any actual command-line arguments.
809 When you invoke Module::Build's C<build> action, it needs to figure
810 out where to install things. The nutshell version of how this works
811 is that default installation locations are determined from
812 F<Config.pm>, and they may be overridden by using the C<install_path>
813 parameter. An C<install_base> parameter lets you specify an
814 alternative installation root like F</home/foo>, and a C<destdir> lets
815 you specify a temporary installation directory like F</tmp/install> in
816 case you want to create bundled-up installable packages.
818 Natively, Module::Build provides default installation locations for
819 the following types of installable items:
825 Usually pure-Perl module files ending in F<.pm>.
829 "Architecture-dependent" module files, usually produced by compiling
830 XS, L<Inline>, or similar code.
834 Programs written in pure Perl. In order to improve reuse, try to make
835 these as small as possible - put the code into modules whenever
840 "Architecture-dependent" executable programs, i.e. compiled C code or
841 something. Pretty rare to see this in a perl distribution, but it
846 Documentation for the stuff in C<script> and C<bin>. Usually
847 generated from the POD in those files. Under Unix, these are manual
848 pages belonging to the 'man1' category.
852 Documentation for the stuff in C<lib> and C<arch>. This is usually
853 generated from the POD in F<.pm> files. Under Unix, these are manual
854 pages belonging to the 'man3' category.
858 This is the same as C<bindoc> above, but applies to HTML documents.
862 This is the same as C<libdoc> above, but applies to HTML documents.
866 Four other parameters let you control various aspects of how
867 installation paths are determined:
873 The default destinations for these installable things come from
874 entries in your system's C<Config.pm>. You can select from three
875 different sets of default locations by setting the C<installdirs>
876 parameter as follows:
878 'installdirs' set to:
881 uses the following defaults from Config.pm:
883 lib => installprivlib installsitelib installvendorlib
884 arch => installarchlib installsitearch installvendorarch
885 script => installscript installsitescript installvendorscript
886 bin => installbin installsitebin installvendorbin
887 bindoc => installman1dir installsiteman1dir installvendorman1dir
888 libdoc => installman3dir installsiteman3dir installvendorman3dir
889 binhtml => installhtml1dir installsitehtml1dir installvendorhtml1dir [*]
890 libhtml => installhtml3dir installsitehtml3dir installvendorhtml3dir [*]
892 * Under some OS (eg. MSWin32) the destination for HTML documents is
893 determined by the C<Config.pm> entry C<installhtmldir>.
895 The default value of C<installdirs> is "site". If you're creating
896 vendor distributions of module packages, you may want to do something
899 perl Build.PL --installdirs vendor
903 ./Build install --installdirs vendor
905 If you're installing an updated version of a module that was included
906 with perl itself (i.e. a "core module"), then you may set
907 C<installdirs> to "core" to overwrite the module in its present
910 (Note that the 'script' line is different from C<MakeMaker> -
911 unfortunately there's no such thing as "installsitescript" or
912 "installvendorscript" entry in C<Config.pm>, so we use the
913 "installsitebin" and "installvendorbin" entries to at least get the
914 general location right. In the future, if C<Config.pm> adds some more
915 appropriate entries, we'll start using those.)
919 Once the defaults have been set, you can override them.
921 On the command line, that would look like this:
923 perl Build.PL --install_path lib=/foo/lib --install_path arch=/foo/lib/arch
927 ./Build install --install_path lib=/foo/lib --install_path arch=/foo/lib/arch
931 You can also set the whole bunch of installation paths by supplying the
932 C<install_base> parameter to point to a directory on your system. For
933 instance, if you set C<install_base> to "/home/ken" on a Linux
934 system, you'll install as follows:
936 lib => /home/ken/lib/perl5
937 arch => /home/ken/lib/perl5/i386-linux
938 script => /home/ken/bin
940 bindoc => /home/ken/man/man1
941 libdoc => /home/ken/man/man3
942 binhtml => /home/ken/html
943 libhtml => /home/ken/html
945 Note that this is I<different> from how C<MakeMaker>'s C<PREFIX>
946 parameter works. C<install_base> just gives you a default layout under the
947 directory you specify, which may have little to do with the
948 C<installdirs=site> layout.
950 The exact layout under the directory you specify may vary by system -
951 we try to do the "sensible" thing on each platform.
955 If you want to install everything into a temporary directory first
956 (for instance, if you want to create a directory tree that a package
957 manager like C<rpm> or C<dpkg> could create a package from), you can
958 use the C<destdir> parameter:
960 perl Build.PL --destdir /tmp/foo
964 ./Build install --destdir /tmp/foo
966 This will effectively install to "/tmp/foo/$sitelib",
967 "/tmp/foo/$sitearch", and the like, except that it will use
968 C<File::Spec> to make the pathnames work correctly on whatever
969 platform you're installing on.
973 Provided for compatibility with C<ExtUtils::MakeMaker>'s PREFIX argument.
974 C<prefix> should be used when you want Module::Build to install your
975 modules, documentation, and scripts in the same place as
976 C<ExtUtils::MakeMaker>'s PREFIX mechanism.
978 The following are equivalent.
980 perl Build.PL --prefix /tmp/foo
981 perl Makefile.PL PREFIX=/tmp/foo
983 Because of the complex nature of the prefixification logic, the
984 behavior of PREFIX in C<MakeMaker> has changed subtly over time.
985 Module::Build's --prefix logic is equivalent to the PREFIX logic found
986 in C<ExtUtils::MakeMaker> 6.30.
988 The maintainers of C<MakeMaker> do understand the troubles with the
989 PREFIX mechanism, and added INSTALL_BASE support in version 6.31 of
990 C<MakeMaker>, which was released in 2006.
992 If you don't need to retain compatibility with old versions (pre-6.31) of C<ExtUtils::MakeMaker> or
993 are starting a fresh Perl installation we recommend you use
994 C<install_base> instead (and C<INSTALL_BASE> in C<ExtUtils::MakeMaker>).
995 See L<Module::Build::Cookbook/Installing in the same location as
996 ExtUtils::MakeMaker> for further information.
1004 There are several reasons I wanted to start over, and not just fix
1005 what I didn't like about C<MakeMaker>:
1011 I don't like the core idea of C<MakeMaker>, namely that C<make> should be
1012 involved in the build process. Here are my reasons:
1018 When a person is installing a Perl module, what can you assume about
1019 their environment? Can you assume they have C<make>? No, but you can
1020 assume they have some version of Perl.
1024 When a person is writing a Perl module for intended distribution, can
1025 you assume that they know how to build a Makefile, so they can
1026 customize their build process? No, but you can assume they know Perl,
1027 and could customize that way.
1031 For years, these things have been a barrier to people getting the
1032 build/install process to do what they want.
1036 There are several architectural decisions in C<MakeMaker> that make it
1037 very difficult to customize its behavior. For instance, when using
1038 C<MakeMaker> you do C<use ExtUtils::MakeMaker>, but the object created in
1039 C<WriteMakefile()> is actually blessed into a package name that's
1040 created on the fly, so you can't simply subclass
1041 C<ExtUtils::MakeMaker>. There is a workaround C<MY> package that lets
1042 you override certain C<MakeMaker> methods, but only certain explicitly
1043 preselected (by C<MakeMaker>) methods can be overridden. Also, the method
1044 of customization is very crude: you have to modify a string containing
1045 the Makefile text for the particular target. Since these strings
1046 aren't documented, and I<can't> be documented (they take on different
1047 values depending on the platform, version of perl, version of
1048 C<MakeMaker>, etc.), you have no guarantee that your modifications will
1049 work on someone else's machine or after an upgrade of C<MakeMaker> or
1054 It is risky to make major changes to C<MakeMaker>, since it does so many
1055 things, is so important, and generally works. C<Module::Build> is an
1056 entirely separate package so that I can work on it all I want, without
1057 worrying about backward compatibility with C<MakeMaker>.
1061 Finally, Perl is said to be a language for system administration.
1062 Could it really be the case that Perl isn't up to the task of building
1063 and installing software? Even if that software is a bunch of
1064 C<.pm> files that just need to be copied from one place to
1065 another? My sense was that we could design a system to accomplish
1066 this in a flexible, extensible, and friendly manner. Or die trying.
1073 The current method of relying on time stamps to determine whether a
1074 derived file is out of date isn't likely to scale well, since it
1075 requires tracing all dependencies backward, it runs into problems on
1076 NFS, and it's just generally flimsy. It would be better to use an MD5
1077 signature or the like, if available. See C<cons> for an example.
1079 - append to perllocal.pod
1080 - add a 'plugin' functionality
1085 Ken Williams <kwilliams@cpan.org>
1087 Development questions, bug reports, and patches should be sent to the
1088 Module-Build mailing list at <module-build@perl.org>.
1090 Bug reports are also welcome at
1091 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Build>.
1093 The latest development version is available from the Git
1094 repository at <https://github.com/Perl-Toolchain-Gang/Module-Build>
1099 Copyright (c) 2001-2006 Ken Williams. All rights reserved.
1101 This library is free software; you can redistribute it and/or
1102 modify it under the same terms as Perl itself.
1107 perl(1), L<Module::Build::Cookbook>, L<Module::Build::Authoring>,
1108 L<Module::Build::API>, L<ExtUtils::MakeMaker>
1110 F<META.yml> Specification:
1113 L<http://www.dsmit.com/cons/>
1115 L<http://search.cpan.org/dist/PerlBuildSystem/>