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_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_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_Output_announce
,$*,$(true
),XCS
,1)
98 $(call gb_Trace_StartRange
,$*,XCS
)
99 $(call gb_XcsTarget__command
,$@
,$*,$(filter %.xcs
,$^
))
100 $(call gb_Trace_EndRange
,$*,XCS
)
102 $(call gb_XcsTarget_get_clean_target
,%) :
103 $(call gb_Output_announce
,$*,$(false
),XCS
,1)
104 rm -f
$(call gb_XcsTarget_get_target
,$*)
107 # XcuDataTarget class
109 gb_XcuTarget_XSLT_AllLang
:= $(SRCDIR
)/officecfg
/util
/alllang.xsl
110 gb_XcuDataTarget_XSLT_DataVal
:= $(SRCDIR
)/officecfg
/util
/data_val.xsl
111 gb_XcuDataTarget_DTD_ComponentUpdate
:= $(SRCDIR
)/officecfg
/registry
/component-update.dtd
113 define gb_XcuDataTarget__command
114 $(call gb_Helper_abbreviate_dirs
,\
115 mkdir
-p
$(dir $(1)) && \
116 $(gb_Configuration_XSLTCOMMAND
) --nonet \
118 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
119 $(gb_Configuration__stringparam_schemaRoot
) \
120 --path
$(SRCDIR
)/officecfg
/registry \
121 $(gb_XcuDataTarget_XSLT_DataVal
) \
123 $(gb_Configuration_XSLTCOMMAND
) --nonet \
125 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
126 $(gb_Configuration__stringparam_schemaRoot
) \
127 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
128 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
129 --path
$(SRCDIR
)/officecfg
/registry \
130 $(gb_XcuTarget_XSLT_AllLang
) \
134 $(call gb_XcuDataTarget_get_target
,%) : $(gb_XcuDataTarget_XSLT_DataVal
) \
135 $(gb_XcuTarget_XSLT_AllLang
) $(gb_XcuDataTarget_DTD_ComponentUpdate
) \
136 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
137 $(call gb_Output_announce
,$*,$(true
),XCU
,2)
138 $(call gb_Trace_StartRange
,$*,XCU
)
139 $(call gb_XcuDataTarget__command
,$@
,$*,$(filter %.xcu
,$^
))
140 $(call gb_Trace_EndRange
,$*,XCU
)
142 $(call gb_XcuDataTarget_get_clean_target
,%) :
143 $(call gb_Output_announce
,$*,$(false
),XCU
,2)
144 $(call gb_Helper_abbreviate_dirs
,\
145 rm -f
$(call gb_XcuDataTarget_get_target
,$*))
148 # XcuModuleTarget class
150 define gb_XcuDataSource_for_XcuModuleTarget
151 $(SRCDIR
)/$(basename $(subst -,.
,$(basename $(1)))).xcu
154 define gb_XcsTarget_for_XcuModuleTarget
155 $(call gb_XcsTarget_get_target
,$(basename $(subst -,.
,$(basename $(1)))).xcs
)
158 define gb_XcuModuleTarget__command
159 $(call gb_Helper_abbreviate_dirs
,\
160 mkdir
-p
$(dir $(1)) && \
161 $(gb_Configuration_XSLTCOMMAND
) --nonet \
163 --stringparam xcs
$(4) \
164 $(gb_Configuration__stringparam_schemaRoot
) \
165 --stringparam module
$(notdir $(subst -,/,$(basename $(notdir $(2))))) \
166 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
167 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
168 $(gb_XcuTarget_XSLT_AllLang
) \
172 $(call gb_XcuModuleTarget_get_target
,%) : $(gb_XcuTarget_XSLT_AllLang
) \
173 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
174 $(if
$(filter %.xcu
,$^
),,$(error There is no target
$(call gb_XcuModuleTarget_get_target
,$*)))
175 $(call gb_Output_announce
,$*,$(true
),XCM
,3)
176 $(call gb_Trace_StartRange
,$*,XCM
)
177 $(call gb_XcuModuleTarget__command
,$@
,$*,$(filter %.xcu
,$^
),$(filter %.xcs
,$^
))
178 $(call gb_Trace_EndRange
,$*,XCM
)
180 $(call gb_XcuModuleTarget_get_clean_target
,%) :
181 $(call gb_Output_announce
,$*,$(false
),XCM
,3)
182 $(call gb_Helper_abbreviate_dirs
,\
183 rm -f
$(call gb_XcuModuleTarget_get_target
,$*))
186 # XcuLangpackTarget class
188 gb_XcuLangpackTarget__get_name_with_lang
= $(basename $(1))-$(2)$(suffix $(1))
190 gb_XcuLangpackTarget__get_target_with_lang
= \
191 $(call gb_XcuLangpackTarget_get_target
,$(call gb_XcuLangpackTarget__get_name_with_lang
,$(1),$(2)))
193 gb_XcuLangpackTarget_SED_delcomment
:= $(SRCDIR
)/officecfg
/util
/delcomment.sed
195 define gb_XcuLangpackTarget__command
196 $(call gb_Helper_abbreviate_dirs
,\
197 mkdir
-p
$(dir $(1)) && \
198 sed
-e
"s/__LANGUAGE__/$(LANGUAGE)/" -f
$(gb_XcuLangpackTarget_SED_delcomment
)\
202 $(call gb_XcuLangpackTarget_get_target
,%) : \
203 $(gb_XcuLangpackTarget_SED_delcomment
)
204 $(call gb_Output_announce
,$*,$(true
),XCL
,1)
205 $(call gb_Trace_StartRange
,$*,XCL
)
206 $(call gb_XcuLangpackTarget__command
,$@
,$*,$(filter %.tmpl
,$^
))
207 $(call gb_Trace_EndRange
,$*,XCL
)
209 $(call gb_XcuLangpackTarget_get_clean_target
,%) :
210 $(call gb_Output_announce
,$*,$(false
),XCL
,1)
211 $(call gb_Helper_abbreviate_dirs
,\
212 rm -f
$(foreach lang
,$(gb_Configuration_LANGS
),\
213 $(call gb_XcuLangpackTarget__get_target_with_lang
,$*,$(lang
))))
216 # XcuMergeTarget class
218 gb_XcuMergeTarget_CFGEXDEPS
:= $(call gb_Executable_get_runtime_dependencies
,cfgex
)
219 gb_XcuMergeTarget_CFGEXCOMMAND
:= $(call gb_Executable_get_command
,cfgex
)
221 define gb_XcuMergeTarget__command
222 MERGEINPUT
=$(call gb_var2file
,$(shell $(gb_MKTEMP
)),$(POFILES
)) && \
223 $(call gb_Helper_abbreviate_dirs
,\
224 mkdir
-p
$(dir $(1)) && \
225 $(gb_XcuMergeTarget_CFGEXCOMMAND
) \
230 rm -rf
$${MERGEINPUT}
234 $(call gb_XcuMergeTarget_get_target
,%) : $(gb_XcuMergeTarget_CFGEXDEPS
)
235 $(call gb_Output_announce
,$*,$(true
),XCX
,1)
236 $(call gb_Trace_StartRange
,$*,XCX
)
237 $(if
$(filter $(words $(POFILES
)),$(words $(wildcard $(POFILES
)))),\
238 $(call gb_XcuMergeTarget__command
,$@
,$*,$(filter %.xcu
,$^
)),\
239 mkdir
-p
$(dir $@
) && cp
$(filter %.xcu
,$^
) $@
)
240 $(call gb_Trace_EndRange
,$*,XCX
)
242 $(call gb_XcuMergeTarget_get_clean_target
,%) :
243 $(call gb_Output_announce
,$*,$(false
),XCX
,1)
244 $(call gb_Helper_abbreviate_dirs
,\
245 rm -f
$(call gb_XcuMergeTarget_get_target
,$*))
247 # $(call gb_XcuMergeTarget_XcuMergeTarget,target,configuration,prefix,xcufile)
248 define gb_XcuMergeTarget_XcuMergeTarget
249 $(call gb_XcuMergeTarget_get_target
,$(1)) : \
250 $(SRCDIR
)/$(3)/$(4) \
251 $(wildcard $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
))
252 $(call gb_XcuMergeTarget_get_target
,$(1)) : \
253 POFILES
:= $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
)
254 $(foreach lang
,$(gb_TRANS_LANGS
),$(gb_POLOCATION
)/$(lang
)/$(patsubst %/,%,$(dir $(1))).po
) :
260 # locale is extracted from the stem (parameter $(2))
261 define gb_XcuResTarget__command
262 $(call gb_Helper_abbreviate_dirs
,\
263 mkdir
-p
$(dir $(1)) && \
264 $(gb_Configuration_XSLTCOMMAND
) --nonet \
266 --stringparam xcs
$(call gb_XcsTarget_for_XcuTarget
,$(XCUFILE
)) \
267 $(gb_Configuration__stringparam_schemaRoot
) \
268 --stringparam locale
$(word 2,$(subst /, ,$(2))) \
269 --stringparam LIBO_SHARE_FOLDER
$(LIBO_SHARE_FOLDER
) \
270 --stringparam LIBO_SHARE_HELP_FOLDER
$(LIBO_SHARE_HELP_FOLDER
) \
271 --path
$(SRCDIR
)/officecfg
/registry \
272 $(gb_XcuTarget_XSLT_AllLang
) \
276 $(call gb_XcuResTarget_get_target
,%) : $(gb_XcuTarget_XSLT_AllLang
) \
277 |
$(gb_Configuration_XSLTCOMMAND_DEPS
)
278 $(call gb_Output_announce
,$*,$(true
),XCR
,2)
279 $(call gb_Trace_StartRange
,$*,XCR
)
280 $(call gb_XcuResTarget__command
,$@
,$*,$(filter %.xcu
,$^
))
281 $(call gb_Trace_EndRange
,$*,XCR
)
283 $(call gb_XcuResTarget_get_clean_target
,%) :
284 $(call gb_Output_announce
,$*,$(false
),XCR
,2)
285 $(call gb_Helper_abbreviate_dirs
,\
286 rm -f
$(call gb_XcuResTarget_get_target
,$*))
288 # $(call gb_XcuResTarget_XcuResTarget,target,configuration,prefix,xcufile,lang)
289 # this depends either on the source or on the merge target (if WITH_LANG)
290 define gb_XcuResTarget_XcuResTarget
291 ifeq ($(strip $(gb_WITH_LANG
)),)
292 $(call gb_XcuResTarget_get_target
,$(1)) : $(SRCDIR
)/$(3)/$(4)
294 $(call gb_XcuResTarget_get_target
,$(1)) : \
295 $(call gb_XcuMergeTarget_get_target
,$(3)/$(4))
297 $(call gb_XcuResTarget_get_target
,$(1)) : \
298 $(call gb_XcsTarget_for_XcuTarget
,$(4))
299 $(call gb_XcuResTarget_get_target
,$(1)) : PRIMARY_REGISTRY
:= $(filter $(2),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
300 $(call gb_XcuResTarget_get_target
,$(1)) : XCUFILE
:= $(4)
304 # Configuration class
306 $(call gb_Configuration_get_clean_target
,%) :
307 $(call gb_Output_announce
,$*,$(false
),CFG
,4)
308 $(call gb_Helper_abbreviate_dirs
,\
309 rm -f
$(call gb_Configuration_get_target
,$*) $(call gb_Configuration_get_preparation_target
,$*))
311 $(call gb_Configuration_get_target
,%) :
312 $(call gb_Output_announce
,$*,$(true
),CFG
,4)
313 $(call gb_Trace_MakeMark
,$*,CFG
)
314 $(call gb_Helper_abbreviate_dirs
,\
315 mkdir
-p
$(dir $@
) && touch
$@
)
317 $(call gb_Configuration_get_preparation_target
,%) :
318 $(call gb_Helper_abbreviate_dirs
,\
319 mkdir
-p
$(dir $@
) && touch
$@
)
321 # $(call gb_Configuration_Configuration,configuration,nodeliver)
322 # last parameter may be used to turn off delivering of files
323 # FIXME: not anymore, no files are delivered now
324 define gb_Configuration_Configuration
325 $(eval gb_Configuration_NODELIVER_
$(1) := $(2))
327 $$(eval
$$(call gb_Module_register_target
,$(call gb_Configuration_get_target
,$(1)),$(call gb_Configuration_get_clean_target
,$(1))))
328 $(call gb_Helper_make_userfriendly_targets
,$(1),Configuration
)
332 # $(call gb_Configuration_add_schema,configuration,prefix,xcsfile)
333 # hopefully extensions do not need to add schemas with same name as officecfg
334 define gb_Configuration_add_schema
335 $(call gb_Configuration_get_clean_target
,$(1)) : \
336 $(call gb_XcsTarget_get_clean_target
,$(3))
337 $(call gb_XcsTarget_get_target
,$(3)) : \
338 $(SRCDIR
)/$(2)/$(3) \
339 $(call gb_Configuration_get_preparation_target
,$(1))
340 $(call gb_XcsTarget_get_target
,$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
341 $(call gb_Configuration_get_target
,$(1)) : \
342 $(call gb_XcsTarget_get_target
,$(3))
346 #$(call gb_Configuration_add_schemas,configuration,prefix,xcsfiles)
347 define gb_Configuration_add_schemas
348 $(foreach xcs
,$(3),$(call gb_Configuration_add_schema
,$(1),$(2),$(xcs
)))
352 # $(call gb_Configuration_add_data,configuration,prefix,xcufile)
353 define gb_Configuration_add_data
354 $(call gb_Configuration_get_clean_target
,$(1)) : \
355 $(call gb_XcuDataTarget_get_clean_target
,$(2)/$(3))
356 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : \
357 $(SRCDIR
)/$(2)/$(3) \
358 $(call gb_Configuration_get_preparation_target
,$(1)) \
359 $(call gb_XcsTarget_for_XcuTarget
,$(3))
360 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
361 $(call gb_XcuDataTarget_get_target
,$(2)/$(3)) : XCUFILE
:= $(3)
362 $(call gb_Configuration_get_target
,$(1)) : \
363 $(call gb_XcuDataTarget_get_target
,$(2)/$(3))
367 #$(call gb_Configuration_add_datas,configuration,prefix,xcufiles)
368 define gb_Configuration_add_datas
369 $(foreach xcu
,$(3),$(call gb_Configuration_add_data
,$(1),$(2),$(xcu
)))
373 # $(call gb_Configuration_add_spool_module,configuration,prefix,xcufile)
374 define gb_Configuration_add_spool_module
375 $(call gb_Configuration_get_clean_target
,$(1)) : \
376 $(call gb_XcuModuleTarget_get_clean_target
,$(2)/$(3))
377 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3)) : \
378 $(call gb_XcuDataSource_for_XcuModuleTarget
,$(2)/$(3)) \
379 $(call gb_Configuration_get_preparation_target
,$(1)) \
380 $(call gb_XcsTarget_for_XcuModuleTarget
,$(3))
381 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3)) : PRIMARY_REGISTRY
:= $(filter $(1),$(gb_Configuration_PRIMARY_REGISTRY_NAME
))
382 $(call gb_Configuration_get_target
,$(1)) : \
383 $(call gb_XcuModuleTarget_get_target
,$(2)/$(3))
387 # $(call gb_Configuration_add_spool_modules,configuration,prefix,xcufiles)
388 define gb_Configuration_add_spool_modules
389 $(foreach xcu
,$(3),$(call gb_Configuration_add_spool_module
,$(1),$(2),$(xcu
)))
393 define gb_Configuration__add_langpack
394 $(if
$(gb_Configuration_NODELIVER_
$(1)),\
395 $(error TODO not needed yet
: cannot add langpack if nodeliver
))
396 $(call gb_Configuration_get_target
,$(1)) : \
397 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4))
398 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4)) : \
399 $(SRCDIR
)/$(2)/$(3).tmpl
400 $(call gb_XcuLangpackTarget__get_target_with_lang
,$(3),$(4)) : LANGUAGE
:= $(4)
404 # $(call gb_Configuration_add_spool_langpack,configuration,prefix,xcufile)
405 define gb_Configuration_add_spool_langpack
406 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
407 $(call gb_Configuration__add_langpack
,$(1),$(2),$(strip $(3)),$(lang
))))
408 $(call gb_Configuration_get_clean_target
,$(1)) : \
409 $(call gb_XcuLangpackTarget_get_clean_target
,$(strip $(3)))
413 # $(call gb_Configuration_add_localized_data,configuration,prefix,xcufile)
414 define gb_Configuration_add_localized_data
415 $(eval
$(call gb_Configuration_add_data
,$(1),$(2),$(3)))
416 ifneq ($(strip $(gb_WITH_LANG
)),)
417 $(eval
$(call gb_XcuMergeTarget_XcuMergeTarget
,$(2)/$(3),$(1),$(2),$(3)))
418 $(eval
$(call gb_Configuration_get_clean_target
,$(1)) : \
419 $(call gb_XcuMergeTarget_get_clean_target
,$(2)/$(3)))
421 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
422 $(call gb_XcuResTarget_XcuResTarget
,$(1)/$(lang
)/$(3),$(1),$(2),$(3),$(lang
))))
423 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
424 $(call gb_Configuration_get_target
,$(1)) : \
425 $(call gb_XcuResTarget_get_target
,$(1)/$(lang
)/$(3))))
426 $(foreach lang
,$(gb_Configuration_LANGS
),$(eval \
427 $(call gb_Configuration_get_clean_target
,$(1)) : \
428 $(call gb_XcuResTarget_get_clean_target
,$(1)/$(lang
)/$(3))))
432 # $(call gb_Configuration_add_localized_datas,configuration,prefix,xcufile)
433 define gb_Configuration_add_localized_datas
434 $(foreach xcu
,$(3),$(call gb_Configuration_add_localized_data
,$(1),$(2),$(xcu
)))
438 # Set extra registry this configuration can use schemas from.
441 # # foo needs schemas from the main configuration
442 # $(eval $(call gb_Configuration_use_configuration,foo,registry))
443 define gb_Configuration_use_configuration
444 $(call gb_Configuration_get_preparation_target
,$(1)) : $(call gb_Configuration_get_target
,$(2))
448 # apparently extensions package the XcuMergeTarget directly...
449 # trivial convenience function to get the right file:
450 ifeq ($(gb_WITH_LANG
),)
451 gb_XcuFile_for_extension
= $(SRCDIR
)/$(1)
453 gb_XcuFile_for_extension
= $(call gb_XcuMergeTarget_get_target
,$(1))
456 # vim: set noet sw=4 ts=4: