| 1 |
# |
| 2 |
# If this file is changed, be sure to run ASTTOPDIR/bootstrap.sh |
| 3 |
# before committing. |
| 4 |
# |
| 5 |
|
| 6 |
AC_DEFUN([_JANSSON_CONFIGURE], |
| 7 |
[ |
| 8 |
if test "${ac_mandatory_list#*JANSSON*}" != "$ac_mandatory_list" ; then |
| 9 |
AC_MSG_ERROR(--with-jansson and --with-jansson-bundled can't both be specified) |
| 10 |
fi |
| 11 |
|
| 12 |
ac_mandatory_list="$ac_mandatory_list JANSSON" |
| 13 |
JANSSON_DIR="${ac_pwd}/third-party/jansson" |
| 14 |
|
| 15 |
AC_MSG_CHECKING(for embedded jansson (may have to download)) |
| 16 |
AC_MSG_RESULT(configuring) |
| 17 |
|
| 18 |
if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then |
| 19 |
AC_MSG_ERROR(A download utility (wget, curl, or fetch) is required to download bundled jansson) |
| 20 |
fi |
| 21 |
if test "${BZIP2}" = ":" ; then |
| 22 |
AC_MSG_ERROR(bzip2 is required to extract the jansson tar file) |
| 23 |
fi |
| 24 |
if test "${TAR}" = ":" ; then |
| 25 |
AC_MSG_ERROR(tar is required to extract the jansson tar file) |
| 26 |
fi |
| 27 |
if test "${PATCH}" = ":" ; then |
| 28 |
AC_MSG_ERROR(patch is required to configure bundled jansson) |
| 29 |
fi |
| 30 |
if test "${SED}" = ":" ; then |
| 31 |
AC_MSG_ERROR(sed is required to configure bundled jansson) |
| 32 |
fi |
| 33 |
if test "${NM}" = ":" ; then |
| 34 |
AC_MSG_ERROR(nm is required to build bundled jansson) |
| 35 |
fi |
| 36 |
if test "${MD5}" = ":" ; then |
| 37 |
AC_MSG_ERROR(md5sum is required to build bundled jansson) |
| 38 |
fi |
| 39 |
if test "${CAT}" = ":" ; then |
| 40 |
AC_MSG_ERROR(cat is required to build bundled jansson) |
| 41 |
fi |
| 42 |
if test "${CUT}" = ":" ; then |
| 43 |
AC_MSG_ERROR(cut is required to build bundled jansson) |
| 44 |
fi |
| 45 |
if test "${GREP}" = ":" ; then |
| 46 |
AC_MSG_ERROR(grep is required to build bundled jansson) |
| 47 |
fi |
| 48 |
|
| 49 |
AC_ARG_VAR([JANSSON_CONFIGURE_OPTS],[Additional configure options to pass to bundled jansson]) |
| 50 |
this_host=$(./config.sub $(./config.guess)) |
| 51 |
if test "$build" != "$this_host" ; then |
| 52 |
JANSSON_CONFIGURE_OPTS+=" --build=$build_alias" |
| 53 |
fi |
| 54 |
if test "$host" != "$this_host" ; then |
| 55 |
JANSSON_CONFIGURE_OPTS+=" --host=$host_alias" |
| 56 |
fi |
| 57 |
|
| 58 |
export TAR PATCH SED NM EXTERNALS_CACHE_DIR AST_DOWNLOAD_CACHE DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT CUT GREP |
| 59 |
export NOISY_BUILD |
| 60 |
${GNU_MAKE} --quiet --no-print-directory -C ${JANSSON_DIR} \ |
| 61 |
JANSSON_CONFIGURE_OPTS="$JANSSON_CONFIGURE_OPTS" \ |
| 62 |
EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" \ |
| 63 |
configure |
| 64 |
if test $? -ne 0 ; then |
| 65 |
AC_MSG_RESULT(failed) |
| 66 |
AC_MSG_NOTICE(Unable to configure ${JANSSON_DIR}) |
| 67 |
AC_MSG_ERROR(Re-run the ./configure command with 'NOISY_BUILD=yes' appended to see error details.) |
| 68 |
fi |
| 69 |
|
| 70 |
AC_MSG_CHECKING(for bundled jansson) |
| 71 |
|
| 72 |
JANSSON_INCLUDE=-I${JANSSON_DIR}/dist/usr/include |
| 73 |
JANSSON_CFLAGS="$JANSSON_INCLUDE" |
| 74 |
JANSSON_LIB="-L${JANSSON_DIR}/dist/usr/lib -ljansson" |
| 75 |
PBX_JANSSON=1 |
| 76 |
|
| 77 |
# We haven't run install yet |
| 78 |
JANSSON_DEFINE_JSON_INT([$JANSSON_DIR]/source/src/) |
| 79 |
|
| 80 |
AC_SUBST([JANSSON_BUNDLED]) |
| 81 |
AC_SUBST([PBX_JANSSON]) |
| 82 |
AC_SUBST([JANSSON_LIB]) |
| 83 |
AC_SUBST([JANSSON_INCLUDE]) |
| 84 |
AC_MSG_RESULT(yes) |
| 85 |
AC_DEFINE([HAVE_JANSSON_BUNDLED], 1, [Define if your system has JANSSON_BUNDLED]) |
| 86 |
]) |
| 87 |
|
| 88 |
AC_DEFUN([JANSSON_CONFIGURE], |
| 89 |
[ |
| 90 |
if test "$JANSSON_BUNDLED" = "yes" ; then |
| 91 |
_JANSSON_CONFIGURE() |
| 92 |
fi |
| 93 |
]) |
| 94 |
|
| 95 |
AC_DEFUN([JANSSON_DEFINE_JSON_INT], |
| 96 |
[ |
| 97 |
# Define the ast_json_int_t (large integer type) to match jansson's |
| 98 |
saved_cppflags="${CPPFLAGS}" |
| 99 |
CPPFLAGS="${CPPFLAGS} ${JANSSON_INCLUDE}" |
| 100 |
AC_COMPILE_IFELSE( |
| 101 |
[AC_LANG_PROGRAM([#include <$1jansson.h>], |
| 102 |
[#if !JSON_INTEGER_IS_LONG_LONG |
| 103 |
#error "not long long" |
| 104 |
#endif |
| 105 |
])], |
| 106 |
[AC_DEFINE([AST_JSON_INT_T], [long long], [Define to 'long' or 'long long'])], |
| 107 |
[AC_DEFINE([AST_JSON_INT_T], [long], [Define to 'long' or 'long long'])]) |
| 108 |
CPPFLAGS="${saved_cppflags}" |
| 109 |
]) |