1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python{2_7,3_5,3_6,3_7} )
8 inherit autotools bash-completion-r1 epunt-cxx flag-o-matic gnome2 libtool linux-info \
9 multilib multilib-minimal pax-utils python-any-r1 toolchain-funcs virtualx
11 # Until bug #537330 glib is a reverse dependency of pkgconfig and, then
12 # adding new dependencies end up making stage3 to grow. Every addition needs
13 # then to be think very closely.
15 DESCRIPTION="The GLib library of C routines"
16 HOMEPAGE="https://www.gtk.org/"
18 https://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz" # pkg.m4 for eautoreconf
22 IUSE="dbus debug fam kernel_linux +mime selinux static-libs systemtap test utils xattr"
24 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux"
26 # Added util-linux multilib dependency to have libmount support (which
27 # is always turned on on linux systems, unless explicitly disabled, but
28 # this ebuild does not do that anyway) (bug #599586)
31 !<dev-util/gdbus-codegen-${PV}
32 >=dev-libs/libpcre-8.13:3[${MULTILIB_USEDEP},static-libs?]
33 >=virtual/libiconv-0-r1[${MULTILIB_USEDEP}]
34 >=virtual/libffi-3.0.13-r1[${MULTILIB_USEDEP}]
35 >=virtual/libintl-0-r2[${MULTILIB_USEDEP}]
36 >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
37 kernel_linux? ( sys-apps/util-linux[${MULTILIB_USEDEP}] )
38 selinux? ( >=sys-libs/libselinux-2.2.2-r5[${MULTILIB_USEDEP}] )
39 xattr? ( >=sys-apps/attr-2.4.47-r1[${MULTILIB_USEDEP}] )
40 fam? ( >=virtual/fam-0-r1[${MULTILIB_USEDEP}] )
42 >=dev-util/gdbus-codegen-${PV}
47 app-text/docbook-xml-dtd:4.1.2
48 >=dev-libs/libxslt-1.0
49 >=sys-devel/gettext-0.11
50 >=dev-util/gtk-doc-am-1.20
51 systemtap? ( >=dev-util/systemtap-1.3 )
55 >=dev-util/gdbus-codegen-${PV}
56 >=sys-apps/dbus-1.2.14 )
57 !<dev-util/gtk-doc-1.15-r2
59 # Migration of glib-genmarshal, glib-mkenums and gtester-report to a separate
60 # python depending package, which can be buildtime depended in packages that
61 # need these tools, without pulling in python at runtime.
63 >=dev-util/glib-utils-${PV}"
65 dbus? ( gnome-base/dconf )
66 mime? ( x11-misc/shared-mime-info )
68 # shared-mime-info needed for gio/xdgmime, bug #409481
69 # dconf is needed to be able to save settings, bug #498436
71 MULTILIB_CHOST_TOOLS=(
72 /usr/bin/gio-querymodules$(get_exeext)
76 if use kernel_linux ; then
77 CONFIG_CHECK="~INOTIFY_USER"
80 WARNING_IPV6="Your kernel needs IPV6 support for running some tests, skipping them."
84 python-any-r1_pkg_setup
88 # Prevent build failure in stage3 where pkgconfig is not available, bug #481056
89 mv -f "${WORKDIR}"/pkg-config-*/pkg.m4 "${S}"/m4macros/ || die
92 # Disable tests requiring dev-util/desktop-file-utils when not installed, bug #286629, upstream bug #629163
93 if ! has_version dev-util/desktop-file-utils ; then
94 ewarn "Some tests will be skipped due dev-util/desktop-file-utils not being present on your system,"
95 ewarn "think on installing it to get these tests run."
96 sed -i -e "/appinfo\/associations/d" gio/tests/appinfo.c || die
97 sed -i -e "/g_test_add_func/d" gio/tests/desktop-app-info.c || die
100 # gdesktopappinfo requires existing terminal (gnome-terminal or any
101 # other), falling back to xterm if one doesn't exist
102 if ! has_version x11-terms/xterm && ! has_version x11-terms/gnome-terminal ; then
103 ewarn "Some tests will be skipped due to missing terminal program"
104 sed -i -e "/appinfo\/launch/d" gio/tests/appinfo.c || die
107 # https://bugzilla.gnome.org/show_bug.cgi?id=722604
108 sed -i -e "/timer\/stop/d" glib/tests/timer.c || die
109 sed -i -e "/timer\/basic/d" glib/tests/timer.c || die
111 ewarn "Tests for search-utils have been skipped"
112 sed -i -e "/search-utils/d" glib/tests/Makefile.am || die
114 # Don't build tests, also prevents extra deps, bug #512022
115 sed -i -e 's/ tests//' {.,gio,glib}/Makefile.am || die
118 # gdbus-codegen is a separate package
119 eapply "${FILESDIR}"/${PN}-2.54.3-external-gdbus-codegen.patch
125 multilib_src_configure() {
126 # Avoid circular depend with dev-util/pkgconfig and
127 # native builds (cross-compiles won't need pkg-config
128 # in the target ROOT to work here)
129 if ! tc-is-cross-compiler && ! $(tc-getPKG_CONFIG) --version >& /dev/null; then
130 if has_version sys-apps/dbus; then
131 export DBUS1_CFLAGS="-I/usr/include/dbus-1.0 -I/usr/$(get_libdir)/dbus-1.0/include"
132 export DBUS1_LIBS="-ldbus-1"
134 export LIBFFI_CFLAGS="-I$(echo /usr/$(get_libdir)/libffi-*/include)"
135 export LIBFFI_LIBS="-lffi"
136 export PCRE_CFLAGS=" " # test -n "$PCRE_CFLAGS" needs to pass
137 export PCRE_LIBS="-lpcre"
140 # These configure tests don't work when cross-compiling.
141 if tc-is-cross-compiler ; then
142 # https://bugzilla.gnome.org/show_bug.cgi?id=756473
144 hppa*|metag*) export glib_cv_stack_grows=yes ;;
145 *) export glib_cv_stack_grows=no ;;
147 # https://bugzilla.gnome.org/show_bug.cgi?id=756474
148 export glib_cv_uscore=no
149 # https://bugzilla.gnome.org/show_bug.cgi?id=756475
150 export ac_cv_func_posix_get{pwuid,grgid}_r=yes
156 *-mingw*) myconf="${myconf} --with-threads=win32" ;;
157 *) myconf="${myconf} --with-threads=posix" ;;
160 # libelf used only by the gresource bin
161 ECONF_SOURCE="${S}" gnome2_src_configure ${myconf} \
162 $(usex debug --enable-debug=yes ' ') \
163 $(use_enable xattr) \
165 $(use_enable kernel_linux libmount) \
166 $(use_enable selinux) \
167 $(use_enable static-libs static) \
168 $(use_enable systemtap dtrace) \
169 $(use_enable systemtap systemtap) \
170 $(multilib_native_use_enable utils libelf) \
171 --with-python=${EPYTHON} \
172 --disable-compile-warnings \
175 --with-xml-catalog="${EPREFIX}/etc/xml/catalog"
177 if multilib_is_native_abi; then
179 for d in glib gio gobject; do
180 ln -s "${S}"/docs/reference/${d}/html docs/reference/${d}/html || die
185 multilib_src_test() {
186 export XDG_CONFIG_DIRS=/etc/xdg
187 export XDG_DATA_DIRS=/usr/local/share:/usr/share
188 export G_DBUS_COOKIE_SHA1_KEYRING_DIR="${T}/temp"
189 export LC_TIME=C # bug #411967
190 unset GSETTINGS_BACKEND # bug #596380
193 # Related test is a bit nitpicking
194 mkdir "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
195 chmod 0700 "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
197 # Hardened: gdb needs this, bug #338891
198 if host-is-pax ; then
199 pax-mark -mr "${BUILD_DIR}"/tests/.libs/assert-msg-test \
200 || die "Hardened adjustment failed"
203 # Need X for dbus-launch session X11 initialization
207 multilib_src_install() {
208 emake DESTDIR="${D}" completiondir="$(get_bashcompdir)" install
209 keepdir /usr/$(get_libdir)/gio/modules
212 multilib_src_install_all() {
215 # These are installed by dev-util/glib-utils
216 # TODO: With patching we might be able to get rid of the python-any deps and removals, and test depend on glib-utils instead; revisit with meson
217 rm "${ED}usr/bin/glib-genmarshal" || die
218 rm "${ED}usr/share/man/man1/glib-genmarshal.1" || die
219 rm "${ED}usr/bin/glib-mkenums" || die
220 rm "${ED}usr/share/man/man1/glib-mkenums.1" || die
221 rm "${ED}usr/bin/gtester-report" || die
222 rm "${ED}usr/share/man/man1/gtester-report.1" || die
224 # Do not install charset.alias even if generated, leave it to libiconv
225 rm -f "${ED}/usr/$(get_libdir)/charset.alias"
227 # Don't install gdb python macros, bug 291328
228 rm -rf "${ED}/usr/share/gdb/" "${ED}/usr/share/glib-2.0/gdb/"
230 # Completely useless with or without USE static-libs, people need to use pkg-config
231 find "${ED}" -name '*.la' -delete || die
237 # Make gschemas.compiled belong to glib alone
238 local cache="usr/share/glib-2.0/schemas/gschemas.compiled"
240 if [[ -e ${EROOT}${cache} ]]; then
241 cp "${EROOT}"${cache} "${ED}"/${cache} || die
243 touch "${ED}"/${cache} || die
246 multilib_pkg_preinst() {
247 # Make giomodule.cache belong to glib alone
248 local cache="usr/$(get_libdir)/gio/modules/giomodule.cache"
250 if [[ -e ${EROOT}${cache} ]]; then
251 cp "${EROOT}"${cache} "${ED}"/${cache} || die
253 touch "${ED}"/${cache} || die
257 # Don't run the cache ownership when cross-compiling, as it would end up with an empty cache
258 # file due to inability to create it and GIO might not look at any of the modules there
259 if ! tc-is-cross-compiler ; then
260 multilib_foreach_abi multilib_pkg_preinst
265 # force (re)generation of gschemas.compiled
266 GNOME2_ECLASS_GLIB_SCHEMAS="force"
270 multilib_pkg_postinst() {
271 gnome2_giomodule_cache_update \
272 || die "Update GIO modules cache failed (for ${ABI})"
274 if ! tc-is-cross-compiler ; then
275 multilib_foreach_abi multilib_pkg_postinst
277 ewarn "Updating of GIO modules cache skipped due to cross-compilation."
278 ewarn "You might want to run gio-querymodules manually on the target for"
279 ewarn "your final image for performance reasons and re-run it when packages"
280 ewarn "installing GIO modules get upgraded or added to the image."
287 if [[ -z ${REPLACED_BY_VERSION} ]]; then
288 multilib_pkg_postrm() {
289 rm -f "${EROOT}"usr/$(get_libdir)/gio/modules/giomodule.cache
291 multilib_foreach_abi multilib_pkg_postrm
292 rm -f "${EROOT}"usr/share/glib-2.0/schemas/gschemas.compiled