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_UnoApiTarget_UNOIDLWRITEDEPS
:= $(call gb_Executable_get_runtime_dependencies
,unoidl-write
)
23 gb_UnoApiTarget_UNOIDLWRITECOMMAND
:= $(call gb_Executable_get_command
,unoidl-write
)
25 gb_UnoApiTarget_UNOIDLCHECKDEPS
:= $(call gb_Executable_get_runtime_dependencies
,unoidl-check
)
26 gb_UnoApiTarget_UNOIDLCHECKCOMMAND
:= $(call gb_Executable_get_command
,unoidl-check
)
28 define gb_UnoApiTarget__command
29 mkdir
-p
$(dir $(1)) \
30 $(if
$(UNOAPI_ENTITIES
), \
31 && RESPONSEFILE
=$(call gb_var2file
,$(shell $(gb_MKTEMP
)),$(UNOAPI_ENTITIES
))) \
32 && $(gb_UnoApiTarget_UNOIDLWRITECOMMAND
) \
33 $(foreach rdb
,$(UNOAPI_DEPRDBS
),$(call gb_UnoApiTarget_get_target
,$(rdb
))) \
34 $(SRCDIR
)/$(gb_UnoApiTarget_REG_
$(2)) $(if
$(UNOAPI_ENTITIES
),@
$${RESPONSEFILE}) $(1) \
35 $(if
$(UNOAPI_ENTITIES
),&& rm -f
$${RESPONSEFILE}) \
36 $(if
$(UNOAPI_REFERENCE
), \
37 $(call gb_Output_announce
,$(2),$(true
),DBc
,3) \
38 && { $(gb_UnoApiTarget_UNOIDLCHECKCOMMAND
) $(UNOAPI_REFERENCE
) -- \
39 $(foreach rdb
,$(UNOAPI_DEPRDBS
),$(call gb_UnoApiTarget_get_target
,$(rdb
))) \
41 ||
{ printf
'ERROR: Published UNO API must not be changed incompatibly!\n(If published UNO API shall be changed incompatibly after all, see\n<https://wiki.documentfoundation.org/Development/Incompatible_UNO_API_Changes>.)\n'; \
45 $(call gb_UnoApiTarget_get_target
,%) :
46 $(call gb_Output_announce
,$*,$(true
),UNO
,4)
47 $(call gb_Trace_StartRange
,$*,UNO
)
48 $(call gb_UnoApiTarget__command
,$@
,$*)
49 $(call gb_Trace_EndRange
,$*,UNO
)
51 .PHONY
: $(call gb_UnoApiTarget_get_clean_target
,%)
52 $(call gb_UnoApiTarget_get_clean_target
,%) :
53 $(call gb_Output_announce
,$*,$(false
),UNO
,4)
54 -$(call gb_Helper_abbreviate_dirs
,\
55 rm -rf
$(call gb_UnoApiTarget_get_target
,$*))
57 define gb_UnoApiTarget_UnoApiTarget
58 gb_UnoApiTarget_REG_
$(1) := $(2)
59 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_ENTITIES
:=
60 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_REFERENCE
:=
61 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_DEPRDBS
:=
62 $(call gb_UnoApiTarget_get_target
,$(1)) : $(gb_UnoApiTarget_UNOIDLWRITEDEPS
)
63 $(call gb_UnoApiTarget_get_target
,$(1)) : $(SRCDIR
)/$(2) # may be dir, though
67 define gb_UnoApiTarget_add_idlfile
68 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_ENTITIES
+= $(subst /,.
,$(2))$(if
$(2),.
)$(3)
69 $(call gb_UnoApiTarget_get_target
,$(1)) : $(SRCDIR
)/$(gb_UnoApiTarget_REG_
$(1))/$(2)/$(3).idl
73 define gb_UnoApiTarget_add_idlfiles
74 $(foreach idl
,$(3),$(call gb_UnoApiTarget_add_idlfile
,$(1),$(2),$(idl
)))
78 define gb_UnoApiTarget_set_reference_rdbfile
79 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_REFERENCE
:= $(2)
80 $(call gb_UnoApiTarget_get_target
,$(1)) : $(2)
81 $(call gb_UnoApiTarget_get_target
,$(1)) : $(gb_UnoApiTarget_UNOIDLCHECKDEPS
)
85 define gb_UnoApiTarget_use_api
86 $(call gb_UnoApiTarget_get_target
,$(1)) : UNOAPI_DEPRDBS
+= $(2)
87 $(call gb_UnoApiTarget_get_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(2))
94 # gb_UnoApiHeadersTarget_select_variant
96 # Allow to redefine header variant.
98 # On iOS we use static linking because dynamic loading of own code
99 # isn't allowed by the iOS App Store rules, and we want our code to be
100 # eventually distributable there as part of apps.
102 # To avoid problems that this causes together with the lovely
103 # intentional breaking of the One Definition Rule, for iOS we always
104 # generate comprehensive headers for certain type RDBS. (The ODR
105 # breakage doesn't harm, by accident or careful design, on platforms
106 # where shared libraries are used.) To avoid generating the same headers
107 # more than once, we are silently "redirecting" the target to point to
108 # comprehensive headers instead.
111 # If gb_UnoApiHeadersTarget_select_variant is defined as
113 # ifeq ($(DISABLE_DYNLOADING),TRUE)
114 # gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
116 # gb_UnoApiHeadersTarget_select_variant = $(2)
119 # then, for the DISABLE_DYNLOADING case, whenever a makefile uses
120 # $(call gb_UnoApiHeadersTarget_get_target,udkapi) or $(call
121 # gb_UnoApiHeadersTarget_get_dir,udkapi), it will get target or dir for
122 # comprehensive headers instead.
124 # We are experimenting with static linking on Android, too. There for
125 # technical reasons to get around silly limitations in the OS, sigh.
127 # gb_UnoApiHeadersTarget_select_variant api default-variant
128 ifeq ($(origin gb_UnoApiHeadersTarget_select_variant
),undefined
)
129 $(eval
$(call gb_Output_error
,gb_UnoApiHeadersTarget_select_variant must be defined by platform
))
132 gb_UnoApiHeadersTarget_CPPUMAKERDEPS
:= $(call gb_Executable_get_runtime_dependencies
,cppumaker
)
133 gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND
:= $(call gb_Executable_get_command
,cppumaker
)
135 define gb_UnoApiHeadersTarget__command
136 $(gb_UnoApiHeadersTarget_CPPUMAKERCOMMAND
) \
137 -Gc
$(4) -O
$(3) $(call gb_UnoApiTarget_get_target
,$(2)) \
143 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,%) : \
144 $(gb_UnoApiHeadersTarget_CPPUMAKERDEPS
)
145 $(call gb_Output_announce
,$*,$(true
),HPB
,3) \
146 $(call gb_Trace_StartRange
,$*,HPB
)
147 $(call gb_UnoApiHeadersTarget__command
,$@
,$*,$(call gb_UnoApiHeadersTarget_get_bootstrap_dir
,$*))
148 $(call gb_Trace_EndRange
,$*,HPB
)
150 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,%) : \
151 $(gb_UnoApiHeadersTarget_CPPUMAKERDEPS
)
152 $(call gb_Output_announce
,$*,$(true
),HPC
,3)
153 $(call gb_Trace_StartRange
,$*,HPC
)
154 $(call gb_UnoApiHeadersTarget__command
,$@
,$*,$(call gb_UnoApiHeadersTarget_get_comprehensive_dir
,$*),-C
)
155 $(call gb_Trace_EndRange
,$*,HPC
)
157 $(call gb_UnoApiHeadersTarget_get_real_target
,%) : \
158 $(gb_UnoApiHeadersTarget_CPPUMAKERDEPS
)
159 $(call gb_Output_announce
,$*,$(true
),HPP
,3) \
160 $(call gb_Trace_StartRange
,$*,HPP
)
161 $(call gb_UnoApiHeadersTarget__command
,$@
,$*,$(call gb_UnoApiHeadersTarget_get_dir
,$*),-L
)
162 $(call gb_Trace_EndRange
,$*,HPP
)
164 .PHONY
: $(call gb_UnoApiHeadersTarget_get_clean_target
,%)
165 $(call gb_UnoApiHeadersTarget_get_clean_target
,%) :
166 $(call gb_Output_announce
,$*,$(false
),HPP
,3)
167 $(call gb_Helper_abbreviate_dirs
,\
169 $(call gb_UnoApiHeadersTarget_get_real_dir
,$*) \
170 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_dir
,$*) \
171 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_dir
,$*) \
172 $(call gb_UnoApiHeadersTarget_get_real_target
,$*) \
173 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,$*)) \
174 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,$*)
176 define gb_UnoApiHeadersTarget_UnoApiHeadersTarget
177 $(call gb_UnoApiHeadersTarget_get_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(1))
178 $(call gb_UnoApiHeadersTarget_get_bootstrap_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(1))
179 $(call gb_UnoApiHeadersTarget_get_comprehensive_target
,$(1)) : $(call gb_UnoApiTarget_get_target
,$(1))
180 $(call gb_UnoApiHeadersTarget_get_clean_target
,$(1)) : $(call gb_UnoApiTarget_get_clean_target
,$(1))
182 $(call gb_UnoApiHeadersTarget_get_target
,$(1)) : UNOAPI_DEPS
:=
183 $(call gb_UnoApiHeadersTarget_get_bootstrap_target
,$(1)) : UNOAPI_DEPS
:=
184 $(call gb_UnoApiHeadersTarget_get_comprehensive_target
,$(1)) : UNOAPI_DEPS
:=
186 # need dummy recipes so that header files are delivered in Package_inc;
187 # otherwise make will consider the header to be up-to-date because it was
188 # actually built by the recipe for gb_UnoApiHeadersTarget_get_target
189 $(call gb_UnoApiHeadersTarget_get_real_dir
,$(1))/%.hdl
: \
190 $(call gb_Executable_get_target_for_build
,cppumaker
) \
191 |
$(call gb_UnoApiHeadersTarget_get_real_target
,$(1))
194 $(call gb_UnoApiHeadersTarget_get_real_dir
,$(1))/%.hpp
: \
195 $(call gb_Executable_get_target_for_build
,cppumaker
) \
196 |
$(call gb_UnoApiHeadersTarget_get_real_target
,$(1))
199 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_dir
,$(1))/%.hdl
: \
200 $(call gb_Executable_get_target_for_build
,cppumaker
) \
201 |
$(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,$(1))
204 $(call gb_UnoApiHeadersTarget_get_real_bootstrap_dir
,$(1))/%.hpp
: \
205 $(call gb_Executable_get_target_for_build
,cppumaker
) \
206 |
$(call gb_UnoApiHeadersTarget_get_real_bootstrap_target
,$(1))
209 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_dir
,$(1))/%.hdl
: \
210 $(call gb_Executable_get_target_for_build
,cppumaker
) \
211 |
$(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,$(1))
214 $(call gb_UnoApiHeadersTarget_get_real_comprehensive_dir
,$(1))/%.hpp
: \
215 $(call gb_Executable_get_target_for_build
,cppumaker
) \
216 |
$(call gb_UnoApiHeadersTarget_get_real_comprehensive_target
,$(1))
221 # ensure that idl change triggers the dummy rule to rebuild the headers
222 # call gb_UnoApiHeadersTarget_add_headerfile,unoapi,headerfile
223 define gb_UnoApiHeadersTarget_add_headerfile
224 $(call gb_UnoApiHeadersTarget_get_dir
,$(1))/$(2) : \
225 $(SRCDIR
)/$(basename $(gb_UnoApiTarget_REG_
$(1))/$(2)).idl
229 # call gb_UnoApiHeadersTarget_add_headerfiles,unoapi,directory,headerfilenames
230 define gb_UnoApiHeadersTarget_add_headerfiles
231 $(foreach hdr
,$(3),$(call gb_UnoApiHeadersTarget_add_headerfile
,$(1),$(2)/$(hdr
)))
234 define gb_UnoApiHeadersTarget__use_api_for_target
235 $(call gb_UnoApiHeadersTarget_get_
$(3),$(1)) : $(call gb_UnoApiTarget_get_target
,$(2))
236 $(call gb_UnoApiHeadersTarget_get_
$(3),$(1)) : UNOAPI_DEPS
+= -X
$(call gb_UnoApiTarget_get_target
,$(2))
240 define gb_UnoApiHeadersTarget__use_api
241 $(call gb_UnoApiHeadersTarget__use_api_for_target
,$(1),$(2),target
)
242 $(call gb_UnoApiHeadersTarget__use_api_for_target
,$(1),$(2),bootstrap_target
)
243 $(call gb_UnoApiHeadersTarget__use_api_for_target
,$(1),$(2),comprehensive_target
)
247 define gb_UnoApiHeadersTarget_use_api
248 $(foreach rdb
,$(2),$(call gb_UnoApiHeadersTarget__use_api
,$(1),$(rdb
)))
252 # vim: set noet sw=4 ts=4: