xref: /freebsd/tools/tools/locale/Makefile (revision 19261079)
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
14LOCALESRCDIR?=	${SRCTOP}/share
15TMPDIR?=	/tmp
16
17BASEDIR=	${.CURDIR}
18ETCDIR=		${BASEDIR}/etc
19TOOLSDIR=	${BASEDIR}/tools
20PATCHDIR=	${BASEDIR}/patch
21UNIDIR=		${.OBJDIR:tA}/unicode
22
23PKGS=	openjdk8 \
24	p5-XML-Parser \
25	p5-Tie-IxHash \
26	p5-Text-Iconv
27tools-test:
28	pkg info -e ${PKGS}
29	@echo tools ok.
30
31KNOWN=		monetdef numericdef msgdef colldef ctypedef # timedef
32TYPES?=		${KNOWN}
33
34SETENV=	env -i \
35	PATH="${PATH}" \
36	TMPDIR="${TMPDIR}" \
37	UNIDIR="${UNIDIR}" \
38	BASEDIR="${BASEDIR}" \
39	TOOLSDIR="${TOOLSDIR}" \
40	ETCDIR="${ETCDIR}"
41
42all: posix build afterbuild
43.ORDER: posix build afterbuild
44
45afterbuild: build
46	@echo ""
47	@find . -name *failed
48
49.for t in ${TYPES}
50.  if ${KNOWN:M${t}}
51build: build-${t}
52.ORDER: build-${t} afterbuild
53.  endif
54.endfor
55
56diff:
57.for t in ${TYPES}
58.  if ${KNOWN:M${t}}
59diff: diff-${t}
60diff-${t}:
61	-/usr/bin/diff -ruN -x Makefile -x Makefile.depend \
62	    ${LOCALESRCDIR}/${t} ${t}
63.  endif
64.endfor
65
66install:
67.for t in ${TYPES:Nctypedef}
68.  if ${KNOWN:M${t}}
69install: install-${t}
70install-${t}:
71	cd ${LOCALESRCDIR}/${t}_unicode && \
72	    rm -f Makefile *.src && \
73	    cd ${.OBJDIR} && \
74	    install -m 644 ${t}/* ${LOCALESRCDIR}/${t}_unicode
75.  endif
76.endfor
77install: install-ctypedef
78install-ctypedef:
79	cd ${LOCALESRCDIR}/ctypedef && \
80		rm -f C.UTF-8.src && \
81		cd ${.OBJDIR} && \
82		install -m 644 ctypedef/C.UTF-8.src ${LOCALESRCDIR}/ctypedef
83
84post-install:
85.for t in ${TYPES}
86.  if ${KNOWN:M${t}}
87	cd ${LOCALSRCDIR}/${t} && \
88	    make && make install && make clean
89.  endif
90.endfor
91
92.for t in ${TYPES}
93CLEANDIRS+=	${t} ${t}.draft
94${t}:
95	mkdir -p ${t} ${t}.draft && \
96	perl -I ${TOOLSDIR} ${TOOLSDIR}/cldr2def.pl \
97		--unidir=${UNIDIR:tA} \
98		--etc=${ETCDIR:tA} \
99		--type=${t}
100
101build-${t}: ${t}
102	${SETENV} OUTBASEDIR="${.OBJDIR}/${t}" ${TOOLSDIR}/finalize ${t}
103.endfor
104
105BASE_LOCALES_OF_INTEREST?= \
106	af_ZA am_ET ar_AE ar_EG ar_JO ar_MA ar_QA ar_SA \
107	be_BY bg_BG ca_AD ca_ES ca_FR ca_IT \
108	cs_CZ da_DK de_AT de_CH de_DE el_GR en_AU en_CA \
109	en_GB en_HK en_IE en_NZ en_PH en_SG en_US en_ZA \
110	es_AR es_CR es_ES es_MX et_EE eu_ES fa_AF fa_IR fi_FI fr_BE \
111	fr_CA fr_CH fr_FR ga_IE he_IL hi_IN hr_HR hu_HU hy_AM \
112	is_IS it_CH it_IT ja_JP ko_KR lt_LT lv_LV \
113	nb_NO nl_BE nl_NL nn_NO pl_PL pt_BR pt_PT ro_RO \
114	ru_RU se_FI se_NO sk_SK sl_SI sv_FI sv_SE tr_TR \
115	uk_UA \
116	kk_KZ mn_MN sr_Cyrl_RS sr_Latn_RS \
117	zh_Hans_CN zh_Hant_HK zh_Hant_TW \
118	bn_IN gu_IN or_IN ta_IN te_IN kn_IN ml_IN si_LK \
119	th_TH lo_LA bo_IN my_MM pa_Guru_IN ka_GE chr_US \
120	km_KH shi_Tfng_MA ii_CN vai_Vaii_LR vi_VN
121
122ENCODINGS=	UTF-8 \
123		UTF-32
124
125# CLDR files
126CLDRVERSION=	39.0
127CLDRFILES_CORE= https://unicode.org/Public/cldr/${CLDRVERSION:R}/core.zip
128CLDRFILES_KEY=	https://unicode.org/Public/cldr/${CLDRVERSION:R}/cldr-keyboards-${CLDRVERSION}.zip
129CLDRFILES_TOOLS=https://unicode.org/Public/cldr/${CLDRVERSION:R}/cldr-tools-${CLDRVERSION}.jar
130CLDRFILES_UCD=	http://www.unicode.org/Public/zipped/13.0.0/UCD.zip
131
132# fetch and extract targets
133${UNIDIR}:
134	mkdir -p ${UNIDIR}
135.for N in CORE KEY TOOLS UCD
136${CLDRFILES_${N}:T}:
137	fetch ${CLDRFILES_${N}}
138fetch: ${CLDRFILES_${N}:T}
139extract-${CLDRFILES_${N}:T}:: ${CLDRFILES_${N}:T} ${UNIDIR}
140	cd ${UNIDIR} && unzip -o ../${CLDRFILES_${N}:T}
141extract: extract-${CLDRFILES_${N}:T}
142.endfor
143	echo ${CLDRVERSION} > ${UNIDIR}/cldr-version
144patch::
145.if exists(${PATCHDIR})
146	cd ${UNIDIR} && cat ${PATCHDIR}/patch-* | patch
147.endif
148
149JAVA_CLDR= java -DCLDR_DIR=${UNIDIR:Q} -jar ${.OBJDIR:tA}//${CLDRFILES_TOOLS:T}
150
151posix: posixcm post-posixcm posixsrc
152.ORDER: posixcm post-posixcm posixsrc
153${UNIDIR}/posix: ${UNIDIR}
154	ln -s -f ../posix ${.TARGET}
155clean-posix:
156	rm -rf posix ${UNIDIR}/posix
157${UNIDIR}/posix/xx_Comm_C.UTF-8.src: ${UNIDIR}/posix
158	perl -I ${TOOLSDIR} ${TOOLSDIR}/utf8-rollup.pl \
159	    --unidir=${UNIDIR}
160post-posixcm: ${UNIDIR}/posix/xx_Comm_C.UTF-8.src
161.for enc in ${ENCODINGS}
162posixcm: posix/${enc}.cm
163.ORDER: posix/${enc}.cm
164posix/${enc}.cm:
165	mkdir -p posix && \
166	    ${JAVA_CLDR} org.unicode.cldr.posix.GenerateCharmap \
167		-d posix -c ${enc}
168.endfor
169.for area in ${BASE_LOCALES_OF_INTEREST}
170posixsrc: posix/${area}.UTF-8.src
171.ORDER: posix/${area}.UTF-8.src
172posix/${area}.UTF-8.src:
173	mkdir -p posix && \
174	    ${JAVA_CLDR} org.unicode.cldr.posix.GeneratePOSIX \
175		-d posix -m ${area} -c UTF-8
176.endfor
177
178# generate widths.txt using the data from libut8proc
179GETWIDTHS=${TOOLSDIR}/getwidths
180MKWIDTHS=${TOOLSDIR}/mkwidths.pl
181WIDTHS=	${ETCDIR}/final-maps/widths.txt
182
183U8CFLAGS!=pkgconf --cflags libutf8proc
184U8LIBS!=pkgconf --libs libutf8proc
185CFLAGS+=${U8CFLAGS}
186LDFLAGS+=${U8LIBS}
187
188CLEANFILES+=${TOOLSDIR}/getwidths
189
190widths:	${WIDTHS}
191${WIDTHS}: posixcm ${GETWIDTHS}
192	${GETWIDTHS} | ${MKWIDTHS} ${.OBJDIR}/posix/UTF-8.cm ${.TARGET}
193
194.include <bsd.obj.mk>
195