]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
meson: fold distconfdir/moduledir handling
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 24 Oct 2024 13:07:52 +0000 (14:07 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 24 Oct 2024 22:46:26 +0000 (17:46 -0500)
We're about to add a few more checks, so instead of duplicating them
fold the handling of custom variables in single place.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
meson.build

index e58af869367305d18138b3eb1758cd16ff75cf68..3937901f404e4237d7df6665ebfd0303bc14f6e2 100644 (file)
@@ -199,16 +199,24 @@ zshcompletiondir = get_option('zshcompletiondir')
 
 cdata.set_quoted('SYSCONFDIR', sysconfdir)
 
-if distconfdir == ''
-  distconfdir = libdir
-endif
-cdata.set_quoted('DISTCONFDIR', distconfdir)
+_customdirs = [
+  ['distconfdir', libdir,         'DISTCONFDIR'],
+  # The default moduledir is hard-coded due to historical reasons
+  ['moduledir',   '/lib/modules', 'MODULE_DIRECTORY'],
+]
 
-# The default moduledir is hard-coded due to historical reasons
-if moduledir == ''
-  moduledir = '/lib/modules'
-endif
-cdata.set_quoted('MODULE_DIRECTORY', moduledir)
+foreach tuple : _customdirs
+  dir_option = tuple[0]
+  def_path = tuple[1]
+  quoted = tuple[2]
+
+  customdir = get_variable(dir_option)
+  if customdir == ''
+    customdir = def_path
+  endif
+  cdata.set_quoted(quoted, customdir)
+  set_variable(dir_option, customdir)
+endforeach
 
 _completiondirs = [
   ['bashcompletiondir', 'bash-completion', 'bash-completion/completions', 'shell-completion/bash/@0@'],