Skip to content

Commit

Permalink
m4/nut_check_libsystemd.m4: extend to try getting SYSTEMD_VERSION fro…
Browse files Browse the repository at this point in the history
…m systemctl if pkg-config is missing [networkupstools#1070]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Aug 19, 2024
1 parent 96daf92 commit 0cf8e3f
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions m4/nut_check_libsystemd.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,42 @@ if test -z "${nut_have_libsystemd_seen}"; then
CFLAGS_ORIG="${CFLAGS}"
LIBS_ORIG="${LIBS}"
SYSTEMD_VERSION="none"
AC_CHECK_TOOL(SYSTEMCTL, systemctl, none)
AS_IF([test x"$have_PKG_CONFIG" = xyes],
[dnl See which version of the systemd library (if any) is installed
dnl FIXME : Support detection of cflags/ldflags below by legacy
dnl discovery if pkgconfig is not there
AC_MSG_CHECKING(for libsystemd version via pkg-config)
SYSTEMD_VERSION="`$PKG_CONFIG --silence-errors --modversion libsystemd 2>/dev/null`"
if test "$?" != "0" -o -z "${SYSTEMD_VERSION}"; then
SYSTEMD_VERSION="none"
fi
AS_IF([test "$?" != "0" -o -z "${SYSTEMD_VERSION}"], [
SYSTEMD_VERSION="none"
])
AC_MSG_RESULT(${SYSTEMD_VERSION} found)
],
[SYSTEMD_VERSION="none"
AC_MSG_NOTICE([can not check libsystemd settings via pkg-config])
]
)
AS_IF([test x"${SYSTEMD_VERSION}" = xnone], [
AS_IF([test x"${SYSTEMCTL}" != xnone], [
AC_MSG_CHECKING(for libsystemd version via systemctl)
dnl NOTE: Unlike the configure.ac file, in a "pure"
dnl m4 script like this one, we have to escape the
dnl dollar-number references (in awk below) lest they
dnl get seen as m4 function positional parameters.
SYSTEMD_VERSION="`LANG=C LC_ALL=C ${SYSTEMCTL} --version | grep -E '^systemd@<:@ \t@:>@*@<:@0-9@:>@@<:@0-9@:>@*' | awk '{print ''$''2}'`" \
&& test -n "${SYSTEMD_VERSION}" \
|| SYSTEMD_VERSION="none"
AC_MSG_RESULT(${SYSTEMD_VERSION} found)
])
]
)
AS_IF([test x"${SYSTEMD_VERSION}" = xnone], [
AC_MSG_NOTICE([can not check libsystemd settings via pkg-config nor systemctl])
])
AC_MSG_CHECKING(for libsystemd cflags)
AC_ARG_WITH(libsystemd-includes,
AS_HELP_STRING([@<:@--with-libsystemd-includes=CFLAGS@:>@], [include flags for the systemd library]),
Expand Down

0 comments on commit 0cf8e3f

Please sign in to comment.