Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Add Hardware::CPU.intel? and Hardware::CPU.ppc?
Browse files Browse the repository at this point in the history
  • Loading branch information
jacknagel committed Nov 27, 2013
1 parent f26bea1 commit 91a69c6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Library/Formula/avidemux.rb
Expand Up @@ -43,7 +43,7 @@ def install

# For 32-bit compilation under gcc 4.2, see:
# http://trac.macports.org/ticket/20938#comment:22
if MacOS.version <= :leopard or Hardware.is_32_bit? && Hardware.cpu_type == :intel && ENV.compiler == :clang
if MacOS.version <= :leopard or Hardware.is_32_bit? && Hardware::CPU.intel? && ENV.compiler == :clang
inreplace 'cmake/admFFmpegBuild.cmake',
'${CMAKE_INSTALL_PREFIX})',
'${CMAKE_INSTALL_PREFIX} --extra-cflags=-mdynamic-no-pic)'
Expand Down
4 changes: 2 additions & 2 deletions Library/Formula/boost.rb
Expand Up @@ -126,7 +126,7 @@ def install
# The context library is implemented as x86_64 ASM, so it
# won't build on PPC or 32-bit builds
# see https://github.com/mxcl/homebrew/issues/17646
if Hardware::CPU.type == :ppc || Hardware::CPU.is_32_bit? || build.universal?
if Hardware::CPU.ppc? || Hardware::CPU.is_32_bit? || build.universal?
without_libraries << "context"
# The coroutine library depends on the context library.
without_libraries << "coroutine"
Expand Down Expand Up @@ -178,7 +178,7 @@ def caveats
EOS
end

if Hardware::CPU.type == :ppc || Hardware::CPU.is_32_bit? || build.universal?
if Hardware::CPU.ppc? || Hardware::CPU.is_32_bit? || build.universal?
s += <<-EOS.undent
Building of Boost.Context and Boost.Coroutine is disabled as they are
Expand Down
2 changes: 1 addition & 1 deletion Library/Formula/ffmpeg.rb
Expand Up @@ -102,7 +102,7 @@ def install

# For 32-bit compilation under gcc 4.2, see:
# http://trac.macports.org/ticket/20938#comment:22
ENV.append_to_cflags "-mdynamic-no-pic" if Hardware.is_32_bit? && Hardware.cpu_type == :intel && ENV.compiler == :clang
ENV.append_to_cflags "-mdynamic-no-pic" if Hardware.is_32_bit? && Hardware::CPU.intel? && ENV.compiler == :clang

system "./configure", *args

Expand Down
10 changes: 9 additions & 1 deletion Library/Homebrew/hardware.rb
Expand Up @@ -30,6 +30,14 @@ def is_32_bit?
def is_64_bit?
bits == 64
end

def intel?
type == :intel
end

def ppc?
type == :ppc
end
end

if OS.mac?
Expand All @@ -53,7 +61,7 @@ def self.cores_as_words
end

def self.oldest_cpu
if Hardware::CPU.type == :intel
if Hardware::CPU.intel?
if Hardware::CPU.is_64_bit?
:core2
else
Expand Down
14 changes: 6 additions & 8 deletions Library/Homebrew/os/mac/hardware.rb
Expand Up @@ -27,9 +27,8 @@ def type
end

def family
if type == :intel
@intel_family ||= `/usr/sbin/sysctl -n hw.cpufamily`.to_i
case @intel_family
if intel?
case @intel_family ||= `/usr/sbin/sysctl -n hw.cpufamily`.to_i
when 0x73d67300 # Yonah: Core Solo/Duo
:core
when 0x426f69ef # Merom: Core 2 Duo
Expand All @@ -49,9 +48,8 @@ def family
else
:dunno
end
elsif type == :ppc
@ppc_family ||= `/usr/sbin/sysctl -n hw.cpusubtype`.to_i
case @ppc_family
elsif ppc?
case @ppc_family ||= `/usr/sbin/sysctl -n hw.cpusubtype`.to_i
when 9
:g3 # PowerPC 750
when 10
Expand Down Expand Up @@ -81,11 +79,11 @@ def bits
end

def arch_32_bit
type == :intel ? :i386 : :ppc
intel? ? :i386 : :ppc
end

def arch_64_bit
type == :intel ? :x86_64 : :ppc64
intel? ? :x86_64 : :ppc64
end

# Returns an array that's been extended with ArchitectureListExtension,
Expand Down

0 comments on commit 91a69c6

Please sign in to comment.