aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory M. Turner <gmt@be-evil.net>2013-10-11 02:44:29 -0700
committerGregory M. Turner <gmt@be-evil.net>2013-10-11 02:45:03 -0700
commit415421d320f2ed940a17d91ba17d7a03b6c00fc3 (patch)
treef0396843751b910f2a9b4458b8b1c88862a6bc1f /eclass/multilib.eclass
parenteclass/*: noop: syntactic consistency: [[ ${foo} ]] vs [[ -n ${foo} ]] (diff)
downloadgmt-415421d320f2ed940a17d91ba17d7a03b6c00fc3.tar.gz
gmt-415421d320f2ed940a17d91ba17d7a03b6c00fc3.tar.bz2
gmt-415421d320f2ed940a17d91ba17d7a03b6c00fc3.zip
eclass/multilib: add do_with_get_libdir_subst convenience function for en-masse @GET_LIBDIR@ substitution in arguments before invocation of named function
Signed-off-by: Gregory M. Turner <gmt@be-evil.net>
Diffstat (limited to 'eclass/multilib.eclass')
-rw-r--r--eclass/multilib.eclass27
1 files changed, 27 insertions, 0 deletions
diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
index 1f268e8..aad705b 100644
--- a/eclass/multilib.eclass
+++ b/eclass/multilib.eclass
@@ -72,6 +72,33 @@ get_libdir_subst() {
return 0
}
+# @FUNCTION: do_with_get_libdir_subst
+# @USAGE: <function-name> [list-of-arguments]
+# @RETURN: Result code from invoking the named function
+# @DESCRIPTION:
+# Invokes the function <function-name> with the argument-list [list-of-arguments],
+# after substituting all occurences of "@GET_LIBDIR@" in [list-of-arguments]
+# with the results of $(get_libdir), being careful not to avoid word-splitting
+# if any arguments contain "IFS" characters. Guaranteed not to pollute the
+# lexical environment in any way or produce console text (assuming it is
+# invoked correctly). get_libdir substitution does not apply to the
+# <function-name> argument.
+do_with_get_libdir_subst() {
+ [[ $# -lt 1 ]] && die "requires at least one argument"
+ declare -a args=()
+ local arg
+ local fn="$1"
+ shift
+ for arg in "$@" ; do
+ args+=( "$( get_libdir_subst "${arg}" )" )
+ done
+ unset arg
+ set -- "${fn}" "${args[@]}"
+ unset args
+ unset fn
+ "$@"
+}
+
# @FUNCTION: get_abi_var
# @USAGE: <VAR> [ABI]
# @RETURN: returns the value of ${<VAR>_<ABI>} which should be set in make.defaults