Linux にインストールされている Perl が /usr/bin/perl にあったりする。
他のバージョンを別のディレクトリにインストールすることで、複数のバージョンの Perl を共存させる。
今回は、/usr/local/perl-5.8.7 以下にインストールする。
perl 実行ファイルは /usr/local/perl-5.8.7/bin/perl となる。
perl の標準モジュールは /usr/local/perl-5.8.7/lib に入る。
Perl のインストール
インストール風景。
$ lynx http://ring.ocn.ad.jp/archives/CPAN/src/perl-5.8.7.tar.bz2
$ tar jcvf perl-5.8.7.tar.bz2
$ cd perl-5.8.7
$ ./configure.gnu --prefix=/usr/local/perl-5.8.7
$ make
make: [extras.make] Error 1 (ignored)
$ make test
All tests successful.
u=9.15 s=1.35 cu=503.69 cs=34.53 scripts=884 tests=99728
# make install
# exit
$ /usr/local/perl-5.8.7/bin/perl -v
This is perl, v5.8.7 built for i686-linux
Error が出たっぽいが、make test は通った……まぁ、いいか。
CPANの環境設定と追加モジュールのインストール
次に、必要なモジュールを追加するためにCPANの環境設定を行う。
以下のコマンドにて、いくつかの質問が表示される。
国の情報やCPANのFTPサーバのURLを入力する (Please enter your CPAN site: [] ftp://ftp.cpan.jp/CPAN/ ) 以外は、質問の回答はほぼデフォルト値。
# /usr/local/perl-5.8.7/bin/perl -MCPAN -e shell
以下のように、必要なモジュールをインストールする。
# /usr/local/perl-5.8.7/bin/perl -MCPAN -e shell
cpan> install XML::XPath
cpan> install XML::DOM
cpan> install XML::LibXML
cpan> install MIME::Base64
cpan> install XML::Atom
Perl をソースからインストールする前に読む文書
Perl をソースからインストールする際に、以下のファイルぐらいは読んでおきたい。
- README
- README.jp
- README.プラットフォーム名 (linuxは無いみたい)
- INSTALL
INSTALL より 標準的なインストール手順。
The basic steps to build and install perl5 on a Unix system with all the defaults are:
rm -f config.sh Policy.sh
sh Configure -de
make
make test
make install
INSTALL より GNU-style configure.
GNU-style configure
If you prefer the GNU-style configure command line interface, you can use the supplied configure.gnu command, e.g.
CC=gcc ./configure.gnu
The configure.gnu script emulates a few of the more common configure options. Try
./configure.gnu --help
for a listing.
(The file is called configure.gnu to avoid problems on systems that would not distinguish the files "Configure" and "configure".)
設定に関する内容は以下のコマンドで参照できる。
Configure を使って設定する場合は
$ ./Configure -h
configure.gnu を使って設定する場合は
$ ./configure.gnu --help
たぶん、以下の2つはほぼ同等の設定になると思う。
$ ./configure.gnu --prefix=/usr/local/perl-5.8.7
$ sh Configure -de -Dprefix=/usr/local/perl-5.8.7
./Configure -h より Configure のヘルプ。
Usage: Configure [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
[-U symbol] [-U symbol=] [-A command:symbol...]
-d : use defaults for all answers.
-e : go on without questioning past the production of config.sh.
-f : specify an alternate default configuration file.
-h : print this help message and exit (with an error status).
-r : reuse C symbols value if possible (skips costly nm extraction).
-s : silent mode, only echoes questions and essential information.
-D : define symbol to have some value:
-D symbol symbol gets the value 'define'
-D symbol=value symbol gets the value 'value'
-E : stop at the end of questions, after having produced config.sh.
-K : do not use unless you know what you are doing.
-O : let -D and -U override definitions from loaded configuration file.
-S : perform variable substitutions on all .SH files (can mix with -f)
-U : undefine symbol:
-U symbol symbol gets the value 'undef'
-U symbol= symbol gets completely empty
-A : manipulate symbol after the platform specific hints have been applied:
-A symbol=value append " "value to symbol
-A append:symbol=value append value to symbol
-A define:symbol=value define symbol to have value
-A clear:symbol define symbol to be ''
-A define:symbol define symbol to be 'define'
-A eval:symbol=value define symbol to be eval of value
-A prepend:symbol=value prepend value to symbol
-A undef:symbol define symbol to be 'undef'
-A undef:symbol= define symbol to be ''
-V : print version number and exit (with a zero status).
./configure.gnu --help より configure.gnu のヘルプ。
Usage: configure.gnu [options]
This is GNU configure-like front end for a metaconfig-generated Configure.
It emulates the following GNU configure options (must be fully spelled out):
--help
--no-create
--prefix=PREFIX
--cache-file (ignored)
--quiet
--silent
--verbose
--version
心残り
Perl で完結しないライブラリに依存している部分 (XML::LibXML → libxml2 とか) はよくわからないが、ライブラリも複数バージョンインストールしておくべきかも。参考
tags: zlashdot Perl Perl
Posted by NI-Lab. (@nilab)