]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/tools/locale/Makefile
tools/tools/locale: fix static-colldef
[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
173 # CLDR files
174 CLDRFILES_CORE= https://unicode.org/Public/cldr/35/core.zip
175 CLDRFILES_KEY=  https://unicode.org/Public/cldr/35/keyboards.zip
176 CLDRFILES_TOOLS=https://unicode.org/Public/cldr/35/tools.zip
177 CLDRFILES_UCD=  http://www.unicode.org/Public/zipped/latest/UCD.zip
178
179 # fetch and extract targets
180 ${UNIDIR}:
181         mkdir -p ${UNIDIR}
182 .for N in CORE KEY TOOLS UCD
183 ${CLDRFILES_${N}:T}:
184         fetch ${CLDRFILES_${N}}
185 fetch: ${CLDRFILES_${N}:T}
186 extract-${CLDRFILES_${N}:T}:: ${CLDRFILES_${N}:T} ${UNIDIR}
187         cd ${UNIDIR} && unzip -o ../${CLDRFILES_${N}:T}
188 extract: extract-${CLDRFILES_${N}:T}
189 .endfor
190         grep 'name="version"' ${UNIDIR}/tools/build.xml | \
191                 sed 's/.* value="//;s/".*//' > ${UNIDIR}/cldr-version
192 patch::
193 .if exists(${PATCHDIR})
194         cd ${UNIDIR} && cat ${PATCHDIR}/patch-* | patch
195 .endif
196
197 .if !exists(${UNIDIR}/tools/java/cldr.jar)
198 .ORDER: extract patch
199 build-tools: extract patch tools-test ${UNIDIR}
200         cd ${UNIDIR}/tools/java && ${SETENV} ant all jar
201 .else
202 build-tools:
203         @echo cldr.jar is ready.
204 .endif
205
206 JAVA_CLDR= java -DCLDR_DIR=${UNIDIR:Q} -jar ${UNIDIR}/tools/java/cldr.jar
207
208 posix: posixcm post-posixcm posixsrc posixcol
209 .ORDER: posixcm post-posixcm posixsrc posixcol
210 ${UNIDIR}/posix:
211         ln -s -f ../posix ${.TARGET}
212 clean-posix:
213         rm -rf posix ${UNIDIR}/posix
214 post-posixcm: ${UNIDIR}/posix
215         perl -I ${TOOLSDIR} ${TOOLSDIR}/utf8-rollup.pl \
216             --unidir=${UNIDIR}
217 .for enc in ${ENCODINGS}
218 posixcm: build-tools posix/${enc}.cm
219 .ORDER: build-tools posix/${enc}.cm
220 posix/${enc}.cm:
221         mkdir -p posix && \
222             ${JAVA_CLDR} org.unicode.cldr.posix.GenerateCharmap \
223                 -d posix -c ${enc}
224 .endfor
225 .for area in ${BASE_LOCALES_OF_INTEREST}
226 posixsrc: build-tools posix/${area}.UTF-8.src
227 .ORDER: build-tools posix/${area}.UTF-8.src
228 posix/${area}.UTF-8.src:
229         mkdir -p posix && \
230             ${JAVA_CLDR} org.unicode.cldr.posix.GeneratePOSIX \
231                 -d posix -m ${area} -c UTF-8
232 .endfor
233 .for area encoding in ${COLLATION_SPECIAL}
234 posixcol: build-tools posix/${area}.${encoding}.src
235 .ORDER: build-tools posix/${area}.${encoding}.src
236 posix/${area}.${encoding}.src:
237         mkdir -p posix && \
238             ${JAVA_CLDR} org.unicode.cldr.posix.GeneratePOSIX \
239                 -d posix -m ${area} -c ${encoding}
240 .endfor
241
242 # generate widths.txt using the data from libut8proc
243 GETWIDTHS=${TOOLSDIR}/getwidths
244 MKWIDTHS=${TOOLSDIR}/mkwidths.pl
245 WIDTHS= ${ETCDIR}/final-maps/widths.txt
246
247 U8CFLAGS!=pkgconf --cflags libutf8proc
248 U8LIBS!=pkgconf --libs libutf8proc
249 CFLAGS+=${U8CFLAGS}
250 LDFLAGS+=${U8LIBS}
251
252 CLEANFILES+=${TOOLSDIR}/getwidths
253
254 widths: ${WIDTHS}
255 ${WIDTHS}: posixcm ${GETWIDTHS}
256         ${GETWIDTHS} | ${MKWIDTHS} ${.OBJDIR}/posix/UTF-8.cm ${.TARGET}
257
258 .include <bsd.obj.mk>