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