aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-09-26 18:52:58 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2021-10-10 14:30:46 +0300
commitda81586a5b026fcce1b11a3505b380dfd61e6a2c (patch)
tree2fdf1b66df34331053a44e2c4e2a79663e89de7b
parent046d088549c9faa0443e0bdf0d73b38690f40485 (diff)
downloadmeson-da81586a5b026fcce1b11a3505b380dfd61e6a2c.zip
meson-da81586a5b026fcce1b11a3505b380dfd61e6a2c.tar.gz
meson-da81586a5b026fcce1b11a3505b380dfd61e6a2c.tar.bz2
pkgconfig module: correctly generate Libs search path with absolute install_dir
For example the OpenRC build files install libraries to install_dir: '/lib' and this works, but causes the generated pkg-config to say: prefix=/usr Libs: -L${prefix}//lib which is both ugly (double //) and resolves to /usr/lib which is exactly what does not work.
-rw-r--r--mesonbuild/modules/pkgconfig.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index e865110..001d3ca 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -318,9 +318,11 @@ class PkgConfigModule(ExtensionModule):
prefix = PurePath(prefix)
subdir = PurePath(subdir)
try:
- return subdir.relative_to(prefix).as_posix()
+ libdir = subdir.relative_to(prefix)
except ValueError:
- return subdir.as_posix()
+ libdir = subdir
+ # pathlib joining makes sure absolute libdir is not appended to '${prefix}'
+ return ('${prefix}' / libdir).as_posix()
def _generate_pkgconfig_file(self, state, deps, subdirs, name, description,
url, version, pcfile, conflicts, variables,
@@ -387,12 +389,12 @@ class PkgConfigModule(ExtensionModule):
is_custom_target = isinstance(l, (build.CustomTarget, build.CustomTargetIndex))
if not is_custom_target and 'cs' in l.compilers:
if isinstance(install_dir, str):
- Lflag = '-r${{prefix}}/{}/{}'.format(self._escape(self._make_relative(prefix, install_dir)), l.filename)
+ Lflag = '-r{}/{}'.format(self._escape(self._make_relative(prefix, install_dir)), l.filename)
else: # install_dir is True
Lflag = '-r${libdir}/%s' % l.filename
else:
if isinstance(install_dir, str):
- Lflag = '-L${prefix}/%s' % self._escape(self._make_relative(prefix, install_dir))
+ Lflag = '-L{}'.format(self._escape(self._make_relative(prefix, install_dir)))
else: # install_dir is True
Lflag = '-L${libdir}'
if Lflag not in Lflags: