ofalk / libdnet

libdnet provides a simplified, portable interface to several low-level networking routines.
Other
153 stars 60 forks source link

Detect "check" lib multi-arch aware via pkg-config #70

Closed florianernst closed 2 years ago

florianernst commented 2 years ago

Hello there,

configure.ac attempts to autodetect the "check" lib presence by looking for ${prefix}/lib/libcheck.a.

However, this fixed path is not Multiarch aware, and hence the detection fails e.g. on a more recent Debian File System Structure.

I now worked around this via the following patch, relying on pkg-config for detection:

diff --git a/INSTALL b/INSTALL
index 6f1959d..4ea224c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,10 @@

 *BSD, MacOS X, Linux
 --------------------
+Make sure you have `pkg-config` installed.
+
+Install Check (https://libcheck.github.io/check/) for additional checks
+during build time.

 ./configure && make

diff --git a/configure.ac b/configure.ac
index 675587d..55b6aee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,7 +129,7 @@ fi
 dnl Checks for Check.
 AC_MSG_CHECKING(for Check)
 AC_ARG_WITH(check,
-[  --with-check=DIR        use Check (http://check.sf.net) in DIR],
+[  --with-check=DIR        use Check (https://libcheck.github.io/check/) in DIR],
 [ case "$withval" in
   yes|no)
      AC_MSG_RESULT(no)
@@ -151,9 +151,10 @@ AC_ARG_WITH(check,
      fi
      ;;
   esac ],
-[ if test -f ${prefix}/include/check.h -a -f ${prefix}/lib/libcheck.a; then
+[ PKG_CHECK_MODULES([CHECK], [check])
+  if test -n "${CHECK_LIBS}"; then
      CHECKINC="-I${prefix}/include"
-     CHECKLIB="-L${prefix}/lib -lcheck"
+     CHECKLIB="${CHECK_LIBS}"
      AC_MSG_RESULT(yes)
   else
      AC_MSG_RESULT(no)

Without pkg-config installed the configure will fail badly, and I actually don't know how generic this approach really is, so YMMV.

Still, I thought I'd let you know.

Cheers, Flo

ofalk commented 2 years ago

Included in the devel branch now. IMHO, pkg-config is widely used and therefore absolutely makes sense.