bump product version to 6.3.0.0.beta1
[LibreOffice.git] / solenv / gbuild / HelpTarget.mk
blob821ed59ff68c841a83f5d670a6931d0ce9f0ab24
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 # This gbuild module handles building of localized help packs. The main
11 # entry point is class HelpTarget; the other classes should be
12 # considered private implementation details and not used directly from
13 # outside of this file.
15 # All defined objects must be named <help-module>/<lang>. If this naming
16 # scheme is not followed, bad things will happen!
18 # Overview of classes and dependencies
20 # class task depends on
21 # HelpTranslatePartTarget l10n of xhp files in one dir xhp file(s)
22 # HelpTranslateTarget l10n of xhp files HelpTranslatePartTarget
23 # HelpTreeTarget l10n of tree file tree file
24 # HelpLinkTarget linking help module HelpTranslateTarget
25 # HelpTreeTarget
26 # HelpJarTarget creating jar of xhp files HelpLinkTarget
27 # HelpIndexTarget indexing help module HelpLinkTarget
28 # HelpTarget creating help pack HelpIndexTarget
29 # HelpJarTarget
30 # extra added files
32 # class HelpTranslatePartTarget
34 # Translates .xhp files in one directory.
36 gb_HelpTranslatePartTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,helpex)
37 gb_HelpTranslatePartTarget_COMMAND := $(call gb_Executable_get_command,helpex)
39 define gb_HelpTranslatePartTarget__command
40 $(call gb_Output_announce,$(2),$(true),HPX,1)
41 HELPFILES=$(call var2file,$(shell $(gb_MKTEMP)),100,$(sort $(filter %.xhp,$(3)))) && \
42 $(call gb_Helper_abbreviate_dirs, \
43 $(if $(filter-out qtz,$(HELP_LANG)), \
44 POFILES=$(call var2file,$(shell $(gb_MKTEMP)),100,$(sort $(POFILES))) && \
45 $(gb_HelpTranslatePartTarget_COMMAND) \
46 -l $(HELP_LANG) \
47 -mi $${HELPFILES} \
48 -m $${POFILES} \
49 -o $(call gb_HelpTranslatePartTarget_get_workdir,$(2)) && \
50 rm -f $${POFILES} \
51 , \
52 $(gb_HelpTranslatePartTarget_COMMAND) \
53 -l $(HELP_LANG) \
54 -mi $${HELPFILES} \
55 -m \
56 -o $(call gb_HelpTranslatePartTarget_get_workdir,$(2)) \
57 ) \
58 ) && \
59 touch $@ && \
60 rm -f $${HELPFILES}
62 endef
64 $(dir $(call gb_HelpTranslatePartTarget_get_target,%)).dir :
65 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
67 $(call gb_HelpTranslatePartTarget_get_target,%) : $(gb_HelpTranslatePartTarget_DEPS)
68 $(call gb_HelpTranslatePartTarget__command,$@,$*,$^)
70 .PHONY : $(call gb_HelpTranslatePartTarget_get_clean_target,%)
71 $(call gb_HelpTranslatePartTarget_get_clean_target,%) :
72 $(call gb_Output_announce,$*,$(false),HPX,1)
73 $(call gb_Helper_abbreviate_dirs,\
74 rm -rf \
75 $(call gb_HelpTranslatePartTarget_get_target,$*) \
76 $(call gb_HelpTranslatePartTarget_get_workdir,$*) \
79 # Translate a set of .xhp files from one directory.
81 # gb_HelpTranslatePartTarget_HelpTranslatePartTarget target lang dir
82 define gb_HelpTranslatePartTarget_HelpTranslatePartTarget
83 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : HELP_LANG := $(2)
84 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : POFILES := $(3)
86 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
87 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : $(3)
88 $(call gb_HelpTranslatePartTarget_get_target,$(1)) :| $(dir $(call gb_HelpTranslatePartTarget_get_target,$(1))).dir
89 $(call gb_HelpTranslatePartTarget_get_target,$(1)) :| $(call gb_HelpTranslatePartTarget_get_workdir,$(1))/.dir
91 endef
93 define gb_HelpTranslatePartTarget_add_file
94 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : $(2)
96 endef
98 # class HelpTranslateTarget
100 # Translates a set of .xhp files.
102 gb_HelpTranslateTarget__get_lang = $(lastword $(subst /, ,$(1)))
104 gb_HelpTranslateTarget__get_partname = $(call gb_HelpTranslateTarget__get_lang,$(1))/$(patsubst %/,%,$(2))
105 gb_HelpTranslateTarget__get_part_workdir = $(call gb_HelpTranslatePartTarget_get_workdir,$(call gb_HelpTranslateTarget__get_partname,$(1),$(2)))
107 gb_HelpTranslateTarget_get_translated_target = $(call gb_HelpTranslatePartTarget_get_translated_target,$(call gb_HelpTranslateTarget__get_partname,$(1),$(dir $(2))),$(notdir $(2)))
108 gb_HelpTranslateTarget__get_any_translated_target = $(abspath $(call gb_HelpTranslatePartTarget_get_translated_target,,$(1)))
109 gb_HelpTranslateTarget_get_workdir = $(call gb_HelpTranslateTarget__get_part_workdir,$(1),$(2))
111 $(dir $(call gb_HelpTranslateTarget_get_target,%)).dir :
112 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
114 $(dir $(call gb_HelpTranslateTarget_get_target,%))%/.dir :
115 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
117 $(call gb_HelpTranslateTarget_get_target,%) :
118 $(call gb_Output_announce,$*,$(true),XHP,2)
119 touch $@
121 $(call gb_HelpTranslateTarget__get_any_translated_target,%) :
122 touch $@
124 .PHONY : $(call gb_HelpTranslateTarget_get_clean_target,%)
125 $(call gb_HelpTranslateTarget_get_clean_target,%) :
126 $(call gb_Output_announce,$*,$(false),XHP,2)
127 $(call gb_Helper_abbreviate_dirs,\
128 rm -f $(call gb_HelpTranslateTarget_get_target,$*) \
131 # Localizes a set of .xhp files to one language.
133 # gb_HelpTranslateTarget_HelpTranslateTarget module
134 define gb_HelpTranslateTarget_HelpTranslateTarget
135 $(call gb_HelpTranslateTarget_get_target,$(1)) :| $(dir $(call gb_HelpTranslateTarget_get_target,$(1))).dir
137 endef
139 # use wildcard to avoid spurious rebuilds if translation is missing
140 # gb_HelpTranslateTarget__make_part module part lang dir
141 define gb_HelpTranslateTarget__make_part
142 $(call gb_HelpTranslatePartTarget_HelpTranslatePartTarget,$(2),$(3),$(wildcard $(gb_POLOCATION)/$(3)/$(patsubst %/,%,$(4)).po))
144 $(call gb_HelpTranslateTarget_get_target,$(1)) : $(call gb_HelpTranslatePartTarget_get_target,$(2))
145 $(call gb_HelpTranslateTarget_get_clean_target,$(1)) : $(call gb_HelpTranslatePartTarget_get_clean_target,$(2))
147 endef
149 # gb_HelpTranslateTarget__add_file module dir file
150 define gb_HelpTranslateTarget__add_file
151 $(call gb_HelpTranslatePartTarget_add_file,$(call gb_HelpTranslateTarget__get_partname,$(1),$(2)),$(SRCDIR)/$(3).xhp)
152 $(call gb_HelpTranslateTarget_get_translated_target,$(1),$(3)) : $(call gb_HelpTranslateTarget_get_target,$(1))
154 endef
156 # gb_HelpTranslateTarget__add_files_impl module lang dir(s) file(s)
157 define gb_HelpTranslateTarget__add_files_impl
158 $(foreach part,$(3),$(call gb_HelpTranslateTarget__make_part,$(1),$(call gb_HelpTranslateTarget__get_partname,$(1),$(part)),$(2),$(part)))
159 $(foreach file,$(4),$(call gb_HelpTranslateTarget__add_file,$(1),$(dir $(file)),$(file)))
161 endef
163 # gb_HelpTranslateTarget__add_files module file(s)
164 define gb_HelpTranslateTarget__add_files
165 $(call gb_HelpTranslateTarget__add_files_impl,$(1),$(call gb_HelpTranslateTarget__get_lang,$(1)),$(sort $(dir $(2))),$(2))
167 endef
169 # gb_HelpTranslateTarget_add_file module file
170 define gb_HelpTranslateTarget_add_file
171 $(call gb_HelpTranslateTarget__add_files,$(1),$(2))
173 endef
175 # gb_HelpTranslateTarget_add_files module file(s)
176 define gb_HelpTranslateTarget_add_files
177 $(call gb_HelpTranslateTarget__add_files,$(1),$(2))
179 endef
181 # class HelpTree
183 # Translates a .tree file.
185 gb_HelpTreeTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,treex)
186 gb_HelpTreeTarget_COMMAND := $(call gb_Executable_get_command,treex)
188 define gb_HelpTreeTarget__command
189 $(call gb_Output_announce,$(2),$(true),TRE,1)
190 $(call gb_Helper_abbreviate_dirs,\
191 $(if $(filter-out qtz,$(HELP_LANG)), \
192 POFILES=$(call var2file,$(shell $(gb_MKTEMP)),100,$(POFILES)) && \
193 $(gb_HelpTreeTarget_COMMAND) \
194 -i $(HELP_TREE) \
195 -l $(HELP_LANG) \
196 -m $${POFILES} \
197 -o $@ \
198 -r $(HELP_TEXTDIR) && \
199 rm -f $${POFILES} \
201 $(gb_HelpTreeTarget_COMMAND) \
202 -i $(HELP_TREE) \
203 -l $(HELP_LANG) \
204 -m \
205 -o $@ \
206 -r $(HELP_TEXTDIR) \
210 endef
212 $(dir $(call gb_HelpTreeTarget_get_target,%)).dir :
213 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
215 $(dir $(call gb_HelpTreeTarget_get_target,%))%/.dir :
216 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
218 $(call gb_HelpTreeTarget_get_target,%) : $(gb_HelpTreeTarget_DEPS)
219 $(if $(HELP_TEXTDIR),,$(call gb_Output_error,HelpTreeTarget: no help text dir for .tree was set))
220 $(if $(HELP_TREE),,$(call gb_Output_error,HelpTreeTarget: no .tree file to translate was set))
221 $(call gb_HelpTreeTarget__command,$@,$*)
223 .PHONY : $(call gb_HelpTreeTarget_get_clean_target,%)
224 $(call gb_HelpTreeTarget_get_clean_target,%) :
225 $(call gb_Output_announce,$*,$(false),TRE,1)
226 $(call gb_Helper_abbreviate_dirs,\
227 rm -f $(call gb_HelpTreeTarget_get_target,$*) \
230 # Translate a .tree file.
232 # gb_HelpTreeTarget_HelpTreeTarget target lang
233 define gb_HelpTreeTarget_HelpTreeTarget
234 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_LANG := $(2)
235 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TEXTDIR :=
236 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TREE :=
237 $(call gb_HelpTreeTarget_get_target,$(1)) : POFILES :=
239 $(call gb_HelpTreeTarget_get_target,$(1)) :| $(dir $(call gb_HelpTreeTarget_get_target,$(1))).dir
241 endef
243 # gb_HelpTreeTarget__set_pofiles target pofiles
244 define gb_HelpTreeTarget__set_pofiles
245 $(call gb_HelpTreeTarget_get_target,$(1)) : POFILES := $(2)
246 $(call gb_HelpTreeTarget_get_target,$(1)) : $(2)
248 endef
250 # use wildcard to avoid spurious rebuilds if translation is missing
251 # gb_HelpTreeTarget_set_treefile target treefile
252 define gb_HelpTreeTarget_set_treefile
253 $(call gb_HelpTreeTarget__set_pofiles,$(1),$(wildcard $(gb_POLOCATION)/$(lastword $(subst /, ,$(1)))/$(patsubst %/,%,$(dir $(2))).po))
255 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TREE := $(SRCDIR)/$(2).tree
256 $(call gb_HelpTreeTarget_get_target,$(1)) : $(SRCDIR)/$(2).tree
258 endef
260 # gb_HelpTreeTarget_set_helptextdir target dir
261 define gb_HelpTreeTarget_set_helptextdir
262 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TEXTDIR := $(2)
264 endef
266 # class HelpLinkTarget
268 # Links a help module.
270 gb_HelpLinkTarget_HELPLINKERDEPS := $(call gb_Executable_get_runtime_dependencies,HelpLinker)
271 gb_HelpLinkTarget_HELPLINKERCOMMAND := $(call gb_Executable_get_command,HelpLinker)
272 gb_HelpLinkTarget_COMPACTTARGET := $(SRCDIR)/xmlhelp/util/compact.xsl
273 gb_HelpLinkTarget_EMBEDTARGET := $(SRCDIR)/xmlhelp/util/embed.xsl
274 gb_HelpLinkTarget_IDXCAPTIONTARGET := $(SRCDIR)/xmlhelp/util/idxcaption.xsl
275 gb_HelpLinkTarget_IDXCONTENTTARGET := $(SRCDIR)/xmlhelp/util/idxcontent.xsl
276 gb_HelpLinkTarget_DEPS := \
277 $(gb_HelpLinkTarget_HELPLINKERDEPS) \
278 $(gb_HelpLinkTarget_COMPACTTARGET) \
279 $(gb_HelpLinkTarget_EMBEDTARGET) \
280 $(gb_HelpLinkTarget_IDXCAPTIONTARGET) \
281 $(gb_HelpLinkTarget_IDXCONTENTTARGET)
283 # delete index files here too just to be on the safe side...
284 # the index files in the .idxl dir are created by HelpIndexer,
285 # the ones outside the dir by HelpLinker
286 define gb_HelpLinkTarget__command
287 $(call gb_Output_announce,$(2),$(true),HLK,3)
288 $(if $(HELP_INDEXED),rm -rf $(addprefix $(HELP_WORKDIR)/,$(HELP_INDEXED)) && \)
289 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,\
290 -lang $(HELP_LANG) \
291 -mod $(HELP_MODULE) \
292 $(if $(HELP_INDEXED),,-noindex) \
293 -nolangroot \
294 -o $(WORKDIR)/dummy.zip \
295 -src $(HELP_SRCDIR) \
296 -zipdir $(HELP_WORKDIR) \
297 -compact $(gb_HelpLinkTarget_COMPACTTARGET) \
298 -idxcaption $(gb_HelpLinkTarget_IDXCAPTIONTARGET) \
299 -idxcontent $(gb_HelpLinkTarget_IDXCONTENTTARGET) \
300 -sty $(gb_HelpLinkTarget_EMBEDTARGET) \
301 $(if $(HELP_CONFIGFILE),-add $(HELP_MODULE).cfg $(HELP_CONFIGFILE)) \
302 $(if $(HELP_TREE),-add $(HELP_MODULE).tree $(HELP_TREE)) \
303 $(foreach file,$(HELP_ADD_FILES),-add $(notdir $(file)) $(file)) \
304 $(foreach extra,$(HELP_EXTRA_ADD_FILES),-add $(subst $(COMMA), ,$(extra))) \
305 $(HELP_FILES) \
306 $(if $(HELP_LINKED_MODULES),\
307 $(shell cat $(foreach module,$(HELP_LINKED_MODULES),$(call gb_HelpTarget_get_filelist,$(module)))) \
309 ) && \
310 $(gb_HelpLinkTarget_HELPLINKERCOMMAND) @$${RESPONSEFILE} && \
311 touch $@ && \
312 rm -f $${RESPONSEFILE}
313 endef
316 $(dir $(call gb_HelpLinkTarget_get_target,%)).dir :
317 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
319 $(dir $(call gb_HelpLinkTarget_get_target,%))%/.dir :
320 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
322 $(call gb_HelpLinkTarget_get_target,%) : $(gb_HelpLinkTarget_DEPS)
323 $(call gb_HelpLinkTarget__command,$@,$*)
325 .PHONY : $(call gb_HelpLinkTarget_get_clean_target,%)
326 $(call gb_HelpLinkTarget_get_clean_target,%) :
327 $(call gb_Output_announce,$*,$(false),HLK,3)
328 rm -f $(call gb_HelpLinkTarget_get_target,$*)
330 # Create a help linking target.
332 # depend on makefile to re-build when files are removed
334 # gb_HelpLinkTarget_HelpLinkTarget name module lang workdir
335 define gb_HelpLinkTarget_HelpLinkTarget
336 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_ADD_FILES :=
337 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_CONFIGFILE :=
338 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_EXTRA_ADD_FILES :=
339 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_FILES :=
340 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_INDEXED :=
341 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_MODULE := $(2)
342 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_LANG := $(3)
343 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_LINKED_MODULES :=
344 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_SRCDIR :=
345 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_TREE :=
346 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_WORKDIR := $(4)
348 $(call gb_HelpLinkTarget_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
349 $(call gb_HelpLinkTarget_get_target,$(1)) :| $(dir $(call gb_HelpLinkTarget_get_target,$(1))).dir
351 $(4)/$(2).tree : $(call gb_HelpLinkTarget_get_target,$(1))
353 endef
355 # gb_HelpLinkTarget_set_configfile target configfile
356 define gb_HelpLinkTarget_set_configfile
357 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_CONFIGFILE := $(2)
358 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
360 endef
362 # gb_HelpLinkTarget_set_sourcedir target source
363 define gb_HelpLinkTarget_set_sourcedir
364 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_SRCDIR := $(2)
366 endef
368 # gb_HelpLinkTarget_set_treefile target treefile
369 define gb_HelpLinkTarget_set_treefile
370 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_TREE := $(2)
371 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
373 endef
375 # gb_HelpLinkTarget_set_indexed target indexfiles
376 define gb_HelpLinkTarget_set_indexed
377 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_INDEXED := $(2)
378 $(addprefix $(call gb_HelpTarget_get_workdir,$(1))/,$(2)) : $(call gb_HelpIndexTarget_get_target,$(1))
380 endef
382 # gb_HelpLinkTarget_add_helpfile target helpfile
383 define gb_HelpLinkTarget_add_helpfile
384 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_FILES += $(2)
385 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
387 endef
389 # Add an arbitrary file to the help pack.
391 # The file will be added to the root directory of the pack.
393 # gb_HelpLinkTarget_add_file target file
394 define gb_HelpLinkTarget_add_file
395 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_ADD_FILES += $(2)
396 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
398 endef
400 # Add an arbitrary file to the help pack under a new name.
402 # The file will be added to the root directory of the pack.
404 # gb_HelpLinkTarget_add_renamed_file target filename file
405 define gb_HelpLinkTarget_add_renamed_file
406 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_EXTRA_ADD_FILES += $(strip $(2)),$(strip $(3))
407 $(call gb_HelpLinkTarget_get_target,$(1)) : $(3)
408 $(call gb_HelpTarget_get_workdir,$(1))/$(2) : $(call gb_HelpLinkTarget_get_target,$(1))
409 touch $$@
411 endef
413 # Link with help files from another help module.
415 # gb_HelpLinkTarget_use_linked_module target help
416 define gb_HelpLinkTarget_use_linked_module
417 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_LINKED_MODULES += $(2)
419 endef
421 # class HelpIndexTarget
423 # Creates a full-text search index for a help module.
425 gb_HelpIndexTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,HelpIndexer)
426 gb_HelpIndexTarget_COMMAND := $(call gb_Executable_get_command,HelpIndexer)
428 # first delete the index stuff since when it is generated an existing _0.cfs
429 # will not be overwritten; instead a new _1.cfs etc. created until disk is full
430 define gb_HelpIndexTarget__command
431 $(call gb_Output_announce,$*,$(true),HIX,3)
432 $(call gb_Helper_abbreviate_dirs,\
434 rm -rf $(HELP_WORKDIR)/$(HELP_MODULE).idxl \
435 && $(gb_HelpIndexTarget_COMMAND) \
436 -dir $(HELP_WORKDIR) \
437 -lang $(HELP_LANG) \
438 -mod $(HELP_MODULE) \
439 && touch $@ \
441 || ( rm -rf $(HELP_MODULE).* ; false )
443 endef
445 $(dir $(call gb_HelpIndexTarget_get_target,%)).dir :
446 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
448 $(dir $(call gb_HelpIndexTarget_get_target,%))%/.dir :
449 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
451 $(call gb_HelpIndexTarget_get_target,%) : $(gb_HelpIndexTarget_DEPS)
452 $(call gb_HelpIndexTarget__command,$@,$*)
454 .PHONY : $(call gb_HelpIndexTarget_get_clean_target,%)
455 $(call gb_HelpIndexTarget_get_clean_target,%) :
456 $(call gb_Output_announce,$*,$(false),HIX,3)
457 rm -f $(call gb_HelpIndexTarget_get_target,$*)
459 # Create a help indexing target.
461 # gb_HelpIndexTarget_HelpIndexTarget target module lang workdir
462 define gb_HelpIndexTarget_HelpIndexTarget
463 $(call gb_HelpIndexTarget_get_target,$(1)) : HELP_LANG := $(3)
464 $(call gb_HelpIndexTarget_get_target,$(1)) : HELP_MODULE := $(2)
465 $(call gb_HelpIndexTarget_get_target,$(1)) : HELP_WORKDIR := $(4)
467 $(call gb_HelpIndexTarget_get_target,$(1)) :| $(dir $(call gb_HelpIndexTarget_get_target,$(1))).dir
469 endef
471 # class HelpJarTarget
473 # Packs help files processed by HelpLinker into a jar in the workdir.
475 gb_HelpJarTarget_COMMAND := zip
477 define gb_HelpJarTarget__get_command
478 $(call gb_Output_announce,$*,$(true),HEJ,3)
479 cd $(HELP_WORKDIR) && \
480 $(gb_HelpJarTarget_COMMAND) -q -0 -rX --filesync --must-match $(HELP_MODULE).jar text/$(HELP_MODULE) && \
481 touch $@
482 endef
484 $(dir $(call gb_HelpJarTarget_get_target,%)).dir :
485 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
487 $(dir $(call gb_HelpJarTarget_get_target,%))%/.dir :
488 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
490 $(call gb_HelpJarTarget_get_target,%) :
491 $(call gb_HelpJarTarget__get_command,$@,$*)
493 $(call gb_HelpJarTarget_get_clean_target,%) :
494 $(call gb_Output_announce,$*,$(false),HEJ,3)
495 rm -f $(call gb_HelpJarTarget_get_target,$*)
497 # gb_HelpJarTarget_HelpJarTarget target module workdir
498 define gb_HelpJarTarget_HelpJarTarget
499 $(call gb_HelpJarTarget_get_target,$(1)) : HELP_MODULE := $(2)
500 $(call gb_HelpJarTarget_get_target,$(1)) : HELP_WORKDIR := $(3)
502 $(call gb_HelpJarTarget_get_target,$(1)) :| $(dir $(call gb_HelpJarTarget_get_target,$(1))).dir
504 $(3)/$(2).jar : $(call gb_HelpJarTarget_get_target,$(1))
506 endef
508 # class HelpTarget
510 # Creates one language version of a help module.
512 # Provides a filelist called HelpTarget/<name>, that is not built by
513 # default (i.e., the user of HelpTarget has to explicitly depend on the
514 # Package).
516 gb_HelpTarget_DEFAULT_LANG := en-US
518 gb_HelpTarget__get_module = $(patsubst %/$(call gb_HelpTarget__get_lang,$(1)),%,$(1))
519 gb_HelpTarget__get_lang = $(lastword $(subst /, ,$(1)))
520 gb_HelpTarget__test_default_lang = $(filter $(gb_HelpTarget_DEFAULT_LANG),$(1))
521 gb_HelpTarget__is_default_lang = $(call gb_HelpTarget__test_default_lang,$(call gb_HelpTarget__get_lang,$(1)))
523 define gb_HelpTarget__get_helpdir
524 $(if $(call gb_HelpTarget__is_default_lang,$(1)) \
525 ,$(SRCDIR)/$(2) \
526 ,$(call gb_HelpTranslateTarget_get_workdir,$(1),$(2)) \
528 endef
530 define gb_HelpTarget__get_helpfile
531 $(if $(call gb_HelpTarget__is_default_lang,$(1)) \
532 ,$(SRCDIR)/$(2).xhp \
533 ,$(call gb_HelpTranslateTarget_get_translated_target,$(1),$(2)) \
535 endef
537 define gb_HelpTarget__get_treefile
538 $(if $(call gb_HelpTarget__is_default_lang,$(1)) \
539 ,$(SRCDIR)/$(2).tree \
540 ,$(call gb_HelpTreeTarget_get_target,$(1)) \
542 endef
544 define gb_HelpTarget__command
545 $(if $(ENABLE_HTMLHELP),,$(call gb_Output_announce,$(2),$(true),HLP,4))
546 touch $@
547 endef
549 $(dir $(call gb_HelpTarget_get_target,%)).dir :
550 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
552 $(dir $(call gb_HelpTarget_get_target,%))%/.dir :
553 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
555 # Translation of the module's .xhp files and all used modules is done.
556 # Also creates the list for gb_HelpTarget_get_filelist.
557 $(call gb_HelpTarget_get_translation_target,%) :
558 rm -f $@ && mv $(call var2file,$@.tmp,100,$(strip $(HELP_FILES))) $@
560 # Translation of the module's .xhp files and all used and linked modules
561 # is done.
562 $(call gb_HelpTarget_get_linked_target,%) :
563 touch $@
565 $(call gb_HelpTarget_get_target,%) :
566 $(call gb_HelpTarget__command,$@,$*)
568 .PHONY : $(call gb_HelpTarget_get_clean_target,%)
569 $(call gb_HelpTarget_get_clean_target,%) :
570 ifeq ($(ENABLE_HTMLHELP),)
571 $(call gb_Output_announce,$*,$(false),HLP,4)
572 endif
573 $(call gb_Helper_abbreviate_dirs,\
574 rm -rf \
575 $(call gb_HelpTarget_get_linked_target,$*) \
576 $(call gb_HelpTarget_get_target,$*) \
577 $(call gb_HelpTarget_get_translation_target,$*) \
578 $(call gb_HelpTarget_get_workdir,$*) \
581 gb_HelpTarget_get_packagename = HelpTarget/$(1)
583 # Create a help target.
585 # depend on makefile to re-build filelist when files are removed
587 # gb_HelpTarget_HelpTarget target module lang
588 define gb_HelpTarget_HelpTarget
589 $(call gb_HelpTarget_get_target,$(1)) : HELP_MODULE := $(2)
590 $(call gb_HelpTarget_get_target,$(1)) : HELP_LANG := $(3)
592 $(call gb_HelpTarget_get_translation_target,$(1)) : HELP_FILES :=
593 $(call gb_HelpTarget_get_translation_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
595 $(call gb_HelpTarget__HelpTarget_impl,$(1),$(2),$(3),$(call gb_HelpTarget_get_workdir,$(1)),$(call gb_HelpTarget_get_packagename,$(1)))
597 endef
599 # gb_HelpTarget__HelpTarget_impl target module lang workdir package
600 define gb_HelpTarget__HelpTarget_impl
601 $(if $(call gb_HelpTarget__test_default_lang,$(3)),,$(call gb_HelpTarget__HelpTarget_impl_lang,$(1),$(2),$(3),$(4)))
603 ifeq ($(ENABLE_HTMLHELP),)
604 $(call gb_HelpLinkTarget_HelpLinkTarget,$(1),$(2),$(3),$(4))
605 $(call gb_HelpIndexTarget_HelpIndexTarget,$(1),$(2),$(3),$(4))
606 $(call gb_HelpJarTarget_HelpJarTarget,$(1),$(2),$(4))
607 $(call gb_Package_Package_internal,$(5),$(4))
608 endif
610 $(call gb_HelpTarget_get_linked_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(1))
611 ifeq ($(ENABLE_HTMLHELP),)
612 $(call gb_HelpLinkTarget_get_target,$(1)) : $(call gb_HelpTarget_get_linked_target,$(1))
613 $(call gb_HelpLinkTarget_get_target,$(1)) :| $(call gb_HelpTarget_get_workdir,$(1))/.dir
614 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
615 $(call gb_Package_get_preparation_target,$(5)) : $(call gb_HelpTarget_get_target,$(1))
616 endif
618 $(call gb_HelpTarget_get_linked_target,$(1)) :| $(dir $(call gb_HelpTarget_get_linked_target,$(1))).dir
619 $(call gb_HelpTarget_get_target,$(1)) :| $(dir $(call gb_HelpTarget_get_target,$(1))).dir
620 $(call gb_HelpTarget_get_translation_target,$(1)) :| $(dir $(call gb_HelpTarget_get_translation_target,$(1))).dir
622 ifeq ($(ENABLE_HTMLHELP),)
623 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpLinkTarget_get_clean_target,$(1))
624 endif
626 endef
628 # gb_HelpTarget__HelpTarget_impl_lang target module lang workdir
629 define gb_HelpTarget__HelpTarget_impl_lang
630 $(call gb_HelpTranslateTarget_HelpTranslateTarget,$(1),$(3))
631 $(call gb_HelpTreeTarget_HelpTreeTarget,$(1),$(3))
633 $(call gb_HelpTarget_get_translation_target,$(1)) : $(call gb_HelpTranslateTarget_get_target,$(1))
634 $(call gb_HelpTreeTarget_get_target,$(1)) : $(call gb_HelpTarget_get_linked_target,$(1))
636 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpTranslateTarget_get_clean_target,$(1))
637 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpTreeTarget_get_clean_target,$(1))
639 endef
641 # need a rule for these because these are targets for the Package
642 $(WORKDIR)/HelpTarget/%.tree :
643 touch $@
644 $(WORKDIR)/HelpTarget/%.jar :
645 touch $@
646 $(WORKDIR)/HelpTarget/%.db :
647 touch $@
648 $(WORKDIR)/HelpTarget/%.ht :
649 touch $@
650 $(WORKDIR)/HelpTarget/%.key :
651 touch $@
652 $(WORKDIR)/HelpTarget/%.idxl/_0.cfs :
653 touch $@
654 $(WORKDIR)/HelpTarget/%.idxl/segments_3 :
655 touch $@
656 $(WORKDIR)/HelpTarget/%.idxl/segments.gen :
657 touch $@
659 # Get list of the various index files.
661 # gb_HelpTarget__add_index_files target module
662 define gb_HelpTarget__get_index_files
663 $(foreach suffix,.db .ht .idxl/_0.cfs .idxl/segments_3 .idxl/segments.gen .key,$(addsuffix $(suffix),$(call gb_HelpTarget__get_module,$(1))))
664 endef
666 # gb_HelpTarget__add_file target file
667 define gb_HelpTarget__add_file
668 ifeq ($(ENABLE_HTMLHELP),)
669 $(call gb_Package_add_file,$(call gb_HelpTarget_get_packagename,$(1)),$(LIBO_SHARE_HELP_FOLDER)/$(call gb_HelpTarget__get_lang,$(1))/$(2),$(2))
670 endif
672 endef
674 # Set config. file used for the help module.
676 # The configfile is relative to $(SRCDIR) and without extension.
678 # gb_HelpTarget_set_configfile target configfile
679 define gb_HelpTarget_set_configfile
680 ifeq ($(ENABLE_HTMLHELP),)
681 $(call gb_HelpLinkTarget_set_configfile,$(1),$(SRCDIR)/$(2).cfg)
682 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).cfg)
683 endif
685 endef
687 # gb_HelpTarget_set_helpdir target helpdir
688 define gb_HelpTarget_set_helpdir
689 ifeq ($(ENABLE_HTMLHELP),)
690 $(call gb_HelpLinkTarget_set_sourcedir,$(1),$(call gb_HelpTarget__get_helpdir,$(1),$(2)))
691 endif
693 endef
695 # gb_HelpTarget_set_treefile target treefile textdir
696 define gb_HelpTarget_set_treefile
697 $(if $(call gb_HelpTarget__is_default_lang,$(1)),,\
698 $(call gb_HelpTreeTarget_set_treefile,$(1),$(2)) \
699 $(call gb_HelpTreeTarget_set_helptextdir,$(1),$(call gb_HelpTarget__get_helpdir,$(1),$(3))) \
701 ifeq ($(ENABLE_HTMLHELP),)
702 $(call gb_HelpLinkTarget_set_treefile,$(1),$(call gb_HelpTarget__get_treefile,$(1),$(2)))
703 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).tree)
704 endif
706 endef
708 # Produce full text search index, bookmark list, etc.
710 # gb_HelpTarget_set_indexed target
711 define gb_HelpTarget_set_indexed
712 ifeq ($(ENABLE_HTMLHELP),)
713 $(call gb_HelpLinkTarget_set_indexed,$(1),$(call gb_HelpTarget__get_index_files,$(1)))
714 $(foreach file,$(call gb_HelpTarget__get_index_files,$(1)),$(call gb_HelpTarget__add_file,$(1),$(file)))
716 $(call gb_HelpIndexTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
717 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpIndexTarget_get_target,$(1))
718 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpIndexTarget_get_clean_target,$(1))
719 endif
721 endef
723 # gb_HelpTarget__add_jar target
724 define gb_HelpTarget__add_jar
725 ifeq ($(ENABLE_HTMLHELP),)
726 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).jar)
727 $(call gb_HelpJarTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
728 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpJarTarget_get_target,$(1))
729 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpJarTarget_get_clean_target,$(1))
730 endif
732 endef
734 define gb_HelpTarget__add_helpfile_impl
735 ifeq ($(ENABLE_HTMLHELP),)
736 $(call gb_HelpLinkTarget_add_helpfile,$(1),$(2))
737 endif
739 $(call gb_HelpTarget_get_translation_target,$(1)) : HELP_FILES += $(2)
741 endef
743 # gb_HelpTarget__add_helpfile target helpfile
744 define gb_HelpTarget__add_helpfile
745 $(call gb_HelpTarget__add_helpfile_impl,$(1),$(call gb_HelpTarget__get_helpfile,$(1),$(2)))
747 endef
749 # gb_HelpTarget_add_helpfile target helpfile
750 define gb_HelpTarget_add_helpfile
751 $(call gb_HelpTranslateTarget_add_file,$(1),$(2))
752 $(call gb_HelpTarget__add_helpfile,$(1),$(2))
753 ifeq ($(ENABLE_HTMLHELP),)
754 $(call gb_HelpTarget__add_jar,$(1))
755 endif
757 endef
759 # gb_HelpTarget_add_helpfiles target helpfile(s)
760 define gb_HelpTarget_add_helpfiles
761 $(call gb_HelpTranslateTarget_add_files,$(1),$(2))
762 $(foreach helpfile,$(2),$(call gb_HelpTarget__add_helpfile,$(1),$(helpfile)))
763 ifeq ($(ENABLE_HTMLHELP),)
764 $(call gb_HelpTarget__add_jar,$(1))
765 endif
767 endef
769 # gb_HelpTarget_add_file target file
770 define gb_HelpTarget_add_file
771 ifeq ($(ENABLE_HTMLHELP),)
772 $(call gb_HelpLinkTarget_add_file,$(1),$(SRCDIR)/$(2))
773 $(call gb_HelpTarget__add_file,$(1),$(notdir $(2)))
774 endif
776 endef
778 # gb_HelpTarget_add_files target file(s)
779 define gb_HelpTarget_add_files
780 $(foreach file,$(2),$(call gb_HelpTarget_add_file,$(1),$(file)))
782 endef
784 # Add a localized file from helpdir under a new name.
786 # This is a hack needed for err.html in shared help module.
788 # gb_HelpTarget_add_helpdir_file target filename file
789 define gb_HelpTarget_add_helpdir_file
790 ifeq ($(ENABLE_HTMLHELP),)
791 $(call gb_HelpLinkTarget_add_renamed_file,$(1),$(2),$(call gb_HelpTarget__get_helpfile,$(1),$(3)))
792 $(call gb_HelpTarget__add_file,$(1),$(2))
793 endif
795 endef
797 # gb_HelpTarget_use_module target module
798 define gb_HelpTarget_use_module
799 $(call gb_HelpTarget_get_translation_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(2))
801 endef
803 # gb_HelpTarget_use_modules target module(s)
804 define gb_HelpTarget_use_modules
805 $(foreach module,$(2),$(call gb_HelpTarget_use_module,$(1),$(module)))
807 endef
809 # gb_HelpTarget_use_linked_module target module
810 define gb_HelpTarget_use_linked_module
811 ifeq ($(ENABLE_HTMLHELP),)
812 $(call gb_HelpLinkTarget_use_linked_module,$(1),$(2))
813 $(call gb_HelpTarget_get_linked_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(2))
814 endif
816 endef
818 # gb_HelpTarget_use_linked_modules target module(s)
819 define gb_HelpTarget_use_linked_modules
820 $(foreach module,$(2),$(call gb_HelpTarget_use_linked_module,$(1),$(module)))
822 endef
824 # vim: set noet sw=4 ts=4: