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