📄 ch24.htm
字号:
INTERN.h dump.c keywords.pl perl_exp.SH scope.h
<BR>
MANIFEST eg lib perlsh sv.c
<BR>
Makefile.SH emacs makeaperl.SH perly.c sv.h
<BR>
README embed.h makedepend.SH perly.c.diff t
<BR>
README.vms embed.pl makedir.SH perly.fixer taint.c
<BR>
Todo ext malloc.c perly.h toke.c
<BR>
XSUB.h form.h mg.c perly.y unixish.h
<BR>
av.c global.sym mg.h pod util.c
<BR>
av.h globals.c minimod.pl pp.c util.h
<BR>
cflags.SH gv.c miniperlmain.c pp.h utils
<BR>
config_H gv.h mv-if-diff pp_ctl.c vms
<BR>
config_h.SH h2pl myconfig pp_hot.c writemain.SH
<BR>
configpm handy.h op.c pp_sys.c x2p</FONT></TT>
</BLOCKQUOTE>
<HR>
<H3><A NAME="ConfiguringYourPerlDistribution"><B>Configuring Your
Perl Distribution</B></A></H3>
<P>
To configure your system, first run the <TT><FONT FACE="Courier">Configure</FONT></TT>
command in the <TT><FONT FACE="Courier">perl5</FONT></TT> directory
where your source files were untarred. The <TT><FONT FACE="Courier">Configure</FONT></TT>
command will figure out various settings about your system. <TT><FONT FACE="Courier">Configure</FONT></TT>
will be able to default to many settings by itself; for other
things it will ask you about. Figure 24.1 contains the output
from the <TT><FONT FACE="Courier">Configure</FONT></TT> command.
<P>
<A HREF="f24-1.gif" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/f24-1.gif" ><B>Figure 24.1 : </B><I>The output from a configure command.</I></A>
<P>
If the test scripts and programs run okay, the defaults are usually
right. <TT><FONT FACE="Courier">Configure</FONT></TT> will then
create a set of defaults for itself and then proceed to make three
files to store these sets of defaults: <TT><FONT FACE="Courier">config.h</FONT></TT>,
<TT><FONT FACE="Courier">config.sh</FONT></TT>, and <TT><FONT FACE="Courier">Makefile</FONT></TT>.
<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR VALIGN=TOP><TD ><B>Tip</B></TD></TR>
<TR VALIGN=TOP><TD >
<BLOCKQUOTE>
If your default shell is not <TT><FONT FACE="Courier">ksh</FONT></TT>, <TT><FONT FACE="Courier">bash</FONT></TT>, or the Bourne shell, <TT><FONT FACE="Courier">sh</FONT></TT>, you may have to enter the following command:
<BR>
<TT><FONT FACE="Courier">sh Configure<BR>
</FONT></TT>This step will ensure that <TT><FONT FACE="Courier">Configure</FONT></TT> is run under <TT><FONT FACE="Courier">sh</FONT></TT>.
</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<P>
If you feel lucky, run <TT><FONT FACE="Courier">Configure -d</FONT></TT>
to take all the defaults, and edit <TT><FONT FACE="Courier">config.sh</FONT></TT>
yourself to patch up any flaws. I do not recommend this course
of action unless you're a Perl wizard, in which case you probably
would have skipped this entire chapter.
<P>
The <TT><FONT FACE="Courier">Configure</FONT></TT> command supports
a lot of options. The one option to know about is the <TT><FONT FACE="Courier">-h</FONT></TT>
option, which prints a list of the available options for <TT><FONT FACE="Courier">Configure</FONT></TT>.
The options are useful in overriding any predefined values. For
example, you may have <TT><FONT FACE="Courier">cc</FONT></TT>'s
and GNU's compilers both on your system with <TT><FONT FACE="Courier">cc</FONT></TT>
as the default. To force <TT><FONT FACE="Courier">Configure</FONT></TT>
to use <TT><FONT FACE="Courier">gcc-elf</FONT></TT>, run the command
<TT><FONT FACE="Courier">Configure -Dcc=gcc-elf</FONT></TT>. Alternatively,
in the interactive mode, you can answer <TT><FONT FACE="Courier">gcc-elf</FONT></TT>
at the <TT><FONT FACE="Courier">cc</FONT></TT> prompt.
<P>
By default, Perl will be installed in the following directories:
<UL>
<LI><TT><FONT FACE="Courier">/usr/local/bin</FONT></TT>
<LI><TT><FONT FACE="Courier">/usr/local/lib</FONT></TT>
<LI><TT><FONT FACE="Courier">/usr/local/man</FONT></TT>
</UL>
<P>
You can specify a different directory for the default installation
location as long as you have read and write access to the directory.
The default directory pathname can be changed with the <TT><FONT FACE="Courier">-D</FONT></TT>
flag; for example, for specifying a pathname to a subdirectory
in my home directory I would use the command line option <TT><FONT FACE="Courier">-Dprefix='/home/khusain/perl5'</FONT></TT>.
The replacement for <TT><FONT FACE="Courier">/usr/local</FONT></TT>
is changed when you respond to the question of prefix in <TT><FONT FACE="Courier">Configure</FONT></TT>
script.
<P>
A couple of other points about running <TT><FONT FACE="Courier">Configure</FONT></TT>:
Do not reuse your old <TT><FONT FACE="Courier">config.h</FONT></TT>
or <TT><FONT FACE="Courier">config.SH</FONT></TT> file from a
previous version. Too many things may have changed. This is true
for patches to the Perl package as well. If you want to see some
differences, save a copy of the old file, rerun the <TT><FONT FACE="Courier">Configure</FONT></TT>
command, and then run a <TT><FONT FACE="Courier">diff</FONT></TT>
command to see the differences.
<P>
Actually, if you have some overrides that you want to use regardless
of those set up with <TT><FONT FACE="Courier">Configure</FONT></TT>,
you can put them in a file called <TT><FONT FACE="Courier">config.over</FONT></TT>.
This file can be used by <TT><FONT FACE="Courier">Configure</FONT></TT>
and overrides any values just before it writes the <TT><FONT FACE="Courier">config.sh</FONT></TT>
file. To get a head start, copy <TT><FONT FACE="Courier">config.sh</FONT></TT>
onto <TT><FONT FACE="Courier">config.over</FONT></TT>, and then
edit <TT><FONT FACE="Courier">config.over</FONT></TT>. The details
of this procedure are given in the <TT><FONT FACE="Courier">INSTALL</FONT></TT>
document.
<P>
Perl will use any dynamic extensions if your system supports them.
If you want to force Perl to be compiled and linked statically,
then you can choose this when <TT><FONT FACE="Courier">Configure</FONT></TT>
prompts you about it. Most of the later versions of Perl use dynamic
loading; therefore, if your system does not support it, consider
upgrading. See the section: "Linux: A Special Case for Perl
5," in this chapter to see what some of the issues are.
<P>
While you are running <TT><FONT FACE="Courier">Configure</FONT></TT>,
be patient. Answer each question after reading it carefully. Yes,
the defaults are great, but ultimately you are the one who has
to run Perl on your system. Make sure you know enough about your
system to know if the defaults look right or not.
<P>
If your system is not recognized, you'll most certainly have to
answer questions alertly. The <TT><FONT FACE="Courier">Configure</FONT></TT>
script tells you if it has recognized your system, as shown in
Figure 24.2.
<P>
<A HREF="f24-2.gif" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/f24-2.gif" ><B>Figure 24.2 : </B><I>Recognition of a computer system by the configure command.</I></A>
<P>
Also, do not hold down the Enter key or press it too many times.
The returns may remain queued and provide a default reply when
you really did not mean to.
<P>
There is no way to back up or re-enter all the information if
you make a mistake. You have to start the entire process all over
from the initial <TT><FONT FACE="Courier">Configure</FONT></TT>
command. Keep this in mind as you answer the questions. You can
backspace on the current line, but you cannot go back to the previous
prompt. The prompter will recognize <TT><FONT FACE="Courier">$*</FONT></TT>
as the entire default line should you want to append to the default
values given. Arguments to responses can also be referred to as
<TT><FONT FACE="Courier">$1</FONT></TT>, <TT><FONT FACE="Courier">$2</FONT></TT>,
and so on to keep you from too much typing or typographical errors.
<P>
Use <TT><FONT FACE="Courier">sh</FONT></TT> at least or some other
shell instead that looks like the Bourne shell for the purpose
of this installation. If you are bent on using your own version
of <TT><FONT FACE="Courier">csh</FONT></TT>, you'll have to copy
the sample file <TT><FONT FACE="Courier">config_H</FONT></TT>
to <TT><FONT FACE="Courier">config.h</FONT></TT>, and edit <TT><FONT FACE="Courier">config.h</FONT></TT>
to adapt to your shell.
<P>
Now would be a good time to peruse the <TT><FONT FACE="Courier">config.h</FONT></TT>
file to make sure that the system dependencies are correct. Most
of them are taken care of by running the <TT><FONT FACE="Courier">Configure</FONT></TT>
script, but this will give you some insight on how the configuration
sets everything up.
<P>
If you have any additional changes to make to the C definitions,
make them in the <TT><FONT FACE="Courier">cflags.SH</FONT></TT>
file. For example, to turn off the optimizer on <TT><FONT FACE="Courier">toke.c</FONT></TT>,
find the line in the switch structure for <TT><FONT FACE="Courier">toke.c</FONT></TT>
and put the command <TT><FONT FACE="Courier">optimize='-g'</FONT></TT>
before the double semicolons. By default, the value is set to
<TT><FONT FACE="Courier">$optdebug</FONT></TT>.
<P>
To change the C flags for all the files, edit <TT><FONT FACE="Courier">config.sh
</FONT></TT>and change either <TT><FONT FACE="Courier">$ccflags</FONT></TT>
or <TT><FONT FACE="Courier">$optimize</FONT></TT>. In order to
ensure that the changes you have made to these header files propagate
to all other programs, you must run the following command:
<BLOCKQUOTE>
<TT><FONT FACE="Courier">Configure -S ; make depend<BR>
</FONT></TT>
</BLOCKQUOTE>
<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR VALIGN=TOP><TD ><B>Tip</B></TD></TR>
<TR VALIGN=TOP><TD >
<BLOCKQUOTE>
Any changes you make to the configuration files will not be automatically propagated to the rest of the files-you must run <TT><FONT FACE="Courier">Configure -S</FONT></TT> and <TT><FONT FACE="Courier">make depend</FONT></TT> to ensure that all affected
files are updated.
</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<H3><A NAME="MakingDependencies"><B>Making Dependencies</B></A>
</H3>
<P>
After you've configured your Perl package for your system, you
must set up all the dependencies for the source files. This is
done by typing the command <TT><FONT FACE="Courier">make depend</FONT></TT>.
The make file looks for all the affected <TT><FONT FACE="Courier">include</FONT></TT>
files and modifies the <TT><FONT FACE="Courier">Makefile</FONT></TT>
accordingly.
<P>
The <TT><FONT FACE="Courier">Configure</FONT></TT> program will
offer to do this for you; you just have to answer Yes, as shown
in Figure 24.3. If you do not get this prompt, you can always
run it from the command line.
<P>
<A HREF="f24-3.gif" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/f24-3.gif" ><B>Figure 24.3 : </B><I>Running make depend from configure.</I></A>
<P>
Now, attempt to <TT><FONT FACE="Courier">make</FONT></TT> Perl
in the current directory. Run the <TT><FONT FACE="Courier">make</FONT></TT>
command from the prompt without any arguments. The execution of
this <TT><FONT FACE="Courier">make</FONT></TT> command will take
a while.
<P>
Generally speaking, you should encounter no errors. If you see
errors and if these errors impede the development of the platform,
the <TT><FONT FACE="Courier">make</FONT></TT> program will terminate.
If the errors are not critical or can be compensated for, <TT><FONT FACE="Courier">make</FONT></TT>
will continue and generate the correct files for you. Linux users
should refer to the online documentation on ELF in Linux.
<P>
No errors during the compile phase does not equal a clean build
in this case. Finish the entire procedure by testing the installation.
<P>
You may see some warnings, too. Again, this depends on the platform
on which you are building Perl. In most cases, the warnings can
be ignored. If you do see warnings about <TT><FONT FACE="Courier">LITTLE_ENDIAN</FONT></TT>
being redefined, ignore them. For your peace of mind, you might
want to check the definitions of <TT><FONT FACE="Courier">LITTLE_ENDIAN</FONT></TT>
in the files that the <TT><FONT FACE="Courier">make</FONT></TT>
file warns you about. Both the declarations should be the same-that
is, either 1234 or 4321, depending on the type of machine you
happen to be building the version of Perl on.
<P>
The <TT><FONT FACE="Courier">gcc</FONT></TT> compilers installed
in your system should be able to handle the Perl distribution
with only a few burps. For example, some function prototypes might
not be recognized by the compiler. There is a way to counter some
of these errors. For instance, try adding a <TT><FONT FACE="Courier">-DCRIPPLED_cc</FONT></TT>
flag. You might even consider turning off the <TT><FONT FACE="Courier">-O2</FONT></TT>
optimization flag in <TT><FONT FACE="Courier">config.sh</FONT></TT>
in your compiler.
<P>
If you get duplicate function definitions (a Perl function has
the same name as another function on your system), try using the
<TT><FONT FACE="Courier">-DEMBED</FONT></TT> switch to get rid
of the error. These errors are rare, but not impossible to come
by.
<P>
The worst error you could run into is an incomplete distribution.
In this case, the only recourse you have is to abandon all efforts
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -