configure: Add code coverage magic
Autoconf changed the way code-coverage was handled in the recent past,
so there a slight complication so we work across both implementations.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I675c64953d262cd4b26a8ab758290ef4325790c0
diff --git a/Makefile.am b/Makefile.am
index c712cfe..f187d9c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,6 +20,18 @@
pkgconfig_DATA = libmctp.pc
+if AUTOCONF_CODE_COVERAGE_2019_01_06
+include $(top_srcdir)/aminclude_static.am
+clean-local: code-coverage-clean
+distclean-local: code-coverage-dist-clean
+else
+@CODE_COVERAGE_RULES@
+endif
+
+AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
+
TESTS = $(check_PROGRAMS)
check_PROGRAMS = tests/test_eid tests/test_seq tests/test_bridge
diff --git a/configure.ac b/configure.ac
index 9ae4681..77212cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,5 +31,11 @@
AM_CONDITIONAL([LIBMCTP_BINDING_serial], [true])
AM_CONDITIONAL([LIBMCTP_BINDING_astlpc], [true])
+AX_CODE_COVERAGE
+m4_ifdef([_AX_CODE_COVERAGE_RULES],
+ [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
+ [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
+AX_ADD_AM_MACRO_STATIC([])
+
AC_CONFIG_FILES([Makefile libmctp.pc])
AC_OUTPUT