Skip to content

Commit

Permalink
m4/nut_check_libpowerman.m4: convert to use depCFLAGS etc. and mix th…
Browse files Browse the repository at this point in the history
…em with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
  • Loading branch information
jimklimov committed Nov 10, 2024
1 parent c172b27 commit 9a45751
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions m4/nut_check_libpowerman.m4
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ if test -z "${nut_have_libpowerman_seen}"; then
dnl save CFLAGS and LIBS
CFLAGS_ORIG="${CFLAGS}"
LIBS_ORIG="${LIBS}"
CFLAGS=""
LIBS=""
depCFLAGS=""
depLIBS=""
AS_IF([test x"$have_PKG_CONFIG" = xyes],
[AC_MSG_CHECKING([for LLNC libpowerman version via pkg-config])
Expand All @@ -33,11 +37,11 @@ if test -z "${nut_have_libpowerman_seen}"; then
)
AS_IF([test x"$POWERMAN_VERSION" != xnone],
[CFLAGS="`$PKG_CONFIG --silence-errors --cflags libpowerman 2>/dev/null`"
LIBS="`$PKG_CONFIG --silence-errors --libs libpowerman 2>/dev/null`"
[depCFLAGS="`$PKG_CONFIG --silence-errors --cflags libpowerman 2>/dev/null`"
depLIBS="`$PKG_CONFIG --silence-errors --libs libpowerman 2>/dev/null`"
],
[CFLAGS=""
LIBS=""
[depCFLAGS=""
depLIBS=""
]
)
Expand All @@ -50,11 +54,11 @@ if test -z "${nut_have_libpowerman_seen}"; then
AC_MSG_ERROR([invalid option --with(out)-powerman-includes - see docs/configure.txt])
;;
*)
CFLAGS="${withval}"
depCFLAGS="${withval}"
;;
esac
], [])
AC_MSG_RESULT([${CFLAGS}])
AC_MSG_RESULT([${depCFLAGS}])
AC_MSG_CHECKING(for libpowerman libs)
AC_ARG_WITH(powerman-libs,
Expand All @@ -65,35 +69,40 @@ if test -z "${nut_have_libpowerman_seen}"; then
AC_MSG_ERROR(invalid option --with(out)-powerman-libs - see docs/configure.txt)
;;
*)
LIBS="${withval}"
depLIBS="${withval}"
;;
esac
], [])
AC_MSG_RESULT([${LIBS}])
AC_MSG_RESULT([${depLIBS}])
dnl check if libpowerman is usable
CFLAGS="${CFLAGS_ORIG} ${depCFLAGS}"
LIBS="${LIBS_ORIG} ${depLIBS}"
AC_CHECK_HEADERS(libpowerman.h, [nut_have_libpowerman=yes], [nut_have_libpowerman=no], [AC_INCLUDES_DEFAULT])
AC_CHECK_FUNCS(pm_connect, [], [
dnl Some systems may just have libpowerman in their
dnl standard paths, but not the pkg-config data
AS_IF([test "${nut_have_libpowerman}" = "yes" && test "$POWERMAN_VERSION" = "none" && test -z "$LIBS"],
[AC_MSG_CHECKING([if libpowerman is just present in path])
LIBS="-L/usr/lib -L/usr/local/lib -lpowerman"
depLIBS="-L/usr/lib -L/usr/local/lib -lpowerman"
unset ac_cv_func_pm_connect || true
LIBS="${LIBS_ORIG} ${depLIBS}"
AC_CHECK_FUNCS(pm_connect, [], [nut_have_libpowerman=no])
AC_MSG_RESULT([${nut_have_libpowerman}])
], [nut_have_libpowerman=no]
)]
)
if test "${nut_have_libpowerman}" = "yes"; then
LIBPOWERMAN_CFLAGS="${CFLAGS}"
LIBPOWERMAN_LIBS="${LIBS}"
LIBPOWERMAN_CFLAGS="${depCFLAGS}"
LIBPOWERMAN_LIBS="${depLIBS}"
fi
unset depCFLAGS
unset depLIBS
dnl restore original CFLAGS and LIBS
CFLAGS="${CFLAGS_ORIG}"
LIBS="${LIBS_ORIG}"
fi
])

0 comments on commit 9a45751

Please sign in to comment.