Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / solenv / gbuild / Library.mk
blobbb799114901c5d514c59ab2bb68e570564c1a9f1
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 #
6 # Copyright 2000, 2011 Oracle and/or its affiliates.
8 # OpenOffice.org - a multi-platform office productivity suite
10 # This file is part of OpenOffice.org.
12 # OpenOffice.org is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License version 3
14 # only, as published by the Free Software Foundation.
16 # OpenOffice.org is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU Lesser General Public License version 3 for more details
20 # (a copy is included in the LICENSE file that accompanied this code).
22 # You should have received a copy of the GNU Lesser General Public License
23 # version 3 along with OpenOffice.org. If not, see
24 # <http://www.openoffice.org/license.html>
25 # for a copy of the LGPLv3 License.
27 #*************************************************************************
30 # Library class
32 # defined globally in TargetLocations.mk
33 # gb_Library_OUTDIRLOCATION := $(OUTDIR)/lib
34 # gb_Library_DLLDIR := $(WORKDIR)/LinkTarget/Library
35 # defined by platform
36 # gb_Library_DEFS
37 # gb_Library_DLLFILENAMES
38 # gb_Library_FILENAMES
39 # gb_Library_Library_platform
41 # doesn't do anything, just used for hooking up component target
42 .PHONY: $(call gb_Library__get_final_target,%)
44 # EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
45 .PHONY : $(WORKDIR)/Clean/OutDir/lib/%$(gb_Library_PLAINEXT)
46 $(WORKDIR)/Clean/OutDir/lib/%$(gb_Library_PLAINEXT) :
47 $(call gb_Helper_abbreviate_dirs,\
48 rm -f $(OUTDIR)/lib/$*$(gb_Library_PLAINEXT) \
49 $(AUXTARGETS))
51 define gb_Library_Library
52 ifeq (,$$(findstring $(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))
55 endif
56 $(call gb_Library_get_target,$(1)) : SOVERSION :=
57 $(call gb_Library__Library_impl,$(1),$(call gb_Library_get_linktargetname,$(1)))
59 endef
61 define gb_Library__Library_impl
62 $(call gb_LinkTarget_LinkTarget,$(2),Library_$(1))
63 $(call gb_LinkTarget_set_targettype,$(2),Library)
64 $(call gb_LinkTarget_add_libs,$(2),$(gb_STDLIBS))
65 $(call gb_LinkTarget_add_defs,$(2),\
66 $(gb_Library_DEFS) \
68 $(call gb_Library__get_final_target,$(1)) : $(call gb_Library_get_target,$(1))
69 $(call gb_Library_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2)) \
70 | $(dir $(call gb_Library_get_target,$(1))).dir
71 $(call gb_Library_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
72 $(call gb_Library_get_clean_target,$(1)) : AUXTARGETS :=
73 $(call gb_Library_Library_platform,$(1),$(2),$(gb_Library_DLLDIR)/$(call gb_Library_get_dllname,$(1)))
74 $$(eval $$(call gb_Module_register_target,$(call gb_Library__get_final_target,$(1)),$(call gb_Library_get_clean_target,$(1))))
75 $(call gb_Deliver_add_deliverable,$(call gb_Library_get_target,$(1)),$(call gb_LinkTarget_get_target,$(2)),$(1))
77 endef
79 # Custom definition that does not simply forward to LinkTarget,
80 # because there are cases where the auxtargets are not delivered to solver...
81 # The auxtarget is delivered via the rule in Package.mk.
82 # gb_Library_add_auxtarget library outdirauxtarget
83 define gb_Library_add_auxtarget
84 $(call gb_LinkTarget_add_auxtarget,$(call gb_Library_get_linktargetname,$(1)),$(dir $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktargetname,$(1))))/$(notdir $(2)))
85 $(call gb_Library_get_target,$(1)) : $(2)
86 $(2) : $(dir $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktargetname,$(1))))/$(notdir $(2))
87 $(call gb_Library_get_clean_target,$(1)) : AUXTARGETS += $(2)
89 endef
91 define gb_Library_add_auxtargets
92 $(foreach aux,$(2),$(call gb_Library_add_auxtarget,$(1),$(aux)))
94 endef
96 define gb_Library__set_soversion_script
97 $(call gb_LinkTarget_set_soversion_script,$(call gb_Library_get_linktargetname,$(1)),$(2),$(3))
98 $(call gb_Library_get_target,$(1)) : SOVERSION := $(2)
99 $(call gb_Library_add_auxtarget,$(1),$(call gb_Library_get_target,$(1)).$(2))
101 endef
103 # for libraries that maintain stable ABI: set SOVERSION and version script
104 # $(call gb_Library_set_soversion_script,soversion,versionscript)
105 define gb_Library_set_soversion_script
106 $(if $(2),,$(call gb_Output_error,gb_Library_set_soversion_script: no version))
107 $(if $(3),,$(call gb_Output_error,gb_Library_set_soversion_script: no script))
108 $(call gb_Library__set_soversion_script_platform,$(1),$(2),$(3))
109 endef
111 # The dependency from workdir component target to outdir library should ensure
112 # that gb_CppunitTest_use_component can transitively depend on the library.
113 # But the component target also must be delivered, so a new phony target
114 # gb_Library__get_final_target has been invented for that purpose...
115 define gb_Library_set_componentfile
116 $(call gb_Library_get_target,$(gb_Library__get_name)) : \
117 COMPONENT := $$(if $$(and $$(COMPONENT),$(filter-out $(gb_MERGEDLIBS),$(1))),\
118 $$(call gb_Output_error,$(1) already has a component file $$(COMPONENT)))$(2)
119 $(call gb_ComponentTarget_ComponentTarget,$(2),\
120 $(call gb_Library__get_componentprefix,$(gb_Library__get_name)),\
121 $(call gb_Library_get_runtime_filename,$(gb_Library__get_name)))
122 $(call gb_Library__get_final_target,$(gb_Library__get_name)) : \
123 $(call gb_ComponentTarget_get_outdir_target,$(2))
124 $(call gb_ComponentTarget_get_target,$(2)) :| \
125 $(call gb_Library_get_target,$(gb_Library__get_name))
126 $(call gb_Library_get_clean_target,$(gb_Library__get_name)) : \
127 $(call gb_ComponentTarget_get_clean_target,$(2))
128 endef
130 gb_Library__get_name = $(if $(filter $(1),$(gb_MERGEDLIBS)),merged,$(1))
132 gb_Library__get_componentprefix = \
133 $(call gb_Library__get_layer_componentprefix,$(call \
134 gb_Library_get_layer,$(1)))
136 gb_Library__get_layer_componentprefix = \
137 $(patsubst $(1):%,%,$(or \
138 $(filter $(1):%,$(gb_Library__COMPONENTPREFIXES)), \
139 $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)')))
141 # The \d gets turned into a dollar sign by a $(subst) call in
142 # gb_ComponentTarget__command in ComponentTarget.mk. As far as I
143 # understand, there is nothing magic to it, it is not some
144 # Make/awk/sed/whatever syntax.
146 gb_Library__COMPONENTPREFIXES := \
147 NONE:vnd.sun.star.expand:\dLO_LIB_DIR/ \
148 OOO:vnd.sun.star.expand:\dLO_LIB_DIR/ \
149 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
150 OXT:./ \
152 define gb_Library__forward_to_Linktarget
153 gb_Library_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_Library_get_linktargetname,$$(1)),$$(2),$$(3),Library_$$(1))
155 endef
157 gb_Library_get_runtime_filename = \
158 $(or $(call gb_Library_get_dllname,$(1)),$(call gb_Library_get_filename,$(1)))
160 $(eval $(foreach method,\
161 add_cobject \
162 add_cobjects \
163 add_cxxobject \
164 add_cxxobjects \
165 add_objcobject \
166 add_objcobjects \
167 add_objcxxobject \
168 add_objcxxobjects \
169 add_asmobject \
170 add_asmobjects \
171 add_exception_objects \
172 add_x64_generated_exception_objects \
173 add_noexception_objects \
174 add_generated_cobjects \
175 add_generated_cxxobjects \
176 add_generated_exception_objects \
177 add_library_objects \
178 use_library_objects \
179 add_grammar \
180 add_grammars \
181 add_scanner \
182 add_scanners \
183 add_cflags \
184 set_cflags \
185 add_cxxflags \
186 set_cxxflags \
187 add_objcxxflags \
188 add_objcflags \
189 set_objcflags \
190 set_objcxxflags \
191 add_defs \
192 set_defs \
193 set_include \
194 add_ldflags \
195 set_ldflags \
196 set_x64 \
197 add_libs \
198 disable_standard_system_libs \
199 use_system_darwin_frameworks \
200 use_system_win32_libs \
201 set_library_path_flags \
202 add_api \
203 use_api \
204 use_sdk_api \
205 use_udk_api \
206 add_internal_api \
207 use_internal_api \
208 add_internal_bootstrap_api \
209 use_internal_bootstrap_api \
210 add_internal_comprehensive_api \
211 use_internal_comprehensive_api \
212 add_linked_libs \
213 use_libraries \
214 add_linked_static_libs \
215 use_static_libraries \
216 use_external \
217 use_externals \
218 add_custom_headers \
219 use_custom_headers \
220 add_external_headers \
221 use_package \
222 use_packages \
223 use_unpacked \
224 add_package_headers \
225 add_sdi_headers \
226 export_objects_list \
227 add_nativeres \
228 set_visibility_default \
229 set_warnings_not_errors \
230 set_generated_cxx_suffix \
232 $(call gb_Library__forward_to_Linktarget,$(method))\
235 # vim: set noet sw=4: