pkg-config directory variables are not usable
Yesterday I noticed a libhandy build failure when trying to build libhandy with --prefix=/app for a flatpak build. Problem was it's glade module and glade catalog were being installed under /usr instead of /app, which is illegal. I noticed libhandy was using pkg-config to get these installation paths:
module_dir = gladeui_dep.get_pkgconfig_variable('moduledir')
which is insufficient to guarantee the installation location is under the correct prefix. I assumed this was a libhandy bug, and tried to fix it as such:
module_dir = gladeui_dep.get_pkgconfig_variable('moduledir', define_variable: ['libdir', libdir)])
However, it turns out that glade's pkg-config file specifies moduledir as an absolute path not relative to any other pkg-config variable. It is not relative to libdir and it is also not relative to prefix. This makes it impossible to use correctly, so I submitted this libhandy merge request to stop using these variables in favor of hardcoded locations.
Actual gladeui-2.0.pc looks like this:
prefix=/usr
exec_prefix=/usr
libdir=/usr/lib64
datarootdir=${prefix}/share
datadir=/usr/share
includedir=/usr/include/libgladeui-2.0
catalogdir=/usr/share/glade/catalogs
pixmapdir=/usr/share/glade/pixmaps
moduledir=/usr/lib64/glade/modules
including strange useless variables exec_prefix and datarootdir. Desired behavior is for it to look something like this:
prefix=/usr
libdir=${prefix}/lib64
datadir=${prefix}/share
includir=${prefix}/include/libgladeui-2.0
catalogdir=${datadir}/glade/catalogs
pixmapdir=${datadir}/glade/pixmaps
moduledir=${libdir}/glade/modules
Look at glib-2.0.pc for example.