public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [Survey || RFC] autotools-utils.eclass
@ 2010-05-25 11:02 Maciej Mrozowski
  2010-05-25 18:31 ` Mike Frysinger
  2010-05-25 21:34 ` Maciej Mrozowski
  0 siblings, 2 replies; 13+ messages in thread
From: Maciej Mrozowski @ 2010-05-25 11:02 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: Text/Plain, Size: 729 bytes --]

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

[-- Attachment #2: base.eclass.diff --]
[-- Type: text/x-patch, Size: 1160 bytes --]

Index: base.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/base.eclass,v
retrieving revision 1.50
diff -u -B -r1.50 base.eclass
--- base.eclass	12 Apr 2010 15:33:03 -0000	1.50
+++ base.eclass	25 May 2010 10:46:31 -0000
@@ -65,7 +65,7 @@
 # @FUNCTION: base_src_prepare
 # @DESCRIPTION:
 # The base src_prepare function, which is exported
-# EAPI is greater or equal to 2.
+# EAPI is greater or equal to 2. Here the PATCHES array is evaluated.
 base_src_prepare() {
 	debug-print-function $FUNCNAME "$@"
 	debug-print "$FUNCNAME: PATCHES=$PATCHES"
@@ -116,13 +116,12 @@
 # @FUNCTION: base_src_configure
 # @DESCRIPTION:
 # The base src_configure function, which is exported when
-# EAPI is greater or equal to 2. Runs basic econf. Here the PATCHES array is
-# evaluated.
+# EAPI is greater or equal to 2. Runs basic econf.
 base_src_configure() {
 	debug-print-function $FUNCNAME "$@"
 
 	# there is no pushd ${S} so we can override its place where to run
-	[[ -x ${ECONF_SOURCE:-.}/configure ]] && econf
+	[[ -x ${ECONF_SOURCE:-.}/configure ]] && econf $@
 }
 
 # @FUNCTION: base_src_compile

[-- Attachment #3: autotools-utils.eclass --]
[-- Type: text/plain, Size: 4916 bytes --]

# 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
}

[-- Attachment #4: clucene-0.9.21b-r1.ebuild --]
[-- Type: text/plain, Size: 1127 bytes --]

# 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/*
}

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-07-14  3:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 11:02 [gentoo-dev] [Survey || RFC] autotools-utils.eclass Maciej Mrozowski
2010-05-25 18:31 ` Mike Frysinger
2010-05-26  3:59   ` Maciej Mrozowski
2010-05-26  4:02     ` Maciej Mrozowski
2010-05-26  4:31     ` Mike Frysinger
2010-05-26  9:12       ` [gentoo-dev] " Duncan
2010-05-26  9:38         ` Maciej Mrozowski
2010-05-26 17:27           ` Mike Frysinger
2010-05-31 13:29             ` Maciej Mrozowski
2010-06-02 23:32               ` Nathan Phillip Brink
2010-07-07  0:16                 ` Maciej Mrozowski
2010-07-14  3:54                   ` Maciej Mrozowski
2010-05-25 21:34 ` Maciej Mrozowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox