2009-07-31 16:06:14 +01:00
|
|
|
def hw_model_output
|
2009-08-04 00:26:07 +01:00
|
|
|
require 'fileutils'
|
|
|
|
FileUtils.mkpath HOMEBREW_CACHE
|
2009-07-31 16:06:14 +01:00
|
|
|
exe=Pathname.new(HOMEBREW_CACHE)+'hw.model'
|
|
|
|
Kernel.system "gcc -Os #{File.dirname __FILE__}/hw.model.c -o #{exe}" unless exe.file?
|
|
|
|
/(.*)(\d+),(\d+)/ =~ `#{exe}`
|
|
|
|
yield $1, $2.to_i, $3.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
# http://support.apple.com/kb/HT3696
|
|
|
|
# http://www.cocoadev.com/index.pl?MacintoshModels
|
|
|
|
def hw_model
|
|
|
|
hw_model_output do |model, major, minor|
|
|
|
|
case model
|
|
|
|
when "iMac"
|
|
|
|
if major <=4
|
|
|
|
:core1
|
|
|
|
else
|
2009-08-01 17:54:44 +01:00
|
|
|
$unknown_hw_model=true if major >8
|
2009-07-31 16:06:14 +01:00
|
|
|
:core2
|
|
|
|
end
|
|
|
|
|
|
|
|
when "MacBookAir"
|
2009-08-01 17:54:44 +01:00
|
|
|
$unknown_hw_model=true if major > 1
|
|
|
|
:core2
|
2009-07-31 16:06:14 +01:00
|
|
|
|
|
|
|
when "MacBook"
|
|
|
|
if major <= 1
|
|
|
|
:core1
|
|
|
|
else
|
2009-08-01 17:54:44 +01:00
|
|
|
$unknown_hw_model=true if major > 4
|
2009-07-31 16:06:14 +01:00
|
|
|
:core2
|
|
|
|
end
|
|
|
|
|
|
|
|
when "MacBookPro"
|
|
|
|
if major <= 1
|
|
|
|
:core1
|
|
|
|
else
|
2009-08-01 17:54:44 +01:00
|
|
|
$unknown_hw_model=true if major > 5
|
2009-07-31 16:06:14 +01:00
|
|
|
:core2
|
|
|
|
end
|
|
|
|
|
|
|
|
when "Macmini" # Mac mini (Core Duo/Solo)
|
2009-08-01 17:54:44 +01:00
|
|
|
$unknown_hw_model=true if major > 1
|
|
|
|
:core
|
2009-07-31 16:06:14 +01:00
|
|
|
|
|
|
|
when "MacPro"
|
2009-08-01 17:54:44 +01:00
|
|
|
$unknown_hw_model=true if major > 3
|
|
|
|
:xeon
|
2009-07-31 16:06:14 +01:00
|
|
|
|
|
|
|
when "PowerBook", "PowerMac", "RackMac" then :ppc
|
|
|
|
|
|
|
|
when "Xserve"
|
2009-08-01 17:54:44 +01:00
|
|
|
$unknown_hw_model=true if major > 2
|
|
|
|
:xeon
|
2009-07-31 16:06:14 +01:00
|
|
|
|
|
|
|
when "ADP" then :dunno # Developer Transition Kit
|
|
|
|
when "M43ADP" then :dunno # Development Mac Pro
|
|
|
|
else :dunno
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|