2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 # Configuration files: a bit of an overview of the targets:
22 # => XcsTarget: schemas
25 # => XcuDataTarget: data
27 # => XcsTarget (schema)
29 # => XcuModuleTaret: modules
32 # => XcuLangpackTarget: langpack (per lang)
35 # => XcuResTarget: resources (per lang)
37 # => XcuMergeTarget: merge
38 # => buildtools (cfgex)
41 # => XcsTarget (schema)
43 # The main LibreOffice registry (cf. officecfg/Configuration_officecfg.mk):
44 gb_Configuration_PRIMARY_REGISTRY_NAME
:= registry
45 gb_Configuration_PRIMARY_REGISTRY_SCHEMA_ROOT
= \
46 $(SRCDIR
)/officecfg
/registry
/schema
48 gb_Configuration__stringparam_schemaRoot
= --stringparam schemaRoot \
49 $(if
$(PRIMARY_REGISTRY
), \
50 $(gb_Configuration_PRIMARY_REGISTRY_SCHEMA_ROOT
), \
51 $(call gb_XcsTarget_get_target
,))
53 gb_Configuration_XSLTCOMMAND
= $(call gb_ExternalExecutable_get_command
,xsltproc
)
54 gb_Configuration_XSLTCOMMAND_DEPS
= $(call gb_ExternalExecutable_get_dependencies
,xsltproc
)
58 # need to locate a schema file corresponding to some XCU file in the outdir
59 define gb_XcsTarget_for_XcuTarget
60 $(call gb_XcsTarget_get_target
,$(basename $(1)).xcs
)
63 gb_Configuration_LANGS
:= en-US
$(filter-out en-US
,$(gb_WITH_LANG
))
65 gb_XcsTarget_XSLT_SchemaVal
:= $(SRCDIR
)/officecfg
/util
/schema_val.xsl
66 gb_XcsTarget_XSLT_Sanity
:= $(SRCDIR
)/officecfg
/util
/sanity.xsl
67 gb_XcsTarget_XSLT_SchemaTrim
:= $(SRCDIR
)/officecfg
/util
/schema_trim.xsl
68 gb_XcsTarget_DTD_Schema
:= $(SRCDIR
)/officecfg
/registry
/component-schema.dtd
70 define gb_XcsTarget__command
71 $(call gb_Output_announce
,$(2),$(true
),XCS
,1)
72 $(call gb_Helper_abbreviate_dirs
,\
73 mkdir
-p
$(dir $(1)) && \
74 $(gb_Configuration_XSLTCOMMAND
) --nonet \
76 --stringparam componentName
$(subst /,.
,$(basename $(2))) \
77 --stringparam root
$(subst $(2),,$(3)) \
78 $(gb_Configuration__stringparam_schemaRoot
) \
79 $(gb_XcsTarget_XSLT_SchemaVal
) \
81 $(gb_Configuration_XSLTCOMMAND
) --nonet \
83 $(gb_XcsTarget_XSLT_Sanity
) \
85 $(gb_Configuration_XSLTCOMMAND
) --nonet \
87 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
88 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
89 $(gb_XcsTarget_XSLT_SchemaTrim
) \
93 $(call gb_XcsTarget_get_target
,%) : \
94 $(gb_XcsTarget_XSLT_SchemaVal
) $(gb_XcsTarget_XSLT_Sanity
) \
95 $(gb_XcsTarget_XSLT_SchemaTrim
) $(gb_XcsTarget_DTD_Schema
) \
96 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
97 $(call gb_XcsTarget__command
,$@
,$*,$(filter %.xcs
,$^
))
99 $(call gb_XcsTarget_get_clean_target
,%) :
100 $(call gb_Output_announce
,$*,$(false
),XCS
,1)
101 rm -f
$(call gb_XcsTarget_get_target
,$*)
104 # XcuDataTarget class
106 gb_XcuTarget_XSLT_AllLang
:= $(SRCDIR
)/officecfg
/util
/alllang.xsl
107 gb_XcuDataTarget_XSLT_DataVal
:= $(SRCDIR
)/officecfg
/util
/data_val.xsl
108 gb_XcuDataTarget_DTD_ComponentUpdate
:= $(SRCDIR
)/officecfg
/registry
/component-update.dtd
110 define gb_XcuDataTarget__command
111 $(call gb_Output_announce
,$(2),$(true
),XCU
,2)
112 $(call gb_Helper_abbreviate_dirs
,\
113 mkdir
-p
$(dir $(1)) && \
114 $(gb_Configuration_XSLTCOMMAND
) --nonet \
116 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
117 $(gb_Configuration__stringparam_schemaRoot
) \
118 --path
$(SRCDIR
)/officecfg
/registry \
119 $(gb_XcuDataTarget_XSLT_DataVal
) \
121 $(gb_Configuration_XSLTCOMMAND
) --nonet \
123 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
124 $(gb_Configuration__stringparam_schemaRoot
) \
125 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
126 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
127 --path
$(SRCDIR
)/officecfg
/registry \
128 $(gb_XcuTarget_XSLT_AllLang
) \
132 $(call gb_XcuDataTarget_get_target
,%) : $(gb_XcuDataTarget_XSLT_DataVal
) \
133 $(gb_XcuTarget_XSLT_AllLang
) $(gb_XcuDataTarget_DTD_ComponentUpdate
) \
134 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
135 $(call gb_XcuDataTarget__command
,$@
,$*,$(filter %.xcu
,$^
))
137 $(call gb_XcuDataTarget_get_clean_target
,%) :
138 $(call gb_Output_announce
,$*,$(false
),XCU
,2)
139 $(call gb_Helper_abbreviate_dirs
,\
140 rm -f
$(call gb_XcuDataTarget_get_target
,$*))
143 # XcuModuleTarget class
145 define gb_XcuDataSource_for_XcuModuleTarget
146 $(SRCDIR
)/$(basename $(subst -,.
,$(basename $(1)))).xcu
149 define gb_XcsTarget_for_XcuModuleTarget
150 $(call gb_XcsTarget_get_target
,$(basename $(subst -,.
,$(basename $(1)))).xcs
)
153 define gb_XcuModuleTarget__command
154 $(call gb_Output_announce
,$(2),$(true
),XCM
,3)
155 $(call gb_Helper_abbreviate_dirs
,\
156 mkdir
-p
$(dir $(1)) && \
157 $(gb_Configuration_XSLTCOMMAND
) --nonet \
159 --stringparam xcs
$(4) \
160 $(gb_Configuration__stringparam_schemaRoot
) \
161 --stringparam module
$(notdir $(subst -,/,$(basename $(notdir $(2))))) \
162 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
163 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
164 $(gb_XcuTarget_XSLT_AllLang
) \
168 $(call gb_XcuModuleTarget_get_target
,%) : $(gb_XcuTarget_XSLT_AllLang
) \
169 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
170 $(if
$(filter %.xcu
,$^
),,$(error There is no target
$(call gb_XcuModuleTarget_get_target
,$*)))
171 $(call gb_XcuModuleTarget__command
,$@
,$*,$(filter %.xcu
,$^
),$(filter %.xcs
,$^
))
173 $(call gb_XcuModuleTarget_get_clean_target
,%) :
174 $(call gb_Output_announce
,$*,$(false
),XCM
,3)
175 $(call gb_Helper_abbreviate_dirs
,\
176 rm -f
$(call gb_XcuModuleTarget_get_target
,$*))
179 # XcuLangpackTarget class
181 gb_XcuLangpackTarget__get_name_with_lang
= $(basename $(1))-$(2)$(suffix $(1))
183 gb_XcuLangpackTarget__get_target_with_lang
= \
184 $(call gb_XcuLangpackTarget_get_target
,$(call gb_XcuLangpackTarget__get_name_with_lang
,$(1),$(2)))
186 gb_XcuLangpackTarget_SED_delcomment
:= $(SRCDIR
)/officecfg
/util
/delcomment.sed
188 define gb_XcuLangpackTarget__command
189 $(call gb_Output_announce
,$(2),$(true
),XCL
,1)
190 $(call gb_Helper_abbreviate_dirs
,\
191 mkdir
-p
$(dir $(1)) && \
192 sed
-e
"s/__LANGUAGE__/$(LANG)/" -f
$(gb_XcuLangpackTarget_SED_delcomment
)\
196 $(call gb_XcuLangpackTarget_get_target
,%) : \
197 $(gb_XcuLangpackTarget_SED_delcomment
)
198 $(call gb_XcuLangpackTarget__command
,$@
,$*,$(filter %.tmpl
,$^
))
200 $(call gb_XcuLangpackTarget_get_clean_target
,%) :
201 $(call gb_Output_announce
,$*,$(false
),XCL
,1)
202 $(call gb_Helper_abbreviate_dirs
,\
203 rm -f
$(foreach lang
,$(gb_Configuration_LANGS
),\
204 $(call gb_XcuLangpackTarget__get_target_with_lang
,$*,$(lang
))))
207 # XcuMergeTarget class
209 gb_XcuMergeTarget_CFGEXDEPS
:= $(call gb_Executable_get_runtime_dependencies
,cfgex
)
210 gb_XcuMergeTarget_CFGEXCOMMAND
:= $(call gb_Executable_get_command
,cfgex
)
212 define gb_XcuMergeTarget__command
213 $(call gb_Output_announce
,$(2),$(true
),XCX
,1)
214 MERGEINPUT
=$(call var2file
,$(shell $(gb_MKTEMP
)),100,$(POFILES
)) && \
215 $(call gb_Helper_abbreviate_dirs
,\
216 mkdir
-p
$(dir $(1)) && \
217 $(gb_XcuMergeTarget_CFGEXCOMMAND
) \
222 rm -rf
$${MERGEINPUT}
226 $(call gb_XcuMergeTarget_get_target
,%) : $(gb_XcuMergeTarget_CFGEXDEPS
)
227 $(if
$(filter $(words $(POFILES
)),$(words $(wildcard $(POFILES
)))),\
228 $(call gb_XcuMergeTarget__command
,$@
,$*,$(filter %.xcu
,$^
)),\
229 mkdir
-p
$(dir $@
) && cp
$(filter %.xcu
,$^
) $@
)
231 $(call gb_XcuMergeTarget_get_clean_target
,%) :
232 $(call gb_Output_announce
,$*,$(false
),XCX
,1)
233 $(call gb_Helper_abbreviate_dirs
,\
234 rm -f
$(call gb_XcuMergeTarget_get_target
,$*))
236 # $(call gb_XcuMergeTarget_XcuMergeTarget,target,configuration,prefix,xcufile)
237 define gb_XcuMergeTarget_XcuMergeTarget
238 $(call gb_XcuMergeTarget_get_target
,$(1)) : \
239 $(SRCDIR
)/$(3)/$(4) \
240 $(wildcard $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
))
241 $(call gb_XcuMergeTarget_get_target
,$(1)) : \
242 POFILES
:= $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
)
243 $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
) :
249 # locale is extracted from the stem (parameter $(2))
250 define gb_XcuResTarget__command
251 $(call gb_Output_announce
,$(2),$(true
),XCR
,2)
252 $(call gb_Helper_abbreviate_dirs
,\
253 mkdir
-p
$(dir $(1)) && \
254 $(gb_Configuration_XSLTCOMMAND
) --nonet \
256 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
257 $(gb_Configuration__stringparam_schemaRoot
) \
258 --stringparam locale
$(word 2,$(subst /, ,$(2))) \
259 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
260 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
261 --path
$(SRCDIR
)/officecfg
/registry \
262 $(gb_XcuTarget_XSLT_AllLang
) \
266 $(call gb_XcuResTarget_get_target
,%) : $(gb_XcuTarget_XSLT_AllLang
) \
267 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
268 $(call gb_XcuResTarget__command
,$@
,$*,$(filter %.xcu
,$^
))
270 $(call gb_XcuResTarget_get_clean_target
,%) :
271 $(call gb_Output_announce
,$*,$(false
),XCR
,2)
272 $(call gb_Helper_abbreviate_dirs
,\
273 rm -f
$(call gb_XcuResTarget_get_target
,$*))
275 # $(call gb_XcuResTarget_XcuResTarget,target,configuration,prefix,xcufile,lang)
276 # this depends either on the source or on the merge target (if WITH_LANG)
277 define gb_XcuResTarget_XcuResTarget
278 ifeq ($(strip $(gb_WITH_LANG
)),)
279 $(call gb_XcuResTarget_get_target
,$(1)) : $(SRCDIR
)/$(3)/$(4)
281 $(call gb_XcuResTarget_get_target
,$(1)) : \
282 $(call gb_XcuMergeTarget_get_target
,$(3)/$(4))
284 $(call gb_XcuResTarget_get_target
,$(1)) : \
285 $(call gb_XcsTarget_for_XcuTarget
,$(4))
286 $(call gb_XcuResTarget_get_target
,$(1)) : PRIMARY_REGISTRY
:= $(filter $(2),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
287 $(call gb_XcuResTarget_get_target
,$(1)) : XCUFILE
:= $(4)
291 # Configuration class
293 $(call gb_Configuration_get_clean_target
,%) :
294 $(call gb_Output_announce
,$*,$(false
),CFG
,4)
295 $(call gb_Helper_abbreviate_dirs
,\
296 rm -f
$(call gb_Configuration_get_target
,$*) $(call gb_Configuration_get_preparation_target
,$*))
298 $(call gb_Configuration_get_target
,%) :
299 $(call gb_Output_announce
,$*,$(true
),CFG
,4)
300 $(call gb_Helper_abbreviate_dirs
,\
301 mkdir
-p
$(dir $@
) && touch
$@
)
303 $(call gb_Configuration_get_preparation_target
,%) :
304 $(call gb_Helper_abbreviate_dirs
,\
305 mkdir
-p
$(dir $@
) && touch
$@
)
307 # $(call gb_Configuration_Configuration,configuration,nodeliver)
308 # last parameter may be used to turn off delivering of files
309 # FIXME: not anymore, no files are delivered now
310 define gb_Configuration_Configuration
311 $(eval gb_Configuration_NODELIVER_
$(1) := $(2))
313 $$(eval
$$(call gb_Module_register_target
,$(call gb_Configuration_get_target
,$(1)),$(call gb_Configuration_get_clean_target
,$(1))))
314 $(call gb_Helper_make_userfriendly_targets
,$(1),Configuration
)
318 # $(call gb_Configuration_add_schema,configuration,prefix,xcsfile)
319 # hopefully extensions do not need to add schemas with same name as officecfg
320 define gb_Configuration_add_schema
321 $(call gb_Configuration_get_clean_target
,$(1)) : \
322 $(call gb_XcsTarget_get_clean_target
,$(3))
323 $(call gb_XcsTarget_get_target
,$(3)) : \
324 $(SRCDIR
)/$(2)/$(3) \
325 $(call gb_Configuration_get_preparation_target
,$(1))
326 $(call gb_XcsTarget_get_target
,$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
327 $(call gb_Configuration_get_target
,$(1)) : \
328 $(call gb_XcsTarget_get_target
,$(3))
332 #$(call gb_Configuration_add_schemas,configuration,prefix,xcsfiles)
333 define gb_Configuration_add_schemas
334 $(foreach xcs
,$(3),$(call gb_Configuration_add_schema
,$(1),$(2),$(xcs
)))
338 # $(call gb_Configuration_add_data,configuration,prefix,xcufile)
339 define gb_Configuration_add_data
340 $(call gb_Configuration_get_clean_target
,$(1)) : \
341 $(call gb_XcuDataTarget_get_clean_target
,$(2)/$(3))
342 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : \
343 $(SRCDIR
)/$(2)/$(3) \
344 $(call gb_Configuration_get_preparation_target
,$(1)) \
345 $(call gb_XcsTarget_for_XcuTarget
,$(3))
346 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
347 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : XCUFILE
:= $(3)
348 $(call gb_Configuration_get_target
,$(1)) : \
349 $(call gb_XcuDataTarget_get_target
,$(2)/$(3))
353 #$(call gb_Configuration_add_datas,configuration,prefix,xcufiles)
354 define gb_Configuration_add_datas
355 $(foreach xcu
,$(3),$(call gb_Configuration_add_data
,$(1),$(2),$(xcu
)))
359 # $(call gb_Configuration_add_spool_module,configuration,prefix,xcufile)
360 define gb_Configuration_add_spool_module
361 $(call gb_Configuration_get_clean_target
,$(1)) : \
362 $(call gb_XcuModuleTarget_get_clean_target
,$(2)/$(3))
363 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3)) : \
364 $(call gb_XcuDataSource_for_XcuModuleTarget
,$(2)/$(3)) \
365 $(call gb_Configuration_get_preparation_target
,$(1)) \
366 $(call gb_XcsTarget_for_XcuModuleTarget
,$(3))
367 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
368 $(call gb_Configuration_get_target
,$(1)) : \
369 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3))
373 # $(call gb_Configuration_add_spool_modules,configuration,prefix,xcufiles)
374 define gb_Configuration_add_spool_modules
375 $(foreach xcu
,$(3),$(call gb_Configuration_add_spool_module
,$(1),$(2),$(xcu
)))
379 define gb_Configuration__add_langpack
380 $(if
$(gb_Configuration_NODELIVER_
$(1)),\
381 $(error TODO not needed yet
: cannot add langpack if nodeliver
))
382 $(call gb_Configuration_get_target
,$(1)) : \
383 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4))
384 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4)) : \
385 $(SRCDIR
)/$(2)/$(3).tmpl
386 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4)) : LANG
:= $(4)
390 # $(call gb_Configuration_add_spool_langpack,configuration,prefix,xcufile)
391 define gb_Configuration_add_spool_langpack
392 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
393 $(call gb_Configuration__add_langpack
,$(1),$(2),$(strip $(3)),$(lang
))))
394 $(call gb_Configuration_get_clean_target
,$(1)) : \
395 $(call gb_XcuLangpackTarget_get_clean_target
,$(strip $(3)))
399 # $(call gb_Configuration_add_localized_data,configuration,prefix,xcufile)
400 define gb_Configuration_add_localized_data
401 $(eval
$(call gb_Configuration_add_data
,$(1),$(2),$(3)))
402 ifneq ($(strip $(gb_WITH_LANG
)),)
403 $(eval
$(call gb_XcuMergeTarget_XcuMergeTarget
,$(2)/$(3),$(1),$(2),$(3)))
404 $(eval
$(call gb_Configuration_get_clean_target
,$(1)) : \
405 $(call gb_XcuMergeTarget_get_clean_target
,$(2)/$(3)))
407 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
408 $(call gb_XcuResTarget_XcuResTarget
,$(1)/$(lang
)/$(3),$(1),$(2),$(3),$(lang
))))
409 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
410 $(call gb_Configuration_get_target
,$(1)) : \
411 $(call gb_XcuResTarget_get_target
,$(1)/$(lang
)/$(3))))
412 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
413 $(call gb_Configuration_get_clean_target
,$(1)) : \
414 $(call gb_XcuResTarget_get_clean_target
,$(1)/$(lang
)/$(3))))
418 # $(call gb_Configuration_add_localized_datas,configuration,prefix,xcufile)
419 define gb_Configuration_add_localized_datas
420 $(foreach xcu
,$(3),$(call gb_Configuration_add_localized_data
,$(1),$(2),$(xcu
)))
424 # Set extra registry this configuration can use schemas from.
427 # # foo needs schemas from the main configuration
428 # $(eval $(call gb_Configuration_use_configuration,foo,registry))
429 define gb_Configuration_use_configuration
430 $(call gb_Configuration_get_preparation_target
,$(1)) : $(call gb_Configuration_get_target
,$(2))
434 # apparently extensions package the XcuMergeTarget directly...
435 # trivial convenience function to get the right file:
436 ifeq ($(gb_WITH_LANG
),)
437 gb_XcuFile_for_extension
= $(SRCDIR
)/$(1)
439 gb_XcuFile_for_extension
= $(call gb_XcuMergeTarget_get_target
,$(1))
442 # vim: set noet sw=4 ts=4: