+CFLAGS="$SAVE_CFLAGS"
+LIBS="$SAVE_LIBS"
+
+# TODO(hamaji): Use official m4 macros provided by testing libraries
+# once the m4 macro of Google Mocking becomes ready.
+# Check if there is Google Test library installed.
+AC_CHECK_PROG(GTEST_CONFIG, gtest-config, "yes")
+AC_CHECK_LIB(gtest, main, have_gtest_lib="yes")
+if test x"$GTEST_CONFIG" = "xyes" -a x"$have_gtest_lib" = "xyes"; then
+ GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
+ GTEST_LIBS=`gtest-config --ldflags --libs`
+ AC_DEFINE(HAVE_LIB_GTEST, 1, [define if you have google gtest library])
+
+ # Check if there is Google Mocking library installed.
+ AC_CHECK_PROG(GMOCK_CONFIG, gmock-config, "yes")
+ if test x"$GMOCK_CONFIG" = "xyes"; then
+ GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
+ GMOCK_LIBS=`gmock-config --ldflags --libs`
+ AC_DEFINE(HAVE_LIB_GMOCK, 1, [define if you have google gmock library])
+ else
+ # We don't run test cases which use Google Mocking framework.
+ GMOCK_CFLAGS=
+ GMOCK_LIBS=
+ fi
+else
+ # We'll use src/googletest.h for our unittests.
+ GTEST_CFLAGS=
+ GTEST_LIBS=
+fi
+AM_CONDITIONAL(HAVE_GMOCK, test x"$GMOCK_CONFIG" = "xyes")
+
+# We want to link in libunwind if it exists
+UNWIND_LIBS=
+# Unfortunately, we need to check the header file in addition to the
+# lib file to check if libunwind is available since libunwind-0.98
+# doesn't install all necessary header files.
+if test x"$ac_cv_have_libunwind_h" = x"1"; then
+ AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind)
+fi
+AC_SUBST(UNWIND_LIBS)
+if test x"$UNWIND_LIBS" != x""; then
+ AC_DEFINE(HAVE_LIB_UNWIND, 1, [define if you have libunwind])
+fi