xref: /titanic_51/usr/src/cmd/localedef/Makefile (revision 3c9168fa8e9c30d55b3aa2fde74bd7da46df53f5)
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)
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
41NATIVELDLIBS	+= -lgen
42
43#
44# Unfortunately, we have a chicken and an egg problem. libavl is becoming
45# public, which means that all of its symbols are in a version that the build
46# machine doesn't have and traditionally there has been no libavl compilation
47# symlink. Therefore, because we know that we only support building on illumos,
48# we regrettably have to link explicitly against the full library path. Sorry.
49#
50NATIVELDLIBS	+= /usr/lib/libavl.so.1
51YFLAGS		= -d -b parser
52
53CLEANFILES	= $(NOBJS) $(OBJS) parser.tab.c parser.tab.h
54CLEANFILES	+= \
55		UTF-8.cm UTF-8.ct \
56		8859-1.cm 8859-2.cm 8859-3.cm 8859-4.cm \
57		8859-5.cm 8859-5.cm 8859-6.cm 8859-7.cm \
58		8859-8.cm 8859-9.cm 8859-9.cm 8859-10.cm \
59		8859-11.cm 8859-13.cm 8859-14.cm 8859-15.cm \
60		8859-16.cm \
61		KOI8-R.cm
62CLOBBERFILES	= $(PROG) $(NPROG) $(POFILE) \
63		GB18030.cm UTF-8.cm
64
65PIFILES		= $(OBJS:%.o=%.i)
66POFILE		= localedef_cmd.po
67
68ISO8859_1_LOCALES	= \
69		da_DK \
70		de_CH de_DE \
71		en_AU en_CA en_GB en_NZ en_US \
72		es_AR es_BO es_CL es_CO es_EC es_ES es_GT es_MX es_NI es_PA \
73		es_PE es_SV es_UY es_VE \
74		fr_CA fr_CH fr_FR \
75		is_IS \
76		it_CH it_IT \
77		sv_SE
78
79ISO8859_2_LOCALES	= \
80		cs_CZ \
81		hr_HR \
82		hu_HU \
83		pl_PL \
84		sq_AL
85
86ISO8859_5_LOCALES	= \
87		bg_BG \
88		mk_MK \
89		ru_RU
90
91ISO8859_6_LOCALES	=
92
93ISO8859_7_LOCALES	= \
94		el_GR
95
96ISO8859_9_LOCALES	= \
97		tr_TR
98
99ISO8859_11_LOCALES	= \
100		th_TH
101
102ISO8859_13_LOCALES	= \
103		lt_LT \
104		lv_LV
105
106ISO8859_15_LOCALES	= \
107		ca_ES \
108		da_DK \
109		de_AT de_DE \
110		en_GB en_IE en_US \
111		es_ES \
112		fi_FI \
113		fr_BE fr_FR \
114		it_IT \
115		nl_BE nl_NL \
116		pt_PT \
117		sv_FI sv_SE
118
119KOI8_R_LOCALES		= \
120		ru_RU
121
122GB18030_LOCALES		= \
123		zh_CN
124
125#
126# All new locales should be in UTF-8 form.
127#
128UTF_8_LOCALES		= \
129		af_ZA \
130		ar_AE ar_BH ar_DZ ar_EG ar_IQ ar_JO ar_KW ar_LB ar_LY ar_MA \
131		ar_OM ar_QA ar_SA ar_TN ar_YE \
132		as_IN \
133		az_AZ \
134		be_BY \
135		bg_BG \
136		bn_BD bn_IN \
137		bo_CN bo_IN \
138		bs_BA \
139		ca_ES \
140		cs_CZ \
141		da_DK \
142		de_AT de_BE de_CH de_DE de_LI de_LU \
143		el_CY el_GR \
144		en_AU en_BW en_BZ en_CA en_GB en_HK en_IE en_IN en_JM en_MH \
145		en_MT en_NA en_NZ en_PH en_PK en_SG en_TT en_US en_ZA en_ZW \
146		es_AR es_BO es_CL es_CO es_CR es_DO es_EC es_ES es_GQ es_GT \
147		es_HN es_MX es_NI es_PA es_PE es_PR es_PY es_SV es_US es_UY \
148		es_VE \
149		et_EE \
150		fi_FI \
151		fil_PH \
152		fr_BE fr_CA fr_CF fr_CH fr_FR fr_GN fr_LU fr_MC fr_MG fr_ML \
153		fr_NE fr_SN \
154		ga_IE \
155		gu_IN \
156		he_IL \
157		hi_IN \
158		hr_HR \
159		hu_HU \
160		hy_AM \
161		id_ID \
162		ii_CN \
163		is_IS \
164		it_CH it_IT \
165		ja_JP \
166		ka_GE \
167		kk_KZ \
168		km_KH \
169		kn_IN \
170		ko_KR \
171		kok_IN \
172		lt_LT \
173		lv_LV \
174		mk_MK \
175		ml_IN \
176		mn_CN mn_MN \
177		mr_IN \
178		ms_MY \
179		mt_MT \
180		ne_IN ne_NP \
181		nl_BE nl_NL \
182		nb_NO \
183		nn_NO \
184		or_IN \
185		pa_IN pa_PK \
186		pl_PL \
187		pt_BR pt_GW pt_MZ pt_PT \
188		ro_MD ro_RO \
189		ru_MD ru_RU ru_UA \
190		sa_IN \
191		si_LK \
192		sk_SK \
193		sl_SI \
194		sq_AL \
195		sr_BA sr_ME sr_RS \
196		sv_FI sv_SE \
197		ta_IN ta_LK \
198		te_IN \
199		th_TH \
200		tr_TR \
201		uk_UA \
202		ug_CN \
203		ur_IN ur_PK \
204		vi_VN \
205		zh_CN zh_HK zh_MO zh_SG zh_TW
206
207UTF8SRCS	= $(UTF_8_LOCALES:%=data/%.UTF-8.src)
208
209LOCNAMES	= \
210		$(ISO8859_1_LOCALES:%=%.ISO8859-1) \
211		$(ISO8859_2_LOCALES:%=%.ISO8859-2) \
212		$(ISO8859_5_LOCALES:%=%.ISO8859-5) \
213		$(ISO8859_6_LOCALES:%=%.ISO8859-6) \
214		$(ISO8859_7_LOCALES:%=%.ISO8859-7) \
215		$(ISO8859_9_LOCALES:%=%.ISO8859-9) \
216		$(ISO8859_11_LOCALES:%=%.ISO8859-11) \
217		$(ISO8859_13_LOCALES:%=%.ISO8859-13) \
218		$(ISO8859_15_LOCALES:%=%.ISO8859-15) \
219		$(KOI8_R_LOCALES:%=%.KOI8-R) \
220		$(GB18030_LOCALES:%=%.GB18030) \
221		$(UTF_8_LOCALES:%=%.UTF-8)
222
223LOCDIRS		= $(LOCNAMES:%=locale/%)
224
225STAMPFILES	= $(LOCDIRS:%=%/stamp)
226
227CATDIRS		= \
228		$(LOCDIRS:%=%/LC_COLLATE) \
229		$(LOCDIRS:%=%/LC_CTYPE) \
230		$(LOCDIRS:%=%/LC_MESSAGES) \
231		$(LOCDIRS:%=%/LC_MONETARY) \
232		$(LOCDIRS:%=%/LC_NUMERIC) \
233		$(LOCDIRS:%=%/LC_TIME)
234
235DATA		= $(CATDIRS:%=%/LCL_DATA)
236
237DCOLL		= LC_COLLATE/LCL_DATA
238DCTYPE		= LC_CTYPE/LCL_DATA
239DMSGS		= LC_MESSAGES/LCL_DATA
240DMON		= LC_MONETARY/LCL_DATA
241DNUM		= LC_NUMERIC/LCL_DATA
242DTIME		= LC_TIME/LCL_DATA
243
244ROOTLOCDIRS	= $(LOCDIRS:%=$(ROOTLIB)/%)
245ROOTCATDIRS	= $(CATDIRS:%=$(ROOTLIB)/%)
246ROOTDATA	= $(DATA:%=$(ROOTLIB)/%)
247
248$(ROOTDATA)	:= FILEMODE=0444
249
250all: $(PROG) $(DATA)
251
252install: all $(ROOTPROG) $(ROOTDATA)
253
254$(NDIR):
255	mkdir $@
256
257$(NDIR)/%.o: %.c
258	$(NATIVECC) $(NATIVE_CFLAGS) $(NATIVE_CPPFLAGS) -o $@ -c $<
259	$(POST_PROCESS_O)
260
261$(NPROG): $(NDIR) .WAIT $(NOBJS)
262	$(LINK.c) $(NOBJS) -o $@ $(NATIVELDLIBS)
263	$(POST_PROCESS)
264
265$(PROG): $(OBJS)
266	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
267	$(POST_PROCESS)
268
269$(OBJS) $(NOBJS):	parser.tab.h
270
271parser.tab.c parser.tab.h: parser.y $(HDRS)
272	$(YACC) $(YFLAGS) parser.y
273
274lint:	$(SRCS)
275	$(LINT.c) $(CPPFLAGS) $(SRCS)
276
277clean:
278	$(RM) $(CLEANFILES)
279	$(RM) $(STAMPFILES)
280
281clobber: clean
282	$(RM) $(CLOBBERFILES)
283	$(RM) -r $(LOCDIRS)
284	$(RM) -r $(NDIR)
285
286$(POFILE):	$(PIFILES)
287	$(RM) $@
288	$(RM) messages.po
289	$(XGETTEXT) -s $(PIFILES)
290	$(SED) -e '/domain/d' messages.po > $@
291	$(RM) $(PIFILES) messages.po
292
293locale $(ROOTLOCDIRS) $(ROOTCATDIRS):
294	$(INS.dir)
295
296$(ROOTBIN)/%: $(ROOTBIN) %
297	$(INS.file)
298
299# Strip LC_CTYPE contents for UTF-8 locales and replace them
300# with UTF-8.ct we compiled
301locale/%.UTF-8/stamp:		data/%.UTF-8.src UTF-8.cm \
302				UTF-8.ct locale $(NPROG)
303	$(SED) '/^LC_CTYPE/,/^END LC_CTYPE/d;$$r UTF-8.ct' $< | \
304		./$(NPROG) -U -w data/widths.txt -f UTF-8.cm $(@D)
305	$(TOUCH) $@
306# Convert EURO_SIGN to CURRENCY_SIGN for the ISO8859-1 locales
307locale/%.ISO8859-1/stamp:	data/%.UTF-8.src 8859-1.cm locale $(NPROG)
308	sed 's/EURO_SIGN/CURRENCY_SIGN/' $< > $<.tmp
309	./$(NPROG) -U -w data/widths.txt -i $<.tmp -f 8859-1.cm $(@D)
310	rm -f $<.tmp
311	$(TOUCH) $@
312locale/%.ISO8859-2/stamp:	data/%.UTF-8.src 8859-2.cm locale $(NPROG)
313	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-2.cm $(@D)
314	$(TOUCH) $@
315locale/%.ISO8859-5/stamp:	data/%.UTF-8.src 8859-5.cm locale $(NPROG)
316	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-5.cm $(@D)
317	$(TOUCH) $@
318locale/%.ISO8859-7/stamp:	data/%.UTF-8.src 8859-7.cm locale $(NPROG)
319	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-7.cm $(@D)
320	$(TOUCH) $@
321locale/%.ISO8859-6/stamp:	data/%.UTF-8.src 8859-6.cm locale $(NPROG)
322	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-6.cm $(@D)
323	$(TOUCH) $@
324locale/%.ISO8859-9/stamp:	data/%.UTF-8.src 8859-9.cm locale $(NPROG)
325	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-9.cm $(@D)
326	$(TOUCH) $@
327locale/%.ISO8859-11/stamp:	data/%.UTF-8.src 8859-11.cm locale $(NPROG)
328	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-11.cm $(@D)
329	$(TOUCH) $@
330locale/%.ISO8859-13/stamp:	data/%.UTF-8.src 8859-13.cm locale $(NPROG)
331	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-13.cm $(@D)
332	$(TOUCH) $@
333locale/%.ISO8859-15/stamp:	data/%.UTF-8.src 8859-15.cm locale $(NPROG)
334	./$(NPROG) -U -w data/widths.txt -i $< -f 8859-15.cm $(@D)
335	$(TOUCH) $@
336locale/%.KOI8-R/stamp:		data/%.UTF-8.src KOI8-R.cm locale $(NPROG)
337	./$(NPROG) -U -w data/widths.txt -i $< -f KOI8-R.cm $(@D)
338	$(TOUCH) $@
339locale/%.GB18030/stamp:		data/%.UTF-8.src GB18030.cm locale $(NPROG)
340	./$(NPROG) -U -w data/widths.txt -i $< -f GB18030.cm $(@D)
341	$(TOUCH) $@
342
343locale/%/$(DCOLL):	locale/%/stamp
344locale/%/$(DCTYPE):	locale/%/stamp
345locale/%/$(DMSGS):	locale/%/stamp
346locale/%/$(DMON):	locale/%/stamp
347locale/%/$(DNUM):	locale/%/stamp
348locale/%/$(DTIME):	locale/%/stamp
349
350UTF-8.cm: data/UTF-8.cm
351	$(LN) -sf data/UTF-8.cm  $@
352
353UTF-8.ct: $(UTF8SRCS)
354	$(SH) data/ctype.sh $(UTF8SRCS) > $@
355
356GB18030.cm: data/GB18030.cm
357	$(LN) -sf data/GB18030.cm  $@
358
359%.cm: data/%.TXT UTF-8.cm
360	$(RM) $@
361	$(PERL) data/convert_map.pl $< > $@
362
363$(ROOTDATA):	$(ROOTLOCDIRS) $(ROOTCATDIRS) $(DATA)
364	$(RM) $@
365	$(CP) $(@:$(ROOTLIB)/%=%) $@
366	$(CHMOD) 0444 $@
367