Extracting and Compiling Perl

When you've successfully downloaded the Perl source code, extract it from its archive. There are two steps required to extract the Perl archive; decompressing it using gzip, and expanding the archive using tar. To unzip the file, use the following command:

gzip -d latest.tar.gz

Then, untar the file using this command:

tar xvf latest.tar

As the tar program runs, a list of all the files being extracted from the archive will be printed on the screen. Don't worry about the output. A directory named perl5.6.1 or something similar will be created with all the Perl files inside.

Detailed installation instructions can be found in the README and INSTALL files; I'll summarize the process in the following sections.

Running the Configure Program

Before you install Perl, run the Configure program to set up the compile-time options. First, cd to the Perl directory created when you untarred the archive (usually, perl plus a version number, for example, perl5.6.1). Then, remove any existing configuration file using

rm -f config.sh

(There might not be any existing configuration file, but don't worry about it.) Then run the Configure program like this:

sh Configure

Configure will ask you a lot of questions about the makeup of your system and where things should be installed. If you want to skip most of those questions, you can use sh Configure -d instead. This will cause Configure to automatically select as many default values as it can, and install Perl in various default locations typical for your platform. These instructions assume you want to run Configure the long way.

Note

Before we start, please be aware that Configure is written to configure software for all kinds of complex features of different platforms. Unless you're really very familiar with Unix systems and with C, a lot of the questions it asks might be really confusing or seem to make no sense. Most every question will have a default value, which you can accept by pressing Return or Enter. Generally, you'll do no harm by accepting Configure's default values, so if you don't know what the program is asking, just press Return.

Also, depending on the version of Perl you're installing, some of the following questions may or may not appear in a slightly different order. If things start to get confusing, just accept the defaults and you should be fine.


Setting Up

First, Configure ensures that you have some things necessary for the Perl installation, provides you with some instructions on the installation process (you can read them if you want to, but it's not necessary), and then locates some of the utilities used in the installation process.

To speed up the installation process, Configure guesses which system you're on so that it can set up some default values. Most likely, it'll guess right, so you can just press Enter and accept the default.

Then, it makes a guess at which operating system you're using. If the defaults are correct, just press Enter for both the name and version.

Depending on your Perl version, you might be asked if you want to build a threading version of Perl. Unless you know what you're doing, you're better off not building one right now because threads are experimental. When you know more about Perl you can go back and recompile it with threads turned on.

Directories and Basic Configuration

The next step, an important one, is to specify under which directory hierarchy Perl will be installed. The default is typically under the /usr/local hierarchy; binaries in /usr/local/bin, man pages in /usr/local/man, and libraries in /usr/local/lib. You can change the basic hierarchy where Perl is installed if you choose to do so; for example, to install them under /usr with the system files (/usr/bin/, /usr/lib, /usr/man). Just indicate a prefix here; if you want to customize where you put each part of Perl you'll have an opportunity to do that later.

The next directory you need to specify is the location for site-specific and architecture-dependent Perl libraries. If you've accepted the defaults for the other directory locations, accepting the defaults here are almost certainly okay.

Depending on the version of Perl you're installing, the next question might be whether you want Perl to be binary-compatible with Perl's earlier versions. If Perl 5.001 was installed on the machine you are currently installing Perl, you'll need to specify where to put the old architecture-dependent library files. For both these questions, the defaults are fine unless you have reason to change them.

configure then checks for secure setuid scripts, and you have a choice of whether to do setuid emulation. Chances are good that if you don't know what this means, you don't need it. Accept the default.

The next question is which memory models are supported on the machine; for most, it's none. Accept the default.

Compilers and Libraries

Configure asks you which compiler to use. It figures out which compiler it would prefer to use, and offers you that as the default.

Configure also figures out in which directories to look for libraries. If you know of other directories to search for shared libraries, add them to the list, and remove any directories that should not be searched from the list. The default will probably work here.

Configure asks for the file extension for shared libraries. If you don't want to use shared libraries, change the default to none. You probably don't want to change it, however.

Next, Configure checks for the presence of some specific libraries on your system. It presents you with a list of shared libraries it will use when it's done. You can add or remove libraries from the list, but the default list will probably work fine.

The Configure program then asks some questions about your compiler. If you don't specifically know a good reason to change the defaults, just go ahead and use them.

One of the compiler questions is where you want to store the Perl binaries. By default the choice is the prefix hierarchy you chose, plus the bin directory, for example, /usr/local/bin. You have the opportunity to change that here.

Documentation and Networking

After all the compiler-related questions are finished, Configure asks where you want to place the Perl man files. As with the binaries, the default is the directory prefix plus man. You'll only need to change it if you want to put the man page somewhere else on your system. It also asks for the extensions for your man pages; you should accept the default.

Configure then tries to determine your host and domain names. If it guesses right, you can accept the defaults. Otherwise, edit its choices and enter the correct values (the hostname is your fully-qualified Internet name for that particular system (for example, www.typerl.com); the domain name is the last part of the address (typerl.com).

The next question is your e-mail address. Perl will try to get the right e-mail address here, but it will be specific to the machine on which you are installing Perl. You might need to change it to your general e-mail address. (For example, it will probably select [email protected], when what you really want is [email protected].)

Perl also wants the e-mail address for the person who will be responsible for administration of Perl on the machine. If it's not you, enter the e-mail address for the person or group who will be responsible here (be nice).

Other Things

Next, Perl wants the value to place in the shebang line of scripts. The default value is almost certainly correct because you've already told Configure where the Perl binaries will be installed. (Don't worry if you don't know what a shebang is; you'll learn about that soon enough. Accept the defaults.)

Then, you need to tell Perl where to place publicly executable scripts. Reasons why you might not want to accept the default are provided by Configure.

Depending on your Perl version, you might be asked for yet more directory pathnames, this time for library files. Once again, the defaults are probably fine.

The next question is whether you want to use the experimental PerlIO abstraction layer instead of <stdio.h>. You probably don't.

Configure then checks for the presence of certain system calls, and for other system specific things. It might ask you a few questions along the way. You can probably accept the defaults for all these. Even if Configure seems to have misgivings (my Linux system triggered a few “WHOA THERE” and “Are you sure” messages), accept the defaults and you'll be fine.

The last questions Configure asks is which Perl extensions you want to load dynamically and statically. You can probably just accept the default, which is to load them all dynamically.

Perl then gives you a chance to edit the configuration file it just built, config.sh, manually. You probably don't need to do so; just press Return.

Configure gives you the chance to run make depend (go ahead), and then exits.

For detailed instructions on most of the options in the Configure program, you should read the INSTALL file in the Perl directory.

Run make

The next step after the Configure program generates the config.sh file is to type make in the Perl directory. make will compile all the Perl binaries and prepare them for installation.

On some systems, the ar program is required to build Perl. Unfortunately, for most users, ar is not in their path. If the make fails because it can't find ar, you should do a man ar, find out where it is located, and add that directory to your PATH environment variable (on Solaris systems, ar is in /usr/ccs/bin). You should then be able to run make again and successfully build Perl. It will take a while for the make process to work, so you might want to go do something else while it's working.)

Before you install Perl, you should type make test in the Perl directory to make sure everything was built correctly. After that's finished, you can make install to move all the Perl files to the locations that you specified using Configure.

One last question that might be asked is whether you want to link /usr/bin/perl to the location where you actually installed Perl. Many scripts assume that Perl will be located in /usr/bin/perl, so if you link your Perl binary to /usr/bin/perl, it could save you some work down the road.

After make install is finished, Perl should be installed and ready to go. This time, if you installed Perl in a standard location in your PATH, then this time if you type

% perl
							-v
						

you should get a version message (This is perl, version 5....), and you're all set and ready to learn Perl.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset