add patch export-sysfs-casefold-feature-attribute
[ext4-patch-queue.git] / refactor-the-rule-for-regenerating-utf8data.h
blob5f6617ee4ac5fcc68aa595a9a17f9adb1f6c95c7
1 unicode: refactor the rule for regenerating utf8data.h
3 From: Masahiro Yamada <yamada.masahiro@socionext.com>
5 scripts/mkutf8data is used only when regenerating utf8data.h,
6 which never happens in the normal kernel build. However, it is
7 irrespectively built if CONFIG_UNICODE is enabled.
9 Moreover, there is no good reason for it to reside in the scripts/
10 directory since it is only used in fs/unicode/.
12 Hence, move it from scripts/ to fs/unicode/.
14 In some cases, we bypass build artifacts in the normal build. The
15 conventional way to do so is to surround the code with ifdef REGENERATE_*.
17 For example,
19 - 7373f4f83c71 ("kbuild: add implicit rules for parser generation")
20 - 6aaf49b495b4 ("crypto: arm,arm64 - Fix random regeneration of S_shipped")
22 I rewrote the rule in a more kbuild'ish style.
24 In the normal build, utf8data.h is just shipped from the check-in file.
26 $ make
27 [ snip ]
28 SHIPPED fs/unicode/utf8data.h
29 CC fs/unicode/utf8-norm.o
30 CC fs/unicode/utf8-core.o
31 CC fs/unicode/utf8-selftest.o
32 AR fs/unicode/built-in.a
34 If you want to generate utf8data.h based on UCD, put *.txt files into
35 fs/unicode/, then pass REGENERATE_UTF8DATA=1 from the command line.
36 The mkutf8data tool will be automatically compiled to generate the
37 utf8data.h from the *.txt files.
39 $ make REGENERATE_UTF8DATA=1
40 [ snip ]
41 HOSTCC fs/unicode/mkutf8data
42 GEN fs/unicode/utf8data.h
43 CC fs/unicode/utf8-norm.o
44 CC fs/unicode/utf8-core.o
45 CC fs/unicode/utf8-selftest.o
46 AR fs/unicode/built-in.a
48 I renamed the check-in utf8data.h to utf8data.h_shipped so that this
49 will work for the out-of-tree build.
51 You can update it based on the latest UCD like this:
53 $ make REGENERATE_UTF8DATA=1 fs/unicode/
54 $ cp fs/unicode/utf8data.h fs/unicode/utf8data.h_shipped
56 Also, I added entries to .gitignore and dontdiff.
58 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
59 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
60 ---
62 Changes in v2:
63 - Make this work correctly with O= option
65 Documentation/dontdiff | 2 ++
66 fs/unicode/.gitignore | 2 ++
67 fs/unicode/Makefile | 41 ++++++++++++++++++++-------
68 fs/unicode/README.utf8data | 9 +++---
69 {scripts => fs/unicode}/mkutf8data.c | 0
70 fs/unicode/{utf8data.h => utf8data.h_shipped} | 0
71 scripts/Makefile | 1 -
72 7 files changed, 38 insertions(+), 17 deletions(-)
73 create mode 100644 fs/unicode/.gitignore
74 rename {scripts => fs/unicode}/mkutf8data.c (100%)
75 rename fs/unicode/{utf8data.h => utf8data.h_shipped} (100%)
77 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
78 index ef25a06..9369377 100644
79 --- a/Documentation/dontdiff
80 +++ b/Documentation/dontdiff
81 @@ -176,6 +176,7 @@ mkprep
82 mkregtable
83 mktables
84 mktree
85 +mkutf8data
86 modpost
87 modules.builtin
88 modules.order
89 @@ -254,6 +255,7 @@ vsyscall_32.lds
90 wanxlfw.inc
91 uImage
92 unifdef
93 +utf8data.h
94 wakeup.bin
95 wakeup.elf
96 wakeup.lds
97 diff --git a/fs/unicode/.gitignore b/fs/unicode/.gitignore
98 new file mode 100644
99 index 0000000..0381e22
100 --- /dev/null
101 +++ b/fs/unicode/.gitignore
102 @@ -0,0 +1,2 @@
103 +mkutf8data
104 +utf8data.h
105 diff --git a/fs/unicode/Makefile b/fs/unicode/Makefile
106 index 671d31f..d46e9ba 100644
107 --- a/fs/unicode/Makefile
108 +++ b/fs/unicode/Makefile
109 @@ -5,15 +5,34 @@ obj-$(CONFIG_UNICODE_NORMALIZATION_SELFTEST) += utf8-selftest.o
111 unicode-y := utf8-norm.o utf8-core.o
113 -# This rule is not invoked during the kernel compilation. It is used to
114 -# regenerate the utf8data.h header file.
115 -utf8data.h.new: *.txt $(objdir)/scripts/mkutf8data
116 - $(objdir)/scripts/mkutf8data \
117 - -a DerivedAge.txt \
118 - -c DerivedCombiningClass.txt \
119 - -p DerivedCoreProperties.txt \
120 - -d UnicodeData.txt \
121 - -f CaseFolding.txt \
122 - -n NormalizationCorrections.txt \
123 - -t NormalizationTest.txt \
124 +$(obj)/utf8-norm.o: $(obj)/utf8data.h
126 +# In the normal build, the checked-in utf8data.h is just shipped.
128 +# To generate utf8data.h from UCD, put *.txt files in this directory
129 +# and pass REGENERATE_UTF8DATA=1 from the command line.
130 +ifdef REGENERATE_UTF8DATA
132 +quiet_cmd_utf8data = GEN $@
133 + cmd_utf8data = $< \
134 + -a $(srctree)/$(src)/DerivedAge.txt \
135 + -c $(srctree)/$(src)/DerivedCombiningClass.txt \
136 + -p $(srctree)/$(src)/DerivedCoreProperties.txt \
137 + -d $(srctree)/$(src)/UnicodeData.txt \
138 + -f $(srctree)/$(src)/CaseFolding.txt \
139 + -n $(srctree)/$(src)/NormalizationCorrections.txt \
140 + -t $(srctree)/$(src)/NormalizationTest.txt \
141 -o $@
143 +$(obj)/utf8data.h: $(obj)/mkutf8data $(filter %.txt, $(cmd_utf8data)) FORCE
144 + $(call if_changed,utf8data)
146 +else
148 +$(obj)/utf8data.h: $(src)/utf8data.h_shipped FORCE
149 + $(call if_changed,shipped)
151 +endif
153 +targets += utf8data.h
154 +hostprogs-y += mkutf8data
155 diff --git a/fs/unicode/README.utf8data b/fs/unicode/README.utf8data
156 index eeb7561..459eebf 100644
157 --- a/fs/unicode/README.utf8data
158 +++ b/fs/unicode/README.utf8data
159 @@ -41,15 +41,14 @@ released version of the UCD can be found here:
161 http://www.unicode.org/Public/UCD/latest/
163 -To build the utf8data.h file, from a kernel tree that has been built,
164 -cd to this directory (fs/unicode) and run this command:
165 +Then, build under fs/unicode/ with REGENERATE_UTF8DATA=1:
167 - make C=../.. objdir=../.. utf8data.h.new
168 + make REGENERATE_UTF8DATA=1 fs/unicode/
170 -After sanity checking the newly generated utf8data.h.new file (the
171 +After sanity checking the newly generated utf8data.h file (the
172 version generated from the 12.1.0 UCD should be 4,109 lines long, and
173 have a total size of 324k) and/or comparing it with the older version
174 -of utf8data.h, rename it to utf8data.h.
175 +of utf8data.h_shipped, rename it to utf8data.h_shipped.
177 If you are a kernel developer updating to a newer version of the
178 Unicode Character Database, please update this README.utf8data file
179 diff --git a/scripts/mkutf8data.c b/fs/unicode/mkutf8data.c
180 similarity index 100%
181 rename from scripts/mkutf8data.c
182 rename to fs/unicode/mkutf8data.c
183 diff --git a/fs/unicode/utf8data.h b/fs/unicode/utf8data.h_shipped
184 similarity index 100%
185 rename from fs/unicode/utf8data.h
186 rename to fs/unicode/utf8data.h_shipped
187 diff --git a/scripts/Makefile b/scripts/Makefile
188 index b87e3e0..9d442ee 100644
189 --- a/scripts/Makefile
190 +++ b/scripts/Makefile
191 @@ -20,7 +20,6 @@ hostprogs-$(CONFIG_ASN1) += asn1_compiler
192 hostprogs-$(CONFIG_MODULE_SIG) += sign-file
193 hostprogs-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
194 hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
195 -hostprogs-$(CONFIG_UNICODE) += mkutf8data
197 HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include
198 HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
200 2.7.4