Add configure --enable-gcov option (enable code coverage analysis)
authorIvan Maidanski <ivmai@mail.ru>
Fri, 13 Jan 2017 17:47:35 +0000 (20:47 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 6 Feb 2017 06:51:30 +0000 (09:51 +0300)
(Cherry-pick commits 0d0a16d, 45896dc from 'master' branch.)

* configure.ac (gcov): New --enable-* option.
* configure.ac [enable_gcov] (CFLAGS): Add "--coverage" option; filter
out "-O" options.

configure.ac

index b38a65a..6075689 100644 (file)
@@ -86,6 +86,14 @@ if test "$enable_assertions" != yes; then
   AC_DEFINE([NDEBUG], 1, [Define to disable assertion checking.])
 fi
 
+AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov],
+                                   [Turn on code coverage analysis]))
+if test "$enable_gcov" = "yes"; then
+  CFLAGS="$CFLAGS --coverage"
+  # Turn off code optimization to get accurate line numbers.
+  CFLAGS=`echo "$CFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
+fi
+
 AC_SUBST(PICFLAG)
 AC_SUBST(DEFS)