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

151 lines
7.3 KiB
HTML

<html lang="en">
<head>
<title>Perl and Perl 5 Modules - Stow</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Stow">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Compile_002dtime-vs-Install_002dtime.html#Compile_002dtime-vs-Install_002dtime" title="Compile-time vs Install-time">
<link rel="prev" href="Cygnus-Software.html#Cygnus-Software" title="Cygnus Software">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual describes GNU Stow version 2.2.2
(9 November 2015), a program for managing the installation of software
packages.
Software and documentation is copyrighted by the following:
(C) 1993, 1994, 1995, 1996 Bob Glickstein <bobg+stow@zanshin.com>
(C) 2000, 2001 Guillaume Morin <gmorin@gnu.org>
(C) 2007 Kahlil (Kal) Hodgson <kahlil@internode.on.net>
(C) 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.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Perl-and-Perl-5-Modules"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="Cygnus-Software.html#Cygnus-Software">Cygnus Software</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Compile_002dtime-vs-Install_002dtime.html#Compile_002dtime-vs-Install_002dtime">Compile-time vs Install-time</a>
<hr>
</div>
<h3 class="section">12.5 Perl and Perl 5 Modules</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's
experience that allows this, though hopefully more packages will adopt
this model.
<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's predecessor, originated at
Carnegie Mellon University, which was also the birthplace of AFS. CMU's
need to separate install-time and run-time trees stemmed from its use of
Depot, not from AFS.
<p>The result of this confusion is that Perl 5's configuration script
doesn't even offer the option of separating install-time and run-time
trees <em>unless</em> you're running AFS. Fortunately, after you've
entered all the configuration settings, Perl's setup script gives you
the opportunity to edit those settings in a file called
<samp><span class="file">config.sh</span></samp>. When prompted, you should edit this file and replace
occurrences of
<pre class="example"> inst<span class="roman">...</span>/usr/local<span class="roman">...</span>
</pre>
<p class="noindent">with
<pre class="example"> inst<span class="roman">...</span>/usr/local/stow/perl<span class="roman">...</span>
</pre>
<p class="noindent">You can do this with the following Unix command:
<pre class="example"> sed 's,^\(inst.*/usr/local\),\1/stow/perl,' config.sh &gt; config.sh.new
mv config.sh.new config.sh
</pre>
<p>Hopefully, the Perl authors will correct this deficiency in Perl 5's
configuration mechanism.
<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><span class="file">Makefile.PL</span></samp>, which is a Perl
script. When it runs, it generates a <samp><span class="file">Makefile</span></samp>.
<p>If you followed the instructions above for editing <samp><span class="file">config.sh</span></samp> when
Perl was built, then when you create a <samp><span class="file">Makefile</span></samp> from a
<samp><span class="file">Makefile.PL</span></samp>, it will contain separate locations for run-time
(<samp><span class="file">/usr/local</span></samp>) and install-time (<samp><span class="file">/usr/local/stow/perl</span></samp>).
Thus you can do
<pre class="example"> perl Makefile.PL
make
make install
</pre>
<p class="noindent">and the files will be installed into <samp><span class="file">/usr/local/stow/perl</span></samp>.
However, you might prefer each Perl module to be stowed separately. In
that case, you must edit the resulting Makefile, replacing
<samp><span class="file">/usr/local/stow/perl</span></samp> with <samp><span class="file">/usr/local/stow/</span><var>module</var></samp>.
The best way to do this is:
<pre class="example"> perl Makefile.PL
find . -name Makefile -print | \
xargs perl -pi~ -e 's,^(INST.*/stow)/perl,$1/<var>module</var>,;'
make
make install
</pre>
<p class="noindent">(The use of &lsquo;<samp><span class="samp">find</span></samp>&rsquo; and &lsquo;<samp><span class="samp">xargs</span></samp>&rsquo; ensures that all Makefiles in
the module's source tree, even those in subdirectories, get edited.) A
good convention to follow is to name the stow directory for a Perl
<var>module</var> <samp><span class="file">cpan.</span><var>module</var></samp>, where &lsquo;<samp><span class="samp">cpan</span></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's easy to tell at a
glance which of the subdirectories of <samp><span class="file">/usr/local/stow</span></samp> are Perl 5
extensions.
<p>When you stow separate Perl 5 modules separately, you are likely to
encounter conflicts (see <a href="Conflicts.html#Conflicts">Conflicts</a>) with files named <samp><span class="file">.exists</span></samp>
and <samp><span class="file">perllocal.pod</span></samp>. One way to work around this is to remove
those files before stowing the module. If you use the
<samp><span class="file">cpan.</span><var>module</var></samp> naming convention, you can simply do this:
<pre class="example"> cd /usr/local/stow
find cpan.* \( -name .exists -o -name perllocal.pod \) -print | \
xargs rm
</pre>
<!-- -->
</body></html>