Move X11 machinery into MacOS::XQuartz namespace
In order to better support Xcode-only systems, where X11 libs and executables live under /usr/X11 but headers live in the SDK, move the x11_* helper methods into a new module. This allows us to keep some of the CLT/Xcode-only and Apple X11/XQuartz logic hidden from outside code, like ENV.x11. Since Apple's X11 is actually XQuartz, name the module "MacOS::XQuartz".
This commit is contained in:
parent
1a48dbc967
commit
148617bc11
@ -59,8 +59,8 @@ module Homebrew extend self
|
||||
end
|
||||
|
||||
def describe_x11
|
||||
return "N/A" unless MacOS.x11_installed?
|
||||
return "#{MacOS.xquartz_version} @ " + describe_path(MacOS.x11_prefix)
|
||||
return "N/A" unless MacOS::XQuartz.installed?
|
||||
return "#{MacOS::XQuartz.version} @ " + describe_path(MacOS::XQuartz.prefix)
|
||||
end
|
||||
|
||||
def describe_perl
|
||||
|
||||
@ -168,7 +168,7 @@ def check_for_stray_las
|
||||
end
|
||||
|
||||
def check_for_x11
|
||||
unless MacOS.x11_installed? then <<-EOS.undent
|
||||
unless MacOS::XQuartz.installed? then <<-EOS.undent
|
||||
X11 is not installed.
|
||||
You don't have X11 installed as part of your OS X installation.
|
||||
This is not required for all formulae, but is expected by some.
|
||||
|
||||
@ -34,7 +34,7 @@ def llvm_build
|
||||
end
|
||||
|
||||
def x11_installed?
|
||||
MacOS.x11_installed?
|
||||
MacOS::XQuartz.installed?
|
||||
end
|
||||
|
||||
def macports_or_fink_installed?
|
||||
@ -189,4 +189,12 @@ module MacOS extend self
|
||||
def clt_version?
|
||||
CLT.version
|
||||
end
|
||||
|
||||
def x11_installed?
|
||||
XQuartz.installed?
|
||||
end
|
||||
|
||||
def x11_prefix
|
||||
XQuartz.prefix
|
||||
end
|
||||
end
|
||||
|
||||
@ -189,7 +189,7 @@ class X11Dependency < Requirement
|
||||
def fatal?; true; end
|
||||
|
||||
def satisfied?
|
||||
MacOS.x11_installed? and (@min_version == nil or @min_version <= MacOS.xquartz_version)
|
||||
MacOS::XQuartz.installed? and (@min_version.nil? or @min_version <= MacOS::XQuartz.version)
|
||||
end
|
||||
|
||||
def message; <<-EOS.undent
|
||||
|
||||
@ -310,35 +310,26 @@ Please take one of the following actions:
|
||||
end
|
||||
|
||||
def x11
|
||||
opoo "You do not have X11 installed, this formula may not build." unless MacOS.x11_installed?
|
||||
|
||||
# There are some config scripts here that should go in the PATH. This
|
||||
# path is always under MacOS.x11_prefix, even for Xcode-only systems.
|
||||
prepend 'PATH', MacOS.x11_prefix/'bin', ':'
|
||||
|
||||
# Similarily, pkgconfig files are only found under MacOS.x11_prefix.
|
||||
prepend 'PKG_CONFIG_PATH', MacOS.x11_prefix/'lib/pkgconfig', ':'
|
||||
prepend 'PKG_CONFIG_PATH', MacOS.x11_prefix/'share/pkgconfig', ':'
|
||||
|
||||
append 'LDFLAGS', "-L#{MacOS.x11_prefix}/lib"
|
||||
append 'CMAKE_PREFIX_PATH', MacOS.x11_prefix, ':'
|
||||
|
||||
# We prefer XQuartz if it is installed. Otherwise, we look for Apple's
|
||||
# X11. For Xcode-only systems, the headers are found in the SDK.
|
||||
prefix = if MacOS.x11_prefix.to_s == '/opt/X11' or MacOS::CLT.installed?
|
||||
MacOS.x11_prefix
|
||||
else
|
||||
MacOS.sdk_path/'usr/X11'
|
||||
unless MacOS::XQuartz.installed?
|
||||
opoo "You do not have X11 installed, this formula may not build."
|
||||
end
|
||||
|
||||
append 'CPPFLAGS', "-I#{prefix}/include"
|
||||
# There are some config scripts here that should go in the PATH
|
||||
prepend 'PATH', MacOS::XQuartz.bin, ':'
|
||||
|
||||
append 'CMAKE_PREFIX_PATH', prefix, ':'
|
||||
append 'CMAKE_INCLUDE_PATH', prefix/'include', ':'
|
||||
prepend 'PKG_CONFIG_PATH', MacOS::XQuartz.lib/'pkgconfig', ':'
|
||||
prepend 'PKG_CONFIG_PATH', MacOS::XQuartz.share/'pkgconfig', ':'
|
||||
|
||||
append 'LDFLAGS', "-L#{MacOS::XQuartz.lib}"
|
||||
append 'CMAKE_PREFIX_PATH', MacOS::XQuartz.prefix, ':'
|
||||
append 'CMAKE_INCLUDE_PATH', MacOS::XQuartz.include, ':'
|
||||
|
||||
append 'CPPFLAGS', "-I#{MacOS::XQuartz.include}"
|
||||
|
||||
unless MacOS::CLT.installed?
|
||||
append 'CPPFLAGS', "-I#{prefix}/include/freetype2"
|
||||
append 'CFLAGS', "-I#{prefix}/include"
|
||||
append 'CMAKE_PREFIX_PATH', MacOS.sdk_path/'usr/X11', ':'
|
||||
append 'CPPFLAGS', "-I#{MacOS::XQuartz.include}/freetype2"
|
||||
append 'CFLAGS', "-I#{MacOS::XQuartz.include}"
|
||||
end
|
||||
end
|
||||
alias_method :libpng, :x11
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
module MacOS extend self
|
||||
|
||||
MDITEM_BUNDLE_ID_KEY = "kMDItemCFBundleIdentifier"
|
||||
APPLE_X11_BUNDLE_ID = "org.x.X11"
|
||||
XQUARTZ_BUNDLE_ID = "org.macosforge.xquartz.X11"
|
||||
|
||||
def version
|
||||
MACOS_VERSION
|
||||
@ -168,28 +166,6 @@ module MacOS extend self
|
||||
end
|
||||
end
|
||||
|
||||
def xquartz_version
|
||||
# This returns the version number of XQuartz, not of the upstream X.org
|
||||
# (which is why it is not called x11_version). Note that the X11.app
|
||||
# distributed by Apple is also XQuartz, and therefore covered by this method.
|
||||
path = app_with_bundle_id(XQUARTZ_BUNDLE_ID) || app_with_bundle_id(APPLE_X11_BUNDLE_ID)
|
||||
version = if not path.nil? and path.exist?
|
||||
`mdls -raw -name kMDItemVersion "#{path}" 2>/dev/null`.strip
|
||||
end
|
||||
end
|
||||
|
||||
def x11_prefix
|
||||
@x11_prefix ||= if Pathname.new('/opt/X11/lib/libpng.dylib').exist?
|
||||
Pathname.new('/opt/X11')
|
||||
elsif Pathname.new('/usr/X11/lib/libpng.dylib').exist?
|
||||
Pathname.new('/usr/X11')
|
||||
end
|
||||
end
|
||||
|
||||
def x11_installed?
|
||||
not x11_prefix.nil?
|
||||
end
|
||||
|
||||
def macports_or_fink_installed?
|
||||
# See these issues for some history:
|
||||
# http://github.com/mxcl/homebrew/issues/#issue/13
|
||||
@ -278,4 +254,5 @@ module MacOS extend self
|
||||
end
|
||||
end
|
||||
|
||||
require 'xcode'
|
||||
require 'macos/xcode'
|
||||
require 'macos/xquartz'
|
||||
|
||||
64
Library/Homebrew/macos/xquartz.rb
Normal file
64
Library/Homebrew/macos/xquartz.rb
Normal file
@ -0,0 +1,64 @@
|
||||
module MacOS::XQuartz extend self
|
||||
FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11"
|
||||
APPLE_BUNDLE_ID = "org.x.X11"
|
||||
|
||||
# This returns the version number of XQuartz, not of the upstream X.org.
|
||||
# The X11.app distributed by Apple is also XQuartz, and therefore covered
|
||||
# by this method.
|
||||
def version
|
||||
path = MacOS.app_with_bundle_id(FORGE_BUNDLE_ID) || MacOS.app_with_bundle_id(APPLE_BUNDLE_ID)
|
||||
version = if not path.nil? and path.exist?
|
||||
`mdls -raw -name kMDItemVersion "#{path}" 2>/dev/null`.strip
|
||||
end
|
||||
end
|
||||
|
||||
# This should really be private, but for compatibility reasons it must
|
||||
# remain public. New code should use MacOS::XQuartz.{bin,lib,include}
|
||||
# instead, as that accounts for Xcode-only systems.
|
||||
def prefix
|
||||
@prefix ||= if Pathname.new('/opt/X11/lib/libpng.dylib').exist?
|
||||
Pathname.new('/opt/X11')
|
||||
elsif Pathname.new('/usr/X11/lib/libpng.dylib').exist?
|
||||
Pathname.new('/usr/X11')
|
||||
end
|
||||
end
|
||||
|
||||
def installed?
|
||||
not prefix.nil?
|
||||
end
|
||||
|
||||
# If XQuartz and/or the CLT are installed, headers will be found under
|
||||
# /opt/X11/include or /usr/X11/include. For Xcode-only systems, they are
|
||||
# found in the SDK, so we use sdk_path for both the headers and libraries.
|
||||
# Confusingly, executables (e.g. config scripts) are only found under
|
||||
# /opt/X11/bin or /usr/X11/bin in all cases.
|
||||
def bin
|
||||
prefix/'bin'
|
||||
end
|
||||
|
||||
def include
|
||||
@include ||= if use_sdk?
|
||||
MacOS.sdk_path/'usr/X11/include'
|
||||
else
|
||||
prefix/'include'
|
||||
end
|
||||
end
|
||||
|
||||
def lib
|
||||
@lib ||= if use_sdk?
|
||||
MacOS.sdk_path/'usr/X11/lib'
|
||||
else
|
||||
prefix/'lib'
|
||||
end
|
||||
end
|
||||
|
||||
def share
|
||||
prefix/'share'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def use_sdk?
|
||||
not (prefix.to_s == '/opt/X11' or MacOS::CLT.installed?)
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user