-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-# $Id$
# @ECLASS: waf-utils.eclass
# @MAINTAINER:
# Original Author: Gilles Dartiguelongue <eva@gentoo.org>
# Various improvements based on cmake-utils.eclass: Tomáš Chvátal <scarabeus@gentoo.org>
# Proper prefix support: Jonathan Callen <jcallen@gentoo.org>
+# @SUPPORTED_EAPIS: 4 5 6
# @BLURB: common ebuild functions for waf-based packages
# @DESCRIPTION:
# The waf-utils eclass contains functions that make creating ebuild for
# waf-based packages much easier.
# Its main features are support of common portage default settings.
-inherit eutils multilib toolchain-funcs multiprocessing
+[[ ${EAPI} == [45] ]] && inherit eutils
+inherit multilib toolchain-funcs multiprocessing
case ${EAPI:-0} in
4|5|6) EXPORT_FUNCTIONS src_configure src_compile src_install ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
-# Python with threads is required to run waf. We do not know which python slot
-# is being used as the system interpreter, so we are forced to block all
-# slots that have USE=-threads.
-DEPEND="${DEPEND}
- dev-lang/python
- !dev-lang/python[-threads]"
-
# @ECLASS-VARIABLE: WAF_VERBOSE
# @DESCRIPTION:
# Set to OFF to disable verbose messages during compilation
fi
fi
- [[ ${fail} ]] || die "Invalid use of ${ECLASS}"
-
- local libdir=""
+ [[ ${fail} ]] && die "Invalid use of waf-utils.eclass"
# @ECLASS-VARIABLE: WAF_BINARY
# @DESCRIPTION:
# Eclass can use different waf executable. Usually it is located in "${S}/waf".
: ${WAF_BINARY:="${S}/waf"}
- # @ECLASS-VARIABLE: NO_WAF_LIBDIR
- # @DEFAULT_UNSET
- # @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)"
+ local conf_args=()
- tc-export AR CC CPP CXX RANLIB
- echo "CCFLAGS=\"${CFLAGS}\" LINKFLAGS=\"${CFLAGS} ${LDFLAGS}\" \"${WAF_BINARY}\" --prefix=${EPREFIX}/usr ${libdir} $@ configure"
-
- # This condition is required because waf takes even whitespace as function
- # calls, awesome isn't it?
- if [[ -z ${NO_WAF_LIBDIR} ]]; then
- CCFLAGS="${CFLAGS}" LINKFLAGS="${CFLAGS} ${LDFLAGS}" "${WAF_BINARY}" \
- "--prefix=${EPREFIX}/usr" \
- "${libdir}" \
- "$@" \
- configure || die "configure failed"
- else
- CCFLAGS="${CFLAGS}" LINKFLAGS="${CFLAGS} ${LDFLAGS}" "${WAF_BINARY}" \
- "--prefix=${EPREFIX}/usr" \
- "$@" \
- configure || die "configure failed"
+ 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
+ if [[ ${waf_help} == *--libdir* ]]; then
+ conf_args+=( --libdir="${EPREFIX}/usr/$(get_libdir)" )
+ fi
+
+ tc-export AR CC CPP CXX RANLIB
+
+ local CMD=(
+ CCFLAGS="${CFLAGS}"
+ LINKFLAGS="${CFLAGS} ${LDFLAGS}"
+ PKGCONFIG="$(tc-getPKG_CONFIG)"
+ "${WAF_BINARY}"
+ "--prefix=${EPREFIX}/usr"
+ "${conf_args[@]}"
+ "${@}"
+ configure
+ )
+
+ echo "${CMD[@]@Q}" >&2
+ env "${CMD[@]}" || die "configure failed"
}
# @FUNCTION: waf-utils_src_compile
waf-utils_src_compile() {
debug-print-function ${FUNCNAME} "$@"
local _mywafconfig
- [[ "${WAF_VERBOSE}" ]] && _mywafconfig="--verbose"
+ [[ ${WAF_VERBOSE} == ON ]] && _mywafconfig="--verbose"
local jobs="--jobs=$(makeopts_jobs)"
- echo "\"${WAF_BINARY}\" build ${_mywafconfig} ${jobs}"
- "${WAF_BINARY}" ${_mywafconfig} ${jobs} || die "build failed"
+ echo "\"${WAF_BINARY}\" build ${_mywafconfig} ${jobs} ${*}"
+ "${WAF_BINARY}" ${_mywafconfig} ${jobs} "${@}" || die "build failed"
}
# @FUNCTION: waf-utils_src_install
waf-utils_src_install() {
debug-print-function ${FUNCNAME} "$@"
- echo "\"${WAF_BINARY}\" --destdir=\"${D}\" install"
- "${WAF_BINARY}" --destdir="${D}" install || die "Make install failed"
+ echo "\"${WAF_BINARY}\" --destdir=\"${D}\" ${*} install"
+ "${WAF_BINARY}" --destdir="${D}" "${@}" install || die "Make install failed"
# Manual document installation
einstalldocs