Folly parseJson doesn't handle minInt properly
[folly.git] / folly / configure.ac
index d7ddb657299fc9e7a8f6ca83fa3b8c04aeb8a2a6..48a99b5b69450adcb7c44c483c2eb15c1f3a08e4 100644 (file)
@@ -36,47 +36,25 @@ AC_LANG([C++])
 # Checks for programs.
 AC_PROG_CXX
 AC_PROG_CC
-AC_CXX_COMPILE_STDCXX_0X
+
+AC_CXX_COMPILE_STDCXX_1Y
 
 # Be sure to add any -std option to CXXFLAGS before we invoke any
 # AC_COMPILE_IFELSE() or similar macros. Any such macros that are invoked
 # before we update CXXFLAGS will not be run with the same options that we use
 # during the real build.
 STD=""
-if test "x$ac_cv_cxx_compile_cxx0x_cxx" = xyes; then
-   STD="-std=c++0x"
+if test "x$ac_cv_cxx_compile_cxx1y_cxx" = xyes; then
+   STD="-std=c++1y"
 fi
-if test "x$ac_cv_cxx_compile_cxx0x_gxx" = xyes; then
-   STD="-std=gnu++0x"
+if test "x$ac_cv_cxx_compile_cxx1y_gxx" = xyes; then
+   STD="-std=gnu++1y"
 fi
 
 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 +78,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,
         [],
@@ -121,7 +122,7 @@ AM_PATH_PYTHON
 
 # Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h byteswap.h bits/functexcept.h bits/c++config.h])
+AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h sched.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h byteswap.h bits/functexcept.h bits/c++config.h])
 
 AC_CHECK_HEADER(double-conversion/double-conversion.h, [], [AC_MSG_ERROR(
                 [Couldn't find double-conversion.h, please download from \
@@ -252,6 +253,28 @@ if test "$folly_cv_lib_libatomic" = no; then
                   [Please install the GNU Atomic library])])
 fi
 
+AC_CACHE_CHECK(
+  [for liblinux-vdso support],
+  [folly_cv_lib_liblinux_vdso],
+  [AC_RUN_IFELSE(
+    [AC_LANG_PROGRAM[
+      #include <dlfcn.h>
+      int main() {
+        void *h = dlopen("linux-vdso.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
+        if (h == nullptr) {
+          return -1;
+        }
+        dlclose(h);
+        return 0;
+      }
+    ]],
+    [folly_cv_lib_liblinux_vdso=yes],
+    [folly_cv_lib_liblinux_vdso=no])])
+
+if test "$folly_cv_lib_liblinux_vdso" = yes; then
+  AC_DEFINE([HAVE_LINUX_VDSO], [1], [Define to 1 if liblinux-vdso is available])
+fi
+
 AC_CACHE_CHECK(
   [for usable std::is_trivially_copyable],
   [folly_cv_decl_std_is_trivially_copyable],
@@ -317,10 +340,10 @@ if test "$folly_cv_prog_cc_weak_symbols" = yes; then
             [Define to 1 if the linker supports weak symbols.])
 fi
 
-# Figure out whether the architecture supports unaligned reads
+# Figure out whether the architecture supports unaligned accesses
 AC_CACHE_CHECK(
-  [for unaligned reads support],
-  [folly_cv_prog_cc_unaligned_reads],
+  [for unaligned access support],
+  [folly_cv_prog_cc_unaligned_access],
   [AC_RUN_IFELSE(
     [AC_LANG_SOURCE[
       int main(int argc, char** argv) {
@@ -330,11 +353,11 @@ AC_CACHE_CHECK(
         return (*ptr & 0xff) == 0xef ? 0 : 1;
       }
     ]],
-    [folly_cv_prog_cc_unaligned_reads=yes],
-    [folly_cv_prog_cc_unaligned_reads=no])])
+    [folly_cv_prog_cc_unaligned_access=yes],
+    [folly_cv_prog_cc_unaligned_access=no])])
 
