1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # ThesaurusIndexTarget class
12 gb_ThesaurusIndexTarget_CHECK_TARGET
:= $(SRCDIR
)/dictionaries
/util
/th_check.pl
13 gb_ThesaurusIndexTarget_CHECK_COMMAND
:= PERL_UNICODE
=0 $(PERL
) -w
$(gb_ThesaurusIndexTarget_CHECK_TARGET
)
14 gb_ThesaurusIndexTarget_INDEX_DEPS
:= $(call gb_Executable_get_runtime_dependencies
,idxdict
)
15 gb_ThesaurusIndexTarget_INDEX_COMMAND
:= $(call gb_Executable_get_command
,idxdict
)
17 define gb_ThesaurusIndexTarget__command
18 $(call gb_Output_announce
,$(2),$(true
),THI
,1)
19 $(call gb_Helper_abbreviate_dirs
,\
20 $(gb_ThesaurusIndexTarget_INDEX_COMMAND
) -o
$(1) < $(THESAURUS_FILE
) \
23 #$(gb_ThesaurusIndexTarget_CHECK_COMMAND) $(THESAURUS_FILE) && \
25 $(dir $(call gb_ThesaurusIndexTarget_get_target
,%)).
dir :
26 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
28 $(dir $(call gb_ThesaurusIndexTarget_get_target
,%))%/.
dir :
29 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
31 $(call gb_ThesaurusIndexTarget_get_target
,%) : $(gb_ThesaurusIndexTarget_INDEX_DEPS
) |
$(gb_ThesaurusIndexTarget_CHECK_TARGET
)
32 $(call gb_ThesaurusIndexTarget__command
,$@
,$*)
34 .PHONY
: $(call gb_ThesaurusIndexTarget_get_clean_target
,%)
35 $(call gb_ThesaurusIndexTarget_get_clean_target
,%) :
36 $(call gb_Output_announce
,$*,$(false
),THI
,1)
37 $(call gb_Helper_abbreviate_dirs
,\
38 rm -f
$(call gb_ThesaurusIndexTarget_get_target
,$*) \
41 # Creates an index for a given thesaurus
43 # The thesaurus' file path is relative to $(SRCDIR).
45 # gb_ThesaurusIndexTarget_ThesaurusIndexTarget thesaurus
46 define gb_ThesaurusIndexTarget_ThesaurusIndexTarget
47 $(call gb_ThesaurusIndexTarget_get_target
,$(1)) : THESAURUS_FILE
:= $(SRCDIR
)/$(1)
48 $(call gb_ThesaurusIndexTarget_get_target
,$(1)) : $(SRCDIR
)/$(1)
49 $(call gb_ThesaurusIndexTarget_get_target
,$(1)) :|
$(dir $(call gb_ThesaurusIndexTarget_get_target
,$(1))).
dir
53 # PropertiesTranslateTarget class
55 # Handles translation of .properties files in dictionaries.
57 gb_PropertiesTranslateTarget_COMMAND
:= $(call gb_Executable_get_command
,propex
)
58 gb_PropertiesTranslateTarget_DEPS
:= $(call gb_Executable_get_runtime_dependencies
,propex
)
60 define gb_PropertiesTranslateTarget__command
61 $(call gb_Output_announce
,$(2),$(true
),PRP
,1)
62 $(call gb_Helper_abbreviate_dirs
, \
63 $(if
$(filter-out qtz
,$(LANG
)), \
64 MERGEINPUT
=$(call var2file
,$(shell $(gb_MKTEMP
)),100,$(POFILE
)) && \
65 $(gb_PropertiesTranslateTarget_COMMAND
) \
66 -i
$(PROPERTIES_FILE
) \
70 rm -f
$${MERGEINPUT} \
72 $(gb_PropertiesTranslateTarget_COMMAND
) \
73 -i
$(PROPERTIES_FILE
) \
81 $(dir $(call gb_PropertiesTranslateTarget_get_target
,%)).
dir :
82 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
84 $(dir $(call gb_PropertiesTranslateTarget_get_target
,%))%/.
dir :
85 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
87 $(call gb_PropertiesTranslateTarget_get_target
,%) : $(gb_PropertiesTranslateTarget_DEPS
)
88 $(call gb_PropertiesTranslateTarget__command
,$@
,$*)
90 .PHONY
: $(call gb_PropertiesTranslateTarget_get_clean_target
,%)
91 $(call gb_PropertiesTranslateTarget_get_clean_target
,%) :
92 $(call gb_Output_announce
,$*,$(false
),PRP
,1)
93 rm -f
$(call gb_PropertiesTranslateTarget_get_target
,$*)
95 # gb_PropertiesTranslateTarget_PropertiesTranslateTarget target source lang
96 define gb_PropertiesTranslateTarget_PropertiesTranslateTarget
97 $(call gb_PropertiesTranslateTarget_get_target
,$(1)) : LANG
:= $(3)
98 $(call gb_PropertiesTranslateTarget_get_target
,$(1)) : POFILE
:= $(gb_POLOCATION
)/$(3)/$(patsubst %/,%,$(dir $(2))).po
99 $(call gb_PropertiesTranslateTarget_get_target
,$(1)) : PROPERTIES_FILE
:= $(SRCDIR
)/$(2)
101 $(call gb_PropertiesTranslateTarget_get_target
,$(1)) : $(SRCDIR
)/$(2)
102 $(call gb_PropertiesTranslateTarget_get_target
,$(1)) :|
$(dir $(call gb_PropertiesTranslateTarget_get_target
,$(1))).
dir
104 $(if
$(filter-out qtz
,$(3)),\
105 $(call gb_PropertiesTranslateTarget__PropertiesTranslateTarget_onelang
,$(1),$(gb_POLOCATION
)/$(3)/$(patsubst %/,%,$(dir $(2))).po
) \
110 # gb_PropertiesTranslateTarget__PropertiesTranslateTarget_onelang target pofile
111 define gb_PropertiesTranslateTarget__PropertiesTranslateTarget_onelang
112 $(call gb_PropertiesTranslateTarget_get_target
,$(1)) : $(2)
117 # DescriptionTranslateTarget class
119 # Handles translation of description.xml files in dictionaries.
121 gb_DescriptionTranslateTarget_COMMAND
:= $(call gb_Executable_get_command
,xrmex
)
122 gb_DescriptionTranslateTarget_DEPS
:= $(call gb_Executable_get_runtime_dependencies
,xrmex
)
124 define gb_DescriptionTranslateTarget__command
125 $(call gb_Output_announce
,$(2),$(true
),XRM
,1)
126 $(call gb_Helper_abbreviate_dirs
,\
127 MERGEINPUT
=$(call var2file
,$(shell $(gb_MKTEMP
)),100,$(POFILES
)) && \
128 $(gb_DescriptionTranslateTarget_COMMAND
) \
129 -i
$(DESCRIPTION_XML
) \
133 rm -f
$${MERGEINPUT} \
137 $(dir $(call gb_DescriptionTranslateTarget_get_target
,%)).
dir :
138 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
140 $(dir $(call gb_DescriptionTranslateTarget_get_target
,%))%/.
dir :
141 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
143 $(call gb_DescriptionTranslateTarget_get_target
,%) : $(gb_DescriptionTranslateTarget_DEPS
)
144 $(call gb_DescriptionTranslateTarget__command
,$@
,$*)
146 .PHONY
: $(call gb_DescriptionTranslateTarget_get_clean_target
,%)
147 $(call gb_DescriptionTranslateTarget_get_clean_target
,%) :
148 $(call gb_Output_announce
,$*,$(false
),XRM
,1)
149 rm -f
$(call gb_DescriptionTranslateTarget_get_target
,$*)
151 # gb_DescriptionTranslateTarget_DescriptionTranslateTarget target source langs
152 define gb_DescriptionTranslateTarget_DescriptionTranslateTarget
153 $(call gb_DescriptionTranslateTarget_get_target
,$(1)) : DESCRIPTION_XML
:= $(SRCDIR
)/$(2)
154 $(call gb_DescriptionTranslateTarget_get_target
,$(1)) : POFILES
:=
156 $(call gb_DescriptionTranslateTarget_get_target
,$(1)) : $(SRCDIR
)/$(2)
157 $(call gb_DescriptionTranslateTarget_get_target
,$(1)) :|
$(dir $(call gb_DescriptionTranslateTarget_get_target
,$(1))).
dir
159 $(foreach lang
,$(3),\
160 $(call gb_DescriptionTranslateTarget__DescriptionTranslateTarget_onelang
,$(1),$(patsubst %/,%,$(dir $(2))),$(lang
)) \
165 # gb_DescriptionTranslateTarget__DescriptionTranslateTarget_onelang target pobase lang
166 define gb_DescriptionTranslateTarget__DescriptionTranslateTarget_onelang
167 $(call gb_DescriptionTranslateTarget_get_target
,$(1)) : POFILES
+= $(if
$(filter-out qtz
,$(3)),$(gb_POLOCATION
)/$(3)/$(2).po
)
168 $(if
$(filter-out qtz
,$(3)),\
169 $(call gb_DescriptionTranslateTarget__DescriptionTranslateTarget_onelang_podeps
,$(1),$(gb_POLOCATION
)/$(3)/$(2).po
))
173 # gb_DescriptionTranslateTarget__DescriptionTranslateTarget_onelang_podeps target pofile
174 define gb_DescriptionTranslateTarget__DescriptionTranslateTarget_onelang_podeps
175 $(call gb_DescriptionTranslateTarget_get_target
,$(1)) : $(2)
182 # Handles creation and delivery of dictionary extensions.
184 # This class provides a filelist called Dictionary/<name> that contains
185 # all installed files of the dictionary.
187 gb_Dictionary_ALL_LANGS
:= $(filter-out en-US
,$(gb_WITH_LANG
))
188 gb_Dictionary_INSTDIR
:= share
/extensions
190 $(dir $(call gb_Dictionary_get_target
,%)).
dir :
191 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
193 $(dir $(call gb_Dictionary_get_target
,%))%/.
dir :
194 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
196 $(call gb_Dictionary_get_target
,%) :
197 $(call gb_Output_announce
,$*,$(true
),DIC
,3)
200 .PHONY
: $(call gb_Dictionary_get_clean_target
,%)
201 $(call gb_Dictionary_get_clean_target
,%) :
202 $(call gb_Output_announce
,$*,$(false
),DIC
,3)
203 rm -f
$(call gb_Dictionary_get_target
,$*)
205 gb_Dictionary_get_packagename
= Dictionary
/$(1)
206 gb_Dictionary_get_packagesetname
= Dictionary
/$(1)
208 # Creates a dictionary extension
210 # gb_Dictionary_Dictionary dictionary srcdir
211 define gb_Dictionary_Dictionary
212 $(call gb_Package_Package_internal
,$(call gb_Dictionary_get_packagename
,$(1)),$(SRCDIR
))
213 $(call gb_Package_Package_internal
,$(call gb_Dictionary_get_packagename
,$(1)_generated
),$(WORKDIR
))
214 $(call gb_PackageSet_PackageSet_internal
,$(call gb_Dictionary_get_packagesetname
,$(1)))
216 $(call gb_Package_set_outdir
,$(call gb_Dictionary_get_packagename
,$(1)),$(INSTDIR
))
217 $(call gb_Package_set_outdir
,$(call gb_Dictionary_get_packagename
,$(1)_generated
),$(INSTDIR
))
218 $(call gb_PackageSet_add_package
,$(call gb_Dictionary_get_packagesetname
,$(1)),$(call gb_Dictionary_get_packagename
,$(1)))
220 ifeq (,$(gb_Dictionary_ALL_LANGS
))
221 $(call gb_Dictionary_add_root_file
,$(1),$(2)/description.xml
)
223 $(call gb_Dictionary__add_description_translations
,$(1),$(2)/description.xml
)
225 $(call gb_Dictionary_add_root_file
,$(1),$(2)/dictionaries.xcu
)
226 $(call gb_Dictionary_add_file
,$(1),META-INF
/manifest.xml
,$(2)/META-INF
/manifest.xml
)
228 $(call gb_Dictionary_get_target
,$(1)) : $(call gb_PackageSet_get_target
,$(call gb_Dictionary_get_packagesetname
,$(1)))
229 $(call gb_Dictionary_get_target
,$(1)) :|
$(dir $(call gb_Dictionary_get_target
,$(1))).
dir
230 $(call gb_Dictionary_get_clean_target
,$(1)) : $(call gb_PackageSet_get_clean_target
,$(call gb_Dictionary_get_packagesetname
,$(1)))
232 $$(eval
$$(call gb_Module_register_target
,$(call gb_Dictionary_get_target
,$(1)),$(call gb_Dictionary_get_clean_target
,$(1))))
233 $(call gb_Helper_make_userfriendly_targets
,$(1),Dictionary
)
237 # gb_Dictionary__add_description_translation_impl dictionary desctarget descxml
238 define gb_Dictionary__add_description_translation_impl
239 $(call gb_DescriptionTranslateTarget_DescriptionTranslateTarget
,$(2),$(3),$(gb_Dictionary_ALL_LANGS
))
240 $(call gb_Dictionary_add_generated_file
,$(1),description.xml
,$(call gb_DescriptionTranslateTarget_get_target
,$(2)))
242 $(call gb_Dictionary_get_target
,$(1)) : $(call gb_DescriptionTranslateTarget_get_target
,$(2))
243 $(call gb_Dictionary_get_clean_target
,$(1)) : $(call gb_DescriptionTranslateTarget_get_clean_target
,$(2))
247 # gb_Dictionary__add_description_translations dictionary descxml
248 define gb_Dictionary__add_description_translations
249 $(call gb_Dictionary__add_description_translation_impl
,$(1),$(basename $(2)),$(2))
253 # gb_Dictionary__add_file dictionary package-base destfile sourcefile
254 define gb_Dictionary__add_file
255 $(call gb_Package_add_file
,$(call gb_Dictionary_get_packagename
,$(2)),$(gb_Dictionary_INSTDIR
)/$(1)/$(3),$(4))
259 # Adds a file from $(SRCDIR) to the dictionary under chosen name
261 # gb_Dictionary_add_file dictionary destfile sourcefile
262 define gb_Dictionary_add_file
263 $(call gb_Dictionary__add_file
,$(1),$(1),$(2),$(3))
267 # Adds several files from $(SRCDIR) to the dictionary at once
269 # The files are put into the chosen directory.
271 # gb_Dictionary_add_files dictionary destdir file(s)
272 define gb_Dictionary_add_files
273 $(foreach file
,$(3),$(call gb_Dictionary_add_file
,$(1),$(2)/$(notdir $(file
)),$(file
)))
277 # Adds an arbitrary file to the dictionary under chosen name
279 # gb_Dictionary_add_file dictionary destfile sourcefile
280 define gb_Dictionary_add_generated_file
281 $(call gb_Dictionary__add_file
,$(1),$(1)_generated
,$(2),$(subst $(WORKDIR
)/,,$(3)))
282 $(call gb_PackageSet_add_package
,$(call gb_Dictionary_get_packagesetname
,$(1)),$(call gb_Dictionary_get_packagename
,$(1)_generated
))
286 # Adds several arbitrary files to the dictionary at once
288 # The files are put into the chosen directory.
290 # gb_Dictionary_add_files dictionary destdir file(s)
291 define gb_Dictionary_add_generated_files
292 $(foreach file
,$(3),$(call gb_Dictionary_add_generated_file
,$(1),$(2)/$(notdir $(file
)),$(file
)))
296 # Adds a localized xcu file, which needs special handling because it may be
297 # in $(WORKDIR) or $(SRCDIR) depending on whether translations are built.
299 # gb_Dictionary_add_localized_xcu_file dictionary destdir file
300 define gb_Dictionary_add_localized_xcu_file
301 ifeq ($(gb_WITH_LANG
),)
302 $(call gb_Dictionary__add_file
,$(1),$(1),$(2)/$(notdir $(3)),$(strip $(3)))
304 $(call gb_Dictionary__add_file
,$(1),$(1)_generated
,$(2)/$(notdir $(3)),$(subst $(WORKDIR
)/,,$(call gb_XcuFile_for_extension
,$(strip $(3)))))
305 $(call gb_PackageSet_add_package
,$(call gb_Dictionary_get_packagesetname
,$(1)),$(call gb_Dictionary_get_packagename
,$(1)_generated
))
310 # Adds a file to the root dir of the dictionary
312 # gb_Dictionary_add_root_file dictionary file
313 define gb_Dictionary_add_root_file
314 $(call gb_Dictionary_add_file
,$(1),$(notdir $(2)),$(2))
318 # Adds several files to the root dir of the dictionary
320 # gb_Dictionary_add_root_files dictionary file(s)
321 define gb_Dictionary_add_root_files
322 $(foreach file
,$(2),$(call gb_Dictionary_add_root_file
,$(1),$(file
)))
326 define gb_Dictionary__add_thesaurus
327 $(call gb_Dictionary__add_file
,$(1),$(1)_generated
,$(notdir $(3)),$(subst $(WORKDIR
)/,,$(3)))
328 $(call gb_PackageSet_add_package
,$(call gb_Dictionary_get_packagesetname
,$(1)),$(call gb_Dictionary_get_packagename
,$(1)_generated
))
332 # Adds a thesaurus to the dictionary
334 # An index for the thesaurus is generated and added to the dictionary as
337 # gb_Dictionary_add_thesaurus dictionary thesaurus
338 define gb_Dictionary_add_thesaurus
339 $(call gb_ThesaurusIndexTarget_ThesaurusIndexTarget
,$(2))
340 $(call gb_Dictionary_add_root_file
,$(1),$(2))
341 $(call gb_Dictionary__add_thesaurus
,$(1),$(2),$(call gb_ThesaurusIndexTarget_get_target
,$(2)))
345 # Adds several thesauri to the dictionary at once
347 # Indexes for the thesauri are generated and added to the dictionary as
350 # gb_Dictionary_add_thesauri dictionary thesauri
351 define gb_Dictionary_add_thesauri
352 $(foreach thesaurus
,$(2),$(call gb_Dictionary_add_thesaurus
,$(1),$(thesaurus
)))
356 # gb_Dictionary__translate_propertyfile_impl dictionary destfile propertyfile propertyname lang
357 define gb_Dictionary__translate_propertyfile_impl
358 $(call gb_PropertiesTranslateTarget_PropertiesTranslateTarget
,$(4),$(3),$(5))
359 $(call gb_Dictionary_add_generated_file
,$(1),$(2),$(call gb_PropertiesTranslateTarget_get_target
,$(4)))
363 # gb_Dictionary__translate_propertyfile dictionary destdir propertyfile propertyname lang
364 define gb_Dictionary__translate_propertyfile
365 $(call gb_Dictionary__translate_propertyfile_impl
,$(1),$(2)$(notdir $(4)).properties
,$(3),$(4),$(5))
369 # gb_Dictionary__add_propertyfile_translations dictionary destfile propertyfile
370 define gb_Dictionary__add_propertyfile_translations
371 $(foreach lang
,$(gb_Dictionary_ALL_LANGS
),$(call gb_Dictionary__translate_propertyfile
,$(1),$(dir $(2)),$(3),$(subst en_US
,$(subst -,_
,$(lang
)),$(basename $(3))),$(lang
)))
375 # Adds a .property file to the dictionary under chosen name
377 # The file is localized automatically.
379 # gb_Dictionary_add_propertyfile dictionary destfile propertyfile
380 define gb_Dictionary_add_propertyfile
381 $(call gb_Dictionary__add_file
,$(1),$(1),$(2),$(3))
382 $(call gb_Dictionary__add_propertyfile_translations
,$(1),$(2),$(3))
386 # Adds several .property files to the dictionary at once
388 # The files are put into chosen directory. They are localized automatically.
390 # gb_Dictionary_add_propertyfiles dictionary destdir propertyfile(s)
391 define gb_Dictionary_add_propertyfiles
392 $(foreach propertyfile
,$(3),$(call gb_Dictionary_add_propertyfile
,$(1),$(2)/$(notdir $(propertyfile
)),$(propertyfile
)))
396 # vim: set noet sw=4 ts=4: