Permalink
Browse files

Add support for building with gcov/tcov

I was not able to get gcov working on my machine (mac),
but I've verified the tcov support

Change-Id: I2a3be2d68786698f316e5b1cf8ac408fe82c7986
Reviewed-on: http://review.couchbase.org/15925
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
  • Loading branch information...
1 parent d9a806e commit 9ad6b0e32db2d83c8181548239a059cf24fd717d @trondn trondn committed with chiyoung May 11, 2012
Showing with 35 additions and 2 deletions.
  1. +2 −0 .gitignore
  2. +2 −2 Makefile.am
  3. +31 −0 m4/couchbase.m4
View
@@ -8,6 +8,7 @@
*.lib
*.obj
*.orig
+*.tcov
*~
.deps
.dirstamp
@@ -35,6 +36,7 @@
/testcase.couch
/vc100.idb
/vc100.pdb
+/cbio_unit_tests.profile/
config.h
config.h.in
core*
View
@@ -24,7 +24,7 @@ pkginclude_HEADERS = \
libcbio_la_CPPFLAGS = $(AM_CPPFLAGS) -DLIBCBIO_INTERNAL=1
libcbio_la_SOURCES = src/document.c src/error.c src/instance.c src/internal.h
-libcbio_la_LDFLAGS = $(AM_LDFLAGS) -lcouchstore \
+libcbio_la_LDFLAGS = $(AM_LDFLAGS) $(AM_PROFILE_C_LDFLAGS) -lcouchstore \
-version-info $(LIBCBIO_API_CURRENT):$(LIBCBIO_API_REVISION):$(LIBCBIO_API_AGE) -no-undefined
check_PROGRAMS =
@@ -39,7 +39,7 @@ tests_cbio_unit_tests_SOURCES = tests/cbio_unit_tests.cc \
tests/document_unit_tests.cc \
tests/instance_unit_tests.cc
tests_cbio_unit_tests_DEPENDENCIES = libcbio.la
-tests_cbio_unit_tests_LDFLAGS = -lgtest libcbio.la
+tests_cbio_unit_tests_LDFLAGS = $(AM_PROFILE_CXX_LDFLAGS) -lgtest libcbio.la
LINTFLAGS=-Iinclude -b -c -errchk=%all \
-erroff=E_INCL_NUSD,E_CAST_INT_TO_SMALL_INT,E_PTRDIFF_OVERFLOW \
View
@@ -22,6 +22,19 @@ AC_DEFUN([COUCHBASE_GENERIC_COMPILER], [
[ac_cv_enable_debug="yes"],
[ac_cv_enable_debug="no"])
+ AC_ARG_ENABLE([gcov],
+ [AS_HELP_STRING([--enable-gcov],
+ [Enable gcov build (code coverage). @<:@default=off@:>@])],
+ [ac_cv_enable_gcov="yes"],
+ [ac_cv_enable_gcov="no"])
+
+ AC_ARG_ENABLE([tcov],
+ [AS_HELP_STRING([--enable-tcov],
+ [Enable tcov build (code coverage). @<:@default=off@:>@])],
+ [ac_cv_enable_tcov="yes"],
+ [ac_cv_enable_tcov="no"])
+
+
AC_CACHE_CHECK([whether the C++ compiler works], [ac_cv_prog_cxx_works], [
AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
@@ -144,6 +157,24 @@ AC_DEFUN([COUCHBASE_GENERIC_COMPILER], [
AM_CXXFLAGS="$AM_CXXFLAGS $CXX_OPTIMIZE"
])
+ dnl gcov settings
+ AS_IF([test "$ac_cv_enable_gcov" = "yes"],
+ [
+ AM_CPPFLAGS="$AM_CPPFLAGS -fprofile-arcs -ftest-coverage"
+ AM_PROFILE_C_LDFLAGS="-lgcov"
+ AM_PROFILE_CXX_LDFLAGS="-lgcov"
+ ])
+
+ dnl tcov settings
+ AS_IF([test "$ac_cv_enable_tcov" = "yes"],
+ [
+ AM_CPPFLAGS="$AM_CPPFLAGS -xprofile=tcov"
+ AM_PROFILE_C_LDFLAGS="-Wc,-xprofile=tcov"
+ AM_PROFILE_CXX_LDFLAGS="-xprofile=tcov"
+ ])
+ AC_SUBST(AM_PROFILE_C_LDFLAGS)
+ AC_SUBST(AM_PROFILE_CXX_LDFLAGS)
+
dnl Export GCC variables
AC_SUBST(GCC_NO_WERROR)
AC_SUBST(GCC_WERROR)

0 comments on commit 9ad6b0e

Please sign in to comment.