m4: Take prefix the into account for the gir and typelib dirs
When building a Flatpak application, all the modules bundled with the app are built/installed with prefix=/app.
Those modules which use gobject-introspection's introspection.m4 will use pkgconfig to query the installation directory for their own gir and typelib files.
As it is, that will always return something under /usr, which causes build failures in flatpak-builder.
With the original pkg-config implementation, app authors would work around this in their manifests by defining a couple of environment variables:
PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_GIRDIR=/app/share/gir-1.0
PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_TYPELIBDIR=/app/lib/girepository-1.0
With the pkgconf implementation though, as used in the Freedesktop Sdk
18.08 and the GNOME Sdk >= 3.30, this does not work any more. One
workaround is now to pass those directories to make install
explicitly:
make install girdir=/app/share/gir-1.0 typelibdir=/app/lib/girepository-1.0
Both methods are workarounds though, which amount to completely short-circuiting the introspection.m4 code, and require knowing the exact directory to install those files. As such they are fragile, and could break if the install directories ever change.
This commit changes the m4 code, so that it takes the prefix into account, removing the need for those workarounds entirely.
More details:
-
pkgconf doesn't support use env vars like pkg-config does:
-
an example of the old and new workarounds: