Skip to content

Commit 102810d

Browse files
committed
Better GCC detection
1 parent 197dd34 commit 102810d

File tree

13 files changed

+64
-15
lines changed

13 files changed

+64
-15
lines changed

bin/ruby-build

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,59 @@ fix_directory_permissions() {
180180
find "$PREFIX_PATH" -type d -exec chmod go-w {} \;
181181
}
182182

183-
use_gcc42_on_lion() {
184-
if [ "$(uname -s)" = "Darwin" ]; then
185-
if [ "$(expr "$(sw_vers -productVersion | cut -f 2 -d .)" \>= 7 || true)" -eq 1 ]; then
186-
export CC=/usr/bin/gcc-4.2
187-
CONFIGURE_OPTS="--with-gcc=$CC $CONFIGURE_OPTS"
188-
fi
183+
requires_gcc() {
184+
local gcc="$(locate_gcc || true)"
185+
if [ -z "$gcc" ]; then
186+
{ echo
187+
echo "ERROR: This package must be compiled with GCC, and we"
188+
echo "couldn't find a suitable \`gcc' binary on your system."
189+
echo "Please install GCC and try again."
190+
echo
191+
192+
if [ "$(uname -s)" = "Darwin" ]; then
193+
echo "You can install these GCC packages on Mac OS X:"
194+
echo "https://github.com/kennethreitz/osx-gcc-installer/downloads"
195+
echo
196+
fi
197+
} >&3
198+
return 1
189199
fi
200+
201+
export CC="$gcc"
202+
}
203+
204+
locate_gcc() {
205+
local gcc gccs
206+
shopt -s nullglob
207+
gccs=( /usr/bin/gcc-* )
208+
shopt -u nullglob
209+
210+
verify_gcc "$CC" ||
211+
verify_gcc "$(command -v gcc || true)" || {
212+
for gcc in "${gccs[@]}"; do
213+
verify_gcc "$gcc" && break || true
214+
done
215+
}
216+
217+
return 1
218+
}
219+
220+
verify_gcc() {
221+
local gcc="$1"
222+
if [ -z "$gcc" ]; then
223+
return 1
224+
fi
225+
226+
local version="$("$gcc" --version || true)"
227+
if [ -z "$version" ]; then
228+
return 1
229+
fi
230+
231+
if echo "$version" | grep LLVM >/dev/null; then
232+
return 1
233+
fi
234+
235+
echo "$gcc"
190236
}
191237

192238
version() {

share/ruby-build/1.8.6-p420

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
use_gcc42_on_lion
1+
requires_gcc
22
install_package "ruby-1.8.6-p420" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p420.tar.gz"
33
install_package "rubygems-1.3.7" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz" ruby

share/ruby-build/1.8.7-p249

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
use_gcc42_on_lion
1+
requires_gcc
22
install_package "ruby-1.8.7-p249" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz"
33
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby

share/ruby-build/1.8.7-p334

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
use_gcc42_on_lion
1+
requires_gcc
22
install_package "ruby-1.8.7-p334" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p334.tar.gz"
33
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby

share/ruby-build/1.8.7-p352

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
use_gcc42_on_lion
1+
requires_gcc
22
install_package "ruby-1.8.7-p352" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p352.tar.gz"
33
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby

share/ruby-build/1.9.1-p378

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
requires_gcc
12
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
23
install_package "ruby-1.9.1-p378" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p378.tar.gz"
34
install_package "rubygems-1.3.5" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.5.tgz" ruby

share/ruby-build/1.9.2-p290

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use_gcc42_on_lion
1+
requires_gcc
22
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
33
install_package "ruby-1.9.2-p290" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz"
44
install_package "rubygems-1.8.10" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz" ruby

share/ruby-build/1.9.3-dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use_gcc42_on_lion
1+
requires_gcc
22
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
33
install_git "ruby-1.9.3-dev" "https://github.com/ruby/ruby.git" "ruby_1_9_3" autoconf standard
44
install_package "rubygems-1.8.10" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz" ruby

share/ruby-build/1.9.3-preview1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
requires_gcc
12
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
23
install_package "ruby-1.9.3-preview1" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-preview1.tar.gz"
34
install_package "rubygems-1.8.10" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz" ruby

share/ruby-build/1.9.3-rc1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
requires_gcc
12
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
23
install_package "ruby-1.9.3-rc1" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-rc1.tar.gz"

0 commit comments

Comments
 (0)