xref: /aoo41x/main/solenv/gbuild/Library.mk (revision cdf0e10c)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2011 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28
29# Library class
30
31# defined globally in TargetLocations.mk
32#  gb_Library_OUTDIRLOCATION := $(OUTDIR)/lib
33#  gb_Library_DLLDIR := $(WORKDIR)/LinkTarget/Library
34# defined by platform
35#  gb_Library_COMPONENTPREFIXES
36#  gb_Library_DEFS
37#  gb_Library_DLLFILENAMES
38#  gb_Library_FILENAMES
39#  gb_Library_Library_platform
40#  gb_Library_TARGETS
41
42gb_Library__get_linktargetname = Library/$(call gb_Library_get_filename,$(1))
43
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))
50
51# EVIL: gb_StaticLibrary and gb_Library need the same deliver rule because they are indistinguishable on windows
52$(gb_Library_OUTDIRLOCATION)/%$(gb_Library_PLAINEXT) :
53	$(call gb_Helper_abbreviate_dirs,\
54		$(call gb_Deliver_deliver,$<,$@) \
55			$(foreach target,$(AUXTARGETS), && $(call gb_Deliver_deliver,$(dir $<)/$(notdir $(target)),$(target))))
56
57define gb_Library_Library
58ifeq (,$$(findstring $(1),$$(gb_Library_KNOWNLIBS)))
59$$(eval $$(call gb_Output_info,Currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
60$$(eval $$(call gb_Output_error,Library $(1) must be registered in Repository.mk))
61endif
62$(call gb_Library_get_target,$(1)) : AUXTARGETS :=
63$(call gb_Library__Library_impl,$(1),$(call gb_Library__get_linktargetname,$(1)))
64$(call gb_Library_add_default_nativeres,$(1),default)
65
66endef
67
68define gb_Library__Library_impl
69$(call gb_LinkTarget_LinkTarget,$(2))
70$(call gb_LinkTarget_set_targettype,$(2),Library)
71$(call gb_LinkTarget_set_defs,$(2),\
72	$$(DEFS) \
73	$(gb_Library_DEFS) \
74)
75$(call gb_Library_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2))
76$(call gb_Library_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
77$(call gb_Library_Library_platform,$(1),$(2),$(gb_Library_DLLDIR)/$(call gb_Library_get_dllname,$(1)))
78$$(eval $$(call gb_Module_register_target,$(call gb_Library_get_target,$(1)),$(call gb_Library_get_clean_target,$(1))))
79$(call gb_Deliver_add_deliverable,$(call gb_Library_get_target,$(1)),$(call gb_LinkTarget_get_target,$(2)))
80
81endef
82
83define gb_Library_set_componentfile
84$(call gb_ComponentTarget_ComponentTarget,$(2),$(call gb_Library__get_componentprefix,$(1)),$(call gb_Library_get_runtime_filename,$(1)))
85$(call gb_Library_get_target,$(1)) : $(call gb_ComponentTarget_get_outdir_target,$(2))
86$(call gb_Library_get_clean_target,$(1)) : $(call gb_ComponentTarget_get_clean_target,$(2))
87
88endef
89
90gb_Library__get_componentprefix = \
91    $(call gb_Library__get_layer_componentprefix,$(call \
92        gb_Library_get_layer,$(1)))
93
94gb_Library__get_layer_componentprefix = \
95    $(patsubst $(1):%,%,$(or \
96        $(filter $(1):%,$(gb_Library_COMPONENTPREFIXES)), \
97        $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)')))
98
99
100define gb_Library__forward_to_Linktarget
101gb_Library_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_Library__get_linktargetname,$$(1)),$$(2),$$(3))
102
103endef
104
105gb_Library_get_runtime_filename = \
106 $(or $(call gb_Library_get_dllname,$(1)),$(call gb_Library_get_filename,$(1)))
107
108$(eval $(foreach method,\
109	add_cobject \
110	add_cobjects \
111	add_cxxobject \
112	add_cxxobjects \
113	add_objcxxobject \
114	add_objcxxobjects \
115	add_exception_objects \
116	add_noexception_objects \
117	add_generated_exception_objects \
118	set_cflags \
119	set_cxxflags \
120	set_objcxxflags \
121	set_defs \
122	set_include \
123	set_ldflags \
124	set_library_path_flags \
125	add_linked_libs \
126	add_linked_static_libs \
127	add_package_headers \
128	add_sdi_headers \
129	add_precompiled_header \
130,\
131	$(call gb_Library__forward_to_Linktarget,$(method))\
132))
133
134# vim: set noet sw=4 ts=4:
135