2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml">
5 <title>ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker
</title>
6 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
7 <link rev=
"made" href=
"mailto:" />
10 <body style=
"background-color: white">
11 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
12 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
13 <big><strong><span class=
"block"> ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker
</span></strong></big>
17 <p><a name=
"__index__"></a></p>
22 <li><a href=
"#name">NAME
</a></li>
23 <li><a href=
"#description">DESCRIPTION
</a></li>
26 <li><a href=
"#module_installation">Module Installation
</a></li>
27 <li><a href=
"#philosophy_and_history">Philosophy and History
</a></li>
28 <li><a href=
"#module_writing">Module Writing
</a></li>
29 <li><a href=
"#xs">XS
</a></li>
32 <li><a href=
"#patching">PATCHING
</a></li>
33 <li><a href=
"#author">AUTHOR
</a></li>
34 <li><a href=
"#see_also">SEE ALSO
</a></li>
41 <h1><a name=
"name">NAME
</a></h1>
42 <p>ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker
</p>
46 <h1><a name=
"description">DESCRIPTION
</a></h1>
47 <p>FAQs, tricks and tips for
<code>ExtUtils::MakeMaker
</code>.
</p>
50 <h2><a name=
"module_installation">Module Installation
</a></h2>
52 <dt><strong><a name=
"item_how_do_i_keep_from_installing_man_pages_3f">How do I keep from installing man pages?
</a></strong>
55 <p>Recent versions of MakeMaker will only install man pages on Unix like
56 operating systems.
</p>
59 <p>For an individual module:
</p>
63 perl Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none
</pre>
66 <p>If you want to suppress man page installation for all modules you have
67 to reconfigure Perl and tell it 'none' when it asks where to install
71 <dt><strong><a name=
"item_how_do_i_use_a_module_without_installing_it_3f">How do I use a module without installing it?
</a></strong>
74 <p>Two ways. One is to build the module normally...
</p>
82 <p>...and then set the PERL5LIB environment variable to point at the
83 blib/lib and blib/arch directories.
</p>
86 <p>The other is to install the module in a temporary location.
</p>
90 perl Makefile.PL PREFIX=~/tmp LIB=~/tmp/lib/perl
</pre>
93 <p>And then set PERL5LIB to
<em>~/tmp/lib/perl
</em>. This works well when you have
94 multiple modules to work with. It also ensures that the module goes
95 through its full installation process which may modify it.
</p>
101 <h2><a name=
"philosophy_and_history">Philosophy and History
</a></h2>
103 <dt><strong><a name=
"item_why_not_just_use__3cinsert_other_build_config_tool">Why not just use
<insert other build config tool here
>?
</a></strong>
106 <p>Why did MakeMaker reinvent the build configuration wheel? Why not
107 just use autoconf or automake or ppm or Ant or ...
</p>
110 <p>There are many reasons, but the major one is cross-platform
114 <p>Perl is one of the most ported pieces of software ever. It works on
115 operating systems I've never even heard of (see perlport for details).
116 It needs a build tool that can work on all those platforms and with
117 any wacky C compilers and linkers they might have.
</p>
120 <p>No such build tool exists. Even make itself has wildly different
121 dialects. So we have to build our own.
</p>
124 <dt><strong><a name=
"item_what_is_module_3a_3abuild_and_how_does_it_relate_t">What is Module::Build and how does it relate to MakeMaker?
</a></strong>
127 <p>Module::Build is a project by Ken Williams to supplant MakeMaker.
128 Its primary advantages are:
</p>
131 <li><strong><a name=
"item_pure_perl_2e_no_make_2c_no_shell_commands">pure perl. no make, no shell commands
</a></strong>
133 <li><strong><a name=
"item_easier_to_customize">easier to customize
</a></strong>
135 <li><strong><a name=
"item_cleaner_internals">cleaner internals
</a></strong>
137 <li><strong><a name=
"item_less_cruft">less cruft
</a></strong>
140 <p>Module::Build is the official heir apparent to MakeMaker and we
141 encourage people to work on M::B rather than spending time adding features
146 <h2><a name=
"module_writing">Module Writing
</a></h2>
148 <dt><strong><a name=
"item_how_do_i_keep_my__24version_up_to_date_without_res">How do I keep my $VERSION up to date without resetting it manually?
</a></strong>
151 <p>Often you want to manually set the $VERSION in the main module
152 distribution because this is the version that everybody sees on CPAN
153 and maybe you want to customize it a bit. But for all the other
154 modules in your dist, $VERSION is really just bookkeeping and all that's
155 important is it goes up every time the module is changed. Doing this
156 by hand is a pain and you often forget.
</p>
159 <p>Simplest way to do it automatically is to use your version control
160 system's revision number (you are using version control, right?).
</p>
163 <p>In CVS, RCS and SVN you use $Revision$ (see the documentation of your
164 version control system for details) writing it like so:
</p>
168 $VERSION = sprintf
"%d.%
03d
", q$Revision$ =~ /(\d+)/g;
</pre>
171 <p>Every time the file is checked in the $Revision$ will be updated,
172 updating your $VERSION.
</p>
175 <p>In CVS version
1.9 is followed by
1.10. Since CPAN compares version
176 numbers numerically we use a
<code>sprintf()
</code> to convert
1.9 to
1.009 and
177 1.10 to
1.010 which compare properly.
</p>
180 <p>If branches are involved (ie. $Revision:
1.5.3.4$) its a little more
185 # must be all on one line or MakeMaker will get confused.
186 $VERSION = do { my @r = (q$Revision$ =~ /\d+/g); sprintf
"%d.
".
"%
03d
" x $#r, @r };
</pre>
189 <dt><strong><a name=
"item_what_27s_this_meta_2eyml_thing_and_how_did_it_get_">What's this
<em>META.yml
</em> thing and how did it get in my
<em>MANIFEST
</em>?!
</a></strong>
192 <p><em>META.yml
</em> is a module meta-data file pioneered by Module::Build and
193 automatically generated as part of the 'distdir' target (and thus
194 'dist'). See
<a href=
"file://C|\msysgit\mingw\html/lib/ExtUtils/MakeMaker.html#module_metadata">Module Meta-Data in the ExtUtils::MakeMaker manpage
</a>.
</p>
197 <p>To shut off its generation, pass the
<code>NO_META
</code> flag to
<code>WriteMakefile()
</code>.
</p>
203 <h2><a name=
"xs">XS
</a></h2>
205 <dt><strong><a name=
"item_how_to_i_prevent__22object_version_x_2exx_does_not">How to I prevent ``object version X.XX does not match bootstrap parameter Y.YY'' errors?
</a></strong>
208 <p>XS code is very sensitive to the module version number and will
209 complain if the version number in your Perl module doesn't match. If
210 you change your module's version # without reruning Makefile.PL the old
211 version number will remain in the Makefile causing the XS code to be built
212 with the wrong number.
</p>
215 <p>To avoid this, you can force the Makefile to be rebuilt whenever you
216 change the module containing the version number by adding this to your
217 <code>WriteMakefile()
</code> arguments.
</p>
221 depend =
> { '$(FIRST_MAKEFILE)' =
> '$(VERSION_FROM)' }
</pre>
224 <dt><strong><a name=
"item_how_do_i_make_two_or_more_xs_files_coexist_in_the_">How do I make two or more XS files coexist in the same directory?
</a></strong>
227 <p>Sometimes you need to have two and more XS files in the same package.
228 One way to go is to put them into separate directories, but sometimes
229 this is not the most suitable solution. The following technique allows
230 you to put two (and more) XS files in the same directory.
</p>
233 <p>Let's assume that we have a package
<code>Cool::Foo
</code>, which includes
234 <code>Cool::Foo
</code> and
<code>Cool::Bar
</code> modules each having a separate XS
235 file. First we use the following
<em>Makefile.PL
</em>:
</p>
239 use ExtUtils::MakeMaker;
</pre>
244 NAME =
> 'Cool::Foo',
245 VERSION_FROM =
> 'Foo.pm',
246 OBJECT =
> q/$(O_FILES)/,
247 # ... other attrs ...
251 <p>Notice the
<code>OBJECT
</code> attribute. MakeMaker generates the following
252 variables in
<em>Makefile
</em>:
</p>
256 # Handy lists of source code files:
265 <p>Therefore we can use the
<code>O_FILES
</code> variable to tell MakeMaker to use
266 these objects into the shared library.
</p>
269 <p>That's pretty much it. Now write
<em>Foo.pm
</em> and
<em>Foo.xs
</em>,
<em>Bar.pm
</em>
270 and
<em>Bar.xs
</em>, where
<em>Foo.pm
</em> bootstraps the shared library and
271 <em>Bar.pm
</em> simply loading
<em>Foo.pm
</em>.
</p>
274 <p>The only issue left is to how to bootstrap
<em>Bar.xs
</em>. This is done
275 from
<em>Foo.xs
</em>:
</p>
279 MODULE = Cool::Foo PACKAGE = Cool::Foo
</pre>
284 # boot the second XS file
285 boot_Cool__Bar(aTHX_ cv);
</pre>
288 <p>If you have more than two files, this is the place where you should
289 boot extra XS files from.
</p>
292 <p>The following four files sum up all the details discussed so far.
</p>
298 package Cool::Foo;
</pre>
302 require DynaLoader;
</pre>
306 our @ISA = qw(DynaLoader);
307 our $VERSION = '
0.01';
308 bootstrap Cool::Foo $VERSION;
</pre>
318 package Cool::Bar;
</pre>
322 use Cool::Foo; # bootstraps Bar.xs
</pre>
332 #include
"EXTERN.h
"
333 #include
"perl.h
"
334 #include
"XSUB.h
"</pre>
338 MODULE = Cool::Foo PACKAGE = Cool::Foo
</pre>
343 # boot the second XS file
344 boot_Cool__Bar(aTHX_ cv);
</pre>
348 MODULE = Cool::Foo PACKAGE = Cool::Foo PREFIX = cool_foo_
</pre>
353 cool_foo_perl_rules()
</pre>
358 fprintf(stderr,
"Cool::Foo says: Perl Rules\n
");
</pre>
364 #include
"EXTERN.h
"
365 #include
"perl.h
"
366 #include
"XSUB.h
"</pre>
370 MODULE = Cool::Bar PACKAGE = Cool::Bar PREFIX = cool_bar_
</pre>
375 cool_bar_perl_rules()
</pre>
380 fprintf(stderr,
"Cool::Bar says: Perl Rules\n
");
</pre>
383 <p>And of course a very basic test:
</p>
390 BEGIN { plan tests =
> 1 };
393 Cool::Foo::perl_rules();
394 Cool::Bar::perl_rules();
398 <p>This tip has been brought to you by Nick Ing-Simmons and Stas Bekman.
</p>
405 <h1><a name=
"patching">PATCHING
</a></h1>
406 <p>If you have a question you'd like to see added to the FAQ (whether or
407 not you have the answer) please send it to
<a href=
"mailto:makemaker@perl.org.">makemaker@perl.org.
</a></p>
411 <h1><a name=
"author">AUTHOR
</a></h1>
412 <p>The denizens of
<a href=
"mailto:makemaker@perl.org.">makemaker@perl.org.
</a></p>
416 <h1><a name=
"see_also">SEE ALSO
</a></h1>
417 <p><a href=
"file://C|\msysgit\mingw\html/lib/ExtUtils/MakeMaker.html">the ExtUtils::MakeMaker manpage
</a></p>
418 <table border=
"0" width=
"100%" cellspacing=
"0" cellpadding=
"3">
419 <tr><td class=
"block" style=
"background-color: #cccccc" valign=
"middle">
420 <big><strong><span class=
"block"> ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker
</span></strong></big>