waf-utils.eclass: Support --docdir and --htmldir
authorChris Mayo <aklhfex@gmail.com>
Tue, 24 Mar 2020 19:49:57 +0000 (19:49 +0000)
committerMikle Kolyada <zlogene@gentoo.org>
Wed, 1 Apr 2020 10:34:10 +0000 (13:34 +0300)
waf can optionally set the standard GNU directories [1].
Based on the code for econf in Portage's phase-helpers.sh.

[1] https://waf.io/apidocs/tools/gnu_dirs.html

Closes: https://bugs.gentoo.org/711612
Signed-off-by: Chris Mayo <aklhfex@gmail.com>
Signed-off-by: Mikle Kolyada <zlogene@gentoo.org>
eclass/waf-utils.eclass

index 2cb26bc8dfd9c9ae03eead941d44aa4a370c3570..a944195b1627675ea5740e70421a93072132b50a 100644 (file)
@@ -69,7 +69,7 @@ waf-utils_src_configure() {
 
        [[ ${fail} ]] && die "Invalid use of waf-utils.eclass"
 
-       local libdir=()
+       local conf_args=()
 
        # @ECLASS-VARIABLE: WAF_BINARY
        # @DESCRIPTION:
@@ -81,7 +81,15 @@ waf-utils_src_configure() {
        # @DESCRIPTION:
        # Variable specifying that you don't want to set the libdir for waf script.
        # Some scripts does not allow setting it at all and die if they find it.
-       [[ -z ${NO_WAF_LIBDIR} ]] && libdir=(--libdir="${EPREFIX}/usr/$(get_libdir)")
+       [[ -z ${NO_WAF_LIBDIR} ]] && conf_args+=(--libdir="${EPREFIX}/usr/$(get_libdir)")
+
+       local waf_help=$("${WAF_BINARY}" --help 2>/dev/null)
+       if [[ ${waf_help} == *--docdir* ]]; then
+               conf_args+=( --docdir="${EPREFIX}"/usr/share/doc/${PF} )
+       fi
+       if [[ ${waf_help} == *--htmldir* ]]; then
+               conf_args+=( --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html )
+       fi
 
        tc-export AR CC CPP CXX RANLIB
 
@@ -91,7 +99,7 @@ waf-utils_src_configure() {
                PKGCONFIG="$(tc-getPKG_CONFIG)"
                "${WAF_BINARY}"
                "--prefix=${EPREFIX}/usr"
-               "${libdir[@]}"
+               "${conf_args[@]}"
                "${@}"
                configure
        )