homebrewでperlをインストールしようとして、できなくて困ってる件→できた??

brew search perlしてみても、perlの最新版って用意されてないみたいで、なんだかなぁと思っていて、やっぱりMacPortsに戻そうか?と思っていたんだけれど、「MacPortsからhomebrewに乗り換えてみた - shtaxxx weblog」によると、brewって簡単にパッケージを作ることができるんですね。なるほど。
早速、やってみた。

% brew create http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz
Version detected as 5.14.1.
==> Downloading http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz
######################################################################## 100.0%
Please `brew audit perl` before submitting, thanks.
% brew audit perl
perl:
 * The homepage should start with http or https.
 * Commented cmake support found.
 * Commented-out dep 'cmake'.
% 

ここで、/usr/local/Library/Formula/perl.rb というファイル見てみた。たしかに、メッセージに出てるように、cmake 関連がcomment outされてる。なるほど。

require 'formula'

class Perl < Formula
  url 'http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz'
  homepage ''
  md5 '0b74cffa3a10aee08442f950aecbaeec'

  # depends_on 'cmake'

  def install
    system "./configure", "--disable-debug", "--disable-dependency-tracking",
                          "--prefix=#{prefix}"
    # system "cmake . #{std_cmake_parameters}"
    system "make install"
  end
end

続きを。

% brew install perl
==> Downloading http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz
File already downloaded in /Users/fukuit/Library/Caches/Homebrew
==> ./configure --disable-debug --prefix=/usr/local/Cellar/perl/5.14.1
configure: unknown option --disable-debug
configure: unknown option --prefix=/usr/local/Cellar/perl/5.14.1
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'
       common used examples (see INSTALL for more info):
         -Duse64bitint            use 64bit integers
         -Duse64bitall            use 64bit integers and pointers
         -Dusethreads             use thread support
         -Dinc_version_list=none  do not include older perl trees in @INC
         -DEBUGGING=none          DEBUGGING options
         -Dcc=gcc                 choose your compiler
         -Dprefix=/opt/perl5      choose your destination
  -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
       e.g.:  -Uversiononly
  -A : manipulate symbol after the platform specific hints have been applied:
         -A append:symbol=value   append value to symbol
         -A symbol=value          like append:, but with a separating space
         -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 ''
       e.g.:  -A prepend:libswanted='cl pthread '
              -A ccflags=-DSOME_MACRO
  -V : print version number and exit (with a zero status).
==> Exit Status: 1
http://github.com/mxcl/homebrew/blob/master/Library/Formula/perl.rb#L11
==> Environment
HOMEBREW_VERSION: 0.8
HEAD: e38b28668c1a911522cbbede516155d06b6cc488
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: dual-core 64-bit core2
OS X: 10.6.8
Kernel Architecture: i386
Ruby: 1.8.7-174
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 3.2.4
GCC-4.0: build 5494 
GCC-4.2: build 5664 
LLVM: build 2326 
MacPorts or Fink? false
X11 installed? true
==> Build Flags
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -march=core2 -w -pipe
CXXFLAGS: -O3 -march=core2 -w -pipe
MAKEFLAGS: -j2

Error: Failed executing: ./configure --disable-debug --prefix=/usr/local/Cellar/perl/5.14.1
Please report this bug: https://github.com/mxcl/homebrew/wiki/Checklist-before-filing-a-new-issue
These existing issues may help you:
https://github.com/mxcl/homebrew/issues/#issue/4716
https://github.com/mxcl/homebrew/issues/#issue/5180
https://github.com/mxcl/homebrew/issues/#issue/5538
https://github.com/mxcl/homebrew/issues/#issue/5737
https://github.com/mxcl/homebrew/issues/#issue/6010
https://github.com/mxcl/homebrew/issues/#issue/6363
https://github.com/mxcl/homebrew/issues/#issue/7081
https://github.com/mxcl/homebrew/issues/#issue/7091
https://github.com/mxcl/homebrew/issues/#issue/7109
It looks like an autotools configure failed.
Consider re-running the install with '-vd' to keep 'config.log' around:
    brew install -vd perl
Gist 'config.log' and any error output when reporting an issue.
Remember to include your config information: brew --config

Also try:
  `brew doctor` to check your setup for common problems.
  `brew missing` to check installed packages for missing deps.
% 

あかんがな。これは、たしかにあり得るかも。perlなんて最後に自分でsourceからbuildした経験なんて、perl5.0.4くらいのような気がするけれど、configureじゃなくて、Configureだった気がするし、対話的にあれこれ入力する必要があったと思う。

configure: unknown option --disable-debug
configure: unknown option --prefix=/usr/local/Cellar/perl/5.14.1

ちょっと、どうすりゃ良いのかよく分からんので、放置。

perl.rbを編集する

perl.rbを編集して、perlのConfigureに対応させた。

require 'formula'

class Perl < Formula
  url 'http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz'
  homepage ''
  md5 '0b74cffa3a10aee08442f950aecbaeec'

  # depends_on 'cmake'

  def install
    system "./Configure", "-des", "-Dprefix=#{prefix}"
    # system "cmake . #{std_cmake_parameters}"
    system "make install"
  end
end

なんのことはない、./configureを./Configureにして、--prefixを-Dprefixにして、、、と、perlをbuildする時のお作法に合わせただけだ。
そしたら、ちゃんとbuildできて、インストールも完了した。
なんかman_dirに関してメッセージも表示されたが、細かいことは気にしないことにする。

% brew install perl
==> Downloading http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz
File already downloaded in /Users/fukuit/Library/Caches/Homebrew
==> ./Configure -des -Dprefix=/usr/local/Cellar/perl/5.14.1
==> make install
Warning: A top-level "man" folder was found.
Homebrew requires that man pages live under share.
This can often be fixed by passing "--mandir=#{man}" to configure.
==> Summary
/usr/local/Cellar/perl/5.14.1: 3056 files, 62M, built in 9.4 minutes

できたっぽいと思いきや

% /usr/local/bin/perl -MCPAN -eshell
Can't load '/usr/local/Cellar/perl/5.14.1/lib/5.14.1/darwin-2level/auto/Fcntl/Fcntl.bundle' for module Fcntl: dlopen(/usr/local/Cellar/perl/5.14.1/lib/5.14.1/darwin-2level/auto/Fcntl/Fcntl.bundle, 1): Symbol not found: _PL_curcop
  Referenced from: /usr/local/Cellar/perl/5.14.1/lib/5.14.1/darwin-2level/auto/Fcntl/Fcntl.bundle
  Expected in: dynamic lookup
 at /usr/local/Cellar/perl/5.14.1/lib/5.14.1/darwin-2level/Fcntl.pm line 66
Compilation failed in require at /usr/local/Cellar/perl/5.14.1/lib/5.14.1/CPAN/FTP.pm line 6.
BEGIN failed--compilation aborted at /usr/local/Cellar/perl/5.14.1/lib/5.14.1/CPAN/FTP.pm line 6.
Compilation failed in require at /usr/local/Cellar/perl/5.14.1/lib/5.14.1/CPAN.pm line 27.
BEGIN failed--compilation aborted at /usr/local/Cellar/perl/5.14.1/lib/5.14.1/CPAN.pm line 27.
Compilation failed in require.
BEGIN failed--compilation aborted.

うーん。まだまだ道は長そうだ。