From 292983c841b4facd5c48fcec9689448d66bcb90e Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Tue, 21 Nov 2023 16:08:04 -0500
Subject: [PATCH] distrib: Rediscover otool and install_name_tool on Darwin

In the bindist configure script we must rediscover the `otool` and
`install_name_tool`s since they may be different from the build
environment.

Fixes #24211.
---
 distrib/configure.ac.in | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 8a2016c1c8fa..ee096ce08568 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -206,6 +206,18 @@ dnl Identify C++ standard library flavour and location
 FP_FIND_CXX_STD_LIB
 AC_CONFIG_FILES([mk/system-cxx-std-lib-1.0.conf])
 
+dnl ** Which otool to use on macOS
+dnl --------------------------------------------------------------
+AC_CHECK_TARGET_TOOL([OTOOL], [otool])
+OtoolCmd="$OTOOL"
+AC_SUBST(OtoolCmd)
+
+dnl ** Which install_name_tool to use on macOS
+dnl --------------------------------------------------------------
+AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool])
+InstallNameToolCmd="$INSTALL_NAME_TOOL"
+AC_SUBST(InstallNameToolCmd)
+
 # Check that we have the same emsdk version as the one we were built with.
 ConfiguredEmsdkVersion=@ConfiguredEmsdkVersion@
 EMSDK_VERSION("", "", ${ConfiguredEmsdkVersion})
-- 
GitLab