Blame SOURCES/0006-Make-the-dependency-on-systemd-optional.patch

2aa065
From e078503fcd9f74ccdd7e6c50c45e5e715f2dcda8 Mon Sep 17 00:00:00 2001
2aa065
From: Jakub Filak <jfilak@redhat.com>
2aa065
Date: Wed, 4 Feb 2015 06:30:25 +0100
2aa065
Subject: [PATCH] Make the dependency on systemd optional
2aa065
2aa065
Closes #44
2aa065
2aa065
Signed-off-by: Jakub Filak <jfilak@redhat.com>
2aa065
---
2aa065
 src/CMakeLists.txt | 16 +++++++++++++---
2aa065
 src/abrt-checker.c |  7 ++++++-
2aa065
 2 files changed, 19 insertions(+), 4 deletions(-)
2aa065
2aa065
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
2aa065
index a178dcd..1d31602 100644
2aa065
--- a/src/CMakeLists.txt
2aa065
+++ b/src/CMakeLists.txt
2aa065
@@ -1,10 +1,17 @@
2aa065
 find_package(JNI REQUIRED)
2aa065
 include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
2aa065
 
2aa065
-pkg_check_modules(PC_JOURNALD REQUIRED libsystemd-journal)
2aa065
 include_directories(${PC_LIBREPORT_INCLUDE_DIRS})
2aa065
 include_directories(${PC_ABRT_INCLUDE_DIRS})
2aa065
-include_directories(${PC_JOURNALD_INCLUDE_DIRS})
2aa065
+
2aa065
+pkg_check_modules(PC_JOURNALD libsystemd-journal)
2aa065
+
2aa065
+if (PC_JOURNALD_FOUND)
2aa065
+    include_directories(${PC_JOURNALD_INCLUDE_DIRS})
2aa065
+    add_definitions(-DHAVE_SYSTEMD=1)
2aa065
+else()
2aa065
+    add_definitions(-DHAVE_SYSTEMD=0)
2aa065
+endif (PC_JOURNALD_FOUND)
2aa065
 
2aa065
 set(AbrtChecker_SRCS configuration.c abrt-checker.c
2aa065
         jthrowable_circular_buf.c jthread_map.c)
2aa065
@@ -19,6 +26,9 @@ set_target_properties(
2aa065
 
2aa065
 target_link_libraries(AbrtChecker ${PC_LIBREPORT_LIBRARIES})
2aa065
 target_link_libraries(AbrtChecker ${PC_ABRT_LIBRARIES})
2aa065
-target_link_libraries(AbrtChecker ${PC_JOURNALD_LIBRARIES})
2aa065
+
2aa065
+if (PC_JOURNALD_FOUND)
2aa065
+    target_link_libraries(AbrtChecker ${PC_JOURNALD_LIBRARIES})
2aa065
+endif (PC_JOURNALD_FOUND)
2aa065
 
2aa065
 install(TARGETS AbrtChecker DESTINATION ${JNIAGENTLIB_INSTALL_DIR})
2aa065
diff --git a/src/abrt-checker.c b/src/abrt-checker.c
2aa065
index 930e485..56f2fa4 100644
2aa065
--- a/src/abrt-checker.c
2aa065
+++ b/src/abrt-checker.c
2aa065
@@ -39,9 +39,12 @@
2aa065
 #include <linux/limits.h>
2aa065
 #include <sys/stat.h>
2aa065
 #include <errno.h>
2aa065
-#include <systemd/sd-journal.h>
2aa065
 #include <syslog.h>
2aa065
 
2aa065
+#if HAVE_SYSTEMD_JOURNAL
2aa065
+#include <systemd/sd-journal.h>
2aa065
+#endif
2aa065
+
2aa065
 /* Shared macros and so on */
2aa065
 #include "abrt-checker.h"
2aa065
 
2aa065
@@ -689,6 +692,7 @@ static void report_stacktrace(
2aa065
         syslog(LOG_ERR, "%s\n%s", message, stacktrace);
2aa065
     }
2aa065
 
2aa065
+#if HAVE_SYSTEMD_JOURNAL
2aa065
     if (globalConfig.reportErrosTo & ED_JOURNALD)
2aa065
     {
2aa065
         VERBOSE_PRINT("Reporting stack trace to JournalD\n");
2aa065
@@ -698,6 +702,7 @@ static void report_stacktrace(
2aa065
                         NULL);
2aa065
 
2aa065
     }
2aa065
+#endif
2aa065
 
2aa065
     log_print("%s\n", message);
2aa065
 
2aa065
-- 
2aa065
2.4.6
2aa065