unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Stéphane Maniaci" <stephane.maniaci@gmail.com>, 39953@debbugs.gnu.org
Subject: bug#39953: 27.0.50; [PATCH] explicitly fail if Emacs was configured with but cannot compile native JSON support
Date: Sat, 11 Apr 2020 09:47:34 -0400	[thread overview]
Message-ID: <87blny3zih.fsf@gmail.com> (raw)
In-Reply-To: <87v9nd6jo4.fsf@gmail.com> (Noam Postavsky's message of "Mon, 09 Mar 2020 22:14:03 -0400")

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

Noam Postavsky <npostavs@gmail.com> writes:

>>> This patch explicitly fails ./configure if `--with-json' is passed but
>>> cannot be fulfilled. Which means users without the Jansson headers
>>> won't be able to compile Emacs unless explicitly disabling it with
>>> `--without-json'; I don't know if that is too extreme,
>
> This seems a bit too extreme to me, but I think giving an error on
> missing Jansson headers only if --with-json is explicitly passed would
> be okay.

I was reminded about this from some reddit posts:

https://old.reddit.com/r/emacs/comments/fwgpkd/weekly_tipstricketc_thread/fmo9d5v/

Here's a proposed patch implementing my suggestion above.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 3112 bytes --]

From 7161e9ae2e55d2624ec60d33a467af6d9960d6bb Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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


  reply	other threads:[~2020-04-11 13:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06 12:13 bug#39953: 27.0.50; [PATCH] explicitly fail if Emacs was configured with but cannot compile native JSON support Stéphane Maniaci
2020-03-06 15:49 ` Eli Zaretskii
2020-03-10  2:14   ` Noam Postavsky
2020-04-11 13:47     ` Noam Postavsky [this message]
2020-04-25 14:07       ` Stefan Kangas
2020-08-08 13:54       ` Lars Ingebrigtsen
2020-08-14 17:31         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87blny3zih.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=39953@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stephane.maniaci@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).