Improve libroken configure check
authorAndrew Deason <adeason@sinenomine.net>
Thu, 17 Jan 2013 21:37:06 +0000 (15:37 -0600)
committerDerrick Brashear <shadow@your-file-system.com>
Mon, 21 Jan 2013 13:32:08 +0000 (05:32 -0800)
It is not sufficient to just check if libroken is available; we need
to check if the specific functionality we want is there. So, try to
compile and link while referencing specific functions.

As mentioned in the comments, testing every single function we use may
not be practical, and we should perhaps just add functions to test as
we find breakage. This commit tests rk_rename, which is missing in at
least the Debian package heimdal-dev, version
1.4.0~git20100726.dfsg.1-2+squeeze1.

Change-Id: I0ac6c9aea1f8598bb1b1315544683b2403de5f69
Reviewed-on: http://gerrit.openafs.org/8916
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/cf/roken.m4

index ee1f095..8f692d3 100644 (file)
@@ -24,17 +24,36 @@ AC_DEFUN([_OPENAFS_ROKEN_CHECK], [
   save_LIBS=$LIBS
   AS_IF([test x"$roken_path" != x],
        [CPPFLAGS="-I$roken_path/include $CPPFLAGS"
-        LDFLAGS="-L$roken_path/lib $LDFLAGS"])
+        LDFLAGS="-L$roken_path/lib $LDFLAGS"
+        checkstr=" in $roken_path"])
 
+  AC_MSG_CHECKING([for usable system libroken$checkstr])
+
+  LIBS="$LIBS -lroken"
   dnl Need to be careful what we check for here, as libroken contains
-  dnl different symbols on different platforms.
-  AC_CHECK_LIB([roken], [ct_memcmp], [roken_foundlib=true])
-  AC_CHECK_HEADER([roken.h], [roken_foundheader=true])
+  dnl different symbols on different platforms. We cannot simply check
+  dnl if e.g. rk_rename is a symbol or not, since on most platforms it
+  dnl will be a preprocessor define, but on others it will be a symbol.
+  dnl
+  dnl Also note that we need to check for the specific functionality in
+  dnl roken that we use, not just the existence of the library itself,
+  dnl since older versions of roken do not contain all of the functions
+  dnl we need. It may not be practical to check everything we use, so
+  dnl just add functions to check here as we find installations where
+  dnl this breaks.
+  AC_LINK_IFELSE(
+   [AC_LANG_PROGRAM(
+    [[#include <roken.h>]],
+    [[ct_memcmp(NULL, NULL, 0); rk_rename(NULL, NULL);]])],
+   [roken_found=true
+    AC_MSG_RESULT([yes])],
+   [AC_MSG_RESULT([no])])
+
   CPPFLAGS=$save_CPPFLAGS
   LDFLAGS=$save_LDFLAGS
   LIBS=$save_LIBS
 
-  AS_IF([test x"$roken_foundlib" = xtrue && test x"$roken_foundheader" = xtrue],
+  AS_IF([test x"$roken_found" = xtrue],
         [AS_IF([test x"$roken_path" != x],
               [CPPFLAGS_roken="-I$roken_path/include"
                LDFLAGS_roken="-L$roken_path/lib"])