Is anyone interested in cmake-utils like autotools/base wrapper?
Features:
- base.eclass autopatcher (including user patches)
- myeconfargs - econf arguments as Bash array (usage like mycmakeargs in
cmake-utils)
- out of source build (enabled by default) with overridable build dir location
- static archives handling (enable/disable static based on static-libs in
IUSE)
- libtool archives removal (depending on static-libs USE flag)
- enable/disable debug handling (debug in IUSE)
- cmake-utils resemblance (DOCS, HTML_DOCS variables)
- ???
- Profit!
Example usage in attached clucene-0.9.21b-r1.
Also a patch for base.eclass to make it's econf accept arguments + some random
function documentation fix.
--
regards
MM
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: autotools-utils.eclass
# @MAINTAINER:
# reavertm@gentoo.org
# @DESCRIPTION:
# autotools.eclass and base.eclass wrapper providing following features:
# - autopatcher (including user patches)
# - myeconfargs - econf arguments as Bash array
# - out of source build (enabled by default) with overridable build dir location
# - static archives handling (static-libs in IUSE)
# - libtool archives removal (depending on static-libs USE flag)
# - enable/disable debug handling (debug in IUSE)
# - cmake-utils resemblance (DOCS, HTML_DOCS variables)
# Keep variable names synced with cmake-utils!
case ${EAPI:-0} in
2|3|4) ;;
*) DEPEND="EAPI-TOO-OLD" ;;
esac
inherit autotools base
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install src_test
# @ECLASS-VARIABLE: AUTOTOOLS_IN_SOURCE_BUILD
# @DESCRIPTION:
# Set to enable in-source build.
# @FUNCTION: _check_build_dir
# @DESCRIPTION:
# Determine using IN or OUT source build
_check_build_dir() {
# @ECLASS-VARIABLE: ECONF_SOURCE
# @DESCRIPTION:
# Sets the directory where we are working with autotools.
# By default it uses ${S}.
: ${ECONF_SOURCE:=${S}}
# @ECLASS-VARIABLE: AUTOTOOLS_BUILD_DIR
# @DESCRIPTION:
# Specify the build directory where all autotools generated
# files should be located.
# For installing binary doins "${AUTOTOOLS_BUILD_DIR}/somefile"
if [[ -n ${AUTOTOOLS_IN_SOURCE_BUILD} ]]; then
# we build in source dir
AUTOTOOLS_BUILD_DIR="${ECONF_SOURCE}"
else
: ${AUTOTOOLS_BUILD_DIR:=${WORKDIR}/${P}_build}
fi
echo ">>> Working in BUILD_DIR: "$AUTOTOOLS_BUILD_DIR""
}
# @FUNCTION: autotools-utils_src_prepare
# @DESCRIPTION:
# The src_prepare function, which is exported EAPI is greater or equal to 2.
autotools-utils_src_prepare() {
debug-print-function $FUNCNAME "$@"
# TODO Maybe some smart patching and automatic eautoreconf call?
base_src_prepare
}
# @FUNCTION: autotools-utils_src_configure
# @DESCRIPTION:
# The src_configure function, which is exported when EAPI is greater or equal
# to 2. Runs basic econf. Here the PATCHES array is evaluated.
autotools-utils_src_configure() {
debug-print-function $FUNCNAME "$@"
# @ECLASS-VARIABLE: myeconfargs
# @DESCRIPTION:
# econf arguments as Bash array, enable shared libs by default
local econfargs=(
--enable-shared
${myeconfargs[@]}
)
# Handle debug found in IUSE
if has debug ${IUSE//+}; then
econfargs+=($(use_enable debug))
fi
# Handle static-libs found in IUSE, disable them by default
if has static-libs ${IUSE//+}; then
econfargs+=($(use_enable static-libs static))
else
econfargs+=(--disable-static)
fi
_check_build_dir
mkdir -p "${AUTOTOOLS_BUILD_DIR}" || die "mkdir '${AUTOTOOLS_BUILD_DIR}' failed"
pushd "${AUTOTOOLS_BUILD_DIR}" &> /dev/null
base_src_configure "${econfargs[@]}"
popd &> /dev/null
}
# @FUNCTION: autotools-utils_src_compile
# @DESCRIPTION:
# The autotools src_compile function, calls src_configure with EAPI older
# than 2.
autotools-utils_src_compile() {
debug-print-function $FUNCNAME "$@"
_check_build_dir
pushd "${AUTOTOOLS_BUILD_DIR}" &> /dev/null
base_src_compile "$@"
popd &> /dev/null
}
# @FUNCTION: autotools-utils_src_install
# @DESCRIPTION:
# The autotools src_install function. Runs make install, installs
# documents and html documents from DOCS and HTML_DOCS arrays
# and removes libtool files.
autotools-utils_src_install() {
debug-print-function $FUNCNAME "$@"
_check_build_dir
pushd "${AUTOTOOLS_BUILD_DIR}" &> /dev/null
base_src_install
popd &> /dev/null
# Remove libtool archives
if ! use static-libs && has static-libs ${IUSE//+}; then
find "${D}" -type f -name '*.la' -exec rm -f {} +
|| die 'libtool archive removal failed'
fi
# Manual document installation
# @ECLASS-VARIABLE: DOCS
# @DESCRIPTION:
# Documents passed to dodoc command.
[[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die 'dodoc failed' ; }
# @ECLASS-VARIABLE: HTML_DOCS
# @DESCRIPTION:
# Documents passed to dohtml command.
[[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die 'dohtml failed' ; }
}
# @FUNCTION: autotools-utils_src_test
# @DESCRIPTION:
# The autotools src_test function. Runs emake check in source directory.
autotools-utils_src_test() {
debug-print-function ${FUNCNAME} "$@"
_check_build_dir
pushd "${AUTOTOOLS_BUILD_DIR}" &> /dev/null
# Standard implementation of src_test
if emake -j1 check -n &> /dev/null; then
einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
if ! emake -j1 check; then
die 'Make check failed. See above for details.'
fi
elif emake -j1 test -n &> /dev/null; then
einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
if ! emake -j1 test; then
die 'Make test failed. See above for details.'
fi
else
einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
fi
popd &> /dev/null
}
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-cpp/clucene/clucene-0.9.21b-r1.ebuild,v 1.1 2010/05/25 06:41:03 reavertm Exp $
EAPI="2"
inherit autotools-utils
MY_P=${PN}-core-${PV}
DESCRIPTION="High-performance, full-featured text search engine based off of lucene in C++"
HOMEPAGE="http://clucene.sourceforge.net/"
SRC_URI="mirror://sourceforge/clucene/${MY_P}.tar.bz2"
LICENSE="|| ( Apache-2.0 LGPL-2.1 )"
SLOT="1"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos"
IUSE="debug doc static-libs threads"
DEPEND="doc? ( >=app-doc/doxygen-1.4.2 )"
RDEPEND=""
PATCHES=(
"${FILESDIR}"/${P}-gcc44.patch #254254
)
S="${WORKDIR}/${MY_P}"
src_configure() {
myeconfargs=(
$(use_enable debug cnddebug)
$(use_enable threads multithreading)
)
autotools-utils_src_configure
}
src_compile() {
autotools-utils_src_compile
use doc && autotools-utils_src_compile doxygen
}
src_install() {
autotools-utils_src_install
use doc && dohtml "${S}"/doc/html/*
}