Update gtest

Change-Id: Ifce12b71b7435df58f9b25ef5b5e4e8d0ab909c6
Reviewed-on: https://weave-review.googlesource.com/2330
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/tests.mk b/tests.mk
index 563b94b..4e11f7e 100644
--- a/tests.mk
+++ b/tests.mk
@@ -28,8 +28,15 @@
 	mkdir -p $(dir $@)
 	$(CXX) $(DEFS_TEST) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
 
-out/$(BUILD_MODE)/libweave_testrunner : $(weave_unittest_obj_files) $(third_party_chromium_crypto_unittest_obj_files) $(third_party_chromium_base_unittest_obj_files) out/$(BUILD_MODE)/libweave_common.a out/$(BUILD_MODE)/libweave-test.a
-	$(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lgmock -lgtest -lpthread -lrt -Lthird_party/lib
+out/$(BUILD_MODE)/libweave_testrunner : \
+	$(weave_unittest_obj_files) \
+	$(third_party_chromium_crypto_unittest_obj_files) \
+	$(third_party_chromium_base_unittest_obj_files) \
+	out/$(BUILD_MODE)/libweave_common.a \
+	out/$(BUILD_MODE)/libweave-test.a \
+	third_party/lib/gmock.a \
+	third_party/lib/gtest.a
+	$(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lpthread -lrt -Lthird_party/lib
 
 test : out/$(BUILD_MODE)/libweave_testrunner
 	$(TEST_ENV) $< $(TEST_FLAGS)
@@ -43,8 +50,14 @@
 	mkdir -p $(dir $@)
 	$(CXX) $(DEFS_TEST) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
 
-out/$(BUILD_MODE)/libweave_exports_testrunner : $(weave_exports_unittest_obj_files) out/$(BUILD_MODE)/libweave.so out/$(BUILD_MODE)/libweave-test.a out/$(BUILD_MODE)/src/test/weave_testrunner.o
-	$(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lgmock -lgtest -lpthread -lrt -Lthird_party/lib -Wl,-rpath=out/$(BUILD_MODE)/
+out/$(BUILD_MODE)/libweave_exports_testrunner : \
+	$(weave_exports_unittest_obj_files) \
+	out/$(BUILD_MODE)/libweave.so \
+	out/$(BUILD_MODE)/libweave-test.a \
+	out/$(BUILD_MODE)/src/test/weave_testrunner.o \
+	third_party/lib/gmock.a \
+	third_party/lib/gtest.a
+	$(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lpthread -lrt -Lthird_party/lib -Wl,-rpath=out/$(BUILD_MODE)/
 
 export-test : out/$(BUILD_MODE)/libweave_exports_testrunner
 	$(TEST_ENV) $< $(TEST_FLAGS)
diff --git a/third_party/get_gtest.sh b/third_party/get_gtest.sh
index 0a2e952..9b546ab 100755
--- a/third_party/get_gtest.sh
+++ b/third_party/get_gtest.sh
@@ -15,16 +15,17 @@
 
 # gtest is in process of changing of dir structure and it has broken build
 # files. So this is temporarily workaround to fix that.
-git reset --hard d945d8c000a0ade73585d143532266968339bbb3
+git reset --hard 82b11b8cfcca464c2ac74b623d04e74452e74f32
 mv googletest googlemock/gtest
 
-for SUB_DIR in googlemock/gtest googlemock; do
-  cd $THIRD_PARTY/googletest/$SUB_DIR || exit 1
-  autoreconf -fvi || exit 1
-  ./configure --disable-shared || exit 1
-  make || exit 1
-  cp -rf include/* $THIRD_PARTY/include/ || exit 1
-  cp -rf lib/.libs/* $THIRD_PARTY/lib/ || exit 1
-done
+cd $THIRD_PARTY/googletest/googlemock/gtest/make || exit 1
+make gtest.a || exit 1
+cp -rf ../include/* $THIRD_PARTY/include/ || exit 1
+cp -rf gtest.a $THIRD_PARTY/lib/ || exit 1
+
+cd $THIRD_PARTY/googletest/googlemock/make || exit 1
+make gmock.a || exit 1
+cp -rf ../include/* $THIRD_PARTY/include/ || exit 1
+cp -rf gmock.a $THIRD_PARTY/lib/ || exit 1
 
 rm -rf $THIRD_PARTY/googletest
diff --git a/third_party/third_party.mk b/third_party/third_party.mk
index f092e89..8a11e2d 100644
--- a/third_party/third_party.mk
+++ b/third_party/third_party.mk
@@ -50,7 +50,10 @@
 ###
 # libgtest and libgmock (third_party, downloaded on build)
 
-third_party/include/gtest/gtest.h :
+third_party/lib/gtest.a: third_party/include/gtest/gtest.h
+third_party/lib/gmock.a: third_party/include/gtest/gtest.h
+
+third_party/include/gtest/gtest.h:
 	@echo Downloading and building libgtest and libgmock...
 	third_party/get_gtest.sh
 	@echo Finished downloading and building libgtest and libgmock.