summaryrefslogtreecommitdiffstats
path: root/common/entities/Makefile
blob: a17f74c307cb861cc3bb2069644b0cdfaf52e48d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
PRI_LANG=en_US
OTHERS =bn_IN ca cs da de el en es fi fr gu hi_IN hr hu it ja ml ms nb nl pa pl pt_BR pt ru sk sr sr_Latn sv ta uk zh_CN zh_TW

#######################################################################
# PLEASE:
# TRANSLATORS SHOULD NOT MAKE ANY CHANGES BELOW THIS LINE.
# THANK YOU.
#######################################################################

#######################################################################
# Populate make(1) with only those suffixes of interest to us
#
.SUFFIXES:
.SUFFIXES:	.ent	.po	.pot	.xml	.xsl
#
#######################################################################

#######################################################################
# Define macros to explicitly instantiate the files to work with
#
OTHERXMLFILES=$(foreach L,${OTHERS},entities-${L}.xml)
POFILES=$(foreach L,${OTHERS},po/${L}.po)
ENTFILES=$(foreach L,${PRI_LANG} ${OTHERS},entities-${L}.ent)
#
#######################################################################

#######################################################################
# Printf(1) format string for describing targets by "make help".
HELPFMT	="%-23s\t| %s.\n"
#
#######################################################################

#######################################################################
FDPCOMMONDIR:=$(shell cd .. && /bin/pwd)
#######################################################################

#######################################################################
# WARNING: put no targets before this one!
#
.PHONY:	all
all::	${ENTFILES}
#######################################################################

#######################################################################
# Target 'help' displays the available targets
#
.PHONY:	help
help::
	@printf ${HELPFMT} "make all" 	"Generate .ENT files"
	@printf ${HELPFMT} "make help" 	"Display this list"
#
#######################################################################

#######################################################################
# Target 'entities.pot' makes a seed translation file.  We
# use the original-language entities XML file as the source.
#
.PHONY:	pot

pot po/entities.pot:: entities-${PRI_LANG}.xml
	xml2po -o po/entities.pot $<

distclean::
	${RM} po/entities.pot

help::
	@printf ${HELPFMT} "make pot" 		"Create template PO file"
	@printf ${HELPFMT} "make po/entities.pot" "Create template PO file"
#
#######################################################################

#######################################################################
# 'PO_template' emits rules to update the locale-specific .PO file
# whenever the "entities-${PRI_LANG}.xml", and therefore the 
# "entities.pot" file, is changed.
#
define	PO_template
.PHONY:	po-${1}
.PRECIOUS: po/${1}.po
po-${1}:: po/${1}.po
po/${1}.po:: po/entities.pot
	if [ ! -f po/${1}.po ]; then					\
		cp $$< po/${1}.po;					\
	else								\
		msgmerge --update --backup=simple po/${1}.po $$<;	\
	fi

postat-${1}::
	@echo "${1}: $(shell msgfmt --stat po/${1}.po 2>&1 | \
                sed 's@[^0-9]\+@/@g')"

help::
	@printf ${HELPFMT} "make po-${1}"	"Generate .PO file for locale '${1}'"
	@printf ${HELPFMT} "make po/${1}.po"	"Generate '${1}.po' file"
endef

$(foreach L,${OTHERS},$(eval $(call PO_template,${L})))

.PHONY:	po-all po
po-all po:	${foreach L,${OTHERS},po/${L}.po}
postat:  	$(foreach L,${OTHERS},postat-${L})

help::
	@printf ${HELPFMT} "make po-all"	"Generate all .PO files"
#
#######################################################################

#######################################################################
# 'UPDATE_template' generates the rules to derive the translated XML
# files based on the "entities-${PRI_LANG}.xml" file and the selected
# "${LANG}.po" file.
#
define UPDATE_template
.PHONY:	xml-${1}
xml-${1}:: entities-${1}.xml
entities-${1}.xml:: entities-${PRI_LANG}.xml po/${1}.po
	xml2po -p po/${1}.po entities-${PRI_LANG}.xml >entities-${1}.xml

help::
	@printf ${HELPFMT} "make xml-${1}"	"Translate XML for locale '${1}'"
	@printf ${HELPFMT} "make entities-${1}.xml" "Build 'entities-${1}.xml' file"
endef

.PHONY:	xml-${PRI_LANG}
xml-${PRI_LANG}:: entities-${PRI_LANG}.xml

$(foreach L,${OTHERS},$(eval $(call UPDATE_template,${L})))

.PHONY:	xml-all
xml-all:: $(foreach L,${OTHERS},entities-${L}.xml)

help::
	@printf ${HELPFMT} "make xml-all"	"Translate XML for all locales"
#
#######################################################################


#######################################################################
# Target 'showvars' displays both provided and computed macro values
#
.PHONY:	showvars
showvars::
	@echo "PRI_LANG=${PRI_LANG}"
	@echo "OTHERS=${OTHERS}"
	@echo "OTHERXMLFILES=${OTHERXMLFILES}"
	@echo "ENTFILES=${ENTFILES}"
	@echo "POFILES=${POFILES}"
	@echo "FDPCOMMONDIR=${FDPCOMMONDIR}"
help::
	@printf ${HELPFMT} "make showvars"	"Show certain macro values"
#
#######################################################################

#######################################################################
# Target 'clean' deletes all temporary files.
#
.PHONY:	clean
clean::
	${RM} *~
	${RM} ${OTHERXMLFILES}

help::
	@printf ${HELPFMT} "make clean"	"Delete all temporary files"
#
#######################################################################

#######################################################################
# Target 'distclean' or 'clobber' deletes all generated product files
# in addition to all temporary files.
#
.PHONY:	distclean clobber
distclean clobber:: clean
	${RM} ${ENTFILES}

help::
	@printf ${HELPFMT} "make distclean" "Delete all generated files"
	@printf ${HELPFMT} "make clobber"   "Delete all generated files"
#
#######################################################################

#######################################################################
define	ENT_template
entities-${1}.ent::	entities-${1}.xml po/entities.pot
	xsltproc -o $$@ --stringparam FDPCOMMONDIR "${FDPCOMMONDIR}" \
		--stringparam LANG "${1}" \
		entities.xsl entities-${1}.xml
endef
$(foreach L,${PRI_LANG} ${OTHERS},$(eval $(call ENT_template,${L})))
#######################################################################