[build] Reimplement yajl m4 macro using only M4sh.

This commit is contained in:
Suresh Sundriyal 2015-03-19 03:49:45 -07:00
parent 12e0befe30
commit 8031a83290
1 changed files with 60 additions and 65 deletions

View File

@ -1,69 +1,64 @@
AC_DEFUN([LNAV_WITH_LOCAL_YAJL],
[
ENABLE_LOCAL_YAJL="no"
AC_ARG_WITH([yajl],
AC_HELP_STRING(
[--with-yajl=DIR],
[use a local installed version of yajl]
),
[
if test "$withval" != "no"; then
ENABLE_LOCAL_YAJL="yes"
modify_env_variables="no"
case "$withval" in
yes)
AC_MSG_NOTICE([Checking for yajl libs])
;;
*)
yajl_include="$withval/include"
yajl_ldflags="$withval/lib"
modify_env_variables="yes"
AC_ARG_WITH([yajl],
AC_HELP_STRING(
[--with-yajl=DIR],
[use a local installed version of yajl]
),
[
AS_IF([test "$withval" != "no"],
[
AS_CASE(["$withval"],
[yes],
[AC_MSG_NOTICE([Checking for yajl libs])],
[
AS_VAR_SET([yajl_saved_ldflags], ["$LDFLAGS"])
AS_VAR_SET([yajl_saved_cppflags], ["$CPPFLAGS"])
AS_VAR_SET([yajl_saved_libtool_link_flags],
["$LIBTOOL_LIBK_FLAGS"]
)
LNAV_ADDTO(CPPFLAGS, ["-I$withval/include"])
LNAV_ADDTO(LDFLAGS, ["-I$withval/lib"])
LNAV_ADDTO(LIBTOOL_LINK_FLAGS, ["-R$withval/lib"])
AC_MSG_NOTICE([Checking for yajl libs in $withval])
;;
esac
fi
]
)
AC_SEARCH_LIBS([yajl_gen_alloc],
[yajl],
[
AC_MSG_NOTICE([Checking for yajl headers])
AC_CHECK_HEADERS([yajl/yajl_parse.h],
[
AS_VAR_SET([HAVE_LOCAL_YAJL], [1])
LNAV_ADDTO(LIBS, [-lyajl])
],
[AC_MSG_WARN([yajl not found on the local system])]
)
]
)
]
)
]
)
AS_VAR_SET_IF([HAVE_LOCAL_YAJL],
[],
[
AC_MSG_NOTICE([compiling with the included version of yajl])
AS_VAR_SET([HAVE_LOCAL_YAJL], [0])
AS_VAR_SET_IF([yajl_saved_ldflags],
[
AS_VAR_SET([CPPFLAGS], ["$yajl_saved_cppflags"])
AS_VAR_SET([LDFLAGS], ["$yajl_saved_ldflags"])
AS_VAR_SET([LIBTOOL_LIBK_FLAGS], ["$yajl_saved_libtool_link_flags"])
]
)
]
)
AC_SUBST(HAVE_LOCAL_YAJL)
]
)
HAVE_LOCAL_YAJL=0
YAJL_HAVE_LOCAL_HEADERS=0
YAJL_HAVE_LOCAL_LIBS=0
if test "$ENABLE_LOCAL_YAJL" != "no"; then
saved_ldflags=$LDFLAGS
saved_cppflags=$CPPFLAGS
saved_libtool_link_flags=$LIBTOOL_LIBK_FLAGS
if test "$modify_env_variables" != "no"; then
LNAV_ADDTO(CPPFLAGS, [-I${yajl_include}])
LNAV_ADDTO(LDFLAGS, [-L${yajl_ldflags}])
LNAV_ADDTO(LIBTOOL_LINK_FLAGS, [-R${yajl_ldflags}])
fi
AC_SEARCH_LIBS([yajl_gen_alloc], [yajl], [YAJL_HAVE_LOCAL_LIBS=1])
if test "$YAJL_HAVE_LOCAL_LIBS" != "0"; then
AC_MSG_NOTICE([Checking for yajl headers])
AC_CHECK_HEADERS([yajl/yajl_parse.h], [YAJL_HAVE_LOCAL_HEADERS=1])
if test "$YAJL_HAVE_LOCAL_HEADERS" != "0"; then
HAVE_LOCAL_YAJL=1
LNAV_ADDTO(LIBS, [-lyajl])
else
AC_MSG_WARN([yajl not found on the local system])
fi
if test "$HAVE_LOCAL_YAJL" = "0"; then
CPPFLAGS=$saved_cppflags
LDFLAGS=$saved_ldflags
LIBTOOL_LIBK_FLAGS=$saved_libtool_link_flags
fi
fi
fi
if test "$HAVE_LOCAL_YAJL" = "0"; then
AC_MSG_NOTICE([compiling with the included version of yajl])
fi
AC_SUBST(HAVE_LOCAL_YAJL)
])dnl
)dnl