1 |
Hi, |
2 |
This is an eclass that provides functionality needed to further split |
3 |
poppler into its constituent libraries and utilities. The current way |
4 |
of doing this, where we have poppler with utils in app-text/poppler and |
5 |
the bindings for qt3, qt4 and glib in app-text/poppler-bindings is |
6 |
suboptimal. |
7 |
|
8 |
1) it requires us to either enable by default a useflag that will pull |
9 |
in a major toolkit or die when all use-flags are unset. |
10 |
2) The cairo use-flag is a subset of the gtk use-flag (which is in |
11 |
itself misnamed) and thus enabling [cairo] will enable [gtk] but |
12 |
without this being reflected in the metadata. |
13 |
|
14 |
Also, as part of the restructuring, I will be able to move packages |
15 |
around a bit so the libs are put in dev-libs/poppler{,-glib,-qt3,-qt4} |
16 |
and the utils are put in app-text/poppler-utils. |
17 |
|
18 |
Without further ado, the eclass: |
19 |
|
20 |
|
21 |
inherit base multilib |
22 |
|
23 |
has 2 ${EAPI} || DEPEND="EAPI-TOO-OLD" |
24 |
|
25 |
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install |
26 |
|
27 |
# @ECLASS-VARIABLE: HOMEPAGE |
28 |
# @DESCRIPTION: |
29 |
# HOMEPAGE is set to http://poppler.freedesktop.org |
30 |
HOMEPAGE="http://poppler.freedesktop.org/" |
31 |
|
32 |
# @ECLASS-VARIABLE: SRC_URI |
33 |
# @DESCRIPTION: |
34 |
# SRC_URI is set to http://poppler.freedesktop.org/poppler-${PV}.tar.gz |
35 |
SRC_URI="http://poppler.freedesktop.org/poppler-${PV}.tar.gz" |
36 |
|
37 |
# @ECLASS-VARIABLE: S |
38 |
# @DESCRIPTION: |
39 |
# S is set to ${WORKDIR}/poppler-${PV} |
40 |
S=${WORKDIR}/poppler-${PV} |
41 |
|
42 |
# @ECLASS-VARIABLE: POPPLER_MODULE |
43 |
# @DESCRIPTION: |
44 |
# The name of the poppler module. Must be set by the ebuild before inheriting |
45 |
# the poppler eclass. |
46 |
POPPLER_MODULE=${POPPLER_MODULE} |
47 |
|
48 |
# @ECLASS-VARIABLE: POPPLER_MODULE_S |
49 |
# @DESCRIPTION: |
50 |
# The working directory of the poppler module. Set by default to |
51 |
# ${S}/${POPPLER_MODULE} |
52 |
POPPLER_MODULE_S=${S}/${POPPLER_MODULE} |
53 |
|
54 |
# @FUNCTION: pkg_check_modules_override |
55 |
# @USAGE: <GROUP> [package1] [package2] |
56 |
# @DESCRIPTION: |
57 |
# Will export the appropriate variables to override PKG_CHECK_MODULES autoconf |
58 |
# macros, with the string " " by default. If packages are specified, they will |
59 |
# be looked up with pkg-config and the appropriate LIBS and CFLAGS substituted. |
60 |
# LIBS and CFLAGS can also be specified per-package with the following syntax: |
61 |
# @CODE |
62 |
# package=LIBS%CFLAGS |
63 |
# @CODE |
64 |
# = and % have no effect unless both are specified. |
65 |
# Here is an example: |
66 |
# @CODE |
67 |
# pkg_check_modules_override GASH "gtk+-2.0=-jule%" gobject-2.0 |
68 |
# @CODE |
69 |
# The above example will do: |
70 |
# export GASH_CFLAGS+=" -jule" |
71 |
# export GASH_LIBS+=" " |
72 |
# export GASH_CFLAGS+=" $(pkg-config --cflags gobject-2.0)" |
73 |
# export GASH_LIBS+=" $(pkg-config --libs gobject-2.0)" |
74 |
# |
75 |
# NOTE: If a package is not found, the string " " will be inserted in place of |
76 |
# <GROUP>_CFLAGS and <GROUP>_LIBS |
77 |
pkg_check_modules_override() { |
78 |
local package |
79 |
local group="${1}" |
80 |
local packages="${*:2}" |
81 |
export ${group}_CFLAGS=" " |
82 |
export ${group}_LIBS=" " |
83 |
|
84 |
if [[ ${#@} -lt 1 ]] |
85 |
then |
86 |
eerror "${FUNCNAME[0]} requires at least one parameter: GROUP" |
87 |
eerror "PKG_CHECK_MODULES(GROUP, package1 package2 etc)" |
88 |
die "${FUNCNAME[0]} requires at least one parameter: GROUP" |
89 |
fi |
90 |
|
91 |
for package in $packages |
92 |
do |
93 |
if [[ ${package/=} != ${package} && ${package/\%} != ${package} ]] |
94 |
then |
95 |
package_cflag_libs=${package##*=} |
96 |
export ${group}_CFLAGS+=" ${package_cflag_libs%%\%*}" |
97 |
export ${group}_LIBS+=" ${package_cflag_libs##*\%}" |
98 |
else |
99 |
if pkg-config --exists $package |
100 |
then |
101 |
export ${group}_CFLAGS+=" $(pkg-config --cflags $package)" |
102 |
export ${group}_LIBS+=" $(pkg-config --libs $package)" |
103 |
else |
104 |
export ${group}_CFLAGS+=" " |
105 |
export ${group}_LIBS+=" " |
106 |
fi |
107 |
fi |
108 |
done |
109 |
} |
110 |
# @FUNCTION: poppler_src_unpack |
111 |
# @DESCRIPTION: |
112 |
# Runs unpack ${A} |
113 |
poppler_src_unpack() { |
114 |
unpack ${A} |
115 |
} |
116 |
|
117 |
# @FUNCTION: poppler_src_prepare |
118 |
# @DESCRIPTION: |
119 |
# Runs autopatch from base.eclass. |
120 |
# Uses sed to replace libpoppler.la references with -lpoppler |
121 |
poppler_src_prepare() { |
122 |
base_src_util autopatch |
123 |
sed -i \ |
124 |
-e 's#$(top_builddir)/poppler/libpoppler.la#-lpoppler#' \ |
125 |
$(find . -type f -name 'Makefile.in') || die "Failed to sed proper lib into Makefile.am" |
126 |
} |
127 |
|
128 |
# @FUNCTION: poppler_src_configure |
129 |
# @DESCRIPTION: |
130 |
# Makes sure we get a uniform Makefile environment by using pkg_check_modules_override to |
131 |
# fill out some blanks that configure wants filled. Probably not really needed, but |
132 |
# insures against future breakage. |
133 |
# Calls econf with some defaults. |
134 |
poppler_src_configure() { |
135 |
pkg_check_modules_override CAIRO cairo |
136 |
pkg_check_modules_override POPPLER_GLIB glib-2.0 |
137 |
pkg_check_modules_override POPPLER_QT4 QtCore QtGui QtXml |
138 |
pkg_check_modules_override POPPLER_QT4_TEST QtTest |
139 |
pkg_check_modules_override ABIWORD libxml-2.0 |
140 |
pkg_check_modules_override GTK_TEST gtk+-2.0 gdk-pixbuf-2.0 libglade-2.0 gthread-2.0 |
141 |
pkg_check_modules_override GDK gdk-2.0 |
142 |
pkg_check_modules_override POPPLER_GLIB glib-2.0 gobject-2.0 |
143 |
|
144 |
econf --disable-static \ |
145 |
--enable-gdk \ |
146 |
--enable-poppler-qt4 \ |
147 |
--enable-poppler-glib \ |
148 |
--enable-poppler-qt \ |
149 |
--enable-xpdf-headers \ |
150 |
--enable-libjpeg \ |
151 |
--enable-libopenjpeg \ |
152 |
--enable-zlib \ |
153 |
--enable-splash-output \ |
154 |
${POPPLER_CONF} \ |
155 |
|| die "configuration failed" |
156 |
} |
157 |
|
158 |
# @FUNCTION: poppler_src_compile |
159 |
# @DESCRIPTION: |
160 |
# Removes top_srcdir Makefile to ensure that no accidental recursion happens. The build |
161 |
# will just die if it tries to go through top_srcdir. |
162 |
# Runs emake "$@" in POPPLER_MODULE_S |
163 |
poppler_src_compile() { |
164 |
rm -f "${S}"/Makefile* &> /dev/null |
165 |
cd $POPPLER_MODULE_S || die "POPPLER_MODULE_S=${POPPLER_MODULE_S} - cd failed" |
166 |
einfo "Now in $POPPLER_MODULE_S" |
167 |
emake "$@" || die "emake failed" |
168 |
} |
169 |
|
170 |
# @FUNCTION: poppler_src_install |
171 |
# @DESCRIPTION: |
172 |
# Runs emake DESTDIR="${D}" ${@:-install} in POPPLER_MODULE_S |
173 |
# Removes .la files. |
174 |
poppler_src_install() { |
175 |
cd $POPPLER_MODULE_S |
176 |
emake DESTDIR="${D}" ${@:-install} || die "make install failed" |
177 |
for pfile in "${POPPLER_PKGCONFIG[@]}" |
178 |
do |
179 |
insinto /usr/$(get_libdir)/pkgconfig |
180 |
if [[ ${pfile/=} != ${pfile} ]] |
181 |
then |
182 |
if use ${pfile%=*} |
183 |
then |
184 |
pfile=${pfile#*=} |
185 |
else |
186 |
pfile=false |
187 |
fi |
188 |
fi |
189 |
[[ ${pfile} != "false" ]] && doins "${S}/${pfile}" |
190 |
done |
191 |
|
192 |
find "${D}" -type f -name '*.la' -exec rm -rf '{}' '+' || die "la removal failed" |
193 |
} |