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