use XQuartz when present

This commit is contained in:
Camillo Lugaresi 2012-06-05 22:21:15 +02:00 committed by Jack Nagel
parent 17e7b7eaa4
commit a07085df2d
2 changed files with 35 additions and 20 deletions

View File

@ -310,25 +310,33 @@ Please take one of the following actions:
def x11 def x11
opoo "You do not have X11 installed, this formula may not build." unless MacOS.x11_installed? opoo "You do not have X11 installed, this formula may not build." unless MacOS.x11_installed?
if MacOS.clt_installed? # There are some config scripts here that should go in the PATH. This
# For Xcode < 4.3 clt_installed? is true. So here is the old style /usr/X11: # path is always under MacOS.x11_prefix, even for Xcode-only systems.
# There are some config scripts (e.g. freetype) here that should go in the path prepend 'PATH', MacOS.x11_prefix/'bin', ':'
# (note we don't use MacOS.sdk_path here, because there is no ./usr/bin in there)
prepend 'PATH', "/usr/X11/bin", ':' # Similarily, pkgconfig files are only found under MacOS.x11_prefix.
# CPPFLAGS are the C-PreProcessor flags, *not* C++! prepend 'PKG_CONFIG_PATH', MacOS.x11_prefix/'lib/pkgconfig', ':'
append 'CPPFLAGS', "-I/usr/X11/include" prepend 'PKG_CONFIG_PATH', MacOS.x11_prefix/'share/pkgconfig', ':'
# Even without Xcode or the CLTs, /usr/X11/lib is there
append 'LDFLAGS', "-L/usr/X11/lib" 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 else
# For Xcode 4.3 and above *without* CLT, we find the includes in the SDK: MacOS.sdk_path/'usr/X11'
# Only the SDK has got include files. (they are no longer in /usr/X11/include !) end
# 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#{prefix}/include"
append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/X11/include"
append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/X11/include/freetype2" append 'CMAKE_PREFIX_PATH', prefix, ':'
# The libs are still in /usr/X11/lib but to be consistent with the includes, we use the SDK, right? append 'CMAKE_INCLUDE_PATH', prefix/'include', ':'
append 'LDFLAGS', "-L#{MacOS.sdk_path}/usr/X11/lib"
append 'CMAKE_INCLUDE_PATH', "#{MacOS.sdk_path}/usr/X11/include", ':' unless MacOS.clt_installed?
append 'CPPFLAGS', "-I#{prefix}/include/freetype2"
append 'CFLAGS', "-I#{prefix}/include"
end end
end end
alias_method :libpng, :x11 alias_method :libpng, :x11

View File

@ -313,9 +313,16 @@ module MacOS extend self
end end
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? def x11_installed?
# Even if only Xcode (without CLT) is installed, this dylib is there. not x11_prefix.nil?
Pathname.new('/usr/X11/lib/libpng.dylib').exist?
end end
def macports_or_fink_installed? def macports_or_fink_installed?