Remove Emacs build need for tex/texindex being installed

* doc/translations/README: Add a `Adding new languages' section

* m4/texinfo.m4 (gl_GET_TEXINFO_TEX_VER, gl_GET_TEXINDEX_VER):
  Detect whether tex or texindex are installed and working under
  pipefail regime and set new variable `tex_available' accordingly.
  (gl_SET_DOCLANGS): Do not fallback to default language when
  tex/texindex are not working or not installed.
This commit is contained in:
Vincent Belaïche 2026-07-17 13:56:34 +02:00
parent 541f693ca2
commit a378b96aaa
3 changed files with 99 additions and 22 deletions

View file

@ -1151,15 +1151,26 @@ $(1)-DOCLANG-$(2): $(1)-common
$$(MAKE) -C doc/$$(subst -, DOCLANG=$(2) ,$(1)) $$(MAKE) -C doc/$$(subst -, DOCLANG=$(2) ,$(1))
endef endef
## Languages to build the manuals in doc/$(1) for: the default
## language, plus every other language in DOCLANGS that has
## translations for this directory (doc/translations/<lang>/$(1)).
## Directories without translations for a language must not run a
## sub-make for it: the doc Makefiles of untranslated directories
## ignore DOCLANG, so such a sub-make would just repeat the
## default-language build, and two sub-makes producing the same
## outputs race under "make -j" (e.g. "cp: cannot create regular
## file ...: File exists").
doc_langs = default $(foreach lang,$(filter-out default,$(DOCLANGS)),$(if $(wildcard ${srcdir}/doc/translations/$(lang)/$(1)),$(lang)))
# $(1) = doc target (e.g. lispintro-info), $(2) = languages to build
define MAKE_DOC define MAKE_DOC
# Define a target to which dependencies common to all of the doc files # Define a target to which dependencies common to all of the doc files
# in this directory may be assigned. # in this directory may be assigned.
$(1)-common: $(1)-common:
$(1): $$(addprefix $(1)-DOCLANG-,$(DOCLANGS)) $(1): $$(addprefix $(1)-DOCLANG-,$(2))
$$(foreach lang,$(DOCLANGS),$$(eval $$(call MAKE_DOC_FOR_DOCLANG,$(1),$$(lang)))) $$(foreach lang,$(2),$$(eval $$(call MAKE_DOC_FOR_DOCLANG,$(1),$$(lang))))
endef endef
$(foreach doc,$(DOCS),$(eval $(call MAKE_DOC,$(doc)))) $(foreach doc,$(DOCS),$(eval $(call MAKE_DOC,$(doc),$(call doc_langs,$(word 1,$(subst -, ,$(doc)))))))
.PHONY: $(DOCS) docs pdf ps .PHONY: $(DOCS) docs pdf ps
.PHONY: info dvi dist html info-dir check-info .PHONY: info dvi dist html info-dir check-info

View file

@ -68,6 +68,17 @@ For the pdf output:
ses-fr.pdf will go into the doc/misc directory. ses-fr.pdf will go into the doc/misc directory.
** Adding new languages
For instance to add Japanese (ja):
- add 'ja' to the list into list gl_DOCLANGS_FULL in file EMACS-REPO/m4/texinfo.m4
- add a subdirectory 'ja' under directory EMACS-REPO/doc/translations/,
- create a info_common.mk file into each subdirectory
EMACS-REPO/doc/translations/ja/TRANSLATED_DIR, eg TRANSLATED_DIR is
'misc' if you translate to Japanese a manual from the misc category.
* Translating the Emacs manuals * Translating the Emacs manuals
** Copyright assignment ** Copyright assignment

View file

