]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
DocBook: Use a fixed encoding for output
authorBen Hutchings <ben@decadent.org.uk>
Mon, 28 Sep 2015 00:09:52 +0000 (01:09 +0100)
committerJonathan Corbet <corbet@lwn.net>
Mon, 28 Sep 2015 07:31:48 +0000 (01:31 -0600)
Currently the encoding of documents generated by DocBook depends on
the current locale.  Make the output reproducible independently of
the locale, by setting the encoding to UTF-8 (LC_CTYPE=C.UTF-8) by
preference, or ASCII (LC_CTYPE=C) as a fallback.

LC_CTYPE can normally be overridden by LC_ALL, but the top-level
Makefile unsets that.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[jc: added check-lc_ctype to .gitignore]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Documentation/DocBook/Makefile
Makefile
scripts/.gitignore
scripts/Makefile
scripts/check-lc_ctype.c [new file with mode: 0644]

index 93eff64387cd2324f3f0731ffaba1bca9f39cfb9..d2544961b67a9f5f60cb0f5261e7a2ee08d755e8 100644 (file)
@@ -69,6 +69,12 @@ installmandocs: mandocs
 KERNELDOCXMLREF = $(srctree)/scripts/kernel-doc-xml-ref
 KERNELDOC       = $(srctree)/scripts/kernel-doc
 DOCPROC         = $(objtree)/scripts/docproc
+CHECK_LC_CTYPE = $(objtree)/scripts/check-lc_ctype
+
+# Use a fixed encoding - UTF-8 if the C library has support built-in
+# or ASCII if not
+LC_CTYPE := $(call try-run, LC_CTYPE=C.UTF-8 $(CHECK_LC_CTYPE),C.UTF-8,C)
+export LC_CTYPE
 
 XMLTOFLAGS = -m $(srctree)/$(src)/stylesheet.xsl
 XMLTOFLAGS += --skip-validation
index 84f4b31e3c6eaa14411812ec3617e1b894175f26..d23d2e97a835265b92db3757179d5a6b5e431f9c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1336,7 +1336,7 @@ $(help-board-dirs): help-%:
 # Documentation targets
 # ---------------------------------------------------------------------------
 %docs: scripts_basic FORCE
-       $(Q)$(MAKE) $(build)=scripts build_docproc
+       $(Q)$(MAKE) $(build)=scripts build_docproc build_check-lc_ctype
        $(Q)$(MAKE) $(build)=Documentation/DocBook $@
 
 else # KBUILD_EXTMOD
index 12efbbefd4d754064c4f8533351d126851449ab9..1f78169d425493356b560459ec5ef2da1b93c903 100644 (file)
@@ -8,6 +8,7 @@ unifdef
 ihex2fw
 recordmcount
 docproc
+check-lc_ctype
 sortextable
 asn1_compiler
 extract-cert
index 1b2661712d449a88668f470d2034b5091c5342c0..fd0d53d4a2346f762aa52f86c7b66abd78ae7470 100644 (file)
@@ -7,6 +7,7 @@
 # conmakehash:   Create chartable
 # conmakehash:  Create arrays for initializing the kernel console tables
 # docproc:       Used in Documentation/DocBook
+# check-lc_ctype: Used in Documentation/DocBook
 
 HOST_EXTRACFLAGS += -I$(srctree)/tools/include
 
@@ -27,14 +28,16 @@ HOSTLOADLIBES_extract-cert = -lcrypto
 always         := $(hostprogs-y) $(hostprogs-m)
 
 # The following hostprogs-y programs are only build on demand
-hostprogs-y += unifdef docproc
+hostprogs-y += unifdef docproc check-lc_ctype
 
 # These targets are used internally to avoid "is up to date" messages
-PHONY += build_unifdef build_docproc
+PHONY += build_unifdef build_docproc build_check-lc_ctype
 build_unifdef: $(obj)/unifdef
        @:
 build_docproc: $(obj)/docproc
        @:
+build_check-lc_ctype: $(obj)/check-lc_ctype
+       @:
 
 subdir-$(CONFIG_MODVERSIONS) += genksyms
 subdir-y                     += mod
diff --git a/scripts/check-lc_ctype.c b/scripts/check-lc_ctype.c
new file mode 100644 (file)
index 0000000..9097ff5
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Check that a specified locale works as LC_CTYPE.  Used by the
+ * DocBook build system to probe for C.UTF-8 support.
+ */
+
+#include <locale.h>
+
+int main(void)
+{
+       return !setlocale(LC_CTYPE, "");
+}