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

vatamane pushed a commit to branch pr-4380-spidermonkey-check
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4a2e0a37106b678df30085dc668108907dcc5f62
Author: Gabor Pali <[email protected]>
AuthorDate: Tue Jan 17 13:18:48 2023 +0100

    chore(configure): be more defensive about SpiderMonkey location
    
    The `configure` script does not check whether SpiderMonkey
    actually exists at the presumed location.  This may go wrong when
    the user has a version different from the default one.  The
    mistake is spotted only in build time, indirectly, via missing
    header files.  That is too late and it may not be evident for the
    user what the problem is.
    
    Add a user-friendly safeguard for Unix-like systems to prevent
    this from happening.
---
 configure | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 7c9fb56a3..1db8d9c23 100755
--- a/configure
+++ b/configure
@@ -30,10 +30,15 @@ WITH_DOCS=1
 ERLANG_MD5="false"
 SKIP_DEPS=0
 
+run_erlang() {
+    erl -noshell -eval "$1" -eval "halt()."
+}
+
 COUCHDB_USER="$(whoami 2>/dev/null || echo couchdb)"
 SM_VSN=${SM_VSN:-"91"}
 ARCH="$(uname -m)"
-ERLANG_VER="$(erl -eval 'io:put_chars(erlang:system_info(otp_release)), 
halt().' -noshell)"
+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.')"
 
 . ${rootdir}/version.mk
 COUCHDB_VERSION=${vsn_major}.${vsn_minor}.${vsn_patch}
@@ -230,6 +235,25 @@ then
   exit 1
 fi
 
+if [ "${ERLANG_OS}" = "unix" ]
+then
+    case "${SM_VSN}" in
+        1.8.5)
+            SM_HEADERS="js"
+            ;;
+        *)  SM_HEADERS="mozjs-${SM_VSN}"
+            ;;
+        esac
+
+    if [ ! -d "/usr/include/${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."
+        exit 1
+    fi
+fi
+
 echo "==> configuring couchdb in rel/couchdb.config"
 cat > rel/couchdb.config << EOF
 % Licensed under the Apache License, Version 2.0 (the "License"); you may not

Reply via email to