build-sys: consolidate systemd support

* systemd (since v209) uses only one library (when compiled
   without --enable-compat-libs)

 * all systemd build-sys stuff is merged into HAVE_SYSTEMD
  (automake) and HAVE_LIBSYSTEMD (C macro) now

 * all is controlled by --with-systemd, default is to automatically
   check for systemd libs

 * no more --enable-socket-activation and --enable-journald

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-04-09 12:23:30 +02:00
parent 4856a7bc01
commit ebff016a19
5 changed files with 44 additions and 44 deletions

View File

@ -1419,19 +1419,33 @@ UL_BUILD_INIT([write])
AM_CONDITIONAL([BUILD_WRITE], [test "x$build_write" = xyes])
AC_ARG_ENABLE([socket-activation],
AS_HELP_STRING([--enable-socket-activation], [build uuidd with support for systemd socket activation]),
[], [enable_socket_activation=no]
AC_ARG_WITH([systemd],
AS_HELP_STRING([--with-systemd], [build with support for systemd]),
[], [with_systemd=check]
)
have_systemd_daemon=no
AS_IF([test "x$enable_socket_activation" = xyes], [
PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon], [], [
AC_MSG_ERROR([cannot find libsystemd-daemon support])
have_systemd=no
AS_IF([test "x$with_systemd" != xno], [
# new version -- all libsystemd-* libs merged into libsystemd
PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [have_systemd=yes], [have_systemd=no])
# old versions
AS_IF([test "x$have_systemd" != "xyes"], [
PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
[have_systemd_daemon=yes], [have_systemd_daemon=no])
PKG_CHECK_MODULES([SYSTEMD_JOURNAL], [libsystemd-journal],
[have_systemd_journal=yes], [have_systemd_journal=no])
AS_IF([test "x$have_systemd_daemon" = "xyes" -a "x$have_systemd_journal" = "xyes" ],[
have_systemd=yes])
])
have_systemd_daemon=yes
AC_DEFINE([HAVE_LIBSYSTEMD_DAEMON], [1], [Define if libsystemd-daemon is available])
AS_CASE([$with_systemd:$have_systemd],
[yes:no],
[AC_MSG_ERROR([systemd expected but libsystemd not found])],
[*:yes],
AC_DEFINE([HAVE_LIBSYSTEMD], [1], [Define if libsystemd is available])
)
])
AM_CONDITIONAL([HAVE_SYSTEMD_DAEMON], [test "x$have_systemd_daemon" = xyes])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$have_systemd" = xyes])
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [directory for systemd service files]),
@ -1442,21 +1456,6 @@ AS_IF([test "x$with_systemdsystemunitdir" != "xno"], [
])
AC_ARG_ENABLE([journald],
AS_HELP_STRING([--enable-journald], [add journald support to logger]),
[], [enable_journald=no]
)
have_journald=no
AS_IF([test "x$enable_journald" = xyes], [
PKG_CHECK_MODULES([SYSTEMD_JOURNAL], [libsystemd-journal], [], [
AC_MSG_ERROR([cannot find libsystemd-journal support])
])
have_journald=yes
AC_DEFINE([HAVE_JOURNALD], [1], [Define if journald is available])
])
AM_CONDITIONAL([HAVE_JOURNALD], [test "x$have_journald" = xyes])
AC_ARG_WITH([smack],
AS_HELP_STRING([--with-smack], [build with SMACK support]),
[], [with_smack=no]
@ -1653,6 +1652,7 @@ AC_MSG_RESULT([
Python libs: ${pyexecdir}
Bash completions: ${with_bashcompletiondir}
Systemd support: ${have_systemd}
warnings:

View File

@ -20,9 +20,9 @@ endif
usrbin_exec_PROGRAMS += logger
dist_man_MANS += misc-utils/logger.1
logger_SOURCES = misc-utils/logger.c lib/strutils.c
if HAVE_JOURNALD
logger_LDADD = $(SYSTEMD_JOURNAL_LIBS)
logger_CFLAGS = $(SYSTEMD_JOURNAL_CFLAGS)
if HAVE_SYSTEMD
logger_LDADD = $(SYSTEMD_LIBS) $(SYSTEMD_JOURNAL_LIBS)
logger_CFLAGS = $(SYSTEMD_CFLAGS) $(SYSTEMD_JOURNAL_CFLAGS)
endif
usrbin_exec_PROGRAMS += look
@ -77,9 +77,9 @@ uuidd_LDADD = $(LDADD) libuuid.la libcommon.la
uuidd_CFLAGS = $(DAEMON_CFLAGS) $(AM_CFLAGS) -I$(ul_libuuid_incdir)
uuidd_LDFLAGS = $(DAEMON_LDFLAGS) $(AM_LDFLAGS)
uuidd_SOURCES = misc-utils/uuidd.c
if HAVE_SYSTEMD_DAEMON
uuidd_LDADD += $(SYSTEMD_DAEMON_LIBS)
uuidd_CFLAGS += $(SYSTEMD_DAEMON_CFLAGS)
if HAVE_SYSTEMD
uuidd_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS)
uuidd_CFLAGS += $(SYSTEMD_CFLAGS) $(SYSTEMD_DAEMON_CFLAGS)
systemdsystemunit_DATA += \
misc-utils/uuidd.service \
misc-utils/uuidd.socket

View File

@ -59,7 +59,7 @@
#define SYSLOG_NAMES
#include <syslog.h>
#ifdef HAVE_JOURNALD
#ifdef HAVE_LIBSYSTEMD
# include <systemd/sd-journal.h>
#endif
@ -210,7 +210,7 @@ static int inet_socket(const char *servername, const char *port,
return fd;
}
#ifdef HAVE_JOURNALD
#ifdef HAVE_LIBSYSTEMD
static int journald_entry(FILE *fp)
{
struct iovec *iovec;
@ -289,7 +289,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
fputs(_(" -s, --stderr output message to standard error as well\n"), out);
fputs(_(" -t, --tag <tag> mark every line with this tag\n"), out);
fputs(_(" -u, --socket <socket> write to this Unix socket\n"), out);
#ifdef HAVE_JOURNALD
#ifdef HAVE_LIBSYSTEMD
fputs(_(" --journald[=<file>] write journald entry\n"), out);
#endif
@ -315,7 +315,7 @@ int main(int argc, char **argv)
char *server = NULL;
char *port = NULL;
int LogSock = -1, socket_type = ALL_TYPES;
#ifdef HAVE_JOURNALD
#ifdef HAVE_LIBSYSTEMD
FILE *jfd = NULL;
#endif
static const struct option longopts[] = {
@ -332,7 +332,7 @@ int main(int argc, char **argv)
{ "version", no_argument, 0, 'V' },
{ "help", no_argument, 0, 'h' },
{ "prio-prefix", no_argument, 0, OPT_PRIO_PREFIX },
#ifdef HAVE_JOURNALD
#ifdef HAVE_LIBSYSTEMD
{ "journald", optional_argument, 0, OPT_JOURNALD },
#endif
{ NULL, 0, 0, 0 }
@ -390,7 +390,7 @@ int main(int argc, char **argv)
case OPT_PRIO_PREFIX:
prio_prefix = 1;
break;
#ifdef HAVE_JOURNALD
#ifdef HAVE_LIBSYSTEMD
case OPT_JOURNALD:
if (optarg) {
jfd = fopen(optarg, "r");
@ -410,7 +410,7 @@ int main(int argc, char **argv)
argv += optind;
/* setup for logging */
#ifdef HAVE_JOURNALD
#ifdef HAVE_LIBSYSTEMD
if (jfd) {
int ret = journald_entry(jfd);
if (stdin != jfd)

View File

@ -38,8 +38,8 @@ extern int optind;
#include "closestream.h"
#include "strutils.h"
#ifdef HAVE_LIBSYSTEMD_DAEMON
#include <systemd/sd-daemon.h>
#ifdef HAVE_LIBSYSTEMD
# include <systemd/sd-daemon.h>
#endif
#include "nls.h"
@ -304,7 +304,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
int fd_pidfile = -1;
int ret;
#ifdef HAVE_LIBSYSTEMD_DAEMON
#ifdef HAVE_LIBSYSTEMD
if (!uuidd_cxt->no_sock) /* no_sock implies no_fork and no_pid */
#endif
{
@ -352,7 +352,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
signal(SIGALRM, terminate_intr);
signal(SIGPIPE, SIG_IGN);
#ifdef HAVE_LIBSYSTEMD_DAEMON
#ifdef HAVE_LIBSYSTEMD
if (uuidd_cxt->no_sock) {
if (sd_listen_fds(0) != 1)
errx(EXIT_FAILURE, _("no or too many file descriptors received"));
@ -538,7 +538,7 @@ int main(int argc, char **argv)
uuidd_cxt.no_fork = 1;
break;
case 'S':
#ifdef HAVE_LIBSYSTEMD_DAEMON
#ifdef HAVE_LIBSYSTEMD
uuidd_cxt.no_sock = 1;
uuidd_cxt.no_fork = 1;
no_pid = 1;

View File

@ -53,7 +53,7 @@ dist_man_MANS += sys-utils/fstrim.8
fstrim_SOURCES = sys-utils/fstrim.c
fstrim_LDADD = $(LDADD) libcommon.la libmount.la
fstrim_CFLAGS = $(AM_CFLAGS) -I$(ul_libmount_incdir)
if HAVE_SYSTEMD_DAEMON
if HAVE_SYSTEMD
systemdsystemunit_DATA += \
sys-utils/fstrim.service \
sys-utils/fstrim.timer