diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb index ec10a7e06eae7..0582969caa4d5 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb @@ -99,6 +99,16 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a MacOS::CLT::PKG_PATH end + # This is a workaround for the missing `m4` in Xcode CLT 15.3, which was + # reported in FB13679972. Apple has fixed this in Xcode CLT 16.0. + # See https://github.com/Homebrew/homebrew-core/issues/165388 + if deps.none? { |d| d.name == "m4" } && + MacOS.active_developer_dir == MacOS::CLT::PKG_PATH && + !File.exist?("#{MacOS::CLT::PKG_PATH}/usr/bin/m4") && + (gm4 = DevelopmentTools.locate("gm4").to_s).present? + self["M4"] = gm4 + end + generic_setup_build_environment(formula:, cc:, build_bottle:, bottle_arch:, testing_formula:, debug_symbols:) diff --git a/Library/Homebrew/shims/mac/super/m4 b/Library/Homebrew/shims/mac/super/m4 deleted file mode 100755 index d68a7fccb30d6..0000000000000 --- a/Library/Homebrew/shims/mac/super/m4 +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# This shim is a workaround for the missing `m4` in Xcode CLT 15.3. -# It can be removed after Apple provides a new CLT with a fix for FB13679972. -# See https://github.com/Homebrew/homebrew-core/issues/165388 - -# HOMEBREW_LIBRARY is set by bin/brew -# HOMEBREW_DEVELOPER_DIR is set by extend/ENV/super.rb -# shellcheck disable=SC2154 -source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh" - -try_exec_non_system "${SHIM_FILE}" "$@" - -if [[ -n "${HOMEBREW_DEVELOPER_DIR}" && ! -x "${HOMEBREW_DEVELOPER_DIR}/usr/bin/m4" ]] -then - safe_exec "/usr/bin/gm4" "$@" -fi - -exec "/usr/bin/m4" "$@"