xref: /illumos-gate/usr/src/cmd/localedef/Makefile (revision fae4f9e0b50e2f5af5fce78f508f8669dc2b1e48)
1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12#
13# Copyright 2017 Nexenta Systems, Inc.
14# Copyright 2011 EveryCity Ltd. All rights reserved.
15# Copyright 2013 DEY Storage Systems, Inc.
16# Copyright 2016 Joyent, Inc.
17#
18
19PROG=localedef
20
21NDIR=native
22NPROG=$(NDIR)/localedef
23
24include ../Makefile.cmd
25
26OBJS = 	charmap.o collate.o ctype.o messages.o monetary.o numeric.o time.o \
27	scanner.o localedef.o wide.o parser.tab.o
28NOBJS = $(OBJS:%.o=native/%.o) native/avl.o native/mkdirp.o
29
30HDRS	= localedef.h
31
32SRCS   = $(OBJS:%.o=%.c)
33
34CPPFLAGS	+= -I $(SRC)/lib/libc/port/locale
35NATIVE_CPPFLAGS	+= -I $(SRC)/lib/libc/port/locale -DNATIVE
36CERRWARN	+= -_gcc=-Wno-char-subscripts
37CERRWARN	+= -_gcc=-Wno-uninitialized
38CERRWARN	+= -_gcc=-Wno-unused-label
39LDLIBS		+= -lgen
40LDLIBS 		+= -lavl
41
42NATIVELDLIBS=
43
44YFLAGS		= -d -b parser
45
46CLEANFILES	= $(NOBJS) $(OBJS) parser.tab.c parser.tab.h
47CLEANFILES	+= \
48		UTF-8.cm UTF-8.ct \
49		8859-1.cm 8859-2.cm 8859-3.cm 8859-4.cm \
50		8859-5.cm 8859-5.cm 8859-6.cm 8859-7.cm \
51		8859-8.cm 8859-9.cm 8859-9.cm 8859-10.cm \
52		8859-11.cm 8859-13.cm 8859-14.cm 8859-15.cm \
53		8859-16.cm \
54		KOI8-R.cm
55CLOBBERFILES	= $(PROG) $(NPROG) $(POFILE) \
56		GB18030.cm UTF-8.cm
57
58PIFILES		= $(OBJS:%.o=%.i)
59POFILE		= localedef_cmd.po
60
61ISO8859_1_LOCALES	= \
62		da_DK \
63		de_CH de_DE \
64		en_AU en_CA en_GB en_NZ en_US \
65		es_AR es_BO es_CL es_CO es_EC es_ES es_GT es_MX es_NI es_PA \
66		es_PE es_SV es_UY es_VE \
67		fr_CA fr_CH fr_FR \
68		is_IS \
69		it_CH it_IT \
70		sv_SE
71
72ISO8859_2_LOCALES	= \
73		cs_CZ \
74		hr_HR \
75		hu_HU \
76		pl_PL \
77		sq_AL
78
79ISO8859_5_LOCALES	= \
80		bg_BG \
81		mk_MK \
82		ru_RU
83
84ISO8859_6_LOCALES	=
85
86ISO8859_7_LOCALES	= \
87		el_GR
88
89ISO8859_9_LOCALES	= \
90		tr_TR
91
92ISO8859_11_LOCALES	= \
93		th_TH
94
95ISO8859_13_LOCALES	= \
96		lt_LT \
97		lv_LV
98
99ISO8859_15_LOCALES	= \
100		ca_ES \
101		da_DK \
102		de_AT de_DE \
103		en_GB en_IE en_US \
104		es_ES \
105		fi_FI \
106		fr_BE fr_FR \
107		it_IT \
108		nl_BE nl_NL \
109		pt_PT \
110		sv_FI sv_SE
111
112KOI8_R_LOCALES		= \
113		ru_RU
114
115GB18030_LOCALES		= \
116		zh_CN
117
118#
119# All new locales should be in UTF-8 form.
120#
121UTF_8_LOCALES		= \
122		af_ZA \
123		ar_AE ar_BH ar_DZ ar_EG ar_IQ ar_JO ar_KW ar_LB ar_LY ar_MA \
124		ar_OM ar_QA ar_SA ar_TN ar_YE \
125		as_IN \
126		az_AZ \
127		be_BY \
128		bg_BG \
129		bn_BD bn_IN \
130		bo_CN bo_IN \
131		bs_BA \
132		ca_ES \
133		cs_CZ \
134		da_DK \
135		de_AT de_BE de_CH de_DE de_LI de_LU \
136		el_CY el_GR \
137		en_AU en_BW en_BZ en_CA en_GB en_HK en_IE en_IN en_JM en_MH \
138		en_MT en_NA en_NZ en_PH en_PK en_SG en_TT en_US en_ZA en_ZW \
139		es_AR es_BO es_CL es_CO es_CR es_DO es_EC es_ES es_GQ es_GT \
140		es_HN es_MX es_NI es_PA es_PE es_PR es_PY es_SV es_US es_UY \
141		es_VE \
142		et_EE \
143		fi_FI \
144		fil_PH \
145		fr_BE fr_CA fr_CF fr_CH fr_FR fr_GN fr_LU fr_MC fr_MG fr_ML \
146		fr_NE fr_SN \
147		ga_IE \
148		gu_IN \
149		he_IL \
150		hi_IN \
151		hr_HR \
152		hu_HU \
153		hy_AM \
154		id_ID \
155		ii_CN \
156		is_IS \
157		it_CH it_IT \
158		ja_JP \
159		ka_GE \
160		kk_KZ \
161		km_KH \
162		kn_IN \
163		ko_KR \
164		kok_IN \
165		lt_LT \
166		lv_LV \
167		mk_MK \
168		ml_IN \
169		mn_CN mn_MN \
170		mr_IN \
171		ms_MY \
172		mt_MT \
173		ne_IN ne_NP \
174		nl_BE nl_NL \
175		nb_NO \
176		nn_NO \
177		or_IN \
178		pa_IN pa_PK \
179		pl_PL \
180		pt_BR pt_GW pt_MZ pt_PT \
181		ro_MD ro_RO \
182		ru_MD ru_RU ru_UA \
183		sa_IN \
184		si_LK \
185		sk_SK \
186		sl_SI \
187		sq_AL \
188		sr_BA sr_ME sr_RS \
189		sv_FI sv_SE \
190		ta_IN ta_LK \
191		te_IN \
192		th_TH \
193		tr_TR \
194		uk_UA \
195		ug_CN \
196		ur_IN ur_PK \
197		vi_VN \
198		zh_CN zh_HK zh_MO zh_SG zh_TW \
199		zz_AA
200
201UTF8SRCS	= $(UTF_8_LOCALES:%=data/%.UTF-8.src)
202
203LOCNAMES	= \
204		$(ISO8859_1_LOCALES:%=%.ISO8859-1) \
205		$(ISO8859_2_LOCALES:%=%.ISO8859-2) \
206		$(ISO8859_5_LOCALES:%=%.ISO8859-5) \
207		$(ISO8859_6_LOCALES:%=%.ISO8859-6) \
208		$(ISO8859_7_LOCALES:%=%.ISO8859-7) \
209		$(ISO8859_9_LOCALES:%=%.ISO8859-9) \
210		$(ISO8859_11_LOCALES:%=%.ISO8859-11) \
211		$(ISO8859_13_LOCALES:%=%.ISO8859-13) \
212		$(ISO8859_15_LOCALES:%=%.ISO8859-15) \
213		$(KOI8_R_LOCALES:%=%.KOI8-R) \
214		$(GB18030_LOCALES:%=%.GB18030) \
215		$(UTF_8_LOCALES:%=%.UTF-8)
216
217LOCDIRS		= $(LOCNAMES:%=locale/%)
218
219STAMPFILES	= $(LOCDIRS:%=%/stamp)
220
221CATDIRS		= \
222		$(LOCDIRS:%=%/LC_COLLATE) \
223		$(LOCDIRS:%=%/LC_CTYPE) \
224		$(LOCDIRS:%=%/LC_MESSAGES) \
225		$(LOCDIRS:%=%/LC_MONETARY) \
226		$(LOCDIRS:%=%/LC_NUMERIC) \
227		$(LOCDIRS:%=%/LC_TIME)
228
229DATA		= $(CATDIRS:%=%/LCL_DATA)
230
231.PARALLEL:
232# The output from yacc must be emitted serially
233.NO_PARALLEL: parser.tab.c parser.tab.h
234
235DCOLL		= LC_COLLATE/LCL_DATA
236DCTYPE		= LC_CTYPE/LCL_DATA
237DMSGS		= LC_MESSAGES/LCL_DATA
238DMON		= LC_MONETARY/LCL_DATA
239DNUM		= LC_NUMERIC/LCL_DATA
240DTIME		= LC_TIME/LCL_DATA
241
242ROOTLOCDIRS	= $(LOCDIRS:%=$(ROOTLIB)/%)
243ROOTCATDIRS	= $(CATDIRS:%=$(ROOTLIB)/%)
244ROOTDATA	= $(DATA:%=$(ROOTLIB)/%)
245
246#
247# This is a list of locales that happen to have translations for them
248# present in the gate.
249#
250TRANSDIR	= translations
251TRANSLOCS	= \
252		zz_AA.UTF-8
253TRANSMOS	= $(TRANSLOCS:%=$(TRANSDIR)/%.mo)
254
255OSTMOFILE	= LC_MESSAGES/SUNW_OST_OSLIB.mo
256
257PRIVTRANSLOCS	= \
258		zz_AA.UTF-8
259PRIVFILE	= LC_MESSAGES/priv_names
260
261ROOTTRANSLATIONS = $(TRANSLOCS:%=$(ROOTLIB)/locale/%/$(OSTMOFILE))
262ROOTPRIVTRANS = $(PRIVTRANSLOCS:%=$(ROOTLIB)/locale/%/$(PRIVFILE))
263
264$(ROOTDATA)	:= FILEMODE=0444
265
266.KEEP_STATE:
267
268all: $(PROG) $(DATA)
269
270translate: $(ROOTTRANSLATIONS) $(ROOTPRIVTRANS)
271
272install: all $(ROOTPROG) $(ROOTDATA) $(ROOTTRANSLATIONS) $(ROOTPRIVTRANS)
273
274$(NDIR):
275	-@mkdir -p $@
276
277$(NDIR)/%.o: %.c
278	$(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c $<
279
280$(NDIR)/avl.o : ../../common/avl/avl.c
281	$(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c \
282	  ../../common/avl/avl.c
283
284$(NDIR)/mkdirp.o : ../../lib/libgen/common/mkdirp.c
285	$(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c \
286	  ../../lib/libgen/common/mkdirp.c
287
288$(NPROG): $(NDIR) .WAIT $(NOBJS)
289	$(LINK.c) $(NOBJS) -o $@ $(NATIVELDLIBS)
290	$(POST_PROCESS)
291
292$(PROG): $(OBJS)
293	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
294	$(POST_PROCESS)
295
296$(OBJS) $(NOBJS):	parser.tab.h
297
298parser.tab.c parser.tab.h: parser.y $(HDRS)
299	$(YACC) $(YFLAGS) parser.y
300
301lint:	$(SRCS)
302	$(LINT.c) $(CPPFLAGS) $(SRCS)
303
304clean:
305	$(RM) $(CLEANFILES)
306	$(RM) $(STAMPFILES)
307
308clobber: clean
309	$(RM) $(CLOBBERFILES)
310	$(RM) -r $(LOCDIRS)
311	$(RM) -r $(NDIR)
312	$(RM) $(TRANSMOS)
313
314$(POFILE):	$(PIFILES)
315	$(RM) $@
316	$(RM) messages.po
317	$(XGETTEXT) -s $(PIFILES)
318	$(SED) -e '/domain/d' messages.po > $@
319	$(RM) $(PIFILES) messages.po
320
321locale $(ROOTLOCDIRS) $(ROOTCATDIRS):
322	$(INS.dir)
323
324$(ROOTBIN)/%: $(ROOTBIN) %
325	$(INS.file)
326
327# Strip LC_CTYPE contents for UTF-8 locales and replace them
328# with UTF-8.ct we compiled
329locale/%.UTF-8/stamp:		data/%.UTF-8.src UTF-8.cm \
330				UTF-8.ct locale $(NPROG)
331	$(SED) '/^LC_CTYPE/,/^END LC_CTYPE/d;$$r UTF-8.ct' $< | \
332		./$(NPROG) -U -w data/widths.txt -f UTF-8.cm $(@D)
333	$(TOUCH) $@
334# Convert EURO_SIGN to CURRENCY_SIGN for the ISO8859-1 locales
335locale/%.ISO8859-1/stamp:	data/%.UTF-8.src 8859-1.cm locale $(NPROG)
336	sed 's/EURO_SIGN/CURRENCY_SIGN/' $< > $<.tmp
337	./$(NPROG) -U -w data/widths.txt -i $<.tmp -f 8859-1.cm $(@D)
338	rm -f $<.tmp
339	$(TOUCH) $@
340locale/%.ISO8859-2/stamp:	data/%.UTF-8.src 8859-2.cm locale $(NPROG)
341	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-2.cm $(@D)
342	$(TOUCH) $@
343locale/%.ISO8859-5/stamp:	data/%.UTF-8.src 8859-5.cm locale $(NPROG)
344	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-5.cm $(@D)
345	$(TOUCH) $@
346locale/%.ISO8859-7/stamp:	data/%.UTF-8.src 8859-7.cm locale $(NPROG)
347	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-7.cm $(@D)
348	$(TOUCH) $@
349locale/%.ISO8859-6/stamp:	data/%.UTF-8.src 8859-6.cm locale $(NPROG)
350	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-6.cm $(@D)
351	$(TOUCH) $@
352locale/%.ISO8859-9/stamp:	data/%.UTF-8.src 8859-9.cm locale $(NPROG)
353	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-9.cm $(@D)
354	$(TOUCH) $@
355locale/%.ISO8859-11/stamp:	data/%.UTF-8.src 8859-11.cm locale $(NPROG)
356	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-11.cm $(@D)
357	$(TOUCH) $@
358locale/%.ISO8859-13/stamp:	data/%.UTF-8.src 8859-13.cm locale $(NPROG)
359	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-13.cm $(@D)
360	$(TOUCH) $@
361locale/%.ISO8859-15/stamp:	data/%.UTF-8.src 8859-15.cm locale $(NPROG)
362	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-15.cm $(@D)
363	$(TOUCH) $@
364locale/%.KOI8-R/stamp:		data/%.UTF-8.src KOI8-R.cm locale $(NPROG)
365	./$(NPROG) -U -w data/widths.txt -i $< -f KOI8-R.cm $(@D)
366	$(TOUCH) $@
367locale/%.GB18030/stamp:		data/%.UTF-8.src GB18030.cm locale $(NPROG)
368	./$(NPROG) -U -w data/widths.txt -i $< -f GB18030.cm $(@D)
369	$(TOUCH) $@
370
371locale/%/$(DCOLL):	locale/%/stamp
372locale/%/$(DCTYPE):	locale/%/stamp
373locale/%/$(DMSGS):	locale/%/stamp
374locale/%/$(DMON):	locale/%/stamp
375locale/%/$(DNUM):	locale/%/stamp
376locale/%/$(DTIME):	locale/%/stamp
377
378UTF-8.cm: data/UTF-8.cm
379	$(LN) -sf data/UTF-8.cm  $@
380
381UTF-8.ct: data/ctype.sh data/manual-input.UTF-8 $(UTF8SRCS)
382	$(SH) data/ctype.sh $(UTF8SRCS) > $@
383
384GB18030.cm: data/GB18030.cm
385	$(LN) -sf data/GB18030.cm  $@
386
387%.cm: data/%.TXT UTF-8.cm
388	$(RM) $@
389	$(PERL) data/convert_map.pl $< > $@
390
391$(ROOTDATA):	$(ROOTLOCDIRS) $(ROOTCATDIRS) $(DATA)
392	$(RM) $@
393	$(CP) $(@:$(ROOTLIB)/%=%) $@
394	$(CHMOD) 0444 $@
395
396%.mo: %.po
397	$(MSGFMT) -o $@ $<
398
399$(ROOTLIB)/locale/%/$(OSTMOFILE): $(TRANSDIR)/%.mo
400	$(INS.rename)
401	$(CHMOD) 0444 $@
402
403$(ROOTLIB)/locale/%/$(PRIVFILE): $(TRANSDIR)/%.priv
404	$(INS.rename)
405	$(CHMOD) 0444 $@
406