config_flags = ["--disable-debug",
                "--disable-dependency-tracking",
                "--disable-install-doc",
                "--enable-shared",
                "--with-opt-dir=#{embedded_dir}",
                "--enable-load-relative"]
env_vars = {}

if platform?("mac_os_x")
  # Mac needs to setup the rpath for the libraries
  env_vars["LDFLAGS"] = "-Wl,-rpath,@loader_path/../lib -Wl,-rpath,@executable_path/../lib"

  # Build a Mach Universal Binary on Mac
  config_flags << "--with-arch=x86_64,i386"
elsif node[:os] == "linux"
  # On all linux installations, add in this rpath so that our
  # libraries can be accessed when called from the `ruby`
  # binary.
  env_vars["LDFLAGS"] = "-Wl,-rpath,$ORIGIN/../lib"
end

util_autotools "ruby" do
  file "ruby-1.9.3-p125.tar.gz"
  config_flags config_flags
  environment env_vars
end

config_flags = ["--disable-debug",
                "--disable-dependency-tracking",
                "--disable-install-doc",
                "--enable-shared",
                "--with-opt-dir=#{embedded_dir}",
                "--enable-load-relative"]
env_vars = {}

if platform?("mac_os_x")
  # Mac needs to setup the rpath for the libraries
  env_vars["LDFLAGS"] = "-Wl,-rpath,@loader_path/../lib -Wl,-rpath,@executable_path/../lib"

  # Build a Mach Universal Binary on Mac
  config_flags << "--with-arch=x86_64,i386"
elsif node[:os] == "linux"
  # On all linux installations, add in this rpath so that our
  # libraries can be accessed when called from the `ruby`
  # binary.
  env_vars["LD_RUN_PATH"] = "\$ORIGIN/../lib"
end

util_autotools "ruby" do
  file "ruby-1.9.3-p125.tar.gz"
  config_flags config_flags
  environment env_vars
end

Use the proper Ruby rpath
Linux: Use the proper Ruby rpath

This fixes a major issue where Ruby would get a bogus Rpath value (see
https://github.com/mitchellh/vagrant/issues/850#issuecomment-6263739).
This bogus value would cause compiled extensions to have a bogus rpath
value (see
https://github.com/mitchellh/vagrant/issues/850#issuecomment-5541549).
This bogus rpath value would cause the extensions to not load properly.

This patch uses LD_RUN_PATH, which is an environmental variable that
absolutely sets the rpath of the binary it is compiling. LD_RUN_PATH is
set absolutely to only the ${ORIGIN}/../lib, which is the correct value
and gets rid of the bogus values.
