Commit 102810d9 authored by Sam Stephenson's avatar Sam Stephenson
Browse files

Better GCC detection

parent 197dd34c
Loading
Loading
Loading
Loading
+52 −6
Original line number Diff line number Diff line
@@ -180,13 +180,59 @@ fix_directory_permissions() {
  find "$PREFIX_PATH" -type d -exec chmod go-w {} \;
}

use_gcc42_on_lion() {
requires_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
    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"
        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() {
+1 −1
Original line number Diff line number Diff line
use_gcc42_on_lion
requires_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
+1 −1
Original line number Diff line number Diff line
use_gcc42_on_lion
requires_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
+1 −1
Original line number Diff line number Diff line
use_gcc42_on_lion
requires_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
+1 −1
Original line number Diff line number Diff line
use_gcc42_on_lion
requires_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
Loading