This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Module-Build to 0.4002
[perl5.git] / cpan / Module-Build / lib / Module / Build.pm
1 package Module::Build;
2
3 # This module doesn't do much of anything itself, it inherits from the
4 # modules that do the real work.  The only real thing it has to do is
5 # figure out which OS-specific module to pull in.  Many of the
6 # OS-specific modules don't do anything either - most of the work is
7 # done in Module::Build::Base.
8
9 use strict;
10 use File::Spec ();
11 use File::Path ();
12 use File::Basename ();
13 use Perl::OSType ();
14
15 use Module::Build::Base;
16
17 use vars qw($VERSION @ISA);
18 @ISA = qw(Module::Build::Base);
19 $VERSION = '0.4002';
20 $VERSION = eval $VERSION;
21
22
23 # Inserts the given module into the @ISA hierarchy between
24 # Module::Build and its immediate parent
25 sub _interpose_module {
26   my ($self, $mod) = @_;
27   eval "use $mod";
28   die $@ if $@;
29
30   no strict 'refs';
31   my $top_class = $mod;
32   while (@{"${top_class}::ISA"}) {
33     last if ${"${top_class}::ISA"}[0] eq $ISA[0];
34     $top_class = ${"${top_class}::ISA"}[0];
35   }
36
37   @{"${top_class}::ISA"} = @ISA;
38   @ISA = ($mod);
39 }
40
41 if (grep {-e File::Spec->catfile($_, qw(Module Build Platform), $^O) . '.pm'} @INC) {
42   __PACKAGE__->_interpose_module("Module::Build::Platform::$^O");
43
44 } elsif ( my $ostype = os_type() ) {
45   __PACKAGE__->_interpose_module("Module::Build::Platform::$ostype");
46
47 } else {
48   warn "Unknown OS type '$^O' - using default settings\n";
49 }
50
51 sub os_type { return Perl::OSType::os_type() }
52
53 sub is_vmsish { return Perl::OSType::is_os_type('VMS') }
54 sub is_windowsish { return Perl::OSType::is_os_type('Windows') }
55 sub is_unixish { return Perl::OSType::is_os_type('Unix') }
56
57 1;
58
59 __END__
60
61 =for :stopwords
62 bindoc binhtml destdir distcheck distclean distdir distmeta distsign disttest
63 fakeinstall html installdirs installsitebin installsitescript installvendorbin
64 installvendorscript libdoc libhtml pardist ppd ppmdist realclean skipcheck
65 testall testcover testdb testpod testpodcoverage versioninstall
66
67 =head1 NAME
68
69 Module::Build - Build and install Perl modules
70
71 =head1 SYNOPSIS
72
73 Standard process for building & installing modules:
74
75   perl Build.PL
76   ./Build
77   ./Build test
78   ./Build install
79
80 Or, if you're on a platform (like DOS or Windows) that doesn't require
81 the "./" notation, you can do this:
82
83   perl Build.PL
84   Build
85   Build test
86   Build install
87
88
89 =head1 DESCRIPTION
90
91 C<Module::Build> is a system for building, testing, and installing
92 Perl modules.  It is meant to be an alternative to
93 C<ExtUtils::MakeMaker>.  Developers may alter the behavior of the
94 module through subclassing in a much more straightforward way than
95 with C<MakeMaker>.  It also does not require a C<make> on your system
96 - most of the C<Module::Build> code is pure-perl and written in a very
97 cross-platform way.  In fact, you don't even need a shell, so even
98 platforms like MacOS (traditional) can use it fairly easily.  Its only
99 prerequisites are modules that are included with perl 5.6.0, and it
100 works fine on perl 5.005 if you can install a few additional modules.
101
102 See L<"MOTIVATIONS"> for more comparisons between C<ExtUtils::MakeMaker>
103 and C<Module::Build>.
104
105 To install C<Module::Build>, and any other module that uses
106 C<Module::Build> for its installation process, do the following:
107
108   perl Build.PL       # 'Build.PL' script creates the 'Build' script
109   ./Build             # Need ./ to ensure we're using this "Build" script
110   ./Build test        # and not another one that happens to be in the PATH
111   ./Build install
112
113 This illustrates initial configuration and the running of three
114 'actions'.  In this case the actions run are 'build' (the default
115 action), 'test', and 'install'.  Other actions defined so far include:
116
117   build                          manifest
118   clean                          manifest_skip
119   code                           manpages
120   config_data                    pardist
121   diff                           ppd
122   dist                           ppmdist
123   distcheck                      prereq_data
124   distclean                      prereq_report
125   distdir                        pure_install
126   distinstall                    realclean
127   distmeta                       retest
128   distsign                       skipcheck
129   disttest                       test
130   docs                           testall
131   fakeinstall                    testcover
132   help                           testdb
133   html                           testpod
134   install                        testpodcoverage
135   installdeps                    versioninstall
136
137 You can run the 'help' action for a complete list of actions.
138
139
140 =head1 GUIDE TO DOCUMENTATION
141
142 The documentation for C<Module::Build> is broken up into sections:
143
144 =over
145
146 =item General Usage (L<Module::Build>)
147
148 This is the document you are currently reading. It describes basic
149 usage and background information.  Its main purpose is to assist the
150 user who wants to learn how to invoke and control C<Module::Build>
151 scripts at the command line.
152
153 =item Authoring Reference (L<Module::Build::Authoring>)
154
155 This document describes the structure and organization of
156 C<Module::Build>, and the relevant concepts needed by authors who are
157 writing F<Build.PL> scripts for a distribution or controlling
158 C<Module::Build> processes programmatically.
159
160 =item API Reference (L<Module::Build::API>)
161
162 This is a reference to the C<Module::Build> API.
163
164 =item Cookbook (L<Module::Build::Cookbook>)
165
166 This document demonstrates how to accomplish many common tasks.  It
167 covers general command line usage and authoring of F<Build.PL>
168 scripts.  Includes working examples.
169
170 =back
171
172
173 =head1 ACTIONS
174
175 There are some general principles at work here.  First, each task when
176 building a module is called an "action".  These actions are listed
177 above; they correspond to the building, testing, installing,
178 packaging, etc., tasks.
179
180 Second, arguments are processed in a very systematic way.  Arguments
181 are always key=value pairs.  They may be specified at C<perl Build.PL>
182 time (i.e. C<perl Build.PL destdir=/my/secret/place>), in which case
183 their values last for the lifetime of the C<Build> script.  They may
184 also be specified when executing a particular action (i.e.
185 C<Build test verbose=1>), in which case their values last only for the
186 lifetime of that command.  Per-action command line parameters take
187 precedence over parameters specified at C<perl Build.PL> time.
188
189 The build process also relies heavily on the C<Config.pm> module.
190 If the user wishes to override any of the
191 values in C<Config.pm>, she may specify them like so:
192
193   perl Build.PL --config cc=gcc --config ld=gcc
194
195 The following build actions are provided by default.
196
197 =over 4
198
199 =item build
200
201 [version 0.01]
202
203 If you run the C<Build> script without any arguments, it runs the
204 C<build> action, which in turn runs the C<code> and C<docs> actions.
205
206 This is analogous to the C<MakeMaker> I<make all> target.
207
208 =item clean
209
210 [version 0.01]
211
212 This action will clean up any files that the build process may have
213 created, including the C<blib/> directory (but not including the
214 C<_build/> directory and the C<Build> script itself).
215
216 =item code
217
218 [version 0.20]
219
220 This action builds your code base.
221
222 By default it just creates a C<blib/> directory and copies any C<.pm>
223 and C<.pod> files from your C<lib/> directory into the C<blib/>
224 directory.  It also compiles any C<.xs> files from C<lib/> and places
225 them in C<blib/>.  Of course, you need a working C compiler (probably
226 the same one that built perl itself) for the compilation to work
227 properly.
228
229 The C<code> action also runs any C<.PL> files in your F<lib/>
230 directory.  Typically these create other files, named the same but
231 without the C<.PL> ending.  For example, a file F<lib/Foo/Bar.pm.PL>
232 could create the file F<lib/Foo/Bar.pm>.  The C<.PL> files are
233 processed first, so any C<.pm> files (or other kinds that we deal
234 with) will get copied correctly.
235
236 =item config_data
237
238 [version 0.26]
239
240 ...
241
242 =item diff
243
244 [version 0.14]
245
246 This action will compare the files about to be installed with their
247 installed counterparts.  For .pm and .pod files, a diff will be shown
248 (this currently requires a 'diff' program to be in your PATH).  For
249 other files like compiled binary files, we simply report whether they
250 differ.
251
252 A C<flags> parameter may be passed to the action, which will be passed
253 to the 'diff' program.  Consult your 'diff' documentation for the
254 parameters it will accept - a good one is C<-u>:
255
256   ./Build diff flags=-u
257
258 =item dist
259
260 [version 0.02]
261
262 This action is helpful for module authors who want to package up their
263 module for source distribution through a medium like CPAN.  It will create a
264 tarball of the files listed in F<MANIFEST> and compress the tarball using
265 GZIP compression.
266
267 By default, this action will use the C<Archive::Tar> module. However, you can
268 force it to use binary "tar" and "gzip" executables by supplying an explicit
269 C<tar> (and optional C<gzip>) parameter:
270
271   ./Build dist --tar C:\path\to\tar.exe --gzip C:\path\to\zip.exe
272
273 =item distcheck
274
275 [version 0.05]
276
277 Reports which files are in the build directory but not in the
278 F<MANIFEST> file, and vice versa.  (See L<manifest> for details.)
279
280 =item distclean
281
282 [version 0.05]
283
284 Performs the 'realclean' action and then the 'distcheck' action.
285
286 =item distdir
287
288 [version 0.05]
289
290 Creates a "distribution directory" named C<$dist_name-$dist_version>
291 (if that directory already exists, it will be removed first), then
292 copies all the files listed in the F<MANIFEST> file to that directory.
293 This directory is what the distribution tarball is created from.
294
295 =item distinstall
296
297 [version 0.37]
298
299 Performs the 'distdir' action, then switches into that directory and runs a
300 C<perl Build.PL>, followed by the 'build' and 'install' actions in that
301 directory.  Use PERL_MB_OPT or F<.modulebuildrc> to set options that should be
302 applied during subprocesses
303
304 =item distmeta
305
306 [version 0.21]
307
308 Creates the F<META.yml> file that describes the distribution.
309
310 F<META.yml> is a file containing various bits of I<metadata> about the
311 distribution.  The metadata includes the distribution name, version,
312 abstract, prerequisites, license, and various other data about the
313 distribution.  This file is created as F<META.yml> in a simplified YAML format.
314
315 F<META.yml> file must also be listed in F<MANIFEST> - if it's not, a
316 warning will be issued.
317
318 The current version of the F<META.yml> specification can be found
319 on CPAN as L<CPAN::Meta::Spec>.
320
321 =item distsign
322
323 [version 0.16]
324
325 Uses C<Module::Signature> to create a SIGNATURE file for your
326 distribution, and adds the SIGNATURE file to the distribution's
327 MANIFEST.
328
329 =item disttest
330
331 [version 0.05]
332
333 Performs the 'distdir' action, then switches into that directory and runs a
334 C<perl Build.PL>, followed by the 'build' and 'test' actions in that directory.
335 Use PERL_MB_OPT or F<.modulebuildrc> to set options that should be applied
336 during subprocesses
337
338
339 =item docs
340
341 [version 0.20]
342
343 This will generate documentation (e.g. Unix man pages and HTML
344 documents) for any installable items under B<blib/> that
345 contain POD.  If there are no C<bindoc> or C<libdoc> installation
346 targets defined (as will be the case on systems that don't support
347 Unix manpages) no action is taken for manpages.  If there are no
348 C<binhtml> or C<libhtml> installation targets defined no action is
349 taken for HTML documents.
350
351 =item fakeinstall
352
353 [version 0.02]
354
355 This is just like the C<install> action, but it won't actually do
356 anything, it will just report what it I<would> have done if you had
357 actually run the C<install> action.
358
359 =item help
360
361 [version 0.03]
362
363 This action will simply print out a message that is meant to help you
364 use the build process.  It will show you a list of available build
365 actions too.
366
367 With an optional argument specifying an action name (e.g. C<Build help
368 test>), the 'help' action will show you any POD documentation it can
369 find for that action.
370
371 =item html
372
373 [version 0.26]
374
375 This will generate HTML documentation for any binary or library files
376 under B<blib/> that contain POD.  The HTML documentation will only be
377 installed if the install paths can be determined from values in
378 C<Config.pm>.  You can also supply or override install paths on the
379 command line by specifying C<install_path> values for the C<binhtml>
380 and/or C<libhtml> installation targets.
381
382 =item install
383
384 [version 0.01]
385
386 This action will use C<ExtUtils::Install> to install the files from
387 C<blib/> into the system.  See L<"INSTALL PATHS">
388 for details about how Module::Build determines where to install
389 things, and how to influence this process.
390
391 If you want the installation process to look around in C<@INC> for
392 other versions of the stuff you're installing and try to delete it,
393 you can use the C<uninst> parameter, which tells C<ExtUtils::Install> to
394 do so:
395
396   ./Build install uninst=1
397
398 This can be a good idea, as it helps prevent multiple versions of a
399 module from being present on your system, which can be a confusing
400 situation indeed.
401
402 =item installdeps
403
404 [version 0.36]
405
406 This action will use the C<cpan_client> parameter as a command to install
407 missing prerequisites.  You will be prompted whether to install
408 optional dependencies.
409
410 The C<cpan_client> option defaults to 'cpan' but can be set as an option or in
411 F<.modulebuildrc>.  It must be a shell command that takes a list of modules to
412 install as arguments (e.g. 'cpanp -i' for CPANPLUS).  If the program part is a
413 relative path (e.g. 'cpan' or 'cpanp'), it will be located relative to the perl
414 program that executed Build.PL.
415
416   /opt/perl/5.8.9/bin/perl Build.PL
417   ./Build installdeps --cpan_client 'cpanp -i'
418   # installs to 5.8.9
419
420 =item manifest
421
422 [version 0.05]
423
424 This is an action intended for use by module authors, not people
425 installing modules.  It will bring the F<MANIFEST> up to date with the
426 files currently present in the distribution.  You may use a
427 F<MANIFEST.SKIP> file to exclude certain files or directories from
428 inclusion in the F<MANIFEST>.  F<MANIFEST.SKIP> should contain a bunch
429 of regular expressions, one per line.  If a file in the distribution
430 directory matches any of the regular expressions, it won't be included
431 in the F<MANIFEST>.
432
433 The following is a reasonable F<MANIFEST.SKIP> starting point, you can
434 add your own stuff to it:
435
436   ^_build
437   ^Build$
438   ^blib
439   ~$
440   \.bak$
441   ^MANIFEST\.SKIP$
442   CVS
443
444 See the L<distcheck> and L<skipcheck> actions if you want to find out
445 what the C<manifest> action would do, without actually doing anything.
446
447 =item manifest_skip
448
449 [version 0.3608]
450
451 This is an action intended for use by module authors, not people
452 installing modules.  It will generate a boilerplate MANIFEST.SKIP file
453 if one does not already exist.
454
455 =item manpages
456
457 [version 0.28]
458
459 This will generate man pages for any binary or library files under
460 B<blib/> that contain POD.  The man pages will only be installed if the
461 install paths can be determined from values in C<Config.pm>.  You can
462 also supply or override install paths by specifying there values on
463 the command line with the C<bindoc> and C<libdoc> installation
464 targets.
465
466 =item pardist
467
468 [version 0.2806]
469
470 Generates a PAR binary distribution for use with L<PAR> or L<PAR::Dist>.
471
472 It requires that the PAR::Dist module (version 0.17 and up) is
473 installed on your system.
474
475 =item ppd
476
477 [version 0.20]
478
479 Build a PPD file for your distribution.
480
481 This action takes an optional argument C<codebase> which is used in
482 the generated PPD file to specify the (usually relative) URL of the
483 distribution.  By default, this value is the distribution name without
484 any path information.
485
486 Example:
487
488   ./Build ppd --codebase "MSWin32-x86-multi-thread/Module-Build-0.21.tar.gz"
489
490 =item ppmdist
491
492 [version 0.23]
493
494 Generates a PPM binary distribution and a PPD description file.  This
495 action also invokes the C<ppd> action, so it can accept the same
496 C<codebase> argument described under that action.
497
498 This uses the same mechanism as the C<dist> action to tar & zip its
499 output, so you can supply C<tar> and/or C<gzip> parameters to affect
500 the result.
501
502 =item prereq_data
503
504 [version 0.32]
505
506 This action prints out a Perl data structure of all prerequisites and the versions
507 required.  The output can be loaded again using C<eval()>.  This can be useful for
508 external tools that wish to query a Build script for prerequisites.
509
510 =item prereq_report
511
512 [version 0.28]
513
514 This action prints out a list of all prerequisites, the versions required, and
515 the versions actually installed.  This can be useful for reviewing the
516 configuration of your system prior to a build, or when compiling data to send
517 for a bug report.
518
519 =item pure_install
520
521 [version 0.28]
522
523 This action is identical to the C<install> action.  In the future,
524 though, when C<install> starts writing to the file
525 F<$(INSTALLARCHLIB)/perllocal.pod>, C<pure_install> won't, and that
526 will be the only difference between them.
527
528 =item realclean
529
530 [version 0.01]
531
532 This action is just like the C<clean> action, but also removes the
533 C<_build> directory and the C<Build> script.  If you run the
534 C<realclean> action, you are essentially starting over, so you will
535 have to re-create the C<Build> script again.
536
537 =item retest
538
539 [version 0.2806]
540
541 This is just like the C<test> action, but doesn't actually build the
542 distribution first, and doesn't add F<blib/> to the load path, and
543 therefore will test against a I<previously> installed version of the
544 distribution.  This can be used to verify that a certain installed
545 distribution still works, or to see whether newer versions of a
546 distribution still pass the old regression tests, and so on.
547
548 =item skipcheck
549
550 [version 0.05]
551
552 Reports which files are skipped due to the entries in the
553 F<MANIFEST.SKIP> file (See L<manifest> for details)
554
555 =item test
556
557 [version 0.01]
558
559 This will use C<Test::Harness> or C<TAP::Harness> to run any regression
560 tests and report their results. Tests can be defined in the standard
561 places: a file called C<test.pl> in the top-level directory, or several
562 files ending with C<.t> in a C<t/> directory.
563
564 If you want tests to be 'verbose', i.e. show details of test execution
565 rather than just summary information, pass the argument C<verbose=1>.
566
567 If you want to run tests under the perl debugger, pass the argument
568 C<debugger=1>.
569
570 If you want to have Module::Build find test files with different file
571 name extensions, pass the C<test_file_exts> argument with an array
572 of extensions, such as C<[qw( .t .s .z )]>.
573
574 If you want test to be run by C<TAP::Harness>, rather than C<Test::Harness>,
575 pass the argument C<tap_harness_args> as an array reference of arguments to
576 pass to the TAP::Harness constructor.
577
578 In addition, if a file called C<visual.pl> exists in the top-level
579 directory, this file will be executed as a Perl script and its output
580 will be shown to the user.  This is a good place to put speed tests or
581 other tests that don't use the C<Test::Harness> format for output.
582
583 To override the choice of tests to run, you may pass a C<test_files>
584 argument whose value is a whitespace-separated list of test scripts to
585 run.  This is especially useful in development, when you only want to
586 run a single test to see whether you've squashed a certain bug yet:
587
588   ./Build test --test_files t/something_failing.t
589
590 You may also pass several C<test_files> arguments separately:
591
592   ./Build test --test_files t/one.t --test_files t/two.t
593
594 or use a C<glob()>-style pattern:
595
596   ./Build test --test_files 't/01-*.t'
597
598 =item testall
599
600 [version 0.2807]
601
602 [Note: the 'testall' action and the code snippets below are currently
603 in alpha stage, see
604 L<"http://www.nntp.perl.org/group/perl.module.build/2007/03/msg584.html"> ]
605
606 Runs the C<test> action plus each of the C<test$type> actions defined by
607 the keys of the C<test_types> parameter.
608
609 Currently, you need to define the ACTION_test$type method yourself and
610 enumerate them in the test_types parameter.
611
612   my $mb = Module::Build->subclass(
613     code => q(
614       sub ACTION_testspecial { shift->generic_test(type => 'special'); }
615       sub ACTION_testauthor  { shift->generic_test(type => 'author'); }
616     )
617   )->new(
618     ...
619     test_types  => {
620       special => '.st',
621       author  => ['.at', '.pt' ],
622     },
623     ...
624
625 =item testcover
626
627 [version 0.26]
628
629 Runs the C<test> action using C<Devel::Cover>, generating a
630 code-coverage report showing which parts of the code were actually
631 exercised during the tests.
632
633 To pass options to C<Devel::Cover>, set the C<$DEVEL_COVER_OPTIONS>
634 environment variable:
635
636   DEVEL_COVER_OPTIONS=-ignore,Build ./Build testcover
637
638 =item testdb
639
640 [version 0.05]
641
642 This is a synonym for the 'test' action with the C<debugger=1>
643 argument.
644
645 =item testpod
646
647 [version 0.25]
648
649 This checks all the files described in the C<docs> action and
650 produces C<Test::Harness>-style output.  If you are a module author,
651 this is useful to run before creating a new release.
652
653 =item testpodcoverage
654
655 [version 0.28]
656
657 This checks the pod coverage of the distribution and
658 produces C<Test::Harness>-style output. If you are a module author,
659 this is useful to run before creating a new release.
660
661 =item versioninstall
662
663 [version 0.16]
664
665 ** Note: since C<only.pm> is so new, and since we just recently added
666 support for it here too, this feature is to be considered
667 experimental. **
668
669 If you have the C<only.pm> module installed on your system, you can
670 use this action to install a module into the version-specific library
671 trees.  This means that you can have several versions of the same
672 module installed and C<use> a specific one like this:
673
674   use only MyModule => 0.55;
675
676 To override the default installation libraries in C<only::config>,
677 specify the C<versionlib> parameter when you run the C<Build.PL> script:
678
679   perl Build.PL --versionlib /my/version/place/
680
681 To override which version the module is installed as, specify the
682 C<version> parameter when you run the C<Build.PL> script:
683
684   perl Build.PL --version 0.50
685
686 See the C<only.pm> documentation for more information on
687 version-specific installs.
688
689 =back
690
691
692 =head1 OPTIONS
693
694 =head2 Command Line Options
695
696 The following options can be used during any invocation of C<Build.PL>
697 or the Build script, during any action.  For information on other
698 options specific to an action, see the documentation for the
699 respective action.
700
701 NOTE: There is some preliminary support for options to use the more
702 familiar long option style.  Most options can be preceded with the
703 C<--> long option prefix, and the underscores changed to dashes
704 (e.g. C<--use-rcfile>).  Additionally, the argument to boolean options is
705 optional, and boolean options can be negated by prefixing them with
706 C<no> or C<no-> (e.g. C<--noverbose> or C<--no-verbose>).
707
708 =over 4
709
710 =item quiet
711
712 Suppress informative messages on output.
713
714 =item verbose
715
716 Display extra information about the Build on output.  C<verbose> will
717 turn off C<quiet>
718
719 =item cpan_client
720
721 Sets the C<cpan_client> command for use with the C<installdeps> action.
722 See C<installdeps> for more details.
723
724 =item use_rcfile
725
726 Load the F<~/.modulebuildrc> option file.  This option can be set to
727 false to prevent the custom resource file from being loaded.
728
729 =item allow_mb_mismatch
730
731 Suppresses the check upon startup that the version of Module::Build
732 we're now running under is the same version that was initially invoked
733 when building the distribution (i.e. when the C<Build.PL> script was
734 first run).  As of 0.3601, a mismatch results in a warning instead of
735 a fatal error, so this option effectively just suppresses the warning.
736
737 =item debug
738
739 Prints Module::Build debugging information to STDOUT, such as a trace of
740 executed build actions.
741
742 =back
743
744 =head2 Default Options File (F<.modulebuildrc>)
745
746 [version 0.28]
747
748 When Module::Build starts up, it will look first for a file,
749 F<$ENV{HOME}/.modulebuildrc>.  If it's not found there, it will look
750 in the the F<.modulebuildrc> file in the directories referred to by
751 the environment variables C<HOMEDRIVE> + C<HOMEDIR>, C<USERPROFILE>,
752 C<APPDATA>, C<WINDIR>, C<SYS$LOGIN>.  If the file exists, the options
753 specified there will be used as defaults, as if they were typed on the
754 command line.  The defaults can be overridden by specifying new values
755 on the command line.
756
757 The action name must come at the beginning of the line, followed by any
758 amount of whitespace and then the options.  Options are given the same
759 as they would be on the command line.  They can be separated by any
760 amount of whitespace, including newlines, as long there is whitespace at
761 the beginning of each continued line.  Anything following a hash mark (C<#>)
762 is considered a comment, and is stripped before parsing.  If more than
763 one line begins with the same action name, those lines are merged into
764 one set of options.
765
766 Besides the regular actions, there are two special pseudo-actions: the
767 key C<*> (asterisk) denotes any global options that should be applied
768 to all actions, and the key 'Build_PL' specifies options to be applied
769 when you invoke C<perl Build.PL>.
770
771   *           verbose=1   # global options
772   diff        flags=-u
773   install     --install_base /home/ken
774               --install_path html=/home/ken/docs/html
775   installdeps --cpan_client 'cpanp -i'
776
777 If you wish to locate your resource file in a different location, you
778 can set the environment variable C<MODULEBUILDRC> to the complete
779 absolute path of the file containing your options.
780
781 =head2 Environment variables
782
783 =over
784
785 =item MODULEBUILDRC
786
787 [version 0.28]
788
789 Specifies an alternate location for a default options file as described above.
790
791 =item PERL_MB_OPT
792
793 [version 0.36]
794
795 Command line options that are applied to Build.PL or any Build action.  The
796 string is split as the shell would (e.g. whitespace) and the result is
797 prepended to any actual command-line arguments.
798
799 =back
800
801 =head1 INSTALL PATHS
802
803 [version 0.19]
804
805 When you invoke Module::Build's C<build> action, it needs to figure
806 out where to install things.  The nutshell version of how this works
807 is that default installation locations are determined from
808 F<Config.pm>, and they may be overridden by using the C<install_path>
809 parameter.  An C<install_base> parameter lets you specify an
810 alternative installation root like F</home/foo>, and a C<destdir> lets
811 you specify a temporary installation directory like F</tmp/install> in
812 case you want to create bundled-up installable packages.
813
814 Natively, Module::Build provides default installation locations for
815 the following types of installable items:
816
817 =over 4
818
819 =item lib
820
821 Usually pure-Perl module files ending in F<.pm>.
822
823 =item arch
824
825 "Architecture-dependent" module files, usually produced by compiling
826 XS, L<Inline>, or similar code.
827
828 =item script
829
830 Programs written in pure Perl.  In order to improve reuse, try to make
831 these as small as possible - put the code into modules whenever
832 possible.
833
834 =item bin
835
836 "Architecture-dependent" executable programs, i.e. compiled C code or
837 something.  Pretty rare to see this in a perl distribution, but it
838 happens.
839
840 =item bindoc
841
842 Documentation for the stuff in C<script> and C<bin>.  Usually
843 generated from the POD in those files.  Under Unix, these are manual
844 pages belonging to the 'man1' category.
845
846 =item libdoc
847
848 Documentation for the stuff in C<lib> and C<arch>.  This is usually
849 generated from the POD in F<.pm> files.  Under Unix, these are manual
850 pages belonging to the 'man3' category.
851
852 =item binhtml
853
854 This is the same as C<bindoc> above, but applies to HTML documents.
855
856 =item libhtml
857
858 This is the same as C<libdoc> above, but applies to HTML documents.
859
860 =back
861
862 Four other parameters let you control various aspects of how
863 installation paths are determined:
864
865 =over 4
866
867 =item installdirs
868
869 The default destinations for these installable things come from
870 entries in your system's C<Config.pm>.  You can select from three
871 different sets of default locations by setting the C<installdirs>
872 parameter as follows:
873
874                           'installdirs' set to:
875                    core          site                vendor
876
877               uses the following defaults from Config.pm:
878
879   lib     => installprivlib  installsitelib      installvendorlib
880   arch    => installarchlib  installsitearch     installvendorarch
881   script  => installscript   installsitescript   installvendorscript
882   bin     => installbin      installsitebin      installvendorbin
883   bindoc  => installman1dir  installsiteman1dir  installvendorman1dir
884   libdoc  => installman3dir  installsiteman3dir  installvendorman3dir
885   binhtml => installhtml1dir installsitehtml1dir installvendorhtml1dir [*]
886   libhtml => installhtml3dir installsitehtml3dir installvendorhtml3dir [*]
887
888   * Under some OS (eg. MSWin32) the destination for HTML documents is
889     determined by the C<Config.pm> entry C<installhtmldir>.
890
891 The default value of C<installdirs> is "site".  If you're creating
892 vendor distributions of module packages, you may want to do something
893 like this:
894
895   perl Build.PL --installdirs vendor
896
897 or
898
899   ./Build install --installdirs vendor
900
901 If you're installing an updated version of a module that was included
902 with perl itself (i.e. a "core module"), then you may set
903 C<installdirs> to "core" to overwrite the module in its present
904 location.
905
906 (Note that the 'script' line is different from C<MakeMaker> -
907 unfortunately there's no such thing as "installsitescript" or
908 "installvendorscript" entry in C<Config.pm>, so we use the
909 "installsitebin" and "installvendorbin" entries to at least get the
910 general location right.  In the future, if C<Config.pm> adds some more
911 appropriate entries, we'll start using those.)
912
913 =item install_path
914
915 Once the defaults have been set, you can override them.
916
917 On the command line, that would look like this:
918
919   perl Build.PL --install_path lib=/foo/lib --install_path arch=/foo/lib/arch
920
921 or this:
922
923   ./Build install --install_path lib=/foo/lib --install_path arch=/foo/lib/arch
924
925 =item install_base
926
927 You can also set the whole bunch of installation paths by supplying the
928 C<install_base> parameter to point to a directory on your system.  For
929 instance, if you set C<install_base> to "/home/ken" on a Linux
930 system, you'll install as follows:
931
932   lib     => /home/ken/lib/perl5
933   arch    => /home/ken/lib/perl5/i386-linux
934   script  => /home/ken/bin
935   bin     => /home/ken/bin
936   bindoc  => /home/ken/man/man1
937   libdoc  => /home/ken/man/man3
938   binhtml => /home/ken/html
939   libhtml => /home/ken/html
940
941 Note that this is I<different> from how C<MakeMaker>'s C<PREFIX>
942 parameter works.  C<install_base> just gives you a default layout under the
943 directory you specify, which may have little to do with the
944 C<installdirs=site> layout.
945
946 The exact layout under the directory you specify may vary by system -
947 we try to do the "sensible" thing on each platform.
948
949 =item destdir
950
951 If you want to install everything into a temporary directory first
952 (for instance, if you want to create a directory tree that a package
953 manager like C<rpm> or C<dpkg> could create a package from), you can
954 use the C<destdir> parameter:
955
956   perl Build.PL --destdir /tmp/foo
957
958 or
959
960   ./Build install --destdir /tmp/foo
961
962 This will effectively install to "/tmp/foo/$sitelib",
963 "/tmp/foo/$sitearch", and the like, except that it will use
964 C<File::Spec> to make the pathnames work correctly on whatever
965 platform you're installing on.
966
967 =item prefix
968
969 Provided for compatibility with C<ExtUtils::MakeMaker>'s PREFIX argument.
970 C<prefix> should be used when you want Module::Build to install your
971 modules, documentation, and scripts in the same place as
972 C<ExtUtils::MakeMaker>'s PREFIX mechanism.
973
974 The following are equivalent.
975
976     perl Build.PL --prefix /tmp/foo
977     perl Makefile.PL PREFIX=/tmp/foo
978
979 Because of the complex nature of the prefixification logic, the
980 behavior of PREFIX in C<MakeMaker> has changed subtly over time.
981 Module::Build's --prefix logic is equivalent to the PREFIX logic found
982 in C<ExtUtils::MakeMaker> 6.30.
983
984 The maintainers of C<MakeMaker> do understand the troubles with the
985 PREFIX mechanism, and added INSTALL_BASE support in version 6.31 of
986 C<MakeMaker>, which was released in 2006.
987
988 If you don't need to retain compatibility with old versions (pre-6.31) of C<ExtUtils::MakeMaker> or
989 are starting a fresh Perl installation we recommend you use
990 C<install_base> instead (and C<INSTALL_BASE> in C<ExtUtils::MakeMaker>).
991 See L<Module::Build::Cookbook/Installing in the same location as
992 ExtUtils::MakeMaker> for further information.
993
994
995 =back
996
997
998 =head1 MOTIVATIONS
999
1000 There are several reasons I wanted to start over, and not just fix
1001 what I didn't like about C<MakeMaker>:
1002
1003 =over 4
1004
1005 =item *
1006
1007 I don't like the core idea of C<MakeMaker>, namely that C<make> should be
1008 involved in the build process.  Here are my reasons:
1009
1010 =over 4
1011
1012 =item +
1013
1014 When a person is installing a Perl module, what can you assume about
1015 their environment?  Can you assume they have C<make>?  No, but you can
1016 assume they have some version of Perl.
1017
1018 =item +
1019
1020 When a person is writing a Perl module for intended distribution, can
1021 you assume that they know how to build a Makefile, so they can
1022 customize their build process?  No, but you can assume they know Perl,
1023 and could customize that way.
1024
1025 =back
1026
1027 For years, these things have been a barrier to people getting the
1028 build/install process to do what they want.
1029
1030 =item *
1031
1032 There are several architectural decisions in C<MakeMaker> that make it
1033 very difficult to customize its behavior.  For instance, when using
1034 C<MakeMaker> you do C<use ExtUtils::MakeMaker>, but the object created in
1035 C<WriteMakefile()> is actually blessed into a package name that's
1036 created on the fly, so you can't simply subclass
1037 C<ExtUtils::MakeMaker>.  There is a workaround C<MY> package that lets
1038 you override certain C<MakeMaker> methods, but only certain explicitly
1039 preselected (by C<MakeMaker>) methods can be overridden.  Also, the method
1040 of customization is very crude: you have to modify a string containing
1041 the Makefile text for the particular target.  Since these strings
1042 aren't documented, and I<can't> be documented (they take on different
1043 values depending on the platform, version of perl, version of
1044 C<MakeMaker>, etc.), you have no guarantee that your modifications will
1045 work on someone else's machine or after an upgrade of C<MakeMaker> or
1046 perl.
1047
1048 =item *
1049
1050 It is risky to make major changes to C<MakeMaker>, since it does so many
1051 things, is so important, and generally works.  C<Module::Build> is an
1052 entirely separate package so that I can work on it all I want, without
1053 worrying about backward compatibility with C<MakeMaker>.
1054
1055 =item *
1056
1057 Finally, Perl is said to be a language for system administration.
1058 Could it really be the case that Perl isn't up to the task of building
1059 and installing software?  Even if that software is a bunch of
1060 C<.pm> files that just need to be copied from one place to
1061 another?  My sense was that we could design a system to accomplish
1062 this in a flexible, extensible, and friendly manner.  Or die trying.
1063
1064 =back
1065
1066
1067 =head1 TO DO
1068
1069 The current method of relying on time stamps to determine whether a
1070 derived file is out of date isn't likely to scale well, since it
1071 requires tracing all dependencies backward, it runs into problems on
1072 NFS, and it's just generally flimsy.  It would be better to use an MD5
1073 signature or the like, if available.  See C<cons> for an example.
1074
1075  - append to perllocal.pod
1076  - add a 'plugin' functionality
1077
1078
1079 =head1 AUTHOR
1080
1081 Ken Williams <kwilliams@cpan.org>
1082
1083 Development questions, bug reports, and patches should be sent to the
1084 Module-Build mailing list at <module-build@perl.org>.
1085
1086 Bug reports are also welcome at
1087 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Build>.
1088
1089 The latest development version is available from the Git
1090 repository at <https://github.com/Perl-Toolchain-Gang/Module-Build>
1091
1092
1093 =head1 COPYRIGHT
1094
1095 Copyright (c) 2001-2006 Ken Williams.  All rights reserved.
1096
1097 This library is free software; you can redistribute it and/or
1098 modify it under the same terms as Perl itself.
1099
1100
1101 =head1 SEE ALSO
1102
1103 perl(1), L<Module::Build::Cookbook>, L<Module::Build::Authoring>,
1104 L<Module::Build::API>, L<ExtUtils::MakeMaker>
1105
1106 F<META.yml> Specification:
1107 L<CPAN::Meta::Spec>
1108
1109 L<http://www.dsmit.com/cons/>
1110
1111 L<http://search.cpan.org/dist/PerlBuildSystem/>
1112
1113 =cut