build: honour CMake install prefix in hardcoded paths
authorJo-Philipp Wich <jo@mein.io>
Fri, 3 Dec 2021 22:36:35 +0000 (23:36 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 8 Dec 2021 19:09:24 +0000 (20:09 +0100)
Search plugins, ACL ressources and other data files relative to the compile
time CMAKE_INSTALL_PREFIX instead of hardcoding `/usr`.

Also ensure that plugin libraries are installed into the lib/rpcd subdir.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
CMakeLists.txt
include/rpcd/plugin.h
include/rpcd/session.h

index 26e011eff2c701fd97b0aaf840a068dc34cd02ac..7628212fb5217e80431d0a380972dde889b6f277 100644 (file)
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.6)
 INCLUDE(CheckFunctionExists)
 
 PROJECT(rpcd C)
-ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
+ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations -DINSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
 INCLUDE_DIRECTORIES(include)
 
 OPTION(FILE_SUPPORT "File plugin support" ON)
@@ -67,5 +67,5 @@ ENDIF()
 
 INSTALL(TARGETS rpcd ${PLUGINS}
        RUNTIME DESTINATION sbin
-       LIBRARY DESTINATION lib
+       LIBRARY DESTINATION lib/rpcd
 )
index 363c0d7db40b71da4cb09021a2e1c1080812c5fe..b795f0ee355498ebd8f9ca3d0295fc8280ddbf4b 100644 (file)
 #include <rpcd/session.h>
 
 /* location of plugin executables */
-#define RPC_PLUGIN_DIRECTORY   "/usr/libexec/rpcd"
+#define RPC_PLUGIN_DIRECTORY   INSTALL_PREFIX "/libexec/rpcd"
 
 /* location of plugin libraries */
-#define RPC_LIBRARY_DIRECTORY  "/usr/lib/rpcd"
+#define RPC_LIBRARY_DIRECTORY  INSTALL_PREFIX "/lib/rpcd"
 
 struct rpc_daemon_ops {
     bool (*session_access)(const char *sid, const char *scope,
index 3815a434ab70263878f68c402a1c56429c307779..8ff3ed0cd35f2fb13b8a36de0d9f338bf95f7b99 100644 (file)
@@ -34,7 +34,7 @@
 #define RPC_DEFAULT_SESSION_TIMEOUT    300
 #define RPC_DEFAULT_SESSION_ID "00000000000000000000000000000000"
 #define RPC_SESSION_DIRECTORY  "/var/run/rpcd/sessions"
-#define RPC_SESSION_ACL_DIR            "/usr/share/rpcd/acl.d"
+#define RPC_SESSION_ACL_DIR            INSTALL_PREFIX "/share/rpcd/acl.d"
 
 extern char apply_sid[RPC_SID_LEN + 1];