To use NUT libraries in your program, use the following code in your configure (.in or .ac) script:
AC_MSG_CHECKING(for NUT client library (libupsclient)) pkg-config --exists libupsclient --silence-errors if test $? -eq 0 then AC_MSG_RESULT(found (using pkg-config)) LDFLAGS="$LDFLAGS `pkg-config --libs libupsclient`" NUT_HEADER="`pkg-config --cflags libupsclient`" else libupsclient-config --version if test $? -eq 0 then AC_MSG_RESULT(found (using libupsclient-config)) LDFLAGS="$LDFLAGS `libupsclient-config --libs`" NUT_HEADER="`libupsclient-config --cflags`" else AC_MSG_ERROR("libupsclient not found") fi fi
This code will test for pkgconfig support for NUT client library, and fall back to libupsclient-config if not available. It will issue an error if none is found!
The same is also valid for other NUT libraries, such as libnutscan. Simply replace libupsclient occurrences in the above example, by the name of the desired library (for example, libnutscan).
this is an alternate method. Use of PKG_CHECK_MODULES macro should be preferred.