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