diff --git a/.gitignore b/.gitignore
index 484f41f..a0c9389 100644
--- a/.gitignore
+++ b/.gitignore
*.lo
*.la
*.so
+*.gcno
+*.gcda
.deps
.libs
.dirstamp
autom4te.cache
test-driver
test-suite.log
+coverage.info
+coverage
lib/bluez.pc
lib/bluetooth
src/builtin.h
diff --git a/Makefile.am b/Makefile.am
index d6cd887..f2b22ae 100644
--- a/Makefile.am
+++ b/Makefile.am
$(AM_V_at)$(MKDIR_P) lib/bluetooth
$(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@
+if COVERAGE
+clean-coverage:
+ @lcov --directory $(top_builddir) --zerocounters
+ $(RM) -r coverage $(top_builddir)/coverage.info
+
+coverage: check
+ @lcov --compat-libtool --directory $(top_builddir) --capture \
+ --output-file $(top_builddir)/coverage.info
+ $(AM_V_at)$(MKDIR_P) coverage
+ @genhtml -o coverage/ $(top_builddir)/coverage.info
+
+clean-local: clean-coverage
+ -find $(top_builddir) -name "*.gcno" -delete
+ -find $(top_builddir) -name "*.gcda" -delete
+ $(RM) -r lib/bluetooth
+
+else
clean-local:
+ -find $(top_builddir) -name "*.gcno" -delete
+ -find $(top_builddir) -name "*.gcda" -delete
$(RM) -r lib/bluetooth
+endif
diff --git a/acinclude.m4 b/acinclude.m4
index 4c241bf..4cfc80a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
misc_ldflags="$misc_ldflags -pie"
fi
])
+ if (test "$USE_MAINTAINER_MODE" = "yes"); then
+ misc_cflags="$misc_cflags --coverage"
+ misc_ldflags="$misc_ldflags --coverage"
+ fi
AC_SUBST([MISC_CFLAGS], $misc_cflags)
AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
])
diff --git a/configure.ac b/configure.ac
index e04a6eb..196e784 100644
--- a/configure.ac
+++ b/configure.ac
AC_DEFINE_UNQUOTED(ANDROID_STORAGEDIR, "${storagedir}/android",
[Directory for the Android daemon storage files])
+if (test "$USE_MAINTAINER_MODE" = "yes"); then
+ AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required))
+fi
+AM_CONDITIONAL(COVERAGE, test "$LCOV" = "yes")
+
AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)