Install udev rules

Change-Id: Id8bb6b0fa005e1e9ba09411f59aa1ac8b2f6f1c6
Signed-off-by: Jakob Haufe <sur5r@sur5r.net>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/264
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: Nico Huber <nico.h@gmx.de>
diff --git a/meson.build b/meson.build
index 171cd0c..50bf73d 100644
--- a/meson.build
+++ b/meson.build
@@ -636,6 +636,8 @@
   endif
 endforeach
 
+subdir('util')
+
 summary({
   'active' : [programmer_names_active],
   'non active' : [programmer_names_not_active],
diff --git a/meson_options.txt b/meson_options.txt
index 53dd9b5..cd0dde0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,6 +4,7 @@
 option('default_programmer_args', type : 'string', description : 'default programmer arguments')
 option('ich_descriptors_tool', type : 'feature', value : 'auto', description : 'Build ich_descriptors_tool')
 option('use_internal_dmi', type : 'boolean', value : 'true')
+option('install_udev_rules', type : 'boolean', value : 'false', description : 'Install udev rules')
 option('programmer', type : 'array', value : ['auto'], choices : [
         'auto', 'all',
         'group_internal', 'group_external',
diff --git a/util/meson.build b/util/meson.build
new file mode 100644
index 0000000..bc89973
--- /dev/null
+++ b/util/meson.build
@@ -0,0 +1,9 @@
+if get_option('install_udev_rules')
+  udev = dependency('udev')
+
+  install_data([
+      'z60_flashprog.rules'
+    ],
+    install_dir : join_paths(udev.get_variable(pkgconfig : 'udevdir'), 'rules.d')
+  )
+endif