MacRubyの最新版をソースコードからインストールには
ここでは、ソースコードからMacRubyの最新版※1をインストールする方法を説明します。ただし、2009年10月3日現在における手順ですので、今後変更の可能性があります。インストールできないという方は、著者(kouji at takao7.net)にご連絡いただけると助かります。
※1:最新版のことをtrunkと呼ぶことがあります。MacRubyはSubversionというソフトウェアを使ってソースコードを管理しています。そして、最新版をtrunkというディレクトリに配置しています。このため、trunkと呼ばれます。
【STEP 1】MacRubyの最新版のソースコードをダウンロードします。ターミナルで以下のコマンドを実行します。しばらくすると、書類フォルダ(/Users/<ユーザ名>/Documentsフォルダ)にMacRuby-trunkというフォルダが作成され、MacRubyの最新版のソースコードがダウンロードされます。
$ cd ~/Documents $ svn co http://svn.macosforge.org/repository/ruby/MacRuby/trunk MacRuby-trunk (以下、実行結果) A MacRuby-trunk/test-macruby A MacRuby-trunk/test-macruby/test_helper.rb A MacRuby-trunk/test-macruby/fixtures 〜省略〜 A MacRuby-trunk/id.c U MacRuby-trunk Checked out revision 2709.
以降の作業は、MacRuby-trunkフォルダにあるREADME.rdocファイルに従って行います。
【STEP 2】LLVM※2をインストールします。まずは、以下のコマンドを実行して書類フォルダにLLVMのソースコードをダウンロードします。
※2:http://ja.wikipedia.org/wiki/Low_Level_Virtual_Machine
$ cd ~/Documents $ svn co -r 82747 https://llvm.org/svn/llvm-project/llvm/trunk llvm-trunk (以下、実行結果) A llvm-trunk/ModuleInfo.txt A llvm-trunk/test A llvm-trunk/test/TableGen 〜省略〜 A llvm-trunk/examples/Makefile U llvm-trunk Checked out revision 82747.
次に、以下のコマンドを実行してLLVMをコンパイルします。
$ cd llvm-trunk $ ./configure (以下、実行結果) checking build system type... i386-apple-darwin9.8.0 checking host system type... i386-apple-darwin9.8.0 checking target system type... i386-apple-darwin9.8.0 〜省略〜 config.status: executing lib/sample/Makefile commands config.status: executing tools/Makefile commands config.status: executing tools/sample/Makefile commands (CPUのコアが1つの場合) $ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make (CPUのコアが2つの場合はこちらをオススメします) $ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make -j2 (以下、実行結果) llvm[1]: Compiling Alarm.cpp for Release build g++ -I/Users/kouji/Documents/llvm-trunk/include -I/Users/kouji/Documents/llvm-trunk/lib/System -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -fno-exceptions -fno-common -Woverloaded-virtual -mmacosx-version-min=10.5 -Wall -W -Wno-unused-parameter -Wwrite-strings -arch i386 -arch x86_64 -c Alarm.cpp -o /Users/kouji/Documents/llvm-trunk/lib/System/Release/Alarm.o 〜省略〜 llvm[4]: ======= Finished Linking Release Executable Sample (without symbols) make[1]: Nothing to be done for `all'. llvm[0]: ***** Completed Release Build
次に、以下のコマンドを実行して「/usr/local」フォルダにLLVMをインストールします。sudoコマンドを実行したときにパスワードの入力を求められることがあります。この場合、現在ログインしているユーザのパスワードを入力します。
$ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install (以下、実行結果) llvm[0]: Installing include files llvm[1]: Installing Release Archive Library /usr/local/lib/libLLVMSystem.a llvm[1]: Installing Release Archive Library /usr/local/lib/libLLVMSupport.a 〜省略〜 make[2]: Nothing to be done for `install'. make[2]: Nothing to be done for `install'. make[1]: Nothing to be done for `install'.
【STEP 3】MacRubyをインストールします。CPUがインテルのMacの場合、以下のコマンドを実行してMacRubyのコンパイルを行います。
$ cd ~/Documents/MacRuby-trunk $ /usr/bin/rake (以下、実行結果) /usr/sbin/dtrace -h -s dtrace.d -o new_dtrace.h /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:725: warning: Insecure world writable dir /Users in PATH, mode 040777 〜省略〜
CPUがPowerPCのMacの場合、上記の代わりに以下のコマンドを実行します。
$ cd ~/Documents/MacRuby-trunk $ /usr/bin/rake RC_ARCHS="ppc i386" (実行結果は省略)
しばらくすると、以下のメッセージがターミナルに表示され、コンパイルが完了します。
/usr/bin/gcc -I. -I../../include -I../../include/ruby/backward -I../../include -I. -I../.. -DHAVE_ZLIB_H -DOS_CODE=OS_UNIX -fno-common -fno-common -pipe -O3 -g -Wall -Wno-parentheses -arch i386 -arch x86_64 -o zlib.o -c zlib.c /usr/bin/gcc -dynamic -bundle -undefined suppress -flat_namespace -arch i386 -arch x86_64 -o zlib.bundle zlib.o -L. -L../.. -arch i386 -arch x86_64 -lmacruby -lz
次に、以下のコマンドを実行してMacRubyをインストールします。
$ sudo /usr/bin/rake install (以下、実行結果) (in /Users/<ユーザ名>/Documents/MacRuby-trunk) cd ext/ripper /usr/bin/make top_srcdir=../.. ruby="../../miniruby -I../.. -I../../lib" extout=../../.ext hdrdir=../../include arch_hdrdir=../../include install 〜省略〜 installing samples installing framework installing IB support
これで、MacRubyの最新版をソースコードからインストールできました。