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 .
23 # defined globally in TargetLocations.mk
24 # gb_Library_DLLDIR := $(WORKDIR)/LinkTarget/Library
27 # gb_Library_ILIBFILENAMES
28 # gb_Library_FILENAMES
29 # gb_Library_Library_platform
31 gb_Library_LAYER_DIRS
:= \
32 URELIB
:$(INSTROOT
)/$(LIBO_URE_LIB_FOLDER
) \
33 OOO
:$(INSTROOT
)/$(LIBO_LIB_FOLDER
) \
34 SHLXTHDL
:$(INSTROOT
)/$(LIBO_LIB_FOLDER
)/shlxthdl \
35 OXT
:$(WORKDIR
)/LinkTarget
/ExtensionLibrary \
36 NONE
:$(gb_Library_DLLDIR
) \
38 gb_Library_LAYER_DIRS_FOR_BUILD
:= \
39 URELIB
:$(INSTROOT_FOR_BUILD
)/$(LIBO_URE_LIB_FOLDER_FOR_BUILD
) \
40 OOO
:$(INSTROOT_FOR_BUILD
)/$(LIBO_LIB_FOLDER_FOR_BUILD
) \
41 SHLXTHDL
:$(INSTROOT_FOR_BUILD
)/$(LIBO_LIB_FOLDER_FOR_BUILD
)/shlxthdl \
42 OXT
:$(WORKDIR_FOR_BUILD
)/LinkTarget
/ExtensionLibrary \
43 NONE
:$(gb_Library_DLLDIR_FOR_BUILD
) \
45 # EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
46 .PHONY
: $(WORKDIR
)/Clean
/Library
/%
47 $(WORKDIR
)/Clean
/Library
/% :
48 $(call gb_Helper_abbreviate_dirs
,\
49 rm -f
$(call gb_Library_get_exports_target
,$*) \
52 gb_Library__get_dir_for_layer
= $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Library_LAYER_DIRS
)))
53 gb_Library__get_dir_for_layer_for_build
= $(patsubst $(1):%,%,$(filter $(1):%,$(call gb_Library_LAYER_DIRS_FOR_BUILD
)))
54 gb_Library_get_instdir
= $(call gb_Library__get_dir_for_layer
,$(call gb_Library_get_layer
,$(1)))
55 gb_Library_get_instdir_for_build
= $(call gb_Library__get_dir_for_layer_for_build
,$(call gb_Library_get_layer
,$(1)))
57 gb_Library_get_ilib_target
= $(if
$(filter $(1),$(gb_Library_RTVERLIBS
) $(gb_Library_UNOVERLIBS
)),$(call gb_Library_get_sdk_link_dir
)/$(call gb_Library_get_ilibfilename
,$(1)),$(gb_Library_DLLDIR
)/$(call gb_Library_get_ilibfilename
,$(1)))
59 define gb_Library_Library
60 $(call gb_Postprocess_register_target
,AllLibraries
,Library
,$(1))
61 ifeq (,$$(filter $(1),$$(gb_Library_KNOWNLIBS
)))
62 $$(eval
$$(call gb_Output_info
,Currently known libraries are
: $(sort $(gb_Library_KNOWNLIBS
)),ALL
))
63 $$(eval
$$(call gb_Output_error
,Library
$(1) must be registered in Repository.mk or RepositoryExternal.mk
))
66 $(if
$(gb_Package_PRESTAGEDIR
),\
67 $(if
$(wildcard $(gb_Package_PRESTAGEDIR
)/$(call gb_Library_get_instdir
,$(1))/$(call gb_Library_get_runtime_filename
,$(1))),\
68 $(call gb_Library__Library_impl_copy
,$(0),$(call gb_Library_get_instdir
,$(1))/$(call gb_Library_get_runtime_filename
,$(1))),\
69 $(call gb_Library__Library_impl
,$(1),$(call gb_Library_get_linktarget
,$(1)))\
71 $(call gb_Library__Library_impl
,$(1),$(call gb_Library_get_linktarget
,$(1)))\
76 define gb_Library__Library_impl_copy
77 $(call gb_Package_Package
,Library_Copy_
$(1),$(gb_Package_PRESTAGEDIR
))
78 $(call gb_Package_add_file
,Library_Copy_
$(1),$(2),$(2))
81 # Note: there may be targets in 3 different directories: the library itself,
82 # the exports target (and other misc. MSVC files) (always in
83 # $(WORKDIR)/LinkTarget), and the import library, which may be in SDK;
84 # the first 2 are always created by gb_LinkTarget_LinkTarget
85 # Also: the directory dependencies must be on the headers_target because
86 # MSVC will write a PDB file when compiling objects.
88 # call gb_Library__Library_impl,library,linktarget
89 define gb_Library__Library_impl
90 $(call gb_LinkTarget_LinkTarget
,$(2),Library_
$(1),$(call gb_Library_get_layer
,$(1)))
91 $(call gb_LinkTarget_set_targettype
,$(2),Library
)
92 $(call gb_LinkTarget_add_libs
,$(2),$(gb_STDLIBS
))
93 $(call gb_LinkTarget_add_defs
,$(2),\
96 $(call gb_Library_get_exports_target
,$(1)) : $(call gb_Library_get_target
,$(1))
97 $(call gb_LinkTarget_get_headers_target
,$(2)) : \
98 |
$(dir $(call gb_Library_get_ilib_target
,$(1))).
dir
99 $(call gb_Library_get_clean_target
,$(1)) : $(call gb_LinkTarget_get_clean_target
,$(2))
100 $(call gb_Library_get_clean_target
,$(1)) : AUXTARGETS
:=
101 $(call gb_Library_Library_platform
,$(1),$(2),$(call gb_Library_get_ilib_target
,$(1)))
103 $$(eval
$$(call gb_Module_register_target
,$(call gb_Library_get_exports_target
,$(1)),$(call gb_Library_get_clean_target
,$(1))))
105 $(call gb_Helper_make_userfriendly_targets
,$(1),Library
,$(call gb_Library_get_exports_target
,$(1)))
109 # we actually (ab)use ILIBTARGET here to store the unversioned symlink -
110 # it serves a similar purpose to an MSVC import library, as input for linker
111 # call gb_Library__add_soversion_link,library,linkname
112 define gb_Library__add_soversion_link
113 $(call gb_LinkTarget_set_ilibtarget
,$(call gb_Library_get_linktarget
,$(1)),$(2))
117 define gb_Library__set_soversion_script
118 $(call gb_LinkTarget_set_soversion_script
,$(call gb_Library_get_linktarget
,$(1)),$(2))
119 $(call gb_Library__add_soversion_link
,$(1),$(call gb_Library_get_versionlink_target
,$(1)))
123 # for libraries that maintain stable ABI: set SOVERSION and version script
124 # $(call gb_Library_set_soversion_script,versionscript)
125 define gb_Library_set_soversion_script
126 $(if
$(2),,$(call gb_Output_error
,gb_Library_set_soversion_script
: no script
))
127 $(if
$(3),$(call gb_Output_error
,gb_Library_set_soversion_script
: too many arguments
))
128 $(call gb_Library__set_soversion_script_platform
,$(1),$(2))
131 gb_Library__get_component_var
= $(call gb_Library__get_workdir_linktargetname
,$(1))<>COMPONENTFILE
132 gb_Library__get_component
= $($(call gb_Library__get_component_var
,$(1)))
134 # The dependency from workdir component target to outdir library should ensure
135 # that gb_CppunitTest_use_component can transitively depend on the library.
136 # But the component target also must be delivered; use the target
137 # gb_Library_get_exports_target for that purpose, since it is already
138 # the "final" target of the Library...
140 # call gb_Library_set_componentfile,library,componentfile,rdb
141 define gb_Library_set_componentfile
142 $(call gb_ComponentTarget_ComponentTarget
,$(2),\
143 $(call gb_Library__get_componentprefix
,$(gb_Library__get_name
)),\
144 $(call gb_Library_get_runtime_filename
,$(gb_Library__get_name
)),$(3))
145 $(call gb_Library_get_exports_target
,$(gb_Library__get_name
)) :| \
146 $(call gb_ComponentTarget_get_target
,$(2))
147 $(call gb_ComponentTarget_get_target
,$(2)) :| \
148 $(call gb_Library_get_target
,$(gb_Library__get_name
))
149 $(call gb_Library_get_clean_target
,$(gb_Library__get_name
)) : \
150 $(call gb_ComponentTarget_get_clean_target
,$(2))
152 $(if
$(call gb_Library__get_component
,$(1)),$(error Can
't have multiple component files per library))
153 $(eval $(call gb_Library__get_component_var,$(1)) = $(2))
157 # The implid is appended to the component file, separated by a dot.
159 # call gb_Library_add_componentimpl,library,implid
160 define gb_Library_add_componentimpl
161 $(if $(call gb_Library__get_component,$(1)),, \
162 $(error Set gb_Library_set_componentfile before using gb_Library_add_componentimpl))
163 $(call gb_ComponentTarget_add_componentimpl,$(call gb_Library__get_component,$(1)),$(2))
167 # call gb_Library_add_componentimpls,library,implids
168 define gb_Library_add_componentimpls
169 $(foreach comp,$(2),$(call gb_Library_add_componentimpl,$(1),$(comp)))
172 gb_Library__get_name = $(if $(filter $(1),$(gb_MERGEDLIBS)),merged,$(1))
174 gb_Library__get_componentprefix = \
175 $(call gb_Library__get_layer_componentprefix,$(call \
176 gb_Library_get_layer,$(1)))
178 gb_Library__get_layer_componentprefix = \
179 $(patsubst $(1):%,%,$(or \
180 $(filter $(1):%,$(gb_Library__COMPONENTPREFIXES)), \
181 $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)')))
183 # The \d gets turned into a dollar sign by a $(subst) call in
184 # gb_ComponentTarget__command in ComponentTarget.mk. As far as I
185 # understand, there is nothing magic to it, it is not some
186 # Make/awk/sed/whatever syntax.
188 gb_Library__COMPONENTPREFIXES := \
189 NONE:vnd.sun.star.expand:\dLO_BUILD_LIB_DIR/ \
190 OOO:vnd.sun.star.expand:\dLO_LIB_DIR/ \
191 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
193 SHLXTHDL:ERROR_NOT_ALLOWED \
196 gb_Library_get_runtime_filename = $(call gb_Library_get_filename,$(1))
197 gb_Library_get_runtime_filename_for_build = $(call gb_Library_get_filename_for_build,$(1))
199 # instead of setting nodep use gb_Library_set_plugin_for_nodep
201 # call gb_Library_set_plugin_for,library,loader,nodep
202 define gb_Library_set_plugin_for
203 ifneq (,$$(filter-out $(gb_Library_KNOWNPLUGINS),$(1)))
204 $$(eval $$(call gb_Output_info,currently known plugins are: $(sort $(gb_Library_KNOWNPLUGINS)),ALL))
205 $$(eval $$(call gb_Output_error,Unknown plugin(s) '$$(filter-out $(gb_Library_KNOWNPLUGINS
),$(1)))'. Plugins must be registered in Repository.mk or RepositoryExternal.mk))
208 $(call gb_Library_get_linktarget_target,$(2)) : PLUGINS += $(1)
209 $(eval $(call gb_LinkTarget__add_plugin,$(call gb_Library_get_linktarget,$(2)),$(1)))
210 $(eval $(call gb_LinkTarget__set_plugin_for,$(call gb_Library_get_linktarget,$(1)),$(2),$(3),Library_$(1)))
213 # call gb_Library_set_plugin_for_nodep,library,loader
214 gb_Library_set_plugin_for_nodep = $(call gb_Library_set_plugin_for,$(1),$(2),$(true))
216 # forward the call to the gb_LinkTarget implementation
217 # (note: because the function name is in $(1), the other args are shifted by 1)
218 define gb_Library__forward_to_Linktarget
219 $(call gb_LinkTarget_$(subst gb_Library_,,$(1)),$(call gb_Library_get_linktarget,$(2)),$(3),$(4),Library_$(2))
223 # copy pasta for forwarding: this could be (and was) done more elegantly, but
224 # these here can be found by both git grep and ctags
225 gb_Library_add_cobject = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
226 gb_Library_add_cobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
227 gb_Library_add_cxxobject = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
228 gb_Library_add_cxxobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
229 gb_Library_add_objcobject = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
230 gb_Library_add_objcobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
231 gb_Library_add_objcxxobject = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
232 gb_Library_add_objcxxobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
233 gb_Library_add_cxxclrobject = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
234 gb_Library_add_cxxclrobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
235 gb_Library_add_generated_cxxclrobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
236 gb_Library_add_asmobject = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
237 gb_Library_add_asmobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
238 gb_Library_add_exception_objects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
239 gb_Library_add_x64_generated_exception_objects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
240 gb_Library_add_generated_asmobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
241 gb_Library_add_generated_cobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
242 gb_Library_add_generated_exception_objects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
243 gb_Library_add_generated_objcobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
244 gb_Library_add_generated_objcxxobjects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
245 gb_Library_use_library_objects = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
246 gb_Library_add_grammar = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
247 gb_Library_add_grammars = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
248 gb_Library_add_scanner = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
249 gb_Library_add_scanners = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
250 gb_Library_add_cflags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
251 gb_Library_add_cxxflags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
252 gb_Library_add_objcxxflags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
253 gb_Library_add_objcflags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
254 gb_Library_add_cxxclrflags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
255 gb_Library_add_defs = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
256 gb_Library_set_include = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
257 gb_Library_add_ldflags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
258 gb_Library_set_ldflags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
259 gb_Library_set_x64 = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
260 gb_Library_set_x86 = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
261 gb_Library_add_libs = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
262 gb_Library_disable_standard_system_libs = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
263 gb_Library_use_system_darwin_frameworks = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
264 gb_Library_use_system_win32_libs = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
265 gb_Library_set_library_path_flags = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
266 gb_Library_use_api = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
267 gb_Library_use_sdk_api = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
268 gb_Library_use_udk_api = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
269 gb_Library_use_internal_api = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
270 gb_Library_use_internal_bootstrap_api = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
271 gb_Library_use_internal_comprehensive_api = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
272 gb_Library_use_libraries = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
273 gb_Library_use_static_libraries = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
274 gb_Library_use_external = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
275 gb_Library_use_externals = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
276 gb_Library_use_custom_headers = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
277 gb_Library_use_package = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
278 gb_Library_use_packages = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
279 gb_Library_use_unpacked = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
280 gb_Library_add_sdi_headers = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
281 gb_Library_set_precompiled_header = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
282 gb_Library_reuse_precompiled_header = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
283 gb_Library_use_common_precompiled_header = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
284 gb_Library_export_objects_list = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
285 gb_Library_add_nativeres = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
286 gb_Library_set_nativeres = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
287 gb_Library_set_visibility_default = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
288 gb_Library_set_warnings_not_errors = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
289 gb_Library_set_warnings_disabled = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
290 gb_Library_set_external_code = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
291 gb_Library_set_generated_cxx_suffix = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
292 gb_Library_use_clang = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
293 gb_Library_set_clang_precompiled_header = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
294 gb_Library_use_vclmain = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
295 gb_Library_set_is_ure_library_or_dependency = $(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3))
297 # vim: set noet sw=4: