+AC_CACHE_CHECK(
+ [gflags namespace],
+ [folly_cv_decl_gflags_namespace],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <gflags/gflags.h>
+ void foo() { gflags::GetArgv(); }]
+ ],
+ [folly_cv_decl_gflags_namespace=gflags],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <gflags/gflags.h>
+ void foo() { google::GetArgv(); }]
+ ],
+ [folly_cv_decl_gflags_namespace=google],
+ [folly_cv_decl_gflags_namespace=error])])])
+
+if test "$folly_cv_decl_gflags_namespace" = error; then
+ AC_MSG_ERROR([Cannot determine gflags namespace])
+else
+ AC_DEFINE_UNQUOTED(
+ [GFLAGS_NAMESPACE], [$folly_cv_decl_gflags_namespace],
+ [Define to gflags namespace (usually "google" or "gflags")])
+ if test "$folly_cv_decl_gflags_namespace" != gflags; then
+ AC_DEFINE([UNUSUAL_GFLAGS_NAMESPACE], [1],
+ [Define to 1 if the gflags namespace is not "gflags"])
+ fi
+fi
+
+# Figure out if we support weak symbols. If not, we will link in some null
+# stubs for functions that would otherwise be weak.
+AC_CACHE_CHECK(
+ [for weak symbol support],
+ [folly_cv_prog_cc_weak_symbols],
+ [AC_LINK_IFELSE(
+ [AC_LANG_SOURCE[
+ extern "C" void configure_link_extern_weak_test() __attribute__((weak));
+ int main(int argc, char** argv) {
+ return configure_link_extern_weak_test == nullptr;
+ }]],
+ [folly_cv_prog_cc_weak_symbols="yes"],
+ [folly_cv_prog_cc_weak_symbols="no"])])
+
+if test "$folly_cv_prog_cc_weak_symbols" = yes; then
+ AC_DEFINE([HAVE_WEAK_SYMBOLS], [1],
+ [Define to 1 if the linker supports weak symbols.])
+fi
+
+
+# Figure out if we support wchar well
+AC_CACHE_CHECK(
+ [for wchar support],
+ [folly_cv_prog_cc_wchar_support],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <cstddef>
+ #include <cwchar>
+
+ int main(int argc, char** argv) {
+ return wcstol(L"01", nullptr, 10) == 1 ? 0 : 1;
+ }
+ ]],
+ [folly_cv_prog_cc_wchar_support=yes],
+ [folly_cv_prog_cc_wchar_support=no])])
+
+if test "$folly_cv_prog_cc_wchar_support" = "yes"; then
+ AC_DEFINE([HAVE_WCHAR_SUPPORT], [1], [Define to 1 if the libc supports wchar well])
+fi
+
+# Figure out whether the architecture supports unaligned accesses
+AC_CACHE_CHECK(
+ [for unaligned access support],
+ [folly_cv_prog_cc_unaligned_access],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE[
+ int main(int argc, char** argv) {
+ char buf[64] = {0};
+ unsigned long *ptr = (unsigned long *)(buf + 1);
+ *ptr = 0xdeadbeef;
+ return (*ptr & 0xff) == 0xef ? 0 : 1;
+ }
+ ]],
+ [folly_cv_prog_cc_unaligned_access=yes],
+ [folly_cv_prog_cc_unaligned_access=no])])
+
+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(
+ [for vsnprintf reporting bad format strings],
+ [folly_cv_prog_vsnprintf_bad_format],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <stdio.h>
+
+ int main(int argc, char** argv) {
+ char buf[256];
+ return vsnprintf(buf, sizeof(buf), "%", 1) < 0 ? 0 : 1;
+ }]],
+ [folly_cv_prog_vsnprintf_bad_format="yes"],
+ [folly_cv_prog_vsnprintf_bad_format="no"])])
+
+if test "$folly_cv_prog_vsnprintf_bad_format" = yes; then
+ AC_DEFINE([HAVE_VSNPRINTF_ERRORS], [1],
+ [Define to 1 if the vsnprintf supports returning errors on bad format strings.])
+fi
+
+AC_SEARCH_LIBS([cplus_demangle_v3_callback], [iberty_pic iberty])
+if test "$ac_cv_search_cplus_demangle_v3_callback" != "no" ; then
+ AC_DEFINE([HAVE_CPLUS_DEMANGLE_V3_CALLBACK], [1],
+ [Define to 1 if we have cplus_demangle_v3_callback.])
+fi
+
+# Check for clock_gettime(2). This is not in an AC_CHECK_FUNCS() because we
+# want to link with librt if necessary.
+AC_SEARCH_LIBS([clock_gettime], [rt],
+ AC_DEFINE(
+ [HAVE_CLOCK_GETTIME],
+ [1],
+ [Define to 1 if we support clock_gettime(2).]),
+ [])
+
+# Check for pthread_atfork(3). This is not in an AC_CHECK_FUNCS() because we
+# want to include pthread.h if necessary.
+AC_CACHE_CHECK(
+ [for pthread_atfork support],
+ [folly_cv_prog_cc_pthread_atfork],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <pthread.h>
+ void func() {pthread_atfork(NULL, NULL, NULL);}]
+ ],
+ [folly_cv_prog_cc_pthread_atfork=yes],
+ [folly_cv_prog_cc_pthread_atfork=no])])
+
+if test "$folly_cv_prog_cc_pthread_atfork" = "yes"; then
+ AC_DEFINE([HAVE_PTHREAD_ATFORK], [1], [Define to 1 if the compiler supports pthread_atfork])
+fi
+
+# 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])