From a07085df2def6bc25ee0d118e86b10e49c68aab0 Mon Sep 17 00:00:00 2001 From: Camillo Lugaresi Date: Tue, 5 Jun 2012 22:21:15 +0200 Subject: [PATCH] use XQuartz when present --- Library/Homebrew/extend/ENV.rb | 44 ++++++++++++++++++++-------------- Library/Homebrew/macos.rb | 11 +++++++-- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 374243343e..8bc7593235 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -310,25 +310,33 @@ Please take one of the following actions: def x11 opoo "You do not have X11 installed, this formula may not build." unless MacOS.x11_installed? - if MacOS.clt_installed? - # For Xcode < 4.3 clt_installed? is true. So here is the old style /usr/X11: - # There are some config scripts (e.g. freetype) here that should go in the path - # (note we don't use MacOS.sdk_path here, because there is no ./usr/bin in there) - prepend 'PATH', "/usr/X11/bin", ':' - # CPPFLAGS are the C-PreProcessor flags, *not* C++! - append 'CPPFLAGS', "-I/usr/X11/include" - # Even without Xcode or the CLTs, /usr/X11/lib is there - append 'LDFLAGS', "-L/usr/X11/lib" + # 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 - # For Xcode 4.3 and above *without* CLT, we find the includes in the SDK: - # Only the SDK has got include files. (they are no longer in /usr/X11/include !) - # Todo: do we need to add cairo, fontconfig, GL, libpng15, pixman-1, VG, xcb, too? - append 'CFLAGS', "-I#{MacOS.sdk_path}/usr/X11/include" - append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/X11/include" - append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/X11/include/freetype2" - # The libs are still in /usr/X11/lib but to be consistent with the includes, we use the SDK, right? - append 'LDFLAGS', "-L#{MacOS.sdk_path}/usr/X11/lib" - append 'CMAKE_INCLUDE_PATH', "#{MacOS.sdk_path}/usr/X11/include", ':' + MacOS.sdk_path/'usr/X11' + end + + append 'CPPFLAGS', "-I#{prefix}/include" + + append 'CMAKE_PREFIX_PATH', prefix, ':' + append 'CMAKE_INCLUDE_PATH', prefix/'include', ':' + + unless MacOS.clt_installed? + append 'CPPFLAGS', "-I#{prefix}/include/freetype2" + append 'CFLAGS', "-I#{prefix}/include" end end alias_method :libpng, :x11 diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index 766e072184..632077dbf2 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -313,9 +313,16 @@ module MacOS extend self 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? - # Even if only Xcode (without CLT) is installed, this dylib is there. - Pathname.new('/usr/X11/lib/libpng.dylib').exist? + not x11_prefix.nil? end def macports_or_fink_installed?