@ -68,26 +68,63 @@ dnl language/encoding corresponding locale is not installer nor active.
dnl See texinfo version 836b8924560. dnl See texinfo version 836b8924560.
m4_define([gl_TEXINFO_TEX_MINVER],[[20260426.12]])dnl m4_define([gl_TEXINFO_TEX_MINVER],[[20260426.12]])dnl
m4_define([gl_TEXINDEX_MINVER],[[7.1]])dnl m4_define([gl_TEXINDEX_MINVER],[[7.1]])dnl
dnl gl_TEXINFO_INDEXING_IS_LOCALE_DEPENDANT
dnl when tex tools are installed & working and that their version suggest that
dnl the PDF/PS/DVI compilation may be broken by UTF-8 encoded manual sources
dnl when the locale is not UTF-8, DOCLANGS is restricted to default language.
m4_define([gl_TEXINFO_INDEXING_IS_LOCALE_DEPENDANT],[dnl m4_define([gl_TEXINFO_INDEXING_IS_LOCALE_DEPENDANT],[dnl
[DOCLANGS='default' [DOCLANGS='default'
gl_fn_doclangs_info () {] gl_fn_doclangs_info () {]
AC_MSG_WARN([texinfo.tex/texindex versions suggest that indexing is locale dependant, manual compilation is restricted to lang 'default', override this by setting DOCLANGS in the environment]) AC_MSG_WARN([texinfo.tex/texindex versions suggest that indexing is locale dependant, manual compilation is restricted to lang 'default', override this by setting DOCLANGS in the environment])
[}]])dnl [}]])dnl
dnl gl_GET_TEXINFO_TEX_VER
dnl Test tex is installed and read the texinfo version into variable texinfo_tex_ver
m4_define([gl_GET_TEXINFO_TEX_VER],[dnl m4_define([gl_GET_TEXINFO_TEX_VER],[dnl
[texinfo_tex_ver=`tex -jobname=conftest '\nonstopmode\input texinfo.tex @typeout{TEXINFO_TEX_VER=@texinfoversion}@bye' | awk 'BEGIN{R=1;FS="="};]gl_dollar[1=="TEXINFO_TEX_VER" { gsub("-","");print ]gl_dollar[2; R=0; exit}; END{ exit R}'` [if false | true; then nopipefail=true; set -o pipefail; else nopipefail=false; fi
if test $? -ne 0; then if texinfo_tex_ver=`tex -jobname=conftest '\nonstopmode\input texinfo.tex @typeout{TEXINFO_TEX_VER=@texinfoversion}@bye' 2>/dev/null | awk 'BEGIN{R=1;FS="="};]gl_dollar[1=="TEXINFO_TEX_VER" { gsub("-","");print ]gl_dollar[2; R=0; exit}; END{ if(R) {print "notfound"}}'`; then
texinfo_tex_ver_ver=0.0 if test "$texinfo_tex_ver" == "notfound"; then
gl_fn_doclangs_info () {] texinfo_tex_ver=0.0
AC_MSG_WARN([Can't find texinfo.tex version, check tex and texinfo.tex are installed.]) gl_fn_texinfo_info () {]
[ } AC_MSG_WARN([Can't find texinfo.tex version, check tex and texinfo.tex are installed.])[
}
fi
else
texinfo_tex_ver=0.0
tex_available=false
gl_fn_texinfo_info () {]
AC_MSG_NOTICE([tex not installed or not working.])[
}
fi fi
if $nopipefail; then set +o pipefail; fi
]])dnl ]])dnl
dnl gl_GET_TEXINDEX_VER
dnl Test texindex is installed and read its vrson into variable texindex_ver
dnl Test is not carried out when tex_available is false
dnl texindex exiting in error will set tex_available to false
m4_define([gl_GET_TEXINDEX_VER],[dnl m4_define([gl_GET_TEXINDEX_VER],[dnl
[texindex_ver=`texindex --version | awk 'BEGIN { R=1};NR==1 && ]gl_dollar[1 == "texindex"{ print $NF; R=0; exit}; {exit}; END { exit R}'` [if $tex_available; then
if test $? -ne 0; then if false | true; then nopipefail=true; set -o pipefail; else nopipefail=false; fi
texindex_ver=0.0] if texindex_ver=`texindex --version 2> /dev/null | awk 'BEGIN { R=1};NR==1 && ]gl_dollar[1 == "texindex"{ print $NF; R=0; exit}; {exit}; END { if (R) { print "notfound"}}'`; then
AC_MSG_WARN([Can't find texindex version, check texindex is installed.]) if test "$texindex_ver" == "notfound"; then
[fi texindex_ver=0.0
gl_fn_texindex_info () {]
AC_MSG_WARN([Can't find texindex version, check texindex is installed.])[
}
fi
else
tex_available=false
texindex_ver=0.0
gl_fn_texindex_info () {]
AC_MSG_NOTICE([texindex not installed or not working.])[
}
fi
if $nopipefail; then set +o pipefail; fi
else
texindex_ver=0.0
gl_fn_texindex_info () {]
AC_MSG_NOTICE([Not testing texindex version for tex not installed or not working])[
}
fi
] ]
])dnl ])dnl
AC_DEFUN([gl_TEXINFO_VERSION_COMPARE],[dnl AC_DEFUN([gl_TEXINFO_VERSION_COMPARE],[dnl
@ -95,22 +132,40 @@ AC_REQUIRE([AS_VERSION_COMPARE])
AS_VERSION_COMPARE([$1],[$2],[gl_TEXINFO_INDEXING_IS_LOCALE_DEPENDANT()],[$3],[$3])dnl AS_VERSION_COMPARE([$1],[$2],[gl_TEXINFO_INDEXING_IS_LOCALE_DEPENDANT()],[$3],[$3])dnl
])dnl ])dnl
dnl gl_SET_DOCLANGS dnl gl_SET_DOCLANGS
dnl DOCLANGS is restricted to default when tex/texindex are installed but their
dnl version do not guarantee that index compilation won't break on an UTF-8 encoded
dnl manual. Old version of texindex may derive the locale from the environment rather
dnl than from the @documentencoding statement and break multibyte characters into
dnl incorrect UTF-8 byte sequences.
dnl The rationale is that default language is assumed not to use UTF-8 encoding
dnl whereas translations may use it.
dnl If ever you wish an UTF-8 encoded English manual to contain some symbol or
dnl emoji, then create an English translation of a default manual without the symbols.
AC_DEFUN([gl_SET_DOCLANGS],[dnl AC_DEFUN([gl_SET_DOCLANGS],[dnl
AC_REQUIRE([gl_TEXINFO_VERSION_COMPARE]) AC_REQUIRE([gl_TEXINFO_VERSION_COMPARE])
AC_ARG_VAR([DOCLANGS],[languages for which manuals are compiled, languages supported: ]gl_DOCLANGS_FULL()[, list is space separated]) AC_ARG_VAR([DOCLANGS],[languages for which manuals are compiled, languages supported: ]gl_DOCLANGS_FULL()[, list is space separated])
AC_MSG_CHECKING([for DOCLANGS derivation from texinfo.tex/texindex versions]) AC_MSG_CHECKING([for DOCLANGS derivation from texinfo.tex/texindex versions])
dnl By default nothing to inform about dnl By default nothing to inform about
[gl_fn_doclangs_info () { :; }] [gl_fn_texinfo_info () { :; }
gl_fn_texindex_info () { :; }
gl_fn_doclangs_info () { :; }
tex_available=true;]
gl_GET_TEXINFO_TEX_VER() gl_GET_TEXINFO_TEX_VER()
gl_GET_TEXINDEX_VER() gl_GET_TEXINDEX_VER()
gl_TEXINFO_VERSION_COMPARE([$texinfo_tex_ver],[gl_TEXINFO_TEX_MINVER()],[dnl [if $tex_available; then]
gl_TEXINFO_VERSION_COMPARE([$texindex_ver],[gl_TEXINDEX_MINVER()],[dnl gl_TEXINFO_VERSION_COMPARE([$texinfo_tex_ver],[gl_TEXINFO_TEX_MINVER()],[dnl
[DOCLANGS=']gl_DOCLANGS_FULL()[' gl_TEXINFO_VERSION_COMPARE([$texindex_ver],[gl_TEXINDEX_MINVER()],[dnl
gl_fn_doclangs_info () {] [DOCLANGS=']gl_DOCLANGS_FULL()['
AC_MSG_NOTICE([texinfo.tex/texindex versions suggest that indexing is not locale dependant]) gl_fn_doclangs_info () {]
[}]]) AC_MSG_NOTICE([texinfo.tex/texindex versions suggest that indexing is not locale dependant])
]) [}]])
])[
else
DOCLANGS=']gl_DOCLANGS_FULL()['
fi]
AC_MSG_RESULT([[']$DOCLANGS[']]) AC_MSG_RESULT([[']$DOCLANGS[']])
gl_fn_texinfo_info
gl_fn_texindex_info
gl_fn_doclangs_info gl_fn_doclangs_info
AC_SUBST([DOCLANGS]) AC_SUBST([DOCLANGS])
]) ])