From 632127500dabbfb42156e312d628d0467b31e213 Mon Sep 17 00:00:00 2001
From: Alexander Fasching <fasching.a91@gmail.com>
Date: Mon, 25 Nov 2019 16:27:16 +0100
Subject: [PATCH] Add build option for udev path

---
 CMakeLists.txt      | 3 +++
 conf/CMakeLists.txt | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a55c3514..5133e632 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -187,6 +187,9 @@ else()
   set(INSTALL_SCRIPTS_DIR "${INSTALL_DOC_DIR}/scripts")
   set(INSTALL_MAN_DIR "share/man/man1")
   set(INSTALL_DATA_DIR "share/${PROJECT_NAME}")
+  if (NOT DEFINED UDEV_RULES_DIR OR "${UDEV_RULES_DIR}" STREQUAL "")
+    set(UDEV_RULES_DIR "/etc/udev/rules.d")
+  endif()
 endif(WIN32 OR CYGWIN)
 
 # requirements
diff --git a/conf/CMakeLists.txt b/conf/CMakeLists.txt
index d4a229d7..a84497f8 100644
--- a/conf/CMakeLists.txt
+++ b/conf/CMakeLists.txt
@@ -26,7 +26,7 @@ file(WRITE "${CMAKE_BINARY_DIR}/direwolf.conf" "${file_content}")
 
 # install udev rules for CM108
 if(LINUX)
-  install(FILES "${CUSTOM_CONF_DIR}/99-direwolf-cmedia.rules" DESTINATION /etc/udev/rules.d/)
+  install(FILES "${CUSTOM_CONF_DIR}/99-direwolf-cmedia.rules" DESTINATION ${UDEV_RULES_DIR})
 endif()
 
 install(FILES "${CMAKE_BINARY_DIR}/direwolf.conf" DESTINATION ${INSTALL_CONF_DIR})