Recompile perl 5.8.7 with threading support

chris (2006-04-28 00:04:00)
4378 views
0 replies
Recompiling Perl is easy, but there are a couple of gotchas required to ensure that you don't mess up an existing perl installation. I have tried upgrading perl on a Redhat system in the past and made a mess of a whole pile of things, so generally it's simpler if you need a different version with support for different features to configure the new build with a different prefix and hence install a parallel perl build elsewhere and just symlink it in to a useful location. This time I'm using Slackware and these are the steps required to get a new perl installation running on your system:

first of all download the sources. I just downloaded them straight off the freshmeat tarball link:
cd /usr/src
wget http://freshmeat.net/redir/perl/7742/url_tgz/perl-5.8.7.tar.gz

now extract the archive and move into the new source directory:
tar -zxvf perl-5.8.7.tar.gz
cd perl-5.8.7

And this is the key to your new installation. The two configure options which we're going to use here are: -Dusethreads, which just means that you want threads support in your new build. The other option -Dprefix=/opt/perl5.8.2 indicates that we want to install perl under /opt/perl5.8.2. This way we can install our new perl version without affecting the existing system perl. One thing to note here is that during the configure stage you will be asked to accept a whole load of defaults. You can skip these simply by issuing '&-d' as your response (without the quotes). This will tell the script to just get on with the process and accept all defaults thereafter.
sh Configure -Dprefix=/opt/perl5.8.2 -Dusethreads
make && make test
su -c 'make install'

So the makefile is built and then perl is compiled and installed. At this stage you can test your new installations threading capability like this:
/opt/perl5.8.2/bin/perl -V| grep thread

You should see the following output:
    osname=linux, osvers=2.4.26, archname=i686-linux-thread-multi
    config_args='-Dprefix=/opt/perl5.8.2 -Dusethreads'
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    /opt/perl5.8.2/lib/5.8.7/i686-linux-thread-multi
    /opt/perl5.8.2/lib/site_perl/5.8.7/i686-linux-thread-multi

So there's a quick reminder that I should upgrade the kernel on my laptop at some time - and also confirmation that my perl build was successful.

The last thing to do if the system is used by other people is to make this new perl installation available to every body else.. All you need to do is symlink it in to the required location:
ln -s /opt/perl5.8.2/bin/perl5.8.7 /usr/bin/perl5.8.7

And that's all there is to it.. just remember to start your new scripts with the new shabang line: #!/usr/bin/perl5.8.7

Christo
comment