Hi,
This is an eclass that provides functionality needed to further split
poppler into its constituent libraries and utilities. The current way
of doing this, where we have poppler with utils in app-text/poppler and
the bindings for qt3, qt4 and glib in app-text/poppler-bindings is
suboptimal.
1) it requires us to either enable by default a useflag that will pull
in a major toolkit or die when all use-flags are unset.
2) The cairo use-flag is a subset of the gtk use-flag (which is in
itself misnamed) and thus enabling [cairo] will enable [gtk] but
without this being reflected in the metadata.
Also, as part of the restructuring, I will be able to move packages
around a bit so the libs are put in dev-libs/poppler{,-glib,-qt3,-qt4}
and the utils are put in app-text/poppler-utils.
Without further ado, the eclass:
inherit base multilib
has 2 ${EAPI} || DEPEND=EAPI-TOO-OLD
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
# @ECLASS-VARIABLE: HOMEPAGE
# @DESCRIPTION:
# HOMEPAGE is set to http://poppler.freedesktop.org
HOMEPAGE=http://poppler.freedesktop.org/;
# @ECLASS-VARIABLE: SRC_URI
# @DESCRIPTION:
# SRC_URI is set to http://poppler.freedesktop.org/poppler-${PV}.tar.gz
SRC_URI=http://poppler.freedesktop.org/poppler-${PV}.tar.gz;
# @ECLASS-VARIABLE: S
# @DESCRIPTION:
# S is set to ${WORKDIR}/poppler-${PV}
S=${WORKDIR}/poppler-${PV}
# @ECLASS-VARIABLE: POPPLER_MODULE
# @DESCRIPTION:
# The name of the poppler module. Must be set by the ebuild before inheriting
# the poppler eclass.
POPPLER_MODULE=${POPPLER_MODULE}
# @ECLASS-VARIABLE: POPPLER_MODULE_S
# @DESCRIPTION:
# The working directory of the poppler module. Set by default to
# ${S}/${POPPLER_MODULE}
POPPLER_MODULE_S=${S}/${POPPLER_MODULE}
# @FUNCTION: pkg_check_modules_override
# @USAGE: GROUP [package1] [package2]
# @DESCRIPTION:
# Will export the appropriate variables to override PKG_CHECK_MODULES autoconf
# macros, with the string by default. If packages are specified, they will
# be looked up with pkg-config and the appropriate LIBS and CFLAGS substituted.
# LIBS and CFLAGS can also be specified per-package with the following syntax:
# @CODE
# package=LIBS%CFLAGS
# @CODE
# = and % have no effect unless both are specified.
# Here is an example:
# @CODE
# pkg_check_modules_override GASH gtk+-2.0=-jule% gobject-2.0
# @CODE
# The above example will do:
# export GASH_CFLAGS+= -jule
# export GASH_LIBS+=
# export GASH_CFLAGS+= $(pkg-config --cflags gobject-2.0)
# export GASH_LIBS+= $(pkg-config --libs gobject-2.0)
#
# NOTE: If a package is not found, the string will be inserted in place of
# GROUP_CFLAGS and GROUP_LIBS
pkg_check_modules_override() {
local package
local group=${1}
local packages=${*:2}
export ${group}_CFLAGS=
export ${group}_LIBS=
if [[ $...@} -lt 1 ]]
then
eerror ${FUNCNAME[0]} requires at least one parameter: GROUP
eerror PKG_CHECK_MODULES(GROUP, package1 package2 etc)
die ${FUNCNAME[0]} requires at least one parameter: GROUP
fi
for package in $packages
do
if [[ ${package/=} != ${package} ${package/\%} != ${package}
]]
then
package_cflag_libs=${package##*=}
export ${group}_CFLAGS+= ${package_cflag_libs%%\%*}
export ${group}_LIBS+= ${package_cflag_libs##*\%}
else
if pkg-config --exists $package
then
export ${group}_CFLAGS+= $(pkg-config --cflags
$package)
export ${group}_LIBS+= $(pkg-config --libs
$package)
else
export ${group}_CFLAGS+=
export ${group}_LIBS+=
fi
fi
done
}
# @FUNCTION: poppler_src_unpack
# @DESCRIPTION:
# Runs unpack ${A}
poppler_src_unpack() {
unpack ${A}
}
# @FUNCTION: poppler_src_prepare
# @DESCRIPTION:
# Runs autopatch from base.eclass.
# Uses sed to replace libpoppler.la references with -lpoppler
poppler_src_prepare() {
base_src_util autopatch
sed -i \
-e 's#$(top_builddir)/poppler/libpoppler.la#-lpoppler#' \
$(find . -type f -name 'Makefile.in') || die Failed to sed
proper lib into Makefile.am
}
# @FUNCTION: poppler_src_configure
# @DESCRIPTION:
# Makes sure we get a uniform Makefile environment by using
pkg_check_modules_override to
# fill out some blanks that configure wants filled. Probably not really needed,
but
# insures against future breakage.
# Calls econf with some defaults.
poppler_src_configure() {
pkg_check_modules_override CAIRO cairo
pkg_check_modules_override POPPLER_GLIB glib-2.0
pkg_check_modules_override POPPLER_QT4 QtCore QtGui QtXml
pkg_check_modules_override