Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / solenv / gbuild / Library.mk
blob5166dbe6c390c9f16b9543fd4b103d277069d805
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 .
21 # Library class
23 # defined globally in TargetLocations.mk
24 # gb_Library_DLLDIR := $(WORKDIR)/LinkTarget/Library
25 # defined by platform
26 # gb_Library_DEFS
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 # EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
39 .PHONY : $(WORKDIR)/Clean/Library/%
40 $(WORKDIR)/Clean/Library/% :
41 $(call gb_Helper_abbreviate_dirs,\
42 rm -f $(call gb_Library_get_exports_target,$*) \
43 $(AUXTARGETS))
45 gb_Library__get_dir_for_layer = $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Library_LAYER_DIRS)))
46 gb_Library_get_instdir = $(call gb_Library__get_dir_for_layer,$(call gb_Library_get_layer,$(1)))
48 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)))
50 define gb_Library_Library
51 $(call gb_Postprocess_register_target,AllLibraries,Library,$(1))
52 ifeq (,$$(filter $(1),$$(gb_Library_KNOWNLIBS)))
53 $$(eval $$(call gb_Output_info,Currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
54 $$(eval $$(call gb_Output_error,Library $(1) must be registered in Repository.mk or RepositoryExternal.mk))
55 endif
57 $(if $(gb_Package_PRESTAGEDIR),\
58 $(if $(wildcard $(gb_Package_PRESTAGEDIR)/$(call gb_Library_get_instdir,$(1))/$(call gb_Library_get_runtime_filename,$(1))),\
59 $(call gb_Library__Library_impl_copy,$(0),$(call gb_Library_get_instdir,$(1))/$(call gb_Library_get_runtime_filename,$(1))),\
60 $(call gb_Library__Library_impl,$(1),$(call gb_Library_get_linktarget,$(1)))\
62 $(call gb_Library__Library_impl,$(1),$(call gb_Library_get_linktarget,$(1)))\
65 endef
67 define gb_Library__Library_impl_copy
68 $(call gb_Package_Package,Library_Copy_$(1),$(gb_Package_PRESTAGEDIR))
69 $(call gb_Package_add_file,Library_Copy_$(1),$(2),$(2))
70 endef
72 # Note: there may be targets in 3 different directories: the library itself,
73 # the exports target (and other misc. MSVC files) (always in
74 # $(WORKDIR)/LinkTarget), and the import library, which may be in SDK;
75 # the first 2 are always created by gb_LinkTarget_LinkTarget
76 # Also: the directory dependencies must be on the headers_target because
77 # MSVC will write a PDB file when compiling objects.
79 # call gb_Library__Library_impl,library,linktarget
80 define gb_Library__Library_impl
81 $(call gb_LinkTarget_LinkTarget,$(2),Library_$(1),$(call gb_Library_get_layer,$(1)))
82 $(call gb_LinkTarget_set_targettype,$(2),Library)
83 $(call gb_LinkTarget_add_libs,$(2),$(gb_STDLIBS))
84 $(call gb_LinkTarget_add_defs,$(2),\
85 $(gb_Library_DEFS) \
87 $(call gb_Library_get_exports_target,$(1)) : $(call gb_Library_get_target,$(1))
88 $(call gb_LinkTarget_get_headers_target,$(2)) : \
89 | $(dir $(call gb_Library_get_ilib_target,$(1))).dir
90 $(call gb_Library_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
91 $(call gb_Library_get_clean_target,$(1)) : AUXTARGETS :=
92 $(call gb_Library_Library_platform,$(1),$(2),$(call gb_Library_get_ilib_target,$(1)))
94 $$(eval $$(call gb_Module_register_target,$(call gb_Library_get_exports_target,$(1)),$(call gb_Library_get_clean_target,$(1))))
96 $(call gb_Helper_make_userfriendly_targets,$(1),Library,$(call gb_Library_get_exports_target,$(1)))
98 endef
100 # we actually (ab)use ILIBTARGET here to store the unversioned symlink -
101 # it serves a similar purpose to an MSVC import library, as input for linker
102 # call gb_Library__add_soversion_link,library,linkname
103 define gb_Library__add_soversion_link
104 $(call gb_LinkTarget_set_ilibtarget,$(call gb_Library_get_linktarget,$(1)),$(2))
106 endef
108 define gb_Library__set_soversion_script
109 $(call gb_LinkTarget_set_soversion_script,$(call gb_Library_get_linktarget,$(1)),$(2))
110 $(call gb_Library__add_soversion_link,$(1),$(call gb_Library_get_versionlink_target,$(1)))
112 endef
114 # for libraries that maintain stable ABI: set SOVERSION and version script
115 # $(call gb_Library_set_soversion_script,versionscript)
116 define gb_Library_set_soversion_script
117 $(if $(2),,$(call gb_Output_error,gb_Library_set_soversion_script: no script))
118 $(if $(3),$(call gb_Output_error,gb_Library_set_soversion_script: too many arguments))
119 $(call gb_Library__set_soversion_script_platform,$(1),$(2))
120 endef
122 # The dependency from workdir component target to outdir library should ensure
123 # that gb_CppunitTest_use_component can transitively depend on the library.
124 # But the component target also must be delivered; use the target
125 # gb_Library_get_exports_target for that purpose, since it is already
126 # the "final" target of the Library...
127 define gb_Library_set_componentfile
128 $(call gb_ComponentTarget_ComponentTarget,$(2),\
129 $(call gb_Library__get_componentprefix,$(gb_Library__get_name)),\
130 $(call gb_Library_get_runtime_filename,$(gb_Library__get_name)))
131 $(call gb_Library_get_exports_target,$(gb_Library__get_name)) :| \
132 $(call gb_ComponentTarget_get_target,$(2))
133 $(call gb_ComponentTarget_get_target,$(2)) :| \
134 $(call gb_Library_get_target,$(gb_Library__get_name))
135 $(call gb_Library_get_clean_target,$(gb_Library__get_name)) : \
136 $(call gb_ComponentTarget_get_clean_target,$(2))
137 endef
139 gb_Library__get_name = $(if $(filter $(1),$(gb_MERGEDLIBS)),merged,$(1))
141 gb_Library__get_componentprefix = \
142 $(call gb_Library__get_layer_componentprefix,$(call \
143 gb_Library_get_layer,$(1)))
145 gb_Library__get_layer_componentprefix = \
146 $(patsubst $(1):%,%,$(or \
147 $(filter $(1):%,$(gb_Library__COMPONENTPREFIXES)), \
148 $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)')))
150 # The \d gets turned into a dollar sign by a $(subst) call in
151 # gb_ComponentTarget__command in ComponentTarget.mk. As far as I
152 # understand, there is nothing magic to it, it is not some
153 # Make/awk/sed/whatever syntax.
155 gb_Library__COMPONENTPREFIXES := \
156 NONE:vnd.sun.star.expand:\dLO_BUILD_LIB_DIR/ \
157 OOO:vnd.sun.star.expand:\dLO_LIB_DIR/ \
158 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
159 OXT:./ \
160 SHLXTHDL:ERROR_NOT_ALLOWED \
163 gb_Library_get_runtime_filename = $(call gb_Library_get_filename,$(1))
165 # forward the call to the gb_LinkTarget implementation
166 # (note: because the function name is in $(1), the other args are shifted by 1)
167 define gb_Library__forward_to_Linktarget
168 $(call gb_LinkTarget_$(1),$(call gb_Library_get_linktarget,$(2)),$(3),$(4),Library_$(2))
170 endef
172 # copy pasta for forwarding: this could be (and was) done more elegantly, but
173 # these here can be found by both git grep and ctags
174 gb_Library_add_cobject = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
175 gb_Library_add_cobject = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
176 gb_Library_add_cobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
177 gb_Library_add_cxxobject = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
178 gb_Library_add_cxxobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
179 gb_Library_add_objcobject = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
180 gb_Library_add_objcobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
181 gb_Library_add_objcxxobject = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
182 gb_Library_add_objcxxobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
183 gb_Library_add_cxxclrobject = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
184 gb_Library_add_cxxclrobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
185 gb_Library_add_generated_cxxclrobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
186 gb_Library_add_asmobject = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
187 gb_Library_add_asmobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
188 gb_Library_add_exception_objects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
189 gb_Library_add_x64_generated_exception_objects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
190 gb_Library_add_generated_cobjects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
191 gb_Library_add_generated_exception_objects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
192 gb_Library_use_library_objects = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
193 gb_Library_add_grammar = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
194 gb_Library_add_grammars = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
195 gb_Library_add_scanner = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
196 gb_Library_add_scanners = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
197 gb_Library_add_cflags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
198 gb_Library_add_cxxflags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
199 gb_Library_add_objcxxflags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
200 gb_Library_add_objcflags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
201 gb_Library_add_cxxclrflags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
202 gb_Library_add_defs = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
203 gb_Library_set_include = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
204 gb_Library_add_ldflags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
205 gb_Library_set_ldflags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
206 gb_Library_set_x64 = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
207 gb_Library_add_libs = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
208 gb_Library_disable_standard_system_libs = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
209 gb_Library_use_system_darwin_frameworks = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
210 gb_Library_use_system_win32_libs = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
211 gb_Library_set_library_path_flags = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
212 gb_Library_use_api = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
213 gb_Library_use_sdk_api = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
214 gb_Library_use_udk_api = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
215 gb_Library_use_internal_api = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
216 gb_Library_use_internal_bootstrap_api = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
217 gb_Library_use_internal_comprehensive_api = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
218 gb_Library_use_libraries = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
219 gb_Library_use_static_libraries = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
220 gb_Library_use_external = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
221 gb_Library_use_externals = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
222 gb_Library_use_custom_headers = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
223 gb_Library_use_package = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
224 gb_Library_use_packages = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
225 gb_Library_use_unpacked = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
226 gb_Library_add_sdi_headers = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
227 gb_Library_set_precompiled_header = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
228 gb_Library_export_objects_list = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
229 gb_Library_add_nativeres = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
230 gb_Library_set_nativeres = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
231 gb_Library_set_visibility_default = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
232 gb_Library_set_warnings_not_errors = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
233 gb_Library_set_external_code = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
234 gb_Library_set_generated_cxx_suffix = $(call gb_Library__forward_to_Linktarget,$(subst gb_Library_,,$(0)),$(1),$(2),$(3))
236 # vim: set noet sw=4: