-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathjson.m4
93 lines (85 loc) · 2.91 KB
/
json.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
AC_DEFUN([AX_CHECK_JSONLIB],
#
# Handle user hints
#
[AC_MSG_CHECKING(if json-c is enabled)
AC_ARG_WITH(json,
[ --with-json=DIR root directory path of jsonlib installation]
[ --without-json disable json (no session functionality)],
[if test "$withval" != no ; then
jsonlib_places="/usr/local /usr /opt/local /sw"
AC_MSG_RESULT(yes)
if test -d "$withval"
then
jsonlib_places="$withval $jsonlib_places"
else
AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
fi
else
AC_MSG_RESULT(no)
ADDON="";
fi],
[AC_MSG_RESULT(yes)])
#JS_CFLAGS="-ljson"
JS_LIBS="-ljson"
JS_LIBS2="-ljson-c"
LIBS=""
#
# Locate jsonlib, if wanted
#
if test -n "${jsonlib_places}"
then
# check the user supplied or any other more or less 'standard' place:
# Most UNIX systems : /usr/local and /usr
# MacPorts / Fink on OSX : /opt/local respectively /sw
for JSONLIB_HOME in ${jsonlib_places} ; do
if test -f "/usr/include/json/json.h"; then break; fi
JSONLIB_HOME=""
done
fi
JSONLIB_OLD_LDFLAGS=$LDFLAGS
JSONLIB_OLD_CPPFLAGS=$CPPFLAGS
LDFLAGS="$LDFLAGS"
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_LIB(json, json_tokener_parse, [jsonlib_cv_libjson=yes], [jsonlib_cv_libjson=no])
AC_CHECK_HEADER(json/json.h, [jsonlib_cv_jsonlib_h=yes], [jsonlib_cv_jsonlib_h=no])
AC_LANG_RESTORE
if test "$jsonlib_cv_libjson" = "yes" -a "$jsonlib_cv_jsonlib_h" = "yes" -a "$withval" != "no"
then
#
# If both library and header were found, use them
#
JS_CFLAGS="-DHAVE_JSON_JSON_H"
#AC_CHECK_LIB(json, json_tokener_parse)
AC_MSG_CHECKING(jsonlib in ${JSONLIB_HOME})
AC_MSG_RESULT(ok)
AC_SUBST([JS_CFLAGS])
AC_SUBST([JS_LIBS])
fi
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_LIB(json-c, json_tokener_parse, [jsonlib_cv_libjson=yes], [jsonlib_cv_libjson=no])
AC_CHECK_HEADER(json/json.h, [jsonlib_cv_jsonlib_h=yes], [jsonlib_cv_jsonlib_h=no])
AC_LANG_RESTORE
if test "$jsonlib_cv_libjson" = "yes" -a "$jsonlib_cv_jsonlib_h" = "yes" -a "$withval" != "no"
then
#
# If both library and header were found, use them
#
JS_CFLAGS="-DHAVE_JSON_JSON_H"
#AC_CHECK_LIB(json, json_tokener_parse)
AC_MSG_CHECKING(jsonlib in ${JSONLIB_HOME})
AC_MSG_RESULT(ok)
AC_SUBST([JS_CFLAGS])
JS_LIBS="-ljson-c"
AC_SUBST([JS_LIBS])
else
#
# If either header or library was not found, revert and bomb
#
JS_LIBS=""
AC_MSG_CHECKING(jsonlib in ${JSONLIB_HOME})
AC_MSG_RESULT(failed)
fi
])