xref: /aoo41x/main/solenv/gbuild/StaticLibrary.mk (revision 7871dc3e)
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# Static Library class
26
27# defined globally in gbuild.mk
28#  gb_StaticLibrary_OUTDIRLOCATION := $(OUTDIR)/lib
29# defined by platform
30#  gb_StaticLibrary_DEFS
31#  gb_StaticLibrary_FILENAMES
32#  gb_StaticLibrary_TARGETS
33
34gb_StaticLibrary__get_linktargetname = StaticLibrary/$(call gb_StaticLibrary_get_filename,$(1))
35
36# EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
37.PHONY : $(WORKDIR)/Clean/OutDir/lib/%$(gb_StaticLibrary_PLAINEXT)
38$(WORKDIR)/Clean/OutDir/lib/%$(gb_StaticLibrary_PLAINEXT) :
39	$(call gb_Helper_abbreviate_dirs,\
40		rm -f $(OUTDIR)/lib/$*$(gb_StaticLibrary_PLAINEXT) \
41			$(AUXTARGETS))
42
43# EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
44$(gb_StaticLibrary_OUTDIRLOCATION)/%$(gb_StaticLibrary_PLAINEXT) :
45	$(call gb_Helper_abbreviate_dirs,\
46		$(call gb_Deliver_deliver,$<,$@) \
47			$(foreach target,$(AUXTARGETS), && $(call gb_Deliver_deliver,$(dir $<)/$(notdir $(target)),$(target))))
48
49define gb_StaticLibrary_StaticLibrary
50ifeq (,$$(findstring $(1),$$(gb_StaticLibrary_KNOWNLIBS)))
51$$(eval $$(call gb_Output_info,Currently known static libraries are: $(sort $(gb_StaticLibrary_KNOWNLIBS)),ALL))
52$$(eval $$(call gb_Output_error,Static library $(1) must be registered in Repository.mk))
53endif
54$(call gb_StaticLibrary_get_target,$(1)) : AUXTARGETS :=
55$(call gb_StaticLibrary__StaticLibrary_impl,$(1),$(call gb_StaticLibrary__get_linktargetname,$(1)))
56
57endef
58
59define gb_StaticLibrary__StaticLibrary_impl
60$(call gb_LinkTarget_LinkTarget,$(2))
61$(call gb_LinkTarget_set_targettype,$(2),StaticLibrary)
62$(call gb_LinkTarget_set_defs,$(2),\
63	$$(DEFS) \
64	$(gb_StaticLibrary_DEFS) \
65)
66$(call gb_StaticLibrary_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2))
67$(call gb_StaticLibrary_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
68$(call gb_StaticLibrary_StaticLibrary_platform,$(1),$(2))
69$$(eval $$(call gb_Module_register_target,$(call gb_StaticLibrary_get_target,$(1)),$(call gb_StaticLibrary_get_clean_target,$(1))))
70$(call gb_Deliver_add_deliverable,$(call gb_StaticLibrary_get_target,$(1)),$(call gb_LinkTarget_get_target,$(2)))
71
72endef
73
74define gb_StaticLibrary_forward_to_Linktarget
75gb_StaticLibrary_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_StaticLibrary__get_linktargetname,$$(1)),$$(2),$$(3))
76
77endef
78
79$(eval $(foreach method,\
80	add_cobject \
81	add_cobjects \
82	add_cxxobject \
83	add_cxxobjects \
84	add_objcxxobject \
85	add_objcxxobjects \
86	add_exception_objects \
87	add_noexception_objects \
88	add_generated_exception_objects \
89	set_cflags \
90	set_cxxflags \
91	set_objcxxflags \
92	set_defs \
93	set_include \
94	set_ldflags \
95	set_library_path_flags \
96	add_linked_libs \
97	add_linked_static_libs \
98	add_package_headers \
99	add_sdi_headers \
100	add_precompiled_header \
101,\
102	$(call gb_StaticLibrary_forward_to_Linktarget,$(method))\
103))
104
105# vim: set noet sw=4 ts=4:
106