]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/tools/locale/Makefile
Merge llvm-project 12.0.0 release
[FreeBSD/FreeBSD.git] / tools / tools / locale / Makefile
1 # $FreeBSD$
2 # See https://wiki.freebsd.org/LocaleNewApproach
3 # Taken from FreeBSD svn [base]/user/edwin/locale/cldr
4 #
5 # needs:
6 # devel/p5-Tie-IxHash
7 #
8 # Modified by John Marino to suit DragonFly needs
9 #
10 .if ${.CURDIR} == ${.OBJDIR}
11 .error Do make obj first.
12 .endif
13
14 LOCALESRCDIR?=  ${SRCTOP}/share
15 TMPDIR?=        /tmp
16
17 BASEDIR=        ${.CURDIR}
18 ETCDIR=         ${BASEDIR}/etc
19 TOOLSDIR=       ${BASEDIR}/tools
20 PATCHDIR=       ${BASEDIR}/patch
21 UNIDIR=         ${.OBJDIR:tA}/unicode
22
23 PKGS=   openjdk8 \
24         apache-ant \
25         p5-XML-Parser \
26         p5-Tie-IxHash \
27         p5-Text-Iconv
28 tools-test:
29         pkg info -e ${PKGS}
30         @echo tools ok.
31
32 KNOWN=          monetdef numericdef msgdef colldef ctypedef # timedef
33 TYPES?=         ${KNOWN}
34
35 COLLATION_SPECIAL?= \
36         cs_CZ ISO8859-2 \
37         da_DK ISO8859-1 \
38         da_DK ISO8859-15 \
39         hr_HR ISO8859-2 \
40         hu_HU ISO8859-2 \
41         nb_NO ISO8859-1 \
42         nb_NO ISO8859-15 \
43         sk_SK ISO8859-2 \
44         sr_Latn_RS ISO8859-2 \
45         sr_Cyrl_RS ISO8859-5 \
46         zh_Hans_CN GB2312 \
47         zh_Hans_CN eucCN \
48         zh_Hant_TW Big5 \
49         zh_Hans_CN GB18030 \
50         zh_Hans_CN GBK \
51         ja_JP eucJP \
52         nn_NO ISO8859-15 \
53         nn_NO ISO8859-1
54
55 .for area enc in ${COLLATION_SPECIAL}
56 COLLATIONS_SPECIAL_ENV+=        ${area}.${enc}
57 .endfor
58 SETENV= env -i \
59         PATH="${PATH}" \
60         TMPDIR="${TMPDIR}" \
61         COLLATIONS_SPECIAL="${COLLATIONS_SPECIAL_ENV}" \
62         UNIDIR="${UNIDIR}" \
63         BASEDIR="${BASEDIR}" \
64         TOOLSDIR="${TOOLSDIR}" \
65         ETCDIR="${ETCDIR}"
66
67 all: posix build afterbuild
68 .ORDER: posix build afterbuild
69
70 afterbuild: build
71         @echo ""
72         @find . -name *failed
73
74 .for t in ${TYPES}
75 .  if ${KNOWN:M${t}}
76 build: build-${t}
77 .ORDER: build-${t} afterbuild
78 .  endif
79 .endfor
80
81 diff:
82 .for t in ${TYPES}
83 .  if ${KNOWN:M${t}}
84 diff: diff-${t}
85 diff-${t}:
86         -/usr/bin/diff -ruN -x Makefile -x Makefile.depend \
87             ${LOCALESRCDIR}/${t} ${t}
88 .  endif
89 .endfor
90
91 install:
92 .for t in ${TYPES}
93 .  if ${KNOWN:M${t}}
94 install: install-${t}
95 install-${t}:
96         cd ${LOCALESRCDIR}/${t} && \
97             rm -f Makefile *.src && \
98             cd ${.OBJDIR} && \
99             install -m 644 ${t}/* ${LOCALESRCDIR}/${t}
100 .  endif
101 .endfor
102
103 post-install:
104 .for t in ${TYPES}
105 .  if ${KNOWN:M${t}}
106         cd ${LOCALSRCDIR}/${t} && \
107             make && make install && make clean
108 .  endif
109 .endfor
110
111 .for t in ${TYPES}
112 CLEANDIRS+=     ${t} ${t}.draft
113 ${t}:
114         mkdir -p ${t} ${t}.draft && \
115         perl -I ${TOOLSDIR} ${TOOLSDIR}/cldr2def.pl \
116                 --unidir=${UNIDIR:tA} \
117                 --etc=${ETCDIR:tA} \
118                 --type=${t}
119
120 build-${t}: ${t}
121         ${SETENV} OUTBASEDIR="${.OBJDIR}/${t}" ${TOOLSDIR}/finalize ${t}
122 .endfor
123
124 static-colldef: colldef
125 build-colldef:  static-colldef
126
127 static-colldef:
128 .for area enc in ${COLLATION_SPECIAL}
129         awk -f ${TOOLSDIR}/extract-colldef.awk \
130             posix/${area}.${enc}.src > colldef.draft/${area}.${enc}.src
131 .endfor
132
133 BASE_LOCALES_OF_INTEREST?= \
134         af_ZA am_ET ar_AE ar_EG ar_JO ar_MA ar_QA ar_SA \
135         be_BY bg_BG ca_AD ca_ES ca_FR ca_IT \
136         cs_CZ da_DK de_AT de_CH de_DE el_GR en_AU en_CA \
137         en_GB en_HK en_IE en_NZ en_PH en_SG en_US en_ZA \
138         es_AR es_CR es_ES es_MX et_EE eu_ES fi_FI fr_BE \
139         fr_CA fr_CH fr_FR ga_IE he_IL hi_IN hr_HR hu_HU hy_AM \
140         is_IS it_CH it_IT ja_JP ko_KR lt_LT lv_LV \
141         nb_NO nl_BE nl_NL nn_NO pl_PL pt_BR pt_PT ro_RO \
142         ru_RU se_FI se_NO sk_SK sl_SI sv_FI sv_SE tr_TR \
143         uk_UA \
144         kk_KZ mn_MN sr_Cyrl_RS sr_Latn_RS \
145         zh_Hans_CN zh_Hant_HK zh_Hant_TW \
146         bn_IN gu_IN or_IN ta_IN te_IN kn_IN ml_IN si_LK \
147         th_TH lo_LA bo_IN my_MM pa_Guru_IN ka_GE chr_US \
148         km_KH shi_Tfng_MA ii_CN vai_Vaii_LR vi_VN
149
150 ENCODINGS=      Big5 \
151                 CP1251 \
152                 CP866 \
153                 CP949 \
154                 eucCN \
155                 eucJP \
156                 eucKR \
157                 GB18030 \
158                 GB2312 \
159                 GBK \
160                 ISO8859-1 \
161                 ISO8859-13 \
162                 ISO8859-15 \
163                 ISO8859-2 \
164                 ISO8859-5 \
165                 ISO8859-7 \
166                 ISO8859-9 \
167                 KOI8-R \
168                 KOI8-U \
169                 SJIS \
170                 US-ASCII \
171                 UTF-8 \
172                 UTF-32
173
174 # CLDR files
175 CLDRFILES_CORE= https://unicode.org/Public/cldr/35/core.zip
176 CLDRFILES_KEY=  https://unicode.org/Public/cldr/35/keyboards.zip
177 CLDRFILES_TOOLS=https://unicode.org/Public/cldr/35/tools.zip
178 CLDRFILES_UCD=  http://www.unicode.org/Public/zipped/latest/UCD.zip
179
180 # fetch and extract targets
181 ${UNIDIR}:
182         mkdir -p ${UNIDIR}
183 .for N in CORE KEY TOOLS UCD
184 ${CLDRFILES_${N}:T}:
185         fetch ${CLDRFILES_${N}}
186 fetch: ${CLDRFILES_${N}:T}
187 extract-${CLDRFILES_${N}:T}:: ${CLDRFILES_${N}:T} ${UNIDIR}
188         cd ${UNIDIR} && unzip -o ../${CLDRFILES_${N}:T}
189 extract: extract-${CLDRFILES_${N}:T}
190 .endfor
191         grep 'name="version"' ${UNIDIR}/tools/build.xml | \
192                 sed 's/.* value="//;s/".*//' > ${UNIDIR}/cldr-version
193 patch::
194 .if exists(${PATCHDIR})
195         cd ${UNIDIR} && cat ${PATCHDIR}/patch-* | patch
196 .endif
197
198 .if !exists(${UNIDIR}/tools/java/cldr.jar)
199 .ORDER: extract patch
200 build-tools: extract patch tools-test ${UNIDIR}
201         cd ${UNIDIR}/tools/java && ${SETENV} ant all jar
202 .else
203 build-tools:
204         @echo cldr.jar is ready.
205 .endif
206
207 JAVA_CLDR= java -DCLDR_DIR=${UNIDIR:Q} -jar ${UNIDIR}/tools/java/cldr.jar
208
209 posix: posixcm post-posixcm posixsrc posixcol
210 .ORDER: posixcm post-posixcm posixsrc posixcol
211 ${UNIDIR}/posix:
212         ln -s -f ../posix ${.TARGET}
213 clean-posix:
214         rm -rf posix ${UNIDIR}/posix
215 ${UNIDIR}/posix/xx_Comm_C.UTF-8.src: ${UNIDIR}/posix
216         perl -I ${TOOLSDIR} ${TOOLSDIR}/utf8-rollup.pl \
217             --unidir=${UNIDIR}
218 post-posixcm: ${UNIDIR}/posix/xx_Comm_C.UTF-8.src
219 .for enc in ${ENCODINGS}
220 posixcm: build-tools posix/${enc}.cm
221 .ORDER: build-tools posix/${enc}.cm
222 posix/${enc}.cm:
223         mkdir -p posix && \
224             ${JAVA_CLDR} org.unicode.cldr.posix.GenerateCharmap \
225                 -d posix -c ${enc}
226 .endfor
227 .for area in ${BASE_LOCALES_OF_INTEREST}
228 posixsrc: build-tools posix/${area}.UTF-8.src
229 .ORDER: build-tools posix/${area}.UTF-8.src
230 posix/${area}.UTF-8.src:
231         mkdir -p posix && \
232             ${JAVA_CLDR} org.unicode.cldr.posix.GeneratePOSIX \
233                 -d posix -m ${area} -c UTF-8
234 .endfor
235 .for area encoding in ${COLLATION_SPECIAL}
236 posixcol: build-tools posix/${area}.${encoding}.src
237 .ORDER: build-tools posix/${area}.${encoding}.src
238 posix/${area}.${encoding}.src:
239         mkdir -p posix && \
240             ${JAVA_CLDR} org.unicode.cldr.posix.GeneratePOSIX \
241                 -d posix -m ${area} -c ${encoding}
242 .endfor
243
244 # generate widths.txt using the data from libut8proc
245 GETWIDTHS=${TOOLSDIR}/getwidths
246 MKWIDTHS=${TOOLSDIR}/mkwidths.pl
247 WIDTHS= ${ETCDIR}/final-maps/widths.txt
248
249 U8CFLAGS!=pkgconf --cflags libutf8proc
250 U8LIBS!=pkgconf --libs libutf8proc
251 CFLAGS+=${U8CFLAGS}
252 LDFLAGS+=${U8LIBS}
253
254 CLEANFILES+=${TOOLSDIR}/getwidths
255
256 widths: ${WIDTHS}
257 ${WIDTHS}: posixcm ${GETWIDTHS}
258         ${GETWIDTHS} | ${MKWIDTHS} ${.OBJDIR}/posix/UTF-8.cm ${.TARGET}
259
260 .include <bsd.obj.mk>