Subject: bug#66125: 29.1; configure --with-small-ja-dic has no effect

From: Eli Zaretskii <[email-masked]>
Date: Sat, 23 Sep 2023 10:55:18 +0300

> Cc: [email-masked]
> Date: Wed, 20 Sep 2023 20:02:19 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > From: Ulrich Mueller <[email-masked]>
> > Cc: [email-masked]
> > Date: Wed, 20 Sep 2023 18:58:29 +0200
> > 
> > >>>>> On Wed, 20 Sep 2023, Eli Zaretskii wrote:
> > 
> > > Please tell more details:
> > 
> > >   . how did you build Emacs with this option? please show all the
> > >     steps, starting from unpacking the tarball
> > 
> > $ tar xf /var/cache/distfiles/emacs-29.1.tar.xz
> > $ cd emacs-29.1
> > $ ./configure --with-small-ja-dic
> > [...]
> >   Does Emacs generate a smaller-size Japanese dictionary? yes
> > [...]
> > $ make
> > [...]
> > $ ls -l lisp/leim/ja-dic/
> > total 9120
> > -rw-r--r-- 1 ulm users 4798823 Jul 23 10:11 ja-dic.el
> > -rw-r--r-- 1 ulm users 4535697 Jul 23 10:11 ja-dic.elc
> > 
> > >   . how is SMALL_JA_DIC defined in leim/Makefile when you configure
> > >     with this option?
> > 
> > $ grep ^SMALL_JA_DIC leim/Makefile
> > SMALL_JA_DIC = yes
> > 
> > >   . when (on what date) did you try building Emacs with that option?
> > 
> > 2023-09-20, i.e. today.
> 
> OK, thanks.  In its current form, this option will only make a
> difference if you remove the ja-dic files that came with the tarball,
> and then rebuild.  We should improve this, although it strikes me that
> such an obscure feature, which is also not recommended, perhaps
> doesn't deserve the effort...

Please try the patch below.  If it gives good results, I will install
it on the emacs-29 branch.

Thanks.

diff --git a/leim/Makefile.in b/leim/Makefile.in
index 4c6c317..03da0f7 100644
--- a/leim/Makefile.in
+++ b/leim/Makefile.in
@@ -26,6 +26,7 @@ SHELL =
 # Here are the things that we expect ../configure to edit.
 srcdir=@srcdir@
 top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
 
 # Where the generated files go.
 leimdir = ${srcdir}/../lisp/leim
@@ -134,9 +135,19 @@ ${leimdir}/leim-list.el:
 
 ${leimdir}/ja-dic/ja-dic.el: | $(leimdir)/ja-dic
 
+# This is used to support regeneration of ja-dic when the SMALL_JA_DIC
+# option is flipped by the configure-time option.
+small-ja-dic-option: ../config.status
+	$(AM_V_GEN)if test -f ${leimdir}/ja-dic/ja-dic.el; then \
+	  sed -n "/small ja-dic option: $(SMALL_JA_DIC)/p" \
+	    ${leimdir}/ja-dic/ja-dic.el > $@.$$$$ && \
+	  ${top_srcdir}/build-aux/move-if-change $@.$$$$ $@; \
+	else echo \
+	  ";; Generated with small ja-dic option: $(SMALL_JA_DIC)" > $@; fi
+
 .PHONY: generate-ja-dic
 generate-ja-dic: ${leimdir}/ja-dic/ja-dic.el
-${leimdir}/ja-dic/ja-dic.el: $(srcdir)/SKK-DIC/SKK-JISYO.L
+${leimdir}/ja-dic/ja-dic.el: $(srcdir)/SKK-DIC/SKK-JISYO.L small-ja-dic-option
 	$(AM_V_GEN)$(RUN_EMACS) -batch -l ja-dic-cnv \
 	  -f batch-skkdic-convert -dir "$(leimdir)/ja-dic" $(JA_DIC_NO_REDUCTION_OPTION) "$<"
 
diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el
index 9ce31f1..46848c1 100644
--- a/lisp/international/ja-dic-cnv.el
+++ b/lisp/international/ja-dic-cnv.el
@@ -346,6 +346,11 @@ skkdic-convert
       (erase-buffer)
       (buffer-disable-undo)
       (generate-lisp-file-heading ja-dic-filename 'skkdic-convert :code nil)
+      ;; The following line is tested by leim/Makefile.in to see if
+      ;; ja-dic.el needs to be regenerated because the SMALL_JA_DIC
+      ;; option was flipped.
+      (insert (format ";; Generated with small ja-dic option: %s\n\n"
+                      (if no-reduction "no" "yes")))
       (insert ";; Original SKK dictionary file: "
 	      (file-relative-name (expand-file-name filename) dirname)
 	      "\n\n"