xref: /titanic_52/usr/src/cmd/localedef/Makefile (revision bc09504ff1ed70f84c9713b732281f14a9ef49b2)
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 2011 Nexenta Systems, Inc.  All rights reserved.
14# Copyright 2011 EveryCity Ltd. All rights reserved.
15# Copyright 2013 DEY Storage Systems, Inc.
16# Copyright 2015 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
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
231DCOLL		= LC_COLLATE/LCL_DATA
232DCTYPE		= LC_CTYPE/LCL_DATA
233DMSGS		= LC_MESSAGES/LCL_DATA
234DMON		= LC_MONETARY/LCL_DATA
235DNUM		= LC_NUMERIC/LCL_DATA
236DTIME		= LC_TIME/LCL_DATA
237
238ROOTLOCDIRS	= $(LOCDIRS:%=$(ROOTLIB)/%)
239ROOTCATDIRS	= $(CATDIRS:%=$(ROOTLIB)/%)
240ROOTDATA	= $(DATA:%=$(ROOTLIB)/%)
241
242#
243# This is a list of locales that happen to have translations for them
244# present in the gate.
245#
246TRANSDIR	= translations
247TRANSLOCS	= \
248		zz_AA.UTF-8
249TRANSMOS	= $(TRANSLOCS:%=$(TRANSDIR)/%.mo)
250
251OSTMOFILE	= LC_MESSAGES/SUNW_OST_OSLIB.mo
252
253PRIVTRANSLOCS	= \
254		zz_AA.UTF-8
255PRIVFILE	= LC_MESSAGES/priv_names
256
257
258ROOTTRANSLATIONS = $(TRANSLOCS:%=$(ROOTLIB)/locale/%/$(OSTMOFILE))
259ROOTPRIVTRANS = $(PRIVTRANSLOCS:%=$(ROOTLIB)/locale/%/$(PRIVFILE))
260
261$(ROOTDATA)	:= FILEMODE=0444
262
263all: $(PROG) $(DATA)
264
265translate: $(ROOTTRANSLATIONS) $(ROOTPRIVTRANS)
266
267install: all $(ROOTPROG) $(ROOTDATA) $(ROOTTRANSLATIONS) $(ROOTPRIVTRANS)
268
269$(NDIR):
270	mkdir $@
271
272$(NDIR)/%.o: %.c
273	$(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c $<
274
275$(NDIR)/avl.o : ../../common/avl/avl.c
276	$(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c \
277	  ../../common/avl/avl.c
278
279$(NDIR)/mkdirp.o : ../../lib/libgen/common/mkdirp.c
280	$(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c \
281	  ../../lib/libgen/common/mkdirp.c
282
283$(NPROG): $(NDIR) .WAIT $(NOBJS)
284	$(LINK.c) $(NOBJS) -o $@ $(NATIVELDLIBS)
285	$(POST_PROCESS)
286
287$(PROG): $(OBJS)
288	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
289	$(POST_PROCESS)
290
291$(OBJS) $(NOBJS):	parser.tab.h
292
293parser.tab.c parser.tab.h: parser.y $(HDRS)
294	$(YACC) $(YFLAGS) parser.y
295
296lint:	$(SRCS)
297	$(LINT.c) $(CPPFLAGS) $(SRCS)
298
299clean:
300	$(RM) $(CLEANFILES)
301	$(RM) $(STAMPFILES)
302
303clobber: clean
304	$(RM) $(CLOBBERFILES)
305	$(RM) -r $(LOCDIRS)
306	$(RM) -r $(NDIR)
307	$(RM) $(TRANSMOS)
308
309$(POFILE):	$(PIFILES)
310	$(RM) $@
311	$(RM) messages.po
312	$(XGETTEXT) -s $(PIFILES)
313	$(SED) -e '/domain/d' messages.po > $@
314	$(RM) $(PIFILES) messages.po
315
316locale $(ROOTLOCDIRS) $(ROOTCATDIRS):
317	$(INS.dir)
318
319$(ROOTBIN)/%: $(ROOTBIN) %
320	$(INS.file)
321
322# Strip LC_CTYPE contents for UTF-8 locales and replace them
323# with UTF-8.ct we compiled
324locale/%.UTF-8/stamp:		data/%.UTF-8.src UTF-8.cm \
325				UTF-8.ct locale $(NPROG)
326	$(SED) '/^LC_CTYPE/,/^END LC_CTYPE/d;$$r UTF-8.ct' $< | \
327		./$(NPROG) -U -w data/widths.txt -f UTF-8.cm $(@D)
328	$(TOUCH) $@
329# Convert EURO_SIGN to CURRENCY_SIGN for the ISO8859-1 locales
330locale/%.ISO8859-1/stamp:	data/%.UTF-8.src 8859-1.cm locale $(NPROG)
331	sed 's/EURO_SIGN/CURRENCY_SIGN/' $< > $<.tmp
332	./$(NPROG) -U -w data/widths.txt -i $<.tmp -f 8859-1.cm $(@D)
333	rm -f $<.tmp
334	$(TOUCH) $@
335locale/%.ISO8859-2/stamp:	data/%.UTF-8.src 8859-2.cm locale $(NPROG)
336	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-2.cm $(@D)
337	$(TOUCH) $@
338locale/%.ISO8859-5/stamp:	data/%.UTF-8.src 8859-5.cm locale $(NPROG)
339	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-5.cm $(@D)
340	$(TOUCH) $@
341locale/%.ISO8859-7/stamp:	data/%.UTF-8.src 8859-7.cm locale $(NPROG)
342	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-7.cm $(@D)
343	$(TOUCH) $@
344locale/%.ISO8859-6/stamp:	data/%.UTF-8.src 8859-6.cm locale $(NPROG)
345	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-6.cm $(@D)
346	$(TOUCH) $@
347locale/%.ISO8859-9/stamp:	data/%.UTF-8.src 8859-9.cm locale $(NPROG)
348	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-9.cm $(@D)
349	$(TOUCH) $@
350locale/%.ISO8859-11/stamp:	data/%.UTF-8.src 8859-11.cm locale $(NPROG)
351	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-11.cm $(@D)
352	$(TOUCH) $@
353locale/%.ISO8859-13/stamp:	data/%.UTF-8.src 8859-13.cm locale $(NPROG)
354	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-13.cm $(@D)
355	$(TOUCH) $@
356locale/%.ISO8859-15/stamp:	data/%.UTF-8.src 8859-15.cm locale $(NPROG)
357	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-15.cm $(@D)
358	$(TOUCH) $@
359locale/%.KOI8-R/stamp:		data/%.UTF-8.src KOI8-R.cm locale $(NPROG)
360	./$(NPROG) -U -w data/widths.txt -i $< -f KOI8-R.cm $(@D)
361	$(TOUCH) $@
362locale/%.GB18030/stamp:		data/%.UTF-8.src GB18030.cm locale $(NPROG)
363	./$(NPROG) -U -w data/widths.txt -i $< -f GB18030.cm $(@D)
364	$(TOUCH) $@
365
366locale/%/$(DCOLL):	locale/%/stamp
367locale/%/$(DCTYPE):	locale/%/stamp
368locale/%/$(DMSGS):	locale/%/stamp
369locale/%/$(DMON):	locale/%/stamp
370locale/%/$(DNUM):	locale/%/stamp
371locale/%/$(DTIME):	locale/%/stamp
372
373UTF-8.cm: data/UTF-8.cm
374	$(LN) -sf data/UTF-8.cm  $@
375
376UTF-8.ct: $(UTF8SRCS)
377	$(SH) data/ctype.sh $(UTF8SRCS) > $@
378
379GB18030.cm: data/GB18030.cm
380	$(LN) -sf data/GB18030.cm  $@
381
382%.cm: data/%.TXT UTF-8.cm
383	$(RM) $@
384	$(PERL) data/convert_map.pl $< > $@
385
386$(ROOTDATA):	$(ROOTLOCDIRS) $(ROOTCATDIRS) $(DATA)
387	$(RM) $@
388	$(CP) $(@:$(ROOTLIB)/%=%) $@
389	$(CHMOD) 0444 $@
390
391%.mo: %.po
392	$(MSGFMT) -o $@ $<
393
394$(ROOTLIB)/locale/%/$(OSTMOFILE): $(TRANSDIR)/%.mo
395	$(INS.rename)
396	$(CHMOD) 0444 $@
397
398$(ROOTLIB)/locale/%/$(PRIVFILE): $(TRANSDIR)/%.priv
399	$(INS.rename)
400	$(CHMOD) 0444 $@
401