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:
23 # => XcsTarget: schemas
26 # => XcuDataTarget: data
28 # => XcsTarget (schema)
30 # => XcuModuleTaret: modules
33 # => XcuLangpackTarget: langpack (per lang)
36 # => XcuResTarget: resources (per lang)
38 # => XcuMergeTarget: merge
39 # => buildtools (cfgex)
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
)
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
)
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_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_Helper_abbreviate_dirs
,\
72 mkdir
-p
$(dir $(1)) && \
73 $(gb_Configuration_XSLTCOMMAND
) --nonet \
75 --stringparam componentName
$(subst /,.
,$(basename $(2))) \
76 --stringparam root
$(subst $(2),,$(3)) \
77 $(gb_Configuration__stringparam_schemaRoot
) \
78 $(gb_XcsTarget_XSLT_SchemaVal
) \
80 $(gb_Configuration_XSLTCOMMAND
) --nonet \
82 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
83 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
84 $(gb_XcsTarget_XSLT_SchemaTrim
) \
88 $(call gb_XcsTarget_get_target
,%) : \
89 $(gb_XcsTarget_XSLT_SchemaVal
) \
90 $(gb_XcsTarget_XSLT_SchemaTrim
) $(gb_XcsTarget_DTD_Schema
) \
91 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
92 $(call gb_Output_announce
,$*,$(true
),XCS
,1)
93 $(call gb_Trace_StartRange
,$*,XCS
)
94 $(call gb_XcsTarget__command
,$@
,$*,$(filter %.xcs
,$^
))
95 $(call gb_Trace_EndRange
,$*,XCS
)
97 $(call gb_XcsTarget_get_clean_target
,%) :
98 $(call gb_Output_announce
,$*,$(false
),XCS
,1)
99 rm -f
$(call gb_XcsTarget_get_target
,$*)
102 # XcuDataTarget class
104 gb_XcuTarget_XSLT_AllLang
:= $(SRCDIR
)/officecfg
/util
/alllang.xsl
105 gb_XcuDataTarget_XSLT_DataVal
:= $(SRCDIR
)/officecfg
/util
/data_val.xsl
106 gb_XcuDataTarget_DTD_ComponentUpdate
:= $(SRCDIR
)/officecfg
/registry
/component-update.dtd
108 define gb_XcuDataTarget__command
109 $(call gb_Helper_abbreviate_dirs
,\
110 mkdir
-p
$(dir $(1)) && \
111 $(gb_Configuration_XSLTCOMMAND
) --nonet \
113 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
114 $(gb_Configuration__stringparam_schemaRoot
) \
115 --path
$(SRCDIR
)/officecfg
/registry \
116 $(gb_XcuDataTarget_XSLT_DataVal
) \
118 $(gb_Configuration_XSLTCOMMAND
) --nonet \
120 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
121 $(gb_Configuration__stringparam_schemaRoot
) \
122 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
123 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
124 --path
$(SRCDIR
)/officecfg
/registry \
125 $(gb_XcuTarget_XSLT_AllLang
) \
129 $(call gb_XcuDataTarget_get_target
,%) : $(gb_XcuDataTarget_XSLT_DataVal
) \
130 $(gb_XcuTarget_XSLT_AllLang
) $(gb_XcuDataTarget_DTD_ComponentUpdate
) \
131 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
132 $(call gb_Output_announce
,$*,$(true
),XCU
,2)
133 $(call gb_Trace_StartRange
,$*,XCU
)
134 $(call gb_XcuDataTarget__command
,$@
,$*,$(filter %.xcu
,$^
))
135 $(call gb_Trace_EndRange
,$*,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_Helper_abbreviate_dirs
,\
155 mkdir
-p
$(dir $(1)) && \
156 $(gb_Configuration_XSLTCOMMAND
) --nonet \
158 --stringparam xcs
$(4) \
159 $(gb_Configuration__stringparam_schemaRoot
) \
160 --stringparam module
$(notdir $(subst -,/,$(basename $(notdir $(2))))) \
161 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
162 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
163 $(gb_XcuTarget_XSLT_AllLang
) \
167 $(call gb_XcuModuleTarget_get_target
,%) : $(gb_XcuTarget_XSLT_AllLang
) \
168 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
169 $(if
$(filter %.xcu
,$^
),,$(error There is no target
$(call gb_XcuModuleTarget_get_target
,$*)))
170 $(call gb_Output_announce
,$*,$(true
),XCM
,3)
171 $(call gb_Trace_StartRange
,$*,XCM
)
172 $(call gb_XcuModuleTarget__command
,$@
,$*,$(filter %.xcu
,$^
),$(filter %.xcs
,$^
))
173 $(call gb_Trace_EndRange
,$*,XCM
)
175 $(call gb_XcuModuleTarget_get_clean_target
,%) :
176 $(call gb_Output_announce
,$*,$(false
),XCM
,3)
177 $(call gb_Helper_abbreviate_dirs
,\
178 rm -f
$(call gb_XcuModuleTarget_get_target
,$*))
181 # XcuLangpackTarget class
183 gb_XcuLangpackTarget__get_name_with_lang
= $(basename $(1))-$(2)$(suffix $(1))
185 gb_XcuLangpackTarget__get_target_with_lang
= \
186 $(call gb_XcuLangpackTarget_get_target
,$(call gb_XcuLangpackTarget__get_name_with_lang
,$(1),$(2)))
188 gb_XcuLangpackTarget_SED_delcomment
:= $(SRCDIR
)/officecfg
/util
/delcomment.sed
190 define gb_XcuLangpackTarget__command
191 $(call gb_Helper_abbreviate_dirs
,\
192 mkdir
-p
$(dir $(1)) && \
193 sed
-e
"s/__LANGUAGE__/$(LANGUAGE)/" -f
$(gb_XcuLangpackTarget_SED_delcomment
)\
197 $(call gb_XcuLangpackTarget_get_target
,%) : \
198 $(gb_XcuLangpackTarget_SED_delcomment
)
199 $(call gb_Output_announce
,$*,$(true
),XCL
,1)
200 $(call gb_Trace_StartRange
,$*,XCL
)
201 $(call gb_XcuLangpackTarget__command
,$@
,$*,$(filter %.tmpl
,$^
))
202 $(call gb_Trace_EndRange
,$*,XCL
)
204 $(call gb_XcuLangpackTarget_get_clean_target
,%) :
205 $(call gb_Output_announce
,$*,$(false
),XCL
,1)
206 $(call gb_Helper_abbreviate_dirs
,\
207 rm -f
$(foreach lang
,$(gb_Configuration_LANGS
),\
208 $(call gb_XcuLangpackTarget__get_target_with_lang
,$*,$(lang
))))
211 # XcuMergeTarget class
213 gb_XcuMergeTarget_CFGEXDEPS
:= $(call gb_Executable_get_runtime_dependencies
,cfgex
)
214 gb_XcuMergeTarget_CFGEXCOMMAND
:= $(call gb_Executable_get_command
,cfgex
)
216 define gb_XcuMergeTarget__command
217 MERGEINPUT
=$(call gb_var2file
,$(shell $(gb_MKTEMP
)),$(POFILES
)) && \
218 $(call gb_Helper_abbreviate_dirs
,\
219 mkdir
-p
$(dir $(1)) && \
220 $(gb_XcuMergeTarget_CFGEXCOMMAND
) \
225 rm -rf
$${MERGEINPUT}
229 $(call gb_XcuMergeTarget_get_target
,%) : $(gb_XcuMergeTarget_CFGEXDEPS
)
230 $(call gb_Output_announce
,$*,$(true
),XCX
,1)
231 $(call gb_Trace_StartRange
,$*,XCX
)
232 $(if
$(filter $(words $(POFILES
)),$(words $(wildcard $(POFILES
)))),\
233 $(call gb_XcuMergeTarget__command
,$@
,$*,$(filter %.xcu
,$^
)),\
234 mkdir
-p
$(dir $@
) && cp
$(filter %.xcu
,$^
) $@
)
235 $(call gb_Trace_EndRange
,$*,XCX
)
237 $(call gb_XcuMergeTarget_get_clean_target
,%) :
238 $(call gb_Output_announce
,$*,$(false
),XCX
,1)
239 $(call gb_Helper_abbreviate_dirs
,\
240 rm -f
$(call gb_XcuMergeTarget_get_target
,$*))
242 # $(call gb_XcuMergeTarget_XcuMergeTarget,target,configuration,prefix,xcufile)
243 define gb_XcuMergeTarget_XcuMergeTarget
244 $(call gb_XcuMergeTarget_get_target
,$(1)) : \
245 $(SRCDIR
)/$(3)/$(4) \
246 $(wildcard $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
))
247 $(call gb_XcuMergeTarget_get_target
,$(1)) : \
248 POFILES
:= $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
)
249 $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
) :
255 # locale is extracted from the stem (parameter $(2))
256 define gb_XcuResTarget__command
257 $(call gb_Helper_abbreviate_dirs
,\
258 mkdir
-p
$(dir $(1)) && \
259 $(gb_Configuration_XSLTCOMMAND
) --nonet \
261 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
262 $(gb_Configuration__stringparam_schemaRoot
) \
263 --stringparam locale
$(word 2,$(subst /, ,$(2))) \
264 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
265 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
266 --path
$(SRCDIR
)/officecfg
/registry \
267 $(gb_XcuTarget_XSLT_AllLang
) \
271 $(call gb_XcuResTarget_get_target
,%) : $(gb_XcuTarget_XSLT_AllLang
) \
272 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
273 $(call gb_Output_announce
,$*,$(true
),XCR
,2)
274 $(call gb_Trace_StartRange
,$*,XCR
)
275 $(call gb_XcuResTarget__command
,$@
,$*,$(filter %.xcu
,$^
))
276 $(call gb_Trace_EndRange
,$*,XCR
)
278 $(call gb_XcuResTarget_get_clean_target
,%) :
279 $(call gb_Output_announce
,$*,$(false
),XCR
,2)
280 $(call gb_Helper_abbreviate_dirs
,\
281 rm -f
$(call gb_XcuResTarget_get_target
,$*))
283 # $(call gb_XcuResTarget_XcuResTarget,target,configuration,prefix,xcufile,lang)
284 # this depends either on the source or on the merge target (if WITH_LANG)
285 define gb_XcuResTarget_XcuResTarget
286 ifeq ($(strip $(gb_WITH_LANG
)),)
287 $(call gb_XcuResTarget_get_target
,$(1)) : $(SRCDIR
)/$(3)/$(4)
289 $(call gb_XcuResTarget_get_target
,$(1)) : \
290 $(call gb_XcuMergeTarget_get_target
,$(3)/$(4))
292 $(call gb_XcuResTarget_get_target
,$(1)) : \
293 $(call gb_XcsTarget_for_XcuTarget
,$(4))
294 $(call gb_XcuResTarget_get_target
,$(1)) : PRIMARY_REGISTRY
:= $(filter $(2),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
295 $(call gb_XcuResTarget_get_target
,$(1)) : XCUFILE
:= $(4)
299 # Configuration class
301 $(call gb_Configuration_get_clean_target
,%) :
302 $(call gb_Output_announce
,$*,$(false
),CFG
,4)
303 $(call gb_Helper_abbreviate_dirs
,\
304 rm -f
$(call gb_Configuration_get_target
,$*) $(call gb_Configuration_get_preparation_target
,$*))
306 $(call gb_Configuration_get_target
,%) :
307 $(call gb_Output_announce
,$*,$(true
),CFG
,4)
308 $(call gb_Trace_MakeMark
,$*,CFG
)
309 $(call gb_Helper_abbreviate_dirs
,\
310 mkdir
-p
$(dir $@
) && touch
$@
)
312 $(call gb_Configuration_get_preparation_target
,%) :
313 $(call gb_Helper_abbreviate_dirs
,\
314 mkdir
-p
$(dir $@
) && touch
$@
)
316 # $(call gb_Configuration_Configuration,configuration,nodeliver)
317 # last parameter may be used to turn off delivering of files
318 # FIXME: not anymore, no files are delivered now
319 define gb_Configuration_Configuration
320 $(eval gb_Configuration_NODELIVER_
$(1) := $(2))
322 $$(eval
$$(call gb_Module_register_target
,$(call gb_Configuration_get_target
,$(1)),$(call gb_Configuration_get_clean_target
,$(1))))
323 $(call gb_Helper_make_userfriendly_targets
,$(1),Configuration
)
327 # $(call gb_Configuration_add_schema,configuration,prefix,xcsfile)
328 # hopefully extensions do not need to add schemas with same name as officecfg
329 define gb_Configuration_add_schema
330 $(call gb_Configuration_get_clean_target
,$(1)) : \
331 $(call gb_XcsTarget_get_clean_target
,$(3))
332 $(call gb_XcsTarget_get_target
,$(3)) : \
333 $(SRCDIR
)/$(2)/$(3) \
334 $(call gb_Configuration_get_preparation_target
,$(1))
335 $(call gb_XcsTarget_get_target
,$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
336 $(call gb_Configuration_get_target
,$(1)) : \
337 $(call gb_XcsTarget_get_target
,$(3))
341 #$(call gb_Configuration_add_schemas,configuration,prefix,xcsfiles)
342 define gb_Configuration_add_schemas
343 $(foreach xcs
,$(3),$(call gb_Configuration_add_schema
,$(1),$(2),$(xcs
)))
347 # $(call gb_Configuration_add_data,configuration,prefix,xcufile)
348 define gb_Configuration_add_data
349 $(call gb_Configuration_get_clean_target
,$(1)) : \
350 $(call gb_XcuDataTarget_get_clean_target
,$(2)/$(3))
351 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : \
352 $(SRCDIR
)/$(2)/$(3) \
353 $(call gb_Configuration_get_preparation_target
,$(1)) \
354 $(call gb_XcsTarget_for_XcuTarget
,$(3))
355 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
356 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : XCUFILE
:= $(3)
357 $(call gb_Configuration_get_target
,$(1)) : \
358 $(call gb_XcuDataTarget_get_target
,$(2)/$(3))
362 #$(call gb_Configuration_add_datas,configuration,prefix,xcufiles)
363 define gb_Configuration_add_datas
364 $(foreach xcu
,$(3),$(call gb_Configuration_add_data
,$(1),$(2),$(xcu
)))
368 # $(call gb_Configuration_add_spool_module,configuration,prefix,xcufile)
369 define gb_Configuration_add_spool_module
370 $(call gb_Configuration_get_clean_target
,$(1)) : \
371 $(call gb_XcuModuleTarget_get_clean_target
,$(2)/$(3))
372 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3)) : \
373 $(call gb_XcuDataSource_for_XcuModuleTarget
,$(2)/$(3)) \
374 $(call gb_Configuration_get_preparation_target
,$(1)) \
375 $(call gb_XcsTarget_for_XcuModuleTarget
,$(3))
376 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
377 $(call gb_Configuration_get_target
,$(1)) : \
378 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3))
382 # $(call gb_Configuration_add_spool_modules,configuration,prefix,xcufiles)
383 define gb_Configuration_add_spool_modules
384 $(foreach xcu
,$(3),$(call gb_Configuration_add_spool_module
,$(1),$(2),$(xcu
)))
388 define gb_Configuration__add_langpack
389 $(if
$(gb_Configuration_NODELIVER_
$(1)),\
390 $(error TODO not needed yet
: cannot add langpack if nodeliver
))
391 $(call gb_Configuration_get_target
,$(1)) : \
392 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4))
393 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4)) : \
394 $(SRCDIR
)/$(2)/$(3).tmpl
395 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4)) : LANGUAGE
:= $(4)
399 # $(call gb_Configuration_add_spool_langpack,configuration,prefix,xcufile)
400 define gb_Configuration_add_spool_langpack
401 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
402 $(call gb_Configuration__add_langpack
,$(1),$(2),$(strip $(3)),$(lang
))))
403 $(call gb_Configuration_get_clean_target
,$(1)) : \
404 $(call gb_XcuLangpackTarget_get_clean_target
,$(strip $(3)))
408 # $(call gb_Configuration_add_localized_data,configuration,prefix,xcufile)
409 define gb_Configuration_add_localized_data
410 $(eval
$(call gb_Configuration_add_data
,$(1),$(2),$(3)))
411 ifneq ($(strip $(gb_WITH_LANG
)),)
412 $(eval
$(call gb_XcuMergeTarget_XcuMergeTarget
,$(2)/$(3),$(1),$(2),$(3)))
413 $(eval
$(call gb_Configuration_get_clean_target
,$(1)) : \
414 $(call gb_XcuMergeTarget_get_clean_target
,$(2)/$(3)))
416 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
417 $(call gb_XcuResTarget_XcuResTarget
,$(1)/$(lang
)/$(3),$(1),$(2),$(3),$(lang
))))
418 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
419 $(call gb_Configuration_get_target
,$(1)) : \
420 $(call gb_XcuResTarget_get_target
,$(1)/$(lang
)/$(3))))
421 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
422 $(call gb_Configuration_get_clean_target
,$(1)) : \
423 $(call gb_XcuResTarget_get_clean_target
,$(1)/$(lang
)/$(3))))
427 # $(call gb_Configuration_add_localized_datas,configuration,prefix,xcufile)
428 define gb_Configuration_add_localized_datas
429 $(foreach xcu
,$(3),$(call gb_Configuration_add_localized_data
,$(1),$(2),$(xcu
)))
433 # Set extra registry this configuration can use schemas from.
436 # # foo needs schemas from the main configuration
437 # $(eval $(call gb_Configuration_use_configuration,foo,registry))
438 define gb_Configuration_use_configuration
439 $(call gb_Configuration_get_preparation_target
,$(1)) : $(call gb_Configuration_get_target
,$(2))
443 # apparently extensions package the XcuMergeTarget directly...
444 # trivial convenience function to get the right file:
445 ifeq ($(gb_WITH_LANG
),)
446 gb_XcuFile_for_extension
= $(SRCDIR
)/$(1)
448 gb_XcuFile_for_extension
= $(call gb_XcuMergeTarget_get_target
,$(1))
451 # vim: set noet sw=4 ts=4: