]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/tools/locale/Makefile
tools/tools/locale: install generated files in current src checkout
[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 colldef.draft/${area}.${enc}.src: posix/${area}.${enc}.src
130         awk -f ${TOOLSDIR}/extract-colldef.awk \
131             ${.ALLSRC} > ${.TARGET} || (rm -f ${.TARGET} && false)
132 .endfor
133
134 BASE_LOCALES_OF_INTEREST?= \
135         af_ZA am_ET ar_AE ar_EG ar_JO ar_MA ar_QA ar_SA \
136         be_BY bg_BG ca_AD ca_ES ca_FR ca_IT \
137         cs_CZ da_DK de_AT de_CH de_DE el_GR en_AU en_CA \
138         en_GB en_HK en_IE en_NZ en_PH en_SG en_US en_ZA \
139         es_AR es_CR es_ES es_MX et_EE eu_ES fi_FI fr_BE \
140         fr_CA fr_CH fr_FR ga_IE he_IL hi_IN hr_HR hu_HU hy_AM \
141         is_IS it_CH it_IT ja_JP ko_KR lt_LT lv_LV \
142         nb_NO nl_BE nl_NL nn_NO pl_PL pt_BR pt_PT ro_RO \
143         ru_RU se_FI se_NO sk_SK sl_SI sv_FI sv_SE tr_TR \
144         uk_UA \
145         kk_KZ mn_MN sr_Cyrl_RS sr_Latn_RS \
146         zh_Hans_CN zh_Hant_HK zh_Hant_TW \
147         bn_IN gu_IN or_IN ta_IN te_IN kn_IN ml_IN si_LK \
148         th_TH lo_LA bo_IN my_MM pa_Guru_IN ka_GE chr_US \
149         km_KH shi_Tfng_MA ii_CN vai_Vaii_LR vi_VN
150
151 ENCODINGS=      Big5 \
152                 CP1251 \
153                 CP866 \
154                 CP949 \
155                 eucCN \
156                 eucJP \
157                 eucKR \
158                 GB18030 \
159                 GB2312 \
160                 GBK \
161                 ISO8859-1 \
162                 ISO8859-13 \
163                 ISO8859-15 \
164                 ISO8859-2 \
165                 ISO8859-5 \
166                 ISO8859-7 \
167                 ISO8859-9 \
168                 KOI8-R \
169                 KOI8-U \
170                 SJIS \
171                 US-ASCII \
172                 UTF-8
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 post-posixcm: ${UNIDIR}/posix
216         perl -I ${TOOLSDIR} ${TOOLSDIR}/utf8-rollup.pl \
217             --unidir=${UNIDIR}
218 .for enc in ${ENCODINGS}
219 posixcm: build-tools posix/${enc}.cm
220 .ORDER: build-tools posix/${enc}.cm
221 posix/${enc}.cm:
222         mkdir -p posix && \
223             ${JAVA_CLDR} org.unicode.cldr.posix.GenerateCharmap \
224                 -d posix -c ${enc}
225 .endfor
226 .for area in ${BASE_LOCALES_OF_INTEREST}
227 posixsrc: build-tools posix/${area}.UTF-8.src
228 .ORDER: build-tools posix/${area}.UTF-8.src
229 posix/${area}.UTF-8.src:
230         mkdir -p posix && \
231             ${JAVA_CLDR} org.unicode.cldr.posix.GeneratePOSIX \
232                 -d posix -m ${area} -c UTF-8
233 .endfor
234 .for area encoding in ${COLLATION_SPECIAL}
235 posixcol: build-tools posix/${area}.${encoding}.src
236 .ORDER: build-tools posix/${area}.${encoding}.src
237 posix/${area}.${encoding}.src:
238         mkdir -p posix && \
239             ${JAVA_CLDR} org.unicode.cldr.posix.GeneratePOSIX \
240                 -d posix -m ${area} -c ${encoding}
241 .endfor
242
243 # generate widths.txt using the data from libut8proc
244 GETWIDTHS=${TOOLSDIR}/getwidths
245 MKWIDTHS=${TOOLSDIR}/mkwidths.pl
246 WIDTHS= ${ETCDIR}/final-maps/widths.txt
247
248 U8CFLAGS!=pkgconf --cflags libutf8proc
249 U8LIBS!=pkgconf --libs libutf8proc
250 CFLAGS+=${U8CFLAGS}
251 LDFLAGS+=${U8LIBS}
252
253 CLEANFILES+=${TOOLSDIR}/getwidths
254
255 widths: ${WIDTHS}
256 ${WIDTHS}: posixcm ${GETWIDTHS}
257         ${GETWIDTHS} | ${MKWIDTHS} ${.OBJDIR}/posix/UTF-8.cm ${.TARGET}
258
259 .include <bsd.obj.mk>