aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory M. Tuner <gmt@be-evil.net>2013-11-29 08:57:15 -0800
committerGregory M. Tuner <gmt@be-evil.net>2013-11-29 08:57:15 -0800
commit94f19e8191957bc27dbd3873f66e0346093332a6 (patch)
treef1dd4322853dee42d6f1d72a10beeb8262155367 /eclass/autotools-utils.eclass
parenteclass/autotools-multilib: use my-god-its-full-of-quotation-marks for debug o... (diff)
downloadgmt-94f19e8191957bc27dbd3873f66e0346093332a6.tar.gz
gmt-94f19e8191957bc27dbd3873f66e0346093332a6.tar.bz2
gmt-94f19e8191957bc27dbd3873f66e0346093332a6.zip
eclass/autotools-utils: Consistency/Elegance
Add myemakeargs, myemakeinstallargs, and myemaketestargs variables that work identically to myeconfargs. Also get rid of @GET_LIBDIR@ substitution as this is now handled in autotools-multilib (where it actually serves a purpose -- here, it more-or-less does not; the standard get-libdir function suffices if we are not being wrapped). Signed-off-by: Gregory M. Tuner <gmt@be-evil.net>
Diffstat (limited to 'eclass/autotools-utils.eclass')
-rw-r--r--eclass/autotools-utils.eclass218
1 files changed, 124 insertions, 94 deletions
diff --git a/eclass/autotools-utils.eclass b/eclass/autotools-utils.eclass
index 82105d5..5b74ffa 100644
--- a/eclass/autotools-utils.eclass
+++ b/eclass/autotools-utils.eclass
@@ -426,27 +426,13 @@ autotools-utils_src_prepare() {
return $_autotools_utils_src_prepare_result
}
-# @FUNCTION: autotools-utils_src_configure
-# @DESCRIPTION:
-# The src_configure function. For out of source build it creates build
-# directory and runs econf there. Configuration parameters defined
-# in myeconfargs are passed here to econf. Additionally following USE
-# flags are known:
-#
-# IUSE="static-libs" passes --enable-shared and either --disable-static/--enable-static
-# to econf respectively. Any occurance of "@GET_LIBDIR@" within the arguments
-# passed or the myeconfargs variable will be subsituted with the results of $(get_libdir)
-
# @VARIABLE: myeconfargs
# @DEFAULT_UNSET
# @DESCRIPTION:
# Optional econf arguments as Bash array. Should be defined before calling src_configure.
-# Any occurance of the string '@GET_LIBDIR@' within the provided arguments will be
-# substituted by invoking the get_libdir function just before the src_configure hooks
-# are fired and econf is invoked. This can be quite handy if you are consuming
-# autotools-utils.eclass indirectly via autotools-multilib.eclass, as the substitution
-# will be performed once for each ABI, with the appropriate substitution being made
-# corresponding to that ABI's environment.
+# If modified during autotools-utils-pre_src_configure ehook processing (but no ehook
+# supresses configure entirely by returning a nonzero value), then those changes will
+# be respected during econf invocation.
# @CODE
# src_configure() {
# local myeconfargs=(
@@ -461,26 +447,23 @@ autotools-utils_src_prepare() {
# @VARIABLE: othereconfargs
# @DESCRIPTION:
-# This variable is only visible to autotools-utils-{pre,post}_src_configure
-# ehook listeners. Like myeconfargs, it can be modified by the hook listener
-# code to affect the configure process, for informational purposes, or as part
-# of an alternative configure process implemented by an autotools-utils-pre_src_configure
-# hook-listener that overrides the configure process by implementing some
-# nonstandard configure process and returning a nonzero value.
-#
-# It contains those additional configure arguments which are scheduled for
+# Contains additional configure arguments which are scheduled for
# inclusion in the econf argument-list but do not come from myeconfargs (specifically,
# those arguments passed to the command-line of autotools-utils_src_configure or
-# generated by it automatically). Like myeconfargs, it will have undergone
-# @GET_LIBDIR@-substitution before the autotools-utils-pre_src_configure hook
-# is fired, so within hook listeners, any new arguments should use the actual
-# get_libdir function instead of the "@GET_LIBDIR@" syntax.
-#
-# The primary benefit of seprating this from myeconfargs is that if someone
-# coding the function calling src_configure assumes it can replace myeconfargs
-# wholesale with some alternative to the values that were passed in, during
-# the pre- ehook, the automagiclly generated arguments provided by
-# autotools-utils_src_configure will not be lost.
+# generated by it automatically).
+#
+# Like myeconfargs, it can be modified by autotools-utils-pre_src_configure
+# ehook listeners to change the configure process.
+
+# @FUNCTION: autotools-utils_src_configure
+# @DESCRIPTION:
+# The src_configure function. For out of source build it creates build
+# directory and runs econf there. Configuration parameters defined
+# in myeconfargs are passed here to econf. Additionally following USE
+# flags are known:
+#
+# IUSE="static-libs" passes --enable-shared and either --disable-static/--enable-static
+# to econf respectively.
autotools-utils_src_configure() {
debug-print-function ${FUNCNAME} "$@"
@@ -489,8 +472,7 @@ autotools-utils_src_configure() {
[[ ${EAPI} == 2 ]] && ! use prefix && EPREFIX=
- # raweconfargs is a scratch-space
- local raweconfargs=() othereconfargs=( "$@" ) i testvar
+ local othereconfargs=("$@") myeconfargs=("${myeconfargs[@]}") testvar
_check_build_dir
if "${ECONF_SOURCE}"/configure --help 2>&1 | grep -q '^ *--docdir='; then
@@ -527,42 +509,9 @@ autotools-utils_src_configure() {
}
fi
- raweconfargs=("${myeconfargs[@]}")
-
- # substitute libdir arguments, putting results back into new-and-improved myeconfargs
- local oldeconfarg neweconfarg
-
- # here we actually re-scope myeconfargs as a local variable.
- # this way, in any multibuild scenarios, we ensure that changes
- # made to myeconfargs here do not spill out into the enclosing
- # lexical scope, a behavior which folks are likely to find
- # quite confusing, I suspect.
- declare -a myeconfargs=( )
-
- # GET_LIBDIR substitution for myeconfargs
- for oldeconfarg in "${raweconfargs[@]}" ; do
- neweconfarg="$(get_libdir_subst "${oldeconfarg}")"
- [[ ${neweconfarg} == ${oldeconfarg} ]] || \
- einfo "patched libdir configure argument: \"${neweconfarg}\" for ABI ${ABI}"
- myeconfargs+=("${neweconfarg}")
- done
-
- # same deal for othereconfargs
- raweconfargs=("${othereconfargs[@]}")
- othereconfargs=( )
- for oldeconfarg in "${raweconfargs[@]}" ; do
- neweconfarg="$(get_libdir_subst "${oldeconfarg}")"
- [[ ${neweconfarg} == ${oldeconfarg} ]] || \
- einfo "patched libdir configure argument: \"${neweconfarg}\" for ABI ${ABO}"
- othereconfargs+=("${neweconfarg}")
- done
-
mkdir -p "${BUILD_DIR}" || die
pushd "${BUILD_DIR}" > /dev/null || die
- # avoid any confusion these might cause for hook-listeners
- unset neweconfarg oldeconfarg raweconfargs
-
local _autotools_utils_src_configure_result=0
ehook_fire autotools-utils-pre_src_configure && {
econf "${myeconfargs[@]}" "${othereconfargs[@]}"
@@ -574,33 +523,47 @@ autotools-utils_src_configure() {
return $_autotools_utils_src_configure_result
}
-# <funcname for informational display> [<arguments>]
-_autotools-utils_libdir_subst_emake() {
- [[ $# -lt 1 ]] && die "_autotools-utils_libdir_subst_emake: requires at least one argument"
- declare -a subst_emake_output=( )
- local subst_emake_oldarg subst_emake_newarg
- local subst_emake_funcname="$1"
- shift
- for subst_emake_oldarg in "$@" ; do
- subst_emake_newarg=$(get_libdir_subst "${subst_emake_oldarg}")
- [[ ${subst_emake_newarg} == ${subst_emake_oldarg} ]] || \
- einfo "${subst_emake_funcname}: Substituted emake argument \"${subst_emake_newarg}\" for ABI ${ABI}"
- subst_emake_output+=("${subst_emake_newarg}")
- done
- debug-print "${FUNCNAME} (for ${subst_emake_funcname}): emake ${subst_emake_output[*]}"
- emake "${subst_emake_output[@]}"
-}
+# @VARIABLE: myemakeargs
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Optional emake arguments as Bash array. Should be defined before calling src_compile
+# If modified during autotools-utils-pre_src_compile ehook processing (but no ehook
+# supresses emake entirely by returning a nonzero value), then those changes will
+# be respected during emake invocation.
+# @CODE
+# src_compile() {
+# local myemakeargs=(
+# -j1
+# FOO="${bar} ${baz}"
+# )
+# autotools-utils_src_compile
+# }
+# @CODE
+
+# @VARIABLE: otheremakeargs
+# @DESCRIPTION:
+# Contains additional compile arguments which are scheduled for
+# inclusion in the emake argument-list but do not come from myemakeargs (specifically,
+# those arguments passed to the command-line of autotools-utils_src_compile or
+# generated by it automatically).
+#
+# Like myemakeargs, it can be modified by autotools-utils-pre_src_compile
+# ehook listeners to change the compile process.
# @FUNCTION: autotools-utils_src_compile
# @DESCRIPTION:
# The autotools src_compile function, invokes emake in specified BUILD_DIR.
autotools-utils_src_compile() {
debug-print-function ${FUNCNAME} "$@"
+ [[ -z ${myemakeargs+1} || $(declare -p myemakeargs) == 'declare -a'* ]] \
+ || die 'autotools-utils.eclass: myemakeargs has to be an array.'
_check_build_dir
+ local myemakeargs=("${myemakeargs[@]}")
+ local otheremakeargs=("$@")
pushd "${BUILD_DIR}" > /dev/null || die
ehook_fire autotools-utils-pre_src_compile && {
- _autotools-utils_libdir_subst_emake autotools-utils_src_compile "$@" || \
+ emake "${myemakeargs[@]}" "${otheremakeargs[@]}" || \
die 'emake failed'
}
ehook_fire autotools-utils-post_src_compile -u
@@ -608,6 +571,33 @@ autotools-utils_src_compile() {
return 0
}
+# @VARIABLE: myemakeinstallargs
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Optional emake arguments as Bash array. Should be defined before calling src_install
+# If modified during autotools-utils-pre_src_install ehook processing (but no ehook
+# supresses emake entirely by returning a nonzero value), then those changes will
+# be respected during emake invocation during autotools-utils_src_install.
+# @CODE
+# src_install() {
+# local myemakeinstallargs=(
+# -j1
+# FOO="${bar} ${baz}"
+# )
+# autotools-utils_src_install
+# }
+# @CODE
+
+# @VARIABLE: otheremakeinstallargs
+# @DESCRIPTION:
+# Contains additional emake arguments which are scheduled for
+# inclusion in the emake argument-list but do not come from myemakeinstallargs (specifically,
+# those arguments passed to the command-line of autotools-utils_src_install or
+# generated by it automatically).
+#
+# Like myemakeinstallargs, it can be modified by autotools-utils-pre_src_install
+# ehook listeners to change the install process.
+
# @FUNCTION: autotools-utils_src_install
# @DESCRIPTION:
# The autotools src_install function. Runs emake install, unconditionally
@@ -619,10 +609,15 @@ autotools-utils_src_compile() {
autotools-utils_src_install() {
debug-print-function ${FUNCNAME} "$@"
+ [[ -z ${myemakeinstallargs+1} || $(declare -p myemakeinstallargs) == 'declare -a'* ]] \
+ || die 'autotools-utils.eclass: myemakeinstallargs has to be an array.'
+
_check_build_dir
+ local myemakeinstallargs=("${myemakeinstallargs[@]}")
+ local otheremakeinstallargs=("DESTDIR=${D}" "$@" "install")
pushd "${BUILD_DIR}" > /dev/null || die
ehook_fire autotools-utils-pre_src_install && {
- _autotools-utils_libdir_subst_emake autotools-utils_src_install DESTDIR="${D}" "$@" install || \
+ emake "${myemakeinstallargs[@]}" "${otheremakeinstallargs[@]}" || \
die "emake install failed"
}
popd > /dev/null || die
@@ -678,23 +673,58 @@ autotools-utils_src_install() {
return 0
}
+# @VARIABLE: myemaketestargs
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Optional emake arguments as Bash array. Should be defined before calling src_test
+# If modified during autotools-utils-pre_src_test ehook processing (but no ehook
+# supresses emake entirely by returning a nonzero value), then those changes will
+# be respected during emake invocation during autotools-utils_src_test.
+# @CODE
+# src_test() {
+# local myemaketestargs=(
+# -j1
+# FOO="${bar} ${baz}"
+# )
+# autotools-utils_src_test
+# }
+# @CODE
+
+# @VARIABLE: otheremaketestargs
+# @DESCRIPTION:
+# Contains additional emake arguments which are scheduled for
+# inclusion in the emake argument-list but do not come from myemaketestargs (specifically,
+# those arguments passed to the command-line of autotools-utils_src_test or
+# generated by it automatically).
+#
+# Like myemaketestargs, it can be modified by autotools-utils-pre_src_test
+# ehook listeners to change the test process.
+
# @FUNCTION: autotools-utils_src_test
# @DESCRIPTION:
# The autotools src_test function. Runs emake check in build directory.
autotools-utils_src_test() {
debug-print-function ${FUNCNAME} "$@"
+ [[ -z ${myemaketestargs+1} || $(declare -p myemaketestargs) == 'declare -a'* ]] \
+ || die 'autotools-utils.eclass: myemaketestargs has to be an array.'
+
_check_build_dir
- pushd "${BUILD_DIR}" > /dev/null || die
+ local myemaketestargs=("${myemaketestargs[@]}") otheremaketestargs=("$@") _how="dont"
+ pushd "${BUILD_DIR}" > /dev/null || die
+ if make -n check "${myemaketestargs[@]}" "${otheremaketestargs[@]}" &>/dev/null 2>&1 ; then
+ _how="check"
+ elif make -n test "${myemaketestargs[@]}" "${otheremaketestargs[@]}" &>/dev/null 2>&1 ; then
+ _how="test"
+ fi
+ [[ ${_how} != dont ]] && otheremaketestargs+=("${_how}")
if ehook_fire autotools-utils-pre_src_test ; then
- if make -n check "${@}" &>/dev/null; then
- emake check "${@}" || die 'emake check failed.'
- elif make -n test "${@}" &>/dev/null; then
- emake test "${@}" || die 'emake test failed.'
- fi
+ [[ ${_how} != dont ]] &&
+ emake "${myemaketestargs[@]}" "${otheremaketestargs[@]}" || die 'emake check failed.'
fi
ehook_fire autotools-utils-post_src_test -u
popd > /dev/null || die
+
return 0
}