-if test "$folly_cv_prog_cc_unaligned_reads" = "yes"; then
-  AC_DEFINE([HAVE_UNALIGNED_READS], [1], [Define to 1 if the architecture allows unaligned reads])
+if test "$folly_cv_prog_cc_unaligned_access" = "yes"; then
+  AC_DEFINE([HAVE_UNALIGNED_ACCESS], [1], [Define to 1 if the architecture allows unaligned accesses])
 fi
 
 AC_CACHE_CHECK(
@@ -452,25 +475,44 @@ AC_CHECK_FUNCS([getdelim \
                 memset \
                 pow \
                 strerror \
-                pthread_yield \
+                sched_yield \
                 malloc_size \
                 malloc_usable_size \
                 memrchr \
-                pipe2])
-
-if test "$ac_cv_func_pthread_yield" = "no"; then
-   AC_CHECK_HEADERS([sched.h])
-   AC_CHECK_FUNCS([sched_yield])
-fi
+                pipe2 \
+                preadv \
+                pwritev \
+              ])
 
 AC_CHECK_HEADER([lz4.h], AC_CHECK_LIB([lz4], [LZ4_decompress_safe]))
 AC_CHECK_HEADER([snappy.h], AC_CHECK_LIB([snappy], [main]))
 AC_CHECK_HEADER([zlib.h], AC_CHECK_LIB([z], [main]))
 AC_CHECK_HEADER([lzma.h], AC_CHECK_LIB([lzma], [main]))
 AC_CHECK_HEADER([zstd.h], AC_CHECK_LIB([zstd], [main]))
-AC_CHECK_HEADERS([libdwarf.h dwarf.h],, AC_MSG_ERROR([Please install libdwarf development package]))
-AC_CHECK_HEADERS([libelf.h elf.h],, AC_MSG_ERROR([Please install libelf development package]))
-AC_CHECK_HEADERS(libunwind.h, ac_cv_have_libunwind_h=1, ac_cv_have_libunwind_h=0)
+
+AC_ARG_ENABLE([follytestmain],
+   AS_HELP_STRING([--enable-follytestmain], [enables using main function from folly for tests]),
+   [follytestmain=${enableval}], [follytestmain=no])
+
+use_follytestmain=yes
+if test "x${follytestmain}" = "xyes"; then
+   AC_CHECK_HEADERS([libdwarf.h dwarf.h],, AC_MSG_ERROR([Please install libdwarf development package]))
+   AC_CHECK_HEADERS([libelf.h elf.h],, AC_MSG_ERROR([Please install libelf development package]))
+   AC_CHECK_HEADERS([libunwind.h],, AC_MSG_ERROR([Please install libinwind development package]))
+else
+   AC_CHECK_HEADERS([libdwarf.h dwarf.h],, [use_follytestmain=no])
+   AC_CHECK_HEADERS([libelf.h elf.h],, [use_follytestmain=no])
+   AC_CHECK_HEADERS([libunwind.h],, [use_follytestmain=no])
+fi
+
+AC_ARG_ENABLE([mobile],
+   AS_HELP_STRING([--enable-mobile],
+                  [enables using main function from folly for tests]),
+                  [mobile=${enableval}], [mobile=no])
+AS_IF([test "x${mobile}" = "xyes"], [
+    AC_DEFINE([MOBILE], [1],
+              [Define to 1 for compiler guards for mobile targets.])
+])
 
 # Include directory that contains "folly" so #include <folly/Foo.h> works
 AM_CPPFLAGS='-I$(top_srcdir)/..'
@@ -490,9 +532,11 @@ AM_CONDITIONAL([RUN_ARCH_SPECIFIC_TESTS], [test "$build_cpu" = "x86_64" || test
 AM_CONDITIONAL([HAVE_LINUX], [test "$build_os" == "linux-gnu"])
 AM_CONDITIONAL([HAVE_WEAK_SYMBOLS],
                [test "$folly_cv_prog_cc_weak_symbols" = "yes"])
-AM_CONDITIONAL([HAVE_BITS_FUNCTEXCEPT], [test "$ac_cv_header_bits_functexcept_h" = "yes"])
+AM_CONDITIONAL([HAVE_BITS_FUNCTEXCEPT_H], [test "$ac_cv_header_bits_functexcept_h" = "yes"])
 AM_CONDITIONAL([HAVE_EXTRANDOM_SFMT19937],
                [test "$folly_cv_prog_cc_have_extrandom_sfmt19937" = "yes"])
+AM_CONDITIONAL([FOLLY_TESTMAIN], [test "x${use_follytestmain}" = "xyes"])
+AM_CONDITIONAL([HAVE_BOOST_CONTEXT], [test "x${ax_cv_boost_context}" = "xyes"])
 
 # Output
 AC_CONFIG_FILES([Makefile