f18c2acdc30b124fbbc57e585cce338c2010e8e5
[gentoo.git] / dev-libs / glib / glib-2.56.2.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
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 ~arm-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         # gdbus-codegen is a separate package
119         eapply "${FILESDIR}"/${PN}-2.54.3-external-gdbus-codegen.patch
120
121         gnome2_src_prepare
122         epunt_cxx
123 }
124
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"
133                 fi
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"
138         fi
139
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
143                 case ${CHOST} in
144                 hppa*|metag*) export glib_cv_stack_grows=yes ;;
145                 *)            export glib_cv_stack_grows=no ;;
146                 esac
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
151         fi
152
153         local myconf
154
155         case "${CHOST}" in
156                 *-mingw*) myconf="${myconf} --with-threads=win32" ;;
157                 *)        myconf="${myconf} --with-threads=posix" ;;
158         esac
159
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) \
164                 $(use_enable fam) \
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 \
173                 --enable-man \
174                 --with-pcre=system \
175                 --with-xml-catalog="${EPREFIX}/etc/xml/catalog"
176
177         if multilib_is_native_abi; then
178                 local d
179                 for d in glib gio gobject; do
180                         ln -s "${S}"/docs/reference/${d}/html docs/reference/${d}/html || die
181                 done
182         fi
183 }
184
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
191         python_setup
192
193         # Related test is a bit nitpicking
194         mkdir "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
195         chmod 0700 "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
196
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"
201         fi
202
203         # Need X for dbus-launch session X11 initialization
204         virtx emake check
205 }
206
207 multilib_src_install() {
208         emake DESTDIR="${D}" completiondir="$(get_bashcompdir)" install
209         keepdir /usr/$(get_libdir)/gio/modules
210 }
211
212 multilib_src_install_all() {
213         einstalldocs
214
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
223
224         # Do not install charset.alias even if generated, leave it to libiconv
225         rm -f "${ED}/usr/$(get_libdir)/charset.alias"
226
227         # Don't install gdb python macros, bug 291328
228         rm -rf "${ED}/usr/share/gdb/" "${ED}/usr/share/glib-2.0/gdb/"
229
230         # Completely useless with or without USE static-libs, people need to use pkg-config
231         find "${ED}" -name '*.la' -delete || die
232 }
233
234 pkg_preinst() {
235         gnome2_pkg_preinst
236
237         # Make gschemas.compiled belong to glib alone
238         local cache="usr/share/glib-2.0/schemas/gschemas.compiled"
239
240         if [[ -e ${EROOT}${cache} ]]; then
241                 cp "${EROOT}"${cache} "${ED}"/${cache} || die
242         else
243                 touch "${ED}"/${cache} || die
244         fi
245
246         multilib_pkg_preinst() {
247                 # Make giomodule.cache belong to glib alone
248                 local cache="usr/$(get_libdir)/gio/modules/giomodule.cache"
249
250                 if [[ -e ${EROOT}${cache} ]]; then
251                         cp "${EROOT}"${cache} "${ED}"/${cache} || die
252                 else
253                         touch "${ED}"/${cache} || die
254                 fi
255         }
256
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
261         fi
262 }
263
264 pkg_postinst() {
265         # force (re)generation of gschemas.compiled
266         GNOME2_ECLASS_GLIB_SCHEMAS="force"
267
268         gnome2_pkg_postinst
269
270         multilib_pkg_postinst() {
271                 gnome2_giomodule_cache_update \
272                         || die "Update GIO modules cache failed (for ${ABI})"
273         }
274         if ! tc-is-cross-compiler ; then
275                 multilib_foreach_abi multilib_pkg_postinst
276         else
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."
281         fi
282 }
283
284 pkg_postrm() {
285         gnome2_pkg_postrm
286
287         if [[ -z ${REPLACED_BY_VERSION} ]]; then
288                 multilib_pkg_postrm() {
289                         rm -f "${EROOT}"usr/$(get_libdir)/gio/modules/giomodule.cache
290                 }
291                 multilib_foreach_abi multilib_pkg_postrm
292                 rm -f "${EROOT}"usr/share/glib-2.0/schemas/gschemas.compiled
293         fi
294 }