folly: fix gflags<->glog configure check ordering
authorWez Furlong <wez@fb.com>
Sat, 12 Mar 2016 00:36:37 +0000 (16:36 -0800)
committerFacebook Github Bot 0 <facebook-github-bot-0-bot@fb.com>
Sat, 12 Mar 2016 00:50:21 +0000 (16:50 -0800)
Summary:On systems that do not have gflags or glog installed globally,
but only locally as static libraries, our configure check failed for
glog because we were checking it prior to gflags.

glog depends on gflags, but when the libraries are static, there is
no explicit dependency information available and the linker fails.

This resolves the issue by checking for gflags first; this causes
configure to add an implicit `-lgflags` for the subsequent glog
tests.

Reviewed By: yfeldblum

Differential Revision: D3044138

fb-gh-sync-id: 5e07ce52842c6e4cff796560672bf950e2fafe6c
shipit-source-id: 5e07ce52842c6e4cff796560672bf950e2fafe6c

folly/configure.ac

index 62c81230b590cdccf0cb5ba03c750c582777d20b..893680667b3398c7803c93648c4fac7ab918f79e 100644 (file)
@@ -54,29 +54,6 @@ CXXFLAGS="$STD $CXXFLAGS"
 
 # Checks for glog and gflags
 # There are no symbols with C linkage, so we do a try-run
-AC_HAVE_LIBRARY([glog],[],[AC_MSG_ERROR(
-                [Please install google-glog library])])
-AC_CACHE_CHECK(
-  [for glog viability],
-  [folly_cv_prog_cc_glog],
-  [AC_RUN_IFELSE(
-    [AC_LANG_SOURCE[
-      #include <glog/logging.h>
-      int main(int argc, char** argv) {
-        google::InitGoogleLogging(argv[0]);
-        google::ShutdownGoogleLogging();
-        return 0;
-      }
-    ]],
-    [folly_cv_prog_cc_glog=yes],
-    [folly_cv_prog_cc_glog=no]
-  )]
-)
-
-if test "$folly_cv_prog_cc_glog" != "yes"; then
-  AC_MSG_ERROR(["libglog invalid, see config.log for details"])
-fi
-
 AC_HAVE_LIBRARY([gflags],[],[AC_MSG_ERROR(
                 [Please install google-gflags library])])
 AC_CACHE_CHECK(
@@ -100,6 +77,29 @@ if test "$folly_cv_prog_cc_gflags" != "yes"; then
   AC_MSG_ERROR(["libgflags invalid, see config.log for details"])
 fi
 
+AC_HAVE_LIBRARY([glog],[],[AC_MSG_ERROR(
+                [Please install google-glog library])])
+AC_CACHE_CHECK(
+  [for glog viability],
+  [folly_cv_prog_cc_glog],
+  [AC_RUN_IFELSE(
+    [AC_LANG_SOURCE[
+      #include <glog/logging.h>
+      int main(int argc, char** argv) {
+        google::InitGoogleLogging(argv[0]);
+        google::ShutdownGoogleLogging();
+        return 0;
+      }
+    ]],
+    [folly_cv_prog_cc_glog=yes],
+    [folly_cv_prog_cc_glog=no]
+  )]
+)
+
+if test "$folly_cv_prog_cc_glog" != "yes"; then
+  AC_MSG_ERROR(["libglog invalid, see config.log for details"])
+fi
+
 AC_CHECK_LIB(ssl,
         SSL_ctrl,
         [],