Avoid potential negative array index access to cached text.
[LibreOffice.git] / solenv / gbuild / HelpTarget.mk
blob75cb22153d9154b836551aeba9ad65e20ab09be6
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 HELPFILES=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(sort $(filter %.xhp,$(3)))) && \
41 $(call gb_Helper_abbreviate_dirs, \
42 $(if $(filter-out qtz,$(HELP_LANG)), \
43 POFILES=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(sort $(POFILES))) && \
44 $(gb_HelpTranslatePartTarget_COMMAND) \
45 -l $(HELP_LANG) \
46 -mi $${HELPFILES} \
47 -m $${POFILES} \
48 -o $(call gb_HelpTranslatePartTarget_get_workdir,$(2)) && \
49 rm -f $${POFILES} \
50 , \
51 $(gb_HelpTranslatePartTarget_COMMAND) \
52 -l $(HELP_LANG) \
53 -mi $${HELPFILES} \
54 -m \
55 -o $(call gb_HelpTranslatePartTarget_get_workdir,$(2)) \
56 ) \
57 ) && \
58 touch $@ && \
59 rm -f $${HELPFILES}
61 endef
63 $(dir $(call gb_HelpTranslatePartTarget_get_target,%)).dir :
64 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
66 $(call gb_HelpTranslatePartTarget_get_target,%) : $(gb_HelpTranslatePartTarget_DEPS)
67 $(call gb_Output_announce,$*,$(true),HPX,1)
68 $(call gb_Trace_StartRange,$*,HPX)
69 $(call gb_HelpTranslatePartTarget__command,$@,$*,$^)
70 $(call gb_Trace_EndRange,$*,HPX)
72 .PHONY : $(call gb_HelpTranslatePartTarget_get_clean_target,%)
73 $(call gb_HelpTranslatePartTarget_get_clean_target,%) :
74 $(call gb_Output_announce,$*,$(false),HPX,1)
75 $(call gb_Helper_abbreviate_dirs,\
76 rm -rf \
77 $(call gb_HelpTranslatePartTarget_get_target,$*) \
78 $(call gb_HelpTranslatePartTarget_get_workdir,$*) \
81 # Translate a set of .xhp files from one directory.
83 # gb_HelpTranslatePartTarget_HelpTranslatePartTarget target lang dir
84 define gb_HelpTranslatePartTarget_HelpTranslatePartTarget
85 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : HELP_LANG := $(2)
86 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : POFILES := $(3)
88 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
89 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : $(3)
90 $(call gb_HelpTranslatePartTarget_get_target,$(1)) :| $(dir $(call gb_HelpTranslatePartTarget_get_target,$(1))).dir
91 $(call gb_HelpTranslatePartTarget_get_target,$(1)) :| $(call gb_HelpTranslatePartTarget_get_workdir,$(1))/.dir
93 endef
95 define gb_HelpTranslatePartTarget_add_file
96 $(call gb_HelpTranslatePartTarget_get_target,$(1)) : $(2)
98 endef
100 # class HelpTranslateTarget
102 # Translates a set of .xhp files.
104 gb_HelpTranslateTarget__get_lang = $(lastword $(subst /, ,$(1)))
106 gb_HelpTranslateTarget__get_partname = $(call gb_HelpTranslateTarget__get_lang,$(1))/$(patsubst %/,%,$(2))
107 gb_HelpTranslateTarget__get_part_workdir = $(call gb_HelpTranslatePartTarget_get_workdir,$(call gb_HelpTranslateTarget__get_partname,$(1),$(2)))
109 gb_HelpTranslateTarget_get_translated_target = $(call gb_HelpTranslatePartTarget_get_translated_target,$(call gb_HelpTranslateTarget__get_partname,$(1),$(dir $(2))),$(notdir $(2)))
110 gb_HelpTranslateTarget__get_any_translated_target = $(abspath $(call gb_HelpTranslatePartTarget_get_translated_target,,$(1)))
111 gb_HelpTranslateTarget_get_workdir = $(call gb_HelpTranslateTarget__get_part_workdir,$(1),$(2))
113 $(dir $(call gb_HelpTranslateTarget_get_target,%)).dir :
114 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
116 $(dir $(call gb_HelpTranslateTarget_get_target,%))%/.dir :
117 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
119 $(call gb_HelpTranslateTarget_get_target,%) :
120 $(call gb_Output_announce,$*,$(true),XHP,2)
121 $(call gb_Trace_MakeMark,$*,XHP)
122 touch $@
124 $(call gb_HelpTranslateTarget__get_any_translated_target,%) :
125 touch $@
127 .PHONY : $(call gb_HelpTranslateTarget_get_clean_target,%)
128 $(call gb_HelpTranslateTarget_get_clean_target,%) :
129 $(call gb_Output_announce,$*,$(false),XHP,2)
130 $(call gb_Helper_abbreviate_dirs,\
131 rm -f $(call gb_HelpTranslateTarget_get_target,$*) \
134 # Localizes a set of .xhp files to one language.
136 # gb_HelpTranslateTarget_HelpTranslateTarget module
137 define gb_HelpTranslateTarget_HelpTranslateTarget
138 $(call gb_HelpTranslateTarget_get_target,$(1)) :| $(dir $(call gb_HelpTranslateTarget_get_target,$(1))).dir
140 endef
142 # use wildcard to avoid spurious rebuilds if translation is missing
143 # gb_HelpTranslateTarget__make_part module part lang dir
144 define gb_HelpTranslateTarget__make_part
145 $(call gb_HelpTranslatePartTarget_HelpTranslatePartTarget,$(2),$(3),$(wildcard $(gb_POLOCATION)/$(3)/$(patsubst %/,%,$(4)).po))
147 $(call gb_HelpTranslateTarget_get_target,$(1)) : $(call gb_HelpTranslatePartTarget_get_target,$(2))
148 $(call gb_HelpTranslateTarget_get_clean_target,$(1)) : $(call gb_HelpTranslatePartTarget_get_clean_target,$(2))
150 endef
152 # gb_HelpTranslateTarget__add_file module dir file
153 define gb_HelpTranslateTarget__add_file
154 $(call gb_HelpTranslatePartTarget_add_file,$(call gb_HelpTranslateTarget__get_partname,$(1),$(2)),$(SRCDIR)/$(3).xhp)
155 $(call gb_HelpTranslateTarget_get_translated_target,$(1),$(3)) : $(call gb_HelpTranslateTarget_get_target,$(1))
157 endef
159 # gb_HelpTranslateTarget__add_files_impl module lang dir(s) file(s)
160 define gb_HelpTranslateTarget__add_files_impl
161 $(foreach part,$(3),$(call gb_HelpTranslateTarget__make_part,$(1),$(call gb_HelpTranslateTarget__get_partname,$(1),$(part)),$(2),$(part)))
162 $(foreach file,$(4),$(call gb_HelpTranslateTarget__add_file,$(1),$(dir $(file)),$(file)))
164 endef
166 # gb_HelpTranslateTarget__add_files module file(s)
167 define gb_HelpTranslateTarget__add_files
168 $(call gb_HelpTranslateTarget__add_files_impl,$(1),$(call gb_HelpTranslateTarget__get_lang,$(1)),$(sort $(dir $(2))),$(2))
170 endef
172 # gb_HelpTranslateTarget_add_file module file
173 define gb_HelpTranslateTarget_add_file
174 $(call gb_HelpTranslateTarget__add_files,$(1),$(2))
176 endef
178 # gb_HelpTranslateTarget_add_files module file(s)
179 define gb_HelpTranslateTarget_add_files
180 $(call gb_HelpTranslateTarget__add_files,$(1),$(2))
182 endef
184 # class HelpTree
186 # Translates a .tree file.
188 gb_HelpTreeTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,treex)
189 gb_HelpTreeTarget_COMMAND := $(call gb_Executable_get_command,treex)
191 define gb_HelpTreeTarget__command
192 $(call gb_Helper_abbreviate_dirs,\
193 $(if $(filter-out qtz,$(HELP_LANG)), \
194 POFILES=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(POFILES)) && \
195 $(gb_HelpTreeTarget_COMMAND) \
196 -i $(HELP_TREE) \
197 -l $(HELP_LANG) \
198 -m $${POFILES} \
199 -o $@ \
200 -r $(HELP_TEXTDIR) && \
201 rm -f $${POFILES} \
203 $(gb_HelpTreeTarget_COMMAND) \
204 -i $(HELP_TREE) \
205 -l $(HELP_LANG) \
206 -m \
207 -o $@ \
208 -r $(HELP_TEXTDIR) \
212 endef
214 $(dir $(call gb_HelpTreeTarget_get_target,%)).dir :
215 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
217 $(dir $(call gb_HelpTreeTarget_get_target,%))%/.dir :
218 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
220 $(call gb_HelpTreeTarget_get_target,%) : $(gb_HelpTreeTarget_DEPS)
221 $(if $(HELP_TEXTDIR),,$(call gb_Output_error,HelpTreeTarget: no help text dir for .tree was set))
222 $(if $(HELP_TREE),,$(call gb_Output_error,HelpTreeTarget: no .tree file to translate was set))
223 $(call gb_Output_announce,$*,$(true),TRE,1)
224 $(call gb_Trace_StartRange,$*,TRE)
225 $(call gb_HelpTreeTarget__command,$@,$*)
226 $(call gb_Trace_EndRange,$*,TRE)
228 .PHONY : $(call gb_HelpTreeTarget_get_clean_target,%)
229 $(call gb_HelpTreeTarget_get_clean_target,%) :
230 $(call gb_Output_announce,$*,$(false),TRE,1)
231 $(call gb_Helper_abbreviate_dirs,\
232 rm -f $(call gb_HelpTreeTarget_get_target,$*) \
235 # Translate a .tree file.
237 # gb_HelpTreeTarget_HelpTreeTarget target lang
238 define gb_HelpTreeTarget_HelpTreeTarget
239 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_LANG := $(2)
240 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TEXTDIR :=
241 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TREE :=
242 $(call gb_HelpTreeTarget_get_target,$(1)) : POFILES :=
244 $(call gb_HelpTreeTarget_get_target,$(1)) :| $(dir $(call gb_HelpTreeTarget_get_target,$(1))).dir
246 endef
248 # gb_HelpTreeTarget__set_pofiles target pofiles
249 define gb_HelpTreeTarget__set_pofiles
250 $(call gb_HelpTreeTarget_get_target,$(1)) : POFILES := $(2)
251 $(call gb_HelpTreeTarget_get_target,$(1)) : $(2)
253 endef
255 # use wildcard to avoid spurious rebuilds if translation is missing
256 # gb_HelpTreeTarget_set_treefile target treefile
257 define gb_HelpTreeTarget_set_treefile
258 $(call gb_HelpTreeTarget__set_pofiles,$(1),$(wildcard $(gb_POLOCATION)/$(lastword $(subst /, ,$(1)))/$(patsubst %/,%,$(dir $(2))).po))
260 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TREE := $(SRCDIR)/$(2).tree
261 $(call gb_HelpTreeTarget_get_target,$(1)) : $(SRCDIR)/$(2).tree
263 endef
265 # gb_HelpTreeTarget_set_helptextdir target dir
266 define gb_HelpTreeTarget_set_helptextdir
267 $(call gb_HelpTreeTarget_get_target,$(1)) : HELP_TEXTDIR := $(2)
269 endef
271 # class HelpLinkTarget
273 # Links a help module.
275 gb_HelpLinkTarget_HELPLINKERDEPS := $(call gb_Executable_get_runtime_dependencies,HelpLinker)
276 gb_HelpLinkTarget_HELPLINKERCOMMAND := $(call gb_Executable_get_command,HelpLinker)
277 gb_HelpLinkTarget_COMPACTTARGET := $(SRCDIR)/xmlhelp/util/compact.xsl
278 gb_HelpLinkTarget_EMBEDTARGET := $(SRCDIR)/xmlhelp/util/embed.xsl
279 gb_HelpLinkTarget_IDXCAPTIONTARGET := $(SRCDIR)/xmlhelp/util/idxcaption.xsl
280 gb_HelpLinkTarget_IDXCONTENTTARGET := $(SRCDIR)/xmlhelp/util/idxcontent.xsl
281 gb_HelpLinkTarget_DEPS := \
282 $(gb_HelpLinkTarget_HELPLINKERDEPS) \
283 $(gb_HelpLinkTarget_COMPACTTARGET) \
284 $(gb_HelpLinkTarget_EMBEDTARGET) \
285 $(gb_HelpLinkTarget_IDXCAPTIONTARGET) \
286 $(gb_HelpLinkTarget_IDXCONTENTTARGET)
288 # delete index files here too just to be on the safe side...
289 # the index files in the .idxl dir are created by HelpIndexer,
290 # the ones outside the dir by HelpLinker
291 define gb_HelpLinkTarget__command
292 $(if $(HELP_INDEXED),rm -rf $(addprefix $(HELP_WORKDIR)/,$(HELP_INDEXED)) && \)
293 RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),\
294 -lang $(HELP_LANG) \
295 -mod $(HELP_MODULE) \
296 $(if $(HELP_INDEXED),,-noindex) \
297 -nolangroot \
298 -o $(WORKDIR)/dummy.zip \
299 -src $(HELP_SRCDIR) \
300 -zipdir $(HELP_WORKDIR) \
301 -compact $(gb_HelpLinkTarget_COMPACTTARGET) \
302 -idxcaption $(gb_HelpLinkTarget_IDXCAPTIONTARGET) \
303 -idxcontent $(gb_HelpLinkTarget_IDXCONTENTTARGET) \
304 -sty $(gb_HelpLinkTarget_EMBEDTARGET) \
305 $(if $(HELP_CONFIGFILE),-add $(HELP_MODULE).cfg $(HELP_CONFIGFILE)) \
306 $(if $(HELP_TREE),-add $(HELP_MODULE).tree $(HELP_TREE)) \
307 $(foreach file,$(HELP_ADD_FILES),-add $(notdir $(file)) $(file)) \
308 $(foreach extra,$(HELP_EXTRA_ADD_FILES),-add $(subst $(COMMA), ,$(extra))) \
309 $(HELP_FILES) \
310 $(if $(HELP_LINKED_MODULES),\
311 $(shell cat $(foreach module,$(HELP_LINKED_MODULES),$(call gb_HelpTarget_get_filelist,$(module)))) \
313 ) && \
314 $(gb_HelpLinkTarget_HELPLINKERCOMMAND) @$${RESPONSEFILE} && \
315 touch $@ && \
316 rm -f $${RESPONSEFILE}
317 endef
320 $(dir $(call gb_HelpLinkTarget_get_target,%)).dir :
321 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
323 $(dir $(call gb_HelpLinkTarget_get_target,%))%/.dir :
324 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
326 $(call gb_HelpLinkTarget_get_target,%) : $(gb_HelpLinkTarget_DEPS)
327 $(call gb_Output_announce,$*,$(true),HLK,3)
328 $(call gb_Trace_StartRange,$*,HLK)
329 $(call gb_HelpLinkTarget__command,$@,$*)
330 $(call gb_Trace_EndRange,$*,HLK)
332 .PHONY : $(call gb_HelpLinkTarget_get_clean_target,%)
333 $(call gb_HelpLinkTarget_get_clean_target,%) :
334 $(call gb_Output_announce,$*,$(false),HLK,3)
335 rm -f $(call gb_HelpLinkTarget_get_target,$*)
337 # Create a help linking target.
339 # depend on makefile to re-build when files are removed
341 # gb_HelpLinkTarget_HelpLinkTarget name module lang workdir
342 define gb_HelpLinkTarget_HelpLinkTarget
343 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_ADD_FILES :=
344 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_CONFIGFILE :=
345 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_EXTRA_ADD_FILES :=
346 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_FILES :=
347 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_INDEXED :=
348 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_MODULE := $(2)
349 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_LANG := $(3)
350 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_LINKED_MODULES :=
351 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_SRCDIR :=
352 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_TREE :=
353 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_WORKDIR := $(4)
355 $(call gb_HelpLinkTarget_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
356 $(call gb_HelpLinkTarget_get_target,$(1)) :| $(dir $(call gb_HelpLinkTarget_get_target,$(1))).dir
358 $(4)/$(2).tree : $(call gb_HelpLinkTarget_get_target,$(1))
360 endef
362 # gb_HelpLinkTarget_set_configfile target configfile
363 define gb_HelpLinkTarget_set_configfile
364 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_CONFIGFILE := $(2)
365 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
367 endef
369 # gb_HelpLinkTarget_set_sourcedir target source
370 define gb_HelpLinkTarget_set_sourcedir
371 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_SRCDIR := $(2)
373 endef
375 # gb_HelpLinkTarget_set_treefile target treefile
376 define gb_HelpLinkTarget_set_treefile
377 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_TREE := $(2)
378 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
380 endef
382 # gb_HelpLinkTarget_set_indexed target indexfiles
383 define gb_HelpLinkTarget_set_indexed
384 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_INDEXED := $(2)
385 $(addprefix $(call gb_HelpTarget_get_workdir,$(1))/,$(2)) : $(call gb_HelpIndexTarget_get_target,$(1))
387 endef
389 # gb_HelpLinkTarget_add_helpfile target helpfile
390 define gb_HelpLinkTarget_add_helpfile
391 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_FILES += $(2)
392 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
394 endef
396 # Add an arbitrary file to the help pack.
398 # The file will be added to the root directory of the pack.
400 # gb_HelpLinkTarget_add_file target file
401 define gb_HelpLinkTarget_add_file
402 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_ADD_FILES += $(2)
403 $(call gb_HelpLinkTarget_get_target,$(1)) : $(2)
405 endef
407 # Add an arbitrary file to the help pack under a new name.
409 # The file will be added to the root directory of the pack.
411 # gb_HelpLinkTarget_add_renamed_file target filename file
412 define gb_HelpLinkTarget_add_renamed_file
413 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_EXTRA_ADD_FILES += $(strip $(2)),$(strip $(3))
414 $(call gb_HelpLinkTarget_get_target,$(1)) : $(3)
415 $(call gb_HelpTarget_get_workdir,$(1))/$(2) : $(call gb_HelpLinkTarget_get_target,$(1))
416 touch $$@
418 endef
420 # Link with help files from another help module.
422 # gb_HelpLinkTarget_use_linked_module target help
423 define gb_HelpLinkTarget_use_linked_module
424 $(call gb_HelpLinkTarget_get_target,$(1)) : HELP_LINKED_MODULES += $(2)
426 endef
428 # class HelpIndexTarget
430 # Creates a full-text search index for a help module.
432 gb_HelpIndexTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,HelpIndexer)
433 gb_HelpIndexTarget_COMMAND := $(call gb_Executable_get_command,HelpIndexer)
435 # first delete the index stuff since when it is generated an existing _0.cfs
436 # will not be overwritten; instead a new _1.cfs etc. created until disk is full
437 define gb_HelpIndexTarget__command
438 $(call gb_Helper_abbreviate_dirs,\
440 rm -rf $(HELP_WORKDIR)/$(HELP_MODULE).idxl \
441 && $(gb_HelpIndexTarget_COMMAND) \
442 -dir $(HELP_WORKDIR) \
443 -lang $(HELP_LANG) \
444 -mod $(HELP_MODULE) \
445 && touch $@ \
447 || ( rm -rf $(HELP_MODULE).* ; false )
449 endef
451 $(dir $(call gb_HelpIndexTarget_get_target,%)).dir :
452 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
454 $(dir $(call gb_HelpIndexTarget_get_target,%))%/.dir :
455 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
457 $(call gb_HelpIndexTarget_get_target,%) : $(gb_HelpIndexTarget_DEPS)
458 $(call gb_Output_announce,$*,$(true),HIX,3)
459 $(call gb_Trace_StartRange,$*,HIX)
460 $(call gb_HelpIndexTarget__command,$@,$*)
461 $(call gb_Trace_EndRange,$*,HIX)
463 .PHONY : $(call gb_HelpIndexTarget_get_clean_target,%)
464 $(call gb_HelpIndexTarget_get_clean_target,%) :
465 $(call gb_Output_announce,$*,$(false),HIX,3)
466 rm -f $(call gb_HelpIndexTarget_get_target,$*)
468 # Create a help indexing target.
470 # gb_HelpIndexTarget_HelpIndexTarget target module lang workdir
471 define gb_HelpIndexTarget_HelpIndexTarget
472 $(call gb_HelpIndexTarget_get_target,$(1)) : HELP_LANG := $(3)
473 $(call gb_HelpIndexTarget_get_target,$(1)) : HELP_MODULE := $(2)
474 $(call gb_HelpIndexTarget_get_target,$(1)) : HELP_WORKDIR := $(4)
476 $(call gb_HelpIndexTarget_get_target,$(1)) :| $(dir $(call gb_HelpIndexTarget_get_target,$(1))).dir
478 endef
480 # class HelpJarTarget
482 # Packs help files processed by HelpLinker into a jar in the workdir.
484 gb_HelpJarTarget_COMMAND := zip
486 define gb_HelpJarTarget__get_command
487 cd $(HELP_WORKDIR) && \
488 $(gb_HelpJarTarget_COMMAND) -q -0 -rX --filesync --must-match $(HELP_MODULE).jar text/$(HELP_MODULE) && \
489 touch $@
490 endef
492 $(dir $(call gb_HelpJarTarget_get_target,%)).dir :
493 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
495 $(dir $(call gb_HelpJarTarget_get_target,%))%/.dir :
496 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
498 $(call gb_HelpJarTarget_get_target,%) :
499 $(call gb_Output_announce,$*,$(true),HEJ,3)
500 $(call gb_Trace_StartRange,$*,HEJ)
501 $(call gb_HelpJarTarget__get_command,$@,$*)
502 $(call gb_Trace_EndRange,$*,HEJ)
504 $(call gb_HelpJarTarget_get_clean_target,%) :
505 $(call gb_Output_announce,$*,$(false),HEJ,3)
506 rm -f $(call gb_HelpJarTarget_get_target,$*)
508 # gb_HelpJarTarget_HelpJarTarget target module workdir
509 define gb_HelpJarTarget_HelpJarTarget
510 $(call gb_HelpJarTarget_get_target,$(1)) : HELP_MODULE := $(2)
511 $(call gb_HelpJarTarget_get_target,$(1)) : HELP_WORKDIR := $(3)
513 $(call gb_HelpJarTarget_get_target,$(1)) :| $(dir $(call gb_HelpJarTarget_get_target,$(1))).dir
515 $(3)/$(2).jar : $(call gb_HelpJarTarget_get_target,$(1))
517 endef
519 # class HelpTarget
521 # Creates one language version of a help module.
523 # Provides a filelist called HelpTarget/<name>, that is not built by
524 # default (i.e., the user of HelpTarget has to explicitly depend on the
525 # Package).
527 gb_HelpTarget_DEFAULT_LANG := en-US
529 gb_HelpTarget__get_module = $(patsubst %/$(call gb_HelpTarget__get_lang,$(1)),%,$(1))
530 gb_HelpTarget__get_lang = $(lastword $(subst /, ,$(1)))
531 gb_HelpTarget__test_default_lang = $(filter $(gb_HelpTarget_DEFAULT_LANG),$(1))
532 gb_HelpTarget__is_default_lang = $(call gb_HelpTarget__test_default_lang,$(call gb_HelpTarget__get_lang,$(1)))
534 define gb_HelpTarget__get_helpdir
535 $(if $(call gb_HelpTarget__is_default_lang,$(1)) \
536 ,$(SRCDIR)/$(2) \
537 ,$(call gb_HelpTranslateTarget_get_workdir,$(1),$(2)) \
539 endef
541 define gb_HelpTarget__get_helpfile
542 $(if $(call gb_HelpTarget__is_default_lang,$(1)) \
543 ,$(SRCDIR)/$(2).xhp \
544 ,$(call gb_HelpTranslateTarget_get_translated_target,$(1),$(2)) \
546 endef
548 define gb_HelpTarget__get_treefile
549 $(if $(call gb_HelpTarget__is_default_lang,$(1)) \
550 ,$(SRCDIR)/$(2).tree \
551 ,$(call gb_HelpTreeTarget_get_target,$(1)) \
553 endef
555 define gb_HelpTarget__command
556 $(if $(ENABLE_HTMLHELP),,$(call gb_Output_announce,$(2),$(true),HLP,4))
557 $(if $(ENABLE_HTMLHELP),,$(call gb_Trace_MakeMark,$(2),HLP))
558 touch $@
559 endef
561 $(dir $(call gb_HelpTarget_get_target,%)).dir :
562 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
564 $(dir $(call gb_HelpTarget_get_target,%))%/.dir :
565 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
567 # Translation of the module's .xhp files and all used modules is done.
568 # Also creates the list for gb_HelpTarget_get_filelist.
569 $(call gb_HelpTarget_get_translation_target,%) :
570 $(file >$@,$(strip $(HELP_FILES)))
572 # Translation of the module's .xhp files and all used and linked modules
573 # is done.
574 $(call gb_HelpTarget_get_linked_target,%) :
575 touch $@
577 $(call gb_HelpTarget_get_target,%) :
578 $(call gb_HelpTarget__command,$@,$*)
580 .PHONY : $(call gb_HelpTarget_get_clean_target,%)
581 $(call gb_HelpTarget_get_clean_target,%) :
582 ifeq ($(ENABLE_HTMLHELP),)
583 $(call gb_Output_announce,$*,$(false),HLP,4)
584 endif
585 $(call gb_Helper_abbreviate_dirs,\
586 rm -rf \
587 $(call gb_HelpTarget_get_linked_target,$*) \
588 $(call gb_HelpTarget_get_target,$*) \
589 $(call gb_HelpTarget_get_translation_target,$*) \
590 $(call gb_HelpTarget_get_workdir,$*) \
593 gb_HelpTarget_get_packagename = HelpTarget/$(1)
595 # Create a help target.
597 # depend on makefile to re-build filelist when files are removed
599 # gb_HelpTarget_HelpTarget target module lang
600 define gb_HelpTarget_HelpTarget
601 $(call gb_HelpTarget_get_target,$(1)) : HELP_MODULE := $(2)
602 $(call gb_HelpTarget_get_target,$(1)) : HELP_LANG := $(3)
604 $(call gb_HelpTarget_get_translation_target,$(1)) : HELP_FILES :=
605 $(call gb_HelpTarget_get_translation_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
607 $(call gb_HelpTarget__HelpTarget_impl,$(1),$(2),$(3),$(call gb_HelpTarget_get_workdir,$(1)),$(call gb_HelpTarget_get_packagename,$(1)))
609 endef
611 # gb_HelpTarget__HelpTarget_impl target module lang workdir package
612 define gb_HelpTarget__HelpTarget_impl
613 $(if $(call gb_HelpTarget__test_default_lang,$(3)),,$(call gb_HelpTarget__HelpTarget_impl_lang,$(1),$(2),$(3),$(4)))
615 ifeq ($(ENABLE_HTMLHELP),)
616 $(call gb_HelpLinkTarget_HelpLinkTarget,$(1),$(2),$(3),$(4))
617 $(call gb_HelpIndexTarget_HelpIndexTarget,$(1),$(2),$(3),$(4))
618 $(call gb_HelpJarTarget_HelpJarTarget,$(1),$(2),$(4))
619 $(call gb_Package_Package_internal,$(5),$(4))
620 endif
622 $(call gb_HelpTarget_get_linked_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(1))
623 ifeq ($(ENABLE_HTMLHELP),)
624 $(call gb_HelpLinkTarget_get_target,$(1)) : $(call gb_HelpTarget_get_linked_target,$(1))
625 $(call gb_HelpLinkTarget_get_target,$(1)) :| $(call gb_HelpTarget_get_workdir,$(1))/.dir
626 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
627 $(call gb_Package_get_preparation_target,$(5)) : $(call gb_HelpTarget_get_target,$(1))
628 endif
630 $(call gb_HelpTarget_get_linked_target,$(1)) :| $(dir $(call gb_HelpTarget_get_linked_target,$(1))).dir
631 $(call gb_HelpTarget_get_target,$(1)) :| $(dir $(call gb_HelpTarget_get_target,$(1))).dir
632 $(call gb_HelpTarget_get_translation_target,$(1)) :| $(dir $(call gb_HelpTarget_get_translation_target,$(1))).dir
634 ifeq ($(ENABLE_HTMLHELP),)
635 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpLinkTarget_get_clean_target,$(1))
636 endif
638 endef
640 # gb_HelpTarget__HelpTarget_impl_lang target module lang workdir
641 define gb_HelpTarget__HelpTarget_impl_lang
642 $(call gb_HelpTranslateTarget_HelpTranslateTarget,$(1),$(3))
643 $(call gb_HelpTreeTarget_HelpTreeTarget,$(1),$(3))
645 $(call gb_HelpTarget_get_translation_target,$(1)) : $(call gb_HelpTranslateTarget_get_target,$(1))
646 $(call gb_HelpTreeTarget_get_target,$(1)) : $(call gb_HelpTarget_get_linked_target,$(1))
648 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpTranslateTarget_get_clean_target,$(1))
649 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpTreeTarget_get_clean_target,$(1))
651 endef
653 # need a rule for these because these are targets for the Package
654 $(WORKDIR)/HelpTarget/%.tree :
655 touch $@
656 $(WORKDIR)/HelpTarget/%.jar :
657 touch $@
658 $(WORKDIR)/HelpTarget/%.db :
659 touch $@
660 $(WORKDIR)/HelpTarget/%.ht :
661 touch $@
662 $(WORKDIR)/HelpTarget/%.key :
663 touch $@
664 $(WORKDIR)/HelpTarget/%.idxl/_0.cfs :
665 touch $@
666 $(WORKDIR)/HelpTarget/%.idxl/segments_3 :
667 touch $@
668 $(WORKDIR)/HelpTarget/%.idxl/segments.gen :
669 touch $@
671 # Get list of the various index files.
673 # gb_HelpTarget__add_index_files target module
674 define gb_HelpTarget__get_index_files
675 $(foreach suffix,.db .ht .idxl/_0.cfs .idxl/segments_3 .idxl/segments.gen .key,$(addsuffix $(suffix),$(call gb_HelpTarget__get_module,$(1))))
676 endef
678 # gb_HelpTarget__add_file target file
679 define gb_HelpTarget__add_file
680 ifeq ($(ENABLE_HTMLHELP),)
681 $(call gb_Package_add_file,$(call gb_HelpTarget_get_packagename,$(1)),$(LIBO_SHARE_HELP_FOLDER)/$(call gb_HelpTarget__get_lang,$(1))/$(2),$(2))
682 endif
684 endef
686 # Set config. file used for the help module.
688 # The configfile is relative to $(SRCDIR) and without extension.
690 # gb_HelpTarget_set_configfile target configfile
691 define gb_HelpTarget_set_configfile
692 ifeq ($(ENABLE_HTMLHELP),)
693 $(call gb_HelpLinkTarget_set_configfile,$(1),$(SRCDIR)/$(2).cfg)
694 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).cfg)
695 endif
697 endef
699 # gb_HelpTarget_set_helpdir target helpdir
700 define gb_HelpTarget_set_helpdir
701 ifeq ($(ENABLE_HTMLHELP),)
702 $(call gb_HelpLinkTarget_set_sourcedir,$(1),$(call gb_HelpTarget__get_helpdir,$(1),$(2)))
703 endif
705 endef
707 # gb_HelpTarget_set_treefile target treefile textdir
708 define gb_HelpTarget_set_treefile
709 $(if $(call gb_HelpTarget__is_default_lang,$(1)),,\
710 $(call gb_HelpTreeTarget_set_treefile,$(1),$(2)) \
711 $(call gb_HelpTreeTarget_set_helptextdir,$(1),$(call gb_HelpTarget__get_helpdir,$(1),$(3))) \
713 ifeq ($(ENABLE_HTMLHELP),)
714 $(call gb_HelpLinkTarget_set_treefile,$(1),$(call gb_HelpTarget__get_treefile,$(1),$(2)))
715 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).tree)
716 endif
718 endef
720 # Produce full text search index, bookmark list, etc.
722 # gb_HelpTarget_set_indexed target
723 define gb_HelpTarget_set_indexed
724 ifeq ($(ENABLE_HTMLHELP),)
725 $(call gb_HelpLinkTarget_set_indexed,$(1),$(call gb_HelpTarget__get_index_files,$(1)))
726 $(foreach file,$(call gb_HelpTarget__get_index_files,$(1)),$(call gb_HelpTarget__add_file,$(1),$(file)))
728 $(call gb_HelpIndexTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
729 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpIndexTarget_get_target,$(1))
730 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpIndexTarget_get_clean_target,$(1))
731 endif
733 endef
735 # gb_HelpTarget__add_jar target
736 define gb_HelpTarget__add_jar
737 ifeq ($(ENABLE_HTMLHELP),)
738 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).jar)
739 $(call gb_HelpJarTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
740 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpJarTarget_get_target,$(1))
741 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpJarTarget_get_clean_target,$(1))
742 endif
744 endef
746 define gb_HelpTarget__add_helpfile_impl
747 ifeq ($(ENABLE_HTMLHELP),)
748 $(call gb_HelpLinkTarget_add_helpfile,$(1),$(2))
749 endif
751 $(call gb_HelpTarget_get_translation_target,$(1)) : HELP_FILES += $(2)
753 endef
755 # gb_HelpTarget__add_helpfile target helpfile
756 define gb_HelpTarget__add_helpfile
757 $(call gb_HelpTarget__add_helpfile_impl,$(1),$(call gb_HelpTarget__get_helpfile,$(1),$(2)))
759 endef
761 # gb_HelpTarget_add_helpfile target helpfile
762 define gb_HelpTarget_add_helpfile
763 $(call gb_HelpTranslateTarget_add_file,$(1),$(2))
764 $(call gb_HelpTarget__add_helpfile,$(1),$(2))
765 ifeq ($(ENABLE_HTMLHELP),)
766 $(call gb_HelpTarget__add_jar,$(1))
767 endif
769 endef
771 # gb_HelpTarget_add_helpfiles target helpfile(s)
772 define gb_HelpTarget_add_helpfiles
773 $(call gb_HelpTranslateTarget_add_files,$(1),$(2))
774 $(foreach helpfile,$(2),$(call gb_HelpTarget__add_helpfile,$(1),$(helpfile)))
775 ifeq ($(ENABLE_HTMLHELP),)
776 $(call gb_HelpTarget__add_jar,$(1))
777 endif
779 endef
781 # gb_HelpTarget_add_file target file
782 define gb_HelpTarget_add_file
783 ifeq ($(ENABLE_HTMLHELP),)
784 $(call gb_HelpLinkTarget_add_file,$(1),$(SRCDIR)/$(2))
785 $(call gb_HelpTarget__add_file,$(1),$(notdir $(2)))
786 endif
788 endef
790 # gb_HelpTarget_add_files target file(s)
791 define gb_HelpTarget_add_files
792 $(foreach file,$(2),$(call gb_HelpTarget_add_file,$(1),$(file)))
794 endef
796 # Add a localized file from helpdir under a new name.
798 # This is a hack needed for err.html in shared help module.
800 # gb_HelpTarget_add_helpdir_file target filename file
801 define gb_HelpTarget_add_helpdir_file
802 ifeq ($(ENABLE_HTMLHELP),)
803 $(call gb_HelpLinkTarget_add_renamed_file,$(1),$(2),$(call gb_HelpTarget__get_helpfile,$(1),$(3)))
804 $(call gb_HelpTarget__add_file,$(1),$(2))
805 endif
807 endef
809 # gb_HelpTarget_use_module target module
810 define gb_HelpTarget_use_module
811 $(call gb_HelpTarget_get_translation_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(2))
813 endef
815 # gb_HelpTarget_use_modules target module(s)
816 define gb_HelpTarget_use_modules
817 $(foreach module,$(2),$(call gb_HelpTarget_use_module,$(1),$(module)))
819 endef
821 # gb_HelpTarget_use_linked_module target module
822 define gb_HelpTarget_use_linked_module
823 ifeq ($(ENABLE_HTMLHELP),)
824 $(call gb_HelpLinkTarget_use_linked_module,$(1),$(2))
825 $(call gb_HelpTarget_get_linked_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(2))
826 endif
828 endef
830 # gb_HelpTarget_use_linked_modules target module(s)
831 define gb_HelpTarget_use_linked_modules
832 $(foreach module,$(2),$(call gb_HelpTarget_use_linked_module,$(1),$(module)))
834 endef
836 # vim: set noet sw=4 ts=4: