build/meson: honor prefix for udev_dir and don't use pkg-config

When building with `mesond -Dprefix=/tmp/nm`, then we would expect
that udev files are installed there (wouldn't we?).

The user can already explicitly set "-Dudev_dir=", or even disable
installing the files with "-Dudev_dir=no".

Note that meson be default pre-populates `get_option("prefix")`, so there
is always something set. So we cannot just act on whether the user set a
prefix. It seems to default to /usr/local.

Note that package builds from Fedora spec file pass "-Dprefix=/usr".

I think we should honor the prefix. However, then it seems wrong to also
honor pkg-config at the same time.
In particular, because `pkg-config --variable=udevdir udev` gives /usr/lib/udev.
That means, if we would just prepend the default prefix "/usr" or "/usr/local"
to "/usr/lib/udev" we get the wrong result.

Note that we already to the same for autotools.
This commit is contained in:
Thomas Haller 2022-05-11 10:27:35 +02:00
parent b0240418b3
commit bddffb1731
No known key found for this signature in database
GPG Key ID: 29C2366E4DFC5728

View File

@ -353,10 +353,15 @@ if enable_introspection
endif
udev_udevdir = get_option('udev_dir')
install_udevdir = (udev_udevdir != 'no')
if install_udevdir and udev_udevdir == ''
udev_udevdir = dependency('udev').get_pkgconfig_variable('udevdir')
if udev_udevdir == 'no'
install_udevdir = false
udev_udevdir = ''
else
install_udevdir = true
if (udev_udevdir == '' or udev_udevdir == 'yes')
udev_udevdir = join_paths(nm_prefix, 'lib/udev')
endif
assert(udev_udevdir.startswith('/'), 'udev_dir must be an absolute path, but is ' + udev_udevdir)
endif
systemd_systemdsystemunitdir = get_option('systemdsystemunitdir')
@ -1013,6 +1018,7 @@ output = '\nSystem paths:\n'
output += ' prefix: ' + nm_prefix + '\n'
output += ' exec_prefix: ' + nm_prefix + '\n'
output += ' systemdunitdir: ' + systemd_systemdsystemunitdir + '\n'
output += ' udev_dir: ' + (install_udevdir ? udev_udevdir : '(none)') + '\n'
output += ' nmbinary: ' + nm_pkgsbindir + '\n'
output += ' nmconfdir: ' + nm_pkgconfdir + '\n'
output += ' nmlibdir: ' + nm_pkglibdir + '\n'