Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / HelpTarget.mk
bloba541a4776e801199c47bfa92d587ea1fc999f7ad
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 ceated 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 $(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,$(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 $(call gb_Output_announce,$*,$(false),HLP,4)
571 $(call gb_Helper_abbreviate_dirs,\
572 rm -rf \
573 $(call gb_HelpTarget_get_linked_target,$*) \
574 $(call gb_HelpTarget_get_target,$*) \
575 $(call gb_HelpTarget_get_translation_target,$*) \
576 $(call gb_HelpTarget_get_workdir,$*) \
579 gb_HelpTarget_get_packagename = HelpTarget/$(1)
581 # Create a help target.
583 # depend on makefile to re-build filelist when files are removed
585 # gb_HelpTarget_HelpTarget target module lang
586 define gb_HelpTarget_HelpTarget
587 $(call gb_HelpTarget_get_target,$(1)) : HELP_MODULE := $(2)
588 $(call gb_HelpTarget_get_target,$(1)) : HELP_LANG := $(3)
590 $(call gb_HelpTarget_get_translation_target,$(1)) : HELP_FILES :=
591 $(call gb_HelpTarget_get_translation_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
593 $(call gb_HelpTarget__HelpTarget_impl,$(1),$(2),$(3),$(call gb_HelpTarget_get_workdir,$(1)),$(call gb_HelpTarget_get_packagename,$(1)))
595 endef
597 # gb_HelpTarget__HelpTarget_impl target module lang workdir package
598 define gb_HelpTarget__HelpTarget_impl
599 $(if $(call gb_HelpTarget__test_default_lang,$(3)),,$(call gb_HelpTarget__HelpTarget_impl_lang,$(1),$(2),$(3),$(4)))
600 $(call gb_HelpLinkTarget_HelpLinkTarget,$(1),$(2),$(3),$(4))
601 $(call gb_HelpIndexTarget_HelpIndexTarget,$(1),$(2),$(3),$(4))
602 $(call gb_HelpJarTarget_HelpJarTarget,$(1),$(2),$(4))
603 $(call gb_Package_Package_internal,$(5),$(4))
605 $(call gb_HelpTarget_get_linked_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(1))
606 $(call gb_HelpLinkTarget_get_target,$(1)) : $(call gb_HelpTarget_get_linked_target,$(1))
607 $(call gb_HelpLinkTarget_get_target,$(1)) :| $(call gb_HelpTarget_get_workdir,$(1))/.dir
608 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
609 $(call gb_Package_get_preparation_target,$(5)) : $(call gb_HelpTarget_get_target,$(1))
611 $(call gb_HelpTarget_get_linked_target,$(1)) :| $(dir $(call gb_HelpTarget_get_linked_target,$(1))).dir
612 $(call gb_HelpTarget_get_target,$(1)) :| $(dir $(call gb_HelpTarget_get_target,$(1))).dir
613 $(call gb_HelpTarget_get_translation_target,$(1)) :| $(dir $(call gb_HelpTarget_get_translation_target,$(1))).dir
615 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpLinkTarget_get_clean_target,$(1))
617 endef
619 # gb_HelpTarget__HelpTarget_impl_lang target module lang workdir
620 define gb_HelpTarget__HelpTarget_impl_lang
621 $(call gb_HelpTranslateTarget_HelpTranslateTarget,$(1),$(3))
622 $(call gb_HelpTreeTarget_HelpTreeTarget,$(1),$(3))
624 $(call gb_HelpTarget_get_translation_target,$(1)) : $(call gb_HelpTranslateTarget_get_target,$(1))
625 $(call gb_HelpTreeTarget_get_target,$(1)) : $(call gb_HelpTarget_get_linked_target,$(1))
627 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpTranslateTarget_get_clean_target,$(1))
628 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpTreeTarget_get_clean_target,$(1))
630 endef
632 # need a rule for these because these are targets for the Package
633 $(WORKDIR)/HelpTarget/%.tree :
634 touch $@
635 $(WORKDIR)/HelpTarget/%.jar :
636 touch $@
637 $(WORKDIR)/HelpTarget/%.db :
638 touch $@
639 $(WORKDIR)/HelpTarget/%.ht :
640 touch $@
641 $(WORKDIR)/HelpTarget/%.key :
642 touch $@
643 $(WORKDIR)/HelpTarget/%.idxl/_0.cfs :
644 touch $@
645 $(WORKDIR)/HelpTarget/%.idxl/segments_3 :
646 touch $@
647 $(WORKDIR)/HelpTarget/%.idxl/segments.gen :
648 touch $@
650 # Get list of the various index files.
652 # gb_HelpTarget__add_index_files target module
653 define gb_HelpTarget__get_index_files
654 $(foreach suffix,.db .ht .idxl/_0.cfs .idxl/segments_3 .idxl/segments.gen .key,$(addsuffix $(suffix),$(call gb_HelpTarget__get_module,$(1))))
655 endef
657 # gb_HelpTarget__add_file target file
658 define gb_HelpTarget__add_file
659 $(call gb_Package_add_file,$(call gb_HelpTarget_get_packagename,$(1)),$(LIBO_SHARE_HELP_FOLDER)/$(call gb_HelpTarget__get_lang,$(1))/$(2),$(2))
661 endef
663 # Set config. file used for the help module.
665 # The configfile is relative to $(SRCDIR) and without extension.
667 # gb_HelpTarget_set_configfile target configfile
668 define gb_HelpTarget_set_configfile
669 $(call gb_HelpLinkTarget_set_configfile,$(1),$(SRCDIR)/$(2).cfg)
670 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).cfg)
672 endef
674 # gb_HelpTarget_set_helpdir target helpdir
675 define gb_HelpTarget_set_helpdir
676 $(call gb_HelpLinkTarget_set_sourcedir,$(1),$(call gb_HelpTarget__get_helpdir,$(1),$(2)))
678 endef
680 # gb_HelpTarget_set_treefile target treefile textdir
681 define gb_HelpTarget_set_treefile
682 $(if $(call gb_HelpTarget__is_default_lang,$(1)),,\
683 $(call gb_HelpTreeTarget_set_treefile,$(1),$(2)) \
684 $(call gb_HelpTreeTarget_set_helptextdir,$(1),$(call gb_HelpTarget__get_helpdir,$(1),$(3))) \
686 $(call gb_HelpLinkTarget_set_treefile,$(1),$(call gb_HelpTarget__get_treefile,$(1),$(2)))
687 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).tree)
689 endef
691 # Produce full text search index, bookmark list, etc.
693 # gb_HelpTarget_set_indexed target
694 define gb_HelpTarget_set_indexed
695 $(call gb_HelpLinkTarget_set_indexed,$(1),$(call gb_HelpTarget__get_index_files,$(1)))
696 $(foreach file,$(call gb_HelpTarget__get_index_files,$(1)),$(call gb_HelpTarget__add_file,$(1),$(file)))
698 $(call gb_HelpIndexTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
699 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpIndexTarget_get_target,$(1))
700 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpIndexTarget_get_clean_target,$(1))
702 endef
704 # gb_HelpTarget__add_jar target
705 define gb_HelpTarget__add_jar
706 $(call gb_HelpTarget__add_file,$(1),$(call gb_HelpTarget__get_module,$(1)).jar)
707 $(call gb_HelpJarTarget_get_target,$(1)) : $(call gb_HelpLinkTarget_get_target,$(1))
708 $(call gb_HelpTarget_get_target,$(1)) : $(call gb_HelpJarTarget_get_target,$(1))
709 $(call gb_HelpTarget_get_clean_target,$(1)) : $(call gb_HelpJarTarget_get_clean_target,$(1))
711 endef
713 define gb_HelpTarget__add_helpfile_impl
714 $(call gb_HelpLinkTarget_add_helpfile,$(1),$(2))
716 $(call gb_HelpTarget_get_translation_target,$(1)) : HELP_FILES += $(2)
718 endef
720 # gb_HelpTarget__add_helpfile target helpfile
721 define gb_HelpTarget__add_helpfile
722 $(call gb_HelpTarget__add_helpfile_impl,$(1),$(call gb_HelpTarget__get_helpfile,$(1),$(2)))
724 endef
726 # gb_HelpTarget_add_helpfile target helpfile
727 define gb_HelpTarget_add_helpfile
728 $(call gb_HelpTranslateTarget_add_file,$(1),$(2))
729 $(call gb_HelpTarget__add_helpfile,$(1),$(2))
730 $(call gb_HelpTarget__add_jar,$(1))
732 endef
734 # gb_HelpTarget_add_helpfiles target helpfile(s)
735 define gb_HelpTarget_add_helpfiles
736 $(call gb_HelpTranslateTarget_add_files,$(1),$(2))
737 $(foreach helpfile,$(2),$(call gb_HelpTarget__add_helpfile,$(1),$(helpfile)))
738 $(call gb_HelpTarget__add_jar,$(1))
740 endef
742 # gb_HelpTarget_add_file target file
743 define gb_HelpTarget_add_file
744 $(call gb_HelpLinkTarget_add_file,$(1),$(SRCDIR)/$(2))
745 $(call gb_HelpTarget__add_file,$(1),$(notdir $(2)))
747 endef
749 # gb_HelpTarget_add_files target file(s)
750 define gb_HelpTarget_add_files
751 $(foreach file,$(2),$(call gb_HelpTarget_add_file,$(1),$(file)))
753 endef
755 # Add a localized file from helpdir under a new name.
757 # This is a hack needed for err.html in shared help module.
759 # gb_HelpTarget_add_helpdir_file target filename file
760 define gb_HelpTarget_add_helpdir_file
761 $(call gb_HelpLinkTarget_add_renamed_file,$(1),$(2),$(call gb_HelpTarget__get_helpfile,$(1),$(3)))
762 $(call gb_HelpTarget__add_file,$(1),$(2))
764 endef
766 # gb_HelpTarget_use_module target module
767 define gb_HelpTarget_use_module
768 $(call gb_HelpTarget_get_translation_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(2))
770 endef
772 # gb_HelpTarget_use_modules target module(s)
773 define gb_HelpTarget_use_modules
774 $(foreach module,$(2),$(call gb_HelpTarget_use_module,$(1),$(module)))
776 endef
778 # gb_HelpTarget_use_linked_module target module
779 define gb_HelpTarget_use_linked_module
780 $(call gb_HelpLinkTarget_use_linked_module,$(1),$(2))
781 $(call gb_HelpTarget_get_linked_target,$(1)) : $(call gb_HelpTarget_get_translation_target,$(2))
783 endef
785 # gb_HelpTarget_use_linked_modules target module(s)
786 define gb_HelpTarget_use_linked_modules
787 $(foreach module,$(2),$(call gb_HelpTarget_use_linked_module,$(1),$(module)))
789 endef
791 # vim: set noet sw=4 ts=4: