build: make 'udevrulesdir' and 'udevhwdbdir' as Linux-only

udev is available only on Linux, so limit their usage when the backend
is 'linux'.

This fixes the build when the backend is different than 'linux', i.e.
typically on non-Linux OSes.
This commit is contained in:
Pino Toscano 2023-07-06 07:17:01 +02:00 committed by Bastien Nocera
parent aee533e517
commit 029651a96d
2 changed files with 22 additions and 20 deletions

View file

@ -81,6 +81,18 @@ if os_backend == 'linux'
endif
cdata.set10('HAVE_IDEVICE', true)
endif
udevrulesdir = get_option('udevrulesdir')
if udevrulesdir == 'auto'
udev_dep = dependency('udev', required: true)
udevrulesdir = udev_dep.get_variable(pkgconfig: 'udev_dir') / 'rules.d'
endif
udevhwdbdir = get_option('udevhwdbdir')
if udevhwdbdir == 'auto'
udev_dep = dependency('udev', required: true)
udevhwdbdir = udev_dep.get_variable(pkgconfig: 'udev_dir') / 'hwdb.d'
endif
endif
historydir = get_option('historydir')
@ -88,18 +100,6 @@ if historydir == ''
historydir = get_option('prefix') / get_option('localstatedir') / 'lib' / 'upower'
endif
udevrulesdir = get_option('udevrulesdir')
if udevrulesdir == 'auto'
udev_dep = dependency('udev', required: true)
udevrulesdir = udev_dep.get_variable(pkgconfig: 'udev_dir') / 'rules.d'
endif
udevhwdbdir = get_option('udevhwdbdir')
if udevhwdbdir == 'auto'
udev_dep = dependency('udev', required: true)
udevhwdbdir = udev_dep.get_variable(pkgconfig: 'udev_dir') / 'hwdb.d'
endif
dbusdir = get_option('datadir') / 'dbus-1'
systemdsystemunitdir = get_option('systemdsystemunitdir')
if systemdsystemunitdir == ''

View file

@ -7,12 +7,14 @@ hwdb = [
'95-upower-hid.hwdb',
]
install_data(
rules,
install_dir: udevrulesdir,
)
if os_backend == 'linux'
install_data(
rules,
install_dir: udevrulesdir,
)
install_data(
hwdb,
install_dir: udevhwdbdir,
)
install_data(
hwdb,
install_dir: udevhwdbdir,
)
endif