Bump version to 6.4.7.2.M8
[LibreOffice.git] / solenv / gbuild / Configuration.mk
blob72fda5e1f675808475245d4e1c0947768acc43cc
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/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # Configuration files: a bit of an overview of the targets:
22 # Configuration
23 # => XcsTarget: schemas
24 # => buildtools
25 # => Xcs source
26 # => XcuDataTarget: data
27 # => buildtools
28 # => XcsTarget (schema)
29 # => Xcu data source
30 # => XcuModuleTaret: modules
31 # => buildtools
32 # => Xcu data source
33 # => XcuLangpackTarget: langpack (per lang)
34 # => buildtools
35 # => Xcu data source
36 # => XcuResTarget: resources (per lang)
37 # => buildtools
38 # => XcuMergeTarget: merge
39 # => buildtools (cfgex)
40 # => Xcu data source
41 # => *.po
42 # => XcsTarget (schema)
44 # The main LibreOffice registry (cf. officecfg/Configuration_officecfg.mk):
45 gb_Configuration_PRIMARY_REGISTRY_NAME := registry
46 gb_Configuration_PRIMARY_REGISTRY_SCHEMA_ROOT = \
47 $(SRCDIR)/officecfg/registry/schema
49 gb_Configuration__stringparam_schemaRoot = --stringparam schemaRoot \
50 $(if $(PRIMARY_REGISTRY), \
51 $(gb_Configuration_PRIMARY_REGISTRY_SCHEMA_ROOT), \
52 $(call gb_XcsTarget_get_target,))
54 gb_Configuration_XSLTCOMMAND = $(call gb_ExternalExecutable_get_command,xsltproc)
55 gb_Configuration_XSLTCOMMAND_DEPS = $(call gb_ExternalExecutable_get_dependencies,xsltproc)
57 # XcsTarget class
59 # need to locate a schema file corresponding to some XCU file in the outdir
60 define gb_XcsTarget_for_XcuTarget
61 $(call gb_XcsTarget_get_target,$(basename $(1)).xcs)
62 endef
64 gb_Configuration_LANGS := en-US $(filter-out en-US,$(gb_WITH_LANG))
66 gb_XcsTarget_XSLT_SchemaVal := $(SRCDIR)/officecfg/util/schema_val.xsl
67 gb_XcsTarget_XSLT_Sanity := $(SRCDIR)/officecfg/util/sanity.xsl
68 gb_XcsTarget_XSLT_SchemaTrim := $(SRCDIR)/officecfg/util/schema_trim.xsl
69 gb_XcsTarget_DTD_Schema := $(SRCDIR)/officecfg/registry/component-schema.dtd
71 define gb_XcsTarget__command
72 $(call gb_Output_announce,$(2),$(true),XCS,1)
73 $(call gb_Helper_abbreviate_dirs,\
74 mkdir -p $(dir $(1)) && \
75 $(gb_Configuration_XSLTCOMMAND) --nonet \
76 --noout \
77 --stringparam componentName $(subst /,.,$(basename $(2))) \
78 --stringparam root $(subst $(2),,$(3)) \
79 $(gb_Configuration__stringparam_schemaRoot) \
80 $(gb_XcsTarget_XSLT_SchemaVal) \
81 $(3) && \
82 $(gb_Configuration_XSLTCOMMAND) --nonet \
83 --noout \
84 $(gb_XcsTarget_XSLT_Sanity) \
85 $(3) && \
86 $(gb_Configuration_XSLTCOMMAND) --nonet \
87 -o $(1) \
88 --stringparam LIBO_SHARE_FOLDER $(LIBO_SHARE_FOLDER) \
89 --stringparam LIBO_SHARE_HELP_FOLDER $(LIBO_SHARE_HELP_FOLDER) \
90 $(gb_XcsTarget_XSLT_SchemaTrim) \
91 $(3))
92 endef
94 $(call gb_XcsTarget_get_target,%) : \
95 $(gb_XcsTarget_XSLT_SchemaVal) $(gb_XcsTarget_XSLT_Sanity) \
96 $(gb_XcsTarget_XSLT_SchemaTrim) $(gb_XcsTarget_DTD_Schema) \
97 | $(gb_Configuration_XSLTCOMMAND_DEPS)
98 $(call gb_XcsTarget__command,$@,$*,$(filter %.xcs,$^))
100 $(call gb_XcsTarget_get_clean_target,%) :
101 $(call gb_Output_announce,$*,$(false),XCS,1)
102 rm -f $(call gb_XcsTarget_get_target,$*)
105 # XcuDataTarget class
107 gb_XcuTarget_XSLT_AllLang := $(SRCDIR)/officecfg/util/alllang.xsl
108 gb_XcuDataTarget_XSLT_DataVal := $(SRCDIR)/officecfg/util/data_val.xsl
109 gb_XcuDataTarget_DTD_ComponentUpdate := $(SRCDIR)/officecfg/registry/component-update.dtd
111 define gb_XcuDataTarget__command
112 $(call gb_Output_announce,$(2),$(true),XCU,2)
113 $(call gb_Helper_abbreviate_dirs,\
114 mkdir -p $(dir $(1)) && \
115 $(gb_Configuration_XSLTCOMMAND) --nonet \
116 --noout \
117 --stringparam xcs $(call gb_XcsTarget_for_XcuTarget,$(XCUFILE)) \
118 $(gb_Configuration__stringparam_schemaRoot) \
119 --path $(SRCDIR)/officecfg/registry \
120 $(gb_XcuDataTarget_XSLT_DataVal) \
121 $(3) && \
122 $(gb_Configuration_XSLTCOMMAND) --nonet \
123 -o $(1) \
124 --stringparam xcs $(call gb_XcsTarget_for_XcuTarget,$(XCUFILE)) \
125 $(gb_Configuration__stringparam_schemaRoot) \
126 --stringparam LIBO_SHARE_FOLDER $(LIBO_SHARE_FOLDER) \
127 --stringparam LIBO_SHARE_HELP_FOLDER $(LIBO_SHARE_HELP_FOLDER) \
128 --path $(SRCDIR)/officecfg/registry \
129 $(gb_XcuTarget_XSLT_AllLang) \
130 $(3))
131 endef
133 $(call gb_XcuDataTarget_get_target,%) : $(gb_XcuDataTarget_XSLT_DataVal) \
134 $(gb_XcuTarget_XSLT_AllLang) $(gb_XcuDataTarget_DTD_ComponentUpdate) \
135 | $(gb_Configuration_XSLTCOMMAND_DEPS)
136 $(call gb_XcuDataTarget__command,$@,$*,$(filter %.xcu,$^))
138 $(call gb_XcuDataTarget_get_clean_target,%) :
139 $(call gb_Output_announce,$*,$(false),XCU,2)
140 $(call gb_Helper_abbreviate_dirs,\
141 rm -f $(call gb_XcuDataTarget_get_target,$*))
144 # XcuModuleTarget class
146 define gb_XcuDataSource_for_XcuModuleTarget
147 $(SRCDIR)/$(basename $(subst -,.,$(basename $(1)))).xcu
148 endef
150 define gb_XcsTarget_for_XcuModuleTarget
151 $(call gb_XcsTarget_get_target,$(basename $(subst -,.,$(basename $(1)))).xcs)
152 endef
154 define gb_XcuModuleTarget__command
155 $(call gb_Output_announce,$(2),$(true),XCM,3)
156 $(call gb_Helper_abbreviate_dirs,\
157 mkdir -p $(dir $(1)) && \
158 $(gb_Configuration_XSLTCOMMAND) --nonet \
159 -o $(1) \
160 --stringparam xcs $(4) \
161 $(gb_Configuration__stringparam_schemaRoot) \
162 --stringparam module $(notdir $(subst -,/,$(basename $(notdir $(2))))) \
163 --stringparam LIBO_SHARE_FOLDER $(LIBO_SHARE_FOLDER) \
164 --stringparam LIBO_SHARE_HELP_FOLDER $(LIBO_SHARE_HELP_FOLDER) \
165 $(gb_XcuTarget_XSLT_AllLang) \
166 $(3))
167 endef
169 $(call gb_XcuModuleTarget_get_target,%) : $(gb_XcuTarget_XSLT_AllLang) \
170 | $(gb_Configuration_XSLTCOMMAND_DEPS)
171 $(if $(filter %.xcu,$^),,$(error There is no target $(call gb_XcuModuleTarget_get_target,$*)))
172 $(call gb_XcuModuleTarget__command,$@,$*,$(filter %.xcu,$^),$(filter %.xcs,$^))
174 $(call gb_XcuModuleTarget_get_clean_target,%) :
175 $(call gb_Output_announce,$*,$(false),XCM,3)
176 $(call gb_Helper_abbreviate_dirs,\
177 rm -f $(call gb_XcuModuleTarget_get_target,$*))
180 # XcuLangpackTarget class
182 gb_XcuLangpackTarget__get_name_with_lang = $(basename $(1))-$(2)$(suffix $(1))
184 gb_XcuLangpackTarget__get_target_with_lang = \
185 $(call gb_XcuLangpackTarget_get_target,$(call gb_XcuLangpackTarget__get_name_with_lang,$(1),$(2)))
187 gb_XcuLangpackTarget_SED_delcomment := $(SRCDIR)/officecfg/util/delcomment.sed
189 define gb_XcuLangpackTarget__command
190 $(call gb_Output_announce,$(2),$(true),XCL,1)
191 $(call gb_Helper_abbreviate_dirs,\
192 mkdir -p $(dir $(1)) && \
193 sed -e "s/__LANGUAGE__/$(LANGUAGE)/" -f $(gb_XcuLangpackTarget_SED_delcomment)\
194 $(3) > $(1))
195 endef
197 $(call gb_XcuLangpackTarget_get_target,%) : \
198 $(gb_XcuLangpackTarget_SED_delcomment)
199 $(call gb_XcuLangpackTarget__command,$@,$*,$(filter %.tmpl,$^))
201 $(call gb_XcuLangpackTarget_get_clean_target,%) :
202 $(call gb_Output_announce,$*,$(false),XCL,1)
203 $(call gb_Helper_abbreviate_dirs,\
204 rm -f $(foreach lang,$(gb_Configuration_LANGS),\
205 $(call gb_XcuLangpackTarget__get_target_with_lang,$*,$(lang))))
208 # XcuMergeTarget class
210 gb_XcuMergeTarget_CFGEXDEPS := $(call gb_Executable_get_runtime_dependencies,cfgex)
211 gb_XcuMergeTarget_CFGEXCOMMAND := $(call gb_Executable_get_command,cfgex)
213 define gb_XcuMergeTarget__command
214 $(call gb_Output_announce,$(2),$(true),XCX,1)
215 MERGEINPUT=$(call var2file,$(shell $(gb_MKTEMP)),100,$(POFILES)) && \
216 $(call gb_Helper_abbreviate_dirs,\
217 mkdir -p $(dir $(1)) && \
218 $(gb_XcuMergeTarget_CFGEXCOMMAND) \
219 -i $(3) \
220 -o $(1) \
221 -m $${MERGEINPUT} \
222 -l all) && \
223 rm -rf $${MERGEINPUT}
225 endef
227 $(call gb_XcuMergeTarget_get_target,%) : $(gb_XcuMergeTarget_CFGEXDEPS)
228 $(if $(filter $(words $(POFILES)),$(words $(wildcard $(POFILES)))),\
229 $(call gb_XcuMergeTarget__command,$@,$*,$(filter %.xcu,$^)),\
230 mkdir -p $(dir $@) && cp $(filter %.xcu,$^) $@)
232 $(call gb_XcuMergeTarget_get_clean_target,%) :
233 $(call gb_Output_announce,$*,$(false),XCX,1)
234 $(call gb_Helper_abbreviate_dirs,\
235 rm -f $(call gb_XcuMergeTarget_get_target,$*))
237 # $(call gb_XcuMergeTarget_XcuMergeTarget,target,configuration,prefix,xcufile)
238 define gb_XcuMergeTarget_XcuMergeTarget
239 $(call gb_XcuMergeTarget_get_target,$(1)) : \
240 $(SRCDIR)/$(3)/$(4) \
241 $(wildcard $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po))
242 $(call gb_XcuMergeTarget_get_target,$(1)) : \
243 POFILES := $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po)
244 $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po) :
245 endef
248 # XcuResTarget class
250 # locale is extracted from the stem (parameter $(2))
251 define gb_XcuResTarget__command
252 $(call gb_Output_announce,$(2),$(true),XCR,2)
253 $(call gb_Helper_abbreviate_dirs,\
254 mkdir -p $(dir $(1)) && \
255 $(gb_Configuration_XSLTCOMMAND) --nonet \
256 -o $(1) \
257 --stringparam xcs $(call gb_XcsTarget_for_XcuTarget,$(XCUFILE)) \
258 $(gb_Configuration__stringparam_schemaRoot) \
259 --stringparam locale $(word 2,$(subst /, ,$(2))) \
260 --stringparam LIBO_SHARE_FOLDER $(LIBO_SHARE_FOLDER) \
261 --stringparam LIBO_SHARE_HELP_FOLDER $(LIBO_SHARE_HELP_FOLDER) \
262 --path $(SRCDIR)/officecfg/registry \
263 $(gb_XcuTarget_XSLT_AllLang) \
264 $(3))
265 endef
267 $(call gb_XcuResTarget_get_target,%) : $(gb_XcuTarget_XSLT_AllLang) \
268 | $(gb_Configuration_XSLTCOMMAND_DEPS)
269 $(call gb_XcuResTarget__command,$@,$*,$(filter %.xcu,$^))
271 $(call gb_XcuResTarget_get_clean_target,%) :
272 $(call gb_Output_announce,$*,$(false),XCR,2)
273 $(call gb_Helper_abbreviate_dirs,\
274 rm -f $(call gb_XcuResTarget_get_target,$*))
276 # $(call gb_XcuResTarget_XcuResTarget,target,configuration,prefix,xcufile,lang)
277 # this depends either on the source or on the merge target (if WITH_LANG)
278 define gb_XcuResTarget_XcuResTarget
279 ifeq ($(strip $(gb_WITH_LANG)),)
280 $(call gb_XcuResTarget_get_target,$(1)) : $(SRCDIR)/$(3)/$(4)
281 else
282 $(call gb_XcuResTarget_get_target,$(1)) : \
283 $(call gb_XcuMergeTarget_get_target,$(3)/$(4))
284 endif
285 $(call gb_XcuResTarget_get_target,$(1)) : \
286 $(call gb_XcsTarget_for_XcuTarget,$(4))
287 $(call gb_XcuResTarget_get_target,$(1)) : PRIMARY_REGISTRY := $(filter $(2),$(gb_Configuration_PRIMARY_REGISTRY_NAME))
288 $(call gb_XcuResTarget_get_target,$(1)) : XCUFILE := $(4)
289 endef
292 # Configuration class
294 $(call gb_Configuration_get_clean_target,%) :
295 $(call gb_Output_announce,$*,$(false),CFG,4)
296 $(call gb_Helper_abbreviate_dirs,\
297 rm -f $(call gb_Configuration_get_target,$*) $(call gb_Configuration_get_preparation_target,$*))
299 $(call gb_Configuration_get_target,%) :
300 $(call gb_Output_announce,$*,$(true),CFG,4)
301 $(call gb_Helper_abbreviate_dirs,\
302 mkdir -p $(dir $@) && touch $@)
304 $(call gb_Configuration_get_preparation_target,%) :
305 $(call gb_Helper_abbreviate_dirs,\
306 mkdir -p $(dir $@) && touch $@)
308 # $(call gb_Configuration_Configuration,configuration,nodeliver)
309 # last parameter may be used to turn off delivering of files
310 # FIXME: not anymore, no files are delivered now
311 define gb_Configuration_Configuration
312 $(eval gb_Configuration_NODELIVER_$(1) := $(2))
314 $$(eval $$(call gb_Module_register_target,Configuration_$(1),$(call gb_Configuration_get_target,$(1)),$(call gb_Configuration_get_clean_target,$(1))))
315 $(call gb_Helper_make_userfriendly_targets,$(1),Configuration)
317 endef
319 # $(call gb_Configuration_add_schema,configuration,prefix,xcsfile)
320 # hopefully extensions do not need to add schemas with same name as officecfg
321 define gb_Configuration_add_schema
322 $(call gb_Configuration_get_clean_target,$(1)) : \
323 $(call gb_XcsTarget_get_clean_target,$(3))
324 $(call gb_XcsTarget_get_target,$(3)) : \
325 $(SRCDIR)/$(2)/$(3) \
326 $(call gb_Configuration_get_preparation_target,$(1))
327 $(call gb_XcsTarget_get_target,$(3)) : PRIMARY_REGISTRY := $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME))
328 $(call gb_Configuration_get_target,$(1)) : \
329 $(call gb_XcsTarget_get_target,$(3))
331 endef
333 #$(call gb_Configuration_add_schemas,configuration,prefix,xcsfiles)
334 define gb_Configuration_add_schemas
335 $(foreach xcs,$(3),$(call gb_Configuration_add_schema,$(1),$(2),$(xcs)))
337 endef
339 # $(call gb_Configuration_add_data,configuration,prefix,xcufile)
340 define gb_Configuration_add_data
341 $(call gb_Configuration_get_clean_target,$(1)) : \
342 $(call gb_XcuDataTarget_get_clean_target,$(2)/$(3))
343 $(call gb_XcuDataTarget_get_target,$(2)/$(3)) : \
344 $(SRCDIR)/$(2)/$(3) \
345 $(call gb_Configuration_get_preparation_target,$(1)) \
346 $(call gb_XcsTarget_for_XcuTarget,$(3))
347 $(call gb_XcuDataTarget_get_target,$(2)/$(3)) : PRIMARY_REGISTRY := $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME))
348 $(call gb_XcuDataTarget_get_target,$(2)/$(3)) : XCUFILE := $(3)
349 $(call gb_Configuration_get_target,$(1)) : \
350 $(call gb_XcuDataTarget_get_target,$(2)/$(3))
352 endef
354 #$(call gb_Configuration_add_datas,configuration,prefix,xcufiles)
355 define gb_Configuration_add_datas
356 $(foreach xcu,$(3),$(call gb_Configuration_add_data,$(1),$(2),$(xcu)))
358 endef
360 # $(call gb_Configuration_add_spool_module,configuration,prefix,xcufile)
361 define gb_Configuration_add_spool_module
362 $(call gb_Configuration_get_clean_target,$(1)) : \
363 $(call gb_XcuModuleTarget_get_clean_target,$(2)/$(3))
364 $(call gb_XcuModuleTarget_get_target,$(2)/$(3)) : \
365 $(call gb_XcuDataSource_for_XcuModuleTarget,$(2)/$(3)) \
366 $(call gb_Configuration_get_preparation_target,$(1)) \
367 $(call gb_XcsTarget_for_XcuModuleTarget,$(3))
368 $(call gb_XcuModuleTarget_get_target,$(2)/$(3)) : PRIMARY_REGISTRY := $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME))
369 $(call gb_Configuration_get_target,$(1)) : \
370 $(call gb_XcuModuleTarget_get_target,$(2)/$(3))
372 endef
374 # $(call gb_Configuration_add_spool_modules,configuration,prefix,xcufiles)
375 define gb_Configuration_add_spool_modules
376 $(foreach xcu,$(3),$(call gb_Configuration_add_spool_module,$(1),$(2),$(xcu)))
378 endef
380 define gb_Configuration__add_langpack
381 $(if $(gb_Configuration_NODELIVER_$(1)),\
382 $(error TODO not needed yet: cannot add langpack if nodeliver))
383 $(call gb_Configuration_get_target,$(1)) : \
384 $(call gb_XcuLangpackTarget__get_target_with_lang,$(3),$(4))
385 $(call gb_XcuLangpackTarget__get_target_with_lang,$(3),$(4)) : \
386 $(SRCDIR)/$(2)/$(3).tmpl
387 $(call gb_XcuLangpackTarget__get_target_with_lang,$(3),$(4)) : LANGUAGE := $(4)
389 endef
391 # $(call gb_Configuration_add_spool_langpack,configuration,prefix,xcufile)
392 define gb_Configuration_add_spool_langpack
393 $(foreach lang,$(gb_Configuration_LANGS),$(eval \
394 $(call gb_Configuration__add_langpack,$(1),$(2),$(strip $(3)),$(lang))))
395 $(call gb_Configuration_get_clean_target,$(1)) : \
396 $(call gb_XcuLangpackTarget_get_clean_target,$(strip $(3)))
398 endef
400 # $(call gb_Configuration_add_localized_data,configuration,prefix,xcufile)
401 define gb_Configuration_add_localized_data
402 $(eval $(call gb_Configuration_add_data,$(1),$(2),$(3)))
403 ifneq ($(strip $(gb_WITH_LANG)),)
404 $(eval $(call gb_XcuMergeTarget_XcuMergeTarget,$(2)/$(3),$(1),$(2),$(3)))
405 $(eval $(call gb_Configuration_get_clean_target,$(1)) : \
406 $(call gb_XcuMergeTarget_get_clean_target,$(2)/$(3)))
407 endif
408 $(foreach lang,$(gb_Configuration_LANGS),$(eval \
409 $(call gb_XcuResTarget_XcuResTarget,$(1)/$(lang)/$(3),$(1),$(2),$(3),$(lang))))
410 $(foreach lang,$(gb_Configuration_LANGS),$(eval \
411 $(call gb_Configuration_get_target,$(1)) : \
412 $(call gb_XcuResTarget_get_target,$(1)/$(lang)/$(3))))
413 $(foreach lang,$(gb_Configuration_LANGS),$(eval \
414 $(call gb_Configuration_get_clean_target,$(1)) : \
415 $(call gb_XcuResTarget_get_clean_target,$(1)/$(lang)/$(3))))
417 endef
419 # $(call gb_Configuration_add_localized_datas,configuration,prefix,xcufile)
420 define gb_Configuration_add_localized_datas
421 $(foreach xcu,$(3),$(call gb_Configuration_add_localized_data,$(1),$(2),$(xcu)))
423 endef
425 # Set extra registry this configuration can use schemas from.
427 # Example:
428 # # foo needs schemas from the main configuration
429 # $(eval $(call gb_Configuration_use_configuration,foo,registry))
430 define gb_Configuration_use_configuration
431 $(call gb_Configuration_get_preparation_target,$(1)) : $(call gb_Configuration_get_target,$(2))
433 endef
435 # apparently extensions package the XcuMergeTarget directly...
436 # trivial convenience function to get the right file:
437 ifeq ($(gb_WITH_LANG),)
438 gb_XcuFile_for_extension = $(SRCDIR)/$(1)
439 else
440 gb_XcuFile_for_extension = $(call gb_XcuMergeTarget_get_target,$(1))
441 endif
443 # vim: set noet sw=4 ts=4: