すがブロ

sugamasaoのhatenablogだよ

RbConfigというのがあってビルド時の情報とかが取れる

Rubyのインストール時の情報を保持しているみたい

RbConfig::CONFIGという定数のHashに様々な情報が入っている。

sugamasao@GRAM% ruby -v
ruby 1.9.3p5 (2011-11-30 revision 33907) [x86_64-darwin10.8.0]
sugamasao@GRAM% ruby -rpp -e"pp RbConfig::CONFIG"
{"DESTDIR"=>"",
 "MAJOR"=>"1",
 "MINOR"=>"9",
 "TEENY"=>"1",
 "PATCHLEVEL"=>"5",
 "INSTALL"=>"/usr/bin/install -c",
 "EXEEXT"=>"",
 "prefix"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head",
 "ruby_install_name"=>"ruby",
 "RUBY_INSTALL_NAME"=>"ruby",
 "RUBY_SO_NAME"=>"ruby.1.9.1",
 "exec"=>"exec",
 "ruby_pc"=>"ruby-1.9.pc",
 "PACKAGE"=>"ruby",
 "BUILTIN_TRANSSRCS"=>" newline.c",
 "USE_RUBYGEMS"=>"YES",
 "MANTYPE"=>"doc",
 "NROFF"=>"/usr/bin/nroff",
 "vendorhdrdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/include/ruby-1.9.1/vendor_ruby",
 "sitehdrdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/include/ruby-1.9.1/site_ruby",
 "rubyhdrdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/include/ruby-1.9.1", "UNIVERSAL_INTS"=>"", "UNIVERSAL_ARCHNAMES"=>"", "configure_args"=>  " '--prefix=/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head' '--enable-shared' '--disable-install-doc' '--with-libyaml-dir=/Users/sugamasao/.rvm/usr' '--with-baseruby=/Users/sugamasao/.rvm/wrappers/ruby-1.8.7-head/ruby' 'CC=clang'", "vendordir"=>  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/vendor_ruby", "sitedir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby", "ruby_version"=>"1.9.1", "sitearch"=>"x86_64-darwin10.8.0", "arch"=>"x86_64-darwin10.8.0", "RI_BASE_NAME"=>"ri", "ridir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/ri", "rubylibprefix"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby", "MAKEFILES"=>"Makefile", "THREAD_MODEL"=>"pthread", "SYMBOL_PREFIX"=>"_", "EXPORT_PREFIX"=>"", "COMMON_HEADERS"=>"", "COMMON_MACROS"=>"", "COMMON_LIBS"=>"", "MAINLIBS"=>"", "ENABLE_SHARED"=>"yes", "DLDLIBS"=>"", "SOLIBS"=>"", "LIBRUBYARG_SHARED"=>"-lruby.1.9.1", "LIBRUBYARG_STATIC"=>"-lruby.1.9.1-static", "LIBRUBYARG"=>"-lruby.1.9.1", "LIBRUBY"=>"libruby.1.9.1.dylib", "LIBRUBY_ALIASES"=>"libruby.1.9.dylib libruby.dylib", "LIBRUBY_SO"=>"libruby.1.9.1.dylib", "LIBRUBY_A"=>"libruby.1.9.1-static.a", "RUBYW_INSTALL_NAME"=>"", "rubyw_install_name"=>"", "LIBRUBY_DLDFLAGS"=>
  "-Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -install_name /Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/libruby.1.9.1.dylib -current_version 1.9.1 -compatibility_version 1.9.1 -Wl,-unexported_symbol,_Init_* -Wl,-unexported_symbol,*_threadptr_*  $(XLDFLAGS)",
 "LIBRUBY_LDSHARED"=>"clang -dynamiclib",
 "warnflags"=>
  "-Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration",
 "debugflags"=>"-ggdb",
 "optflags"=>"-O3",
 "cxxflags"=>
  " -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration",
 "cflags"=>
  " -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration",
 "cppflags"=>"",
 "NULLCMD"=>":",
 "INSTALLDOC"=>"nodoc",
 "CAPITARGET"=>"nodoc",
 "RDOCTARGET"=>"nodoc",
 "EXECUTABLE_EXTS"=>"",
 "ARCHFILE"=>"",
 "LIBRUBY_RELATIVE"=>"no",
 "EXTOUT"=>".ext",
 "PREP"=>"miniruby",
 "TEST_RUNNABLE"=>"yes",
 "setup"=>"Setup",
 "EXTSTATIC"=>"",
 "STRIP"=>"strip -A -n",
 "TRY_LINK"=>"",
 "LIBPATHENV"=>"DYLD_LIBRARY_PATH",
 "RPATHFLAG"=>"",
 "LIBPATHFLAG"=>" -L%s",
 "LINK_SO"=>"",
 "LIBEXT"=>"a",
 "DLEXT2"=>"",
 "DLEXT"=>"bundle",
 "LDSHAREDXX"=>"g++ -dynamic -bundle",
 "LDSHARED"=>"clang -dynamic -bundle",
 "CCDLFLAGS"=>"-fno-common",
 "STATIC"=>"",
 "ARCH_FLAG"=>"",
 "DLDFLAGS"=>
  "-Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace",
 "ALLOCA"=>"",
 "WERRORFLAG"=>"-Werror",
 "CHDIR"=>"cd -P",
 "RMALL"=>"rm -fr",
 "RMDIRS"=>"rmdir -p",
 "RMDIR"=>"rmdir",
 "CP"=>"cp",
 "RM"=>"rm -f",
 "PKG_CONFIG"=>"",
 "DOXYGEN"=>"",
 "DOT"=>"",
 "MAKEDIRS"=>"mkdir -p",
 "MKDIR_P"=>"mkdir -p",
 "INSTALL_DATA"=>"/usr/bin/install -c -m 644",
 "INSTALL_SCRIPT"=>"/usr/bin/install -c",
 "INSTALL_PROGRAM"=>"/usr/bin/install -c",
 "SET_MAKE"=>"",
 "LN_S"=>"ln -s",
 "NM"=>"nm",
 "DLLWRAP"=>"",
 "WINDRES"=>"",
 "OBJCOPY"=>":",
 "OBJDUMP"=>"",
 "ASFLAGS"=>"",
 "AS"=>"as",
 "AR"=>"ar",
 "RANLIB"=>"ranlib",
 "try_header"=>"",
 "COUTFLAG"=>"-o ",
 "OUTFLAG"=>"-o ",
 "CPPOUTFILE"=>"-o conftest.i",
 "GNU_LD"=>"no",
 "GCC"=>"yes",
 "EGREP"=>"/usr/bin/grep -E",
 "GREP"=>"/usr/bin/grep",
 "CPP"=>"clang -E",
 "CXXFLAGS"=>
  " -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration",
 "CXX"=>"g++",
 "OBJEXT"=>"o",
 "CPPFLAGS"=>"-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  ",
 "LDFLAGS"=>"-L. ",
 "CFLAGS"=>
  " -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration  -fno-common -pipe",
 "CC"=>"clang",
 "target_os"=>"darwin10.8.0",
 "target_vendor"=>"apple",
 "target_cpu"=>"x86_64",
 "target"=>"x86_64-apple-darwin10.8.0",
 "host_os"=>"darwin10.8.0",
 "host_vendor"=>"apple",
 "host_cpu"=>"x86_64",
 "host"=>"x86_64-apple-darwin10.8.0",
 "RUBYW_BASE_NAME"=>"rubyw",
 "RUBY_BASE_NAME"=>"ruby",
 "build_os"=>"darwin10.8.0",
 "build_vendor"=>"apple",
 "build_cpu"=>"x86_64",
 "build"=>"x86_64-apple-darwin10.8.0",
 "RUBY_RELEASE_DATE"=>"2011-11-30",
 "RUBY_PROGRAM_VERSION"=>"1.9.3",
 "BASERUBY"=>"/Users/sugamasao/.rvm/wrappers/ruby-1.8.7-head/ruby",
 "target_alias"=>"",
 "host_alias"=>"",
 "build_alias"=>"",
 "LIBS"=>"-lpthread -ldl -lobjc",
 "ECHO_T"=>"",
 "ECHO_N"=>"",
 "ECHO_C"=>"\\\\c",
 "DEFS"=>"",
 "mandir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/man",
 "localedir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/locale",
 "libdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib",
 "psdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/doc/ruby",
 "pdfdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/doc/ruby",
 "dvidir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/doc/ruby",
 "htmldir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/doc/ruby",
 "infodir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/info",
 "docdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share/doc/ruby",
 "oldincludedir"=>"/usr/include",
 "includedir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/include",
 "localstatedir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/var",
 "sharedstatedir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/com",
 "sysconfdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/etc",
 "datadir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share",
 "datarootdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/share",
 "libexecdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/libexec",
 "sbindir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/sbin",
 "bindir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/bin",
 "exec_prefix"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head",
 "PACKAGE_URL"=>"",
 "PACKAGE_BUGREPORT"=>"",
 "PACKAGE_STRING"=>"",
 "PACKAGE_VERSION"=>"",
 "PACKAGE_TARNAME"=>"",
 "PACKAGE_NAME"=>"",
 "PATH_SEPARATOR"=>":",
 "SHELL"=>"/bin/sh",
 "rubylibdir"=>"/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1",
 "archdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/x86_64-darwin10.8.0",
 "sitelibdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1",
 "sitearchdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/x86_64-darwin10.8.0",
 "vendorlibdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/vendor_ruby/1.9.1",
 "vendorarchdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin10.8.0",
 "topdir"=>
  "/Users/sugamasao/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/x86_64-darwin10.8.0"}

ちなみに、元々はConfigのエイリアスとしてRbConfigっていうのがあったっぽいけど*1Ruby1.9.3(から?)だと、逆にConfigの方がエイリアスになっているらしく、RbConfigを使うことが推奨されている。
Configを使うと、プギャー!ってされるのだった。

ruby-1.9.3-head :001 > Config
(irb):1: Use RbConfig instead of obsolete and deprecated Config.

みんな大好きwatchrもConfig(RbConfigじゃないので使うと警告がでるのであった)を使っていて、OS毎のファイルイベントを扱うライブラリの選択とかの参考にしてる感じ。

*1:ruby1.8時代のマニュアルのニュアンスだと