mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-15 12:44:55 +03:00
configure.ac: add option for gcov flags
Gcov[1] is a tool to investigate test code coverage. To collect runtime statistics, certain compiler options must be set, i.e. -fprofile-arcs, -ftest-coverage, and --coverage. Currently, only the Gnu C Compiler is known to support the gcov instrumentation. This change adds the configure option --enable-gcov that checks if the compiler supports the aforementioned compiler flags and enables these. [1] https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
This commit is contained in:
1 parent
4980971dce
commit
7dc5c9d822
1 file changed
+26
@@ -504,6 +504,27 @@ AC_ARG_ENABLE([examples],
|
||||
|
||||
AM_CONDITIONAL(BUILD_EXAMPLES, [test "x$build_examples" = "xyes"])
|
||||
|
||||
# configure options
|
||||
# __gcov__
|
||||
AC_ARG_ENABLE([gcov],
|
||||
[AS_HELP_STRING([--enable-gcov],
|
||||
[Enable building with gcov test coverage support [default=no]])],
|
||||
[build_gcov="$enableval"],
|
||||
[build_gcov="no"
|
||||
AC_MSG_WARN([gcov is disabled])
|
||||
])
|
||||
|
||||
if test "x$build_gcov" = "xyes"; then
|
||||
if test "x$GCC" != "xyes"; then
|
||||
AC_MSG_ERROR([Currently, gcov is assumed to work with GCC-compatible compilers only.])
|
||||
else
|
||||
AX_CHECK_COMPILE_FLAG([-fprofile-arcs], [CFLAGS="$CFLAGS -fprofile-arcs"])
|
||||
AX_CHECK_COMPILE_FLAG([-ftest-coverage], [CFLAGS="$CFLAGS -ftest-coverage"])
|
||||
# FIXME: clang complains about '--coverage'
|
||||
AX_CHECK_COMPILE_FLAG([--coverage], [CFLAGS="$CFLAGS --coverage -O0" LDFLAGS="$LDFLAGS --coverage"])
|
||||
fi
|
||||
fi
|
||||
|
||||
# end configure options
|
||||
#######################
|
||||
|
||||
@@ -708,3 +729,8 @@ if test "x$build_examples" = "xyes"; then
|
||||
else
|
||||
AC_MSG_RESULT([ build examples : "no"])
|
||||
fi
|
||||
if test "x$build_gcov" = "xyes"; then
|
||||
AC_MSG_RESULT([ build with gcov support : "yes"])
|
||||
else
|
||||
AC_MSG_RESULT([ build with gcov support : "no"])
|
||||
fi
|
||||
Reference in new issue
Block a user