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