diff options
author | Gabor Pali <gabor.pali@ibm.com> | 2023-01-17 13:18:48 +0100 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2023-01-26 15:56:19 +0100 |
commit | 9536b9796b9f98dbcc2aa230edaa5f9f85b5dd17 (patch) | |
tree | bc2efd7baa8389d8b4a5972e219591dabfd20048 | |
parent | 88ebc65c0d0c464bf45b10ad6a3234dd07361975 (diff) | |
download | couchdb-9536b9796b9f98dbcc2aa230edaa5f9f85b5dd17.tar.gz |
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.
-rwxr-xr-x | configure | 27 | ||||
-rw-r--r-- | src/couch/rebar.config.script | 3 |
2 files changed, 29 insertions, 1 deletions
@@ -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,26 @@ 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 + + # This list is taken from src/couch/rebar.config.script, please keep them in sync. + 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 diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script index 2769de841..f1682f6b7 100644 --- a/src/couch/rebar.config.script +++ b/src/couch/rebar.config.script @@ -114,6 +114,9 @@ ProperConfig = case code:lib_dir(proper) of _ -> [{d, 'WITH_PROPER'}] end. +% The include directories (parameters for the `-I` C compiler flag) are +% considered in the `configure` script as a pre-check for their existence. +% Please keep them in sync. {JS_CFLAGS, JS_LDFLAGS} = case os:type() of {win32, _} when SMVsn == "1.8.5" -> { |