-
Notifications
You must be signed in to change notification settings - Fork 65
/
configure.in
77 lines (65 loc) · 2.62 KB
/
configure.in
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
AC_INIT(src/rlibjson.c)
AC_ARG_WITH(local-libjson, [use the libjson code that comes with this package rather than
looking for an installed version on the system],
USE_LOCAL=$withval)
AC_ARG_WITH(prefix, [the name of the directory into which the libjson include files and library were installed],
[ LIBJSON_PREFIX=$withval; if test -z "$USE_LOCAL" ; then USE_LOCAL="never" ; fi],
[ LIBJSON_PREFIX="/usr/local" ;
])
ORIG_USE_LOCAL="$USE_LOCAL"
if test -z "$USE_LOCAL" || test "$USE_LOCAL" = "no" ; then
echo "Trying to find libjson.h header file"
CPPFLAGS="$CPPFLAGS -I$LIBJSON_PREFIX/include"
AC_TRY_COMPILE(
[#include <libjson/libjson.h>],
[JSONNODE *ptr = json_parse("[1, 3]");],
[USE_LOCAL=1; echo "Found system libjson header file libjson.h"], []
)
if test -n "$USE_LOCAL" && ! test "$USE_LOCAL" = "no"; then
echo "Trying to link against libjson"
LIBS="$LIBS -L$LIBJSON_PREFIX/lib -ljson"
AC_TRY_LINK(
[#include <libjson/libjson.h>],
[JSONNODE *ptr = json_parse("[1, 3]");],
[USE_LOCAL=1; echo "linked against libjson"],
[USE_LOCAL=""; echo "Failed to link against system libjson"]
)
fi
fi
echo "USE_LOCAL = \"$USE_LOCAL\""
if test -n "$USE_LOCAL" && ! test "$USE_LOCAL" = "" && ! test "$USE_LOCAL" = "yes" && test -n "$LIBJSON_PREFIX" ; then
LIBJSON_CFLAGS="-I${LIBJSON_PREFIX}/include -I." # -I${LIBJSON_PREFIX}/Source
LIBJSON_LIBS="-L${LIBJSON_PREFIX}/lib -ljson"
CPP_FILES=""
else
if test "$ORIG_USE_LOCAL" = "never" ; then
echo " ****************"
echo "Couldn't find libjson on system so would use the local version of libjson in this package but you asked not to"
echo " ****************"
exit 1;
fi
if test -z "${LIBJSON_SRC}" ; then
LIBJSON_SRC="src/libjson/Source"
LIBJSON_CFLAGS="-I. -Ilibjson -Ilibjson/Source"
else
LIBJSON_CFLAGS="-I${LIBJSON_SRC}/.. -I${LIBJSON_SRC}"
fi
MINOR_VERSION=`grep 'define __LIBJSON_MINOR__' $LIBJSON_SRC/JSONDefs.h | sed -e 's/.* __LIBJSON_MINOR__ //'`
if test "$MINOR_VERSION" = "0" ; then
LIBJSON_CFLAGS="${LIBJSON_CFLAGS} -DJSON_NO_EXCEPTIONS=1"
else
LIBJSON_CFLAGS="${LIBJSON_CFLAGS} -DNEW_JSON_NEW_STREAM"
fi
echo "Minor Version: $MINOR_VERSION"
echo "Using local libjson code. Copying files from ${LIBJSON_SRC}"
echo "`pwd`"
CPP_FILES="`(cd ${LIBJSON_SRC}; ls *.cpp)`"
echo "$CPP_FILES"
cp ${LIBJSON_SRC}/*.cpp src/
cp src/libjson/JSONOptions.h src/
fi
AC_SUBST(CPP_FILES)
AC_SUBST(LIBJSON_CFLAGS)
AC_SUBST(LIBJSON_LIBS)
AC_OUTPUT(src/Makevars cleanup)
chmod +x cleanup