diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb index 049fa6adce..2df379cde5 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb @@ -97,12 +97,14 @@ module Stdenv end # Some configure scripts won't find libxml2 without help + # This is a no-op with macOS SDK 10.15.4 and later def libxml2 - if !MacOS.sdk_path_if_needed + sdk = MacOS.sdk_path_if_needed + if !sdk append "CPPFLAGS", "-I/usr/include/libxml2" - else + elsif !(sdk/"usr/include/libxml").directory? # Use the includes form the sdk - append "CPPFLAGS", "-I#{MacOS.sdk_path}/usr/include/libxml2" + append "CPPFLAGS", "-I#{sdk}/usr/include/libxml2" end end diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb index acbdd982fd..104aa9861f 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb @@ -42,9 +42,17 @@ module Superenv paths end + # @private + def libxml2_include_needed? + return false if deps.any? { |d| d.name == "libxml2" } + return false if Pathname("#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml").directory? + + true + end + def homebrew_extra_isystem_paths paths = [] - paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" unless deps.any? { |d| d.name == "libxml2" } + paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" @@ -64,7 +72,7 @@ module Superenv def homebrew_extra_cmake_include_paths paths = [] - paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" unless deps.any? { |d| d.name == "libxml2" } + paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"