stow/dot-local/share/doc/stow/manual-split/Perl-and-Perl-5-Modules.html

179 lines
7.8 KiB
HTML

<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual describes GNU Stow version 2.3.2-fixbug56727
(2 November 2023), a program for managing farms of symbolic links.
Software and documentation is copyrighted by the following:
© 1993, 1994, 1995, 1996 Bob Glickstein <bobg+stow@zanshin.com>
© 2000, 2001 Guillaume Morin <gmorin@gnu.org>
© 2007 Kahlil (Kal) Hodgson <kahlil@internode.on.net>
© 2011 Adam Spiers <stow@adamspiers.org>
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
section entitled "GNU General Public License" is included with the
modified manual, and provided that the entire resulting derived work is
distributed under the terms of a permission notice identical to this
one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation
approved by the Free Software Foundation. -->
<title>Perl and Perl 5 Modules (Stow)</title>
<meta name="description" content="Perl and Perl 5 Modules (Stow)">
<meta name="keywords" content="Perl and Perl 5 Modules (Stow)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Index.html" rel="index" title="Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Compile_002dtime-vs-Install_002dtime.html" rel="up" title="Compile-time vs Install-time">
<link href="Cygnus-Software.html" rel="prev" title="Cygnus Software">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span.r {font-family: initial; font-weight: normal; font-style: normal}
span:hover a.copiable-link {visibility: visible}
-->
</style>
</head>
<body lang="en">
<div class="section-level-extent" id="Perl-and-Perl-5-Modules">
<div class="nav-panel">
<p>
Previous: <a href="Cygnus-Software.html" accesskey="p" rel="prev">Cygnus Software</a>, Up: <a href="Compile_002dtime-vs-Install_002dtime.html" accesskey="u" rel="up">Compile-time vs Install-time</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Perl-and-Perl-5-Modules-1"><span>12.5 Perl and Perl 5 Modules<a class="copiable-link" href="#Perl-and-Perl-5-Modules-1"> &para;</a></span></h3>
<p>Perl 4.036 allows you to specify different locations for installation
and for run-time. It is the only widely-used package in this author&rsquo;s
experience that allows this, though hopefully more packages will adopt
this model.
</p>
<p>Unfortunately, the authors of Perl believed that only AFS sites need
this ability. The configuration instructions for Perl 4 misleadingly
state that some occult means are used under AFS to transport files from
their installation tree to their run-time tree. In fact, that confusion
arises from the fact that Depot, Stow&rsquo;s predecessor, originated at
Carnegie Mellon University, which was also the birthplace of AFS. CMU&rsquo;s
need to separate install-time and run-time trees stemmed from its use of
Depot, not from AFS.
</p>
<p>The result of this confusion is that Perl 5&rsquo;s configuration script
doesn&rsquo;t even offer the option of separating install-time and run-time
trees <em class="emph">unless</em> you&rsquo;re running AFS. Fortunately, after you&rsquo;ve
entered all the configuration settings, Perl&rsquo;s setup script gives you
the opportunity to edit those settings in a file called
<samp class="file">config.sh</samp>. When prompted, you should edit this file and replace
occurrences of
</p>
<div class="example">
<pre class="example-preformatted">inst<span class="r">...</span>/usr/local<span class="r">...</span>
</pre></div>
<p>with
</p>
<div class="example">
<pre class="example-preformatted">inst<span class="r">...</span>/usr/local/stow/perl<span class="r">...</span>
</pre></div>
<p>You can do this with the following Unix command:
</p>
<div class="example">
<pre class="example-preformatted">sed 's,^\(inst.*/usr/local\),\1/stow/perl,' config.sh &gt; config.sh.new
mv config.sh.new config.sh
</pre></div>
<p>Hopefully, the Perl authors will correct this deficiency in Perl 5&rsquo;s
configuration mechanism.
</p>
<p>Perl 5 modules&mdash;i.e., extensions to Perl 5&mdash;generally conform to a set
of standards for building and installing them. The standard says that
the package comes with a top-level <samp class="file">Makefile.PL</samp>, which is a Perl
script. When it runs, it generates a <samp class="file">Makefile</samp>.
</p>
<p>If you followed the instructions above for editing <samp class="file">config.sh</samp> when
Perl was built, then when you create a <samp class="file">Makefile</samp> from a
<samp class="file">Makefile.PL</samp>, it will contain separate locations for run-time
(<samp class="file">/usr/local</samp>) and install-time (<samp class="file">/usr/local/stow/perl</samp>).
Thus you can do
</p>
<div class="example">
<pre class="example-preformatted">perl Makefile.PL
make
make install
</pre></div>
<p>and the files will be installed into <samp class="file">/usr/local/stow/perl</samp>.
However, you might prefer each Perl module to be stowed separately. In
that case, you must edit the resulting Makefile, replacing
<samp class="file">/usr/local/stow/perl</samp> with <samp class="file">/usr/local/stow/<var class="var">module</var></samp>.
The best way to do this is:
</p>
<div class="example">
<pre class="example-preformatted">perl Makefile.PL
find . -name Makefile -print | \
xargs perl -pi~ -e 's,^(INST.*/stow)/perl,$1/<var class="var">module</var>,;'
make
make install
</pre></div>
<p>(The use of &lsquo;<samp class="samp">find</samp>&rsquo; and &lsquo;<samp class="samp">xargs</samp>&rsquo; ensures that all Makefiles in
the module&rsquo;s source tree, even those in subdirectories, get edited.) A
good convention to follow is to name the stow directory for a Perl
<var class="var">module</var> <samp class="file">cpan.<var class="var">module</var></samp>, where &lsquo;<samp class="samp">cpan</samp>&rsquo; stands for
Comprehensive Perl Archive Network, a collection of FTP sites that is
the source of most Perl 5 extensions. This way, it&rsquo;s easy to tell at a
glance which of the subdirectories of <samp class="file">/usr/local/stow</samp> are Perl 5
extensions.
</p>
<p>When you stow separate Perl 5 modules separately, you are likely to
encounter conflicts (see <a class="pxref" href="Conflicts.html">Conflicts</a>) with files named <samp class="file">.exists</samp>
and <samp class="file">perllocal.pod</samp>. One way to work around this is to remove
those files before stowing the module. If you use the
<samp class="file">cpan.<var class="var">module</var></samp> naming convention, you can simply do this:
</p>
<div class="example">
<pre class="example-preformatted">cd /usr/local/stow
find cpan.* \( -name .exists -o -name perllocal.pod \) -print | \
xargs rm
</pre></div>
</div>
<hr>
<div class="nav-panel">
<p>
Previous: <a href="Cygnus-Software.html">Cygnus Software</a>, Up: <a href="Compile_002dtime-vs-Install_002dtime.html">Compile-time vs Install-time</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>