1ExtUtils::MakeMaker::FAQP(e3rplm)Programmers ReferenceEGxutiUdteils::MakeMaker::FAQ(3pm)
2
3
4

NAME

6       ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker
7

DESCRIPTION

9       FAQs, tricks and tips for "ExtUtils::MakeMaker".
10
11   Module Installation
12       How do I install a module into my home directory?
13           If you're not the Perl administrator you probably don't have
14           permission to install a module to its default location.  Then you
15           should install it for your own use into your home directory like
16           so:
17
18               # Non-unix folks, replace ~ with /path/to/your/home/dir
19               perl Makefile.PL INSTALL_BASE=~
20
21           This will put modules into ~/lib/perl5, man pages into ~/man and
22           programs into ~/bin.
23
24           To ensure your Perl programs can see these newly installed modules,
25           set your "PERL5LIB" environment variable to ~/lib/perl5 or tell
26           each of your programs to look in that directory with the following:
27
28               use lib "$ENV{HOME}/lib/perl5";
29
30           or if $ENV{HOME} isn't set and you don't want to set it for some
31           reason, do it the long way.
32
33               use lib "/path/to/your/home/dir/lib/perl5";
34
35       How do I get MakeMaker and Module::Build to install to the same place?
36           Module::Build, as of 0.28, supports two ways to install to the same
37           location as MakeMaker.
38
39           1) Use INSTALL_BASE / "--install_base"
40
41           MakeMaker (as of 6.31) and Module::Build (as of 0.28) both can
42           install to the same locations using the "install_base" concept.
43           See "INSTALL_BASE" in ExtUtils::MakeMaker for details.  To get MM
44           and MB to install to the same location simply set INSTALL_BASE in
45           MM and "--install_base" in MB to the same location.
46
47               perl Makefile.PL INSTALL_BASE=/whatever
48               perl Build.PL    --install_base /whatever
49
50           2) Use PREFIX / "--prefix"
51
52           Module::Build 0.28 added support for "--prefix" which works like
53           MakeMaker's PREFIX.
54
55               perl Makefile.PL PREFIX=/whatever
56               perl Build.PL    --prefix /whatever
57
58       How do I keep from installing man pages?
59           Recent versions of MakeMaker will only install man pages on Unix
60           like operating systems.
61
62           For an individual module:
63
64                   perl Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none
65
66           If you want to suppress man page installation for all modules you
67           have to reconfigure Perl and tell it 'none' when it asks where to
68           install man pages.
69
70       How do I use a module without installing it?
71           Two ways.  One is to build the module normally...
72
73                   perl Makefile.PL
74                   make
75                   make test
76
77           ...and then set the PERL5LIB environment variable to point at the
78           blib/lib and blib/arch directories.
79
80           The other is to install the module in a temporary location.
81
82                   perl Makefile.PL INSTALL_BASE=~/tmp
83                   make
84                   make test
85                   make install
86
87           And then set PERL5LIB to ~/tmp/lib/perl5.  This works well when you
88           have multiple modules to work with.  It also ensures that the
89           module goes through its full installation process which may modify
90           it.
91
92       PREFIX vs INSTALL_BASE from Module::Build::Cookbook
93           The behavior of PREFIX is complicated and depends closely on how
94           your Perl is configured. The resulting installation locations will
95           vary from machine to machine and even different installations of
96           Perl on the same machine.  Because of this, its difficult to
97           document where prefix will place your modules.
98
99           In contrast, INSTALL_BASE has predictable, easy to explain
100           installation locations.  Now that Module::Build and MakeMaker both
101           have INSTALL_BASE there is little reason to use PREFIX other than
102           to preserve your existing installation locations. If you are
103           starting a fresh Perl installation we encourage you to use
104           INSTALL_BASE. If you have an existing installation installed via
105           PREFIX, consider moving it to an installation structure matching
106           INSTALL_BASE and using that instead.
107
108   Philosophy and History
109       Why not just use <insert other build config tool here>?
110           Why did MakeMaker reinvent the build configuration wheel?  Why not
111           just use autoconf or automake or ppm or Ant or ...
112
113           There are many reasons, but the major one is cross-platform
114           compatibility.
115
116           Perl is one of the most ported pieces of software ever.  It works
117           on operating systems I've never even heard of (see perlport for
118           details).  It needs a build tool that can work on all those
119           platforms and with any wacky C compilers and linkers they might
120           have.
121
122           No such build tool exists.  Even make itself has wildly different
123           dialects.  So we have to build our own.
124
125       What is Module::Build and how does it relate to MakeMaker?
126           Module::Build is a project by Ken Williams to supplant MakeMaker.
127           Its primary advantages are:
128
129           ·       pure perl.  no make, no shell commands
130
131           ·       easier to customize
132
133           ·       cleaner internals
134
135           ·       less cruft
136
137           Module::Build is the official heir apparent to MakeMaker and we
138           encourage people to work on M::B rather than spending time adding
139           features to MakeMaker.
140
141   Module Writing
142       How do I keep my $VERSION up to date without resetting it manually?
143           Often you want to manually set the $VERSION in the main module
144           distribution because this is the version that everybody sees on
145           CPAN and maybe you want to customize it a bit.  But for all the
146           other modules in your dist, $VERSION is really just bookkeeping and
147           all that's important is it goes up every time the module is
148           changed.  Doing this by hand is a pain and you often forget.
149
150           Simplest way to do it automatically is to use your version control
151           system's revision number (you are using version control, right?).
152
153           In CVS, RCS and SVN you use $Revision$ (see the documentation of
154           your version control system for details).  Every time the file is
155           checked in the $Revision$ will be updated, updating your $VERSION.
156
157           SVN uses a simple integer for $Revision$ so you can adapt it for
158           your $VERSION like so:
159
160               ($VERSION) = q$Revision$ =~ /(\d+)/;
161
162           In CVS and RCS version 1.9 is followed by 1.10.  Since CPAN
163           compares version numbers numerically we use a sprintf() to convert
164           1.9 to 1.009 and 1.10 to 1.010 which compare properly.
165
166               $VERSION = sprintf "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/g;
167
168           If branches are involved (ie. $Revision: 1.5.3.4$) its a little
169           more complicated.
170
171               # must be all on one line or MakeMaker will get confused.
172               $VERSION = do { my @r = (q$Revision$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
173
174           In SVN, $Revision$ should be the same for every file in the project
175           so they would all have the same $VERSION.  CVS and RCS have a
176           different $Revision$ per file so each file will have a differnt
177           $VERSION.  Distributed version control systems, such as SVK, may
178           have a different $Revision$ based on who checks out the file
179           leading to a different $VERSION on each machine!  Finally, some
180           distributed version control systems, such as darcs, have no concept
181           of revision number at all.
182
183       What's this META.yml thing and how did it get in my MANIFEST?!
184           META.yml is a module meta-data file pioneered by Module::Build and
185           automatically generated as part of the 'distdir' target (and thus
186           'dist').  See "Module Meta-Data" in ExtUtils::MakeMaker.
187
188           To shut off its generation, pass the "NO_META" flag to
189           "WriteMakefile()".
190
191       How do I delete everything not in my MANIFEST?
192           Some folks are surpried that "make distclean" does not delete
193           everything not listed in their MANIFEST (thus making a clean
194           distribution) but only tells them what they need to delete.  This
195           is done because it is considered too dangerous.  While developing
196           your module you might write a new file, not add it to the MANIFEST,
197           then run a "distclean" and be sad because your new work was
198           deleted.
199
200           If you really want to do this, you can use
201           "ExtUtils::Manifest::manifind()" to read the MANIFEST and
202           File::Find to delete the files.  But you have to be careful.
203           Here's a script to do that.  Use at your own risk.  Have fun
204           blowing holes in your foot.
205
206               #!/usr/bin/perl -w
207
208               use strict;
209
210               use File::Spec;
211               use File::Find;
212               use ExtUtils::Manifest qw(maniread);
213
214               my %manifest = map  {( $_ => 1 )}
215                              grep { File::Spec->canonpath($_) }
216                                   keys %{ maniread() };
217
218               if( !keys %manifest ) {
219                   print "No files found in MANIFEST.  Stopping.\n";
220                   exit;
221               }
222
223               find({
224                     wanted   => sub {
225                         my $path = File::Spec->canonpath($_);
226
227                         return unless -f $path;
228                         return if exists $manifest{ $path };
229
230                         print "unlink $path\n";
231                         unlink $path;
232                     },
233                     no_chdir => 1
234                    },
235                    "."
236               );
237
238       Which zip should I use on Windows for '[nd]make zipdist'?
239           We recommend InfoZIP: http://www.info-zip.org/Zip.html
240           <http://www.info-zip.org/Zip.html>
241
242   XS
243       How to I prevent "object version X.XX does not match bootstrap
244       parameter Y.YY" errors?
245           XS code is very sensitive to the module version number and will
246           complain if the version number in your Perl module doesn't match.
247           If you change your module's version # without rerunning Makefile.PL
248           the old version number will remain in the Makefile causing the XS
249           code to be built with the wrong number.
250
251           To avoid this, you can force the Makefile to be rebuilt whenever
252           you change the module containing the version number by adding this
253           to your WriteMakefile() arguments.
254
255               depend => { '$(FIRST_MAKEFILE)' => '$(VERSION_FROM)' }
256
257       How do I make two or more XS files coexist in the same directory?
258           Sometimes you need to have two and more XS files in the same
259           package.  One way to go is to put them into separate directories,
260           but sometimes this is not the most suitable solution. The following
261           technique allows you to put two (and more) XS files in the same
262           directory.
263
264           Let's assume that we have a package "Cool::Foo", which includes
265           "Cool::Foo" and "Cool::Bar" modules each having a separate XS file.
266           First we use the following Makefile.PL:
267
268             use ExtUtils::MakeMaker;
269
270             WriteMakefile(
271                 NAME              => 'Cool::Foo',
272                 VERSION_FROM      => 'Foo.pm',
273                 OBJECT              => q/$(O_FILES)/,
274                 # ... other attrs ...
275             );
276
277           Notice the "OBJECT" attribute. MakeMaker generates the following
278           variables in Makefile:
279
280             # Handy lists of source code files:
281             XS_FILES= Bar.xs \
282                   Foo.xs
283             C_FILES = Bar.c \
284                   Foo.c
285             O_FILES = Bar.o \
286                   Foo.o
287
288           Therefore we can use the "O_FILES" variable to tell MakeMaker to
289           use these objects into the shared library.
290
291           That's pretty much it. Now write Foo.pm and Foo.xs, Bar.pm and
292           Bar.xs, where Foo.pm bootstraps the shared library and Bar.pm
293           simply loading Foo.pm.
294
295           The only issue left is to how to bootstrap Bar.xs. This is done
296           from Foo.xs:
297
298             MODULE = Cool::Foo PACKAGE = Cool::Foo
299
300             BOOT:
301             # boot the second XS file
302             boot_Cool__Bar(aTHX_ cv);
303
304           If you have more than two files, this is the place where you should
305           boot extra XS files from.
306
307           The following four files sum up all the details discussed so far.
308
309             Foo.pm:
310             -------
311             package Cool::Foo;
312
313             require DynaLoader;
314
315             our @ISA = qw(DynaLoader);
316             our $VERSION = '0.01';
317             bootstrap Cool::Foo $VERSION;
318
319             1;
320
321             Bar.pm:
322             -------
323             package Cool::Bar;
324
325             use Cool::Foo; # bootstraps Bar.xs
326
327             1;
328
329             Foo.xs:
330             -------
331             #include "EXTERN.h"
332             #include "perl.h"
333             #include "XSUB.h"
334
335             MODULE = Cool::Foo  PACKAGE = Cool::Foo
336
337             BOOT:
338             # boot the second XS file
339             boot_Cool__Bar(aTHX_ cv);
340
341             MODULE = Cool::Foo  PACKAGE = Cool::Foo  PREFIX = cool_foo_
342
343             void
344             cool_foo_perl_rules()
345
346                 CODE:
347                 fprintf(stderr, "Cool::Foo says: Perl Rules\n");
348
349             Bar.xs:
350             -------
351             #include "EXTERN.h"
352             #include "perl.h"
353             #include "XSUB.h"
354
355             MODULE = Cool::Bar  PACKAGE = Cool::Bar PREFIX = cool_bar_
356
357             void
358             cool_bar_perl_rules()
359
360                 CODE:
361                 fprintf(stderr, "Cool::Bar says: Perl Rules\n");
362
363           And of course a very basic test:
364
365             t/cool.t:
366             --------
367             use Test;
368             BEGIN { plan tests => 1 };
369             use Cool::Foo;
370             use Cool::Bar;
371             Cool::Foo::perl_rules();
372             Cool::Bar::perl_rules();
373             ok 1;
374
375           This tip has been brought to you by Nick Ing-Simmons and Stas
376           Bekman.
377

PATCHING

379       If you have a question you'd like to see added to the FAQ (whether or
380       not you have the answer) please send it to makemaker@perl.org.
381

AUTHOR

383       The denizens of makemaker@perl.org.
384

SEE ALSO

386       ExtUtils::MakeMaker
387
388
389
390perl v5.12.4                      2011-06-07     ExtUtils::MakeMaker::FAQ(3pm)
Impressum