Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / solenv / gbuild / Gallery.mk
blobd08fe69aef55467e2f2d650ec0928a3d3fc526be
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 $(if $(filter-out MACOSX WNT,$(OS_FOR_BUILD)),$(if $(ENABLE_HEADLESS),, \
24 SAL_USE_VCLPLUGIN=svp \
25 )) \
26 $(call gb_Executable_get_command,gengal,$(ICECREAM_RUN)) \
27 --build-tree \
28 --destdir $(GALLERY_BASEDIR) \
29 --name "$(GALLERY_NAME)" \
30 --path $(call gb_Gallery_get_workdir,$(2)) \
31 --filenames $(call gb_Helper_make_url,$$RESPONSEFILE),\
32 $@.log \
33 ) && \
34 rm $$RESPONSEFILE && \
35 touch $@ \
37 endef
39 define gb_Gallery__command_str
40 $(call gb_Output_announce,$(2),$(true),STR,1)
41 cp -f $(GALLERY_STRFILE) $@ && \
42 $(PERL) $(gb_Gallery_TRANSLATE) \
43 --ext "str" --key "name" \
44 -d $(GALLERY_WORKDIR) \
45 $(GALLERY_ULFFILE)
46 endef
48 gb_Gallery__get_final_target = $(WORKDIR)/Gallery/$(1).final
50 $(dir $(call gb_Gallery_get_target,$(1))).dir :
51 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
53 $(dir $(call gb_Gallery_get_target,$(1)))%/.dir :
54 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
56 $(call gb_Gallery_get_target,%) : \
57 $(call gb_Executable_get_runtime_dependencies,gengal)
58 $(call gb_Gallery__command,$@,$*)
60 $(call gb_Gallery__get_final_target,%) :
61 touch $@
63 # difficult to determine source dep for this one...
64 $(call gb_Gallery_get_workdir,%).ulf : \
65 $(call gb_Executable_get_runtime_dependencies,ulfex)
66 $(call gb_CustomTarget_ulfex__command,$@,$(GALLERY_ULFFILE),\
67 $(foreach lang,$(gb_TRANS_LANGS),\
68 $(gb_POLOCATION)/$(lang)/extras/source/gallery/share.po))
70 $(call gb_Gallery_get_workdir,%).str : $(gb_Gallery_TRANSLATE)
71 $(call gb_Gallery__command_str,$@,$*)
73 # there must be a rule for these since they are targets due to Package
74 $(call gb_Gallery_get_workdir,%).sdg :
75 touch $@
76 $(call gb_Gallery_get_workdir,%).sdv :
77 touch $@
78 $(call gb_Gallery_get_workdir,%).thm :
79 touch $@
81 .PHONY : $(call gb_Gallery_get_clean_target,%)
82 $(call gb_Gallery_get_clean_target,%) :
83 $(call gb_Output_announce,$*,$(false),GAL,1)
84 $(call gb_Helper_abbreviate_dirs,\
85 rm -rf \
86 $(call gb_Gallery__get_final_target,$*) \
87 $(call gb_Gallery_get_target,$*) \
88 $(call gb_Gallery_get_target,$*).log \
89 $(call gb_Gallery_get_workdir,$*) \
92 # the theme package
93 gb_Gallery_get_packagename = Gallery/$(1)
94 # the files package
95 gb_Gallery_get_files_packagename = Gallery/Files/$(1)
97 # Create a gallery.
99 # basedir less one directory will be stripped from paths of the files when they are
100 # inserted into the gallery.
102 # gb_Gallery_Gallery gallery basedir name
103 define gb_Gallery_Gallery
104 $(call gb_Gallery__Gallery_impl,$(1),$(call gb_Gallery_get_packagename,$(1)),$(2),$(3))
106 # setup the files package - we install all of these too
107 $(call gb_Package_Package_internal,$(call gb_Gallery_get_files_packagename,$(1)),$(SRCDIR)/$(2))
108 $(call gb_Gallery__get_final_target,$(1)) : $(call gb_Package_get_target,$(call gb_Gallery_get_files_packagename,$(1)))
109 $(call gb_Gallery_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(call gb_Gallery_get_files_packagename,$(1)))
111 endef
114 gb_Gallery_basedir = $(patsubst %/,%,$(dir $(SRCDIR)/$(1)))
116 # TODO: we process the same ulf file for every gallery. That does not
117 # make sense.
119 # gb_Gallery__Gallery_impl gallery package basedir name
120 define gb_Gallery__Gallery_impl
121 $(call gb_Package_Package_internal,$(2),$(call gb_Gallery_get_workdir,$(1)))
122 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdg,$(1).sdg)
123 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).sdv,$(1).sdv)
124 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).thm,$(1).thm)
125 $(call gb_Package_add_file,$(2),$(gb_Gallery_INSTDIR)/$(1).str,$(1).str)
127 # strip URL, without / to help the internal gallery system
128 $(call gb_Gallery_get_target,$(1)) : GALLERY_BASEDIR := $(call gb_Helper_make_url,$(call gb_Gallery_basedir,$(3)))
129 $(call gb_Gallery_get_target,$(1)) : GALLERY_FILES :=
130 $(call gb_Gallery_get_target,$(1)) : GALLERY_NAME := $(1)
131 $(call gb_Gallery_get_workdir,$(1))/$(1).str : GALLERY_STRFILE := $(SRCDIR)/$(3)/$(1).str
132 $(call gb_Gallery_get_workdir,$(1))/$(1).str : GALLERY_ULFFILE := $(call gb_Gallery_get_workdir,$(1))/$(1).ulf
133 $(call gb_Gallery_get_workdir,$(1))/$(1).str : GALLERY_WORKDIR := $(call gb_Gallery_get_workdir,$(1))
134 $(call gb_Gallery_get_workdir,$(1))/$(1).ulf : GALLERY_BASEDIR := $(3)
135 $(call gb_Gallery_get_workdir,$(1))/$(1).ulf : GALLERY_ULFFILE := $(call gb_Gallery_basedir,$(3))/share/gallery_names.ulf
137 $(call gb_Gallery_get_workdir,$(1))/$(1).ulf : \
138 $(call gb_Gallery_basedir,$(3))/share/gallery_names.ulf \
139 $(call gb_Gallery_get_target,$(1)) # that rule pre-cleans our output directory
141 $(call gb_Gallery_get_workdir,$(1))/$(1).str : $(call gb_Gallery_get_workdir,$(1))/$(1).ulf
143 $(call gb_Gallery_get_workdir,$(1))/$(1).sdg \
144 $(call gb_Gallery_get_workdir,$(1))/$(1).sdv \
145 $(call gb_Gallery_get_workdir,$(1))/$(1).thm : $(call gb_Gallery_get_target,$(1))
146 $(call gb_Gallery__get_final_target,$(1)) : $(call gb_Package_get_target,$(2))
148 $(call gb_Gallery_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(2))
149 $(call gb_Gallery_get_target,$(1)) :| $(dir $(call gb_Gallery_get_target,$(1))).dir \
150 $(call gb_Gallery_get_workdir,$(1))/.dir
152 $$(eval $$(call gb_Module_register_target,$(call gb_Gallery__get_final_target,$(1)),$(call gb_Gallery_get_clean_target,$(1))))
153 $(call gb_Helper_make_userfriendly_targets,$(1),Gallery,$(call gb_Gallery__get_final_target,$(1)))
155 endef
157 # Add a file to the gallery.
159 # The file is given by path relative to $(SRCDIR).
161 # gb_Gallery_add_file gallery file
162 define gb_Gallery_add_file
163 $(call gb_Gallery_get_target,$(1)) : $(SRCDIR)/$(3)
164 $(call gb_Gallery_get_target,$(1)) : GALLERY_FILES += $(call gb_Helper_make_url,$(SRCDIR)/$(3))
165 $(call gb_Package_add_file,$(call gb_Gallery_get_files_packagename,$(1)),$(2)/$(notdir $(3)),$(notdir $(3)))
167 endef
169 # Add several files to the gallery at once.
171 # The files are given by path relative to $(SRCDIR).
173 # gb_Gallery_add_files gallery file(s)
174 define gb_Gallery_add_files
175 $(foreach fname,$(3),$(call gb_Gallery_add_file,$(1),$(2),$(fname)))
177 endef
179 # vim: set noet sw=4 ts=4: