summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt81
-rw-r--r--src/utils-systemd.c11
2 files changed, 56 insertions, 36 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b4894b6..903a7de 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,7 +41,7 @@ set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
include(FindPkgConfig)
-pkg_check_modules(EXTRAS REQUIRED libxml-2.0 openssl xmlsec1 xmlsec1-openssl json-c libsystemd>=222)
+pkg_check_modules(EXTRAS REQUIRED libxml-2.0 openssl xmlsec1 xmlsec1-openssl json-c)
add_compile_options(${EXTRAS_CFLAGS})
include_directories(${EXTRAS_INCLUDE_DIRS})
link_libraries(${EXTRAS_LIBRARIES})
@@ -56,6 +56,15 @@ else()
add_definitions(-DUSE_LIBZIP=0)
endif()
+pkg_check_modules(libsystemd libsystemd>=222)
+if(libsystemd_FOUND)
+ add_compile_options(${libsystemd_CFLAGS})
+ include_directories(${libsystemd_INCLUDE_DIRS})
+ link_libraries(${libsystemd_LIBRARIES})
+else()
+ add_definitions(-DNO_LIBSYSTEMD)
+endif()
+
###########################################################################
if(SIMULATE_SECMGR)
@@ -100,7 +109,6 @@ add_library(utils STATIC
utils-dir.c
utils-file.c
utils-json.c
- utils-jbus.c
utils-systemd.c
verbose.c
)
@@ -144,38 +152,43 @@ target_link_libraries(wgtpkg-installer wgtpkg wgt secwrp utils)
install(TARGETS wgtpkg-sign wgtpkg-pack wgtpkg-info wgtpkg-installer DESTINATION ${CMAKE_INSTALL_BINDIR})
-###########################################################################
-# the daemons
-MESSAGE(STATUS "Creating daemons")
-
-add_executable(afm-user-daemon afm-user-daemon.c)
-target_link_libraries(afm-user-daemon afm secwrp wgt utils)
-install(TARGETS afm-user-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-add_executable(afm-system-daemon afm-system-daemon.c)
-target_link_libraries(afm-system-daemon wgtpkg afm secwrp wgt utils)
-install(TARGETS afm-system-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
-
-###########################################################################
-# the binding for afb
-
-pkg_check_modules(AFB afb-daemon)
-if(AFB_FOUND)
- message(STATUS "Creation afm-main-binding for AFB-DAEMON")
- ###############################################################
- pkg_get_variable(afb_binding_install_dir afb-daemon binding_install_dir)
- ###############################################################
- add_library(afm-main-binding MODULE afm-main-binding.c)
- target_compile_options(afm-main-binding PRIVATE ${AFB_CFLAGS})
- target_include_directories(afm-main-binding PRIVATE ${AFB_INCLUDE_DIRS})
- target_link_libraries(afm-main-binding utils ${AFB_LIBRARIES})
- set_target_properties(afm-main-binding PROPERTIES
- PREFIX ""
- LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/afm-main-binding.export-map"
- )
- install(TARGETS afm-main-binding LIBRARY DESTINATION ${afb_binding_install_dir})
-else()
- message(STATUS "Not creating the binding for AFB-DAEMON")
+if(libsystemd_FOUND)
+ ###########################################################################
+ # the daemons
+
+ MESSAGE(STATUS "Creating daemons")
+
+ add_library(jbus STATIC utils-jbus.c)
+
+ add_executable(afm-user-daemon afm-user-daemon.c)
+ target_link_libraries(afm-user-daemon afm secwrp wgt utils jbus)
+ install(TARGETS afm-user-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+ add_executable(afm-system-daemon afm-system-daemon.c)
+ target_link_libraries(afm-system-daemon wgtpkg afm secwrp wgt utils jbus)
+ install(TARGETS afm-system-daemon DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+ ###########################################################################
+ # the binding for afb
+
+ pkg_check_modules(AFB afb-daemon)
+ if(AFB_FOUND)
+ message(STATUS "Creation afm-main-binding for AFB-DAEMON")
+ ###############################################################
+ pkg_get_variable(afb_binding_install_dir afb-daemon binding_install_dir)
+ ###############################################################
+ add_library(afm-main-binding MODULE afm-main-binding.c)
+ target_compile_options(afm-main-binding PRIVATE ${AFB_CFLAGS})
+ target_include_directories(afm-main-binding PRIVATE ${AFB_INCLUDE_DIRS})
+ target_link_libraries(afm-main-binding utils jbus ${AFB_LIBRARIES})
+ set_target_properties(afm-main-binding PROPERTIES
+ PREFIX ""
+ LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/afm-main-binding.export-map"
+ )
+ install(TARGETS afm-main-binding LIBRARY DESTINATION ${afb_binding_install_dir})
+ else()
+ message(STATUS "Not creating the binding for AFB-DAEMON")
+ endif()
endif()
###########################################################################
diff --git a/src/utils-systemd.c b/src/utils-systemd.c
index b8c3c0b..d804144 100644
--- a/src/utils-systemd.c
+++ b/src/utils-systemd.c
@@ -27,8 +27,15 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <systemd/sd-bus.h>
-#include <systemd/sd-bus-protocol.h>
+#ifndef NO_LIBSYSTEMD
+# include <systemd/sd-bus.h>
+# include <systemd/sd-bus-protocol.h>
+#else
+ struct sd_bus;
+# define sd_bus_default_user(p) ((*(p)=NULL),(-ENOTSUP))
+# define sd_bus_default_system(p) ((*(p)=NULL),(-ENOTSUP))
+# define sd_bus_call_method(...) (-ENOTSUP)
+#endif
#include "utils-systemd.h"