aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2012-07-25 15:04:46 -0500
committerJack Nagel2012-08-01 00:31:38 -0500
commit148617bc1164c919eda86403ce2df197b913cdde (patch)
treecefbb21cf8a59dc6cee5996e9db9d7ec3c8121bd /Library
parent1a48dbc967bdfb03c78240637233c9f9553678fc (diff)
downloadbrew-148617bc1164c919eda86403ce2df197b913cdde.tar.bz2
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".
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/--config.rb4
-rw-r--r--Library/Homebrew/cmd/doctor.rb2
-rw-r--r--Library/Homebrew/compat/compatibility.rb10
-rw-r--r--Library/Homebrew/dependencies.rb2
-rw-r--r--Library/Homebrew/extend/ENV.rb37
-rw-r--r--Library/Homebrew/macos.rb27
-rw-r--r--Library/Homebrew/macos/xcode.rb (renamed from Library/Homebrew/xcode.rb)0
-rw-r--r--Library/Homebrew/macos/xquartz.rb64
8 files changed, 93 insertions, 53 deletions
diff --git a/Library/Homebrew/cmd/--config.rb b/Library/Homebrew/cmd/--config.rb
index 3b749c5ab..d70af5f99 100644
--- a/Library/Homebrew/cmd/--config.rb
+++ b/Library/Homebrew/cmd/--config.rb
@@ -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
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 922c9ca70..1b723daaf 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -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.
diff --git a/Library/Homebrew/compat/compatibility.rb b/Library/Homebrew/compat/compatibility.rb
index e14909496..a06978398 100644
--- a/Library/Homebrew/compat/compatibility.rb
+++ b/Library/Homebrew/compat/compatibility.rb
@@ -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
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index 9493c623b..5af3311d5 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -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
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index 363c6d356..b6240d8e3 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -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', ':'
+ unless MacOS::XQuartz.installed?
+ opoo "You do not have X11 installed, this formula may not build."
+ end
- append 'LDFLAGS', "-L#{MacOS.x11_prefix}/lib"
- append 'CMAKE_PREFIX_PATH', MacOS.x11_prefix, ':'
+ # There are some config scripts here that should go in the PATH
+ prepend 'PATH', MacOS::XQuartz.bin, ':'
- # 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'
- end
+ prepend 'PKG_CONFIG_PATH', MacOS::XQuartz.lib/'pkgconfig', ':'
+ prepend 'PKG_CONFIG_PATH', MacOS::XQuartz.share/'pkgconfig', ':'
- append 'CPPFLAGS', "-I#{prefix}/include"
+ append 'LDFLAGS', "-L#{MacOS::XQuartz.lib}"
+ append 'CMAKE_PREFIX_PATH', MacOS::XQuartz.prefix, ':'
+ append 'CMAKE_INCLUDE_PATH', MacOS::XQuartz.include, ':'
- append 'CMAKE_PREFIX_PATH', prefix, ':'
- append 'CMAKE_INCLUDE_PATH', prefix/'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
diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb
index 1db630619..43f9ab031 100644
--- a/Library/Homebrew/macos.rb
+++ b/Library/Homebrew/macos.rb
@@ -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'
diff --git a/Library/Homebrew/xcode.rb b/Library/Homebrew/macos/xcode.rb
index 0c8139c62..0c8139c62 100644
--- a/Library/Homebrew/xcode.rb
+++ b/Library/Homebrew/macos/xcode.rb
diff --git a/Library/Homebrew/macos/xquartz.rb b/Library/Homebrew/macos/xquartz.rb
new file mode 100644
index 000000000..d00c55680
--- /dev/null
+++ b/Library/Homebrew/macos/xquartz.rb
@@ -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