superenv only adds X11 paths if required

Since we are moving towards only depending on X11 for X-headers, superenv now doesn't automatically add X11 compilation. I was reluctant to do this, but it is the right thing to do now that X11 is not automatically installed by OS X or Xcode.

I didn't implement ENV.x11 because the order that the X headers are inserted is important. It must be done at initial setup to ensure that brewed versions of e.g. freetype and Cairo are used and not the ones installed by XQuartz.
This commit is contained in:
Max Howell 2012-08-29 11:19:39 -04:00
parent b834027b17
commit a360a41472
2 changed files with 9 additions and 5 deletions

View File

@ -83,6 +83,7 @@ def install f
if superenv? if superenv?
ENV.deps = keg_only_deps.map(&:to_s) ENV.deps = keg_only_deps.map(&:to_s)
ENV.x11 = f.requirements.detect{|rq| rq.class == X11Dependency }
ENV.setup_build_environment ENV.setup_build_environment
class << ENV class << ENV
def []=(key, value) def []=(key, value)

View File

@ -24,6 +24,8 @@ end
class << ENV class << ENV
attr :deps, true attr :deps, true
attr :x11, true
alias_method :x11?, :x11
def reset def reset
%w{CC CXX LD CPP OBJC MAKE %w{CC CXX LD CPP OBJC MAKE
@ -100,7 +102,7 @@ class << ENV
end end
paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" } paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" }
paths << HOMEBREW_PREFIX/:bin paths << HOMEBREW_PREFIX/:bin
paths << "#{MacSystem.x11_prefix}/bin" paths << "#{MacSystem.x11_prefix}/bin" if x11?
paths += %w{/usr/bin /bin /usr/sbin /sbin} paths += %w{/usr/bin /bin /usr/sbin /sbin}
paths.to_path_s paths.to_path_s
end end
@ -111,7 +113,7 @@ class << ENV
paths << "#{HOMEBREW_REPOSITORY}/lib/pkgconfig" paths << "#{HOMEBREW_REPOSITORY}/lib/pkgconfig"
paths << "#{HOMEBREW_REPOSITORY}/share/pkgconfig" paths << "#{HOMEBREW_REPOSITORY}/share/pkgconfig"
# we put our paths before X because we dupe some of the X libraries # we put our paths before X because we dupe some of the X libraries
paths << "#{MacSystem.x11_prefix}/lib/pkgconfig" << "#{MacSystem.x11_prefix}/share/pkgconfig" paths << "#{MacSystem.x11_prefix}/lib/pkgconfig" << "#{MacSystem.x11_prefix}/share/pkgconfig" if x11?
# Mountain Lion no longer ships some .pcs; ensure we pick up our versions # Mountain Lion no longer ships some .pcs; ensure we pick up our versions
paths << "#{HOMEBREW_REPOSITORY}/Library/Homebrew/pkgconfig" if MacOS.mountain_lion? paths << "#{HOMEBREW_REPOSITORY}/Library/Homebrew/pkgconfig" if MacOS.mountain_lion?
paths.to_path_s paths.to_path_s
@ -121,13 +123,14 @@ class << ENV
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}" } paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}" }
paths << "#{MacOS.sdk_path}/usr" if MacSystem.xcode43_without_clt? paths << "#{MacOS.sdk_path}/usr" if MacSystem.xcode43_without_clt?
paths << HOMEBREW_PREFIX.to_s # again always put ourselves ahead of X11 paths << HOMEBREW_PREFIX.to_s # again always put ourselves ahead of X11
paths << MacSystem.x11_prefix paths << MacSystem.x11_prefix if x11?
paths.to_path_s paths.to_path_s
end end
def determine_cmake_include_path def determine_cmake_include_path
sdk = MacOS.sdk_path if MacSystem.xcode43_without_clt? sdk = MacOS.sdk_path if MacSystem.xcode43_without_clt?
paths = %W{#{MacSystem.x11_prefix}/include/freetype2} paths = []
paths << "#{MacSystem.x11_prefix}/include/freetype2" if x11?
paths << "#{sdk}/usr/include/libxml2" unless deps.include? 'libxml2' paths << "#{sdk}/usr/include/libxml2" unless deps.include? 'libxml2'
# TODO prolly shouldn't always do this? # TODO prolly shouldn't always do this?
paths << "#{sdk}/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7" if MacSystem.xcode43_without_clt? paths << "#{sdk}/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7" if MacSystem.xcode43_without_clt?
@ -137,7 +140,7 @@ class << ENV
def determine_aclocal_path def determine_aclocal_path
paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/share/aclocal" } paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/share/aclocal" }
paths << "#{HOMEBREW_PREFIX}/share/aclocal" paths << "#{HOMEBREW_PREFIX}/share/aclocal"
paths << "/opt/X11/share/aclocal" paths << "/opt/X11/share/aclocal" if x11?
paths.to_path_s paths.to_path_s
end end