Building CPAN Perl modules on Solaris 10
Why Solaris is different than Linux in this respect
Building
CPAN modules on Solaris might be a bit different than on your average Linux platform. Here is the reason why:
Solaris 10 comes pre-installed with Perl 5.8.4. This the good news. However, it has been built with Sun's Studio compiler suite. When
perl is built it saves the name of the compiler and any compiler flags in its configuration files, and then uses these saved settings when any additional modules are built. So when you try to build additional modules it will expect to find the Sun Studio compiler.
Solaris 10 comes pre-installed with GNU C/C++ compiler but the Sun Studio compiler is optional and is likely not installed.
Luckily Solaris comes with a tool called
perlgcc that fixes this problem. It will make sure that modules are build with gcc rather than the Sun Studio compiler. Instead of invoking
perl Makefile.PL to generate the makefile needed to compile a module,
perlgcc Makefile.PL should be used instead. All command-line arguments to perlgcc are passed unmodified to perl.
Needless to say you can forget all in this article if you have Sun Studio compiler installed and wish to use that for building modules. However most Perl modules have only been tested to compile with the GNU C/C++ compiler so if you do not want trouble stick with the recipe in this article.
Where to install Perl modules
During install you need to decide if you want to install CPAN modules into the standard system-wide location or to special location. There may be (at least) two reasons that you want to do the latter:
- You do not have privilege to install perl modules into the system-wide location.
- You wish to keep your default Perl installation clean and have a clear overview of what has been installed only for the sake of TWiki.
Note: The remainder of this document assumes that your want to install TWiki related Perl modules into /apps/twiki-root/perlmodules.
Manual install method
Note: The automated method described below is an aternative and is preferred. It will save you a lot of time.
These are the general steps to follow when installing a CPAN module manually on your TWiki host:
- Make sure
gcc can be found. On a default Solaris install the gcc is in /usr/sfw/bin. Add this to your path if it is not already there. Check using the which command.
- If you plan to install into a special location then you need to make sure Perl reads modules from this location before continue with the steps below. This is done by
$ PERL5LIB=$PERL5LIB:/apps/twiki-root/perlmodules
$ export PERL5LIB
- Download the package from CPAN and unpack into a temporary directory.
-
$ /usr/perl5/bin/perlgcc Makefile.PL LIB=/apps/twiki-root/perlmodules
-
$ /usr/sfw/bin/gmake MAKE=/usr/sfw/bin/gmake
-
$ /usr/sfw/bin/gmake MAKE=/usr/sfw/bin/gmake test
-
$ /usr/sfw/bin/gmake MAKE=/usr/sfw/bin/gmake install
- Remember to remove the temp directory.
- To view the modules installed in this special location, use
$ grep :: /apps/twiki-root/perlmodules/sun4-solaris-64int/perllocal.pod
Note how we force the make process to use GNU make rather than the Sun equivalent.
Automated install method (preferred)
These are the general steps to follow when installing a CPAN module automatically using the CPAN shell script. This script will automatically download, make and install Perl modules for you. It can use a range of different tools to download depending on what is installed on host. It can access the CPAN repository by either ftp or http.
The suggestion below is to use http to access the CPAN repository and force the shell script to use the
wget tool to download rather than any other alternative.
- Make sure
gcc can be found. On a default Solaris install the gcc is in /usr/sfw/bin. Add this to your path if it is not already there. Check using the which command.
- If you plan to install into a special location then you need to make sure Perl reads modules from this location before continue with the steps below. This is done by
$ PERL5LIB=$PERL5LIB:/apps/twiki-root/perlmodules
$ export PERL5LIB
Recommend to put the above into your login script.
- The following step will need to access the internet. Therefore make sure to let Solaris know your proxy settings (if any) beforehand:
$ http_proxy=myproxy:80; export http_proxy
- Start the CPAN shell script:
/usr/perl5/bin/perlgcc -MCPAN -e shell. If this is the first time this script is run it will ask a lot of questions and store the results in $HOME/.cpan/CPAN/MyConfig.pm. The file can edited by hand afterwards if need be. Here are some hints:
- Be sure to use GNU tools rather than Sun equivalents:
'make' => q[/usr/sfw/bin/gmake],
'tar' => q[/usr/sfw/bin/gtar],
- Make sure it uses wget and not anything else.
'ftp' => q[],
'ftp_proxy' => q[],
'lynx' => q[],
'ncftpget' => q[],
'urllist' => [q[http://www.cpan.dk/]],
'wget' => q[/usr/sfw/bin/wget],
- Set your proxy to access Internet (if required):
'http_proxy' => q[myproxy:80],
- Install into special location:
'makepl_arg' => q[LIB=/apps/twiki-root/perlmodules PREFIX=/apps/twiki-root/perlmodules INSTALLMAN3DIR=/apps/twiki-root/perlmodules/man/man3],
- Exit the script:
exit
The above was one time only. Now you are ready to install Perl modules the easy way:
- Start the CPAN shell script:
/usr/perl5/bin/perlgcc -MCPAN -e shell.
- Install a module, e.g.:
install CGI::Session
- Exit the shell script:
exit
--
Contributors: Lars Haarber - 30 March 2008
Discussion