makemaker.html
来自「perl教程」· HTML 代码 · 共 1,694 行 · 第 1/5 页
HTML
1,694 行
</dd>
<dd>
<p>Overridable by PREFIX</p>
</dd>
</li>
<dt><strong><a name="item_sign">SIGN</a></strong>
<dd>
<p>When true, perform the generation and addition to the MANIFEST of the
SIGNATURE file in the distdir during 'make distdir', via 'cpansign
-s'.</p>
</dd>
<dd>
<p>Note that you need to install the Module::Signature module to
perform this operation.</p>
</dd>
<dd>
<p>Defaults to false.</p>
</dd>
</li>
<dt><strong><a name="item_skip">SKIP</a></strong>
<dd>
<p>Arrayref. E.g. [qw(name1 name2)] skip (do not write) sections of the
Makefile. Caution! Do not use the SKIP attribute for the negligible
speedup. It may seriously damage the resulting Makefile. Only use it
if you really need it.</p>
</dd>
</li>
<dt><strong><a name="item_typemaps">TYPEMAPS</a></strong>
<dd>
<p>Ref to array of typemap file names. Use this when the typemaps are
in some directory other than the current directory or when they are
not named <strong>typemap</strong>. The last typemap in the list takes
precedence. A typemap in the current directory has highest
precedence, even if it isn't listed in TYPEMAPS. The default system
typemap has lowest precedence.</p>
</dd>
</li>
<dt><strong><a name="item_vendorprefix">VENDORPREFIX</a></strong>
<dd>
<p>Like PERLPREFIX, but only for the vendor install locations.</p>
</dd>
<dd>
<p>Defaults to $Config{vendorprefixexp}.</p>
</dd>
<dd>
<p>Overridable by PREFIX</p>
</dd>
</li>
<dt><strong><a name="item_verbinst">VERBINST</a></strong>
<dd>
<p>If true, make install will be verbose</p>
</dd>
</li>
<dt><strong><a name="item_version">VERSION</a></strong>
<dd>
<p>Your version number for distributing the package. This defaults to
0.1.</p>
</dd>
</li>
<dt><strong><a name="item_version_from">VERSION_FROM</a></strong>
<dd>
<p>Instead of specifying the VERSION in the Makefile.PL you can let
MakeMaker parse a file to determine the version number. The parsing
routine requires that the file named by VERSION_FROM contains one
single line to compute the version number. The first line in the file
that contains the regular expression</p>
</dd>
<dd>
<pre>
/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/</pre>
</dd>
<dd>
<p>will be evaluated with <a href="../../lib/Pod/perlfunc.html#item_eval"><code>eval()</code></a> and the value of the named variable
<strong>after</strong> the <a href="../../lib/Pod/perlfunc.html#item_eval"><code>eval()</code></a> will be assigned to the VERSION attribute of the
MakeMaker object. The following lines will be parsed o.k.:</p>
</dd>
<dd>
<pre>
<span class="variable">$VERSION</span> <span class="operator">=</span> <span class="string">'1.00'</span><span class="operator">;</span>
<span class="variable">*VERSION</span> <span class="operator">=</span> <span class="operator">\</span><span class="string">'1.01'</span><span class="operator">;</span>
<span class="variable">$VERSION</span> <span class="operator">=</span> <span class="keyword">sprintf</span> <span class="string">"%d.%03d"</span><span class="operator">,</span> <span class="string">q$Revision: 4535 $</span> <span class="operator">=~</span> <span class="regex">/(\d+)/g</span><span class="operator">;</span>
<span class="variable">$FOO::VERSION</span> <span class="operator">=</span> <span class="string">'1.10'</span><span class="operator">;</span>
<span class="variable">*FOO::VERSION</span> <span class="operator">=</span> <span class="operator">\</span><span class="string">'1.11'</span><span class="operator">;</span>
<span class="keyword">our</span> <span class="variable">$VERSION</span> <span class="operator">=</span> <span class="number">1.2</span><span class="operator">.</span><span class="number">3</span><span class="operator">;</span> <span class="comment"># new for perl5.6.0</span>
</pre>
</dd>
<dd>
<p>but these will fail:</p>
</dd>
<dd>
<pre>
<span class="keyword">my</span> <span class="variable">$VERSION</span> <span class="operator">=</span> <span class="string">'1.01'</span><span class="operator">;</span>
<span class="keyword">local</span> <span class="variable">$VERSION</span> <span class="operator">=</span> <span class="string">'1.02'</span><span class="operator">;</span>
<span class="keyword">local</span> <span class="variable">$FOO::VERSION</span> <span class="operator">=</span> <span class="string">'1.30'</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<p>(Putting <a href="../../lib/Pod/perlfunc.html#item_my"><code>my</code></a> or <a href="../../lib/Pod/perlfunc.html#item_local"><code>local</code></a> on the preceding line will work o.k.)</p>
</dd>
<dd>
<p>The file named in VERSION_FROM is not added as a dependency to
Makefile. This is not really correct, but it would be a major pain
during development to have to rewrite the Makefile for any smallish
change in that file. If you want to make sure that the Makefile
contains the correct VERSION macro after any change of the file, you
would have to do something like</p>
</dd>
<dd>
<pre>
<span class="string">depend</span> <span class="operator">=></span> <span class="operator">{</span> <span class="string">Makefile</span> <span class="operator">=></span> <span class="string">'$(VERSION_FROM)'</span> <span class="operator">}</span>
</pre>
</dd>
<dd>
<p>See attribute <a href="#item_depend"><code>depend</code></a> below.</p>
</dd>
</li>
<dt><strong><a name="item_version_sym">VERSION_SYM</a></strong>
<dd>
<p>A sanitized VERSION with . replaced by _. For places where . has
special meaning (some filesystems, RCS labels, etc...)</p>
</dd>
</li>
<dt><strong><a name="item_xs">XS</a></strong>
<dd>
<p>Hashref of .xs files. MakeMaker will default this. e.g.</p>
</dd>
<dd>
<pre>
<span class="operator">{</span><span class="string">'name_of_file.xs'</span> <span class="operator">=></span> <span class="string">'name_of_file.c'</span><span class="operator">}</span>
</pre>
</dd>
<dd>
<p>The .c files will automatically be included in the list of files
deleted by a make clean.</p>
</dd>
</li>
<dt><strong><a name="item_xsopt">XSOPT</a></strong>
<dd>
<p>String of options to pass to xsubpp. This might include <code>-C++</code> or
<code>-extern</code>. Do not include typemaps here; the TYPEMAP parameter exists for
that purpose.</p>
</dd>
</li>
<dt><strong><a name="item_xsprotoarg">XSPROTOARG</a></strong>
<dd>
<p>May be set to an empty string, which is identical to <code>-prototypes</code>, or
<code>-noprototypes</code>. See the xsubpp documentation for details. MakeMaker
defaults to the empty string.</p>
</dd>
</li>
<dt><strong><a name="item_xs_version">XS_VERSION</a></strong>
<dd>
<p>Your version number for the .xs file of this package. This defaults
to the value of the VERSION attribute.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="additional_lowercase_attributes">Additional lowercase attributes</a></h2>
<p>can be used to pass parameters to the methods which implement that
part of the Makefile. Parameters are specified as a hash ref but are
passed to the method as a hash.</p>
<dl>
<dt><strong><a name="item_clean">clean</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">FILES</span> <span class="operator">=></span> <span class="string">"*.xyz foo"</span><span class="operator">}</span>
</pre>
</dd>
<dt><strong><a name="item_depend">depend</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">ANY_TARGET</span> <span class="operator">=></span> <span class="variable">ANY_DEPENDECY</span><span class="operator">,</span> <span class="operator">...}</span>
</pre>
</dd>
<dd>
<p>(ANY_TARGET must not be given a double-colon rule by MakeMaker.)</p>
</dd>
<dt><strong><a name="item_dist">dist</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">TARFLAGS</span> <span class="operator">=></span> <span class="string">'cvfF'</span><span class="operator">,</span> <span class="string">COMPRESS</span> <span class="operator">=></span> <span class="string">'gzip'</span><span class="operator">,</span> <span class="string">SUFFIX</span> <span class="operator">=></span> <span class="string">'.gz'</span><span class="operator">,</span>
<span class="string">SHAR</span> <span class="operator">=></span> <span class="string">'shar -m'</span><span class="operator">,</span> <span class="string">DIST_CP</span> <span class="operator">=></span> <span class="string">'ln'</span><span class="operator">,</span> <span class="string">ZIP</span> <span class="operator">=></span> <span class="string">'/bin/zip'</span><span class="operator">,</span>
<span class="string">ZIPFLAGS</span> <span class="operator">=></span> <span class="string">'-rl'</span><span class="operator">,</span> <span class="string">DIST_DEFAULT</span> <span class="operator">=></span> <span class="string">'private tardist'</span> <span class="operator">}</span>
</pre>
</dd>
<dd>
<p>If you specify COMPRESS, then SUFFIX should also be altered, as it is
needed to tell make the target file of the compression. Setting
DIST_CP to ln can be useful, if you need to preserve the timestamps on
your files. DIST_CP can take the values 'cp', which copies the file,
'ln', which links the file, and 'best' which copies symbolic links and
links the rest. Default is 'best'.</p>
</dd>
<dt><strong><a name="item_dynamic_lib">dynamic_lib</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">ARMAYBE</span> <span class="operator">=></span> <span class="string">'ar'</span><span class="operator">,</span> <span class="string">OTHERLDFLAGS</span> <span class="operator">=></span> <span class="string">'...'</span><span class="operator">,</span> <span class="string">INST_DYNAMIC_DEP</span> <span class="operator">=></span> <span class="string">'...'</span><span class="operator">}</span>
</pre>
</dd>
<dt><strong><a name="item_linkext">linkext</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">LINKTYPE</span> <span class="operator">=></span> <span class="string">'static'</span><span class="operator">,</span> <span class="string">'dynamic'</span> <span class="keyword">or</span> <span class="string">''</span><span class="operator">}</span>
</pre>
</dd>
<dd>
<p>NB: Extensions that have nothing but *.pm files had to say</p>
</dd>
<dd>
<pre>
<span class="operator">{</span><span class="string">LINKTYPE</span> <span class="operator">=></span> <span class="string">''</span><span class="operator">}</span>
</pre>
</dd>
<dd>
<p>with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line
can be deleted safely. MakeMaker recognizes when there's nothing to
be linked.</p>
</dd>
<dt><strong><a name="item_macro">macro</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">ANY_MACRO</span> <span class="operator">=></span> <span class="variable">ANY_VALUE</span><span class="operator">,</span> <span class="operator">...}</span>
</pre>
</dd>
<dt><strong><a name="item_postamble">postamble</a></strong>
<dd>
<p>Anything put here will be passed to MY::postamble() if you have one.</p>
</dd>
</li>
<dt><strong><a name="item_realclean">realclean</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">FILES</span> <span class="operator">=></span> <span class="string">'$(INST_ARCHAUTODIR)/*.xyz'</span><span class="operator">}</span>
</pre>
</dd>
<dt><strong><a name="item_test">test</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">TESTS</span> <span class="operator">=></span> <span class="string">'t/*.t'</span><span class="operator">}</span>
</pre>
</dd>
<dt><strong><a name="item_tool_autosplit">tool_autosplit</a></strong>
<dd>
<pre>
<span class="operator">{</span><span class="string">MAXLEN</span> <span class="operator">=></span> <span class="number">8</span><span class="operator">}</span>
</pre>
</dd>
</dl>
<p>
</p>
<h2><a name="overriding_makemaker_methods">Overriding MakeMaker Methods</a></h2>
<p>If you cannot achieve the desired Makefile behaviour by specifying
attributes you may define private subroutines in the Makefile.PL.
Each subroutine returns the text it wishes to have written to
the Makefile. To override a section of the Makefile you can
either say:</p>
<pre>
<span class="keyword">sub</span><span class="variable"> MY::c_o </span><span class="operator">{</span> <span class="string">"new literal text"</span> <span class="operator">}</span>
</pre>
<p>or you can edit the default by saying something like:</p>
<pre>
<span class="keyword">package</span> <span class="variable">MY</span><span class="operator">;</span> <span class="comment"># so that "SUPER" works right</span>
<span class="keyword">sub</span><span class="variable"> c_o </span><span class="operator">{</span>
<span class="keyword">my</span> <span class="variable">$inherited</span> <span class="operator">=</span> <span class="keyword">shift</span><span class="operator">-></span><span class="variable">SUPER::c_o</span><span class="operator">(</span><span class="variable">@_</span><span class="operator">);</span>
<span class="variable">$inherited</span> <span class="operator">=~</span> <span class="regex">s/old text/new text/</span><span class="operator">;</span>
<span class="variable">$inherited</span><span class="operator">;</span>
<span class="operator">}</span>
</pre>
<p>If you are running experiments with embedding perl as a library into
other applications, you might find MakeMaker is not sufficient. You'd
better have a look at ExtUtils::Embed which is a collection of utilities
for embedding.</p>
<p>If you still need a different solution, try to develop another
subroutine that fits your needs and submit the diffs to
<code>makemaker@perl.org</code></p>
<p>For a complete description of all MakeMaker methods see
<a href="../../lib/ExtUtils/MM_Unix.html">the ExtUtils::MM_Unix manpage</a>.</p>
<p>Here is a simple example of how to add a new target to the generated
Makefile:</p>
<pre>
<span class="keyword">sub</span><span class="variable"> MY::postamble </span><span class="operator">{</span>
<span class="keyword">return</span> <span class="operator"><<</span><span class="default">'MAKE_FRAG'</span><span class="operator">;</span><span class="string">
$(MYEXTLIB): sdbm/Makefile
cd sdbm && $(MAKE) all
</span>
</pre>
<pre>
MAKE_FRAG
}</pre>
<p>
</p>
<h2><a name="the_end_of_cargo_cult_programming">The End Of Cargo Cult Programming</a></h2>
<p><code>WriteMakefile()</code> now does some basic sanity checks on its parameters to
protect against typos and malformatted values. This means some things
which happened to work in the past will now throw warnings and
possibly produce internal errors.</p>
<p>Some of the most common mistakes:</p>
<dl>
<dt><strong><a name="item_man3pods__3d_3e__27__27"><code>MAN3PODS => ' '</code></a></strong>
<dd>
<p>This is commonly used to supress the creation of man pages. MAN3PODS
takes a hash ref not a string, but the above worked by accident in old
versions of MakeMaker.</p>
</dd>
<dd>
<p>The correct code is <code>MAN3PODS => { }</code>.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="hintsfile_support">Hintsfile support</a></h2>
<p>MakeMaker.pm uses the architecture specifi
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?