Imported Upstream version 0.12.1
[platform/upstream/json-c.git] / configure.ac
1 AC_PREREQ(2.52)
2
3 # Process this file with autoconf to produce a configure script.
4 AC_INIT([json-c], 0.12.1, [json-c@googlegroups.com])
5
6 AM_INIT_AUTOMAKE
7
8 AC_PROG_MAKE_SET
9
10 AC_ARG_ENABLE(rdrand,
11  AS_HELP_STRING([--enable-rdrand],
12    [Enable RDRAND Hardware RNG Hash Seed generation on supported x86/x64 platforms.]),
13 [if test x$enableval = xyes; then
14   enable_rdrand=yes
15   AC_DEFINE(ENABLE_RDRAND, 1, [Enable RDRANR Hardware RNG Hash Seed])
16 fi])
17
18 if test "x$enable_rdrand" = "xyes"; then
19   AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed enabled on supported x86/x64 platforms])
20 else
21   AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed disabled. Use --enable-rdrand to enable])
22 fi
23
24 # Checks for programs.
25
26 # Checks for libraries.
27
28 # Checks for header files.
29 AM_PROG_CC_C_O
30 AC_CONFIG_HEADER(config.h)
31 AC_CONFIG_HEADER(json_config.h)
32 AC_HEADER_STDC
33 AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/cdefs.h] [sys/param.h] stdarg.h locale.h endian.h)
34 AC_CHECK_HEADER(inttypes.h,[AC_DEFINE([JSON_C_HAVE_INTTYPES_H],[1],[Public define for json_inttypes.h])])
35
36 # Checks for typedefs, structures, and compiler characteristics.
37 AC_C_CONST
38 AC_TYPE_SIZE_T
39
40 # Checks for library functions.
41 AC_FUNC_VPRINTF
42 AC_FUNC_MEMCMP
43 AC_FUNC_MALLOC
44 AC_FUNC_REALLOC
45 AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale)
46 AC_CHECK_DECLS([INFINITY], [], [], [[#include <math.h>]])
47 AC_CHECK_DECLS([nan], [], [], [[#include <math.h>]])
48 AC_CHECK_DECLS([isnan], [], [], [[#include <math.h>]])
49 AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]])
50 AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]])
51 AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]])
52
53 #check if .section.gnu.warning accepts long strings (for __warn_references)
54 AC_LANG_PUSH([C])
55
56 AC_MSG_CHECKING([if .gnu.warning accepts long strings])
57 AC_LINK_IFELSE([AC_LANG_SOURCE([[
58 extern void json_object_get();
59 __asm__(".section .gnu.json_object_get,\n\t.ascii \"Please link against libjson-c instead of libjson\"\n\t.text");
60
61 int main(int c,char* v) {return 0;}
62 ]])], [
63     AC_DEFINE(HAS_GNU_WARNING_LONG, 1, [Define if .gnu.warning accepts long strings.])
64     AC_MSG_RESULT(yes)
65 ], [
66    AC_MSG_RESULT(no)
67 ])
68
69 AC_LANG_POP([C])
70
71 AM_PROG_LIBTOOL
72
73 # Check for the -Bsymbolic-functions linker flag
74 AC_ARG_ENABLE([Bsymbolic],
75               [AS_HELP_STRING([--disable-Bsymbolic], [Avoid linking with -Bsymbolic-function])],
76               [],
77               [enable_Bsymbolic=check])
78
79 AS_IF([test "x$enable_Bsymbolic" = "xcheck"],
80       [
81         saved_LDFLAGS="${LDFLAGS}"
82         AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
83         LDFLAGS=-Wl,-Bsymbolic-functions
84         AC_TRY_LINK([], [int main (void) { return 0; }],
85                     [
86                       AC_MSG_RESULT([yes])
87                       enable_Bsymbolic=yes
88                     ],
89                     [
90                       AC_MSG_RESULT([no])
91                       enable_Bsymbolic=no
92                     ])
93         LDFLAGS="${saved_LDFLAGS}"
94       ])
95
96 AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions])
97 AC_SUBST(JSON_BSYMBOLIC_LDFLAGS)
98
99 AC_CONFIG_FILES([
100 Makefile
101 json-c.pc
102 tests/Makefile
103 json-c-uninstalled.pc
104 ])
105
106 AC_OUTPUT
107