This is an automated email from the ASF dual-hosted git repository. ronny pushed a commit to branch dev/detect-multiarch in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 17d05a471aed4094b4655766ed6599f9a2d5e214 Author: Ronny Berndt <[email protected]> AuthorDate: Fri Aug 22 19:34:50 2025 +0200 dev: Automatic version detection and flags simplification --- configure | 4 +-- src/couch/rebar.config.script | 58 +++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/configure b/configure index f2b23824a..423b650a5 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)" -MULTIARCHNAME="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" +MULTIARCH_NAME="$(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/${MULTIARCHNAME}" ] && \ + [ ! -d "/usr/include/${MULTIARCH_NAME}" ] && \ [ ! -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 c4e0b7a7e..32f9b1b24 100644 --- a/src/couch/rebar.config.script +++ b/src/couch/rebar.config.script @@ -151,6 +151,25 @@ ProperConfig = case code:lib_dir(proper) of _ -> [{d, 'WITH_PROPER'}] 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". + +WithDpkgArchitecture = case os:find_executable("dpkg-architecture") of + false -> false; + _ -> true +end. + +MozJSIncludePath = case WithDpkgArchitecture of + false -> GenericMozJSIncludePaths; + true -> GenericMozJSIncludePaths ++ " -I/usr/include/" ++ string:strip(os:cmd(DpkgArchitectureCmd), right, $\n) ++ "/mozjs-" ++ SMVsn +end. + +MozJSLibPath = case WithDpkgArchitecture of + false -> GenericMozJSLibPaths; + true -> GenericMozJSLibPaths ++ " -L/usr/lib/" ++ string:strip(os:cmd(DpkgArchitectureCmd), right, $\n) +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. @@ -195,48 +214,27 @@ end. "-DXP_UNIX -I/usr/include/mozjs-86 -I/usr/local/include/mozjs-86 -I/opt/homebrew/include/mozjs-86/ -std=c++17 -Wno-invalid-offsetof", "-L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-86 -lm" }; - {unix, _} when SMVsn == "91" -> - { - "$CFLAGS -DXP_UNIX -I/usr/include/mozjs-91 -I/usr/local/include/mozjs-91 -I/opt/homebrew/include/mozjs-91/ -std=c++17 -Wno-invalid-offsetof", - "$LDFLAGS -L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-91 -lm" - }; - {unix, _} when SMVsn == "102" -> + {unix, _} when SMVsn == "91"; SMVsn == "102"; SMVsn == "115"; SMVsn == "128" -> { - "$CFLAGS -DXP_UNIX -I/usr/include/mozjs-102 -I/usr/local/include/mozjs-102 -I/opt/homebrew/include/mozjs-102/ -std=c++17 -Wno-invalid-offsetof", - "$LDFLAGS -L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-102 -lm" - }; - {unix, _} when SMVsn == "115" -> - { - "$CFLAGS -DXP_UNIX -I/usr/include/mozjs-115 -I/usr/local/include/mozjs-115 -I/opt/homebrew/include/mozjs-115/ -std=c++17 -Wno-invalid-offsetof", - "$LDFLAGS -L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-115 -lm" - }; - {unix, _} when SMVsn == "128" -> - { - "$CFLAGS -DXP_UNIX -I/usr/include/mozjs-128 -I/usr/local/include/mozjs-128 -I/opt/homebrew/include/mozjs-128/ -std=c++17 -Wno-invalid-offsetof", - "$LDFLAGS -L/usr/local/lib -L /opt/homebrew/lib/ -std=c++17 -lmozjs-128 -lm" + "$CFLAGS -DXP_UNIX " ++ MozJSIncludePath ++ " -std=c++17 -Wno-invalid-offsetof", + "$LDFLAGS " ++ MozJSLibPath ++ " -std=c++17 -lm -lmozjs-" ++ SMVsn }; {win32, _} when SMVsn == "91" -> { "/std:c++17 /DXP_WIN", "$LDFLAGS mozjs-91.lib" }; - {win32, _} when SMVsn == "102" -> - { - "/std:c++17 /DXP_WIN /Zc:preprocessor /utf-8", - "$LDFLAGS mozjs-102.lib" - }; - {win32, _} when SMVsn == "115" -> - { - "/std:c++17 /DXP_WIN /Zc:preprocessor /utf-8", - "$LDFLAGS mozjs-115.lib" - }; - {win32, _} when SMVsn == "128" -> + {win32, _} when SMVsn == "102"; SMVsn == "115"; SMVsn == "128" -> { "/std:c++17 /DXP_WIN /Zc:preprocessor /utf-8", - "$LDFLAGS mozjs-128.lib" + "$LDFLAGS mozjs-" ++ SMVsn ++ ".lib" } end. +% io:format(standard_error, "JS_CFLAGS: ~s~n", [JS_CFLAGS]). +% io:format(standard_error, "JS_LDFLAGS: ~s~n", [JS_LDFLAGS]). +% erlang:halt(1). + CouchJSSrc = case SMVsn of "1.8.5" -> ["priv/couch_js/1.8.5/*.c"]; "60" -> ["priv/couch_js/60/*.cpp"];
