xref: /aoo41x/main/solenv/gbuild/LinkTarget.mk (revision 82c216fc)
17871dc3eSAndrew Rist#**************************************************************
27871dc3eSAndrew Rist#
37871dc3eSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
47871dc3eSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
57871dc3eSAndrew Rist#  distributed with this work for additional information
67871dc3eSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
77871dc3eSAndrew Rist#  to you under the Apache License, Version 2.0 (the
87871dc3eSAndrew Rist#  "License"); you may not use this file except in compliance
97871dc3eSAndrew Rist#  with the License.  You may obtain a copy of the License at
107871dc3eSAndrew Rist#
117871dc3eSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
127871dc3eSAndrew Rist#
137871dc3eSAndrew Rist#  Unless required by applicable law or agreed to in writing,
147871dc3eSAndrew Rist#  software distributed under the License is distributed on an
157871dc3eSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
167871dc3eSAndrew Rist#  KIND, either express or implied.  See the License for the
177871dc3eSAndrew Rist#  specific language governing permissions and limitations
187871dc3eSAndrew Rist#  under the License.
197871dc3eSAndrew Rist#
207871dc3eSAndrew Rist#**************************************************************
217871dc3eSAndrew Rist
227871dc3eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir
25cdf0e10cSrcweir# CObject class
26cdf0e10cSrcweir
27cdf0e10cSrcweirgb_CObject_REPOS := $(gb_REPOS)
28cdf0e10cSrcweir
29cdf0e10cSrcweirgb_CObject_get_source = $(1)/$(2).c
30cdf0e10cSrcweir# defined by platform
31cdf0e10cSrcweir#  gb_CObject__command
32cdf0e10cSrcweir
33cdf0e10cSrcweir# this rule generates an "always rebuild" dep file, to have something to include.
34cdf0e10cSrcweir# the dep file will be overridden on the fly, when the object is compiled
35cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
36cdf0e10cSrcweirdefine gb_CObject__command_dep
37cdf0e10cSrcweirmkdir -p $(dir $(1)) && \
38cdf0e10cSrcweir	echo '$(call gb_CObject_get_target,$(2)) : $$(gb_Helper_PHONY)' > $(1)
39cdf0e10cSrcweir
40cdf0e10cSrcweirendef
41cdf0e10cSrcweirelse
42cdf0e10cSrcweirgb_CObject__command_dep =
43cdf0e10cSrcweirendif
44cdf0e10cSrcweir
45cdf0e10cSrcweirdefine gb_CObject__rules
46cdf0e10cSrcweir$$(call gb_CObject_get_target,%) : $$(call gb_CObject_get_source,$(1),%)
47cdf0e10cSrcweir	$$(call gb_CObject__command,$$@,$$*,$$<,$$(DEFS),$$(CFLAGS),$$(INCLUDE))
48cdf0e10cSrcweir
49cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
50cdf0e10cSrcweir$$(call gb_CObject_get_dep_target,%) : $$(call gb_CObject_get_source,$(1),%)
51cdf0e10cSrcweir	$$(call gb_CObject__command_dep,$$@,$$*,$$<,$$(DEFS),$$(CFLAGS),$$(INCLUDE))
52cdf0e10cSrcweirendif
53cdf0e10cSrcweir
54cdf0e10cSrcweirendef
55cdf0e10cSrcweir
56cdf0e10cSrcweir$(foreach repo,$(gb_CObject_REPOS),$(eval $(call gb_CObject__rules,$(repo))))
57cdf0e10cSrcweir
58cdf0e10cSrcweir$(call gb_CObject_get_dep_target,%) :
59cdf0e10cSrcweir	$(eval $(call gb_Output_error,Unable to find plain C file $(call gb_CObject_get_source,,$*) in the repositories: $(gb_CObject_REPOS)))
60cdf0e10cSrcweir
61cdf0e10cSrcweirgb_CObject_CObject =
62cdf0e10cSrcweir
63cdf0e10cSrcweir
64cdf0e10cSrcweir# CxxObject class
65cdf0e10cSrcweir
66cdf0e10cSrcweirgb_CxxObject_REPOS := $(gb_REPOS)
67cdf0e10cSrcweir
68cdf0e10cSrcweirgb_CxxObject_get_source = $(1)/$(2).cxx
69cdf0e10cSrcweir# defined by platform
70cdf0e10cSrcweir#  gb_CxxObject__command
71cdf0e10cSrcweir
72cdf0e10cSrcweir# This rule generates an "always rebuild" dep file, to have something to
73cdf0e10cSrcweir# include. The dep file will be overridden on the fly, when the object is
74cdf0e10cSrcweir# compiled.
75cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
76cdf0e10cSrcweirdefine gb_CxxObject__command_dep
77cdf0e10cSrcweirmkdir -p $(dir $(1)) && \
78cdf0e10cSrcweir	echo '$(call gb_CxxObject_get_target,$(2)) : $$(gb_Helper_PHONY)' > $(1)
79cdf0e10cSrcweir
80cdf0e10cSrcweirendef
81cdf0e10cSrcweirelse
82cdf0e10cSrcweirgb_CxxObject__command_dep =
83cdf0e10cSrcweirendif
84cdf0e10cSrcweir
85cdf0e10cSrcweir# Only enable PCH if the PCH_CXXFLAGS and the PCH_DEFS (from the linktarget)
86cdf0e10cSrcweir# are the same as the CXXFLAGS and DEFS we want to use for this object. This
87cdf0e10cSrcweir# should usually be the case.  The DEFS/CXXFLAGS would have too be manually
88cdf0e10cSrcweir# overridden for one object file for them to differ.  PCH_CXXFLAGS/PCH_DEFS
89cdf0e10cSrcweir# should never be overridden on an object -- they should be the same as for the
90cdf0e10cSrcweir# whole linktarget. In general it should be cleaner to use a static library
91cdf0e10cSrcweir# compiled with different flags and link that in rather than mixing different
92cdf0e10cSrcweir# flags in one linktarget.
93cdf0e10cSrcweirdefine gb_CxxObject__set_pchflags
94cdf0e10cSrcweirifeq ($(gb_ENABLE_PCH),$(true))
95cdf0e10cSrcweirifneq ($(strip $$(PCH_NAME)),)
96cdf0e10cSrcweirifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)),$$(sort $$(CXXFLAGS) $$(DEFS)))
97cdf0e10cSrcweir$$@ : PCHFLAGS := $$(call gb_PrecompiledHeader_get_enableflags,$$(PCH_NAME))
98cdf0e10cSrcweirelse
99cdf0e10cSrcweirifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_NOEXCEPTIONFLAGS)),$$(sort $$(CXXFLAGS) $$(DEFS)))
100cdf0e10cSrcweir$$@ : PCHFLAGS := $$(call gb_NoexPrecompiledHeader_get_enableflags,$$(PCH_NAME))
101cdf0e10cSrcweirelse
102cdf0e10cSrcweir$$(info No precompiled header available for $$*.)
103cdf0e10cSrcweir$$(info precompiled header flags (  ex) : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)))
104cdf0e10cSrcweir$$(info precompiled header flags (noex) : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_NOEXCEPTIONFLAGS)))
105cdf0e10cSrcweir$$(info .           object flags        : $$(sort $$(CXXFLAGS) $$(DEFS)))
106cdf0e10cSrcweir$$@ : PCHFLAGS :=
107cdf0e10cSrcweirendif
108cdf0e10cSrcweirendif
109cdf0e10cSrcweirendif
110cdf0e10cSrcweirendif
111cdf0e10cSrcweirendef
112cdf0e10cSrcweir
113cdf0e10cSrcweirdefine gb_CxxObject__rules
114cdf0e10cSrcweir$$(call gb_CxxObject_get_target,%) : $$(call gb_CxxObject_get_source,$(1),%)
115cdf0e10cSrcweir	$$(eval $$(gb_CxxObject__set_pchflags))
116cdf0e10cSrcweir	$$(call gb_CxxObject__command,$$@,$$*,$$<)
117cdf0e10cSrcweir
118cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
119cdf0e10cSrcweir$$(call gb_CxxObject_get_dep_target,%) : $$(call gb_CxxObject_get_source,$(1),%)
120cdf0e10cSrcweir	$$(eval $$(gb_CxxObject__set_pchflags))
121cdf0e10cSrcweir	$$(call gb_CxxObject__command_dep,$$@,$$*,$$<)
122cdf0e10cSrcweirendif
123cdf0e10cSrcweir
124cdf0e10cSrcweirendef
125cdf0e10cSrcweir
126cdf0e10cSrcweir$(foreach repo,$(gb_CxxObject_REPOS),$(eval $(call gb_CxxObject__rules,$(repo))))
127cdf0e10cSrcweir
128cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
129cdf0e10cSrcweir$(call gb_CxxObject_get_dep_target,%) :
130cdf0e10cSrcweir	$(eval $(call gb_Output_error,Unable to find C++ file $(call gb_CxxObject_get_source,,$*) in repositories: $(gb_CxxObject_REPOS)))
131cdf0e10cSrcweir
132cdf0e10cSrcweirendif
133cdf0e10cSrcweir
134cdf0e10cSrcweirgb_CxxObject_CxxObject =
135cdf0e10cSrcweir
136cdf0e10cSrcweir
137cdf0e10cSrcweir# GenCxxObject class
138cdf0e10cSrcweir
139cdf0e10cSrcweirgb_GenCxxObject_get_source = $(WORKDIR)/$(1).cxx
140cdf0e10cSrcweir# defined by platform
141cdf0e10cSrcweir#  gb_CxxObject__command
142cdf0e10cSrcweir
143cdf0e10cSrcweir# This rule generates an "always rebuild" dep file, to have something to
144cdf0e10cSrcweir# include. The dep file will be overridden on the fly, when the object is
145cdf0e10cSrcweir# compiled.
146cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
147cdf0e10cSrcweirdefine gb_GenCxxObject__command_dep
148cdf0e10cSrcweirmkdir -p $(dir $(1)) && \
149cdf0e10cSrcweir	echo '$(call gb_GenCxxObject_get_target,$(2)) : $$(gb_Helper_PHONY)' > $(1)
150cdf0e10cSrcweirendef
151cdf0e10cSrcweirelse
152cdf0e10cSrcweirgb_GenCxxObject__command_dep =
153cdf0e10cSrcweirendif
154cdf0e10cSrcweir
155cdf0e10cSrcweir$(call gb_GenCxxObject_get_target,%) : $(call gb_GenCxxObject_get_source,%)
156cdf0e10cSrcweir	$(call gb_CxxObject__command,$@,$*,$<)
157cdf0e10cSrcweir
158cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
159cdf0e10cSrcweir$(call gb_GenCxxObject_get_dep_target,%) : $(call gb_GenCxxObject_get_source,%)
160cdf0e10cSrcweir	$(call gb_GenCxxObject__command_dep,$@,$*,$<)
161cdf0e10cSrcweir
162cdf0e10cSrcweir$(call gb_GenCxxObject_get_dep_target,%) :
163cdf0e10cSrcweir	$(eval $(call gb_Output_error,Unable to find generated C++ file $(call gb_GenCxxObject_get_source,$*) in WORKDIR.))
164cdf0e10cSrcweirendif
165cdf0e10cSrcweir
166cdf0e10cSrcweirgb_GenCxxObject_GenCxxObject =
167cdf0e10cSrcweir
168cdf0e10cSrcweir
169cdf0e10cSrcweir# ObjCxxObject class
170cdf0e10cSrcweir#
171cdf0e10cSrcweirgb_ObjCxxObject_REPOS := $(gb_REPOS)
172cdf0e10cSrcweir
173cdf0e10cSrcweirgb_ObjCxxObject_get_source = $(1)/$(2).mm
174cdf0e10cSrcweir# defined by platform
175cdf0e10cSrcweir#  gb_ObjCxxObject__command
176cdf0e10cSrcweir
177cdf0e10cSrcweir# this rule generates an "always rebuild" dep file, to have something to include.
178cdf0e10cSrcweir# the dep file will be overridden on the fly, when the object is compiled
179cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
180cdf0e10cSrcweirdefine gb_ObjCxxObject__command_dep
181cdf0e10cSrcweirmkdir -p $(dir $(1)) && \
182cdf0e10cSrcweir	echo '$(call gb_ObjCxxObject_get_target,$(2)) : $$(gb_Helper_PHONY)' > $(1)
183cdf0e10cSrcweir
184cdf0e10cSrcweirendef
185cdf0e10cSrcweirelse
186cdf0e10cSrcweirgb_ObjCxxObject__command_dep =
187cdf0e10cSrcweirendif
188cdf0e10cSrcweir
189cdf0e10cSrcweirdefine gb_ObjCxxObject__rules
190cdf0e10cSrcweir$$(call gb_ObjCxxObject_get_target,%) : $$(call gb_ObjCxxObject_get_source,$(1),%)
191cdf0e10cSrcweir	$$(call gb_ObjCxxObject__command,$$@,$$*,$$<,$$(DEFS),$$(OBJCXXFLAGS),$$(INCLUDE_STL) $$(INCLUDE))
192cdf0e10cSrcweir
193cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
194cdf0e10cSrcweir$$(call gb_ObjCxxObject_get_dep_target,%) : $$(call gb_ObjCxxObject_get_source,$(1),%)
195cdf0e10cSrcweir	$$(call gb_ObjCxxObject__command_dep,$$@,$$*,$$<,$$(DEFS),$$(OBJCXXFLAGS),$$(INCLUDE_STL) $$(INCLUDE))
196cdf0e10cSrcweirendif
197cdf0e10cSrcweir
198cdf0e10cSrcweirendef
199cdf0e10cSrcweir
200cdf0e10cSrcweir$(foreach repo,$(gb_ObjCxxObject_REPOS),$(eval $(call gb_ObjCxxObject__rules,$(repo))))
201cdf0e10cSrcweir
202cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
203cdf0e10cSrcweir$(call gb_ObjCxxObject_get_dep_target,%) :
204cdf0e10cSrcweir	$(eval $(call gb_Output_error,Unable to find Objective C++ file $(call gb_ObjCxxObject_get_source,,$*) in repositories: $(gb_ObjCxxObject_REPOS)))
205cdf0e10cSrcweirendif
206cdf0e10cSrcweir
207cdf0e10cSrcweirgb_ObjCxxObject_ObjCxxObject =
208cdf0e10cSrcweir
209cdf0e10cSrcweir
210cdf0e10cSrcweir
211cdf0e10cSrcweir# LinkTarget class
212cdf0e10cSrcweir
213cdf0e10cSrcweirgb_LinkTarget_DEFAULTDEFS := $(gb_GLOBALDEFS)
214cdf0e10cSrcweir# defined by platform
215cdf0e10cSrcweir#  gb_LinkTarget_CXXFLAGS
216cdf0e10cSrcweir#  gb_LinkTarget_LDFLAGS
217cdf0e10cSrcweir#  gb_LinkTarget_INCLUDE
218cdf0e10cSrcweir#  gb_LinkTarget_INCLUDE_STL
219cdf0e10cSrcweir
220cdf0e10cSrcweir.PHONY : $(call gb_LinkTarget_get_clean_target,%)
221cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,%) :
222cdf0e10cSrcweir	$(call gb_Output_announce,$*,$(false),LNK,4)
223cdf0e10cSrcweir	RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
224cdf0e10cSrcweir		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
225cdf0e10cSrcweir		$(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
226cdf0e10cSrcweir		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
227cdf0e10cSrcweir		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
228cdf0e10cSrcweir		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
229cdf0e10cSrcweir		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
230cdf0e10cSrcweir		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
231cdf0e10cSrcweir		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
232cdf0e10cSrcweir		$(call gb_LinkTarget_get_target,$*) \
233cdf0e10cSrcweir		$(call gb_LinkTarget_get_dep_target,$*) \
234cdf0e10cSrcweir		$(call gb_LinkTarget_get_headers_target,$*) \
235cdf0e10cSrcweir		$(call gb_LinkTarget_get_external_headers_target,$*) \
236cdf0e10cSrcweir		$(DLLTARGET) \
237cdf0e10cSrcweir		$(AUXTARGETS)) && \
238cdf0e10cSrcweir	cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -f && \
239cdf0e10cSrcweir	rm -f $${RESPONSEFILE}
240cdf0e10cSrcweir
241cdf0e10cSrcweir
242cdf0e10cSrcweir# cat the deps of all objects in one file, then we need only open that one file
243cdf0e10cSrcweirdefine gb_LinkTarget__command_dep
244cdf0e10cSrcweir$(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
245cdf0e10cSrcweir$(call gb_Helper_abbreviate_dirs,\
246cdf0e10cSrcweir	mkdir -p $(dir $(1)) && \
247cdf0e10cSrcweir	RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
248cdf0e10cSrcweir		$(foreach object,$(3),$(call gb_CObject_get_dep_target,$(object))) \
249cdf0e10cSrcweir		$(foreach object,$(4),$(call gb_CxxObject_get_dep_target,$(object))) \
250cdf0e10cSrcweir		$(foreach object,$(5),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
251*44c25570SAndre Fischer		$(foreach object,$(6),$(call gb_GenCxxObject_get_dep_target,$(object)))\
252cdf0e10cSrcweir		) && \
253cdf0e10cSrcweir	cat $${RESPONSEFILE} /dev/null | xargs -n 200 cat > $(1)) && \
254cdf0e10cSrcweir	rm -f $${RESPONSEFILE}
255cdf0e10cSrcweir
256cdf0e10cSrcweirendef
257cdf0e10cSrcweir
258cdf0e10cSrcweir$(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_headers_target,%) $(gb_Helper_MISCDUMMY)
259cdf0e10cSrcweir	$(call gb_LinkTarget__command,$@,$*)
260cdf0e10cSrcweir
261cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
262cdf0e10cSrcweir$(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_dep_target,%)
263cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,%) : | $(call gb_LinkTarget_get_headers_target,%)
264cdf0e10cSrcweir	$(call gb_LinkTarget__command_dep,$@,$*,$(COBJECTS),$(CXXOBJECTS),$(OBJCXXOBJECTS),$(GENCXXOBJECTS))
265cdf0e10cSrcweirendif
266cdf0e10cSrcweir
267cdf0e10cSrcweir# Ok, this is some dark voodoo: When declaring a linktarget with
268cdf0e10cSrcweir# gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
269cdf0e10cSrcweir# target. When the rule for the headertarget is executed and SELF does not
270cdf0e10cSrcweir# match the target name, we are depending on a linktarget that was never
271cdf0e10cSrcweir# declared. In a full build exclusively in gbuild that should never happen.
272cdf0e10cSrcweir# However, partial gbuild build will not know about how to build lower level
273cdf0e10cSrcweir# linktargets, just as gbuild can not know about linktargets generated in the
274cdf0e10cSrcweir# old build.pl/dmake system. Once all is migrated, gbuild should error out
275cdf0e10cSrcweir# when is is told to depend on a linktarget it does not know about and not
276cdf0e10cSrcweir# only warn.
277cdf0e10cSrcweirdefine gb_LinkTarget__get_external_headers_check
278cdf0e10cSrcweirifneq ($$(SELF),$$*)
279cdf0e10cSrcweir$$(eval $$(call gb_Output_info,LinkTarget $$* not defined: Assuming headers to be there!,ALL))
280cdf0e10cSrcweirendif
281cdf0e10cSrcweir$$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, mkdir -p $$(dir $$@) && touch $$@ && mkdir -p $(call gb_LinkTarget_get_target,)pdb/$$(dir $$*))
282cdf0e10cSrcweir
283cdf0e10cSrcweirendef
284cdf0e10cSrcweir
285cdf0e10cSrcweir$(call gb_LinkTarget_get_external_headers_target,%) :
286cdf0e10cSrcweir	$(eval $(gb_LinkTarget__get_external_headers_check))
287cdf0e10cSrcweir	$(COMMAND)
288cdf0e10cSrcweir
289cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,%) : $(call gb_LinkTarget_get_external_headers_target,%)
290cdf0e10cSrcweir	$(call gb_Helper_abbreviate_dirs,\
291cdf0e10cSrcweir		mkdir -p $(dir $@) && touch $@)
292cdf0e10cSrcweir
293cdf0e10cSrcweir# Explanation of some of the targets:
294cdf0e10cSrcweir# - gb_LinkTarget_get_external_headers_target is the targets that guarantees all
295cdf0e10cSrcweir#   headers from linked against libraries are in OUTDIR.
296cdf0e10cSrcweir# - gb_LinkTarget_get_headers_target is the target that guarantees all headers
297cdf0e10cSrcweir#   from the linked against the libraries and the linktargets own headers
298cdf0e10cSrcweir#   (including generated headers) are in the OUTDIR.
299cdf0e10cSrcweir# - gb_LinkTarget_get_target links the objects into a file in WORKDIR.
300cdf0e10cSrcweir# gb_LinkTarget_get_target depends on gb_LinkTarget_get_headers_target which in
301cdf0e10cSrcweir# turn depends gb_LinkTarget_get_external_headers_target.
302cdf0e10cSrcweir# gb_LinkTarget_get_target depends additionally on the objects, which in turn
303cdf0e10cSrcweir# depend build-order only on the gb_LinkTarget_get_headers_target. The build
304cdf0e10cSrcweir# order-only dependency ensures all headers to be there for compiling and
305cdf0e10cSrcweir# dependency generation without causing all objects to be rebuild when one
306cdf0e10cSrcweir# header changes. Only the ones with an explicit dependency in their generated
307cdf0e10cSrcweir# dependency file will be rebuild.
308cdf0e10cSrcweir#
309cdf0e10cSrcweir# gb_LinkTarget_get_target is the target that links the objects into a file in
310cdf0e10cSrcweir# WORKDIR
311cdf0e10cSrcweir# Explanation of some of the variables:
312cdf0e10cSrcweir# - AUXTARGETS are the additionally generated files that need to be cleaned out
313cdf0e10cSrcweir#   on clean.
314cdf0e10cSrcweir# - PCH_CXXFLAGS and PCH_DEFS are the flags that the precompiled headers will
315cdf0e10cSrcweir#   be compiled with.  They should never be overridden in a single object
316cdf0e10cSrcweir#   files.
317cdf0e10cSrcweir# - TARGETTYPE is the type of linktarget as some platforms need very different
318cdf0e10cSrcweir#   command to link different targettypes.
319cdf0e10cSrcweir#
320cdf0e10cSrcweir# Since most variables are set on the linktarget and not on the object, the
321cdf0e10cSrcweir# object learns about these setting via GNU makes scoping of target variables.
322cdf0e10cSrcweir# Therefore it is important that objects are only directly depended on by the
323cdf0e10cSrcweir# linktarget. This for example means that you cannot build a single object
324cdf0e10cSrcweir# alone, because then you would directly depend on the object.
325cdf0e10cSrcweirdefine gb_LinkTarget_LinkTarget
326cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
327cdf0e10cSrcweir$(call gb_LinkTarget_get_external_headers_target,$(1)) : SELF := $(1)
328cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : DLLTARGET :=
329cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) \
330cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
331cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) \
332cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
333cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) \
334cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
335cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) \
336cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS :=
337cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
338cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : CFLAGS := $$(gb_LinkTarget_CFLAGS)
339cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
340cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
341cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
342cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS) $(gb_COMPILEROPTFLAGS)
343cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
344cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
345cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS)
346cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
347cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS)
348cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
349cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
350cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
351cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : INCLUDE_STL := $$(gb_LinkTarget_INCLUDE_STL)
352cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : LDFLAGS := $$(gb_LinkTarget_LDFLAGS)
353cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS :=
354cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS :=
355*44c25570SAndre Fischer$(call gb_LinkTarget_get_target,$(1)) : EXTERNAL_LIBS :=
356cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE :=
357cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
358cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCH_NAME :=
359cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCHOBJS :=
360cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
361cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PDBFILE :=
362cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : NATIVERES :=
363cdf0e10cSrcweir
364cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
365cdf0e10cSrcweirifneq ($(wildcard $(call gb_LinkTarget_get_dep_target,$(1))),)
366cdf0e10cSrcweirinclude $(call gb_LinkTarget_get_dep_target,$(1))
367cdf0e10cSrcweirelse
368cdf0e10cSrcweir$(firstword $(MAKEFILE_LIST)) : $(call gb_LinkTarget_get_dep_target,$(1))
369cdf0e10cSrcweirendif
370cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
371cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
372cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
373cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
374cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : CFLAGS := $$(gb_LinkTarget_CFLAGS)
375cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
376cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS) $(gb_COMPILEROPTFLAGS)
377cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
378cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS)
379cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS)
380cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
381cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE_STL := $$(gb_LinkTarget_INCLUDE_STL)
382cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE :=
383cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_NAME :=
384cdf0e10cSrcweirendif
385cdf0e10cSrcweir
386cdf0e10cSrcweirendef
387cdf0e10cSrcweir
388cdf0e10cSrcweirdefine gb_LinkTarget_set_defs
389cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
390cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : DEFS := $(2)
391cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
392cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $(2)
393cdf0e10cSrcweir
394cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
395cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $(2)
396cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS := $(2)
397cdf0e10cSrcweirendif
398cdf0e10cSrcweir
399cdf0e10cSrcweirendef
400cdf0e10cSrcweir
401cdf0e10cSrcweirdefine gb_LinkTarget_set_cflags
402cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : CFLAGS := $(2)
403cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
404cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : CFLAGS := $(2)
405cdf0e10cSrcweirendif
406cdf0e10cSrcweir
407cdf0e10cSrcweirendef
408cdf0e10cSrcweir
409cdf0e10cSrcweirdefine gb_LinkTarget_set_cxxflags
410cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
411cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : CXXFLAGS := $(2)
412cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
413cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $(2)
414cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
415cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : CXXFLAGS := $(2)
416cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS := $(2)
417cdf0e10cSrcweirendif
418cdf0e10cSrcweir
419cdf0e10cSrcweirendef
420cdf0e10cSrcweir
421cdf0e10cSrcweirdefine gb_LinkTarget_set_objcxxflags
422cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : OBJCXXFLAGS := $(2)
423cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
424cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXFLAGS := $(2)
425cdf0e10cSrcweirendif
426cdf0e10cSrcweir
427cdf0e10cSrcweirendef
428cdf0e10cSrcweir
429cdf0e10cSrcweirdefine gb_LinkTarget_set_include
430cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
431cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2)
432cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
433cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $(2)
434cdf0e10cSrcweirendif
435cdf0e10cSrcweir
436cdf0e10cSrcweirendef
437cdf0e10cSrcweir
438cdf0e10cSrcweirdefine gb_LinkTarget_set_include_stl
439cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
440cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : INCLUDE_STL := $(2)
441cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
442cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE_STL := $(2)
443cdf0e10cSrcweirendif
444cdf0e10cSrcweir
445cdf0e10cSrcweirendef
446cdf0e10cSrcweir
447cdf0e10cSrcweirdefine gb_LinkTarget_set_ldflags
448cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : LDFLAGS := $(2)
449cdf0e10cSrcweirendef
450cdf0e10cSrcweir
451cdf0e10cSrcweirdefine gb_LinkTarget_add_linked_libs
452cdf0e10cSrcweirifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
453cdf0e10cSrcweir$$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
454cdf0e10cSrcweir$$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
455cdf0e10cSrcweirendif
456cdf0e10cSrcweir
457cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(2)
458cdf0e10cSrcweir
459cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_Library_get_target,$$(lib)))
460cdf0e10cSrcweir$(call gb_LinkTarget_get_external_headers_target,$(1)) : \
461cdf0e10cSrcweir$$(foreach lib,$(2),$$(call gb_Library_get_headers_target,$$(lib)))
462cdf0e10cSrcweir
463cdf0e10cSrcweirendef
464cdf0e10cSrcweir
465cdf0e10cSrcweirdefine gb_LinkTarget_add_linked_static_libs
466cdf0e10cSrcweirifneq (,$$(filter-out $(gb_StaticLibrary_KNOWNLIBS),$(2)))
467cdf0e10cSrcweir$$(eval $$(call gb_Output_info, currently known static libraries are: $(sort $(gb_StaticLibrary_KNOWNLIBS)),ALL))
468cdf0e10cSrcweir$$(eval $$(call gb_Output_error,Cannot link against static library/libraries $$(filter-out $(gb_StaticLibrary_KNOWNLIBS),$(2)). Static libraries must be registered in Repository.mk))
469cdf0e10cSrcweirendif
470cdf0e10cSrcweir
471cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $(2)
472cdf0e10cSrcweir
473cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_StaticLibrary_get_target,$$(lib)))
474cdf0e10cSrcweir$(call gb_LinkTarget_get_external_headers_target,$(1)) : \
475cdf0e10cSrcweir$$(foreach lib,$(2),$$(call gb_StaticLibrary_get_headers_target,$$(lib)))
476cdf0e10cSrcweir
477cdf0e10cSrcweirendef
478cdf0e10cSrcweir
479*44c25570SAndre Fischer#
480*44c25570SAndre Fischer# Add external libs for linking.  External libaries are not built by any module.
481*44c25570SAndre Fischer#
482*44c25570SAndre Fischer# The list of libraries is used as is, ie it is not filtered with gb_Library_KNOWNLIBS.
483*44c25570SAndre Fischer#
484*44c25570SAndre Fischer# An error is signaled, when any of the library names does not look like
485*44c25570SAndre Fischer# a base name, ie is prefixed by -l or lib or is folled by .lib or .so.
486*44c25570SAndre Fischer#
487*44c25570SAndre Fischer# @param target
488*44c25570SAndre Fischer# @param libraries
489*44c25570SAndre Fischer#     A list of (base names of) libraries that will be added to the target
490*44c25570SAndre Fischer#     local EXTERNAL_LIBS variable and eventually linked in when the
491*44c25570SAndre Fischer#     target is made.
492*44c25570SAndre Fischer#
493*44c25570SAndre Fischerdefine gb_LinkTarget_add_external_libs
494*44c25570SAndre Fischer
495*44c25570SAndre Fischer# Make sure that all libraries are given as base names.
496*44c25570SAndre Fischerifneq (,$$(filter -l% lib% %.so %.lib, $(2)))
497*44c25570SAndre Fischer$$(eval $$(call gb_Output_announce,ERROR: Please give only libary basenames to gb_LinkTarget_add_external_libs))
498*44c25570SAndre Fischer$$(eval $$(call gb_Output_announce,ERROR:    (no prefixes -l% or lib%, no suffixes %.so or %.lib)))
499*44c25570SAndre Fischer$$(eval $$(call gb_Output_announce,ERROR:    libraries given: $(2)))
500*44c25570SAndre Fischer$$(eval $$(call gb_Output_announce,ERROR:    offending: $$(filter -l% lib% %.so %.lib, $(2))))
501*44c25570SAndre Fischer$$(eval $$(call gb_Output_error,  ))
502*44c25570SAndre Fischerendif
503*44c25570SAndre Fischer
504*44c25570SAndre Fischer$(call gb_LinkTarget_get_target,$(1)) : EXTERNAL_LIBS += $(2)
505*44c25570SAndre Fischer
506*44c25570SAndre Fischer$(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_Library_get_target,$$(lib)))
507*44c25570SAndre Fischer$(call gb_LinkTarget_get_external_headers_target,$(1)) : \
508*44c25570SAndre Fischer$$(foreach lib,$(2),$$(call gb_Library_get_headers_target,$$(lib)))
509*44c25570SAndre Fischer
510*44c25570SAndre Fischerendef
511*44c25570SAndre Fischer
512*44c25570SAndre Fischer
513cdf0e10cSrcweirdefine gb_LinkTarget_add_cobject
514cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
515cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : COBJECTS += $(2)
516cdf0e10cSrcweir
517cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : $(call gb_CObject_get_target,$(2))
518cdf0e10cSrcweir$(call gb_CObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
519cdf0e10cSrcweir$(call gb_CObject_get_target,$(2)) : CFLAGS += $(3)
520cdf0e10cSrcweir
521cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
522cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS += $(2)
523cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CObject_get_dep_target,$(2))
524cdf0e10cSrcweirendif
525cdf0e10cSrcweir
526cdf0e10cSrcweirendef
527cdf0e10cSrcweir
528cdf0e10cSrcweirdefine gb_LinkTarget_add_cxxobject
529cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
530cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
531cdf0e10cSrcweir
532cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
533cdf0e10cSrcweir$(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
534cdf0e10cSrcweir$(call gb_CxxObject_get_target,$(2)) : CXXFLAGS += $(3)
535cdf0e10cSrcweir
536cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
537cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS += $(2)
538cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxObject_get_dep_target,$(2))
539cdf0e10cSrcweirendif
540cdf0e10cSrcweir
541cdf0e10cSrcweirendef
542cdf0e10cSrcweir
543cdf0e10cSrcweirdefine gb_LinkTarget_add_objcxxobject
544cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
545cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : OBJCXXOBJECTS += $(2)
546cdf0e10cSrcweir
547cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCxxObject_get_target,$(2))
548cdf0e10cSrcweir$(call gb_ObjCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
549cdf0e10cSrcweir$(call gb_ObjCxxObject_get_target,$(2)) : OBJCXXFLAGS += $(3)
550cdf0e10cSrcweir
551cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
552cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS += $(2)
553cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCxxObject_get_dep_target,$(2))
554cdf0e10cSrcweirendif
555cdf0e10cSrcweir
556cdf0e10cSrcweirendef
557cdf0e10cSrcweir
558cdf0e10cSrcweirdefine gb_LinkTarget_add_generated_cxx_object
559cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
560cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
561cdf0e10cSrcweir
562cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
563cdf0e10cSrcweir$(call gb_GenCxxObject_get_source,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
564cdf0e10cSrcweir$(call gb_GenCxxObject_get_target,$(2)) : CXXFLAGS += $(3) $(gb_COMPILEROPTFLAGS)
565cdf0e10cSrcweir
566cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
567cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS += $(2)
568cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxObject_get_dep_target,$(2))
569cdf0e10cSrcweirendif
570cdf0e10cSrcweir
571cdf0e10cSrcweirendef
572cdf0e10cSrcweir
573cdf0e10cSrcweirdefine gb_LinkTarget_add_noexception_object
574cdf0e10cSrcweir$(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_NOEXCEPTIONFLAGS) $(gb_COMPILEROPTFLAGS))
575cdf0e10cSrcweirendef
576cdf0e10cSrcweir
577cdf0e10cSrcweirdefine gb_LinkTarget_add_exception_object
578cdf0e10cSrcweir$(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(gb_COMPILEROPTFLAGS))
579cdf0e10cSrcweirendef
580cdf0e10cSrcweir
581cdf0e10cSrcweirdefine gb_LinkTarget_add_cobjects
582cdf0e10cSrcweir$(foreach obj,$(2),$(call gb_LinkTarget_add_cobject,$(1),$(obj),$(3)))
583cdf0e10cSrcweirendef
584cdf0e10cSrcweir
585cdf0e10cSrcweirdefine gb_LinkTarget_add_cxxobjects
586cdf0e10cSrcweir$(foreach obj,$(2),$(call gb_LinkTarget_add_cxxobject,$(1),$(obj),$(3)))
587cdf0e10cSrcweirendef
588cdf0e10cSrcweir
589cdf0e10cSrcweirdefine gb_LinkTarget_add_objcxxobjects
590cdf0e10cSrcweir$(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3)))
591cdf0e10cSrcweirendef
592cdf0e10cSrcweir
593cdf0e10cSrcweirdefine gb_LinkTarget_add_noexception_objects
594cdf0e10cSrcweir$(foreach obj,$(2),$(call gb_LinkTarget_add_noexception_object,$(1),$(obj)))
595cdf0e10cSrcweirendef
596cdf0e10cSrcweir
597cdf0e10cSrcweirdefine gb_LinkTarget_add_exception_objects
598cdf0e10cSrcweir$(foreach obj,$(2),$(call gb_LinkTarget_add_exception_object,$(1),$(obj)))
599cdf0e10cSrcweirendef
600cdf0e10cSrcweir
601cdf0e10cSrcweirdefine gb_LinkTarget_add_generated_exception_object
602cdf0e10cSrcweir$(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS))
603cdf0e10cSrcweirendef
604cdf0e10cSrcweir
605cdf0e10cSrcweirdefine gb_LinkTarget_add_generated_exception_objects
606cdf0e10cSrcweir$(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj)))
607cdf0e10cSrcweirendef
608cdf0e10cSrcweir
609cdf0e10cSrcweirdefine gb_LinkTarget_set_targettype
610cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) \
611cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE := $(2)
612cdf0e10cSrcweirendef
613cdf0e10cSrcweir
614cdf0e10cSrcweirdefine gb_LinkTarget_set_dlltarget
615cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) \
616cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : DLLTARGET := $(2)
617cdf0e10cSrcweirendef
618cdf0e10cSrcweir
619cdf0e10cSrcweirdefine gb_LinkTarget_set_auxtargets
620cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS := $(2)
621cdf0e10cSrcweirendef
622cdf0e10cSrcweir
623cdf0e10cSrcweirdefine gb_LinkTarget__add_internal_headers
624cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) : $(2)
625cdf0e10cSrcweir$(2) :|	$(call gb_LinkTarget_get_external_headers_target,$(1))
626cdf0e10cSrcweir
627cdf0e10cSrcweirendef
628cdf0e10cSrcweir
629cdf0e10cSrcweirdefine gb_LinkTarget_add_package_headers
630cdf0e10cSrcweir$(foreach package,$(2),$(call gb_LinkTarget__add_internal_headers,$(1),$(call gb_Package_get_target,$(package))))
631cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach package,$(2),$(call gb_Package_get_clean_target,$(package)))
632cdf0e10cSrcweir
633cdf0e10cSrcweirendef
634cdf0e10cSrcweir
635cdf0e10cSrcweirdefine gb_LinkTarget_add_sdi_headers
636cdf0e10cSrcweir$(call gb_LinkTarget__add_internal_headers,$(1),$(foreach sdi,$(2),$(call gb_SdiTarget_get_target,$(sdi))))
637cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_clean_target,$(sdi)))
638cdf0e10cSrcweirendef
639cdf0e10cSrcweir
640cdf0e10cSrcweirdefine gb_LinkTarget__add_precompiled_header_impl
641cdf0e10cSrcweir$(call gb_LinkTarget__add_internal_headers,$(1),$(call gb_PrecompiledHeader_get_target,$(3)))
642cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_PrecompiledHeader_get_clean_target,$(3))
643cdf0e10cSrcweir$(call gb_PrecompiledHeader_get_target,$(3)) : $(2).cxx
644cdf0e10cSrcweir
645cdf0e10cSrcweir$(call gb_LinkTarget__add_internal_headers,$(1),$(call gb_NoexPrecompiledHeader_get_target,$(3)))
646cdf0e10cSrcweir$(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_NoexPrecompiledHeader_get_clean_target,$(3))
647cdf0e10cSrcweir$(call gb_NoexPrecompiledHeader_get_target,$(3)) : $(2).cxx
648cdf0e10cSrcweir
649cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCH_NAME := $(3)
650cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCHOBJS = $(call gb_PrecompiledHeader_get_target,$(3)).obj $(call gb_NoexPrecompiledHeader_get_target,$(3)).obj
651cdf0e10cSrcweir
652cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
653cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(DEFS) -DPRECOMPILED_HEADERS
654cdf0e10cSrcweir$(call gb_LinkTarget_get_headers_target,$(1)) \
655cdf0e10cSrcweir$(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS = $$(DEFS)
656cdf0e10cSrcweirifeq ($(gb_FULLDEPS),$(true))
657cdf0e10cSrcweir-include \
658cdf0e10cSrcweir	$(call gb_PrecompiledHeader_get_dep_target,$(3)) \
659cdf0e10cSrcweir	$(call gb_NoexPrecompiledHeader_get_dep_target,$(3))
660cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $$(DEFS) -DPRECOMPILED_HEADERS
661cdf0e10cSrcweir$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS = $$(DEFS)
662cdf0e10cSrcweirendif
663cdf0e10cSrcweir
664cdf0e10cSrcweirendef
665cdf0e10cSrcweir
666cdf0e10cSrcweirdefine gb_LinkTarget_add_precompiled_header
667cdf0e10cSrcweirifeq ($(gb_ENABLE_PCH),$(true))
668cdf0e10cSrcweir$(call gb_LinkTarget__add_precompiled_header_impl,$(1),$(2),$(notdir $(2)))
669cdf0e10cSrcweirendif
670cdf0e10cSrcweir
671cdf0e10cSrcweirendef
672cdf0e10cSrcweir
673cdf0e10cSrcweir# vim: set noet sw=4 ts=4:
674