Skip to content

Commit

Permalink
Merge pull request rbenv#70 from sstephenson/better-gcc-detection
Browse files Browse the repository at this point in the history
Better GCC detection
  • Loading branch information
sstephenson committed Oct 20, 2011
2 parents 197dd34 + 7630d84 commit 5ddb90f
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 15 deletions.
58 changes: 52 additions & 6 deletions bin/ruby-build
Expand Up @@ -180,13 +180,59 @@ fix_directory_permissions() {
find "$PREFIX_PATH" -type d -exec chmod go-w {} \;
}

use_gcc42_on_lion() {
if [ "$(uname -s)" = "Darwin" ]; then
if [ "$(expr "$(sw_vers -productVersion | cut -f 2 -d .)" \>= 7 || true)" -eq 1 ]; then
export CC=/usr/bin/gcc-4.2
CONFIGURE_OPTS="--with-gcc=$CC $CONFIGURE_OPTS"
fi
require_gcc() {
local gcc="$(locate_gcc || true)"
if [ -z "$gcc" ]; then
{ echo
echo "ERROR: This package must be compiled with GCC, and we"
echo "couldn't find a suitable \`gcc' binary on your system."
echo "Please install GCC and try again."
echo

if [ "$(uname -s)" = "Darwin" ]; then
echo "You can install these GCC packages on Mac OS X:"
echo "https://github.com/kennethreitz/osx-gcc-installer/downloads"
echo
fi
} >&3
return 1
fi

export CC="$gcc"
}

locate_gcc() {
local gcc gccs
shopt -s nullglob
gccs=( /usr/bin/gcc-* )
shopt -u nullglob

verify_gcc "$CC" ||
verify_gcc "$(command -v gcc || true)" || {
for gcc in "${gccs[@]}"; do
verify_gcc "$gcc" && break || true
done
}

return 1
}

verify_gcc() {
local gcc="$1"
if [ -z "$gcc" ]; then
return 1
fi

local version="$("$gcc" --version || true)"
if [ -z "$version" ]; then
return 1
fi

if echo "$version" | grep LLVM >/dev/null; then
return 1
fi

echo "$gcc"
}

version() {
Expand Down
2 changes: 1 addition & 1 deletion share/ruby-build/1.8.6-p420
@@ -1,3 +1,3 @@
use_gcc42_on_lion
require_gcc
install_package "ruby-1.8.6-p420" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p420.tar.gz"
install_package "rubygems-1.3.7" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz" ruby
2 changes: 1 addition & 1 deletion share/ruby-build/1.8.7-p249
@@ -1,3 +1,3 @@
use_gcc42_on_lion
require_gcc
install_package "ruby-1.8.7-p249" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz"
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby
2 changes: 1 addition & 1 deletion share/ruby-build/1.8.7-p334
@@ -1,3 +1,3 @@
use_gcc42_on_lion
require_gcc
install_package "ruby-1.8.7-p334" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p334.tar.gz"
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby
2 changes: 1 addition & 1 deletion share/ruby-build/1.8.7-p352
@@ -1,3 +1,3 @@
use_gcc42_on_lion
require_gcc
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
1 change: 1 addition & 0 deletions share/ruby-build/1.9.1-p378
@@ -1,3 +1,4 @@
require_gcc
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.1-p378" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p378.tar.gz"
install_package "rubygems-1.3.5" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.5.tgz" ruby
2 changes: 1 addition & 1 deletion share/ruby-build/1.9.2-p290
@@ -1,4 +1,4 @@
use_gcc42_on_lion
require_gcc
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.2-p290" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz"
install_package "rubygems-1.8.10" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz" ruby
2 changes: 1 addition & 1 deletion share/ruby-build/1.9.3-dev
@@ -1,4 +1,4 @@
use_gcc42_on_lion
require_gcc
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_git "ruby-1.9.3-dev" "https://github.com/ruby/ruby.git" "ruby_1_9_3" autoconf standard
install_package "rubygems-1.8.10" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz" ruby
1 change: 1 addition & 0 deletions share/ruby-build/1.9.3-preview1
@@ -1,3 +1,4 @@
require_gcc
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.3-preview1" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-preview1.tar.gz"
install_package "rubygems-1.8.10" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz" ruby
1 change: 1 addition & 0 deletions share/ruby-build/1.9.3-rc1
@@ -1,2 +1,3 @@
require_gcc
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.3-rc1" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-rc1.tar.gz"
2 changes: 1 addition & 1 deletion share/ruby-build/ree-1.8.6-2009.06
@@ -1,3 +1,3 @@
use_gcc42_on_lion
require_gcc
install_package "ruby-enterprise-1.8.6-20090610" "http://files.rubyforge.vm.bytemark.co.uk/emm-ruby/ruby-enterprise-1.8.6-20090610.tar.gz" ree_installer
install_package "rubygems-1.4.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.4.2.tgz" ruby
2 changes: 1 addition & 1 deletion share/ruby-build/ree-1.8.7-2010.02
@@ -1,3 +1,3 @@
use_gcc42_on_lion
require_gcc
install_package "ruby-enterprise-1.8.7-2010.02" "http://files.rubyforge.vm.bytemark.co.uk/emm-ruby/ruby-enterprise-1.8.7-2010.02.tar.gz" ree_installer
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby
2 changes: 1 addition & 1 deletion share/ruby-build/ree-1.8.7-2011.03
@@ -1,3 +1,3 @@
use_gcc42_on_lion
require_gcc
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
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby

0 comments on commit 5ddb90f

Please sign in to comment.