From acb2131f30bbb0d620fec6dc17c6eaf4aa4acb6a Mon Sep 17 00:00:00 2001
From: Sam Stephenson <sam@37signals.com>
Date: Wed, 3 Aug 2011 23:47:23 -0500
Subject: [PATCH] Use gcc-4.2 on Lion for 1.8.7

---
 bin/ruby-build             | 8 ++++++++
 versions/1.8.7-p352        | 1 +
 versions/ree-1.8.7-2011.03 | 1 +
 3 files changed, 10 insertions(+)

diff --git a/bin/ruby-build b/bin/ruby-build
index d9c0aeeb..31666a34 100755
--- a/bin/ruby-build
+++ b/bin/ruby-build
@@ -74,6 +74,14 @@ after_install_package() {
   local stub=1
 }
 
+use_gcc42_on_lion() {
+  if [ "$(uname -s)" = "Darwin" ]; then
+    if [ "$(expr "$(sw_vers -productVersion | cut -f 2 -d .)" \>= 7)" = 0 ]; then
+      export CC=/usr/bin/gcc-4.2
+    fi
+  fi
+}
+
 usage() {
   echo "usage: ruby-build DEFINITION-PATH INSTALLATION-PREFIX"
   exit 1
diff --git a/versions/1.8.7-p352 b/versions/1.8.7-p352
index e779a3ff..6a26320d 100644
--- a/versions/1.8.7-p352
+++ b/versions/1.8.7-p352
@@ -1,2 +1,3 @@
+use_gcc42_on_lion
 install_package "ruby-1.8.7-p352" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p352.tar.gz"
 install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby
diff --git a/versions/ree-1.8.7-2011.03 b/versions/ree-1.8.7-2011.03
index d48a39f0..dd342250 100644
--- a/versions/ree-1.8.7-2011.03
+++ b/versions/ree-1.8.7-2011.03
@@ -8,4 +8,5 @@ build_package_ree_installer() {
   } >$LOG_PATH 2>&1
 }
 
+use_gcc42_on_lion
 install_package "ruby-enterprise-1.8.7-2011.03" "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz" ree_installer