update configure and test/Makefile.am

Update configure.ac and test/Makefile.am to properly handle
newer googletest, per gerrit/11203.

Change-Id: Idcef3d81ff834457fcdc6e0aa1be76b98c64b54c
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/configure.ac b/configure.ac
index 55c8a43..06c18ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@
 PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], [], [AC_MSG_ERROR(["phosphor-dbus-interfaces required and not found."])])
 AC_CHECK_HEADER(experimental/any, ,[AC_MSG_ERROR([Could not find experimental/any...libstdc++fs development package required])])
 PKG_CHECK_MODULES([LIBCONFIGXX], [libconfig++ >= 1.5], ,AC_MSG_ERROR([libconfig++ 1.5 or newer not found.]))
+AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])])
 
 # Checks for library functions.
 LT_INIT # Required for systemd linking
@@ -35,8 +36,7 @@
 # Check/set gtest specific functions.
 PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
 PKG_CHECK_MODULES([GMOCK], [gmock], [], [AC_MSG_NOTICE([gmock not found, tests will not build])])
-AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"])
-AC_SUBST(GTEST_CPPFLAGS)
+PKG_CHECK_MODULES([GTEST_MAIN], [gtest_main], [], [AC_MSG_NOTICE([gtest_main not found, tests will not build])])
 
 AC_ARG_ENABLE([oe-sdk],
     AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
diff --git a/test/Makefile.am b/test/Makefile.am
index 2a51c00..7fdbaf5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,12 +1,11 @@
 AM_CPPFLAGS = -I$(top_srcdir)/ $(GTEST_CFLAGS) $(GMOCK_CFLAGS)
-AM_CXXFLAGS = $(PTHREAD_CFLAGS) \
-	$(GTEST_CFLAGS) \
-	$(GMOCK_CFLAGS) \
+AM_CXXFLAGS = \
+	$(GTEST_MAIN_CFLAGS) \
 	$(SDBUSPLUS_CFLAGS) \
 	$(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
-AM_LDFLAGS = $(GTEST_LIBS) \
-	$(PTHREAD_LIBS) \
+AM_LDFLAGS = \
 	$(GMOCK_LIBS) \
+	$(GTEST_MAIN_LIBS) \
 	$(OESDK_TESTCASE_FLAGS) \
 	$(SDBUSPLUS_LIBS) \
 	$(PHOSPHOR_DBUS_INTERFACES_LIBS)