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 .
22 gb_UnoApiPartTarget_IDLCDEPS
:= $(call gb_Executable_get_runtime_dependencies
,idlc
)
23 gb_UnoApiPartTarget_IDLCCOMMAND
:= SOLARBINDIR
=$(OUTDIR_FOR_BUILD
)/bin
$(call gb_Executable_get_command
,idlc
)
25 # The .urd files are actually created by the gb_UnoApiPartTarget__command,
26 # invoked for the per-directory .done files.
27 # The reason why .urd files are tracked is so new files that are added are
28 # picked up and cause a rebuild, even if older than the .done file (also, as a
29 # convenience for users who delete them from the workdir by hand; this dummy
30 # rule plus the dependency from the .done target to the .urd file plus the
31 # sort/patsubst call in gb_UnoApiPartTarget__command cause command to be
32 # invoked with the .idl file corresponding to the .urd in that case.
33 # Touch the .urd file, so it is newer than the .done file, causing that to
34 # be rebuilt and overwriting the .urd file again.
35 # the .dir is for make 3.81, which ignores trailing /
36 $(dir $(call gb_UnoApiPartTarget_get_target
,))%/.
dir :
37 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
39 $(call gb_UnoApiPartTarget_get_target
,%.urd
) :
43 # - get idlc switch "-P" (generate .urd into package dir)
44 # - empty $? in headertarget?
46 define gb_UnoApiPartTarget__command
47 $(call gb_Output_announce
,$(2),$(true
),IDL
,2)
48 mkdir
-p
$(call gb_UnoApiPartTarget_get_target
,$(dir $(2))) && \
49 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),500,\
50 $(sort $(patsubst $(call gb_UnoApiPartTarget_get_target
,%.urd
),$(SRCDIR
)/%.idl
,$(3)))) && \
51 $(gb_UnoApiPartTarget_IDLCCOMMAND
) \
53 -M
$(basename $(call gb_UnoApiPartTarget_get_dep_target
,$(dir $(2)))) \
54 -O
$(call gb_UnoApiPartTarget_get_target
,$(dir $(2))) -verbose \
55 @
$${RESPONSEFILE} > /dev
/null
&& \
56 rm -f
$${RESPONSEFILE} && \
61 # If idlc changed, rebuild everything; otherwise just the changed files.
62 # In order for this to work the .urd files need to have a dependency on
63 # idlc as well so their dummy rule fires if that changes.
64 $(call gb_UnoApiPartTarget_get_target
,%.done
) : $(gb_UnoApiPartTarget_IDLCDEPS
)
65 $(call gb_UnoApiPartTarget__command
,$@
,$*,$(filter-out $(gb_UnoApiPartTarget_IDLCDEPS
),$(if
$(filter $(gb_UnoApiPartTarget_IDLCDEPS
),$?
),$^
,$?
)))
67 ifeq ($(gb_FULLDEPS
),$(true
))
69 $(call gb_UnoApiPartTarget_get_dep_target
,%) :
70 $(if
$(wildcard $@
),touch
$@
,\
71 $(call gb_Object__command_dep
,$@
,$(call gb_UnoApiPartTarget_get_target
,$*.urd
)))
77 gb_UnoApiTarget_REGCOMPAREDEPS
:= $(call gb_Executable_get_runtime_dependencies
,regcompare
)
78 gb_UnoApiTarget_REGCOMPARECOMMAND
:= SOLARBINDIR
=$(OUTDIR_FOR_BUILD
)/bin
$(call gb_Executable_get_command
,regcompare
)
79 gb_UnoApiTarget_REGMERGEDEPS
:= $(call gb_Executable_get_runtime_dependencies
,regmerge
) $(call gb_Executable_get_runtime_dependencies
,reg2unoidl
)
80 gb_UnoApiTarget_REGMERGECOMMAND
:= SOLARBINDIR
=$(OUTDIR_FOR_BUILD
)/bin
$(call gb_Executable_get_command
,regmerge
)
82 gb_UnoApiTarget_TYPESRDB
:= $(call gb_UnoApiTarget_get_target
,types
)
84 define gb_UnoApiTarget__command_impl
85 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),500,$(1).oldformat
$(2) $(3)) && \
86 $(gb_UnoApiTarget_REGMERGECOMMAND
) @
$${RESPONSEFILE} && \
87 rm -f
$${RESPONSEFILE} && \
88 SOLARBINDIR
=$(OUTDIR_FOR_BUILD
)/bin \
89 $(call gb_Executable_get_command
,reg2unoidl
) \
90 $(foreach rdb
,$(4),$(call gb_UnoApiTarget_get_target
,$(rdb
))) \
94 # first delete target rdb file to detect problems when removing IDL files
95 define gb_UnoApiTarget__command
96 $(call gb_Output_announce
,$(2),$(true
),UNO
,4)
97 mkdir
-p
$(dir $(1)) && \
99 $(call gb_UnoApiTarget__command_impl
,$(1),$(UNOAPI_ROOT
),$(UNOAPI_FILES
),$(UNOAPI_DEPRDBS
)) \
100 $(if
$(UNOAPI_REFERENCE
), \
101 $(call gb_Output_announce
,$(2),$(true
),DBc
,3) \
102 && $(gb_UnoApiTarget_REGCOMPARECOMMAND
) \
104 -r1
$(UNOAPI_REFERENCE
) \
108 define gb_UnoApiTarget__check_mode
109 $(if
$(UNOAPI_FILES
),,$(error No IDL files have been set for the rdb file
))
110 $(if
$(UNOAPI_ROOT
),,$(error No root has been set for the rdb file
))
113 $(call gb_UnoApiTarget_get_target
,%) :
114 $(call gb_UnoApiTarget__check_mode
)
115 $(call gb_UnoApiTarget__command
,$@
,$*)
117 .PHONY
: $(call gb_UnoApiTarget_get_clean_target
,%)
118 $(call gb_UnoApiTarget_get_clean_target
,%) :
119 $(call gb_Output_announce
,$*,$(false
),UNO
,4)
120 -$(call gb_Helper_abbreviate_dirs
,\
121 rm -rf
$(call gb_UnoApiTarget_get_target
,$*) \
122 $(call gb_UnoApiTarget_get_target
,$*).oldformat \
123 $(call gb_UnoApiTarget_get_dep_target
,$*) \
124 $(basename $(call gb_UnoApiPartTarget_get_dep_target
,$*)) \
125 $(call gb_UnoApiPartTarget_get_target
,$*))
127 # cat the deps of all IDLs in one file, then we need only open that one file
128 define gb_UnoApiTarget__command_dep
129 $(call gb_Output_announce
,IDL
:$(2),$(true
),DEP
,1)
130 $(call gb_Helper_abbreviate_dirs
,\
131 mkdir
-p
$(dir $(1)) && \
132 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),200,\
133 $(foreach idl
,$(patsubst %.idl
,%,$(3)),$(call gb_UnoApiPartTarget_get_dep_target
,$(idl
)))) && \
134 $(call gb_Executable_get_command
,concat-deps
) $${RESPONSEFILE} > $(1)) && \
135 rm -f
$${RESPONSEFILE}
139 ifeq ($(gb_FULLDEPS
),$(true
))
141 $(call gb_UnoApiTarget_get_dep_target
,%) : $(call gb_Executable_get_runtime_dependencies
,concat-deps
)
142 $(call gb_UnoApiTarget__command_dep
,$@
,$*,$(UNOAPI_IDLFILES
))
146 define gb_UnoApiTarget_UnoApiTarget
147 $(call gb_UnoApiTarget_get_target
,$(1)) : INCLUDE
:=
148 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_FILES
:=
149 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_REFERENCE
:=
150 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_ROOT
:=
151 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_DEPRDBS
:=
153 ifeq ($(gb_FULLDEPS
),$(true
))
154 $(call gb_UnoApiTarget_get_dep_target
,$(1)) : UNOAPI_IDLFILES
:=
155 -include $(call gb_UnoApiTarget_get_dep_target
,$(1))
160 define gb_UnoApiTarget__add_urdfile
161 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_FILES
+= $(2)
162 $(call gb_UnoApiTarget_get_target
,$(1)) : $(2)
166 define gb_UnoApiTarget__add_idlfile
167 $(call gb_UnoApiPartTarget_get_target
,$(2)/idl.done
) : \
168 $(call gb_UnoApiPartTarget_get_target
,$(2)/$(3).urd
)
169 $(call gb_UnoApiTarget__add_urdfile
,$(1),$(call gb_UnoApiPartTarget_get_target
,$(2)/$(3).urd
))
170 $(call gb_UnoApiPartTarget_get_target
,$(2)/$(3).urd
) \
171 : $(gb_UnoApiPartTarget_IDLCDEPS
) \
172 |
$(call gb_UnoApiPartTarget_get_target
,$(2)/.
dir)
174 ifeq ($(gb_FULLDEPS
),$(true
))
175 $(call gb_UnoApiTarget_get_dep_target
,$(1)) : UNOAPI_IDLFILES
+= $(2)/$(3).idl
176 $(call gb_UnoApiTarget_get_dep_target
,$(1)) : \
177 $(call gb_UnoApiPartTarget_get_dep_target
,$(2)/$(3))
182 define gb_UnoApiTarget__add_idlfiles
183 $(call gb_UnoApiTarget_get_target
,$(1)) : \
184 $(call gb_UnoApiPartTarget_get_target
,$(2)/idl.done
)
185 $(call gb_UnoApiPartTarget_get_target
,$(2)/idl.done
) : \
186 $(foreach idl
,$(3),$(SRCDIR
)/$(2)/$(idl
).idl
)
190 define gb_UnoApiTarget_add_idlfiles
191 $(foreach idl
,$(3),$(call gb_UnoApiTarget_add_idlfile
,$(1),$(2),$(idl
)))
192 $(call gb_UnoApiTarget__add_idlfiles
,$(1),$(2),$(3))
193 $(call gb_UnoApiTarget_get_target
,$(1)) : $(gb_UnoApiTarget_REGMERGEDEPS
)
197 define gb_UnoApiTarget_add_idlfile
198 $(call gb_UnoApiTarget__add_idlfile
,$(1),$(2),$(3))
202 define gb_UnoApiTarget_add_reference_rdbfile
203 $$(call gb_Output_error
,gb_UnoApiTarget_add_reference_rdbfile
: use gb_UnoApiTarget_set_reference_rdbfile instead.
)
206 define gb_UnoApiTarget_set_reference_rdbfile
207 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_REFERENCE
:= $(SRCDIR
)/$(strip $(2)).rdb
208 $(call gb_UnoApiTarget_get_target
,$(1)) : $(gb_UnoApiTarget_REGCOMPAREDEPS
)
212 define gb_UnoApiTarget_set_include
213 $(call gb_UnoApiTarget_get_target
,$(1)) : INCLUDE
:= $(2)
217 define gb_UnoApiTarget_set_root
218 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_ROOT
:= $(2)
222 define gb_UnoApiTarget_use_api
223 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_DEPRDBS
+= $(2)
224 $(call gb_UnoApiTarget_get_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(2))
228 # UnoApiHeadersTarget
230 # defined by platform
231 # gb_UnoApiHeadersTarget_select_variant
233 # Allow to redefine header variant.
235 # On iOS we use static linking because dynamic loading of own code
236 # isn't allowed by the iOS App Store rules, and we want our code to be
237 # eventually distributable there as part of apps.
239 # To avoid problems that this causes together with the lovely
240 # intentional breaking of the One Definition Rule, for iOS we always
241 # generate comprehensive headers for certain type RDBS. (The ODR
242 # breakage doesn't harm, by accident or careful design, on platforms
243 # where shared libraries are used.) To avoid generating the same headers
244 # more than once, we are silently "redirecting" the target to point to
245 # comprehensive headers instead.
248 # If gb_UnoApiHeadersTarget_select_variant is defined as
250 # ifeq ($(DISABLE_DYNLOADING),YES)
251 # gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
253 # gb_UnoApiHeadersTarget_select_variant = $(2)
256 # then, for the DISABLE_DYNLOADING case, whenever a makefile uses
257 # $(call gb_UnoApiHeadersTarget_get_target,udkapi) or $(call
258 # gb_UnoApiHeadersTarget_get_dir,udkapi), it will get target or dir for
259 # comprehensive headers instead.
261 # We are experimenting with static linking on Android, too. There for
262 # technical reasons to get around silly limitations in the OS, sigh.
264 # gb_UnoApiHeadersTarget_select_variant api default-variant
265 ifeq ($(origin gb_UnoApiHeadersTarget_select_variant
),undefined
)
266 $(eval
$(call gb_Output_error
,gb_UnoApiHeadersTarget_select_variant must be defined by platform
))
269 gb_UnoApiHeadersTarget_CPPUMAKERDEPS
:= $(call gb_Executable_get_runtime_dependencies
,cppumaker
)
270 gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND
:= SOLARBINDIR
=$(OUTDIR_FOR_BUILD
)/bin
$(call gb_Executable_get_command
,cppumaker
)
272 define gb_UnoApiHeadersTarget__command
273 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),100,\
275 $(gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND
) \
276 -Gc
$(4) -O
$(3) $(call gb_UnoApiTarget_get_target
,$(2)) \
277 @
$${RESPONSEFILE} && \
278 rm -f
$${RESPONSEFILE} && \
283 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,%) : \
284 $(gb_UnoApiHeadersTarget_CPPUMAKERDEPS
)
285 $(call gb_Output_announce
,$*,$(true
),HPB
,3) \
286 $(call gb_UnoApiHeadersTarget__command
,$@
,$*,$(call gb_UnoApiHeadersTarget_get_bootstrap_dir
,$*))
288 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,%) : \
289 $(gb_UnoApiHeadersTarget_CPPUMAKERDEPS
)
290 $(call gb_Output_announce
,$*,$(true
),HPC
,3)
291 $(call gb_UnoApiHeadersTarget__command
,$@
,$*,$(call gb_UnoApiHeadersTarget_get_comprehensive_dir
,$*),-C
)
293 $(call gb_UnoApiHeadersTarget_get_real_target
,%) : \
294 $(gb_UnoApiHeadersTarget_CPPUMAKERDEPS
)
295 $(call gb_Output_announce
,$*,$(true
),HPP
,3) \
296 $(call gb_UnoApiHeadersTarget__command
,$@
,$*,$(call gb_UnoApiHeadersTarget_get_dir
,$*),-L
)
298 .PHONY
: $(call gb_UnoApiHeadersTarget_get_clean_target
,%)
299 $(call gb_UnoApiHeadersTarget_get_clean_target
,%) :
300 $(call gb_Output_announce
,$*,$(false
),HPP
,3)
301 $(call gb_Helper_abbreviate_dirs
,\
303 $(call gb_UnoApiHeadersTarget_get_real_dir
,$*) \
304 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_dir
,$*) \
305 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_dir
,$*) \
306 $(call gb_UnoApiHeadersTarget_get_real_target
,$*) \
307 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,$*)) \
308 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,$*)
310 define gb_UnoApiHeadersTarget_UnoApiHeadersTarget
311 $(call gb_UnoApiHeadersTarget_get_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(1))
312 $(call gb_UnoApiHeadersTarget_get_bootstrap_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(1))
313 $(call gb_UnoApiHeadersTarget_get_comprehensive_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(1))
314 $(call gb_UnoApiHeadersTarget_get_clean_target
,$(1)) : $(call gb_UnoApiTarget_get_clean_target
,$(1))
316 $(call gb_UnoApiHeadersTarget_get_target
,$(1)) : UNOAPI_DEPS
:=
317 $(call gb_UnoApiHeadersTarget_get_bootstrap_target
,$(1)) : UNOAPI_DEPS
:=
318 $(call gb_UnoApiHeadersTarget_get_comprehensive_target
,$(1)) : UNOAPI_DEPS
:=
320 # need dummy recipes so that header files are delivered in Package_inc;
321 # otherwise make will consider the header to be up-to-date because it was
322 # actually built by the recipe for gb_UnoApiHeadersTarget_get_target
323 $(call gb_UnoApiHeadersTarget_get_real_dir
,$(1))/%.hdl
:| \
324 $(call gb_UnoApiHeadersTarget_get_real_target
,$(1))
327 $(call gb_UnoApiHeadersTarget_get_real_dir
,$(1))/%.hpp
:| \
328 $(call gb_UnoApiHeadersTarget_get_real_target
,$(1))
331 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_dir
,$(1))/%.hdl
:| \
332 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,$(1))
335 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_dir
,$(1))/%.hpp
:| \
336 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,$(1))
339 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_dir
,$(1))/%.hdl
:| \
340 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,$(1))
343 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_dir
,$(1))/%.hpp
:| \
344 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,$(1))
349 # ensure that new urd triggers the dummy rule to rebuild the headers
350 define gb_UnoApiHeadersTarget_add_headerfile
351 $(call gb_UnoApiHeadersTarget_get_dir
,$(1))/$(3) : \
352 $(call gb_UnoApiPartTarget_get_target
,$(basename $(2)).urd
)
356 define gb_UnoApiHeadersTarget__use_api_for_target
357 $(call gb_UnoApiHeadersTarget_get_
$(3),$(1)) : $(call gb_UnoApiTarget_get_target
,$(2))
358 $(call gb_UnoApiHeadersTarget_get_
$(3),$(1)) : UNOAPI_DEPS
+= -X
$(call gb_UnoApiTarget_get_target
,$(2))
362 define gb_UnoApiHeadersTarget_add_rdbfile
363 $$(call gb_Output_error
,gb_UnoApiHeadersTarget_add_rdbfile
: use gb_UnoApiHeadersTarget_use_api instead.
)
366 define gb_UnoApiHeadersTarget__use_api
367 $(call gb_UnoApiHeadersTarget__use_api_for_target
,$(1),$(2),target
)
368 $(call gb_UnoApiHeadersTarget__use_api_for_target
,$(1),$(2),bootstrap_target
)
369 $(call gb_UnoApiHeadersTarget__use_api_for_target
,$(1),$(2),comprehensive_target
)
373 define gb_UnoApiHeadersTarget_add_rdbfiles
374 $$(call gb_Output_error
,gb_UnoApiHeadersTarget_add_rdbfiles
: use gb_UnoApiHeadersTarget_use_api instead.
)
377 define gb_UnoApiHeadersTarget_use_api
378 $(foreach rdb
,$(2),$(call gb_UnoApiHeadersTarget__use_api
,$(1),$(rdb
)))
382 # vim: set noet sw=4 ts=4: