Generate main() for running self-test.

Avoid running test from global constructor as (in skeleton code):

  (global scope)
  static int SKELETONResult = SKELETON::RunTest();

Executing complicated code in global constructors is quite dangerous. As
the order of global constructors being invoked between translation units
is unspecified, we may end up using things from dependent libraries that
haven't been initialized yet.

In our internal build environment, farmhash_unittest is linked against
static version of STL library (more specifically, libc++.a). Running it
gets segfault because RunTest()s access uninitialized `std::cout`.

This commit modifies builder.cc to generate main() in farmhash.cc which
calls RunTest()s for self-test code. There's no functionality changed.

Test plan: pass "make check".
diff --git a/dev/builder.cc b/dev/builder.cc
index e90cd72..a8ac91c 100644
--- a/dev/builder.cc
+++ b/dev/builder.cc
@@ -459,6 +459,14 @@
                   "done");
   DoWithNoOutputExpected("(echo; echo '#if FARMHASHSELFTEST'; echo;"
                          " cat " + dir + "/*_selftest1.cc;"
+                         " echo; echo 'int main() {';"
+                         " for i in " + dir + "/*_gen.cc; "
+                         " do"
+                         "   namespace=$(basename ${i%_gen.cc});"
+                         "   echo '  '${namespace}'Test::RunTest();';"
+                         " done;"
+                         " echo '  __builtin_unreachable();';"
+                         " echo '}';"
                          " echo; echo '#endif  // FARMHASHSELFTEST') "
                          ">> ../src/farmhash.cc");
 
diff --git a/dev/self-test-skeleton.cc b/dev/self-test-skeleton.cc
index 40a3370..ec54018 100644
--- a/dev/self-test-skeleton.cc
+++ b/dev/self-test-skeleton.cc
@@ -144,11 +144,7 @@
 
 }  // namespace SKELETON
 
-#if TESTING
-
-static int SKELETONResult = SKELETON::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
diff --git a/src/farm-test.cc b/src/farm-test.cc
index 91c9b6d..b4fdcc2 100644
--- a/src/farm-test.cc
+++ b/src/farm-test.cc
@@ -34,5 +34,3 @@
 #define FARMHASH_DIE_IF_MISCONFIGURED do { return 0; } while (0)
 
 #include "farmhash.cc"
-
-int main() {}
diff --git a/src/farmhash.cc b/src/farmhash.cc
index 5af1087..560eb66 100644
--- a/src/farmhash.cc
+++ b/src/farmhash.cc
@@ -3571,11 +3571,7 @@
 
 }  // namespace farmhashccTest
 
-#if TESTING
-
-static int farmhashccTestResult = farmhashccTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -4467,11 +4463,7 @@
 
 }  // namespace farmhashmkTest
 
-#if TESTING
-
-static int farmhashmkTestResult = farmhashmkTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -5727,11 +5719,7 @@
 
 }  // namespace farmhashnaTest
 
-#if TESTING
-
-static int farmhashnaTestResult = farmhashnaTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -6623,11 +6611,7 @@
 
 }  // namespace farmhashntTest
 
-#if TESTING
-
-static int farmhashntTestResult = farmhashntTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -7519,11 +7503,7 @@
 
 }  // namespace farmhashsaTest
 
-#if TESTING
-
-static int farmhashsaTestResult = farmhashsaTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -8415,11 +8395,7 @@
 
 }  // namespace farmhashsuTest
 
-#if TESTING
-
-static int farmhashsuTestResult = farmhashsuTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -9675,11 +9651,7 @@
 
 }  // namespace farmhashteTest
 
-#if TESTING
-
-static int farmhashteTestResult = farmhashteTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -10571,11 +10543,7 @@
 
 }  // namespace farmhashuoTest
 
-#if TESTING
-
-static int farmhashuoTestResult = farmhashuoTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -11831,11 +11799,7 @@
 
 }  // namespace farmhashxoTest
 
-#if TESTING
-
-static int farmhashxoTestResult = farmhashxoTest::RunTest();
-
-#else
+#if !TESTING
 int main(int argc, char** argv) {
   Setup();
   cout << "uint32_t expected[] = {\n";
@@ -11851,4 +11815,17 @@
 }
 #endif
 
+int main() {
+  farmhashccTest::RunTest();
+  farmhashmkTest::RunTest();
+  farmhashnaTest::RunTest();
+  farmhashntTest::RunTest();
+  farmhashsaTest::RunTest();
+  farmhashsuTest::RunTest();
+  farmhashteTest::RunTest();
+  farmhashuoTest::RunTest();
+  farmhashxoTest::RunTest();
+  __builtin_unreachable();
+}
+
 #endif  // FARMHASHSELFTEST