+# Check for XSI-compatible strerror_r as default implementation
+AC_CACHE_CHECK(
+ [for XSI style strerror_r support],
+ [folly_cv_prog_cc_xsi_strerror_r],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <string.h>
+ #include <errno.h>
+ int main(int argc, char** argv) {
+ char buf[1024];
+ buf[0] = 0;
+ int ret = strerror_r(ENOMEM, buf, sizeof(buf));
+ return ret;
+ }
+ ]],
+ [folly_cv_prog_cc_xsi_strerror_r=yes],
+ [folly_cv_prog_cc_xsi_strerror_r=no])])
+
+if test "$folly_cv_prog_cc_xsi_strerror_r" = "yes"; then
+ AC_DEFINE([HAVE_XSI_STRERROR_R], [1], [Define to 1 if the runtime supports XSI-style strerror_r])
+fi
+
+AC_CACHE_CHECK(
+ [for ext/random and __gnu_cxx::sfmt19937],
+ [folly_cv_prog_cc_have_extrandom_sfmt19937],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <ext/random>
+ int main(int argc, char** argv) {
+ __gnu_cxx::sfmt19937 rng;
+ return 0;
+ }
+ ]],
+ [folly_cv_prog_cc_have_extrandom_sfmt19937=yes],
+ [folly_cv_prog_cc_have_extrandom_sfmt19937=no])])
+
+AC_CACHE_CHECK(
+ [for VLA (variable-length array) support],
+ [folly_cv_prog_cc_have_vla],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE[
+ int main(int argc, char** argv) {
+ unsigned size = argc;
+ char data[size];
+ return 0;
+ }
+ ]],
+ [folly_cv_prog_cc_have_vla=yes],
+ [folly_cv_prog_cc_have_vla=no])])
+
+test "$folly_cv_prog_cc_have_vla" = yes && have_vla=1 || have_vla=0
+AC_DEFINE_UNQUOTED(
+ [HAVE_VLA],
+ [$have_vla],
+ [Define to 1 if the compiler has VLA (variable-length array) support,
+ otherwise define to 0])
+
+AC_CACHE_CHECK(
+ [for variable template support],
+ [folly_cv_prog_cc_have_variable_templates],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE[
+ template <class> constexpr bool g = true;
+ int main() {}
+ ]],
+ [folly_cv_prog_cc_have_variable_templates=yes],
+ [folly_cv_prog_cc_have_variable_templates=no])])
+
+AM_CONDITIONAL(
+ [HAVE_VARIABLE_TEMPLATES],
+ [test "x${folly_cv_prog_cc_have_variable_templates}" = "xyes"],
+ [Define to 1 if the compiler supports variable templates])
+
+# Checks for library functions.
+AC_CHECK_FUNCS([malloc_size \
+ malloc_usable_size \
+ memrchr \
+ 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], [ZSTD_compressStream]))
+AC_CHECK_HEADER([bzlib.h], AC_CHECK_LIB([bz2], [main]))
+AC_CHECK_HEADER([linux/membarrier.h], AC_DEFINE([HAVE_LINUX_MEMBARRIER_H], [1], [Define to 1 if membarrier.h is available]))
+
+AC_ARG_ENABLE([follytestmain],
+ AS_HELP_STRING([--enable-follytestmain], [enables using main function from folly for tests]),
+ [use_follytestmain=${enableval}], [use_follytestmain=yes])
+
+# libdwarf used to install in /usr/include, now installs in /usr/include/libdwarf.
+have_libdwarf=no
+AC_CHECK_HEADERS([libdwarf/dwarf.h dwarf.h], [have_libdwarf=yes])
+
+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.])
+])
+
+AC_ARG_ENABLE([exception-tracer],
+ AS_HELP_STRING([--enable-exception-tracer], [enables building exception tracer]),
+ [build_exception_tracer=${enableval}], [build_exception_tracer=no])
+
+AC_ARG_ENABLE([symbolizer],
+ AS_HELP_STRING([--enable-symbolizer], [try to build symbolizer if possible]),
+ [folly_try_use_symbolizer=${enableval}], [folly_try_use_symbolizer=yes])
+
+folly_use_symbolizer=no
+if test "$folly_try_use_symbolizer" = yes; then
+ if test "$build_os" = "linux-gnu" && test "$have_libdwarf" = yes; then
+ AC_CHECK_HEADER(
+ [elf.h],
+ AC_CHECK_LIB([unwind], [backtrace], [folly_use_symbolizer=yes]),
+ )
+ fi
+fi
+if test "$folly_use_symbolizer" = yes; then
+ AC_DEFINE([USE_SYMBOLIZER], [1], [Define to 1 if we should use the symbolizer in init])
+fi
+
+
+# Include directory that contains "folly" so #include <folly/Foo.h> works
+AM_CPPFLAGS='-I$(top_srcdir)/..'
+AM_CPPFLAGS="$AM_CPPFLAGS $BOOST_CPPFLAGS $OPENSSL_INCLUDES"
+AM_LDFLAGS="$AM_LDFLAGS $BOOST_CONTEXT_LIB $BOOST_PROGRAM_OPTIONS_LIB"
+AM_LDFLAGS="$AM_LDFLAGS $BOOST_THREAD_LIB $BOOST_FILESYSTEM_LIB"
+AM_LDFLAGS="$AM_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_REGEX_LIB -lpthread"
+AM_LDFLAGS="$AM_LDFLAGS $BOOST_CHRONO_LIB"
+
+AM_LDFLAGS="$AM_LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LIBS"
+
+AC_SUBST([AM_CPPFLAGS])
+AC_SUBST([AM_LDFLAGS])