aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory M. Turner <gmt@be-evil.net>2013-10-07 04:51:22 -0700
committerGregory M. Turner <gmt@be-evil.net>2013-10-07 04:51:22 -0700
commitc29d94855b759bdf2ea341baa4a66ee798976ee4 (patch)
tree2fd7e7c4b565b4e727908982c5c3a334d4bbc9f3 /eclass/autotools-utils.eclass
parenteclass/autotools-utils: Clone upstream (diff)
downloadgmt-c29d94855b759bdf2ea341baa4a66ee798976ee4.tar.gz
gmt-c29d94855b759bdf2ea341baa4a66ee798976ee4.tar.bz2
gmt-c29d94855b759bdf2ea341baa4a66ee798976ee4.zip
eclass/autotools-utils: @GET_LIBDIR@ substitution and ehooks
Several minor refinements to the autotools-utils flow of control. Ehooks are offered to control each major step of the process, @GET_LIBDIR@ substitution is performed during src_configure and src_compile, and tests are performed to ensure that the automagically generated configure arguments don't circumvent arguments explicitly provided by the user. Also myeconfargs is split into two variables, so that nobody implementing the autotools-utils-pre_src_configure hook mistakenly removes the autogenerated configure arguments due to an erroeous assumption that myeconfargs will have passed through unchanged (by making that assumption no longer erroneous). Signed-off-by: Gregory M. Turner <gmt@be-evil.net>
Diffstat (limited to 'eclass/autotools-utils.eclass')
-rw-r--r--eclass/autotools-utils.eclass161
1 files changed, 139 insertions, 22 deletions
diff --git a/eclass/autotools-utils.eclass b/eclass/autotools-utils.eclass
index 28acb3b..a8f4440 100644
--- a/eclass/autotools-utils.eclass
+++ b/eclass/autotools-utils.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-utils.eclass,v 1.70 2013/06/29 08:17:06 mgorny Exp $
+# $Header: $
# @ECLASS: autotools-utils.eclass
# @MAINTAINER:
@@ -113,7 +113,7 @@ esac
# appropriate packages to DEPEND yourself.
[[ ${AUTOTOOLS_AUTORECONF} ]] || : ${AUTOTOOLS_AUTO_DEPEND:=no}
-inherit autotools eutils libtool
+inherit autotools eutils libtool ehooker
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install src_test
@@ -398,8 +398,12 @@ autotools-utils_src_prepare() {
fi
fi
- [[ ${want_autoreconf} ]] && eautoreconf
- elibtoolize --patch-only
+ if ehook_fire autotools-utils-pre_src_prepare ; then
+ [[ ${want_autoreconf} ]] && eautoreconf
+ [[ ${AT_NOELIBTOOLIZE} != yes ]] && elibtoolize
+ fi
+
+ ehook_fire autotools-utils-post_src_prepare -u
}
# @FUNCTION: autotools-utils_src_configure
@@ -410,12 +414,19 @@ autotools-utils_src_prepare() {
# flags are known:
#
# IUSE="static-libs" passes --enable-shared and either --disable-static/--enable-static
-# to econf respectively.
+# 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.
# @CODE
# src_configure() {
# local myeconfargs=(
@@ -427,6 +438,29 @@ autotools-utils_src_prepare() {
# autotools-utils_src_configure
# }
# @CODE
+
+# @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
+# 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.
autotools-utils_src_configure() {
debug-print-function ${FUNCNAME} "$@"
@@ -435,33 +469,104 @@ autotools-utils_src_configure() {
[[ ${EAPI} == 2 ]] && ! use prefix && EPREFIX=
- # Common args
- local econfargs=()
+ # raweconfargs is a scratch-space
+ local raweconfargs=() othereconfargs=( "$@" ) i testvar
_check_build_dir
if "${ECONF_SOURCE}"/configure --help 2>&1 | grep -q '^ *--docdir='; then
- econfargs+=(
+ testvar=no # has a similar arg already?
+ for i in "${myeconfargs[@]}" "$@" ; do
+ if [[ ${i} == "--docdir="* ]] ; then
+ testvar=yes
+ fi
+ done
+ [[ ${testvar} == no ]] && othereconfargs+=(
--docdir="${EPREFIX}"/usr/share/doc/${PF}
)
fi
# Handle static-libs found in IUSE, disable them by default
if in_iuse static-libs; then
- econfargs+=(
- --enable-shared
- $(use_enable static-libs static)
- )
+ has "--enable-shared" "${myeconfargs[@]}" "${othereconfargs[@]}" || {
+ has "--disable-shared" "${myeconfargs[@]}" "${othereconfargs[@]}" || {
+ othereconfargs+=("--enable-shared")
+ debug-print "${FUNCNAME}: adding --enable-shared to othereconfargs (since in_iuse static-libs)"
+ }
+ }
+ has "--enable-static" "${myeconfargs[@]}" "${othereconfargs[@]}" || {
+ has "--disable-static" "${myeconfargs[@]}" "${othereconfargs[@]}" || {
+ othereconfargs+=("$(use_enable static-libs static)")
+ debug-print "${FUNCNAME}: adding $(use_enable static-libs static) to othereconfargs (since static-libs useflag $(
+ if use static-libs ; then
+ echo "is set"
+ else
+ echo "is not set"
+ fi
+ ))"
+ }
+ }
fi
- # Append user args
- econfargs+=("${myeconfargs[@]}")
+ 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
- econf "${econfargs[@]}" "$@"
+
+ # avoid any confusion these might cause for hook-listeners
+ unset neweconfarg oldeconfarg raweconfargs
+
+ ehook_fire autotools-utils-pre_src_configure && \
+ econf "${myeconfargs[@]}" "${othereconfargs[@]}"
+ ehook_fire autotools-utils-post_src_configure -u
+
popd > /dev/null || die
}
+# <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[@]}"
+}
+
# @FUNCTION: autotools-utils_src_compile
# @DESCRIPTION:
# The autotools src_compile function, invokes emake in specified BUILD_DIR.
@@ -470,7 +575,11 @@ autotools-utils_src_compile() {
_check_build_dir
pushd "${BUILD_DIR}" > /dev/null || die
- emake "$@" || die 'emake failed'
+ ehook_fire autotools-utils-pre_src_compile && {
+ _autotools-utils_libdir_subst_emake autotools-utils_src_compile "$@" || \
+ die 'emake failed'
+ }
+ ehook_fire autotools-utils-post_src_compile -u
popd > /dev/null || die
}
@@ -487,7 +596,10 @@ autotools-utils_src_install() {
_check_build_dir
pushd "${BUILD_DIR}" > /dev/null || die
- emake DESTDIR="${D}" "$@" install || die "emake install failed"
+ ehook_fire autotools-utils-pre_src_install && {
+ _autotools-utils_libdir_subst_emake autotools-utils_src_install DESTDIR="${D}" "$@" install || \
+ die "emake install failed"
+ }
popd > /dev/null || die
# Move docs installed by autotools (in EAPI < 4).
@@ -535,6 +647,9 @@ autotools-utils_src_install() {
if [[ ${prune_ltfiles} != none ]]; then
prune_libtool_files ${prune_ltfiles:+--${prune_ltfiles}}
fi
+ pushd "${BUILD_DIR}" > /dev/null || die
+ ehook_fire autotools-utils-post_src_install -u
+ popd > /dev/null || die
}
# @FUNCTION: autotools-utils_src_test
@@ -546,11 +661,13 @@ autotools-utils_src_test() {
_check_build_dir
pushd "${BUILD_DIR}" > /dev/null || die
- 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.'
+ 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
fi
-
+ ehook_fire autotools-utils-post_src_test -u
popd > /dev/null || die
}