pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/41849?usp=email )


Change subject: Add --disable-syslog-logging configure option
......................................................................

Add --disable-syslog-logging configure option

Right now syslog logging support is built in automatically based on
syslog.h being built at compile time. That's not desirable; as with
other dependencies make sure there's an explicit configure option for
it. Leave it enabled by default since most systems come with syslog.h
and it's a feature nice to have by default.

Take the chance to completelly skip compiling the logging_syslog.c file
if support for syslog logging is disabled.

Change-Id: Ifc54d60e24547696b3059b6eb75572f8c84874d0
---
M configure.ac
M src/core/Makefile.am
M src/core/logging.c
M src/core/logging_syslog.c
M src/vty/logging_vty.c
5 files changed, 27 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/49/41849/1

diff --git a/configure.ac b/configure.ac
index 6a5f0c0..625e437 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,7 +74,7 @@

 dnl checks for header files
 AC_HEADER_STDC
-AC_CHECK_HEADERS(execinfo.h poll.h sys/select.h sys/socket.h sys/signalfd.h 
sys/eventfd.h sys/timerfd.h syslog.h ctype.h netinet/tcp.h netinet/in.h)
+AC_CHECK_HEADERS(execinfo.h poll.h sys/select.h sys/socket.h sys/signalfd.h 
sys/eventfd.h sys/timerfd.h ctype.h netinet/tcp.h netinet/in.h)
 AC_CHECK_DECL(HAVE_SYS_SOCKET_H, AC_SUBST(HAVE_SYS_SOCKET_H, 1), 
AC_SUBST(HAVE_SYS_SOCKET_H, 0))
 # for src/conv.c
 AC_FUNC_ALLOCA
@@ -242,6 +242,21 @@
        AC_DEFINE([USE_GNUTLS], [1], [Use GnuTLS as a fallback for missing 
getrandom()])
 fi

+AC_ARG_ENABLE([syslog_logging],
+       [AS_HELP_STRING(
+               [--disable-syslog-logging],
+               [Build without syslog logging support]
+       )],
+       [syslog_logging=$enableval], [syslog_logging="yes"])
+AS_IF([test "x$syslog_logging" = "xyes"], [
+       AC_CHECK_HEADER([syslog.h], [SYSLOG_H_FOUND='yes'],
+                       [SYSLOG_H_FOUND='no';
+                       AC_MSG_ERROR([syslog logging support needs syslog.h 
header])])
+       AC_DEFINE([ENABLE_SYSLOG_LOGGING], [1], [Enable syslog logging target])
+])
+AM_CONDITIONAL(ENABLE_SYSLOG_LOGGING, test "x$syslog_logging" = "xyes")
+AC_SUBST(ENABLE_SYSLOG_LOGGING)
+
 AC_ARG_ENABLE([systemd_logging],
        [AS_HELP_STRING(
                [--enable-systemd-logging],
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 0b756da..f2cf138 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -44,7 +44,6 @@
        isdnhdlc.c \
        it_q.c \
        logging.c \
-       logging_syslog.c \
        logging_gsmtap.c \
        loggingrb.c \
        macaddr.c \
@@ -137,6 +136,10 @@
 libosmocore_la_SOURCES += serial.c
 endif

+if ENABLE_SYSLOG_LOGGING
+libosmocore_la_SOURCES += logging_syslog.c
+endif
+
 if ENABLE_SYSTEMD_LOGGING
 libosmocore_la_SOURCES += logging_systemd.c
 libosmocore_la_LIBADD += $(SYSTEMD_LIBS)
diff --git a/src/core/logging.c b/src/core/logging.c
index cccfd93..9e5ae9f 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -37,7 +37,7 @@
 #include <strings.h>
 #endif

-#ifdef HAVE_SYSLOG_H
+#ifdef ENABLE_SYSLOG_LOGGING
 #include <syslog.h>
 #endif

@@ -1429,11 +1429,11 @@
        case LOG_TGT_TYPE_GSMTAP:
                gsmtap_source_free(target->tgt_gsmtap.gsmtap_inst);
                break;
-#ifdef HAVE_SYSLOG_H
+#ifdef ENABLE_SYSLOG_LOGGING
        case LOG_TGT_TYPE_SYSLOG:
                closelog();
                break;
-#endif /* HAVE_SYSLOG_H */
+#endif /* ENABLE_SYSLOG_LOGGING */
        default:
                /* make GCC happy */
                break;
diff --git a/src/core/logging_syslog.c b/src/core/logging_syslog.c
index 1153bdf..eb84057 100644
--- a/src/core/logging_syslog.c
+++ b/src/core/logging_syslog.c
@@ -24,8 +24,6 @@

 #include "config.h"

-#ifdef HAVE_SYSLOG_H
-
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -84,6 +82,4 @@
        return target;
 }

-#endif /* HAVE_SYSLOG_H */
-
 /* @} */
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 128b23a..6fd7abc 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -644,7 +644,7 @@
        1
 };

-#ifdef HAVE_SYSLOG_H
+#ifdef ENABLE_SYSLOG_LOGGING

 #include <syslog.h>

@@ -751,7 +751,7 @@

        RET_WITH_UNLOCK(CMD_SUCCESS);
 }
-#endif /* HAVE_SYSLOG_H */
+#endif /* ENABLE_SYSLOG_LOGGING */

 DEFUN(cfg_log_systemd_journal, cfg_log_systemd_journal_cmd,
       "log systemd-journal [raw]",
@@ -1049,7 +1049,7 @@
                        vty_out(vty, "log stderr blocking-io%s", VTY_NEWLINE);
                break;
        case LOG_TGT_TYPE_SYSLOG:
-#ifdef HAVE_SYSLOG_H
+#ifdef ENABLE_SYSLOG_LOGGING
                vty_out(vty, "log syslog %s%s",
                        get_value_string(sysl_level_names,
                                         tgt->tgt_syslog.facility),
@@ -1302,7 +1302,7 @@
        install_lib_element(CONFIG_NODE, &cfg_no_log_file_cmd);
        install_lib_element(CONFIG_NODE, &cfg_log_alarms_cmd);
        install_lib_element(CONFIG_NODE, &cfg_no_log_alarms_cmd);
-#ifdef HAVE_SYSLOG_H
+#ifdef ENABLE_SYSLOG_LOGGING
        install_lib_element(CONFIG_NODE, &cfg_log_syslog_cmd);
        install_lib_element(CONFIG_NODE, &cfg_log_syslog_local_cmd);
        install_lib_element(CONFIG_NODE, &cfg_no_log_syslog_cmd);

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41849?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ifc54d60e24547696b3059b6eb75572f8c84874d0
Gerrit-Change-Number: 41849
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to