You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

configure.ac 4.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. AC_PREREQ(2.64)
  2. # Process this file with autoconf to produce a configure script.
  3. AC_INIT([json-c], 0.12.99, [json-c@googlegroups.com])
  4. AM_INIT_AUTOMAKE
  5. AC_PROG_MAKE_SET
  6. AC_CANONICAL_HOST
  7. AC_ARG_ENABLE(rdrand,
  8. AS_HELP_STRING([--enable-rdrand],
  9. [Enable RDRAND Hardware RNG Hash Seed generation on supported x86/x64 platforms.]),
  10. [if test x$enableval = xyes; then
  11. enable_rdrand=yes
  12. AC_DEFINE(ENABLE_RDRAND, 1, [Enable RDRANR Hardware RNG Hash Seed])
  13. fi])
  14. if test "x$enable_rdrand" = "xyes"; then
  15. AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed enabled on supported x86/x64 platforms])
  16. else
  17. AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed disabled. Use --enable-rdrand to enable])
  18. fi
  19. # enable silent build by default
  20. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  21. # Checks for programs.
  22. # Checks for libraries.
  23. # Checks for header files.
  24. AM_PROG_CC_C_O
  25. AC_PROG_CC_C99
  26. AC_CONFIG_HEADER(config.h)
  27. AC_CONFIG_HEADER(json_config.h)
  28. AC_HEADER_STDC
  29. AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/cdefs.h] [sys/param.h] stdarg.h locale.h xlocale.h endian.h)
  30. AC_CHECK_HEADER(inttypes.h,[AC_DEFINE([JSON_C_HAVE_INTTYPES_H],[1],[Public define for json_inttypes.h])])
  31. # Checks for typedefs, structures, and compiler characteristics.
  32. AC_C_CONST
  33. AC_TYPE_SIZE_T
  34. AC_CACHE_CHECK([for __thread support], ac_cv___thread, [dnl
  35. AC_LINK_IFELSE([dnl
  36. AC_LANG_PROGRAM([[#undef __thread
  37. static __thread int a; int foo (int b) { return a + b; }]],
  38. [[exit (foo (0));]])],
  39. ac_cv___thread=yes, ac_cv___thread=no)
  40. ])
  41. AS_IF([test "x$ac_cv___thread" != xno],
  42. [AC_DEFINE(HAVE___THREAD, 1, [Have __thread])
  43. AC_DEFINE(SPEC___THREAD, [__thread], [Specifier for __thread])]
  44. )
  45. # Checks for library functions.
  46. AC_FUNC_VPRINTF
  47. AC_FUNC_MEMCMP
  48. AC_CHECK_FUNCS([realloc])
  49. AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale)
  50. AC_CHECK_DECLS([INFINITY], [], [], [[#include <math.h>]])
  51. AC_CHECK_DECLS([nan], [], [], [[#include <math.h>]])
  52. AC_CHECK_DECLS([isnan], [], [], [[#include <math.h>]])
  53. AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]])
  54. AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]])
  55. AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]])
  56. case "${host_os}" in
  57. linux*)
  58. AC_CHECK_FUNCS([uselocale])
  59. ;;
  60. *) # Nothing
  61. ;;
  62. esac
  63. if test "$ac_cv_have_decl_isnan" = "yes" ; then
  64. AC_TRY_LINK([#include <math.h>], [float f = 0.0; return isnan(f)], [], [LIBS="$LIBS -lm"])
  65. fi
  66. #check if .section.gnu.warning accepts long strings (for __warn_references)
  67. AC_LANG_PUSH([C])
  68. AC_MSG_CHECKING([if .gnu.warning accepts long strings])
  69. AC_LINK_IFELSE([AC_LANG_SOURCE([[
  70. extern void json_object_get();
  71. __asm__(".section .gnu.json_object_get,\n\t.ascii \"Please link against libjson-c instead of libjson\"\n\t.text");
  72. int main(int c,char* v) {return 0;}
  73. ]])], [
  74. AC_DEFINE(HAS_GNU_WARNING_LONG, 1, [Define if .gnu.warning accepts long strings.])
  75. AC_MSG_RESULT(yes)
  76. ], [
  77. AC_MSG_RESULT(no)
  78. ])
  79. AC_LANG_POP([C])
  80. LT_INIT
  81. # Check for the -Bsymbolic-functions linker flag
  82. AC_ARG_ENABLE([Bsymbolic],
  83. [AS_HELP_STRING([--disable-Bsymbolic], [Avoid linking with -Bsymbolic-function])],
  84. [],
  85. [enable_Bsymbolic=check])
  86. AS_IF([test "x$enable_Bsymbolic" = "xcheck"],
  87. [
  88. saved_LDFLAGS="${LDFLAGS}"
  89. AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
  90. LDFLAGS=-Wl,-Bsymbolic-functions
  91. AC_TRY_LINK([], [int main (void) { return 0; }],
  92. [
  93. AC_MSG_RESULT([yes])
  94. enable_Bsymbolic=yes
  95. ],
  96. [
  97. AC_MSG_RESULT([no])
  98. enable_Bsymbolic=no
  99. ])
  100. LDFLAGS="${saved_LDFLAGS}"
  101. ])
  102. AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions])
  103. AC_SUBST(JSON_BSYMBOLIC_LDFLAGS)
  104. AX_APPEND_COMPILE_FLAGS([-Wall -Werror -Wcast-qual -Wno-error=deprecated-declarations])
  105. AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-string -Wno-unused-parameter])
  106. AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE -D_REENTRANT])
  107. AX_COMPILE_CHECK_SIZEOF(int)
  108. AX_COMPILE_CHECK_SIZEOF(long)
  109. AX_COMPILE_CHECK_SIZEOF(long long)
  110. AX_COMPILE_CHECK_SIZEOF(size_t, [#include <stdint.h>])
  111. AC_CONFIG_FILES([
  112. Makefile
  113. json-c.pc
  114. tests/Makefile
  115. json-c-uninstalled.pc
  116. ])
  117. AC_OUTPUT