build: meson: Use variables present in pkg-config files

Although some paths related to DBus and PolicyKit are present in
their pkg-config files, those paths might not be writable for the
user. To solve this issue, some build options are present that can
be used to choose a different location.

However, usually these paths are relative to some other variables
such as `prefix`, `datadir`, etc. Using the `define_variable`
option the relative path can be change to point to a directory
under prefix.

These paths are now using relative paths based on the installation
`prefix` and their related options have been removed as they are
unnecessary now. Only `dbus_conf_dir` option has been left because
it must be modified depending on the distribution[0].

[0] contrib/fedora/rpm/NetworkManager.spec
This commit is contained in:
Iñigo Martínez 2018-10-12 09:59:25 +02:00 committed by Thomas Haller
parent 4b32bbc820
commit b00e004890
2 changed files with 6 additions and 20 deletions

View file

@ -464,13 +464,11 @@ config_h.set10('WITH_JSON_VALIDATION', enable_json_validation)
# polkit
enable_polkit = get_option('polkit')
if enable_polkit
polkit_dir = get_option('polkit_dir')
if polkit_dir == ''
polkit_dir = dependency('polkit-gobject-1').get_pkgconfig_variable('policydir')
endif
# FIXME: policydir should be relative to `datadir`, not `prefix`. Fixed in https://gitlab.freedesktop.org/polkit/polkit/merge_requests/2
polkit_dir = dependency('polkit-gobject-1').get_pkgconfig_variable('policydir', define_variable: ['prefix', nm_prefix])
endif
config_default_main_auth_polkit = (polkit == 'yes').to_string()
config_default_main_auth_polkit = enable_polkit.to_string()
config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT', config_default_main_auth_polkit)
enable_modify_system = get_option('modify_system')
@ -499,17 +497,8 @@ if dbus_conf_dir == ''
dbus_conf_dir = join_paths(dbus_dep.get_pkgconfig_variable('sysconfdir'), 'dbus-1', 'system.d')
endif
dbus_ifaces_dir = get_option('dbus_ifaces_dir')
if dbus_ifaces_dir == ''
assert(dbus_dep.found(), 'D-Bus required but not found, please provide a valid interfaces dir')
dbus_ifaces_dir = dbus_dep.get_pkgconfig_variable('interfaces_dir')
endif
dbus_sys_dir = get_option('dbus_sys_dir')
if dbus_sys_dir == ''
assert(dbus_dep.found(), 'D-Bus required but not found, please provide a valid system bus services dir')
dbus_sys_dir = dbus_dep.get_pkgconfig_variable('system_bus_services_dir')
endif
dbus_ifaces_dir = dbus_dep.get_pkgconfig_variable('interfaces_dir', define_variable: ['datadir', nm_datadir])
dbus_sys_dir = dbus_dep.get_pkgconfig_variable('system_bus_services_dir', define_variable: ['datadir', nm_datadir])
# pppd
enable_ppp = get_option('ppp')
@ -950,7 +939,7 @@ output += ' suspend/resume: ' + suspend_resume + '\n'
output += ' policykit: ' + enable_polkit.to_string()
if enable_polkit
modify = (enable_modify_system ? 'permissive' : 'restrictive')
output += ' (' + modify + ' modify.system) (default: main.auth-polkit=' + polkit + ')'
output += ' (' + modify + ' modify.system) (default: main.auth-polkit=true)'
endif
output += '\n'
output += ' polkit agent: ' + enable_polkit_agent.to_string() + '\n'

View file

@ -3,9 +3,6 @@ option('systemdsystemunitdir', type: 'string', value: '', description: 'Director
option('system_ca_path', type: 'string', value: '/etc/ssl/certs', description: 'path to system CA certificates')
option('udev_dir', type: 'string', value: '', description: 'Absolute path of the udev base directory. Set to \'no\' not to install the udev rule')
option('dbus_conf_dir', type: 'string', value: '', description: 'where D-Bus system.d directory is')
option('dbus_ifaces_dir', type: 'string', value: '', description: 'where D-Bus interfaces directory is')
option('dbus_sys_dir', type: 'string', value: '', description: 'where D-Bus system service directory is')
option('polkit_dir', type: 'string', value: '', description: 'where PolicyKit policy directory is')
option('kernel_firmware_dir', type: 'string', value: '/lib/firmware', description: 'where kernel firmware directory is (default is /lib/firmware)')
option('iptables', type: 'string', value: '', description: 'path to iptables')
option('dnsmasq', type: 'string', value: '', description: 'path to dnsmasq')