Control optional build dependencies and installation paths.

Keep Python helpers private, exclude Meson's label build file (also fixed
in Nixpkgs), and allow packagers to select tests, docs and the systemd path.
The API documentation target is not installed by upstream.

Nixpkgs reference for the stray label file:
https://github.com/NixOS/nixpkgs/commit/d0bc1c7aa71db4d7f4c09e533dd82c7da19666a5

--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,6 +4,13 @@
 # Database backend
 
 # Keep options sorted, per group
+
+option('tests', type: 'feature', value: 'auto',
+       description: 'build unit tests with cmocka')
+option('docs', type: 'feature', value: 'auto',
+       description: 'build Sphinx API documentation')
+option('systemd-unit-dir', type: 'string', value: 'lib/systemd/system',
+       description: 'systemd system unit directory')
 
 option('disable-all', type : 'boolean', value: false,
         description: 'disable all features. Useful to check broken deps')
--- a/meson.build
+++ b/meson.build
@@ -29,12 +29,12 @@
 
 have_unittest = false
 cmocka_version_2 = false
-if not get_option('disable-all')
+if not get_option('disable-all') and not get_option('tests').disabled()
     cmocka_dep = dependency('cmocka', version: '>= 2.0', required: false)
     if cmocka_dep.found()
         cmocka_version_2 = true
     else
-        cmocka_dep = dependency('cmocka', required: false)
+        cmocka_dep = dependency('cmocka', required: get_option('tests'))
     endif
     if cmocka_dep.found()
         have_unittest = true
@@ -69,7 +69,7 @@
 arch_arm = arch == 'all' or arch == 'arm'
 arch_riscv = arch == 'all' or arch == 'riscv'
 
-pydir = py.get_install_dir(pure: true)
+pydir = prefix / datadir / 'rasdaemon'
 
 #
 # Global dependencies and install directory paths
@@ -77,23 +77,7 @@
 
 libtraceevent_dep = dependency('libtraceevent', required: true)
 
-systemd_dep = dependency('systemd', required: false)
-if systemd_dep.found()
-  systemd_unitdir = systemd_dep.get_variable(
-    pkgconfig: 'systemdsystemunitdir',
-    default_value: join_paths(libdir, 'systemd', 'system')
-  )
-else
-  systemd_unitdir = join_paths(libdir, 'systemd', 'system')
-endif
-
-if prefix != '/usr'
-  if systemd_unitdir.startswith('/')
-    systemd_unitdir = prefix + systemd_unitdir
-  else
-    systemd_unitdir = join_paths(prefix, systemd_unitdir)
-  endif
-endif
+systemd_unitdir = prefix / get_option('systemd-unit-dir')
 
 bash_compdir = prefix / datadir / 'bash-completion' / 'completions'
 zsh_compdir = prefix / datadir  / 'zsh' / 'site-functions'
--- a/util/meson.build
+++ b/util/meson.build
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 2026 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
 
-py.install_sources([
+install_data([
     '__init__.py',
     'display_table.py',
     'mem_layout.py',
@@ -11,7 +11,7 @@
     'ras_filter.py',
     'ras_dimm.py',
     'ras_env.py',
-])
+], install_dir: pydir)
 
 ras_mc_ctl_conf = configuration_data()
 ras_mc_ctl_conf.set('PYTHON_DIR', pydir)
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 2026 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
 
-sphinx = find_program('sphinx-build', required: false)
+sphinx = find_program('sphinx-build', required: get_option('docs'))
 
 enable_sphinx = sphinx.found()
 if not enable_sphinx
--- a/labels/meson.build
+++ b/labels/meson.build
@@ -6,7 +6,7 @@
 labels_list = []
 
 foreach f : labels_files
-    if f != '' and f != 'meson.build'
+    if f != '' and fs.name(f) != 'meson.build'
         labels_list += f
     endif
 endforeach
