-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathfind_yajl.m4
153 lines (140 loc) · 4.3 KB
/
find_yajl.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
dnl Check for YAJL Libraries
dnl CHECK_YAJL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
dnl Sets:
dnl YAJL_CFLAGS
dnl YAJL_LDADD
dnl YAJL_LDFLAGS
dnl YAJL_LIBS
AC_DEFUN([CHECK_YAJL],
[dnl
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
YAJL_CONFIG=""
YAJL_VERSION=""
YAJL_CFLAGS=""
YAJL_CPPFLAGS=""
YAJL_LDADD=""
YAJL_LDFLAGS=""
YAJL_CONFIG=${PKG_CONFIG}
YAJL_PKGNAMES="yajl2 yajl"
YAJL_SONAMES="so la sl dll dylib"
AC_ARG_WITH(
yajl,
[AC_HELP_STRING([--with-yajl=PATH],[Path to yajl prefix or config script])]
,, with_yajl=yes)
AS_CASE(["${with_yajl}"],
[no], [test_paths=],
[yes], [test_paths="/usr/local/libyajl /usr/local/yajl /usr/local /opt/libyajl /opt/yajl /opt /usr"],
[test_paths="${with_yajl}"])
AS_IF([test "x${test_paths}" != "x"], [
AC_MSG_CHECKING([for libyajl config script])
for x in ${test_paths}; do
dnl # Determine if the script was specified and use it directly
if test ! -d "$x" -a -e "$x"; then
YAJL_CONFIG=$x
break
fi
dnl # Try known config script names/locations
for y in $YAJL_CONFIG; do
if test -e "${x}/bin/${y}"; then
YAJL_CONFIG="${x}/bin/${y}"
yajl_config="${YAJL_CONFIG}"
break
elif test -e "${x}/${y}"; then
YAJL_CONFIG="${x}/${y}"
yajl_config="${YAJL_CONFIG}"
break
fi
done
if test -n "${yajl_config}"; then
break
fi
done
dnl # Try known package names
if test -n "${YAJL_CONFIG}"; then
YAJL_PKGNAME=""
for x in ${YAJL_PKGNAMES}; do
if ${YAJL_CONFIG} --exists ${x}; then
YAJL_PKGNAME="$x"
break
fi
done
fi
if test -n "${YAJL_PKGNAME}"; then
AC_MSG_RESULT([${YAJL_CONFIG}])
YAJL_VERSION="`${YAJL_CONFIG} ${YAJL_PKGNAME} --modversion`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl VERSION: $YAJL_VERSION); fi
YAJL_CFLAGS="`${YAJL_CONFIG} ${YAJL_PKGNAME} --cflags`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl CFLAGS: $YAJL_CFLAGS); fi
YAJL_LDADD="`${YAJL_CONFIG} ${YAJL_PKGNAME} --libs-only-l`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl LDADD: $YAJL_LDADD); fi
YAJL_LDFLAGS="`${YAJL_CONFIG} ${YAJL_PKGNAME} --libs-only-L --libs-only-other`"
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl LDFLAGS: $YAJL_LDFLAGS); fi
else
AC_MSG_RESULT([no])
dnl Hack to just try to find the lib and include
AC_MSG_CHECKING([for yajl install])
for x in ${test_paths}; do
for y in ${YAJL_SONAMES}; do
if test -e "${x}/libyajl.${y}"; then
yajl_lib_path="${x}/"
yajl_lib_name="yajl"
break
else
yajl_lib_path=""
yajl_lib_name=""
fi
done
if test -n "$yajl_lib_path"; then
break
fi
done
for x in ${test_paths}; do
if test -e "${x}/include/yajl_parse.h"; then
yajl_inc_path="${x}/include"
break
elif test -e "${x}/yajl_parse.h"; then
yajl_inc_path="${x}"
break
fi
dnl # Check some sub-paths as well
for yajl_pkg_name in ${yajl_lib_name} ${YAJL_PKGNAMES}; do
if test -e "${x}/include/${yajl_pkg_name}/yajl_parse.h"; then
yajl_inc_path="${x}/include"
break
elif test -e "${x}/${yajl_pkg_name}/yajl_parse.h"; then
yajl_inc_path="${x}"
break
else
yajl_inc_path=""
fi
done
if test -n "$yajl_inc_path"; then
break
fi
done
if test -n "${yajl_lib_path}" -a -n "${yajl_inc_path}"; then
YAJL_CONFIG=""
AC_MSG_RESULT([${yajl_lib_path} ${yajl_inc_path}])
YAJL_VERSION="2"
YAJL_CFLAGS="-I${yajl_inc_path}"
YAJL_LDADD="-l${yajl_lib_name}"
YAJL_LDFLAGS="-L${yajl_lib_path}"
else
YAJL_VERSION=""
AC_MSG_RESULT([no])
fi
fi
])
YAJL_LIBS=${YAJL_LDADD}
AC_SUBST(YAJL_CFLAGS)
AC_SUBST(YAJL_LDADD)
AC_SUBST(YAJL_LIBS)
AC_SUBST(YAJL_LDFLAGS)
if test -z "${YAJL_VERSION}"; then
ifelse([$2], , AC_MSG_NOTICE([optional yajl library not found]), $2)
else
AC_MSG_NOTICE([using yajl v${YAJL_VERSION}])
YAJL_CFLAGS="-DWITH_YAJL ${YAJL_CFLAGS}"
ifelse([$1], , , $1)
fi
])