[gentoo-dev] New eclass: autotools-multilib-minimal

2013-02-23 Thread hasufell
Some people seem to feel uncomfortable with autotools-multilib, because
it depends on autotools-utils.

Instead of arguing whether it makes sense or not I'd propose a similar
autotools related eclass.

I also attach an example conversion of media-libs/libexif (the
maintainer wants to keep the changes minimal).
Effectively I am only (almost) changing the function names and not the
ebuild code.

Feel free to propose a different eclass name.
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: autotools-multilib-minimal.eclass
# @MAINTAINER:
# Julian Ospald hasuf...@gentoo.org
# @BLURB: wrapper for multilib builds providing convenient multilib_src_* 
functions
# @DESCRIPTION:
#
# src_configure, src_compile, src_test and src_install are exported
# use multilib_src_* instead of src_* which runs this phase for
# all enabled ABIs
#
# if you need generic install rules, use multilib_src_install_all function

# @ECLASS-VARIABLE: AUTOTOOLS_IN_SOURCE_BUILD
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set to enable in-source build.
# If you enable this, ensure that prepabisources is called
# at the END of src_prepare!


# EAPI=5 is required for meaningful MULTILIB_USEDEP.
case ${EAPI:-0} in
5) ;;
*) die EAPI=${EAPI} is not supported ;;
esac

inherit multilib-build

EXPORT_FUNCTIONS src_configure src_compile src_test src_install

prepabisources() {
if [[ $AUTOTOOLS_IN_SOURCE_BUILD ]] ; then
einfo Copying sources to abi-specific dirs

prepabisources() {
cp -pR ${S} ${BUILD_DIR} || die failed to copy 
sources
}
multilib_foreach_abi prepabisources
fi
}

autotools-multilib-minimal_src_configure() {
local myeconfsource
if [[ $AUTOTOOLS_IN_SOURCE_BUILD ]] ; then
myeconfsource=.
else
myeconfsource=${S}
fi

_autotools-multilib-minimal_src_configure() {
einfo Configuring for ${ABI}

mkdir -p ${BUILD_DIR} || die
pushd ${BUILD_DIR} /dev/null || die
if declare -f multilib_src_configure /dev/null ; then
ECONF_SOURCE=${myeconfsource} multilib_src_configure
else
ECONF_SOURCE=${myeconfsource} default_src_configure
fi
popd /dev/null || die
}
multilib_foreach_abi _autotools-multilib-minimal_src_configure
}

autotools-multilib-minimal_src_compile() {
_autotools-multilib-minimal_src_compile() {
einfo Compiling for ${ABI}

pushd ${BUILD_DIR} /dev/null || die
if declare -f multilib_src_compile /dev/null ; then
multilib_src_compile
else
default_src_compile
fi
popd /dev/null || die
}
multilib_foreach_abi _autotools-multilib-minimal_src_compile
}

autotools-multilib-minimal_src_test() {
_autotools-multilib-minimal_src_test() {
einfo Testing for ${ABI}

pushd ${BUILD_DIR} /dev/null || die
if declare -f multilib_src_test /dev/null ; then
multilib_src_test
else
default_src_test
fi
popd /dev/null || die
}
multilib_foreach_abi _autotools-multilib-minimal_src_test
}

autotools-multilib-minimal_src_install() {
_autotools-multilib-minimal_src_install() {
einfo Installing for ${ABI}

pushd ${BUILD_DIR} /dev/null || die
if declare -f multilib_src_install /dev/null ; then
multilib_src_install
else
default_src_install 
fi
multilib_check_headers
popd /dev/null || die
}
multilib_foreach_abi _autotools-multilib-minimal_src_install

if declare -f multilib_src_install_all /dev/null ; then
multilib_src_install_all
fi
}
--- media-libs/libexif/libexif-0.6.21.ebuild
+++ media-libs/libexif/libexif-0.6.21-r1.ebuild
@@ -2,8 +2,8 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/media-libs/libexif/libexif-0.6.21.ebuild,v 
1.8 2012/11/07 19:03:58 grobian Exp $
 
-EAPI=4
-inherit eutils libtool
+EAPI=5
+inherit autotools-multilib-minimal eutils libtool
 
 DESCRIPTION=Library for parsing, editing, and saving EXIF data
 HOMEPAGE=http://libexif.sourceforge.net/;
@@ -11,7 +11,7 @@
 
 LICENSE=LGPL-2.1
 SLOT=0
-KEYWORDS=alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 
~amd64-fbsd ~x86-fbsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos 
~x64-macos ~x86-macos ~x64-solaris ~x86-solaris
+KEYWORDS=~alpha ~amd64 ~arm ~hppa ~ia64 ~mips 

Re: [gentoo-dev] New eclass: autotools-multilib-minimal

2013-02-23 Thread hasufell
Before people start asking I should explain why I started this:
https://bugs.gentoo.org/show_bug.cgi?id=458638

I think having such an eclass has several advantages over
autootools-multilib.eclass (which depends on autotools-utils.eclass) as
it is now:

a) Less eclass dependencies. One could argue: the more eclasses my
ebuild uses the more prone to error and exposed to changes it is.
b) easier conversion in some cases: often times a simple rename
src_compile - multilib_src_compile will do
c) it allows more custom definition of phase functions
d) the previous point will also allow to convert go-mono.eclass packages
without introducing yet another eclass for that
e) autotools-utils.eclass does a bit more than just calling default
phase functions; the developer has little choice on this matter unless
he wants to rewrite his ebuild based on multilib-build.eclass which will
create a lot of code duplication in ebuilds, hence this proposition

I don't have a problem with the present eclasses, but I find this a
logical enhancement.