Integrate systemd unit files with paths from configure

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2018-08-05 19:15:44 +02:00
parent 9829309bc4
commit cda4c6a037
4 changed files with 33 additions and 3 deletions

2
.gitignore vendored
View File

@ -13,6 +13,8 @@ configure
depcomp
install-sh
klogd
klogd.service
missing
stamp-h1
syslogd
syslogd.service

View File

@ -22,12 +22,15 @@ AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([src/syslogd.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile klogd.service syslogd.service])
AC_PROG_CC
AC_PROG_INSTALL
AC_HEADER_STDC
# Check for required packages
PKG_PROG_PKG_CONFIG
AC_ARG_WITH(klogd-delay,
AS_HELP_STRING([--with-klogd-delay=SEC], [when started at the same time as syslogd, default: 0]),
[klogd_delay=$withval], [klogd_delay='no'])
@ -36,6 +39,10 @@ AC_ARG_WITH(syslogd-pidfile,
AS_HELP_STRING([--with-syslogd-pidfile=FILE], [custom PID file, default: syslogd.pid]),
[syslogd_pidfile=$withval], [syslogd_pidfile='no'])
AC_ARG_WITH(systemd,
[AS_HELP_STRING([--with-systemd=DIR], [Directory for systemd service files])],,
[with_systemd=auto])
AS_IF([test "x$klogd_delay" != "xno"],[
AS_IF([test "x$klogd_delay" = "xyes"],[
AC_MSG_ERROR([Must supply argument])])
@ -48,4 +55,25 @@ AS_IF([test "x$syslogd_pidfile" != "xno"],[
]
AC_DEFINE_UNQUOTED(SYSLOGD_PIDNAME, "$syslogd_pidfile", [Custom syslogd PID file]))
# Check where to install the systemd .service file
AS_IF([test "x$with_systemd" = "xyes" -o "x$with_systemd" = "xauto"], [
def_systemd=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
AS_IF([test "x$def_systemd" = "x"],
[AS_IF([test "x$with_systemd" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemd=no], [with_systemd="$def_systemd"])]
)
AS_IF([test "x$with_systemd" != "xno"],
[AC_SUBST([systemddir], [$with_systemd])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemd" != "xno"])
# Expand $sbindir early, into $SBINDIR, for systemd unit file
# NOTE: This does *not* take prefix/exec_prefix override at "make
# install" into account, unfortunately.
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
SBINDIR=`eval echo $sbindir`
SBINDIR=`eval echo $SBINDIR`
AC_SUBST(SBINDIR)
AC_OUTPUT

View File

@ -4,7 +4,7 @@ After=syslogd.service
[Service]
Type=forking
ExecStart=/sbin/klogd
ExecStart=@SBINDIR@/klogd
PIDFile=/var/run/klogd.pid
StandardOutput=null
Restart=on-failure

View File

@ -4,7 +4,7 @@ Requires=syslog.socket
[Service]
Type=forking
ExecStart=/sbin/syslogd
ExecStart=@SBINDIR@/syslogd
PIDFile=/var/run/syslogd.pid
StandardOutput=null
Restart=on-failure