From a360a41472cad35dfdf81d1551df55b442a22ba1 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 29 Aug 2012 11:19:39 -0400 Subject: [PATCH] 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. --- Library/Homebrew/build.rb | 1 + Library/Homebrew/superenv.rb | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index 77960f8ee9..99e8a35505 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -83,6 +83,7 @@ def install f if superenv? ENV.deps = keg_only_deps.map(&:to_s) + ENV.x11 = f.requirements.detect{|rq| rq.class == X11Dependency } ENV.setup_build_environment class << ENV def []=(key, value) diff --git a/Library/Homebrew/superenv.rb b/Library/Homebrew/superenv.rb index 50ae6aa932..5bf815dcb4 100644 --- a/Library/Homebrew/superenv.rb +++ b/Library/Homebrew/superenv.rb @@ -24,6 +24,8 @@ end class << ENV attr :deps, true + attr :x11, true + alias_method :x11?, :x11 def reset %w{CC CXX LD CPP OBJC MAKE @@ -100,7 +102,7 @@ class << ENV end paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/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.to_path_s end @@ -111,7 +113,7 @@ class << ENV paths << "#{HOMEBREW_REPOSITORY}/lib/pkgconfig" paths << "#{HOMEBREW_REPOSITORY}/share/pkgconfig" # 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 paths << "#{HOMEBREW_REPOSITORY}/Library/Homebrew/pkgconfig" if MacOS.mountain_lion? paths.to_path_s @@ -121,13 +123,14 @@ class << ENV paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}" } paths << "#{MacOS.sdk_path}/usr" if MacSystem.xcode43_without_clt? 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 end def determine_cmake_include_path 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' # 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? @@ -137,7 +140,7 @@ class << ENV def determine_aclocal_path paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/share/aclocal" } paths << "#{HOMEBREW_PREFIX}/share/aclocal" - paths << "/opt/X11/share/aclocal" + paths << "/opt/X11/share/aclocal" if x11? paths.to_path_s end