bump product version to 4.1.6.2
[LibreOffice.git] / solenv / gbuild / UIConfig.mk
blob52cffe59f1a5aab5d84c276458294d8a615e4691
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 # class UILocalizeTarget
12 # Produces translations for one .ui file.
14 gb_UILocalizeTarget_WORKDIR := $(WORKDIR)/UILocalizeTarget
16 gb_UILocalizeTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,uiex)
17 gb_UILocalizeTarget_COMMAND := $(call gb_Executable_get_command,uiex)
19 # If translatable strings from a .ui file are not merged into the
20 # respective .po file yet, the produced translated files are empty,
21 # which breaks delivery. This hack avoids the problem by creating a
22 # dummy translation file.
23 $(call gb_UILocalizeTarget_get_workdir,%).ui :
24 $(if $(wildcard $@) \
25 ,touch $@ \
26 ,echo '<?xml version="1.0"?><t></t>' > $@ \
29 define gb_UILocalizeTarget__command
30 $(call gb_Output_announce,$(2),$(true),UIX,1)
31 MERGEINPUT=`$(gb_MKTEMP)` && \
32 echo $(POFILES) > $${MERGEINPUT} && \
33 $(call gb_Helper_abbreviate_dirs,\
34 $(gb_UILocalizeTarget_COMMAND) \
35 -i $(UIConfig_FILE) \
36 -o $(call gb_UILocalizeTarget_get_workdir,$(2)) \
37 -l all \
38 -m $${MERGEINPUT} \
39 && touch $(1) \
40 ) && \
41 rm -rf $${MERGEINPUT}
42 endef
44 $(dir $(call gb_UILocalizeTarget_get_target,%)).dir :
45 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
47 $(dir $(call gb_UILocalizeTarget_get_target,%))%/.dir :
48 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
50 $(call gb_UILocalizeTarget_get_target,%) : $(gb_UILocalizeTarget_DEPS)
51 $(call gb_UILocalizeTarget__command,$@,$*)
53 .PHONY : $(call gb_UILocalizeTarget_get_clean_target,%)
54 $(call gb_UILocalizeTarget_get_clean_target,%) :
55 $(call gb_Output_announce,$*,$(false),UIX,1)
56 $(call gb_Helper_abbreviate_dirs,\
57 rm -rf $(call gb_UILocalizeTarget_get_target,$*) $(call gb_UILocalizeTarget_get_workdir,$*) \
60 # Produce translations for one .ui file
62 # gb_UILocalizeTarget_UILocalizeTarget target
63 define gb_UILocalizeTarget_UILocalizeTarget
64 $(call gb_UILocalizeTarget__UILocalizeTarget_impl,$(1),$(wildcard $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po)))
66 endef
68 # gb_UILocalizeTarget__UILocalizeTarget_impl target pofiles
69 define gb_UILocalizeTarget__UILocalizeTarget_impl
70 $(call gb_UILocalizeTarget_get_target,$(1)) : POFILES := $(2)
71 $(call gb_UILocalizeTarget_get_target,$(1)) : UIConfig_FILE := $(SRCDIR)/$(1).ui
73 $(call gb_UILocalizeTarget_get_target,$(1)) : $(2)
74 $(call gb_UILocalizeTarget_get_target,$(1)) : $(SRCDIR)/$(1).ui
75 $(call gb_UILocalizeTarget_get_target,$(1)) :| \
76 $(dir $(call gb_UILocalizeTarget_get_target,$(1))).dir \
77 $(call gb_UILocalizeTarget_get_workdir,$(1))/.dir
79 endef
81 # class UIMenubarTarget
83 # Handles platform-specific processing of menubar config files.
85 # defined by platform:
86 # gb_UIMenubarTarget_UIMenubarTarget_platform
87 # gb_UIMenubarTarget__command
89 $(dir $(call gb_UIMenubarTarget_get_target,%)).dir :
90 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
92 $(dir $(call gb_UIMenubarTarget_get_target,%))%/.dir :
93 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
95 $(call gb_UIMenubarTarget_get_target,%) :
96 $(call gb_UIMenubarTarget__command,$@,$*,$<)
98 .PHONY : $(call gb_UIMenubarTarget_get_clean_target,%)
99 $(call gb_UIMenubarTarget_get_clean_target,%) :
100 $(call gb_Output_announce,$(2),$(false),UIM,1)
101 rm -f $(call gb_UIMenubarTarget_get_target,$*)
103 # Process a menubar configuration file.
105 # gb_UIMenubarTarget_UIMenubarTarget target source
106 define gb_UIMenubarTarget_UIMenubarTarget
107 $(call gb_UIMenubarTarget_get_target,$(1)) : $(2)
108 $(call gb_UIMenubarTarget_get_target,$(1)) :| $(dir $(call gb_UIMenubarTarget_get_target,$(1))).dir
110 $(call gb_UIMenubarTarget_UIMenubarTarget_platform,$(1),$(2))
112 endef
114 # class UIImageListTarget
116 # Handles creation of image lists for .ui files.
118 gb_UIImageListTarget_COMMAND = $(call gb_ExternalExecutable_get_command,xsltproc)
119 gb_UIImageListTarget_DEPS = $(call gb_ExternalExecutable_get_dependencies,xsltproc)
120 gb_UIImageListTarget_XSLTFILE := $(SRCDIR)/solenv/bin/uiimagelist.xsl
122 # NOTE: for some reason xsltproc does not produce any file if there is
123 # no output, so we touch the target to make sure it exists.
124 define gb_UIImageListTarget__command
125 $(call gb_Output_announce,$(2),$(true),UIL,1)
126 $(call gb_Helper_abbreviate_dirs,\
127 $(gb_UIImageListTarget_COMMAND) -o $@ $(gb_UIImageListTarget_XSLTFILE) $(UIFILE) && \
128 touch $@ \
130 endef
132 $(dir $(call gb_UIImageListTarget_get_target,%)).dir :
133 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
135 $(dir $(call gb_UIImageListTarget_get_target,%))%/.dir :
136 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
138 $(call gb_UIImageListTarget_get_target,%) : $(gb_UIImageListTarget_DEPS) $(gb_UIImageListTarget_XSLTFILE)
139 $(call gb_UIImageListTarget__command,$@,$*)
141 .PHONY : $(call gb_UIImageListTarget_get_clean_target,%)
142 $(call gb_UIImageListTarget_get_clean_target,%) :
143 $(call gb_Output_announce,$(2),$(false),UIL,1)
144 rm -f $(call gb_UIImageListTarget_get_target,$*)
146 # Extract list of images referenced in a .ui file.
148 # gb_UIImageListTarget_UIImageListTarget uifile
149 define gb_UIImageListTarget_UIImageListTarget
150 $(call gb_UIImageListTarget_get_target,$(1)) : UIFILE := $(SRCDIR)/$(1).ui
152 $(call gb_UIImageListTarget_get_target,$(1)) : $(SRCDIR)/$(1).ui
153 $(call gb_UIImageListTarget_get_target,$(1)) :| $(dir $(call gb_UIImageListTarget_get_target,$(1))).dir
155 endef
157 # class UIConfig
159 # Handles UI configuration files.
161 # This mostly means UI description files (suffix .ui) for the new layouting
162 # mechanism.
164 # This class provides the following filelists:
165 # * UIConfig/<name> containing all nontranslatable files
166 # * UIConfig/<name>_<lang> for each active lang, containing translations
167 # of .ui files. This filelist only exists if the UIConfig contains any
168 # .ui files.
170 gb_UIConfig_INSTDIR := share/config/soffice.cfg
171 # en-US is the default, so there is no translation for it
172 gb_UIConfig_LANGS := $(filter-out en-US,$(gb_WITH_LANG))
174 $(dir $(call gb_UIConfig_get_target,%)).dir :
175 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
177 $(dir $(call gb_UIConfig_get_target,%))%/.dir :
178 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
180 $(call gb_UIConfig_get_target,%) : $(call gb_UIConfig_get_imagelist_target,%)
181 $(call gb_Output_announce,$*,$(true),UIC,2)
182 $(call gb_Helper_abbreviate_dirs,\
183 touch $@ \
186 $(call gb_UIConfig_get_imagelist_target,%) :
187 $(call gb_Helper_abbreviate_dirs,\
188 sort -u $(UI_IMAGELISTS) /dev/null > $@ \
191 .PHONY : $(call gb_UIConfig_get_clean_target,%)
192 $(call gb_UIConfig_get_clean_target,%) :
193 $(call gb_Output_announce,$*,$(false),UIC,2)
194 $(call gb_Helper_abbreviate_dirs,\
195 rm -f $(call gb_UIConfig_get_target,$*) \
198 gb_UIConfig_get_packagename = UIConfig/$(1)
199 gb_UIConfig_get_packagename_for_lang = UIConfig/$(1)_$(2)
200 gb_UIConfig_get_packagesetname = UIConfig/$(1)
202 # Processes and delivers a set of UI configuration files.
204 # gb_UIConfig_UIConfig modulename
205 define gb_UIConfig_UIConfig
206 $(call gb_UIConfig_get_imagelist_target,$(1)) : UI_IMAGELISTS :=
208 $(call gb_PackageSet_PackageSet_internal,$(call gb_UIConfig_get_packagesetname,$(1)))
209 $(call gb_Package_Package_internal,$(call gb_UIConfig_get_packagename,$(1)),$(SRCDIR))
210 $(call gb_Package_Package_internal,$(call gb_UIConfig_get_packagename,$(1)_generated),$(WORKDIR))
212 $(call gb_Package_set_outdir,$(call gb_UIConfig_get_packagename,$(1)),$(INSTDIR))
213 $(call gb_Package_set_outdir,$(call gb_UIConfig_get_packagename,$(1)_generated),$(INSTDIR))
214 $(call gb_PackageSet_add_package,$(call gb_UIConfig_get_packagesetname,$(1)),$(call gb_UIConfig_get_packagename,$(1)))
216 $(call gb_UIConfig_get_target,$(1)) :| $(dir $(call gb_UIConfig_get_target,$(1))).dir
217 $(call gb_UIConfig_get_imagelist_target,$(1)) :| $(dir $(call gb_UIConfig_get_imagelist_target,$(1))).dir
218 $(call gb_UIConfig_get_target,$(1)) : $(call gb_PackageSet_get_target,$(call gb_UIConfig_get_packagesetname,$(1)))
219 $(call gb_Postprocess_get_target,AllUIConfigs) : $(call gb_UIConfig_get_target,$(1))
220 $(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_PackageSet_get_clean_target,$(call gb_UIConfig_get_packagesetname,$(1)))
222 ifneq ($(gb_UIConfig_LANGS),)
223 $(foreach lang,$(gb_UIConfig_LANGS),$(call gb_UIConfig__UIConfig_for_lang,$(1),$(lang)))
224 endif
226 $$(eval $$(call gb_Module_register_target,$(call gb_UIConfig_get_target,$(1)),$(call gb_UIConfig_get_clean_target,$(1))))
227 $(call gb_Helper_make_userfriendly_targets,$(1),UIConfig)
229 endef
231 define gb_UIConfig__UIConfig_for_lang
232 $(call gb_Package_Package_internal,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(2)),$(gb_UILocalizeTarget_WORKDIR))
233 $(call gb_Package_set_outdir,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(2)),$(INSTDIR))
234 $(call gb_UIConfig_get_target,$(1)) : $(call gb_Package_get_target,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(2)))
235 $(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(2)))
237 endef
239 # gb_UIConfig__package_file target package type destfile srcfile
240 define gb_UIConfig__package_file
241 $(call gb_Package_add_file,$(2),$(gb_UIConfig_INSTDIR)/$(1)/$(3)/$(4),$(5))
243 endef
245 # gb_UIConfig__package_uifile target package destfile srcfile
246 define gb_UIConfig__package_uifile
247 $(call gb_UIConfig__package_file,$(1),$(2),ui,$(3),$(4))
249 endef
251 # gb_UIConfig__add_uifile target file
252 define gb_UIConfig__add_uifile
253 $(call gb_UIConfig__package_uifile,$(1),$(call gb_UIConfig_get_packagename,$(1)),$(notdir $(2)).ui,$(2).ui)
254 $(call gb_UIImageListTarget_UIImageListTarget,$(2))
256 $(call gb_UIConfig_get_imagelist_target,$(1)) : UI_IMAGELISTS += $(call gb_UIImageListTarget_get_target,$(2))
257 $(call gb_UIConfig_get_imagelist_target,$(1)) : $(call gb_UIImageListTarget_get_target,$(2))
258 $(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_UIImageListTarget_get_clean_target,$(2))
260 endef
262 # Add a l10n for an .ui file to respective lang package.
264 # gb_UIConfig__add_uifile_for_lang target file lang
265 define gb_UIConfig__add_uifile_for_lang
266 $(call gb_UIConfig__package_uifile,$(1),$(call gb_UIConfig_get_packagename_for_lang,$(1),$(3)),res/$(3)/$(notdir $(2)),$(2)/$(3).ui)
267 $(call gb_Package_get_preparation_target,$(call gb_UIConfig_get_packagename_for_lang,$(1),$(3))) : $(call gb_UILocalizeTarget_get_target,$(2))
269 endef
271 # Add a l10n for an .ui file to respective lang package.
273 # This is only for "real" languages, i.e., everything except qtz.
275 # gb_UIConfig__add_uifile_for_real_lang target file lang
276 define gb_UIConfig__add_uifile_for_real_lang
277 $(if $(filter qtz,$(3)),$(call gb_Output_error,gb_UIConfig__add_uifile_for_real_lang called with qtz))
278 $(call gb_UIConfig__add_uifile_for_lang,$(1),$(2),$(3))
280 endef
282 # gb_UIConfig__add_translations_impl target uifile langs
283 define gb_UIConfig__add_translations_impl
284 $(call gb_UILocalizeTarget_UILocalizeTarget,$(2))
285 $(call gb_UIConfig_get_target,$(1)) : $(call gb_UILocalizeTarget_get_target,$(2))
286 $(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_UILocalizeTarget_get_clean_target,$(2))
287 $(foreach lang,$(3),$(call gb_UIConfig__add_uifile_for_real_lang,$(1),$(2),$(lang)))
289 endef
291 # gb_UIConfig__add_translations target uifile langs qtz
292 define gb_UIConfig__add_translations
293 $(if $(strip $(3) $(4)),$(call gb_UIConfig__add_translations_impl,$(1),$(2),$(3)))
294 $(if $(strip $(4)),$(call gb_UIConfig__add_uifile_for_lang,$(1),$(2),$(strip $(4))))
296 endef
298 # Adds translations for languages that have corresponding .po file
300 # gb_UIConfig__add_uifile_translations target uifile
301 define gb_UIConfig__add_uifile_translations
302 $(call gb_UIConfig__add_translations,$(1),$(2),\
303 $(foreach lang,$(gb_UIConfig_LANGS),\
304 $(if $(wildcard $(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(2))).po),$(lang)) \
306 $(filter qtz,$(gb_UIConfig_LANGS)) \
309 endef
311 # Adds .ui file to the package
313 # The file is relative to $(SRCDIR) and without extension.
315 # gb_UIConfig_add_uifile target uifile
316 define gb_UIConfig_add_uifile
317 $(call gb_UIConfig__add_uifile,$(1),$(2))
319 ifneq ($(gb_UIConfig_LANGS),)
320 $(call gb_UIConfig__add_uifile_translations,$(1),$(2))
321 endif
323 endef
325 # Adds multiple .ui files to the package
327 # gb_UIConfig_add_uifiles target uifile(s)
328 define gb_UIConfig_add_uifiles
329 $(foreach uifile,$(2),$(call gb_UIConfig_add_uifile,$(1),$(uifile)))
331 endef
333 # gb_UIConfig__add_xmlfile target package-target type xmlfile
334 define gb_UIConfig__add_xmlfile
335 $(call gb_UIConfig__package_file,$(1),$(call gb_UIConfig_get_packagename,$(2)),$(3),$(notdir $(4)).xml,$(4).xml)
337 endef
339 define gb_UIConfig__add_menubarfile
340 $(call gb_UIMenubarTarget_UIMenubarTarget,$(2),$(3))
341 $(call gb_Package_add_file,$(call gb_UIConfig_get_packagename,$(1)_generated),$(gb_UIConfig_INSTDIR)/$(1)/menubar/$(notdir $(2)).xml,$(subst $(WORKDIR)/,,$(call gb_UIMenubarTarget_get_target,$(2))))
342 $(call gb_PackageSet_add_package,$(call gb_UIConfig_get_packagesetname,$(1)),$(call gb_UIConfig_get_packagename,$(1)_generated))
344 $(call gb_Package_get_target,$(call gb_UIConfig_get_packagename,$(1)_generated)) : $(call gb_UIMenubarTarget_get_target,$(2))
345 $(call gb_Package_get_clean_target,$(call gb_UIConfig_get_packagename,$(1)_generated)) : $(call gb_UIMenubarTarget_get_clean_target,$(2))
347 endef
349 # Add menubar config file to the package.
351 # The file is relative to $(SRCDIR) and without extension.
353 # gb_UIConfig_add_menubarfile target file
354 define gb_UIConfig_add_menubarfile
355 $(call gb_UIConfig__add_menubarfile,$(1),$(gb_UIConfig_INSTDIR)/$(1)/menubar/$(notdir $(2)),$(SRCDIR)/$(2).xml)
357 endef
359 # Adds multiple menubar config files to the package.
361 # gb_UIConfig_add_menubarfiles target file(s)
362 define gb_UIConfig_add_menubarfiles
363 $(foreach menubarfile,$(2),$(call gb_UIConfig_add_menubarfile,$(1),$(menubarfile)))
365 endef
367 # Add a generated menubar config file to the package.
369 # The file is relative to $(WORKDIR) and without extension.
371 # gb_UIConfig_add_generated_menubarfile target file
372 define gb_UIConfig_add_generated_menubarfile
373 $(call gb_UIConfig__add_menubarfile,$(1),$(gb_UIConfig_INSTDIR)/$(1)/menubar/$(notdir $(2)),$(WORKDIR)/$(2).xml)
375 endef
377 # Adds multiple menubar config files to the package.
379 # gb_UIConfig_add_generated_menubarfiles target file(s)
380 define gb_UIConfig_add_generated_menubarfiles
381 $(foreach menubarfile,$(2),$(call gb_UIConfig_add_generated_menubarfile,$(1),$(menubarfile)))
383 endef
385 # Add statusbar config file to the package.
387 # The file is relative to $(SRCDIR) and without extension.
389 # gb_UIConfig_add_statusbarfile target file
390 define gb_UIConfig_add_statusbarfile
391 $(call gb_UIConfig__add_xmlfile,$(1),$(1),statusbar,$(2))
393 endef
395 # Adds multiple statusbar config files to the package.
397 # gb_UIConfig_add_statusbarfiles target file(s)
398 define gb_UIConfig_add_statusbarfiles
399 $(foreach statusbarfile,$(2),$(call gb_UIConfig_add_statusbarfile,$(1),$(statusbarfile)))
401 endef
403 # Add toolbar config file to the package.
405 # The file is relative to $(SRCDIR) and without extension.
407 # gb_UIConfig_add_toolbarfile target file
408 define gb_UIConfig_add_toolbarfile
409 $(call gb_UIConfig__add_xmlfile,$(1),$(1),toolbar,$(2))
411 endef
413 # Adds multiple toolbar config files to the package.
415 # gb_UIConfig_add_toolbarfiles target file(s)
416 define gb_UIConfig_add_toolbarfiles
417 $(foreach toolbarfile,$(2),$(call gb_UIConfig_add_toolbarfile,$(1),$(toolbarfile)))
419 endef
421 # vim: set noet sw=4 ts=4: