Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / Library.mk
blob8042f3357010396959ca08121903756d60eaf466
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 \
162 define gb_Library__forward_to_Linktarget
163 gb_Library_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_Library_get_linktarget,$$(1)),$$(2),$$(3),Library_$$(1))
165 endef
167 gb_Library_get_runtime_filename = $(call gb_Library_get_filename,$(1))
169 $(eval $(foreach method,\
170 add_cobject \
171 add_cobjects \
172 add_cxxobject \
173 add_cxxobjects \
174 add_objcobject \
175 add_objcobjects \
176 add_objcxxobject \
177 add_objcxxobjects \
178 add_asmobject \
179 add_asmobjects \
180 add_exception_objects \
181 add_x64_generated_exception_objects \
182 add_generated_cobjects \
183 add_generated_cxxobjects \
184 add_generated_exception_objects \
185 use_library_objects \
186 add_grammar \
187 add_grammars \
188 add_scanner \
189 add_scanners \
190 add_cflags \
191 add_cxxflags \
192 add_objcxxflags \
193 add_objcflags \
194 add_defs \
195 set_include \
196 add_ldflags \
197 set_ldflags \
198 set_x64 \
199 add_libs \
200 disable_standard_system_libs \
201 use_system_darwin_frameworks \
202 use_system_win32_libs \
203 set_library_path_flags \
204 use_api \
205 use_sdk_api \
206 use_udk_api \
207 use_internal_api \
208 use_internal_bootstrap_api \
209 use_internal_comprehensive_api \
210 use_libraries \
211 use_static_libraries \
212 use_external \
213 use_externals \
214 use_custom_headers \
215 use_package \
216 use_packages \
217 use_unpacked \
218 use_restarget \
219 add_sdi_headers \
220 set_precompiled_header \
221 export_objects_list \
222 add_nativeres \
223 set_nativeres \
224 set_visibility_default \
225 set_warnings_not_errors \
226 set_external_code \
227 set_generated_cxx_suffix \
229 $(call gb_Library__forward_to_Linktarget,$(method))\
232 # vim: set noet sw=4: