Hack 67. Build Your Own Perl


Compile Perl just the way you like it.

Perl has so many features that no single binary can do everything everyone wants. If you're debugging XS code, you might want to enable debugging. If you like to experiment, you might want to enable threads. If you need to run Perl on an odd platform where memory or disk space are low, you might want to disable certain features and core modules. You might even want an experimental patch that adds type information (autobox on the CPAN) or the defined-or operator (dor on the CPAN). You might also want to patch Perl yourself or help test out a development release.

Whatever the case, building your own Perl is reasonably easy.

The Hack

Before you start, you need a working C development environment with a compiler, system headers, and a Make utility.

First, download Perl. The latest version is always available from the CPAN at http://www.cpan.org/src/. Stable versions have even minor version numbers (Perl 5.6.x, Perl 5.8.x, Perl 5.10.x) while development versions have odd minor numbers (Perl 5.7.x, Perl 5.9.x). Unless you are ready to report and possibly debug bugs, choose a stable version.

After you have downloaded and unpacked the distribution, change to the new directory. To configure the default build, simply run the Configure file:

$ sh Configure -de             

You don't have to use the -de flag, but the configuration will prompt you for multitudinous options that few people care about and fewer still all understand. However, some options are useful.

To install Perl to a different root directory, use the -Dprefix option. For example, if you want to test Perl 5.9.3 and install it to /usr/local/bleadperl-5.9.3, use the flag -Dprefix=/usr/local/bleadperl-5.9.3.

If you already have a system Perl installed, some of the OS utilities might rely on it. In this case, build and install a parallel Perl rather than overwrite an installed version.


To build a development release, pass the -Dusedevel flag.

To enable threads, use the -Dusethreads flag.

To enable debugging of the perl binary itself, pass the -Doptimize='g' flag.

To see the other configuration options, run:

$ sh Configure -h             

Running the Hack

Now you have Perl configured and can build it. Building is as simple as running your Make utility, usually make but sometimes gmake:

$ make             

If everything goes well, you will have a perl binary in a few minutes, along with compiled versions of the necessary core libraries in lib/. Then, run the core tests:

$ make test             

Everything should pass. If not, check the appropriate README.* file for your platform to see if there are any expected failures.

If there are failures, or if you're building a development release, consider using the perlbug utility built with this Perl to report the failures:

$ ./perlbug -nok             

Use the -ok flag instead to report success of a development release.


If you can't send mail from this system, send the output to a file with the -f switch:

$ ./perlbug -nok -f build.failure             

Then mail the file to perlbug@perl.org.

If everything is to your expectation, install your new Perl with:

$ make install             

Switch to the root user or use sudo as necessary, depending on your installation prefix.

Hacking the Hack

The INSTALL file in the source distribution contains the most information about building and installing Perl, as well as reporting any bugs to the Perl 5 Porters. If you run into trouble, read that file for answers. The numerous README.* files contain platform-specific information that affects how Perl builds and runs (read them with perldoc or your favorite pager).

To hack on Perl itself, start by reading pod/perlhack.pod in the source directory. This also gives the rsync command used to access the very latest sources, as well as instructions on sending patches.



Perl Hacks
Perl Hacks: Tips & Tools for Programming, Debugging, and Surviving
ISBN: 0596526741
EAN: 2147483647
Year: 2004
Pages: 141

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net