Bump for 3.6-28
[LibreOffice.git] / solenv / gbuild / UnoApiTarget.mk
blob87fd57bb99d88c68ed2e8bbd12222c3a685cc354
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 #
6 # Copyright 2000, 2010 Oracle and/or its affiliates.
8 # OpenOffice.org - a multi-platform office productivity suite
10 # This file is part of OpenOffice.org.
12 # OpenOffice.org is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License version 3
14 # only, as published by the Free Software Foundation.
16 # OpenOffice.org is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU Lesser General Public License version 3 for more details
20 # (a copy is included in the LICENSE file that accompanied this code).
22 # You should have received a copy of the GNU Lesser General Public License
23 # version 3 along with OpenOffice.org. If not, see
24 # <http://www.openoffice.org/license.html>
25 # for a copy of the LGPLv3 License.
27 #*************************************************************************
29 # UnoApiPartTarget
31 gb_UnoApiPartTarget_IDLCTARGET := $(call gb_Executable_get_target_for_build,idlc)
32 gb_UnoApiPartTarget_IDLCCOMMAND := $(gb_Helper_set_ld_path) SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(gb_UnoApiPartTarget_IDLCTARGET)
34 # The .urd files are actually created by the gb_UnoApiPartTarget__command,
35 # invoked for the per-directory .done files.
36 # The reason why .urd files are tracked is so new files that are added are
37 # picked up and cause a rebuild, even if older than the .done file (also, as a
38 # convenience for users who delete them from the workdir by hand; this dummy
39 # rule plus the dependency from the .done target to the .urd file plus the
40 # sort/patsubst call in gb_UnoApiPartTarget__command cause command to be
41 # invoked with the .idl file corresponding to the .urd in that case.
42 # Touch the .urd file, so it is newer than the .done file, causing that to
43 # be rebuilt and overwriting the .urd file again.
44 # the .dir is for make 3.81, which ignores trailing /
45 $(dir $(call gb_UnoApiPartTarget_get_target,))%/.dir :
46 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
48 $(call gb_UnoApiPartTarget_get_target,%.urd) :
49 touch $@
51 # TODO:
52 # - get idlc switch "-P" (generate .urd into package dir)
53 # - empty $? in headertarget?
55 define gb_UnoApiPartTarget__command
56 $(call gb_Output_announce,$(2),$(true),IDL,2)
57 mkdir -p $(call gb_UnoApiPartTarget_get_target,$(dir $(2))) && \
58 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,\
59 $(INCLUDE) \
60 -M $(basename $(call gb_UnoApiPartTarget_get_dep_target,$(dir $(2)))) \
61 -O $(call gb_UnoApiPartTarget_get_target,$(dir $(2))) -verbose \
62 $(sort $(patsubst $(call gb_UnoApiPartTarget_get_target,%.urd),$(SRCDIR)/%.idl,$(3)))) && \
63 $(gb_UnoApiPartTarget_IDLCCOMMAND) @$${RESPONSEFILE} > /dev/null && \
64 rm -f $${RESPONSEFILE} && \
65 touch $(1)
67 endef
69 $(call gb_UnoApiPartTarget_get_target,%.done) : \
70 $(gb_UnoApiPartTarget_IDLCTARGET)
71 $(call gb_UnoApiPartTarget__command,$@,$*,$(filter-out $(gb_UnoApiPartTarget_IDLCTARGET),$?))
73 ifeq ($(gb_FULLDEPS),$(true))
75 $(call gb_UnoApiPartTarget_get_dep_target,%) :
76 $(if $(wildcard $@),touch $@,\
77 $(call gb_Object__command_dep,$@,$(call gb_UnoApiPartTarget_get_target,$*.urd)))
79 endif
81 # UnoApiTarget
83 gb_UnoApiTarget_RDBMAKERTARGET := $(call gb_Executable_get_target_for_build,rdbmaker)
84 gb_UnoApiTarget_RDBMAKERCOMMAND := $(gb_Helper_set_ld_path) SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(gb_UnoApiTarget_RDBMAKERTARGET)
85 gb_UnoApiTarget_REGCOMPARETARGET := $(call gb_Executable_get_target_for_build,regcompare)
86 gb_UnoApiTarget_REGCOMPARECOMMAND := $(gb_Helper_set_ld_path) SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(gb_UnoApiTarget_REGCOMPARETARGET)
87 gb_UnoApiTarget_REGMERGETARGET := $(call gb_Executable_get_target_for_build,regmerge)
88 gb_UnoApiTarget_REGMERGECOMMAND := $(gb_Helper_set_ld_path) SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(gb_UnoApiTarget_REGMERGETARGET)
89 gb_UnoApiTarget_XML2CMPTARGET := $(call gb_Executable_get_target_for_build,xml2cmp)
90 gb_UnoApiTarget_XML2CMPCOMMAND := $(gb_Helper_set_ld_path) $(gb_UnoApiTarget_XML2CMPTARGET)
92 gb_UnoApiTarget_XMLRDB := $(call gb_UnoApiTarget_get_target,types)
94 define gb_UnoApiTarget__get_types
95 $(if $(1),$(foreach type,$(shell $(gb_UnoApiTarget_XML2CMPCOMMAND) -types stdout $(1)),$(addprefix -T,$(type))))
96 endef
98 define gb_UnoApiTarget__command_impl
99 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,$(2)) && \
100 $(1) @$${RESPONSEFILE} && \
101 rm -f $${RESPONSEFILE}
102 endef
104 define gb_UnoApiTarget__regmerge_command_impl
105 $(call gb_UnoApiTarget__command_impl,$(gb_UnoApiTarget_REGMERGECOMMAND),$(1) $(2) $(3))
106 endef
108 define gb_UnoApiTarget__rdbmaker_command_impl
109 $(call gb_UnoApiTarget__command_impl,$(gb_UnoApiTarget_RDBMAKERCOMMAND),-O$(1) -B$(2) -b$(3) $(4) $(5))
110 endef
112 define gb_UnoApiTarget__command
113 $(call gb_Output_announce,$*,$(true),UNO,4)
114 mkdir -p $(dir $(1)) && \
115 $(if $(UNOAPI_FILES),\
116 $(call gb_UnoApiTarget__regmerge_command_impl,$(1),$(UNOAPI_ROOT),$(UNOAPI_FILES)),\
117 $(if $(UNOAPI_MERGE),\
118 $(call gb_UnoApiTarget__regmerge_command_impl,$(1),$(UNOAPI_ROOT),$(UNOAPI_MERGE)),\
119 $(call gb_UnoApiTarget__rdbmaker_command_impl,$(1),UCR,$(UNOAPI_ROOT),\
120 $(call gb_UnoApiTarget__get_types,$(UNOAPI_XML)),$(gb_UnoApiTarget_XMLRDB)))) \
121 $(if $(UNOAPI_REFERENCE), \
122 $(call gb_Output_announce,$*,$(true),DBc,3) \
123 && $(gb_UnoApiTarget_REGCOMPARECOMMAND) \
124 -f -t \
125 -r1 $(UNOAPI_REFERENCE) \
126 -r2 $(1))
127 endef
129 define gb_UnoApiTarget__check_mode
130 $(if $(or $(and $(1),$(2),$(3)),$(and $(1),$(2)),$(and $(2),$(3)),$(and $(1),$(3))),\
131 $(error More than one mode of function of UnoApiTarget used: this is not supported),\
132 $(if $(or $(1),$(2),$(3)),,\
133 $(error Neither IDL files nor merged RDBs nor XML desc. were used: nothing will be produced)))
134 $(if $(4),,$(error No root has been set for the rdb file))
135 endef
137 # FIXME cannot have a dependency on $(gb_UnoApiTarget_RDBMAKERTARGET) here
138 # because that leads to dependency cycle because rdbmaker depends on offapi
139 $(call gb_UnoApiTarget_get_target,%) : $(gb_UnoApiTarget_XML2CMPTARGET) \
140 $(gb_UnoApiTarget_REGCOMPARETARGET) $(gb_UnoApiTarget_REGMERGETARGET)
141 $(call gb_UnoApiTarget__check_mode,$(UNOAPI_FILES),$(UNOAPI_MERGE),$(UNOAPI_XML),$(UNOAPI_ROOT))
142 $(call gb_UnoApiTarget__command,$@,$*)
144 .PHONY : $(call gb_UnoApiTarget_get_clean_target,%)
145 $(call gb_UnoApiTarget_get_clean_target,%) :
146 $(call gb_Output_announce,$*,$(false),UNO,4)
147 -$(call gb_Helper_abbreviate_dirs,\
148 rm -f $(call gb_UnoApiTarget_get_target,$*))
149 -rm -rf $(call gb_UnoApiTarget_get_dep_target,$*) \
150 $(basename $(call gb_UnoApiPartTarget_get_dep_target,$*)) \
151 $(call gb_UnoApiPartTarget_get_target,$*)
153 # cat the deps of all IDLs in one file, then we need only open that one file
154 define gb_UnoApiTarget__command_dep
155 $(call gb_Output_announce,IDL:$(2),$(true),DEP,1)
156 $(call gb_Helper_abbreviate_dirs,\
157 mkdir -p $(dir $(1)) && \
158 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
159 $(foreach idl,$(patsubst %.idl,%,$(3)),$(call gb_UnoApiPartTarget_get_dep_target,$(idl)))) && \
160 $(SOLARENV)/bin/concat-deps $${RESPONSEFILE} > $(1)) && \
161 rm -f $${RESPONSEFILE}
163 endef
165 ifeq ($(gb_FULLDEPS),$(true))
167 $(call gb_UnoApiTarget_get_dep_target,%) :
168 $(call gb_UnoApiTarget__command_dep,$@,$*,$(UNOAPI_IDLFILES))
170 endif
172 define gb_UnoApiTarget_UnoApiTarget
173 $(call gb_UnoApiTarget_get_target,$(1)) : INCLUDE :=
174 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_FILES :=
175 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_MERGE :=
176 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_XML :=
177 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_REFERENCE :=
178 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_ROOT :=
180 ifeq ($(gb_FULLDEPS),$(true))
181 $(call gb_UnoApiTarget_get_dep_target,$(1)) : UNOAPI_IDLFILES :=
182 -include $(call gb_UnoApiTarget_get_dep_target,$(1))
183 endif
185 endef
187 define gb_UnoApiTarget__add_urdfile
188 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_FILES += $(2)
189 $(call gb_UnoApiTarget_get_target,$(1)) : $(2)
191 endef
193 define gb_UnoApiTarget__add_idlfile
194 $(call gb_UnoApiPartTarget_get_target,$(2)/idl.done) : \
195 $(call gb_UnoApiPartTarget_get_target,$(2)/$(3).urd)
196 $(call gb_UnoApiTarget__add_urdfile,$(1),$(call gb_UnoApiPartTarget_get_target,$(2)/$(3).urd))
197 $(call gb_UnoApiPartTarget_get_target,$(2)/$(3).urd) :| \
198 $(call gb_UnoApiPartTarget_get_target,$(2)/.dir)
200 ifeq ($(gb_FULLDEPS),$(true))
201 $(call gb_UnoApiTarget_get_dep_target,$(1)) : UNOAPI_IDLFILES += $(2)/$(3).idl
202 $(call gb_UnoApiTarget_get_dep_target,$(1)) : \
203 $(call gb_UnoApiPartTarget_get_dep_target,$(2)/$(3))
204 endif
206 endef
208 define gb_UnoApiTarget__add_idlfiles
209 $(call gb_UnoApiTarget_get_target,$(1)) : \
210 $(call gb_UnoApiPartTarget_get_target,$(2)/idl.done)
211 $(call gb_UnoApiPartTarget_get_target,$(2)/idl.done) : \
212 $(foreach idl,$(3),$(SRCDIR)/$(2)/$(idl).idl)
214 endef
216 define gb_UnoApiTarget_add_idlfiles
217 $(foreach idl,$(3),$(call gb_UnoApiTarget_add_idlfile,$(1),$(2),$(idl)))
218 $(call gb_UnoApiTarget__add_idlfiles,$(1),$(2),$(3))
220 endef
222 define gb_UnoApiTarget_add_idlfile
223 $(call gb_UnoApiTarget__add_idlfile,$(1),$(2),$(3))
225 endef
227 define gb_UnoApiTarget_merge_rdbfiles
228 $$(call gb_Output_error,gb_UnoApiTarget_merge_rdbfiles: use gb_UnoApiTarget_merge_api instead.)
229 endef
231 define gb_UnoApiTarget_merge_api
232 $(foreach rdb,$(2),$(call gb_UnoApiTarget__merge_api,$(1),$(rdb)))
234 endef
236 define gb_UnoApiTarget_merge_rdbfile
237 $$(call gb_Output_error,gb_UnoApiTarget_merge_rdbfile: use gb_UnoApiTarget_merge_api instead.)
238 endef
240 define gb_UnoApiTarget__merge_api
241 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_MERGE += $(call gb_UnoApiTarget_get_target,$(2))
242 $(call gb_UnoApiTarget_get_target,$(1)) : $(call gb_UnoApiTarget_get_target,$(2))
244 endef
246 # Set XML component dependencies description.
247 define gb_UnoApiTarget_set_xmlfile
248 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_XML := $(SRCDIR)/$(2)
249 $(call gb_UnoApiTarget_get_target,$(1)) : $(SRCDIR)/$(2)
250 $(call gb_UnoApiTarget_get_target,$(1)) : $(gb_UnoApiTarget_XMLRDB)
252 endef
254 define gb_UnoApiTarget_add_reference_rdbfile
255 $$(call gb_Output_error,gb_UnoApiTarget_add_reference_rdbfile: use gb_UnoApiTarget_set_reference_rdbfile instead.)
256 endef
258 define gb_UnoApiTarget_set_reference_rdbfile
259 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_REFERENCE := $(SRCDIR)/$(strip $(2)).rdb
261 endef
263 define gb_UnoApiTarget_set_include
264 $(call gb_UnoApiTarget_get_target,$(1)) : INCLUDE := $(2)
266 endef
268 define gb_UnoApiTarget_set_root
269 $(call gb_UnoApiTarget_get_target,$(1)) : UNOAPI_ROOT := $(2)
271 endef
273 # UnoApiHeadersTarget
275 gb_UnoApiHeadersTarget_CPPUMAKERTARGET := $(call gb_Executable_get_target_for_build,cppumaker)
276 gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND := $(gb_Helper_set_ld_path) SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(gb_UnoApiHeadersTarget_CPPUMAKERTARGET)
278 define gb_UnoApiHeadersTarget__command
279 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,\
280 -Gc $(4) -BUCR \
281 -O$(3) $(call gb_UnoApiTarget_get_target,$(2)) $(UNOAPI_DEPS)) && \
282 $(gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND) @$${RESPONSEFILE} && \
283 rm -f $${RESPONSEFILE} && \
284 touch $(1)
286 endef
288 $(call gb_UnoApiHeadersTarget_get_bootstrap_target,%) : \
289 $(gb_UnoApiHeadersTarget_CPPUMAKERTARGET)
290 $(call gb_Output_announce,$*,$(true),HPB,3)
291 $(call gb_UnoApiHeadersTarget__command,$@,$*,$(call gb_UnoApiHeadersTarget_get_bootstrap_dir,$*))
293 $(call gb_UnoApiHeadersTarget_get_comprehensive_target,%) : \
294 $(gb_UnoApiHeadersTarget_CPPUMAKERTARGET)
295 $(call gb_Output_announce,$*,$(true),HPC,3)
296 $(call gb_UnoApiHeadersTarget__command,$@,$*,$(call gb_UnoApiHeadersTarget_get_comprehensive_dir,$*),-C)
298 $(call gb_UnoApiHeadersTarget_get_target,%) : \
299 $(gb_UnoApiHeadersTarget_CPPUMAKERTARGET)
300 $(call gb_Output_announce,$*,$(true),HPP,3)
301 $(call gb_UnoApiHeadersTarget__command,$@,$*,$(call gb_UnoApiHeadersTarget_get_dir,$*),-L)
303 .PHONY : $(call gb_UnoApiHeadersTarget_get_clean_target,%)
304 $(call gb_UnoApiHeadersTarget_get_clean_target,%) :
305 $(call gb_Output_announce,$*,$(false),HPP,3)
306 $(call gb_Helper_abbreviate_dirs,\
307 rm -rf \
308 $(call gb_UnoApiHeadersTarget_get_dir,$*) \
309 $(call gb_UnoApiHeadersTarget_get_bootstrap_dir,$*) \
310 $(call gb_UnoApiHeadersTarget_get_comprehensive_dir,$*) \
311 $(call gb_UnoApiHeadersTarget_get_target,$*) \
312 $(call gb_UnoApiHeadersTarget_get_bootstrap_target,$*)) \
313 $(call gb_UnoApiHeadersTarget_get_comprehensive_target,$*)
315 define gb_UnoApiHeadersTarget_UnoApiHeadersTarget
316 $(call gb_UnoApiHeadersTarget_get_target,$(1)) : $(call gb_UnoApiTarget_get_target,$(1))
317 $(call gb_UnoApiHeadersTarget_get_bootstrap_target,$(1)) : $(call gb_UnoApiTarget_get_target,$(1))
318 $(call gb_UnoApiHeadersTarget_get_comprehensive_target,$(1)) : $(call gb_UnoApiTarget_get_target,$(1))
319 $(call gb_UnoApiHeadersTarget_get_clean_target,$(1)) : $(call gb_UnoApiTarget_get_clean_target,$(1))
321 $(call gb_UnoApiHeadersTarget_get_target,$(1)) : UNOAPI_DEPS :=
322 $(call gb_UnoApiHeadersTarget_get_bootstrap_target,$(1)) : UNOAPI_DEPS :=
323 $(call gb_UnoApiHeadersTarget_get_comprehensive_target,$(1)) : UNOAPI_DEPS :=
325 # need dummy recipes so that header files are delivered in Package_inc;
326 # otherwise make will consider the header to be up-to-date because it was
327 # actually built by the recipe for gb_UnoApiHeadersTarget_get_target
328 $(call gb_UnoApiHeadersTarget_get_dir,$(1),/%.hdl) :
329 touch $$@
331 $(call gb_UnoApiHeadersTarget_get_dir,$(1),/%.hpp) :
332 touch $$@
334 $(call gb_UnoApiHeadersTarget_get_bootstrap_dir,$(1),/%.hdl) :
335 touch $$@
337 $(call gb_UnoApiHeadersTarget_get_bootstrap_dir,$(1),/%.hpp) :
338 touch $$@
340 $(call gb_UnoApiHeadersTarget_get_comprehensive_dir,$(1),/%.hdl) :
341 touch $$@
343 $(call gb_UnoApiHeadersTarget_get_comprehensive_dir,$(1),/%.hpp) :
344 touch $$@
346 endef
348 # ensure that new urd triggers the dummy rule to rebuild the headers
349 define gb_UnoApiHeadersTarget_add_headerfile
350 $(call gb_UnoApiHeadersTarget_get_dir,$(1),/$(3)) : \
351 $(call gb_UnoApiPartTarget_get_target,$(basename $(2)).urd)
353 endef
355 define gb_UnoApiHeadersTarget__use_api_for_target
356 $(call gb_UnoApiHeadersTarget_get_$(3),$(1)) : $(call gb_UnoApiTarget_get_target,$(2))
357 $(call gb_UnoApiHeadersTarget_get_$(3),$(1)) : UNOAPI_DEPS += -X$(call gb_UnoApiTarget_get_target,$(2))
359 endef
361 define gb_UnoApiHeadersTarget_add_rdbfile
362 $$(call gb_Output_error,gb_UnoApiHeadersTarget_add_rdbfile: use gb_UnoApiHeadersTarget_use_api instead.)
363 endef
365 define gb_UnoApiHeadersTarget__use_api
366 $(call gb_UnoApiHeadersTarget__use_api_for_target,$(1),$(2),target)
367 $(call gb_UnoApiHeadersTarget__use_api_for_target,$(1),$(2),bootstrap_target)
368 $(call gb_UnoApiHeadersTarget__use_api_for_target,$(1),$(2),comprehensive_target)
370 endef
372 define gb_UnoApiHeadersTarget_add_rdbfiles
373 $$(call gb_Output_error,gb_UnoApiHeadersTarget_add_rdbfiles: use gb_UnoApiHeadersTarget_use_api instead.)
374 endef
376 define gb_UnoApiHeadersTarget_use_api
377 $(foreach rdb,$(2),$(call gb_UnoApiHeadersTarget__use_api,$(1),$(rdb)))
379 endef
381 # vim: set noet sw=4 ts=4: