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