1AC_PREREQ(2.52)
2
3# Process this file with autoconf to produce a configure script.
4AC_INIT([json-c], 0.12.99, [json-c@googlegroups.com])
5
6AM_INIT_AUTOMAKE
7
8AC_PROG_MAKE_SET
9
10AC_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])
16fi])
17
18if test "x$enable_rdrand" = "xyes"; then
19  AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed enabled on supported x86/x64 platforms])
20else
21  AC_MSG_RESULT([RDRAND Hardware RNG Hash Seed disabled. Use --enable-rdrand to enable])
22fi
23
24# Checks for programs.
25
26# Checks for libraries.
27
28# Checks for header files.
29AM_PROG_CC_C_O
30AC_CONFIG_HEADER(config.h)
31AC_CONFIG_HEADER(json_config.h)
32AC_HEADER_STDC
33AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/cdefs.h] [sys/param.h] stdarg.h locale.h endian.h)
34AC_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.
37AC_C_CONST
38AC_TYPE_SIZE_T
39
40# Checks for library functions.
41AC_FUNC_VPRINTF
42AC_FUNC_MEMCMP
43AC_FUNC_MALLOC
44AC_FUNC_REALLOC
45AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale)
46AC_CHECK_DECLS([INFINITY], [], [], [[#include <math.h>]])
47AC_CHECK_DECLS([nan], [], [], [[#include <math.h>]])
48AC_CHECK_DECLS([isnan], [], [], [[#include <math.h>]])
49AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]])
50AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]])
51AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]])
52
53#check if .section.gnu.warning accepts long strings (for __warn_references)
54AC_LANG_PUSH([C])
55
56AC_MSG_CHECKING([if .gnu.warning accepts long strings])
57AC_LINK_IFELSE([AC_LANG_SOURCE([[
58extern 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
61int 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
69AC_LANG_POP([C])
70
71AM_PROG_LIBTOOL
72
73# Check for the -Bsymbolic-functions linker flag
74AC_ARG_ENABLE([Bsymbolic],
75              [AS_HELP_STRING([--disable-Bsymbolic], [Avoid linking with -Bsymbolic-function])],
76              [],
77              [enable_Bsymbolic=check])
78
79AS_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
96AS_IF([test "x$enable_Bsymbolic" = "xyes"], [JSON_BSYMBOLIC_LDFLAGS=-Wl[,]-Bsymbolic-functions])
97AC_SUBST(JSON_BSYMBOLIC_LDFLAGS)
98
99AC_CONFIG_FILES([
100Makefile
101json-c.pc
102tests/Makefile
103json-c-uninstalled.pc
104])
105
106AC_OUTPUT
107
108