Re: New Module::Build released
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / Authoring.pod
1 =head1 NAME
2
3 Module::Build::Authoring - Authoring Module::Build modules
4
5
6 =head1 DESCRIPTION
7
8 When creating a C<Build.PL> script for a module, something like the
9 following code will typically be used:
10
11   use Module::Build;
12   my $build = Module::Build->new
13     (
14      module_name => 'Foo::Bar',
15      license  => 'perl',
16      requires => {
17                   'perl'          => '5.6.1',
18                   'Some::Module'  => '1.23',
19                   'Other::Module' => '>= 1.2, != 1.5, < 2.0',
20                  },
21     );
22   $build->create_build_script;
23
24 A simple module could get away with something as short as this for its
25 C<Build.PL> script:
26
27   use Module::Build;
28   Module::Build->new(
29     module_name => 'Foo::Bar',
30     license     => 'perl',
31   )->create_build_script;
32
33 The model used by C<Module::Build> is a lot like the C<MakeMaker>
34 metaphor, with the following correspondences:
35
36    In Module::Build                 In ExtUtils::MakeMaker
37   ---------------------------      ------------------------
38    Build.PL (initial script)        Makefile.PL (initial script)
39    Build (a short perl script)      Makefile (a long Makefile)
40    _build/ (saved state info)       various config text in the Makefile
41
42 Any customization can be done simply by subclassing C<Module::Build>
43 and adding a method called (for example) C<ACTION_test>, overriding
44 the default 'test' action.  You could also add a method called
45 C<ACTION_whatever>, and then you could perform the action C<Build
46 whatever>.
47
48 For information on providing compatibility with
49 C<ExtUtils::MakeMaker>, see L<Module::Build::Compat> and
50 L<http://www.makemaker.org/wiki/index.cgi?ModuleBuildConversionGuide>.
51
52
53 =head1 API
54
55 I list here some of the most important methods in C<Module::Build>.
56 Normally you won't need to deal with these methods unless you want to
57 subclass C<Module::Build>.  But since one of the reasons I created
58 this module in the first place was so that subclassing is possible
59 (and easy), I will certainly write more docs as the interface
60 stabilizes.
61
62
63 =head2 CONSTRUCTORS
64
65
66 =over 4
67
68 =item current()
69
70 [version 0.20]
71
72 This method returns a reasonable facsimile of the currently-executing
73 C<Module::Build> object representing the current build.  You can use
74 this object to query its C<notes()> method, inquire about installed
75 modules, and so on.  This is a great way to share information between
76 different parts of your build process.  For instance, you can ask
77 the user a question during C<perl Build.PL>, then use their answer
78 during a regression test:
79
80   # In Build.PL:
81   my $color = $build->prompt("What is your favorite color?");
82   $build->notes(color => $color);
83
84   # In t/colortest.t:
85   use Module::Build;
86   my $build = Module::Build->current;
87   my $color = $build->notes('color');
88   ...
89
90 The way the C<current()> method is currently implemented, there may be
91 slight differences between the C<$build> object in Build.PL and the
92 one in C<t/colortest.t>.  It is our goal to minimize these differences
93 in future releases of Module::Build, so please report any anomalies
94 you find.
95
96 One important caveat: in its current implementation, C<current()> will
97 B<NOT> work correctly if you have changed out of the directory that
98 C<Module::Build> was invoked from.
99
100 =item new()
101
102 [version 0.03]
103
104 Creates a new Module::Build object.  Arguments to the new() method are
105 listed below.  Most arguments are optional, but you must provide
106 either the C<module_name> argument, or C<dist_name> and one of
107 C<dist_version> or C<dist_version_from>.  In other words, you must
108 provide enough information to determine both a distribution name and
109 version.
110
111
112 =over 4
113
114 =item add_to_cleanup
115
116 [version 0.19]
117
118 An array reference of files to be cleaned up when the C<clean> action
119 is performed.  See also the add_to_cleanup() method.
120
121 =item auto_features
122
123 [version 0.26]
124
125 This parameter supports the setting of features (see
126 L<feature($name)>) automatically based on a set of prerequisites.  For
127 instance, for a module that could optionally use either MySQL or
128 PostgreSQL databases, you might use C<auto_features> like this:
129
130   my $build = Module::Build->new
131     (
132      ...other stuff here...
133      auto_features => {
134        pg_support    => {
135                          description => "Interface with Postgres databases",
136                          requires    => { 'DBD::Pg' => 23.3,
137                                           'DateTime::Format::Pg' => 0 },
138                         },
139        mysql_support => {
140                          description => "Interface with MySQL databases",
141                          requires    => { 'DBD::mysql' => 17.9,
142                                           'DateTime::Format::MySQL' => 0 },
143                         },
144      }
145     );
146
147 For each feature named, the required prerequisites will be checked, and
148 if there are no failures, the feature will be enabled (set to C<1>).
149 Otherwise the failures will be displayed to the user and the feature
150 will be disabled (set to C<0>).
151
152 See the documentation for L<requires> for the details of how
153 requirements can be specified.
154
155 =item autosplit
156
157 [version 0.04]
158
159 An optional C<autosplit> argument specifies a file which should be run
160 through the C<Autosplit::autosplit()> function.  If multiple files
161 should be split, the argument may be given as an array of the files to
162 split.
163
164 In general I don't consider autosplitting a great idea, because it's
165 not always clear that autosplitting achieves its intended performance
166 benefits.  It may even harm performance in environments like mod_perl,
167 where as much as possible of a module's code should be loaded during
168 startup.
169
170 =item build_class
171
172 [version 0.28]
173
174 The Module::Build class or subclass to use in the build
175 script.  Defaults to "Module::Build" or the class name passed to or
176 created by a call to C<subclass()>.  This property is useful if you're
177 writing a custom Module::Build subclass and have a bootstrapping
178 problem--that is, your subclass requires modules that may not be
179 installed when C<perl Build.PL> is executed, but you've listed in
180 C<build_requires> so that they should be available when C<./Build> is
181 executed.
182
183 =item build_requires
184
185 [version 0.07]
186
187 Modules listed in this section are necessary to build and install the
188 given module, but are not necessary for regular usage of it.  This is
189 actually an important distinction - it allows for tighter control over
190 the body of installed modules, and facilitates correct dependency
191 checking on binary/packaged distributions of the module.
192
193 See the documentation for L<"PREREQUISITES"> for the details of how
194 requirements can be specified.
195
196 =item create_packlist
197
198 If true, this parameter tells Module::Build to create a F<.packlist>
199 file during the C<install> action, just like ExtUtils::MakeMaker does.
200 The file is created in a subdirectory of the C<arch> installation
201 location.  It is used by some other tools (CPAN, CPANPLUS, etc.) for
202 determining what files are part of an install.
203
204 The default value is true.  This parameter was introduced in
205 Module::Build version 0.2609; previously no packlists were ever
206 created by Module::Build.
207
208 =item c_source
209
210 [version 0.04]
211
212 An optional C<c_source> argument specifies a directory which contains
213 C source files that the rest of the build may depend on.  Any C<.c>
214 files in the directory will be compiled to object files.  The
215 directory will be added to the search path during the compilation and
216 linking phases of any C or XS files.
217
218 =item conflicts
219
220 [version 0.07]
221
222 Modules listed in this section conflict in some serious way with the
223 given module.  C<Module::Build> (or some higher-level tool) will
224 refuse to install the given module if the given module/version is also
225 installed.
226
227 See the documentation for L<"PREREQUISITES"> for the details of how
228 requirements can be specified.
229
230 =item create_makefile_pl
231
232 [version 0.19]
233
234 This parameter lets you use Module::Build::Compat during the
235 C<distdir> (or C<dist>) action to automatically create a Makefile.PL
236 for compatibility with ExtUtils::MakeMaker.  The parameter's value
237 should be one of the styles named in the Module::Build::Compat
238 documentation.
239
240 =item create_readme
241
242 [version 0.22]
243
244 This parameter tells Module::Build to automatically create a F<README>
245 file at the top level of your distribution.  Currently it will simply
246 use C<Pod::Text> (or C<Pod::Readme> if it's installed) on the file
247 indicated by C<dist_version_from> and put the result in the F<README>
248 file.  This is by no means the only recommended style for writing a
249 README, but it seems to be one common one used on the CPAN.
250
251 If you generate a F<README> in this way, it's probably a good idea to
252 create a separate F<INSTALL> file if that information isn't in the
253 generated F<README>.
254
255 =item dist_abstract
256
257 [version 0.20]
258
259 This should be a short description of the distribution.  This is used
260 when generating metadata for F<META.yml> and PPD files.  If it is not
261 given then C<Module::Build> looks in the POD of the module from which
262 it gets the distribution's version.  It looks for the first line
263 matching C<$package\s-\s(.+)>, and uses the captured text as the
264 abstract.
265
266 =item dist_author
267
268 [version 0.20]
269
270 This should be something like "John Doe <jdoe@example.com>", or if
271 there are multiple authors, an anonymous array of strings may be
272 specified.  This is used when generating metadata for F<META.yml> and
273 PPD files.  If this is not specified, then C<Module::Build> looks at
274 the module from which it gets the distribution's version.  If it finds
275 a POD section marked "=head1 AUTHOR", then it uses the contents of
276 this section.
277
278 =item dist_name
279
280 [version 0.11]
281
282 Specifies the name for this distribution.  Most authors won't need to
283 set this directly, they can use C<module_name> to set C<dist_name> to
284 a reasonable default.  However, some agglomerative distributions like
285 C<libwww-perl> or C<bioperl> have names that don't correspond directly
286 to a module name, so C<dist_name> can be set independently.
287
288 =item dist_version
289
290 [version 0.11]
291
292 Specifies a version number for the distribution.  See C<module_name>
293 or C<dist_version_from> for ways to have this set automatically from a
294 C<$VERSION> variable in a module.  One way or another, a version
295 number needs to be set.
296
297 =item dist_version_from
298
299 [version 0.11]
300
301 Specifies a file to look for the distribution version in.  Most
302 authors won't need to set this directly, they can use C<module_name>
303 to set it to a reasonable default.
304
305 The version is extracted from the specified file according to the same
306 rules as C<ExtUtils::MakeMaker> and C<CPAN.pm>.  It involves finding
307 the first line that matches the regular expression
308
309    /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/
310
311 eval()-ing that line, then checking the value of the C<$VERSION>
312 variable.  Quite ugly, really, but all the modules on CPAN depend on
313 this process, so there's no real opportunity to change to something
314 better.
315
316 =item dynamic_config
317
318 [version 0.07]
319
320 A boolean flag indicating whether the F<Build.PL> file must be
321 executed, or whether this module can be built, tested and installed
322 solely from consulting its metadata file.  The main reason to set this
323 to a true value is that your module performs some dynamic
324 configuration as part of its build/install process.  If the flag is
325 omitted, the F<META.yml> spec says that installation tools should
326 treat it as 1 (true), because this is a safer way to behave.
327
328 Currently C<Module::Build> doesn't actually do anything with this flag
329 - it's up to higher-level tools like C<CPAN.pm> to do
330 something useful with it.  It can potentially bring lots of security,
331 packaging, and convenience improvements.
332
333 =item extra_compiler_flags
334
335 =item extra_linker_flags
336
337 [version 0.19]
338
339 These parameters can contain array references (or strings, in which
340 case they will be split into arrays) to pass through to the compiler
341 and linker phases when compiling/linking C code.  For example, to tell
342 the compiler that your code is C++, you might do:
343
344   my $build = Module::Build->new
345     (
346      module_name          => 'Foo::Bar',
347      extra_compiler_flags => ['-x', 'c++'],
348     );
349
350 To link your XS code against glib you might write something like:
351
352   my $build = Module::Build->new
353     (
354      module_name          => 'Foo::Bar',
355      dynamic_config       => 1,
356      extra_compiler_flags => scalar `glib-config --cflags`,
357      extra_linker_flags   => scalar `glib-config --libs`,
358     );
359
360 =item get_options
361
362 [version 0.26]
363
364 You can pass arbitrary command line options to F<Build.PL> or
365 F<Build>, and they will be stored in the Module::Build object and can
366 be accessed via the C<args()> method.  However, sometimes you want
367 more flexibility out of your argument processing than this allows.  In
368 such cases, use the C<get_options> parameter to pass in a hash
369 reference of argument specifications, and the list of arguments to
370 F<Build.PL> or F<Build> will be processed according to those
371 specifications before they're passed on to C<Module::Build>'s own
372 argument processing.
373
374 The supported option specification hash keys are:
375
376
377 =over 4
378
379 =item type
380
381 The type of option.  The types are those supported by Getopt::Long; consult
382 its documentation for a complete list.  Typical types are C<=s> for strings,
383 C<+> for additive options, and C<!> for negatable options.  If the
384 type is not specified, it will be considered a boolean, i.e. no
385 argument is taken and a value of 1 will be assigned when the option is
386 encountered.
387
388 =item store
389
390 A reference to a scalar in which to store the value passed to the option.
391 If not specified, the value will be stored under the option name in the
392 hash returned by the C<args()> method.
393
394 =item default
395
396 A default value for the option.  If no default value is specified and no option
397 is passed, then the option key will not exist in the hash returned by
398 C<args()>.
399
400 =back
401
402
403 You can combine references to your own variables or subroutines with
404 unreferenced specifications, for which the result will also be stored in the
405 hash returned by C<args()>.  For example:
406
407   my $loud = 0;
408   my $build = Module::Build->new
409     (
410      module_name => 'Foo::Bar',
411      get_options => {
412                      loud =>     { store => \$loud },
413                      dbd  =>     { type  => '=s'   },
414                      quantity => { type  => '+'    },
415                     }
416     );
417
418   print STDERR "HEY, ARE YOU LISTENING??\n" if $loud;
419   print "We'll use the ", $build->args('dbd'), " DBI driver\n";
420   print "Are you sure you want that many?\n"
421     if $build->args('quantity') > 2;
422
423 The arguments for such a specification can be called like so:
424
425   perl Build.PL --loud --dbd=DBD::pg --quantity --quantity --quantity
426
427 B<WARNING:> Any option specifications that conflict with Module::Build's own
428 options (defined by its properties) will throw an exception.
429
430 Consult the Getopt::Long documentation for details on its usage.
431
432 =item include_dirs
433
434 [version 0.24]
435
436 Specifies any additional directories in which to search for C header
437 files.  May be given as a string indicating a single directory, or as
438 a list reference indicating multiple directories.
439
440 =item install_path
441
442 [version 0.19]
443
444 You can set paths for individual installable elements by using the
445 C<install_path> parameter:
446
447   my $build = Module::Build->new
448     (
449      ...other stuff here...
450      install_path => {
451                       lib  => '/foo/lib',
452                       arch => '/foo/lib/arch',
453                      }
454     );
455
456 =item installdirs
457
458 [version 0.19]
459
460 Determines where files are installed within the normal perl hierarchy
461 as determined by F<Config.pm>.  Valid values are: C<core>, C<site>,
462 C<vendor>.  The default is C<site>.  See
463 L<Module::Build/"INSTALL PATHS">
464
465 =item license
466
467 [version 0.07]
468
469 Specifies the licensing terms of your distribution.  Valid options include:
470
471
472 =over 4
473
474 =item apache
475
476 The distribution is licensed under the Apache Software License
477 (http://opensource.org/licenses/apachepl.php).
478
479 =item artistic
480
481 The distribution is licensed under the Artistic License, as specified
482 by the F<Artistic> file in the standard perl distribution.
483
484 =item bsd
485
486 The distribution is licensed under the BSD License
487 (http://www.opensource.org/licenses/bsd-license.php).
488
489 =item gpl
490
491 The distribution is licensed under the terms of the Gnu General
492 Public License (http://www.opensource.org/licenses/gpl-license.php).
493
494 =item lgpl
495
496 The distribution is licensed under the terms of the Gnu Lesser
497 General Public License
498 (http://www.opensource.org/licenses/lgpl-license.php).
499
500 =item mit
501
502 The distribution is licensed under the MIT License
503 (http://opensource.org/licenses/mit-license.php).
504
505 =item mozilla
506
507 The distribution is licensed under the Mozilla Public
508 License.  (http://opensource.org/licenses/mozilla1.0.php or
509 http://opensource.org/licenses/mozilla1.1.php)
510
511 =item open_source
512
513 The distribution is licensed under some other Open Source
514 Initiative-approved license listed at
515 http://www.opensource.org/licenses/ .
516
517 =item perl
518
519 The distribution may be copied and redistributed under the same terms
520 as perl itself (this is by far the most common licensing option for
521 modules on CPAN).  This is a dual license, in which the user may
522 choose between either the GPL or the Artistic license.
523
524 =item restrictive
525
526 The distribution may not be redistributed without special permission
527 from the author and/or copyright holder.
528
529 =item unrestricted
530
531 The distribution is licensed under a license that is B<not> approved
532 by www.opensource.org but that allows distribution without
533 restrictions.
534
535 =back
536
537
538 Note that you must still include the terms of your license in your
539 documentation - this field only lets automated tools figure out your
540 licensing restrictions.  Humans still need something to read.  If you
541 choose to provide this field, you should make sure that you keep it in
542 sync with your written documentation if you ever change your licensing
543 terms.
544
545 It is a fatal error to use a license other than the ones mentioned
546 above.  This is not because I wish to impose licensing terms on you -
547 please let me know if you would like another license option to be
548 added to the list.  You may also use a license type of C<unknown> if
549 you don't wish to specify your terms (but this is usually not a good
550 idea for you to do!).
551
552 I just started out with a small set of licenses to keep things simple,
553 figuring I'd let people with actual working knowledge in this area
554 tell me what to do.  So if that's you, drop me a line.
555
556 =item meta_add
557
558 [version 0.28]
559
560 A hash of key/value pairs that should be added to the F<META.yml> file
561 during the C<distmeta> action.  Any existing entries with the same
562 names will be overridden.
563
564 =item meta_merge
565
566 [version 0.28]
567
568 A hash of key/value pairs that should be merged into the F<META.yml>
569 file during the C<distmeta> action.  Any existing entries with the
570 same names will be overridden.
571
572 The only difference between C<meta_add> and C<meta_merge> is their
573 behavior on hash-valued and array-valued entries: C<meta_add> will
574 completely blow away the existing hash or array value, but
575 C<meta_merge> will merge the supplied data into the existing hash or
576 array value.
577
578 =item module_name
579
580 [version 0.03]
581
582 The C<module_name> is a shortcut for setting default values of
583 C<dist_name> and C<dist_version_from>, reflecting the fact that the
584 majority of CPAN distributions are centered around one "main" module.
585 For instance, if you set C<module_name> to C<Foo::Bar>, then
586 C<dist_name> will default to C<Foo-Bar> and C<dist_version_from> will
587 default to C<lib/Foo/Bar.pm>.  C<dist_version_from> will in turn be
588 used to set C<dist_version>.
589
590 Setting C<module_name> won't override a C<dist_*> parameter you
591 specify explicitly.
592
593 =item PL_files
594
595 [version 0.06]
596
597 An optional parameter specifying a set of C<.PL> files in your
598 distribution.  These will be run as Perl scripts prior to processing
599 the rest of the files in your distribution.  They are usually used as
600 templates for creating other files dynamically, so that a file like
601 C<lib/Foo/Bar.pm.PL> might create the file C<lib/Foo/Bar.pm>.
602
603 The files are specified with the C<.PL> files as hash keys, and the
604 file(s) they generate as hash values, like so:
605
606   my $build = Module::Build->new
607     (
608      module_name => 'Foo::Bar',
609      ...
610      PL_files => { 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm' },
611     );
612
613 Note that the path specifications are I<always> given in Unix-like
614 format, not in the style of the local system.
615
616 If your C<.PL> scripts don't create any files, or if they create files
617 with unexpected names, or even if they create multiple files, you can
618 indicate that so that Module::Build can properly handle these created
619 files:
620
621   PL_files => {
622                'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm',
623                'lib/something.PL'  => ['/lib/something', '/lib/else'],
624                'lib/funny.PL'      => [],
625               }
626
627 =item pm_files
628
629 [version 0.19]
630
631 An optional parameter specifying the set of C<.pm> files in this
632 distribution, specified as a hash reference whose keys are the files'
633 locations in the distributions, and whose values are their logical
634 locations based on their package name, i.e. where they would be found
635 in a "normal" Module::Build-style distribution.  This parameter is
636 mainly intended to support alternative layouts of files.
637
638 For instance, if you have an old-style MakeMaker distribution for a
639 module called C<Foo::Bar> and a F<Bar.pm> file at the top level of the
640 distribution, you could specify your layout in your C<Build.PL> like
641 this:
642
643   my $build = Module::Build->new
644     (
645      module_name => 'Foo::Bar',
646      ...
647      pm_files => { 'Bar.pm' => 'lib/Foo/Bar.pm' },
648     );
649
650 Note that the values should include C<lib/>, because this is where
651 they would be found in a "normal" Module::Build-style distribution.
652
653 Note also that the path specifications are I<always> given in
654 Unix-like format, not in the style of the local system.
655
656 =item pod_files
657
658 [version 0.19]
659
660 Just like C<pm_files>, but used for specifying the set of C<.pod>
661 files in your distribution.
662
663 =item recommends
664
665 [version 0.08]
666
667 This is just like the C<requires> argument, except that modules listed
668 in this section aren't essential, just a good idea.  We'll just print
669 a friendly warning if one of these modules aren't found, but we'll
670 continue running.
671
672 If a module is recommended but not required, all tests should still
673 pass if the module isn't installed.  This may mean that some tests
674 may be skipped if recommended dependencies aren't present.
675
676 Automated tools like CPAN.pm should inform the user when recommended
677 modules aren't installed, and it should offer to install them if it
678 wants to be helpful.
679
680 See the documentation for L<"PREREQUISITES"> for the details of how
681 requirements can be specified.
682
683 =item recursive_test_files
684
685 [version 0.28]
686
687 Normally, C<Module::Build> does not search subdirectories when looking
688 for tests to run. When this options is set it will search recursively
689 in all subdirectories of the standard 't' test directory.
690
691 =item requires
692
693 [version 0.07]
694
695 An optional C<requires> argument specifies any module prerequisites
696 that the current module depends on.
697
698 One note: currently C<Module::Build> doesn't actually I<require> the
699 user to have dependencies installed, it just strongly urges.  In the
700 future we may require it.  There's also a C<recommends> section for
701 things that aren't absolutely required.
702
703 Automated tools like CPAN.pm should refuse to install a module if one
704 of its dependencies isn't satisfied, unless a "force" command is given
705 by the user.  If the tools are helpful, they should also offer to
706 install the dependencies.
707
708 A synonym for C<requires> is C<prereq>, to help succour people
709 transitioning from C<ExtUtils::MakeMaker>.  The C<requires> term is
710 preferred, but the C<prereq> term will remain valid in future
711 distributions.
712
713 See the documentation for L<"PREREQUISITES"> for the details of how
714 requirements can be specified.
715
716 =item script_files
717
718 [version 0.18]
719
720 An optional parameter specifying a set of files that should be
721 installed as executable perl scripts when the module is installed.
722 May be given as an array reference of the files, or as a hash
723 reference whose keys are the files (and whose values will currently be
724 ignored).
725
726 The default is to install no script files - in other words, there is
727 no default location where Module::Build will look for script files to
728 install.
729
730 For backward compatibility, you may use the parameter C<scripts>
731 instead of C<script_files>.  Please consider this usage deprecated,
732 though it will continue to exist for several version releases.
733
734 =item sign
735
736 [version 0.16]
737
738 If a true value is specified for this parameter, C<Module::Signature>
739 will be used (via the 'distsign' action) to create a SIGNATURE file
740 for your distribution during the 'distdir' action, and to add the
741 SIGNATURE file to the MANIFEST (therefore, don't add it yourself).
742
743 The default value is false.  In the future, the default may change to
744 true if you have C<Module::Signature> installed on your system.
745
746 =item test_files
747
748 [version 0.23]
749
750 An optional parameter specifying a set of files that should be used as
751 C<Test::Harness>-style regression tests to be run during the C<test>
752 action.  May be given as an array reference of the files, or as a hash
753 reference whose keys are the files (and whose values will currently be
754 ignored).  If the argument is given as a single string (not in an
755 array reference), that string will be treated as a C<glob()> pattern
756 specifying the files to use.
757
758 The default is to look for a F<test.pl> script in the top-level
759 directory of the distribution, and any files matching the glob pattern
760 C<*.t> in the F<t/> subdirectory.  If the C<recursive_test_files>
761 property is true, then the C<t/> directory will be scanned recursively
762 for C<*.t> files.
763
764 =item xs_files
765
766 [version 0.19]
767
768 Just like C<pm_files>, but used for specifying the set of C<.xs>
769 files in your distribution.
770
771 =back
772
773
774 =item new_from_context(%args)
775
776 [version 0.28]
777
778 When called from a directory containing a F<Build.PL> script and a
779 F<META.yml> file (in other words, the base directory of a
780 distribution), this method will run the F<Build.PL> and return the
781 resulting C<Module::Build> object to the caller.  Any key-value
782 arguments given to C<new_from_context()> are essentially like
783 command line arguments given to the F<Build.PL> script, so for example
784 you could pass C<< verbose => 1 >> to this method to turn on
785 verbosity.
786
787 =item resume()
788
789 [version 0.03]
790
791 You'll probably never call this method directly, it's only called from
792 the auto-generated C<Build> script.  The C<new()> method is only
793 called once, when the user runs C<perl Build.PL>.  Thereafter, when
794 the user runs C<Build test> or another action, the C<Module::Build>
795 object is created using the C<resume()> method to re-instantiate with
796 the settings given earlier to C<new()>.
797
798 =item subclass()
799
800 [version 0.06]
801
802 This creates a new C<Module::Build> subclass on the fly, as described
803 in the L<"SUBCLASSING"> section.  The caller must provide either a
804 C<class> or C<code> parameter, or both.  The C<class> parameter
805 indicates the name to use for the new subclass, and defaults to
806 C<MyModuleBuilder>.  The C<code> parameter specifies Perl code to use
807 as the body of the subclass.
808
809 =back
810
811
812 =head2 METHODS
813
814
815 =over 4
816
817 =item add_build_element($type)
818
819 [version 0.26]
820
821 Adds a new type of entry to the build process.  Accepts a single
822 string specifying its type-name.  There must also be a method defined
823 to process things of that type, e.g. if you add a build element called
824 C<'foo'>, then you must also define a method called
825 C<process_foo_files()>.
826
827 See also L<Module::Build::Cookbook/"Adding new file types to the build process">.
828
829 =item add_to_cleanup(@files)
830
831 [version 0.03]
832
833 You may call C<< $self->add_to_cleanup(@patterns) >> to tell
834 C<Module::Build> that certain files should be removed when the user
835 performs the C<Build clean> action.  The arguments to the method are
836 patterns suitable for passing to Perl's C<glob()> function, specified
837 in either Unix format or the current machine's native format.  It's
838 usually convenient to use Unix format when you hard-code the filenames
839 (e.g. in F<Build.PL>) and the native format when the names are
840 programmatically generated (e.g. in a testing script).
841
842 I decided to provide a dynamic method of the C<$build> object, rather
843 than just use a static list of files named in the F<Build.PL>, because
844 these static lists can get difficult to manage.  I usually prefer to
845 keep the responsibility for registering temporary files close to the
846 code that creates them.
847
848 =item args()
849
850 [version 0.26]
851
852   my $args_href = $build->args;
853   my %args = $build->args;
854   my $arg_value = $build->args($key);
855   $build->args($key, $value);
856
857 This method is the preferred interface for retrieving the arguments passed via
858 command line options to F<Build.PL> or F<Build>, minus the Module-Build
859 specific options.
860
861 When called in in a scalar context with no arguments, this method returns a
862 reference to the hash storing all of the arguments; in an array context, it
863 returns the hash itself.  When passed a single argument, it returns the value
864 stored in the args hash for that option key.  When called with two arguments,
865 the second argument is assigned to the args hash under the key passed as the
866 first argument.
867
868 =item autosplit_file($from, $to)
869
870 [version 0.28]
871
872 Invokes the C<AutoSplit> module on the C<$from> file, sending the
873 output to the C<lib/auto> directory inside C<$to>.  C<$to> is
874 typically the C<blib/> directory.
875
876 =item base_dir()
877
878 [version 0.14]
879
880 Returns a string containing the root-level directory of this build,
881 i.e. where the C<Build.PL> script and the C<lib> directory can be
882 found.  This is usually the same as the current working directory,
883 because the C<Build> script will C<chdir()> into this directory as
884 soon as it begins execution.
885
886 =item build_requires()
887
888 [version 0.21]
889
890 Returns a hash reference indicating the C<build_requires>
891 prerequisites that were passed to the C<new()> method.
892
893 =item check_installed_status($module, $version)
894
895 [version 0.11]
896
897 This method returns a hash reference indicating whether a version
898 dependency on a certain module is satisfied.  The C<$module> argument
899 is given as a string like C<"Data::Dumper"> or C<"perl">, and the
900 C<$version> argument can take any of the forms described in L<requires>
901 above.  This allows very fine-grained version checking.
902
903 The returned hash reference has the following structure:
904
905   {
906    ok => $whether_the_dependency_is_satisfied,
907    have => $version_already_installed,
908    need => $version_requested, # Same as incoming $version argument
909    message => $informative_error_message,
910   }
911
912 If no version of C<$module> is currently installed, the C<have> value
913 will be the string C<< "<none>" >>.  Otherwise the C<have> value will
914 simply be the version of the installed module.  Note that this means
915 that if C<$module> is installed but doesn't define a version number,
916 the C<have> value will be C<undef> - this is why we don't use C<undef>
917 for the case when C<$module> isn't installed at all.
918
919 This method may be called either as an object method
920 (C<< $build->check_installed_status($module, $version) >>)
921 or as a class method 
922 (C<< Module::Build->check_installed_status($module, $version) >>).
923
924 =item check_installed_version($module, $version)
925
926 [version 0.05]
927
928 Like C<check_installed_status()>, but simply returns true or false
929 depending on whether module C<$module> satisfies the dependency
930 C<$version>.
931
932 If the check succeeds, the return value is the actual version of
933 C<$module> installed on the system.  This allows you to do the
934 following:
935
936   my $installed = $build->check_installed_version('DBI', '1.15');
937   if ($installed) {
938     print "Congratulations, version $installed of DBI is installed.\n";
939   } else {
940     die "Sorry, you must install DBI.\n";
941   }
942
943 If the check fails, we return false and set C<$@> to an informative
944 error message.
945
946 If C<$version> is any non-true value (notably zero) and any version of
947 C<$module> is installed, we return true.  In this case, if C<$module>
948 doesn't define a version, or if its version is zero, we return the
949 special value "0 but true", which is numerically zero, but logically
950 true.
951
952 In general you might prefer to use C<check_installed_status> if you
953 need detailed information, or this method if you just need a yes/no
954 answer.
955
956 =item compare_versions($v1, $op, $v2)
957
958 [version 0.28]
959
960 Compares two module versions C<$v1> and C<$v2> using the operator
961 C<$op>, which should be one of Perl's numeric operators like C<!=> or
962 C<< >= >> or the like.  We do at least a halfway-decent job of
963 handling versions that aren't strictly numeric, like C<0.27_02>, but
964 exotic stuff will likely cause problems.
965
966 In the future, the guts of this method might be replaced with a call
967 out to C<version.pm>.
968
969 =item config()
970
971 [version 0.22]
972
973 Returns a hash reference containing the C<Config.pm> hash, including
974 any changes the author or user has specified.  This is a reference to
975 the actual internal hash we use, so you probably shouldn't modify
976 stuff there.
977
978 =item config_data($name)
979
980 =item config_data($name => $value)
981
982 [version 0.26]
983
984 With a single argument, returns the value of the configuration
985 variable C<$name>.  With two arguments, sets the given configuration
986 variable to the given value.  The value may be any perl scalar that's
987 serializable with C<Data::Dumper>.  For instance, if you write a
988 module that can use a MySQL or PostgreSQL back-end, you might create
989 configuration variables called C<mysql_connect> and
990 C<postgres_connect>, and set each to an array of connection parameters
991 for C<< DBI->connect() >>.
992
993 Configuration values set in this way using the Module::Build object
994 will be available for querying during the build/test process and after
995 installation via the generated C<...::ConfigData> module, as
996 C<< ...::ConfigData->config($name) >>.
997
998 The C<feature()> and C<config_data()> methods represent
999 Module::Build's main support for configuration of installed modules.
1000 See also L<SAVING CONFIGURATION INFORMATION>.
1001
1002 =item conflicts()
1003
1004 [version 0.21]
1005
1006 Returns a hash reference indicating the C<conflicts> prerequisites
1007 that were passed to the C<new()> method.
1008
1009 =item contains_pod($file)
1010
1011 [version 0.20]
1012
1013 [Deprecated] Please see L<Module::Build::ModuleInfo> instead.
1014
1015 Returns true if the given file appears to contain POD documentation.
1016 Currently this checks whether the file has a line beginning with
1017 '=pod', '=head', or '=item', but the exact semantics may change in the
1018 future.
1019
1020 =item copy_if_modified(%parameters)
1021
1022 [version 0.19]
1023
1024 Takes the file in the C<from> parameter and copies it to the file in
1025 the C<to> parameter, or the directory in the C<to_dir> parameter, if
1026 the file has changed since it was last copied (or if it doesn't exist
1027 in the new location).  By default the entire directory structure of
1028 C<from> will be copied into C<to_dir>; an optional C<flatten>
1029 parameter will copy into C<to_dir> without doing so.
1030
1031 Returns the path to the destination file, or C<undef> if nothing
1032 needed to be copied.
1033
1034 Any directories that need to be created in order to perform the
1035 copying will be automatically created.
1036
1037 =item create_build_script()
1038
1039 [version 0.05]
1040
1041 Creates an executable script called C<Build> in the current directory
1042 that will be used to execute further user actions.  This script is
1043 roughly analogous (in function, not in form) to the Makefile created
1044 by C<ExtUtils::MakeMaker>.  This method also creates some temporary
1045 data in a directory called C<_build/>.  Both of these will be removed
1046 when the C<realclean> action is performed.
1047
1048 =item current_action()
1049
1050 [version 0.28]
1051
1052 Returns the name of the currently-running action, such as "build" or
1053 "test".  This action is not necessarily the action that was originally
1054 invoked by the user.  For example, if the user invoked the "test"
1055 action, current_action() would initially return "test".  However,
1056 action "test" depends on action "code", so current_action() will
1057 return "code" while that dependency is being executed.  Once that
1058 action has completed, current_action() will again return "test".
1059
1060 If you need to know the name of the original action invoked by the
1061 user, see L<invoked_action()> below.
1062
1063 =item depends_on(@actions)
1064
1065 [version 0.28]
1066
1067 Invokes the named action or list of actions in sequence.  Using this
1068 method is preferred to calling the action explicitly because it
1069 performs some internal record-keeping, and it ensures that the same
1070 action is not invoked multiple times (note: in future versions of
1071 Module::Build it's conceivable that this run-only-once mechanism will
1072 be changed to something more intelligent).
1073
1074 Note that the name of this method is something of a misnomer; it
1075 should really be called something like
1076 C<invoke_actions_unless_already_invoked()> or something, but for
1077 better or worse (perhaps better!) we were still thinking in
1078 C<make>-like dependency terms when we created this method.
1079
1080 See also C<dispatch()>.  The main distinction between the two is that
1081 C<depends_on()> is meant to call an action from inside another action,
1082 whereas C<dispatch()> is meant to set the very top action in motion.
1083
1084 =item dir_contains($first_dir, $second_dir)
1085
1086 [version 0.28]
1087
1088 Returns true if the first directory logically contains the second
1089 directory.  This is just a convenience function because C<File::Spec>
1090 doesn't really provide an easy way to figure this out (but
1091 C<Path::Class> does...).
1092
1093 =item dispatch($action, %args)
1094
1095 [version 0.03]
1096
1097 Invokes the build action C<$action>.  Optionally, a list of options
1098 and their values can be passed in.  This is equivalent to invoking an
1099 action at the command line, passing in a list of options.
1100
1101 Custom options that have not been registered must be passed in as a
1102 hash reference in a key named "args":
1103
1104   $build->dispatch('foo', verbose => 1, args => { my_option => 'value' });
1105
1106 This method is intended to be used to programmatically invoke build
1107 actions, e.g. by applications controlling Module::Build-based builds
1108 rather than by subclasses.
1109
1110 See also C<depends_on()>.  The main distinction between the two is that
1111 C<depends_on()> is meant to call an action from inside another action,
1112 whereas C<dispatch()> is meant to set the very top action in motion.
1113
1114 =item dist_dir()
1115
1116 [version 0.28]
1117
1118 Returns the name of the directory that will be created during the
1119 C<dist> action.  The name is derived from the C<dist_name> and
1120 C<dist_version> properties.
1121
1122 =item dist_name()
1123
1124 [version 0.21]
1125
1126 Returns the name of the current distribution, as passed to the
1127 C<new()> method in a C<dist_name> or modified C<module_name>
1128 parameter.
1129
1130 =item dist_version()
1131
1132 [version 0.21]
1133
1134 Returns the version of the current distribution, as determined by the
1135 C<new()> method from a C<dist_version>, C<dist_version_from>, or
1136 C<module_name> parameter.
1137
1138 =item do_system($cmd, @args)
1139
1140 [version 0.21]
1141
1142 This is a fairly simple wrapper around Perl's C<system()> built-in
1143 command.  Given a command and an array of optional arguments, this
1144 method will print the command to C<STDOUT>, and then execute it using
1145 Perl's C<system()>.  It returns true or false to indicate success or
1146 failure (the opposite of how C<system()> works, but more intuitive).
1147
1148 Note that if you supply a single argument to C<do_system()>, it
1149 will/may be processed by the systems's shell, and any special
1150 characters will do their special things.  If you supply multiple
1151 arguments, no shell will get involved and the command will be executed
1152 directly.
1153
1154 =item feature($name)
1155
1156 =item feature($name => $value)
1157
1158 [version 0.26]
1159
1160 With a single argument, returns true if the given feature is set.
1161 With two arguments, sets the given feature to the given boolean value.
1162 In this context, a "feature" is any optional functionality of an
1163 installed module.  For instance, if you write a module that could
1164 optionally support a MySQL or PostgreSQL backend, you might create
1165 features called C<mysql_support> and C<postgres_support>, and set them
1166 to true/false depending on whether the user has the proper databases
1167 installed and configured.
1168
1169 Features set in this way using the Module::Build object will be
1170 available for querying during the build/test process and after
1171 installation via the generated C<...::ConfigData> module, as 
1172 C<< ...::ConfigData->feature($name) >>.
1173
1174 The C<feature()> and C<config_data()> methods represent
1175 Module::Build's main support for configuration of installed modules.
1176 See also L<SAVING CONFIGURATION INFORMATION>.
1177
1178 =item have_c_compiler()
1179
1180 [version 0.21]
1181
1182 Returns true if the current system seems to have a working C compiler.
1183 We currently determine this by attempting to compile a simple C source
1184 file and reporting whether the attempt was successful.
1185
1186 =item install_destination($type)
1187
1188 [version 0.28]
1189
1190 Returns the directory in which items of type C<$type> (e.g. C<lib>,
1191 C<arch>, C<bin>, or anything else returned by the C<install_types()>
1192 method) will be installed during the C<install> action.  Any settings
1193 for C<install_path>, C<install_base>, and C<prefix> are taken into
1194 account when determining the return value.
1195
1196 =item install_path()
1197
1198 =item install_path($type)
1199
1200 =item install_path($type => $path)
1201
1202 [version 0.28]
1203
1204 Set or retrieve paths for specific installable elements. This is
1205 useful when you want to examine any explicit install paths specified
1206 by the user on the command line, or if you want to set the install
1207 path for a specific installable element based on another attribute
1208 like C<install_base()>.
1209
1210 With no argument, it returns a reference to a hash containing all
1211 elements and their respective values. This hash should not be modified
1212 directly; use the multi-argument below form to change values.
1213
1214 The single argument form returns the value associated with the
1215 element C<$type>.
1216
1217 The multi-argument form allows you to set the paths for one or more
1218 element types. The return value is undefined.
1219
1220 =item install_types()
1221
1222 [version 0.28]
1223
1224 Returns a list of installable types that this build knows about.
1225 These types each correspond to the name of a directory in F<blib/>,
1226 and the list usually includes items such as C<lib>, C<arch>, C<bin>,
1227 C<script>, C<libdoc>, C<bindoc>, and if HTML documentation is to be
1228 built, C<libhtml> and C<binhtml>.  Other user-defined types may also
1229 exist.
1230
1231 =item invoked_action()
1232
1233 [version 0.28]
1234
1235 This is the name of the original action invoked by the user.  This
1236 value is set when the user invokes F<Build.PL>, the F<Build> script,
1237 or programatically through the L<dispatch()> method.  It does not
1238 change as sub-actions are executed as dependencies are evaluated.
1239
1240 To get the name of the currently executing dependency, see
1241 L<current_action()> above.
1242
1243 =item notes()
1244
1245 =item notes($key)
1246
1247 =item notes($key => $value)
1248
1249 [version 0.20]
1250
1251 The C<notes()> value allows you to store your own persistent
1252 information about the build, and to share that information among
1253 different entities involved in the build.  See the example in the
1254 C<current()> method.
1255
1256 The C<notes()> method is essentally a glorified hash access.  With no
1257 arguments, C<notes()> returns the entire hash of notes.  With one argument,
1258 C<notes($key)> returns the value associated with the given key.  With two
1259 arguments, C<notes($key, $value)> sets the value associated with the given key
1260 to C<$value> and returns the new value.
1261
1262 The lifetime of the C<notes> data is for "a build" - that is, the
1263 C<notes> hash is created when C<perl Build.PL> is run (or when the
1264 C<new()> method is run, if the Module::Build Perl API is being used
1265 instead of called from a shell), and lasts until C<perl Build.PL> is
1266 run again or the C<clean> action is run.
1267
1268 =item orig_dir()
1269
1270 [version 0.28]
1271
1272 Returns a string containing the working directory that was in effect
1273 before the F<Build> script chdir()-ed into the C<base_dir>.  This
1274 might be useful for writing wrapper tools that might need to chdir()
1275 back out.
1276
1277 =item os_type()
1278
1279 [version 0.04]
1280
1281 If you're subclassing Module::Build and some code needs to alter its
1282 behavior based on the current platform, you may only need to know
1283 whether you're running on Windows, Unix, MacOS, VMS, etc., and not the
1284 fine-grained value of Perl's C<$^O> variable.  The C<os_type()> method
1285 will return a string like C<Windows>, C<Unix>, C<MacOS>, C<VMS>, or
1286 whatever is appropriate.  If you're running on an unknown platform, it
1287 will return C<undef> - there shouldn't be many unknown platforms
1288 though.
1289
1290 =item prepare_metadata()
1291
1292 [version 0.28]
1293
1294 This method is provided for authors to override to customize the
1295 fields of F<META.yml>.  It is passed a YAML::Node node object which can
1296 be modified as desired and then returned.  E.g.
1297
1298   package My::Builder;
1299   use base 'Module::Build';
1300
1301   sub prepare_metadata {
1302     my $self = shift;
1303     my $node = $self->SUPER::prepare_metadata( shift );
1304     $node->{custom_field} = 'foo';
1305     return $node;
1306   }
1307
1308 =item prereq_failures()
1309
1310 [version 0.11]
1311
1312 Returns a data structure containing information about any failed
1313 prerequisites (of any of the types described above), or C<undef> if
1314 all prerequisites are met.
1315
1316 The data structure returned is a hash reference.  The top level keys
1317 are the type of prerequisite failed, one of "requires",
1318 "build_requires", "conflicts", or "recommends".  The associated values
1319 are hash references whose keys are the names of required (or
1320 conflicting) modules.  The associated values of those are hash
1321 references indicating some information about the failure.  For example:
1322
1323   {
1324    have => '0.42',
1325    need => '0.59',
1326    message => 'Version 0.42 is installed, but we need version 0.59',
1327   }
1328
1329 or
1330
1331   {
1332    have => '<none>',
1333    need => '0.59',
1334    message => 'Prerequisite Foo isn't installed',
1335   }
1336
1337 This hash has the same structure as the hash returned by the
1338 C<check_installed_status()> method, except that in the case of
1339 "conflicts" dependencies we change the "need" key to "conflicts" and
1340 construct a proper message.
1341
1342 Examples:
1343
1344   # Check a required dependency on Foo::Bar
1345   if ( $build->prereq_failures->{requires}{Foo::Bar} ) { ...
1346
1347   # Check whether there were any failures
1348   if ( $build->prereq_failures ) { ...
1349
1350   # Show messages for all failures
1351   my $failures = $build->prereq_failures;
1352   while (my ($type, $list) = each %$failures) {
1353     while (my ($name, $hash) = each %$list) {
1354       print "Failure for $name: $hash->{message}\n";
1355     }
1356   }
1357
1358 =item prereq_report()
1359
1360 [version 0.28]
1361
1362 Returns a human-readable (table-form) string showing all
1363 prerequisites, the versions required, and the versions actually
1364 installed.  This can be useful for reviewing the configuration of your
1365 system prior to a build, or when compiling data to send for a bug
1366 report.  The C<prereq_report> action is just a thin wrapper around the
1367 C<prereq_report()> method.
1368
1369 =item prompt($message, $default)
1370
1371 [version 0.12]
1372
1373 Asks the user a question and returns their response as a string.  The
1374 first argument specifies the message to display to the user (for
1375 example, C<"Where do you keep your money?">).  The second argument,
1376 which is optional, specifies a default answer (for example,
1377 C<"wallet">).  The user will be asked the question once.
1378
1379 If C<prompt()> detects that it is not running interactively and there
1380 is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
1381 is set to true, the $default will be used without prompting.  This
1382 prevents automated processes from blocking on user input.
1383
1384 If no $default is provided an empty string will be used instead.
1385
1386 This method may be called as a class or object method.
1387
1388 =item recommends()
1389
1390 [version 0.21]
1391
1392 Returns a hash reference indicating the C<recommends> prerequisites
1393 that were passed to the C<new()> method.
1394
1395 =item requires()
1396
1397 [version 0.21]
1398
1399 Returns a hash reference indicating the C<requires> prerequisites that
1400 were passed to the C<new()> method.
1401
1402 =item rscan_dir($dir, $pattern)
1403
1404 [version 0.28]
1405
1406 Uses C<File::Find> to traverse the directory C<$dir>, returning a
1407 reference to an array of entries matching C<$pattern>.  C<$pattern>
1408 may either be a regular expression (using C<qr//> or just a plain
1409 string), or a reference to a subroutine that will return true for
1410 wanted entries.  If C<$pattern> is not given, all entries will be
1411 returned.
1412
1413 Examples:
1414
1415  # All the *.pm files in lib/
1416  $m->rscan_dir('lib', qr/\.pm$/)
1417  
1418  # All the files in blib/ that aren't *.html files
1419  $m->rscan_dir('blib', sub {-f $_ and not /\.html$/});
1420
1421  # All the files in t/
1422  $m->rscan_dir('t');
1423
1424 =item runtime_params()
1425
1426 =item runtime_params($key)
1427
1428 [version 0.28]
1429
1430 The C<runtime_params()> method stores the values passed on the command line
1431 for valid properties (that is, any command line options for which
1432 C<valid_property()> returns a true value).  The value on the command line may
1433 override the default value for a property, as well as any value specified in a
1434 call to C<new()>.  This allows you to programmatically tell if C<perl Build.PL>
1435 or any execution of C<./Build> had command line options specified that
1436 override valid properties.
1437
1438 The C<runtime_params()> method is essentally a glorified read-only hash.  With
1439 no arguments, C<runtime_params()> returns the entire hash of properties
1440 specified on the command line.  With one argument, C<runtime_params($key)>
1441 returns the value associated with the given key.
1442
1443 The lifetime of the C<runtime_params> data is for "a build" - that is, the
1444 C<runtime_params> hash is created when C<perl Build.PL> is run (or when the
1445 C<new()> method is called, if the Module::Build Perl API is being used instead
1446 of called from a shell), and lasts until C<perl Build.PL> is run again or the
1447 C<clean> action is run.
1448
1449 =item script_files()
1450
1451 [version 0.18]
1452
1453 Returns a hash reference whose keys are the perl script files to be
1454 installed, if any.  This corresponds to the C<script_files> parameter to the
1455 C<new()> method.  With an optional argument, this parameter may be set
1456 dynamically.
1457
1458 For backward compatibility, the C<scripts()> method does exactly the
1459 same thing as C<script_files()>.  C<scripts()> is deprecated, but it
1460 will stay around for several versions to give people time to
1461 transition.
1462
1463 =item up_to_date($source_file, $derived_file)
1464
1465 =item up_to_date(\@source_files, \@derived_files)
1466
1467 [version 0.20]
1468
1469 This method can be used to compare a set of source files to a set of
1470 derived files.  If any of the source files are newer than any of the
1471 derived files, it returns false.  Additionally, if any of the derived
1472 files do not exist, it returns false.  Otherwise it returns true.
1473
1474 The arguments may be either a scalar or an array reference of file
1475 names.
1476
1477 =item y_n($message, $default)
1478
1479 [version 0.12]
1480
1481 Asks the user a yes/no question using C<prompt()> and returns true or
1482 false accordingly.  The user will be asked the question repeatedly
1483 until they give an answer that looks like "yes" or "no".
1484
1485 The first argument specifies the message to display to the user (for
1486 example, C<"Shall I invest your money for you?">), and the second
1487 argument specifies the default answer (for example, C<"y">).
1488
1489 Note that the default is specified as a string like C<"y"> or C<"n">,
1490 and the return value is a Perl boolean value like 1 or 0.  I thought
1491 about this for a while and this seemed like the most useful way to do
1492 it.
1493
1494 This method may be called as a class or object method.
1495
1496 =back
1497
1498
1499 =head2 Autogenerated Accessors
1500
1501 In addition to the aforementioned methods, there are also some get/set
1502 accessor methods for the following properties:
1503
1504 =over 4
1505
1506 =item PL_files()
1507
1508 =item autosplit()
1509
1510 =item base_dir()
1511
1512 =item bindoc_dirs()
1513
1514 =item blib()
1515
1516 =item build_bat()
1517
1518 =item build_class()
1519
1520 =item build_elements()
1521
1522 =item build_requires()
1523
1524 =item build_script()
1525
1526 =item c_source()
1527
1528 =item config()
1529
1530 =item config_dir()
1531
1532 =item conflicts()
1533
1534 =item create_makefile_pl()
1535
1536 =item create_packlist()
1537
1538 =item create_readme()
1539
1540 =item debugger()
1541
1542 =item destdir()
1543
1544 =item get_options()
1545
1546 =item html_css()
1547
1548 =item include_dirs()
1549
1550 =item install_base()
1551
1552 =item install_path()
1553
1554 =item install_sets()
1555
1556 =item installdirs()
1557
1558 =item libdoc_dirs()
1559
1560 =item license()
1561
1562 =item magic_number()
1563
1564 =item mb_version()
1565
1566 =item meta_add()
1567
1568 =item meta_merge()
1569
1570 =item metafile()
1571
1572 =item module_name()
1573
1574 =item orig_dir()
1575
1576 =item original_prefix()
1577
1578 =item perl()
1579
1580 =item pm_files()
1581
1582 =item pod_files()
1583
1584 =item pollute()
1585
1586 =item prefix()
1587
1588 =item prereq_action_types()
1589
1590 =item quiet()
1591
1592 =item recommends()
1593
1594 =item recurse_into()
1595
1596 =item recursive_test_files()
1597
1598 =item requires()
1599
1600 =item scripts()
1601
1602 =item use_rcfile()
1603
1604 =item verbose()
1605
1606 =item xs_files()
1607
1608 =back
1609
1610
1611 =head1 PREREQUISITES
1612
1613 There are three basic types of prerequisites that can be defined: 1)
1614 "requires" - are versions of modules that are required for certain
1615 functionality to be available; 2) "recommends" - are versions of
1616 modules that are recommended to provide enhanced functionality; and 3)
1617 "conflicts" - are versions of modules that conflict with, and that can
1618 cause problems with the distribution.
1619
1620 Each of the three types of prerequisites listed above can be applied
1621 to different aspects of the Build process.  For the module distribution
1622 itself you simply define "requires", "recommends", or "conflicts".  The
1623 types can also apply to other aspects of the Build process.  Currently,
1624 only "build_requires" is defined which is used for modules which are
1625 required during the Build process.
1626
1627
1628 =head2 Format of prerequisites
1629
1630 The prerequisites are given in a hash reference, where the keys are
1631 the module names and the values are version specifiers:
1632
1633   requires => {
1634                Foo::Module => '2.4',
1635                Bar::Module => 0,
1636                Ken::Module => '>= 1.2, != 1.5, < 2.0',
1637                perl => '5.6.0'
1638               },
1639
1640 These four version specifiers have different effects.  The value
1641 C<'2.4'> means that B<at least> version 2.4 of C<Foo::Module> must be
1642 installed.  The value C<0> means that B<any> version of C<Bar::Module>
1643 is acceptable, even if C<Bar::Module> doesn't define a version.  The
1644 more verbose value C<'E<gt>= 1.2, != 1.5, E<lt> 2.0'> means that
1645 C<Ken::Module>'s version must be B<at least> 1.2, B<less than> 2.0,
1646 and B<not equal to> 1.5.  The list of criteria is separated by commas,
1647 and all criteria must be satisfied.
1648
1649 A special C<perl> entry lets you specify the versions of the Perl
1650 interpreter that are supported by your module.  The same version
1651 dependency-checking semantics are available, except that we also
1652 understand perl's new double-dotted version numbers.
1653
1654
1655 =head1 SAVING CONFIGURATION INFORMATION
1656
1657 Module::Build provides a very convenient way to save configuration
1658 information that your installed modules (or your regression tests) can
1659 access.  If your Build process calls the C<feature()> or
1660 C<config_data()> methods, then a C<Foo::Bar::ConfigData> module will
1661 automatically be created for you, where C<Foo::Bar> is the
1662 C<module_name> parameter as passed to C<new()>.  This module provides
1663 access to the data saved by these methods, and a way to update the
1664 values.  There is also a utility script called C<config_data>
1665 distributed with Module::Build that provides a command line interface
1666 to this same functionality.  See also the generated
1667 C<Foo::Bar::ConfigData> documentation, and the C<config_data>
1668 script's documentation, for more information.
1669
1670
1671 =head1 AUTOMATION
1672
1673 One advantage of Module::Build is that since it's implemented as Perl
1674 methods, you can invoke these methods directly if you want to install
1675 a module non-interactively.  For instance, the following Perl script
1676 will invoke the entire build/install procedure:
1677
1678   my $build = Module::Build->new(module_name => 'MyModule');
1679   $build->dispatch('build');
1680   $build->dispatch('test');
1681   $build->dispatch('install');
1682
1683 If any of these steps encounters an error, it will throw a fatal
1684 exception.
1685
1686 You can also pass arguments as part of the build process:
1687
1688   my $build = Module::Build->new(module_name => 'MyModule');
1689   $build->dispatch('build');
1690   $build->dispatch('test', verbose => 1);
1691   $build->dispatch('install', sitelib => '/my/secret/place/');
1692
1693 Building and installing modules in this way skips creating the
1694 C<Build> script.
1695
1696
1697 =head1 STRUCTURE
1698
1699 Module::Build creates a class hierarchy conducive to customization.
1700 Here is the parent-child class hierarchy in classy ASCII art:
1701
1702    /--------------------\
1703    |   Your::Parent     |  (If you subclass Module::Build)
1704    \--------------------/
1705             |
1706             |
1707    /--------------------\  (Doesn't define any functionality
1708    |   Module::Build    |   of its own - just figures out what
1709    \--------------------/   other modules to load.)
1710             |
1711             |
1712    /-----------------------------------\  (Some values of $^O may
1713    |   Module::Build::Platform::$^O    |   define specialized functionality.
1714    \-----------------------------------/   Otherwise it's ...::Default, a
1715             |                              pass-through class.)
1716             |
1717    /--------------------------\
1718    |   Module::Build::Base    |  (Most of the functionality of 
1719    \--------------------------/   Module::Build is defined here.)
1720
1721
1722 =head1 SUBCLASSING
1723
1724 Right now, there are two ways to subclass Module::Build.  The first
1725 way is to create a regular module (in a C<.pm> file) that inherits
1726 from Module::Build, and use that module's class instead of using
1727 Module::Build directly:
1728
1729   ------ in Build.PL: ----------
1730   #!/usr/bin/perl
1731
1732   use lib q(/nonstandard/library/path);
1733   use My::Builder;  # Or whatever you want to call it
1734
1735   my $build = My::Builder->new
1736     (
1737      module_name => 'Foo::Bar',  # All the regular args...
1738      license     => 'perl',
1739      dist_author => 'A N Other <me@here.net.au>',
1740      requires    => { Carp => 0 }
1741     );
1742   $build->create_build_script;
1743
1744 This is relatively straightforward, and is the best way to do things
1745 if your My::Builder class contains lots of code.  The
1746 C<create_build_script()> method will ensure that the current value of
1747 C<@INC> (including the C</nonstandard/library/path>) is propogated to
1748 the Build script, so that My::Builder can be found when running build
1749 actions.
1750
1751 For very small additions, Module::Build provides a C<subclass()>
1752 method that lets you subclass Module::Build more conveniently, without
1753 creating a separate file for your module:
1754
1755   ------ in Build.PL: ----------
1756   #!/usr/bin/perl
1757
1758   use Module::Build;
1759   my $class = Module::Build->subclass
1760     (
1761      class => 'My::Builder',
1762      code => q{
1763        sub ACTION_foo {
1764          print "I'm fooing to death!\n";
1765        }
1766      },
1767     );
1768
1769   my $build = $class->new
1770     (
1771      module_name => 'Foo::Bar',  # All the regular args...
1772      license     => 'perl',
1773      dist_author => 'A N Other <me@here.net.au>',
1774      requires    => { Carp => 0 }
1775     );
1776   $build->create_build_script;
1777
1778 Behind the scenes, this actually does create a C<.pm> file, since the
1779 code you provide must persist after Build.PL is run if it is to be
1780 very useful.
1781
1782 See also the documentation for the C<subclass()> method.
1783
1784
1785 =head1 STARTING MODULE DEVELOPMENT
1786
1787 When starting development on a new module, it's rarely worth your time
1788 to create a tree of all the files by hand.  Some automatic
1789 module-creators are available: the oldest is C<h2xs>, which has
1790 shipped with perl itself for a long time.  Its name reflects the fact
1791 that modules were originally conceived of as a way to wrap up a C
1792 library (thus the C<h> part) into perl extensions (thus the C<xs>
1793 part).
1794
1795 These days, C<h2xs> has largely been superseded by modules like
1796 C<ExtUtils::ModuleMaker>, C<Module::Starter>, and C<Module::Maker>.
1797 They have varying degrees of support for C<Module::Build>.
1798
1799
1800 =head1 MIGRATION
1801
1802 Note that if you want to provide both a F<Makefile.PL> and a
1803 F<Build.PL> for your distribution, you probably want to add the
1804 following to C<WriteMakefile> in your F<Makefile.PL> so that MakeMaker
1805 doesn't try to run your F<Build.PL> as a normal F<.PL> file:
1806
1807   PL_FILES => {},
1808
1809 You may also be interested in looking at the C<Module::Build::Compat>
1810 module, which can automatically create various kinds of F<Makefile.PL>
1811 compatibility layers.
1812
1813
1814 =head1 AUTHOR
1815
1816 Ken Williams, kwilliams@cpan.org
1817
1818 Development questions, bug reports, and patches should be sent to the
1819 Module-Build mailing list at module-build-general@lists.sourceforge.net .
1820
1821 Bug reports are also welcome at
1822 http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Build .
1823
1824 An anonymous CVS repository containing the latest development version
1825 is available; see http://sourceforge.net/cvs/?group_id=45731 for the
1826 details of how to access it.
1827
1828
1829 =head1 SEE ALSO
1830
1831 perl(1), Module::Build(3), Module::Build::Cookbook(3),
1832 ExtUtils::MakeMaker(3), YAML(3)
1833
1834 F<META.yml> Specification:
1835 L<http://module-build.sourceforge.net/META-spec-v1.2.html>
1836
1837 L<http://www.dsmit.com/cons/>
1838
1839 =cut