Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / InstallModuleTarget.mk
blob54848b0bf0d8e83825474d36118c15e307178756
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 # Overview of dependencies and tasks of InstallModuleTarget
11 # target task depends on
13 # ScpTemplateTarget class
15 gb_ScpTemplateTarget_TARGET := $(SRCDIR)/scp2/source/templates/modules.pl
16 gb_ScpTemplateTarget_COMMAND := $(PERL) -w $(gb_ScpTemplateTarget_TARGET)
18 gb_ScpTemplateTarget_LANGS := $(sort $(ALL_LANGS))
20 # Pass first arg if make is running in silent mode, second arg otherwise
21 define gb_ScpTemplateTarget__if_silent
22 $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),$(1),$(2))
23 endef
25 gb_ScpTemplateTarget_get_source = $(SRCDIR)/$(1).sct
27 define gb_ScpTemplateTarget__command
28 $(call gb_Output_announce,$(2),$(true),SCT,1)
29 $(call gb_Helper_abbreviate_dirs,\
30 export COMPLETELANGISO_VAR='$(gb_ScpTemplateTarget_LANGS)' && \
31 $(gb_ScpTemplateTarget_COMMAND) \
32 $(call gb_ScpTemplateTarget__if_silent,,-verbose) \
33 -i $(SCP_TEMPLATE) \
34 -o $(1) \
36 endef
38 $(dir $(call gb_ScpTemplateTarget_get_target,%))%/.dir :
39 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
41 # depend on configure output to rebuild everything
42 $(call gb_ScpTemplateTarget_get_target,%) : \
43 $(gb_ScpTemplateTarget_TARGET) $(BUILDDIR)/config_$(gb_Side).mk
44 $(call gb_ScpTemplateTarget__command,$@,$*)
46 .PHONY : $(call gb_ScpTemplateTarget_get_clean_target,%)
47 $(call gb_ScpTemplateTarget_get_clean_target,%) :
48 $(call gb_Output_announce,$*,$(false),SCT,1)
49 rm -f $(call gb_ScpTemplateTarget_get_target,$*)
51 # gb_ScpTemplateTarget_ScpTemplateTarget(<target>)
52 define gb_ScpTemplateTarget_ScpTemplateTarget
53 $(call gb_ScpTemplateTarget_get_target,$(1)) : $(call gb_ScpTemplateTarget_get_source,$(1))
54 $(call gb_ScpTemplateTarget_get_target,$(1)) :| $(dir $(call gb_ScpTemplateTarget_get_target,$(1))).dir
55 $(call gb_ScpTemplateTarget_get_target,$(1)) : SCP_TEMPLATE := $(call gb_ScpTemplateTarget_get_source,$(1))
57 endef
59 # ScpPreprocessTarget class
61 gb_ScpPreprocessTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,cpp)
62 gb_ScpPreprocessTarget_COMMAND := $(call gb_Executable_get_command,cpp)
64 gb_ScpPreprocessTarget_get_source = $(SRCDIR)/$(1).scp
66 define gb_ScpPreprocessTarget__command
67 $(call gb_Output_announce,$(2),$(true),SPP,2)
68 $(call gb_Helper_abbreviate_dirs,\
69 $(gb_ScpPreprocessTarget_COMMAND) \
70 -+ -P \
71 $(SCPDEFS) $(SCP_DEFS) -DDLLPOSTFIX=$(gb_Library_DLLPOSTFIX) \
72 $(SCP_INCLUDE) $(SCP_TEMPLATE_INCLUDE) \
73 $(if $(ENABLE_JAVA),-DENABLE_JAVA) \
74 $(SCP_SOURCE) > $(1) \
76 endef
78 $(dir $(call gb_ScpPreprocessTarget_get_target,%))%/.dir :
79 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
81 # depend on configure output to rebuild everything
82 $(call gb_ScpPreprocessTarget_get_target,%) : \
83 $(gb_ScpPreprocessTarget_DEPS) $(BUILDDIR)/config_$(gb_Side).mk
84 $(call gb_ScpPreprocessTarget__command,$@,$*)
86 .PHONY : $(call gb_ScpPreprocessTarget_get_clean_target,%)
87 $(call gb_ScpPreprocessTarget_get_clean_target,%) :
88 $(call gb_Output_announce,$*,$(false),SPP,2)
89 rm -f $(call gb_ScpPreprocessTarget_get_target,$*)
91 # gb_ScpPreprocessTarget_ScpPreprocessTarget(<target>)
92 define gb_ScpPreprocessTarget_ScpPreprocessTarget
93 $(call gb_ScpPreprocessTarget_get_target,$(1)) : SCP_SOURCE := $(call gb_ScpPreprocessTarget_get_source,$(1))
94 $(call gb_ScpPreprocessTarget_get_target,$(1)) : $(call gb_ScpPreprocessTarget_get_source,$(1))
95 $(call gb_ScpPreprocessTarget_get_target,$(1)) :| $(dir $(call gb_ScpPreprocessTarget_get_target,$(1))).dir
97 endef
99 # ScpMergeTarget class
101 gb_ScpMergeTarget_get_source = $(SRCDIR)/$(1).ulf
103 $(dir $(call gb_ScpMergeTarget_get_target,%)).dir :
104 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
106 $(dir $(call gb_ScpMergeTarget_get_target,%))%/.dir :
107 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
109 $(eval $(call gb_CustomTarget_ulfex_rule,\
110 $(call gb_ScpMergeTarget_get_target,%),\
111 $(call gb_ScpMergeTarget_get_source,%),\
112 $$(SCP_POFILES)))
114 .PHONY : $(call gb_ScpMergeTarget_get_clean_target,%)
115 $(call gb_ScpMergeTarget_get_clean_target,%) :
116 $(call gb_Output_announce,$*,$(false),SUM,1)
117 rm -f $(call gb_ScpMergeTarget_get_target,$*)
119 # gb_ScpMergeTarget_ScpMergeTarget(<target>)
120 define gb_ScpMergeTarget_ScpMergeTarget
121 $(call gb_ScpMergeTarget_get_target,$(1)) :| $(dir $(call gb_ScpMergeTarget_get_target,$(1))).dir
122 $(call gb_ScpMergeTarget_get_target,$(1)) : \
123 SCP_POFILES := $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po)
124 $(call gb_ScpMergeTarget_get_target,$(1)) : \
125 $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po)
126 $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po) :
128 endef
130 # ScpTarget class
132 gb_ScpTarget_TARGET := $(SRCDIR)/solenv/bin/pre2par.pl
133 gb_ScpTarget_COMMAND := $(PERL) $(gb_ScpTarget_TARGET)
135 define gb_ScpTarget__command
136 $(call gb_Output_announce,$(2),$(true),SCP,2)
137 $(call gb_Helper_abbreviate_dirs,\
138 $(gb_ScpTarget_COMMAND) -l $(SCP_ULF) -s $(SCP_SOURCE) -o $(1) \
140 endef
142 $(dir $(call gb_ScpTarget_get_target,%))%/.dir :
143 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
145 $(call gb_ScpTarget_get_target,%) : $(gb_ScpTarget_TARGET)
146 $(call gb_ScpTarget__command,$@,$*)
148 $(call gb_ScpTarget_get_external_target,%) :
149 touch $@
151 .PHONY : $(call gb_ScpTarget_get_clean_target,%)
152 $(call gb_ScpTarget_get_clean_target,%) :
153 $(call gb_Output_announce,$*,$(false),SCP,2)
154 rm -f \
155 $(call gb_ScpTarget_get_target,$*) \
156 $(call gb_ScpTarget_get_external_target,$*)
158 # gb_ScpTarget_ScpTarget(<target>)
159 define gb_ScpTarget_ScpTarget
160 $(call gb_ScpPreprocessTarget_ScpPreprocessTarget,$(1))
162 $(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpPreprocessTarget_get_target,$(1))
163 $(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpTarget_get_external_target,$(1))
164 $(call gb_ScpTarget_get_external_target,$(1)) :| $(dir $(call gb_ScpTarget_get_target,$(1))).dir
165 $(call gb_ScpPreprocessTarget_get_target,$(1)) : $(call gb_ScpTarget_get_external_target,$(1))
166 $(call gb_ScpTarget_get_clean_target,$(1)) : $(call gb_ScpPreprocessTarget_get_clean_target,$(1))
167 $(call gb_ScpTarget_get_target,$(1)) : SCP_SOURCE := $(call gb_ScpPreprocessTarget_get_target,$(1))
168 $(call gb_ScpTarget_get_target,$(1)) : SCP_ULF := $(gb_Helper_PHONY)
170 endef
172 define gb_ScpTarget_set_localized
173 ifneq ($(gb_WITH_LANG),)
174 $(call gb_ScpMergeTarget_ScpMergeTarget,$(1))
175 $(call gb_ScpTarget_get_target,$(1)) : SCP_ULF := $(call gb_ScpMergeTarget_get_target,$(1))
176 $(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpMergeTarget_get_target,$(1))
177 $(call gb_ScpTarget_get_clean_target,$(1)) : $(call gb_ScpMergeTarget_get_clean_target,$(1))
178 else
179 $(call gb_ScpTarget_get_target,$(1)) : SCP_ULF := $(call gb_ScpMergeTarget_get_source,$(1))
180 $(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpMergeTarget_get_source,$(1))
181 endif
183 endef
185 # InstallModuleTarget class
187 # platform:
188 # gb_InstallModuleTarget_InstallModuleTarget_platform
190 define gb_InstallModuleTarget__command
191 $(call gb_Output_announce,$(2),$(true),INM,3)
192 $(call gb_Helper_abbreviate_dirs,\
193 rm -f $(1) \
194 $(foreach scpfile,$(SCP_FILES),&& echo $(scpfile) >> $(1)) \
196 endef
198 $(dir $(call gb_InstallModuleTarget_get_target,%))%/.dir :
199 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
201 $(call gb_InstallModuleTarget_get_target,%) :
202 $(call gb_InstallModuleTarget__command,$@,$*)
204 $(call gb_InstallModuleTarget_get_external_target,%) :
205 touch $@
207 .PHONY : $(call gb_InstallModuleTarget_get_clean_target,%)
208 $(call gb_InstallModuleTarget_get_clean_target,%) :
209 $(call gb_Output_announce,$*,$(false),INM,3)
210 rm -rf \
211 $(call gb_InstallModuleTarget_get_target,$*) \
212 $(call gb_InstallModuleTarget_get_external_target,$*)
214 define gb_InstallModuleTarget_InstallModuleTarget
215 $(call gb_InstallModuleTarget_get_target,$(1)) : \
216 $(call gb_InstallModuleTarget_get_external_target,$(1))
217 $(call gb_InstallModuleTarget_get_external_target,$(1)) :| \
218 $(dir $(call gb_InstallModuleTarget_get_target,$(1))).dir
220 $(call gb_InstallModuleTarget_get_target,$(1)) : SCP_FILES :=
221 $(call gb_InstallModuleTarget_get_target,$(1)) : SCP_DEFS :=
222 $(call gb_InstallModuleTarget_get_target,$(1)) : SCP_INCLUDE := -I$(SRCDIR)/scp2/inc -I$(WORKDIR) -I$(BUILDDIR)/config_$(gb_Side)
223 $(call gb_InstallModuleTarget_get_target,$(1)) : SCP_TEMPLATE_INCLUDE :=
224 $(call gb_InstallModuleTarget_use_custom_headers,$(1),scp2/macros)
226 $(call gb_InstallModuleTarget_InstallModuleTarget_platform,$(1))
228 endef
230 define gb_InstallModuleTarget_add_defs
231 $(call gb_InstallModuleTarget_get_target,$(1)) : SCP_DEFS += $(2)
233 endef
235 define gb_InstallModuleTarget_define_if_set
236 $(call gb_InstallModuleTarget_add_defs,$(1),\
237 $(foreach def,$(2),$(if $(filter TRUE YES,$($(def))),-D$(def))) \
240 endef
242 define gb_InstallModuleTarget_define_value_if_set
243 $(call gb_InstallModuleTarget_add_defs,$(1),\
244 $(foreach def,$(2),$(if $($(def)),-D$(def)=\""$($(def))"\")) \
247 endef
249 define gb_InstallModuleTarget_use_auto_install_libs
250 $(call gb_InstallModuleTarget_get_external_target,$(1)) : $(foreach ai,$(2),$(call gb_AutoInstall_get_target,$(ai)))
252 endef
254 define gb_InstallModuleTarget_use_custom_header
255 $(call gb_InstallModuleTarget_get_external_target,$(1)) : $(call gb_CustomTarget_get_target,$(2))
256 $(call gb_InstallModuleTarget_get_target,$(1)) : SCP_INCLUDE += -I$(call gb_CustomTarget_get_workdir,$(2)) \
258 endef
260 define gb_InstallModuleTarget_use_custom_headers
261 $(foreach customtarget,$(2),$(call gb_InstallModuleTarget_use_custom_header,$(1),$(customtarget)))
263 endef
265 define gb_InstallModuleTarget_add_scpfile
266 $(call gb_ScpTarget_ScpTarget,$(2))
267 $(call gb_InstallModuleTarget_get_target,$(1)) : $(call gb_ScpTarget_get_target,$(2))
268 $(call gb_InstallModuleTarget_get_clean_target,$(1)) : $(call gb_ScpTarget_get_clean_target,$(2))
269 $(call gb_InstallModuleTarget_get_target,$(1)) : SCP_FILES += $(call gb_ScpTarget_get_target,$(2))
270 $(call gb_ScpTarget_get_external_target,$(2)) : $(call gb_InstallModuleTarget_get_external_target,$(1))
272 endef
274 define gb_InstallModuleTarget_add_scpfiles
275 $(foreach scpfile,$(2),$(call gb_InstallModuleTarget_add_scpfile,$(1),$(scpfile)))
277 endef
279 define gb_InstallModuleTarget_add_localized_scpfile
280 $(call gb_InstallModuleTarget_add_scpfile,$(1),$(2))
281 $(call gb_ScpTarget_set_localized,$(2))
283 endef
285 define gb_InstallModuleTarget_add_localized_scpfiles
286 $(foreach scpfile,$(2),$(call gb_InstallModuleTarget_add_localized_scpfile,$(1),$(scpfile)))
288 endef
290 define gb_InstallModuleTarget_add_template
291 $(call gb_ScpTemplateTarget_ScpTemplateTarget,$(2))
292 $(call gb_InstallModuleTarget_get_external_target,$(1)) : $(call gb_ScpTemplateTarget_get_target,$(2))
293 $(call gb_InstallModuleTarget_get_clean_target,$(1)) : $(call gb_ScpTemplateTarget_get_clean_target,$(2))
294 $(call gb_InstallModuleTarget_get_target,$(1)) : \
295 SCP_TEMPLATE_INCLUDE := $$(sort $$(SCP_TEMPLATE_INCLUDE) -I$(call gb_ScpTemplateTarget_get_dir,$(2)))
297 endef
299 define gb_InstallModuleTarget_add_templates
300 $(foreach template,$(2),$(call gb_InstallModuleTarget_add_template,$(1),$(template)))
302 endef
304 # vim: set shiftwidth=4 tabstop=4 noexpandtab: