configure.ac 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. m4_define([snappy_major], [1])
  2. m4_define([snappy_minor], [1])
  3. m4_define([snappy_patchlevel], [2])
  4. # Libtool shared library interface versions (current:revision:age)
  5. # Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
  6. # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
  7. m4_define([snappy_ltversion], [3:1:2])
  8. AC_INIT([snappy], [snappy_major.snappy_minor.snappy_patchlevel])
  9. AC_CONFIG_MACRO_DIR([m4])
  10. # These are flags passed to automake (though they look like gcc flags!)
  11. AM_INIT_AUTOMAKE([-Wall])
  12. LT_INIT
  13. AC_SUBST([LIBTOOL_DEPS])
  14. AC_PROG_CXX
  15. AC_LANG([C++])
  16. AC_C_BIGENDIAN
  17. AC_TYPE_SIZE_T
  18. AC_TYPE_SSIZE_T
  19. AC_CHECK_HEADERS([stdint.h stddef.h sys/mman.h sys/resource.h windows.h byteswap.h sys/byteswap.h sys/endian.h sys/time.h])
  20. # Don't use AC_FUNC_MMAP, as it checks for mappings of already-mapped memory,
  21. # which we don't need (and does not exist on Windows).
  22. AC_CHECK_FUNC([mmap])
  23. GTEST_LIB_CHECK([], [true], [true # Ignore; we can live without it.])
  24. AC_ARG_WITH([gflags],
  25. [AS_HELP_STRING(
  26. [--with-gflags],
  27. [use Google Flags package to enhance the unit test @<:@default=check@:>@])],
  28. [],
  29. [with_gflags=check])
  30. if test "x$with_gflags" != "xno"; then
  31. PKG_CHECK_MODULES(
  32. [gflags],
  33. [libgflags],
  34. [AC_DEFINE([HAVE_GFLAGS], [1], [Use the gflags package for command-line parsing.])],
  35. [if test "x$with_gflags" != "xcheck"; then
  36. AC_MSG_FAILURE([--with-gflags was given, but test for gflags failed])
  37. fi])
  38. fi
  39. # See if we have __builtin_expect.
  40. # TODO: Use AC_CACHE.
  41. AC_MSG_CHECKING([if the compiler supports __builtin_expect])
  42. AC_TRY_COMPILE(, [
  43. return __builtin_expect(1, 1) ? 1 : 0
  44. ], [
  45. snappy_have_builtin_expect=yes
  46. AC_MSG_RESULT([yes])
  47. ], [
  48. snappy_have_builtin_expect=no
  49. AC_MSG_RESULT([no])
  50. ])
  51. if test x$snappy_have_builtin_expect = xyes ; then
  52. AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler supports __builtin_expect.])
  53. fi
  54. # See if we have working count-trailing-zeros intrinsics.
  55. # TODO: Use AC_CACHE.
  56. AC_MSG_CHECKING([if the compiler supports __builtin_ctzll])
  57. AC_TRY_COMPILE(, [
  58. return (__builtin_ctzll(0x100000000LL) == 32) ? 1 : 0
  59. ], [
  60. snappy_have_builtin_ctz=yes
  61. AC_MSG_RESULT([yes])
  62. ], [
  63. snappy_have_builtin_ctz=no
  64. AC_MSG_RESULT([no])
  65. ])
  66. if test x$snappy_have_builtin_ctz = xyes ; then
  67. AC_DEFINE([HAVE_BUILTIN_CTZ], [1], [Define to 1 if the compiler supports __builtin_ctz and friends.])
  68. fi
  69. # Other compression libraries; the unit test can use these for comparison
  70. # if they are available. If they are not found, just ignore.
  71. UNITTEST_LIBS=""
  72. AC_DEFUN([CHECK_EXT_COMPRESSION_LIB], [
  73. AH_CHECK_LIB([$1])
  74. AC_CHECK_LIB(
  75. [$1],
  76. [$2],
  77. [
  78. AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
  79. UNITTEST_LIBS="-l$1 $UNITTEST_LIBS"
  80. ],
  81. [true]
  82. )
  83. ])
  84. CHECK_EXT_COMPRESSION_LIB([z], [zlibVersion])
  85. CHECK_EXT_COMPRESSION_LIB([lzo2], [lzo1x_1_15_compress])
  86. CHECK_EXT_COMPRESSION_LIB([lzf], [lzf_compress])
  87. CHECK_EXT_COMPRESSION_LIB([fastlz], [fastlz_compress])
  88. CHECK_EXT_COMPRESSION_LIB([quicklz], [qlz_compress])
  89. AC_SUBST([UNITTEST_LIBS])
  90. # These are used by snappy-stubs-public.h.in.
  91. if test "$ac_cv_header_stdint_h" = "yes"; then
  92. AC_SUBST([ac_cv_have_stdint_h], [1])
  93. else
  94. AC_SUBST([ac_cv_have_stdint_h], [0])
  95. fi
  96. if test "$ac_cv_header_stddef_h" = "yes"; then
  97. AC_SUBST([ac_cv_have_stddef_h], [1])
  98. else
  99. AC_SUBST([ac_cv_have_stddef_h], [0])
  100. fi
  101. if test "$ac_cv_header_sys_uio_h" = "yes"; then
  102. AC_SUBST([ac_cv_have_sys_uio_h], [1])
  103. else
  104. AC_SUBST([ac_cv_have_sys_uio_h], [0])
  105. fi
  106. # Export the version to snappy-stubs-public.h.
  107. SNAPPY_MAJOR="snappy_major"
  108. SNAPPY_MINOR="snappy_minor"
  109. SNAPPY_PATCHLEVEL="snappy_patchlevel"
  110. AC_SUBST([SNAPPY_MAJOR])
  111. AC_SUBST([SNAPPY_MINOR])
  112. AC_SUBST([SNAPPY_PATCHLEVEL])
  113. AC_SUBST([SNAPPY_LTVERSION], snappy_ltversion)
  114. AC_CONFIG_HEADERS([config.h])
  115. AC_CONFIG_FILES([Makefile snappy-stubs-public.h])
  116. AC_OUTPUT