aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMisty De Meo2013-08-01 20:19:00 -0700
committerMisty De Meo2013-08-15 22:46:55 -0700
commitf3c3a840fe7ea14680952d70cfeb057eb7dbbb2c (patch)
tree2c4ccada38e79493543ecbf0c94495038b8e671e /Library
parent4888c02c30bb43b436249b60abaa1ee516fd03d3 (diff)
downloadhomebrew-f3c3a840fe7ea14680952d70cfeb057eb7dbbb2c.tar.bz2
Add Hardware::CPU.arch_(32|64)_bit
This replaces hardcoding of i386/x86_64 all over the code.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/ENV.rb17
-rw-r--r--Library/Homebrew/os/mac/hardware.rb8
2 files changed, 16 insertions, 9 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index b2650e851..a5d17da6d 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -174,7 +174,7 @@ module HomebrewEnvExtension
def clang
self['CC'] = self['OBJC'] = MacOS.locate("clang")
self['CXX'] = self['OBJCXX'] = MacOS.locate("clang++")
- replace_in_cflags(/-Xarch_i386 (-march=\S*)/, '\1')
+ replace_in_cflags(/-Xarch_#{Hardware::CPU.arch_32_bit} (-march=\S*)/, '\1')
# Clang mistakenly enables AES-NI on plain Nehalem
set_cpu_cflags '-march=native', :nehalem => '-march=native -Xclang -target-feature -Xclang -aes'
append_to_cflags '-Qunused-arguments'
@@ -284,22 +284,21 @@ module HomebrewEnvExtension
def m64
append_to_cflags '-m64'
- append 'LDFLAGS', '-arch x86_64'
+ append 'LDFLAGS', "-arch #{Hardware::CPU.arch_64_bit}"
end
def m32
append_to_cflags '-m32'
- append 'LDFLAGS', '-arch i386'
+ append 'LDFLAGS', "-arch #{Hardware::CPU.arch_32_bit}"
end
- # i386 and x86_64 (no PPC)
def universal_binary
- append_to_cflags '-arch i386 -arch x86_64'
+ append_to_cflags "-arch #{Hardware::CPU.arch_32_bit} -arch #{Hardware::CPU.arch_64_bit}"
replace_in_cflags '-O4', '-O3' # O4 seems to cause the build to fail
- append 'LDFLAGS', '-arch i386 -arch x86_64'
+ append 'LDFLAGS', "-arch #{Hardware::CPU.arch_32_bit} -arch #{Hardware::CPU.arch_64_bit}"
if compiler != :clang && Hardware.is_32_bit?
# Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
- replace_in_cflags(/-march=\S*/, '-Xarch_i386 \0')
+ replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \0")
end
end
@@ -317,9 +316,9 @@ module HomebrewEnvExtension
# Sets architecture-specific flags for every environment variable
# given in the list `flags`.
def set_cpu_flags flags, default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
- cflags =~ %r{(-Xarch_i386 )-march=}
+ cflags =~ %r{(-Xarch_#{Hardware::CPU.arch_32_bit} )-march=}
xarch = $1.to_s
- remove flags, %r{(-Xarch_i386 )?-march=\S*}
+ remove flags, %r{(-Xarch_#{Hardware::CPU.arch_32_bit} )?-march=\S*}
remove flags, %r{( -Xclang \S+)+}
remove flags, %r{-mssse3}
remove flags, %r{-msse4(\.\d)?}
diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb
index 5487a8d4d..05cd3da5e 100644
--- a/Library/Homebrew/os/mac/hardware.rb
+++ b/Library/Homebrew/os/mac/hardware.rb
@@ -75,6 +75,14 @@ module MacCPUs
@bits ||= is_64_bit ? 64 : 32
end
+ def arch_32_bit
+ type == :intel ? :i386 : :ppc
+ end
+
+ def arch_64_bit
+ type == :intel ? :x86_64 : :ppc64
+ end
+
def altivec?
@altivec ||= sysctl_bool('hw.optional.altivec')
end