autotools: Fix for autoconf-archive 2019.01.19

The code coverage macros from the archive changed in a backward
incompatible way. This adds a workaround to autodetect either version
and do the right thing

Change-Id: Ic010ed59fb332e19e5c76f60e55f864f8f4a43f8
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/configure.ac b/configure.ac
index a2ae7a6..c725bcf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIRS([m4])
 AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE([nostdinc foreign subdir-objects -Wall -Werror dist-xz tar-ustar])
+AM_INIT_AUTOMAKE([nostdinc foreign subdir-objects -Wall -Wno-portability -Werror dist-xz tar-ustar])
 AM_SILENT_RULES([yes])
 
 # Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS
@@ -142,7 +142,13 @@
 
 # Code coverage
 AX_CODE_COVERAGE
-AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage])
+AS_IF([test "x$CODE_COVERAGE_ENABLED" = "xyes"], [
+    AX_APPEND_COMPILE_FLAGS([-DHAVE_GCOV], [CODE_COVERAGE_CPPFLAGS])
+])
+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([])
 
 # Append -Werror after doing autoconf compiler checks
 # Otherwise some perfectly valid checks can fail and cause our