From 7161e9ae2e55d2624ec60d33a467af6d9960d6bb Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 11 Apr 2020 09:33:20 -0400 Subject: [PATCH] Make --with-json imply than jansson support is mandatory (Bug#39953) Currently, it is easy to miss that jansson support was not included, since configure succeeds if the jansson development files (headers, etc) are missing. Failing when jansson is missing by default would be a bit extreme, so this is a compromise; we only fail if --with-json was explicitly passed. * configure.ac (OPTION_DEFAULT_IFAVAILABLE): New macro. Use it to define the --with-json option. Add with_json and HAVE_JSON to the 'MISSING' checks. --- configure.ac | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 73243001ba..f4b01e833b 100644 --- a/configure.ac +++ b/configure.ac @@ -219,6 +219,21 @@ AC_DEFUN m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl ])dnl +dnl OPTION_DEFAULT_IFAVAILABLE(NAME, HELP-STRING) +dnl Create a new --with option that defaults to 'ifavailable'. +dnl NAME is the base name of the option. The shell variable with_NAME +dnl will be set to either the user's value (if the option is +dnl specified; 'yes' for a plain --with-NAME) or to 'ifavailable' (if the +dnl option is not specified). Note that the shell variable name is +dnl constructed as autoconf does, by replacing non-alphanumeric +dnl characters with "_". +dnl HELP-STRING is the help text for the option. +AC_DEFUN([OPTION_DEFAULT_IFAVAILABLE], [dnl + AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl + m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=ifavailable])dnl +])dnl + + dnl OPTION_DEFAULT_ON(NAME, HELP-STRING) dnl Create a new --with option that defaults to $with_features. dnl NAME is the base name of the option. The shell variable with_NAME @@ -433,7 +448,7 @@ AC_DEFUN OPTION_DEFAULT_OFF([cairo],[compile with Cairo drawing]) OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support]) OPTION_DEFAULT_OFF([imagemagick],[compile with ImageMagick image support]) -OPTION_DEFAULT_ON([json], [don't compile with native JSON support]) +OPTION_DEFAULT_IFAVAILABLE([json], [don't compile with native JSON support]) OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts]) OPTION_DEFAULT_ON([harfbuzz],[don't use HarfBuzz for text shaping]) @@ -2950,7 +2965,7 @@ AC_DEFUN HAVE_JSON=no JSON_OBJ= -if test "${with_json}" = yes; then +if test "${with_json}" != no; then EMACS_CHECK_MODULES([JSON], [jansson >= 2.7], [HAVE_JSON=yes], [HAVE_JSON=no]) if test "${HAVE_JSON}" = yes; then @@ -3893,6 +3908,11 @@ AC_DEFUN *) MISSING="$MISSING gnutls" WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gnutls=ifavailable";; esac +case $with_json,$HAVE_JSON in + no,* | ifavailable,* | *,yes) ;; + *) MISSING="$MISSING json" + WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-json=ifavailable";; +esac if test "X${MISSING}" != X; then AC_MSG_ERROR([The following required libraries were not found: $MISSING -- 2.11.0