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