Bump version to 6.4.7.2.M8
[LibreOffice.git] / solenv / gbuild / Gallery.mk
bloba810715540a15ae69d19e0694fd9dc9b996bedda
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # class Gallery
12 # Handles creation of image galleries.
14 gb_Gallery_TRANSLATE := $(SRCDIR)/solenv/bin/desktop-translate.pl
15 gb_Gallery_INSTDIR := $(LIBO_SHARE_FOLDER)/gallery
17 define gb_Gallery__command
18 $(call gb_Output_announce,$(2),$(true),GAL,1)
19 $(call gb_Helper_abbreviate_dirs,\
20 rm -f $(call gb_Gallery_get_workdir,$(2))/* && \
21 RESPONSEFILE=$(call var2file,$(shell $(call gb_MKTEMP)),100,$(GALLERY_FILES)) && \
22 $(call gb_Helper_print_on_error,\
23 $(call gb_Executable_get_command,gengal,$(ICECREAM_RUN)) \
24 --build-tree \
25 --destdir $(GALLERY_BASEDIR) \
26 --name "$(GALLERY_NAME)" \
27 --path $(call gb_Gallery_get_workdir,$(2)) \
28 --filenames $(call gb_Helper_make_url,$$RESPONSEFILE),\
29 $@.log \
30 ) && \
31 rm $$RESPONSEFILE && \
32 touch $@ \
34 endef
36 define gb_Gallery__command_str
37 $(call gb_Output_announce,$(2),$(true),STR,1)
38 cp -f $(GALLERY_STRFILE) $@ && \
39 $(PERL) $(gb_Gallery_TRANSLATE) \
40 --ext "str" --key "name" \
41 -d $(GALLERY_WORKDIR) \
42 $(GALLERY_ULFFILE)
43 endef
45 gb_Gallery__get_final_target = $(WORKDIR)/Gallery/$(1).final
47 $(dir $(call gb_Gallery_get_target,$(1))).dir :
48 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
50 $(dir $(call gb_Gallery_get_target,$(1)))%/.dir :
51 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
53 $(call gb_Gallery_get_target,%) : \
54 $(call gb_Executable_get_runtime_dependencies,gengal)
55 $(call gb_Gallery__command,$@,$*)
57 $(call gb_Gallery__get_final_target,%) :
58 touch $@
60 # difficult to determine source dep for this one...
61 $(call gb_Gallery_get_workdir,%).ulf : \
62 $(call gb_Executable_get_runtime_dependencies,ulfex)
63 $(call gb_CustomTarget_ulfex__command,$@,$(GALLERY_ULFFILE),\
64 $(foreach lang,$(gb_TRANS_LANGS),\
65 $(gb_POLOCATION)/$(lang)/extras/source/gallery/share.po))
67 $(call gb_Gallery_get_workdir,%).str : $(gb_Gallery_TRANSLATE)
68 $(call gb_Gallery__command_str,$@,$*)
70 # there must be a rule for these since they are targets due to Package
71 $(call gb_Gallery_get_workdir,%).sdg :
72 touch $@
73 $(call gb_Gallery_get_workdir,%).sdv :
74 touch $@
75 $(call gb_Gallery_get_workdir,%).thm :
76 touch $@
78 .PHONY : $(call gb_Gallery_get_clean_target,%)
79 $(call gb_Gallery_get_clean_target,%) :
80 $(call gb_Output_announce,$*,$(false),GAL,1)
81 $(call gb_Helper_abbreviate_dirs,\
82 rm -rf \
83 $(call gb_Gallery__get_final_target,$*) \
84 $(call gb_Gallery_get_target,$*) \
85 $(call gb_Gallery_get_target,$*).log \
86 $(call gb_Gallery_get_workdir,$*) \
89 # the theme package
90 gb_Gallery_get_packagename = Gallery/$(1)
91 # the files package
92 gb_Gallery_get_files_packagename = Gallery/Files/$(1)
94 # Create a gallery.
96 # basedir less one directory will be stripped from paths of the files when they are
97 # inserted into the gallery.
99 # gb_Gallery_Gallery gallery basedir name
100 define gb_Gallery_Gallery
101 $(call gb_Gallery__Gallery_impl,$(1),$(call gb_Gallery_get_packagename,$(1)),$(2),$(3))
103 # setup the files package - we install all of these too
104 $(call gb_Package_Package_internal,$(call gb_Gallery_get_files_packagename,$(1)),$(SRCDIR)/$(2))
105 $(call gb_Gallery__get_final_target,$(1)) : $(call gb_Package_get_target,$(call gb_Gallery_get_files_packagename,$(1)))
106 $(call gb_Gallery_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(call gb_Gallery_get_files_packagename,$(1)))
108 endef
111 gb_Gallery_basedir = $(patsubst %/,%,$(dir $(SRCDIR)/$(1)))
113 # TODO: we process the same ulf file for every gallery. That does not
114 # make sense.
116 # gb_Gallery__Gallery_impl gallery package basedir name
117 define gb_Gallery__Gallery_impl
118 $(call gb_Package_Package_internal,$(2),$(call gb_Gallery_get_workdir,$(1)))
119 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdg,$(1).sdg)
120 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdv,$(1).sdv)
121 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).thm,$(1).thm)
122 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).str,$(1).str)
124 # strip URL, without / to help the internal gallery system
125 $(call gb_Gallery_get_target,$(1)) : GALLERY_BASEDIR := $(call gb_Helper_make_url,$(call gb_Gallery_basedir,$(3)))
126 $(call gb_Gallery_get_target,$(1)) : GALLERY_FILES :=
127 $(call gb_Gallery_get_target,$(1)) : GALLERY_NAME := $(1)
128 $(call gb_Gallery_get_workdir,$(1))/$(1).str : GALLERY_STRFILE := $(SRCDIR)/$(3)/$(1).str
129 $(call gb_Gallery_get_workdir,$(1))/$(1).str : GALLERY_ULFFILE := $(call gb_Gallery_get_workdir,$(1))/$(1).ulf
130 $(call gb_Gallery_get_workdir,$(1))/$(1).str : GALLERY_WORKDIR := $(call gb_Gallery_get_workdir,$(1))
131 $(call gb_Gallery_get_workdir,$(1))/$(1).ulf : GALLERY_BASEDIR := $(3)
132 $(call gb_Gallery_get_workdir,$(1))/$(1).ulf : GALLERY_ULFFILE := $(call gb_Gallery_basedir,$(3))/share/gallery_names.ulf
134 $(call gb_Gallery_get_workdir,$(1))/$(1).ulf : \
135 $(call gb_Gallery_basedir,$(3))/share/gallery_names.ulf \
136 $(call gb_Gallery_get_target,$(1)) # that rule pre-cleans our output directory
138 $(call gb_Gallery_get_workdir,$(1))/$(1).str : $(call gb_Gallery_get_workdir,$(1))/$(1).ulf
140 $(call gb_Gallery_get_workdir,$(1))/$(1).sdg \
141 $(call gb_Gallery_get_workdir,$(1))/$(1).sdv \
142 $(call gb_Gallery_get_workdir,$(1))/$(1).thm : $(call gb_Gallery_get_target,$(1))
143 $(call gb_Gallery__get_final_target,$(1)) : $(call gb_Package_get_target,$(2))
145 $(call gb_Gallery_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(2))
146 $(call gb_Gallery_get_target,$(1)) :| $(dir $(call gb_Gallery_get_target,$(1))).dir \
147 $(call gb_Gallery_get_workdir,$(1))/.dir
149 $$(eval $$(call gb_Module_register_target,Gallery_$(1),$(call gb_Gallery__get_final_target,$(1)),$(call gb_Gallery_get_clean_target,$(1))))
150 $(call gb_Helper_make_userfriendly_targets,$(1),Gallery,$(call gb_Gallery__get_final_target,$(1)))
152 endef
154 # Add a file to the gallery.
156 # The file is given by path relative to $(SRCDIR).
158 # gb_Gallery_add_file gallery file
159 define gb_Gallery_add_file
160 $(call gb_Gallery_get_target,$(1)) : $(SRCDIR)/$(3)
161 $(call gb_Gallery_get_target,$(1)) : GALLERY_FILES += $(call gb_Helper_make_url,$(SRCDIR)/$(3))
162 $(call gb_Package_add_file,$(call gb_Gallery_get_files_packagename,$(1)),$(2)/$(notdir $(3)),$(notdir $(3)))
164 endef
166 # Add several files to the gallery at once.
168 # The files are given by path relative to $(SRCDIR).
170 # gb_Gallery_add_files gallery file(s)
171 define gb_Gallery_add_files
172 $(foreach fname,$(3),$(call gb_Gallery_add_file,$(1),$(2),$(fname)))
174 endef
176 # vim: set noet sw=4 ts=4: