1# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2#
3# This file is part of the LibreOffice project.
4#
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/.
8#
9
10$(eval $(call gb_CustomTarget_CustomTarget,extras/source/templates/styles))
11
12extras_TEMPLATES_STYLES := \
13	Default \
14	Modern \
15
16
17extras_STYLES_XMLFILES := \
18	Default/META-INF/manifest.xml \
19	Default/meta.xml \
20	Default/styles.xml \
21	Default/Thumbnails/thumbnail.png \
22	Modern/META-INF/manifest.xml \
23	Modern/meta.xml \
24	Modern/styles.xml \
25	Modern/Thumbnails/thumbnail.png \
26
27
28extras_STYLES_MIMETYPEFILES := $(foreach atexts,$(extras_TEMPLATES_STYLES),$(atexts)/mimetype)
29
30
31$(call gb_CustomTarget_get_target,extras/source/templates/styles) : \
32	$(foreach atexts,$(extras_TEMPLATES_STYLES),$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/$(atexts).ott)
33
34$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%/mimetype : $(SRCDIR)/extras/source/templates/styles/%/mimetype
35	$(call gb_Output_announce,templates/styles/$*/mimetype,$(true),CPY,1)
36	cp $< $@
37
38$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%.jpg : $(SRCDIR)/extras/source/templates/styles/%.jpg
39	$(call gb_Output_announce,templates/styles/$*.jpg,$(true),CPY,1)
40	cp $< $@
41
42$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%.png : $(SRCDIR)/extras/source/templates/styles/%.png
43	$(call gb_Output_announce,templates/styles/$*.png,$(true),CPY,1)
44	cp $< $@
45
46$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%.rdf : $(SRCDIR)/extras/source/templates/styles/%.rdf
47	$(call gb_Output_announce,templates/styles/$*.rdf,$(true),CPY,1)
48	cp $< $@
49
50$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%.svg : $(SRCDIR)/extras/source/templates/styles/%.svg
51	$(call gb_Output_announce,templates/styles/$*.svg,$(true),CPY,1)
52	cp $< $@
53
54$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%.svm : $(SRCDIR)/extras/source/templates/styles/%.svm
55	$(call gb_Output_announce,templates/styles/$*.svm,$(true),CPY,1)
56	cp $< $@
57
58$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%.xml : $(SRCDIR)/extras/source/templates/styles/%.xml \
59		| $(call gb_ExternalExecutable_get_dependencies,xsltproc)
60	$(call gb_Output_announce,templates/styles/$*.xml,$(true),XSL,1)
61	$(call gb_ExternalExecutable_get_command,xsltproc) --nonet -o $@ $(SRCDIR)/extras/util/compact.xsl $<
62
63$(call gb_CustomTarget_get_workdir,extras/source/templates/styles)/%.ott :
64	$(call gb_Output_announce,templates/styles/$*.ott,$(true),ZIP,2)
65	$(call gb_Helper_abbreviate_dirs,\
66		cd $(EXTRAS_STYLES_DIR) && \
67		zip -q0X --filesync --must-match $@ $(EXTRAS_STYLES_MIMEFILES_FILTER) && \
68		zip -qrX --must-match $@ $(EXTRAS_STYLES_XMLFILES_FILTER) \
69	)
70
71define extras_Tplstyles_make_file_deps
72$(call gb_CustomTarget_get_workdir,$(1))/$(2) : $(SRCDIR)/$(1)/$(2) \
73	| $(dir $(call gb_CustomTarget_get_workdir,$(1))/$(2)).dir
74
75endef
76
77define extras_Tplstyles_make_zip_deps
78$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
79	$(addprefix $(call gb_CustomTarget_get_workdir,$(1))/,$(filter $(3)/%,$(extras_STYLES_MIMETYPEFILES) $(extras_STYLES_XMLFILES))) \
80	| $(dir $(call gb_CustomTarget_get_workdir,$(1))/$(2)).dir
81
82$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
83	EXTRAS_STYLES_MIMEFILES_FILTER := $(foreach file,$(filter $(3)/%,$(extras_STYLES_MIMETYPEFILES)),$(subst $(3)/,,$(file)))
84$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
85	EXTRAS_STYLES_XMLFILES_FILTER := $(foreach file,$(filter $(3)/%,$(extras_STYLES_XMLFILES)),$(subst $(3)/,,$(file)))
86$(call gb_CustomTarget_get_workdir,$(1))/$(2) : \
87	EXTRAS_STYLES_DIR := $(call gb_CustomTarget_get_workdir,$(1))/$(3)
88
89endef
90
91$(eval $(foreach file,$(extras_STYLES_MIMETYPEFILES) $(extras_STYLES_XMLFILES),\
92	$(call extras_Tplstyles_make_file_deps,extras/source/templates/styles,$(file)) \
93))
94
95$(eval $(foreach atexts,$(extras_TEMPLATES_STYLES),\
96	$(call extras_Tplstyles_make_zip_deps,extras/source/templates/styles,$(atexts).ott,$(atexts)) \
97))
98
99# vim: set noet sw=4 ts=4:
100