diff options
author | Iñigo MartÃnez <inigomartinez@gmail.com> | 2017-11-16 15:14:41 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-11-19 18:20:21 +0200 |
commit | 638077181a79bb974494bce8355e49a11b22d242 (patch) | |
tree | 7ac2ba8f2a5f0eb3da84b426751b6619c5231303 /mesonbuild/modules/pkgconfig.py | |
parent | 34d1d4509426a3a842f00fec92f7695fa202d507 (diff) | |
download | meson-638077181a79bb974494bce8355e49a11b22d242.zip meson-638077181a79bb974494bce8355e49a11b22d242.tar.gz meson-638077181a79bb974494bce8355e49a11b22d242.tar.bz2 |
pkgconfig: Handle prefix in library path
The install_dir parameter of the libraries can also contain the
prefix path, which creates wrong library paths in the .pc file.
This patch detects if prefix is contained in the library path
and creates a relative path.
Fixes #2469
Diffstat (limited to 'mesonbuild/modules/pkgconfig.py')
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 52f3a50..f963323 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -55,6 +55,15 @@ class PkgConfigModule(ExtensionModule): value = value.as_posix() return value.replace(' ', '\ ') + def _make_relative(self, prefix, subdir): + if isinstance(prefix, PurePath): + prefix = prefix.as_posix() + if isinstance(subdir, PurePath): + subdir = subdir.as_posix() + if subdir.startswith(prefix): + subdir = subdir.replace(prefix, '') + return subdir + def generate_pkgconfig_file(self, state, libraries, subdirs, name, description, url, version, pcfile, pub_reqs, priv_reqs, conflicts, priv_libs, extra_cflags, variables): @@ -98,7 +107,7 @@ class PkgConfigModule(ExtensionModule): if install_dir is False: continue if isinstance(install_dir, str): - yield '-L${prefix}/%s ' % self._escape(install_dir) + yield '-L${prefix}/%s ' % self._escape(self._make_relative(prefix, install_dir)) else: # install_dir is True yield '-L${libdir}' lname = self._get_lname(l, msg, pcfile) |