xref: /trunk/main/solenv/gbuild/Library.mk (revision 8f71f2da3780fff02b58fe2fe2c8a220939be93f)
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))
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_cobject \
111    add_cobjects \
112    add_cxxobject \
113    add_cxxobjects \
114    add_objcxxobject \
115    add_objcxxobjects \
116    add_exception_objects \
117    add_noexception_objects \
118    add_generated_exception_objects \
119    set_yaccflags \
120    add_cflags \
121    set_cflags \
122    add_cxxflags \
123    set_cxxflags \
124    add_objcxxflags \
125    set_objcxxflags \
126    add_defs \
127    set_defs \
128    set_include \
129    add_ldflags \
130    set_ldflags \
131    add_libs \
132    set_library_path_flags \
133    add_api \
134    add_linked_libs \
135    add_linked_static_libs \
136    add_external_libs \
137    use_external \
138    use_externals \
139    add_package_headers \
140    add_sdi_headers \
141    add_precompiled_header \
142    set_versionmap \
143,\
144    $(call gb_Library__forward_to_Linktarget,$(method))\
145))
146
147# vim: set noet sw=4 ts=4:
148