9ccdbdf98d3258da40d0d3d3fb54d9de83cc64a1
[gentoo.git] / dev-libs / glib / glib-2.56.2.ebuild
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python{2_7,3_5,3_6,3_7} )
6 GNOME2_EAUTORECONF=yes
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
10
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.
14
15 DESCRIPTION="The GLib library of C routines"
16 HOMEPAGE="https://www.gtk.org/"
17 SRC_URI="${SRC_URI}
18         https://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz" # pkg.m4 for eautoreconf
19
20 LICENSE="LGPL-2.1+"
21 SLOT="2"
22 IUSE="dbus debug fam kernel_linux +mime selinux static-libs systemtap test utils xattr"
23
24 KEYWORDS="~alpha amd64 arm arm64 ~hppa ia64 ~m68k ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
25
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)
29
30 RDEPEND="
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}] )
41         utils? (
42                 >=dev-util/gdbus-codegen-${PV}
43                 virtual/libelf:0=
44         )
45 "
46 DEPEND="${RDEPEND}
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 )
52         ${PYTHON_DEPS}
53         test? (
54                 sys-devel/gdb
55                 >=dev-util/gdbus-codegen-${PV}
56                 >=sys-apps/dbus-1.2.14 )
57         !<dev-util/gtk-doc-1.15-r2
58 "
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.
62 RDEPEND="${RDEPEND}
63         >=dev-util/glib-utils-${PV}"
64 PDEPEND="
65         dbus? ( gnome-base/dconf )
66         mime? ( x11-misc/shared-mime-info )
67 "
68 # shared-mime-info needed for gio/xdgmime, bug #409481
69 # dconf is needed to be able to save settings, bug #498436
70
71 MULTILIB_CHOST_TOOLS=(
72         /usr/bin/gio-querymodules$(get_exeext)
73 )
74
75 pkg_setup() {
76         if use kernel_linux ; then
77                 CONFIG_CHECK="~INOTIFY_USER"
78                 if use test ; then
79                         CONFIG_CHECK="~IPV6"
80                         WARNING_IPV6="Your kernel needs IPV6 support for running some tests, skipping them."
81                 fi
82                 linux-info_pkg_setup
83         fi
84         python-any-r1_pkg_setup
85 }
86
87 src_prepare() {
88         # Prevent build failure in stage3 where pkgconfig is not available, bug #481056
89         mv -f "${WORKDIR}"/pkg-config-*/pkg.m4 "${S}"/m4macros/ || die
90
91         if use test; then
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
98                 fi
99
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
105                 fi
106
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
110
111                 ewarn "Tests for search-utils have been skipped"
112                 sed -i -e "/search-utils/d" glib/tests/Makefile.am || die
113         else
114                 # Don't build tests, also prevents extra deps, bug #512022
115                 sed -i -e 's/ tests//' {.,gio,glib}/Makefile.am || die
116         fi
117
118         # Less max runs in network monitor race test to avoid hitting timeout limits
119         eapply "${FILESDIR}"/${PV}-network-monitor-race-test-iterations.patch # included in 2.57.1
120
121         # gdbus-codegen is a separate package
122         eapply "${FILESDIR}"/${PN}-2.54.3-external-gdbus-codegen.patch
123
124         gnome2_src_prepare
125         epunt_cxx
126 }
127
128 multilib_src_configure() {
129         # Avoid circular depend with dev-util/pkgconfig and
130         # native builds (cross-compiles won't need pkg-config
131         # in the target ROOT to work here)
132         if ! tc-is-cross-compiler && ! $(tc-getPKG_CONFIG) --version >& /dev/null; then
133                 if has_version sys-apps/dbus; then
134                         export DBUS1_CFLAGS="-I/usr/include/dbus-1.0 -I/usr/$(get_libdir)/dbus-1.0/include"
135                         export DBUS1_LIBS="-ldbus-1"
136                 fi
137                 export LIBFFI_CFLAGS="-I$(echo /usr/$(get_libdir)/libffi-*/include)"
138                 export LIBFFI_LIBS="-lffi"
139                 export PCRE_CFLAGS=" " # test -n "$PCRE_CFLAGS" needs to pass
140                 export PCRE_LIBS="-lpcre"
141         fi
142
143         # These configure tests don't work when cross-compiling.
144         if tc-is-cross-compiler ; then
145                 # https://bugzilla.gnome.org/show_bug.cgi?id=756473
146                 case ${CHOST} in
147                 hppa*|metag*) export glib_cv_stack_grows=yes ;;
148                 *)            export glib_cv_stack_grows=no ;;
149                 esac
150                 # https://bugzilla.gnome.org/show_bug.cgi?id=756474
151                 export glib_cv_uscore=no
152                 # https://bugzilla.gnome.org/show_bug.cgi?id=756475
153                 export ac_cv_func_posix_get{pwuid,grgid}_r=yes
154         fi
155
156         local myconf
157
158         case "${CHOST}" in
159                 *-mingw*) myconf="${myconf} --with-threads=win32" ;;
160                 *)        myconf="${myconf} --with-threads=posix" ;;
161         esac
162
163         # libelf used only by the gresource bin
164         ECONF_SOURCE="${S}" gnome2_src_configure ${myconf} \
165                 $(usex debug --enable-debug=yes ' ') \
166                 $(use_enable xattr) \
167                 $(use_enable fam) \
168                 $(use_enable kernel_linux libmount) \
169                 $(use_enable selinux) \
170                 $(use_enable static-libs static) \
171                 $(use_enable systemtap dtrace) \
172                 $(use_enable systemtap systemtap) \
173                 $(multilib_native_use_enable utils libelf) \
174                 --with-python=${EPYTHON} \
175                 --disable-compile-warnings \
176                 --enable-man \
177                 --with-pcre=system \
178                 --with-xml-catalog="${EPREFIX}/etc/xml/catalog"
179
180         if multilib_is_native_abi; then
181                 local d
182                 for d in glib gio gobject; do
183                         ln -s "${S}"/docs/reference/${d}/html docs/reference/${d}/html || die
184                 done
185         fi
186 }
187
188 multilib_src_test() {
189         export XDG_CONFIG_DIRS=/etc/xdg
190         export XDG_DATA_DIRS=/usr/local/share:/usr/share
191         export G_DBUS_COOKIE_SHA1_KEYRING_DIR="${T}/temp"
192         export LC_TIME=C # bug #411967
193         unset GSETTINGS_BACKEND # bug #596380
194         python_setup
195
196         # Related test is a bit nitpicking
197         mkdir "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
198         chmod 0700 "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
199
200         # Hardened: gdb needs this, bug #338891
201         if host-is-pax ; then
202                 pax-mark -mr "${BUILD_DIR}"/tests/.libs/assert-msg-test \
203                         || die "Hardened adjustment failed"
204         fi
205
206         # Need X for dbus-launch session X11 initialization
207         virtx emake check
208 }
209
210 multilib_src_install() {
211         emake DESTDIR="${D}" completiondir="$(get_bashcompdir)" install
212         keepdir /usr/$(get_libdir)/gio/modules
213 }
214
215 multilib_src_install_all() {
216         einstalldocs
217
218         # These are installed by dev-util/glib-utils
219         # 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
220         rm "${ED}usr/bin/glib-genmarshal" || die
221         rm "${ED}usr/share/man/man1/glib-genmarshal.1" || die
222         rm "${ED}usr/bin/glib-mkenums" || die
223         rm "${ED}usr/share/man/man1/glib-mkenums.1" || die
224         rm "${ED}usr/bin/gtester-report" || die
225         rm "${ED}usr/share/man/man1/gtester-report.1" || die
226
227         # Do not install charset.alias even if generated, leave it to libiconv
228         rm -f "${ED}/usr/$(get_libdir)/charset.alias"
229
230         # Don't install gdb python macros, bug 291328
231         rm -rf "${ED}/usr/share/gdb/" "${ED}/usr/share/glib-2.0/gdb/"
232
233         # Completely useless with or without USE static-libs, people need to use pkg-config
234         find "${ED}" -name '*.la' -delete || die
235 }
236
237 pkg_preinst() {
238         gnome2_pkg_preinst
239
240         # Make gschemas.compiled belong to glib alone
241         local cache="usr/share/glib-2.0/schemas/gschemas.compiled"
242
243         if [[ -e ${EROOT}${cache} ]]; then
244                 cp "${EROOT}"${cache} "${ED}"/${cache} || die
245         else
246                 touch "${ED}"/${cache} || die
247         fi
248
249         multilib_pkg_preinst() {
250                 # Make giomodule.cache belong to glib alone
251                 local cache="usr/$(get_libdir)/gio/modules/giomodule.cache"
252
253                 if [[ -e ${EROOT}${cache} ]]; then
254                         cp "${EROOT}"${cache} "${ED}"/${cache} || die
255                 else
256                         touch "${ED}"/${cache} || die
257                 fi
258         }
259
260         # Don't run the cache ownership when cross-compiling, as it would end up with an empty cache
261         # file due to inability to create it and GIO might not look at any of the modules there
262         if ! tc-is-cross-compiler ; then
263                 multilib_foreach_abi multilib_pkg_preinst
264         fi
265 }
266
267 pkg_postinst() {
268         # force (re)generation of gschemas.compiled
269         GNOME2_ECLASS_GLIB_SCHEMAS="force"
270
271         gnome2_pkg_postinst
272
273         multilib_pkg_postinst() {
274                 gnome2_giomodule_cache_update \
275                         || die "Update GIO modules cache failed (for ${ABI})"
276         }
277         if ! tc-is-cross-compiler ; then
278                 multilib_foreach_abi multilib_pkg_postinst
279         else
280                 ewarn "Updating of GIO modules cache skipped due to cross-compilation."
281                 ewarn "You might want to run gio-querymodules manually on the target for"
282                 ewarn "your final image for performance reasons and re-run it when packages"
283                 ewarn "installing GIO modules get upgraded or added to the image."
284         fi
285 }
286
287 pkg_postrm() {
288         gnome2_pkg_postrm
289
290         if [[ -z ${REPLACED_BY_VERSION} ]]; then
291                 multilib_pkg_postrm() {
292                         rm -f "${EROOT}"usr/$(get_libdir)/gio/modules/giomodule.cache
293                 }
294                 multilib_foreach_abi multilib_pkg_postrm
295                 rm -f "${EROOT}"usr/share/glib-2.0/schemas/gschemas.compiled
296         fi
297 }