Commit c06ed219 by Serge Hallyn

configure.ac: fix the check for static libcap

The existing check doesn't work, because when you statically link a program against libc, any functions not called are not included. So cap_init() which we check for is not there in the built binary. So instead just check whether a "gcc -lcap -static" works. If libcap.a is not available it will fail, if it is it will succeed. Signed-off-by: 's avatarSerge Hallyn <shallyn@cisco.com>
parent acd546ad
...@@ -347,16 +347,32 @@ else ...@@ -347,16 +347,32 @@ else
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
fi fi
AC_MSG_CHECKING(for static libcap)
# Check for static libcap, make sure the function checked for differs from the # Check for static libcap, make sure the function checked for differs from the
# the one checked below so the cache doesn't give a wrong answer # the one checked below so the cache doesn't give a wrong answer
OLD_CFLAGS="$CFLAGS" OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -static" OLD_CPPFLAGS="$CPPFLAGS"
AC_CHECK_LIB([cap],[cap_init],[have_static_libcap=yes],[have_static_libcap=no]) OLD_LDFLAGS="$LDFLAGS"
OLD_LIBS="$LIBS"
CFLAGS=""
CPPFLAGS=""
LDFLAGS="-static"
LIBS="-lcap"
AC_LINK_IFELSE([
AC_LANG_SOURCE(
[[int main() { return 0; }]]
)],[have_static_libcap=yes],[have_static_libcap=no])
AM_CONDITIONAL([HAVE_STATIC_LIBCAP], [test "x$have_static_libcap" = "xyes"]) AM_CONDITIONAL([HAVE_STATIC_LIBCAP], [test "x$have_static_libcap" = "xyes"])
if test "x$have_static_libcap" = "xyes"; then if test "x$have_static_libcap" = "xyes"; then
AC_DEFINE([HAVE_STATIC_LIBCAP], 1, [Have static libcap]) AC_DEFINE([HAVE_STATIC_LIBCAP], 1, [Have static libcap])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi fi
CPPFLAGS="$OLD_CPPFLAGS"
CFLAGS="$OLD_CFLAGS" CFLAGS="$OLD_CFLAGS"
LDFLAGS="$OLD_LDFLAGS"
LIBS="$OLD_LIBS"
# Linux capabilities # Linux capabilities
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment