autotools: Fix autoconf-archive compatibility issues

autoconf-archive 2019-01-06 changed the setup of code coverage support.
Deal with both old and new. Based on Patrick Venture's similar patch in
other repositories[1].

[1] https://github.com/openbmc/phosphor-pid-control/commit/90e9dbcae6c1df3127dd3de41f9d1e1b5a438828

Change-Id: Ifafda526794602801e7ac1b2f01e62c64f4220d7
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/Makefile.am b/Makefile.am
index 68921d2..9e839a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,7 +12,13 @@
 phosphor_ledcontroller_CFLAGS =  $(SDBUSPLUS_CFLAGS) \
                                  $(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
 
+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
 
 check_PROGRAMS =
 XFAIL_TESTS =
@@ -20,6 +26,3 @@
 include test/Makefile.am.include
 
 TESTS = $(check_PROGRAMS)
-
-clean-local: code-coverage-clean
-dist-clean-local: code-coverage-dist-clean
diff --git a/configure.ac b/configure.ac
index 7060472..7faec80 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
 AC_INIT([phosphor-led-sysfs], [1.0], [https://github.com/openbmc/phosphor-led-sysfs/issues])
 AC_LANG([C++])
 AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
+AM_INIT_AUTOMAKE([subdir-objects -Wall -Wno-portability -Werror foreign dist-xz])
 AM_SILENT_RULES([yes])
 
 # Checks for programs.
@@ -90,6 +90,10 @@
 ])
 
 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_ARG_VAR(BUSNAME, [The Dbus busname to own])
 AS_IF([test "x$BUSNAME" == "x"], [BUSNAME="xyz.openbmc_project.LED.Controller"])