This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch fix-brew-sm-build
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d5cea60d39a2201ebcb4b04897daff9787bdcec6
Author: Robert Newson <[email protected]>
AuthorDate: Mon Sep 15 14:29:54 2025 +0100

    fix homebrew spidermonkey build
    
    and suppress Debian-specific calls when not on Debian.
---
 configure                     |  4 ++--
 src/couch/rebar.config.script | 22 +++++++++++-----------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index aada5855f..08808ce33 100755
--- a/configure
+++ b/configure
@@ -46,7 +46,7 @@ 
CLOUSEAU_URI=${CLOUSEAU_URI:-"https://github.com/cloudant-labs/clouseau/releases
 CLOUSEAU_VSN=${CLOUSEAU_VSN:-"2.25.0"}
 CLOUSEAU_DIR="$(pwd)"/clouseau
 ARCH="$(uname -m)"
-MULTIARCH_NAME="$(dpkg-architecture -q DEB_HOST_MULTIARCH || true)"
+MULTIARCH_NAME="$(which dpkg-architecture && dpkg-architecture -q 
DEB_HOST_MULTIARCH || true)"
 ERLANG_VER="$(run_erlang 'io:put_chars(erlang:system_info(otp_release)).')"
 ERLANG_OS="$(run_erlang 'case os:type() of {OS, _} -> io:format("~s~n", [OS]) 
end.')"
 
@@ -328,7 +328,7 @@ if [ "${WITH_SPIDERMONKEY}" = "true" ] && [ "${ERLANG_OS}" 
= "unix" ]; then
 
     # This list is taken from src/couch/rebar.config.script, please keep them 
in sync.
     if [ ! -d "/usr/include/${SM_HEADERS}" ] && \
-        [ ! -d "/usr/include/${MULTIARCH_NAME}/${SM_HEADERS}" ] && \
+        [ -n "${MULTIARCH_NAME}" -a ! -d 
"/usr/include/${MULTIARCH_NAME}/${SM_HEADERS}" ] && \
         [ ! -d "/usr/local/include/${SM_HEADERS}" ] && \
         [ ! -d "/opt/homebrew/include/${SM_HEADERS}" ]; then
         echo "ERROR: SpiderMonkey ${SM_VSN} is not found. Please specify with 
--spidermonkey-version."
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index 86d6d5934..1c9809902 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -153,21 +153,21 @@ end.
 
 DpkgArchitectureCmd = "dpkg-architecture -q DEB_HOST_MULTIARCH".
 GenericMozJSIncludePaths = "-I/usr/include/mozjs-" ++ SMVsn ++ " 
-I/usr/local/include/mozjs-" ++ SMVsn.
-GenericMozJSLibPaths = "-L/usr/local/lib -L/opt/homebrew/lib".
+GenericMozJSLibPaths = "-L/usr/local/lib".
 
-WithDpkgArchitecture = case os:find_executable("dpkg-architecture") of
-    false -> false;
-    _ -> true
-end.
+WithDpkgArchitecture = os:find_executable("dpkg-architecture") /= false.
+WithHomebrew = os:find_executable("brew") /= false.
 
-MozJSIncludePath = case WithDpkgArchitecture of
-    false -> GenericMozJSIncludePaths;
-    true -> GenericMozJSIncludePaths ++ " -I/usr/include/" ++ 
string:trim(os:cmd(DpkgArchitectureCmd)) ++ "/mozjs-" ++ SMVsn
+MozJSIncludePath = case {WithDpkgArchitecture, WithHomebrew} of
+    {false, false} -> GenericMozJSIncludePaths;
+    {true, false} -> GenericMozJSIncludePaths ++ " -I/usr/include/" ++ 
string:trim(os:cmd(DpkgArchitectureCmd)) ++ "/mozjs-" ++ SMVsn;
+    {false, true} -> GenericMozJSIncludePaths ++ " 
-I/opt/homebrew/include/mozjs-" ++ SMVsn
 end.
 
-MozJSLibPath = case WithDpkgArchitecture of
-    false -> GenericMozJSLibPaths;
-    true -> GenericMozJSLibPaths ++ " -L/usr/lib/" ++ 
string:trim(os:cmd(DpkgArchitectureCmd))
+MozJSLibPath = case {WithDpkgArchitecture, WithHomebrew} of
+    {false, false} -> GenericMozJSLibPaths;
+    {true, false} -> GenericMozJSLibPaths ++ " -L/usr/lib/" ++ 
string:trim(os:cmd(DpkgArchitectureCmd));
+    {false, true} -> GenericMozJSLibPaths ++ " -L/opt/homebrew/lib"
 end.
 
 % The include directories (parameters for the `-I` C compiler flag) are

Reply via email to