From e831babc61f564316d26d79b4fb995c0661b056e Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 11 Mar 2021 07:15:48 +0530 Subject: [PATCH] Add support for specifying configure opts when building extensions from source --- src/scripts/common.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/scripts/common.sh b/src/scripts/common.sh index 4aef3bdd..9d17e2a3 100644 --- a/src/scripts/common.sh +++ b/src/scripts/common.sh @@ -291,6 +291,17 @@ php_src_tag() { echo "$php_src_tag" } +# Function to parse extension environment variables +parse_args() { + extension=$1 + suffix=$2 + up_extension=$(echo "$extension" | tr '[:lower:]' '[:upper:]') + var="${extension}_${suffix}" + up_var="${up_extension}_${suffix}" + output=$(echo "${!var} ${!up_var}" | sed "s/, */ /g") + echo "$output" | xargs -n 1 | sort | uniq | xargs +} + # Function to add required libraries add_libs() { libs=("$@") @@ -308,8 +319,10 @@ add_extension_from_github() { repo=$3 release=$4 prefix=$5 - libs_var="${extension}_LIBS" - IFS=' ' read -r -a libs <<< "${!libs_var}" + IFS=' ' read -r -a libs <<< "$(parse_args "$extension" LIBS)" + IFS=' ' read -r -a opts <<< "$(parse_args "$extension" CONFIGURE_OPTS)" + IFS=' ' read -r -a prefix_opts <<< "$(parse_args "$extension" CONFIGURE_PREFIX_OPTS)" + IFS=' ' read -r -a suffix_opts <<< "$(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)" ( add_devtools phpize delete_extension "$extension" @@ -318,7 +331,10 @@ add_extension_from_github() { git checkout "$release" || exit 1 git submodule update --init --recursive || exit 1 add_libs "${libs[@]}" - phpize && ./configure && make -j"$(nproc)" && sudo make install + phpize + sudo "${prefix_opts[@]}" ./configure "${suffix_opts[@]}" "${opts[@]}" + sudo make -j"$(nproc 2>/dev/null || sysctl -n hw.ncpu)" + sudo make install enable_extension "$extension" "$prefix" ) >/dev/null 2>&1 add_extension_log "$extension-$org/$repo@$release" "Installed and enabled"