xref: /aoo42x/main/solenv/gbuild/Library.mk (revision e53b81a8)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24
25# Library class
26
27# defined globally in TargetLocations.mk
28#  gb_Library_OUTDIRLOCATION := $(OUTDIR)/lib
29#  gb_Library_DLLDIR := $(WORKDIR)/LinkTarget/Library
30# defined by platform
31#  gb_Library_COMPONENTPREFIXES
32#  gb_Library_DEFS
33#  gb_Library_DLLFILENAMES
34#  gb_Library_FILENAMES
35#  gb_Library_Library_platform
36#  gb_Library_TARGETS
37
38gb_Library__get_linktargetname = Library/$(call gb_Library_get_filename,$(1))
39
40# EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
41.PHONY : $(WORKDIR)/Clean/OutDir/lib/%$(gb_Library_PLAINEXT)
42$(WORKDIR)/Clean/OutDir/lib/%$(gb_Library_PLAINEXT) :
43	$(call gb_Helper_abbreviate_dirs,\
44		rm -f $(OUTDIR)/lib/$*$(gb_Library_PLAINEXT) \
45			$(AUXTARGETS))
46
47# EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
48$(gb_Library_OUTDIRLOCATION)/%$(gb_Library_PLAINEXT) :
49	$(call gb_Helper_abbreviate_dirs,\
50		$(call gb_Deliver_deliver,$<,$@) \
51			$(foreach target,$(AUXTARGETS), && $(call gb_Deliver_deliver,$(dir $<)/$(notdir $(target)),$(target))))
52
53define gb_Library_Library
54ifeq (,$$(findstring $(1),$$(gb_Library_KNOWNLIBS)))
55$$(eval $$(call gb_Output_info,Currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
56$$(eval $$(call gb_Output_error,Library $(1) must be registered in Repository.mk))
57endif
58$(call gb_Library_get_target,$(1)) : AUXTARGETS :=
59$(call gb_Library__Library_impl,$(1),$(call gb_Library__get_linktargetname,$(1)))
60$(call gb_Library_add_default_nativeres,$(1),default)
61
62endef
63
64define gb_Library__Library_impl
65$(call gb_LinkTarget_LinkTarget,$(2))
66$(call gb_LinkTarget_set_targettype,$(2),Library)
67$(call gb_LinkTarget_add_defs,$(2),\
68	$(gb_Library_DEFS) \
69)
70$(call gb_Library_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2))
71$(call gb_Library_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
72$(call gb_Library_Library_platform,$(1),$(2),$(gb_Library_DLLDIR)/$(call gb_Library_get_dllname,$(1)))
73$$(eval $$(call gb_Module_register_target,$(call gb_Library_get_target,$(1)),$(call gb_Library_get_clean_target,$(1))))
74$(call gb_Deliver_add_deliverable,$(call gb_Library_get_target,$(1)),$(call gb_LinkTarget_get_target,$(2)),$(1))
75
76endef
77
78define gb_Library_set_componentfile
79$(call gb_ComponentTarget_ComponentTarget,$(2),$(call gb_Library__get_componentprefix,$(1)),$(call gb_Library_get_runtime_filename,$(1)))
80$(call gb_Library_get_target,$(1)) : $(call gb_ComponentTarget_get_outdir_target,$(2)) $(call gb_ComponentTarget_get_outdir_inbuild_target,$(2))
81$(call gb_Library_get_clean_target,$(1)) : $(call gb_ComponentTarget_get_clean_target,$(2))
82
83endef
84
85gb_Library__get_componentprefix = \
86    $(call gb_Library__get_layer_componentprefix,$(call \
87        gb_Library_get_layer,$(1)))
88
89gb_Library__get_layer_componentprefix = \
90    $(patsubst $(1):%,%,$(or \
91        $(filter $(1):%,$(gb_Library_COMPONENTPREFIXES)), \
92        $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)')))
93
94
95define gb_Library__forward_to_Linktarget
96gb_Library_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_Library__get_linktargetname,$$(1)),$$(2),$$(3),$$(4))
97
98endef
99
100gb_Library_get_runtime_filename = \
101 $(or $(call gb_Library_get_dllname,$(1)),$(call gb_Library_get_filename,$(1)))
102
103define gb_Library_is_udk_versioned
104$(or \
105	$(filter $(patsubst %:$(notdir $(1)),%,$(filter %:$(notdir $(1)),$(gb_Library_FILENAMES))),$(gb_Library_RTVERLIBS)),\
106	$(filter $(patsubst %:$(notdir $(1)),%,$(filter %:$(notdir $(1)),$(gb_Library_FILENAMES))),$(gb_Library_UNOVERLIBS)))
107endef
108
109$(eval $(foreach method,\
110	add_asmobject \
111	add_asmobjects \
112	add_cobject \
113	add_cobjects \
114	add_cxxobject \
115	add_cxxobjects \
116	add_objcobject \
117	add_objcobjects \
118	add_objcxxobject \
119	add_objcxxobjects \
120	add_exception_objects \
121	add_noexception_objects \
122	add_generated_cobject \
123	add_generated_cobjects \
124	add_generated_exception_objects \
125	set_yaccflags \
126	add_cflags \
127	set_cflags \
128	add_cxxflags \
129	set_cxxflags \
130	add_objcflags \
131	set_objcflags \
132	add_objcxxflags \
133	set_objcxxflags \
134	add_defs \
135	set_defs \
136	set_include \
137	add_ldflags \
138	set_ldflags \
139	add_libs \
140	set_library_path_flags \
141	add_api \
142	add_linked_libs \
143	add_linked_static_libs \
144	add_external_libs \
145	use_external \
146	use_externals \
147	add_package_headers \
148	add_sdi_headers \
149	add_precompiled_header \
150	set_versionmap \
151	set_private_api \
152	set_private_extract_of_public_api \
153,\
154	$(call gb_Library__forward_to_Linktarget,$(method))\
155))
156
157# vim: set noet sw=4 ts=4:
158