xref: /trunk/main/solenv/gbuild/LinkTarget.mk (revision 7f6ffbef)
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#the following user-defined variables are supported:
25# CPPFLAGS
26# CFLAGS
27# CXXFLAGS
28# OBJCXXFLAGS
29# JAVAFLAGS
30# LDFLAGS
31
32# CFLAGS from environment override debug/optimization flags
33
34ifeq ($(gb_DEBUGGING),TRUE)
35CFLAGS ?= $(gb_COMPILEROPTFLAGS) $(gb_DEBUG_CFLAGS)
36CXXFLAGS ?= $(gb_COMPILEROPTFLAGS) $(gb_DEBUG_CFLAGS)
37OBJCXXFLAGS ?= $(gb_COMPILEROPTFLAGS) $(gb_DEBUG_CFLAGS)
38JAVAFLAGS ?= -g
39else
40CFLAGS ?= $(gb_COMPILEROPTFLAGS)
41CXXFLAGS ?= $(gb_COMPILEROPTFLAGS)
42OBJCXXFLAGS ?= $(gb_COMPILEROPTFLAGS)
43endif
44
45
46# For every object there is a dep file (if gb_FULLDEPS is active).
47# The dep file depends on the object: the Object__command also updates the
48# dep file as a side effect.
49# In the dep file rule just touch it so it's newer than the object.
50
51# The gb_Object__command_dep generates an "always rebuild" dep file;
52# It is _only_ used in case the user deletes the object dep file.
53ifeq ($(gb_FULLDEPS),$(true))
54define gb_Object__command_dep
55mkdir -p $(dir $(1)) && \
56	echo '$(2) : $$(gb_Helper_PHONY)' > $(1)
57
58endef
59else
60gb_Object__command_dep = \
61 $(call gb_Output_error,gb_Object__command_dep is only for gb_FULLDEPS)
62endif
63
64
65# AsmObject class
66
67gb_AsmObject_REPOS := $(gb_REPOS)
68
69gb_AsmObject_get_source = $(1)/$(2)$(gb_AsmObject_EXT)
70
71define gb_AsmObject__rules
72$$(call gb_AsmObject_get_target,%) : $$(call gb_AsmObject_get_source,$(1),%)
73	$$(call gb_AsmObject__command,$$@,$$*,$$<)
74
75endef
76
77$(foreach repo,$(gb_AsmObject_REPOS),$(eval $(call gb_AsmObject__rules,$(repo))))
78
79gb_AsmObject_AsmObject =
80
81
82# CObject class
83
84gb_CObject_REPOS := $(gb_REPOS)
85
86gb_CObject_get_source = $(1)/$(2).c
87# defined by platform
88#  gb_CObject__command
89
90define gb_CObject__rules
91$$(call gb_CObject_get_target,%) : $$(call gb_CObject_get_source,$(1),%)
92	$$(call gb_CObject__command,$$@,$$*,$$<,$$(call gb_CObject_get_dep_target,$$*))
93
94ifeq ($(gb_FULLDEPS),$(true))
95$$(call gb_CObject_get_dep_target,%) : $$(call gb_CObject_get_target,%)
96	$$(if $$(wildcard $$@),touch $$@,\
97	  $$(call gb_Object__command_dep,$$@,$$(call gb_CObject_get_target,$$*)))
98endif
99
100endef
101
102$(foreach repo,$(gb_CObject_REPOS),$(eval $(call gb_CObject__rules,$(repo))))
103
104$(call gb_CObject_get_dep_target,%) :
105	$(eval $(call gb_Output_error,Unable to find plain C file $(call gb_CObject_get_source,,$*) in the repositories: $(gb_CObject_REPOS)))
106
107gb_CObject_CObject =
108
109
110# GenCObject class
111
112gb_GenCObject_get_source = $(WORKDIR)/$(1).c
113# defined by platform
114#  gb_CObject__command
115
116$(call gb_GenCObject_get_target,%) : $(call gb_GenCObject_get_source,%)
117	$(call gb_CObject__command,$@,$*,$<,$(call gb_GenCObject_get_dep_target,$*))
118
119ifeq ($(gb_FULLDEPS),$(true))
120$(call gb_GenCObject_get_dep_target,%) : $(call gb_GenCObject_get_target,%)
121	$(if $(wildcard $@),touch $@,\
122	  $(call gb_Object__command_dep,$@,$(call gb_GenCObject_get_target,$*)))
123endif
124
125gb_GenCObject_GenCObject =
126
127
128
129
130# CxxObject class
131
132gb_CxxObject_REPOS := $(gb_REPOS)
133
134gb_CxxObject_get_source = $(1)/$(2).cxx
135# defined by platform
136#  gb_CxxObject__command
137
138# Only enable PCH if the PCH_CXXFLAGS and the PCH_DEFS (from the linktarget)
139# are the same as the T_CXXFLAGS and DEFS we want to use for this object. This
140# should usually be the case.  The DEFS/T_CXXFLAGS would have too be manually
141# overridden for one object file for them to differ.  PCH_CXXFLAGS/PCH_DEFS
142# should never be overridden on an object -- they should be the same as for the
143# whole linktarget. In general it should be cleaner to use a static library
144# compiled with different flags and link that in rather than mixing different
145# flags in one linktarget.
146define gb_CxxObject__set_pchflags
147ifeq ($(gb_ENABLE_PCH),$(true))
148ifneq ($(strip $$(PCH_NAME)),)
149ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)),$$(sort $$(T_CXXFLAGS) $$(CXXFLAGS) $$(DEFS)))
150$$@ : PCHFLAGS := $$(call gb_PrecompiledHeader_get_enableflags,$$(PCH_NAME))
151else
152ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_NOEXCEPTIONFLAGS)),$$(sort $$(T_CXXFLAGS) $$(CXXFLAGS) $$(DEFS)))
153$$@ : PCHFLAGS := $$(call gb_NoexPrecompiledHeader_get_enableflags,$$(PCH_NAME))
154else
155$$(info No precompiled header available for $$*.)
156$$(info precompiled header flags (  ex) : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)))
157$$(info precompiled header flags (noex) : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_NOEXCEPTIONFLAGS)))
158$$(info .           object flags        : $$(sort $$(T_CXXFLAGS) $$(DEFS)))
159$$@ : PCHFLAGS :=
160endif
161endif
162endif
163endif
164endef
165
166define gb_CxxObject__rules
167$$(call gb_CxxObject_get_target,%) : $$(call gb_CxxObject_get_source,$(1),%)
168	$$(eval $$(gb_CxxObject__set_pchflags))
169	$$(call gb_CxxObject__command,$$@,$$*,$$<,$$(call gb_CxxObject_get_dep_target,$$*))
170
171ifeq ($(gb_FULLDEPS),$(true))
172$$(call gb_CxxObject_get_dep_target,%) : $$(call gb_CxxObject_get_target,%)
173	$$(if $$(wildcard $$@),touch $$@,\
174	  $$(eval $$(gb_CxxObject__set_pchflags))\
175	  $$(call gb_Object__command_dep,$$@,$$(call gb_CxxObject_get_target,$$*)))
176endif
177
178endef
179
180$(foreach repo,$(gb_CxxObject_REPOS),$(eval $(call gb_CxxObject__rules,$(repo))))
181
182ifeq ($(gb_FULLDEPS),$(true))
183$(call gb_CxxObject_get_dep_target,%) :
184	$(eval $(call gb_Output_error,Unable to find C++ file $(call gb_CxxObject_get_source,,$*) in repositories: $(gb_CxxObject_REPOS)))
185
186endif
187
188gb_CxxObject_CxxObject =
189
190
191# GenCxxObject class
192
193gb_GenCxxObject_get_source = $(WORKDIR)/$(1).cxx
194# defined by platform
195#  gb_CxxObject__command
196
197$(call gb_GenCxxObject_get_target,%) : $(call gb_GenCxxObject_get_source,%)
198	$(call gb_CxxObject__command,$@,$*,$<,$(call gb_GenCxxObject_get_dep_target,$*))
199
200ifeq ($(gb_FULLDEPS),$(true))
201$(call gb_GenCxxObject_get_dep_target,%) : $(call gb_GenCxxObject_get_target,%)
202	$(if $(wildcard $@),touch $@,\
203	  $(call gb_Object__command_dep,$@,$(call gb_GenCxxObject_get_target,$*)))
204endif
205
206gb_GenCxxObject_GenCxxObject =
207
208
209# ObjCxxObject class
210#
211gb_ObjCxxObject_REPOS := $(gb_REPOS)
212
213gb_ObjCxxObject_get_source = $(1)/$(2).mm
214# defined by platform
215#  gb_ObjCxxObject__command
216
217define gb_ObjCxxObject__rules
218$$(call gb_ObjCxxObject_get_target,%) : $$(call gb_ObjCxxObject_get_source,$(1),%)
219	$$(call gb_ObjCxxObject__command,$$@,$$*,$$<,$$(call gb_ObjCxxObject_get_dep_target,$$*))
220
221ifeq ($(gb_FULLDEPS),$(true))
222$$(call gb_ObjCxxObject_get_dep_target,%) : $$(call gb_ObjCxxObject_get_target,%)
223	$$(if $$(wildcard $$@),touch $$@,\
224	  $$(call gb_Object__command_dep,$$@,$$(call gb_ObjCxxObject_get_target,$$*)))
225endif
226
227endef
228
229$(foreach repo,$(gb_ObjCxxObject_REPOS),$(eval $(call gb_ObjCxxObject__rules,$(repo))))
230
231ifeq ($(gb_FULLDEPS),$(true))
232$(call gb_ObjCxxObject_get_dep_target,%) :
233	$(eval $(call gb_Output_error,Unable to find Objective C++ file $(call gb_ObjCxxObject_get_source,,$*) in repositories: $(gb_ObjCxxObject_REPOS)))
234endif
235
236gb_ObjCxxObject_ObjCxxObject =
237
238
239
240# LinkTarget class
241
242gb_LinkTarget_DEFAULTDEFS := $(gb_GLOBALDEFS)
243# defined by platform
244#  gb_LinkTarget_CXXFLAGS
245#  gb_LinkTarget_LDFLAGS
246#  gb_LinkTarget_INCLUDE
247#  gb_LinkTarget_INCLUDE_STL
248
249.PHONY : $(call gb_LinkTarget_get_clean_target,%)
250$(call gb_LinkTarget_get_clean_target,%) :
251	$(call gb_Output_announce,$*,$(false),LNK,4)
252	RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
253		$(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
254		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
255		$(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
256		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
257		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
258		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
259		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
260		$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
261		$(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
262		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
263		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
264		$(call gb_LinkTarget_get_target,$*) \
265		$(call gb_LinkTarget_get_dep_target,$*) \
266		$(call gb_LinkTarget_get_headers_target,$*) \
267		$(call gb_LinkTarget_get_external_headers_target,$*) \
268		$(DLLTARGET) \
269		$(AUXTARGETS)) && \
270	cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -f && \
271	rm -f $${RESPONSEFILE}
272
273
274# cat the deps of all objects in one file, then we need only open that one file
275define gb_LinkTarget__command_dep
276$(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
277$(call gb_Helper_abbreviate_dirs,\
278	mkdir -p $(dir $(1)) && \
279	RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
280		$(foreach object,$(3),$(call gb_CObject_get_dep_target,$(object))) \
281		$(foreach object,$(4),$(call gb_CxxObject_get_dep_target,$(object))) \
282		$(foreach object,$(5),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
283		$(foreach object,$(6),$(call gb_GenCObject_get_dep_target,$(object)))\
284		$(foreach object,$(7),$(call gb_GenCxxObject_get_dep_target,$(object)))\
285		) && \
286	cat $${RESPONSEFILE} /dev/null | xargs -n 200 cat > $(1)) && \
287	rm -f $${RESPONSEFILE}
288
289endef
290
291$(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_headers_target,%) $(gb_Helper_MISCDUMMY)
292	$(call gb_LinkTarget__command,$@,$*)
293
294ifeq ($(gb_FULLDEPS),$(true))
295$(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_dep_target,%)
296$(call gb_LinkTarget_get_dep_target,%) : | $(call gb_LinkTarget_get_headers_target,%)
297	$(call gb_LinkTarget__command_dep,$@,$*,$(COBJECTS),$(CXXOBJECTS),$(OBJCXXOBJECTS),$(GENCOBJECTS),$(GENCXXOBJECTS))
298endif
299
300# Ok, this is some dark voodoo: When declaring a linktarget with
301# gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
302# target. When the rule for the headertarget is executed and SELF does not
303# match the target name, we are depending on a linktarget that was never
304# declared. In a full build exclusively in gbuild that should never happen.
305# However, partial gbuild build will not know about how to build lower level
306# linktargets, just as gbuild can not know about linktargets generated in the
307# old build.pl/dmake system. Once all is migrated, gbuild should error out
308# when is is told to depend on a linktarget it does not know about and not
309# only warn.
310define gb_LinkTarget__get_external_headers_check
311ifneq ($$(SELF),$$*)
312$$(eval $$(call gb_Output_info,LinkTarget $$* not defined: Assuming headers to be there!,ALL))
313endif
314$$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, mkdir -p $$(dir $$@) && touch $$@ && mkdir -p $(call gb_LinkTarget_get_target,)pdb/$$(dir $$*))
315
316endef
317
318$(call gb_LinkTarget_get_external_headers_target,%) :
319	$(eval $(gb_LinkTarget__get_external_headers_check))
320	$(COMMAND)
321
322$(call gb_LinkTarget_get_headers_target,%) : $(call gb_LinkTarget_get_external_headers_target,%)
323	$(call gb_Helper_abbreviate_dirs,\
324		mkdir -p $(dir $@) && touch $@)
325
326# Explanation of some of the targets:
327# - gb_LinkTarget_get_external_headers_target is the targets that guarantees all
328#   headers from linked against libraries are in OUTDIR.
329# - gb_LinkTarget_get_headers_target is the target that guarantees all headers
330#   from the linked against the libraries and the linktargets own headers
331#   (including generated headers) are in the OUTDIR.
332# - gb_LinkTarget_get_target links the objects into a file in WORKDIR.
333# gb_LinkTarget_get_target depends on gb_LinkTarget_get_headers_target which in
334# turn depends gb_LinkTarget_get_external_headers_target.
335# gb_LinkTarget_get_target depends additionally on the objects, which in turn
336# depend build-order only on the gb_LinkTarget_get_headers_target. The build
337# order-only dependency ensures all headers to be there for compiling and
338# dependency generation without causing all objects to be rebuild when one
339# header changes. Only the ones with an explicit dependency in their generated
340# dependency file will be rebuild.
341#
342# gb_LinkTarget_get_target is the target that links the objects into a file in
343# WORKDIR
344# Explanation of some of the variables:
345# - AUXTARGETS are the additionally generated files that need to be cleaned out
346#   on clean.
347# - PCH_CXXFLAGS and PCH_DEFS are the flags that the precompiled headers will
348#   be compiled with.  They should never be overridden in a single object
349#   files.
350# - TARGETTYPE is the type of linktarget as some platforms need very different
351#   command to link different targettypes.
352# - VERSIONMAP is the linker script, usually used to version a dynamic
353#   library's symbols (on *nix/Mac).
354#
355# Since most variables are set on the linktarget and not on the object, the
356# object learns about these setting via GNU makes scoping of target variables.
357# Therefore it is important that objects are only directly depended on by the
358# linktarget. This for example means that you cannot build a single object
359# alone, because then you would directly depend on the object.
360#
361# A note about flags: because the overriding the global variables with a target
362# local variable of the same name is considered obscure, the target local
363# variables have a T_ prefix.
364define gb_LinkTarget_LinkTarget
365$(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
366$(call gb_LinkTarget_get_external_headers_target,$(1)) : SELF := $(1)
367$(call gb_LinkTarget_get_target,$(1)) : DLLTARGET :=
368$(call gb_LinkTarget_get_clean_target,$(1)) \
369$(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS :=
370$(call gb_LinkTarget_get_clean_target,$(1)) \
371$(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
372$(call gb_LinkTarget_get_clean_target,$(1)) \
373$(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
374$(call gb_LinkTarget_get_clean_target,$(1)) \
375$(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
376$(call gb_LinkTarget_get_clean_target,$(1)) \
377$(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS :=
378$(call gb_LinkTarget_get_clean_target,$(1)) \
379$(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS :=
380$(call gb_LinkTarget_get_headers_target,$(1)) \
381$(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
382$(call gb_LinkTarget_get_headers_target,$(1)) \
383$(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
384$(call gb_LinkTarget_get_headers_target,$(1)) \
385$(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS) $$(CXXFLAGS)
386$(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
387$(call gb_LinkTarget_get_headers_target,$(1)) \
388$(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
389$(call gb_LinkTarget_get_headers_target,$(1)) \
390$(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
391$(call gb_LinkTarget_get_headers_target,$(1)) \
392$(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
393$(call gb_LinkTarget_get_headers_target,$(1)) \
394$(call gb_LinkTarget_get_target,$(1)) : INCLUDE_STL := $$(gb_LinkTarget_INCLUDE_STL)
395$(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $$(gb_LinkTarget_LDFLAGS) $(LDFLAGS)
396$(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS :=
397$(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS :=
398$(call gb_LinkTarget_get_target,$(1)) : EXTERNAL_LIBS :=
399$(call gb_LinkTarget_get_target,$(1)) : LIBS :=
400$(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE :=
401$(call gb_LinkTarget_get_target,$(1)) : VERSIONMAP :=
402$(call gb_LinkTarget_get_headers_target,$(1)) \
403$(call gb_LinkTarget_get_target,$(1)) : PCH_NAME :=
404$(call gb_LinkTarget_get_target,$(1)) : PCHOBJS :=
405#$(call gb_LinkTarget_get_headers_target,$(1)) \
406#$(call gb_LinkTarget_get_target,$(1)) : PDBFILE :=
407$(call gb_LinkTarget_get_target,$(1)) : NATIVERES :=
408
409ifeq ($(gb_FULLDEPS),$(true))
410-include $(call gb_LinkTarget_get_dep_target,$(1))
411$(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
412$(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
413$(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
414$(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
415$(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
416$(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
417$(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
418$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS) $$(CXXFLAGS)
419$(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
420$(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
421$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
422$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
423$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE_STL := $$(gb_LinkTarget_INCLUDE_STL)
424$(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE :=
425$(call gb_LinkTarget_get_dep_target,$(1)) : VERSIONMAP :=
426$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_NAME :=
427endif
428
429endef
430
431define gb_LinkTarget_add_defs
432$(call gb_LinkTarget_get_headers_target,$(1)) \
433$(call gb_LinkTarget_get_target,$(1)) : DEFS += $(2)
434$(call gb_LinkTarget_get_headers_target,$(1)) \
435$(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS += $(2)
436ifeq ($(gb_FULLDEPS),$(true))
437$(call gb_LinkTarget_get_dep_target,$(1)) : DEFS += $(2)
438$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS += $(2)
439endif
440endef
441
442define gb_LinkTarget_set_defs
443ifeq (,)
444$$(call gb_Output_error,\
445 gb_LinkTarget_set_defs: use gb_LinkTarget_add_defs instead.)
446else
447$(call gb_LinkTarget_get_headers_target,$(1)) \
448$(call gb_LinkTarget_get_target,$(1)) : DEFS := $(2)
449$(call gb_LinkTarget_get_headers_target,$(1)) \
450$(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $(2)
451
452ifeq ($(gb_FULLDEPS),$(true))
453$(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $(2)
454$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS := $(2)
455endif
456endif
457
458endef
459
460define gb_LinkTarget_add_cflags
461$(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS += $(2)
462ifeq ($(gb_FULLDEPS),$(true))
463$(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS += $(2)
464endif
465
466endef
467
468define gb_LinkTarget_set_cflags
469ifeq (,)
470$$(call gb_Output_error,\
471 gb_LinkTarget_set_cflags: use gb_LinkTarget_add_cflags instead.)
472else
473$(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS := $(2)
474ifeq ($(gb_FULLDEPS),$(true))
475$(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS := $(2)
476endif
477endif
478
479endef
480
481define gb_LinkTarget_add_cxxflags
482$(call gb_LinkTarget_get_headers_target,$(1)) \
483$(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS += $(2)
484$(call gb_LinkTarget_get_headers_target,$(1)) \
485$(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS += $(2)
486ifeq ($(gb_FULLDEPS),$(true))
487$(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS += $(2)
488$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS += $(2)
489endif
490endef
491
492define gb_LinkTarget_set_cxxflags
493ifeq (,)
494$$(call gb_Output_error,\
495 gb_LinkTarget_set_cxxflags: use gb_LinkTarget_add_cxxflags instead.)
496else
497$(call gb_LinkTarget_get_headers_target,$(1)) \
498$(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $(2)
499$(call gb_LinkTarget_get_headers_target,$(1)) \
500$(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $(2)
501ifeq ($(gb_FULLDEPS),$(true))
502$(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS := $(2)
503$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS := $(2)
504endif
505endif
506
507endef
508
509define gb_LinkTarget_add_objcxxflags
510$(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS += $(2)
511ifeq ($(gb_FULLDEPS),$(true))
512$(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS += $(2)
513endif
514endef
515
516define gb_LinkTarget_set_objcxxflags
517ifeq (,)
518$$(call gb_Output_error,\
519 gb_LinkTarget_set_objcxxflags: use gb_LinkTarget_add_objcxxflags instead.)
520else
521$(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $(2)
522ifeq ($(gb_FULLDEPS),$(true))
523$(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS := $(2)
524endif
525endif
526endef
527
528define gb_LinkTarget_set_c_optimization
529$(foreach object,$(1),$(eval $(call gb_CObject_get_target,$(object)) : CFLAGS := $(filter-out $(gb_COMPILEROPTFLAGS),$(CFLAGS)) $(2)))
530endef
531
532define gb_LinkTarget_set_cxx_optimization
533$(foreach object,$(1),$(eval $(call gb_CxxObject_get_target,$(object)) : CXXFLAGS := $(filter-out $(gb_COMPILEROPTFLAGS),$(CXXFLAGS)) $(2)))
534endef
535
536define gb_LinkTarget_set_genc_optimization
537$(foreach object,$(1),$(eval $(call gb_GenCObject_get_target,$(object)) : CFLAGS := $(filter-out $(gb_COMPILEROPTFLAGS),$(CFLAGS)) $(2)))
538endef
539
540define gb_LinkTarget_set_gencxx_optimization
541$(foreach object,$(1),$(eval $(call gb_GenCxxObject_get_target,$(object)) : CXXFLAGS := $(filter-out $(gb_COMPILEROPTFLAGS),$(CXXFLAGS)) $(2)))
542endef
543
544define gb_LinkTarget_set_objcxx_optimization
545$(foreach object,$(1),$(eval $(call gb_ObjCxxObject_get_target,$(object)) : OBJCXXFLAGS := $(filter-out $(gb_COMPILEROPTFLAGS),$(OBJCXXFLAGS)) $(2)))
546endef
547
548define gb_LinkTarget_set_include
549$(call gb_LinkTarget_get_headers_target,$(1)) \
550$(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2)
551ifeq ($(gb_FULLDEPS),$(true))
552$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $(2)
553endif
554
555endef
556
557define gb_LinkTarget_set_include_stl
558$(call gb_LinkTarget_get_headers_target,$(1)) \
559$(call gb_LinkTarget_get_target,$(1)) : INCLUDE_STL := $(2)
560ifeq ($(gb_FULLDEPS),$(true))
561$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE_STL := $(2)
562endif
563
564endef
565
566define gb_LinkTarget_add_ldflags
567$(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS += $(2)
568endef
569
570# real use in RepositoryExternal.mk
571define gb_LinkTarget_set_ldflags
572$(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $(2)
573endef
574
575define gb_LinkTarget_add_api
576$(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
577	$$(foreach api,$(2),$$(call gb_Package_get_target,$$(api)_inc))
578$(call gb_LinkTarget_get_headers_target,$(1)) \
579$(call gb_LinkTarget_get_target,$(1)) : INCLUDE += $$(foreach api,$(2),-I$(OUTDIR)/inc/$$(api))
580ifeq ($(gb_FULLDEPS),$(true))
581$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += $$(foreach api,$(2),-I$(OUTDIR)/inc/$$(api))
582endif
583
584endef
585
586define gb_LinkTarget_add_private_api
587$(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
588	$(call gb_UnoPrivateApiTarget_get_target,$(1)/idl.cppumaker.flag)
589$(call gb_LinkTarget_get_headers_target,$(1)) \
590$(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(call gb_UnoPrivateApiTarget_get_target,$(1)/inc)
591ifeq ($(gb_FULLDEPS),$(true))
592$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += -I$(call gb_UnoPrivateApiTarget_get_target,$(1)/inc)
593endif
594
595$(call gb_UnoPrivateApiTarget_get_target,$(1)/idl.cppumaker.flag): $(2) $(3)
596	$(call gb_Output_announce,$@,$(true),PVTIDL,2)
597	-$$(call gb_Helper_abbreviate_dirs_native,\
598		mkdir -p $$(call gb_UnoPrivateApiTarget_get_target,$(1)/urd) && \
599		mkdir -p $$(call gb_UnoPrivateApiTarget_get_target,$(1)/rdb) && \
600		mkdir -p $$(call gb_UnoPrivateApiTarget_get_target,$(1)/inc) && \
601		$$(gb_UnoApiTarget_IDLCCOMMAND) -I$$(OUTDIR)/idl -O $$(call gb_UnoPrivateApiTarget_get_target,$(1)/urd) \
602			-verbose -cid -we $(3) && \
603		$$(gb_UnoApiTarget_REGMERGECOMMAND) $$(call gb_UnoPrivateApiTarget_get_target,$(1)/rdb/registry.rdb) /UCR \
604			$(patsubst %.idl,%.urd,$$(call gb_UnoPrivateApiTarget_get_target,$(1)/urd)/$(notdir $(3))) && \
605		$(gb_UnoApiTarget_CPPUMAKERCOMMAND) \
606			-O $$(call gb_UnoPrivateApiTarget_get_target,$(1)/inc) \
607			$(foreach unotype,$(4),-T$(unotype)) \
608			-BUCR \
609			-C \
610			$$(call gb_UnoPrivateApiTarget_get_target,$(1)/rdb/registry.rdb) \
611			$(2) && \
612		touch $(call gb_UnoPrivateApiTarget_get_target,$(1)/idl.cppumaker.flag))
613
614$(call gb_LinkTarget_get_clean_target,$(1)) :
615	rm -rf $(call gb_UnoPrivateApiTarget_get_target,$(1))
616
617endef
618
619# FIXME: multiple??
620define gb_LinkTarget_set_private_api
621$(foreach api,$(3),$(call gb_LinkTarget_add_private_api,$(1),$(2),$(api),$(4)))
622
623endef
624
625define gb_LinkTarget_set_private_extract_of_public_api
626$(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
627	$(call gb_UnoPrivateApiExtractTarget_get_target,$(1)/idl.cppumaker.flag)
628$(call gb_LinkTarget_get_headers_target,$(1)) \
629$(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(call gb_UnoPrivateApiExtractTarget_get_target,$(1)/inc)
630ifeq ($(gb_FULLDEPS),$(true))
631$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += -I$(call gb_UnoPrivateApiExtractTarget_get_target,$(1)/inc)
632endif
633
634$(call gb_UnoPrivateApiExtractTarget_get_target,$(1)/idl.cppumaker.flag): $(2)
635	$(call gb_Output_announce,$@,$(true),PVTUNOTYPES,2)
636	-$$(call gb_Helper_abbreviate_dirs_native,\
637		mkdir -p $$(call gb_UnoPrivateApiExtractTarget_get_target,$(1)/inc) && \
638		$(gb_UnoApiTarget_CPPUMAKERCOMMAND) \
639			-O $$(call gb_UnoPrivateApiExtractTarget_get_target,$(1)/inc) \
640			$(foreach unotype,$(3),-T$(unotype)) \
641			-BUCR \
642			-C \
643			$(2) && \
644		touch $(call gb_UnoPrivateApiExtractTarget_get_target,$(1)/idl.cppumaker.flag))
645
646$(call gb_LinkTarget_get_clean_target,$(1)) :
647	rm -rf $(call gb_UnoPrivateApiExtractTarget_get_target,$(1))
648
649
650endef
651
652gb_BisonTarget_get_source = $(SRCDIR)/$(1).y
653
654# Bison-generated .cxx files are always #include'd into in-module files,
655# and aren't compiled, so they effectively act as generated headers, not generated .cxx.
656
657define gb_LinkTarget_add_bison_file
658
659$(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
660	$(call gb_BisonTarget_get_target,$(1),$(2))
661
662$(call gb_LinkTarget_get_headers_target,$(1)) \
663$(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(dir $(call gb_BisonTarget_get_target,$(1),$(2)))
664ifeq ($(gb_FULLDEPS),$(true))
665$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += -I$(dir $(call gb_BisonTarget_get_target,$(1),$(2)))
666endif
667
668$(call gb_BisonTarget_get_target,$(1),$(2)) : $(call gb_BisonTarget_get_source,$(2))
669	mkdir -p $(dir $(call gb_BisonTarget_get_target,$(1),$(2))) && \
670	tr -d "\015" < $(call gb_BisonTarget_get_source,$(2)) > $(dir $(call gb_BisonTarget_get_target,$(1),$(2)))/stripped_$(notdir $(call gb_BisonTarget_get_source,$(2))) && \
671	bison -d -o $(call gb_BisonTarget_get_target,$(1),$(2)) $(dir $(call gb_BisonTarget_get_target,$(1),$(2)))/stripped_$(notdir $(call gb_BisonTarget_get_source,$(2)))
672
673endef
674
675define gb_LinkTarget_add_bison_files
676$(foreach bisonfile,$(2),$(call gb_LinkTarget_add_bison_file,$(1),$(bisonfile)))
677
678endef
679
680
681
682gb_FlexTarget_get_source = $(SRCDIR)/$(1).ll
683
684# Flex-generated .cxx files are always #include'd into in-module files,
685# and aren't compiled, so they effectively act as generated headers, not generated .cxx.
686
687define gb_LinkTarget_add_flex_file
688
689$(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
690        $(call gb_FlexTarget_get_target,$(1),$(2))
691
692$(call gb_LinkTarget_get_headers_target,$(1)) \
693$(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(dir $(call gb_FlexTarget_get_target,$(1),$(2)))
694ifeq ($(gb_FULLDEPS),$(true))
695$(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += -I$(dir $(call gb_FlexTarget_get_target,$(1),$(2)))
696endif
697
698$(call gb_FlexTarget_get_target,$(1),$(2)) : $(call gb_FlexTarget_get_source,$(2))
699	mkdir -p $(dir $(call gb_FlexTarget_get_target,$(1),$(2))) && \
700	tr -d "\015" < $(call gb_FlexTarget_get_source,$(2)) > $(dir $(call gb_FlexTarget_get_target,$(1),$(2)))/stripped_$(notdir $(call gb_FlexTarget_get_source,$(2))) && \
701	flex -o$(call gb_FlexTarget_get_target,$(1),$(2)) $(dir $(call gb_FlexTarget_get_target,$(1),$(2)))/stripped_$(notdir $(call gb_FlexTarget_get_source,$(2)))
702
703endef
704
705define gb_LinkTarget_add_flex_files
706$(foreach flexfile,$(2),$(call gb_LinkTarget_add_flex_file,$(1),$(flexfile)))
707
708endef
709
710
711
712
713define gb_LinkTarget_add_libs
714$(call gb_LinkTarget_get_target,$(1)) : LIBS += $(2)
715endef
716
717define gb_LinkTarget_add_linked_libs
718ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
719$$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
720$$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
721endif
722
723$(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(2)
724
725$(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_Library_get_target,$$(lib)))
726$(call gb_LinkTarget_get_external_headers_target,$(1)) : \
727$$(foreach lib,$(2),$$(call gb_Library_get_headers_target,$$(lib)))
728
729endef
730
731define gb_LinkTarget_add_linked_static_libs
732ifneq (,$$(filter-out $(gb_StaticLibrary_KNOWNLIBS),$(2)))
733$$(eval $$(call gb_Output_info, currently known static libraries are: $(sort $(gb_StaticLibrary_KNOWNLIBS)),ALL))
734$$(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))
735endif
736
737$(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $(2)
738
739$(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_StaticLibrary_get_target,$$(lib)))
740$(call gb_LinkTarget_get_external_headers_target,$(1)) : \
741$$(foreach lib,$(2),$$(call gb_StaticLibrary_get_headers_target,$$(lib)))
742
743endef
744
745#
746# Add external libs for linking.  External libaries are not built by any module.
747#
748# The list of libraries is used as is, ie it is not filtered with gb_Library_KNOWNLIBS.
749#
750# An error is signaled, when any of the library names does not look like
751# a base name, ie is prefixed by -l or is folled by .lib or .so.
752#
753# @param target
754# @param libraries
755#     A list of (base names of) libraries that will be added to the target
756#     local EXTERNAL_LIBS variable and eventually linked in when the
757#     target is made.
758#
759define gb_LinkTarget_add_external_libs
760
761# Make sure that all libraries are given as base names.
762ifneq (,$$(filter -l% %.so %.lib, $(2)))
763$$(eval $$(call gb_Output_announce,ERROR: Please give only library basenames to gb_LinkTarget_add_external_libs))
764$$(eval $$(call gb_Output_announce,ERROR:    (no prefixes -l% or lib%, no suffixes %.so or %.lib)))
765$$(eval $$(call gb_Output_announce,ERROR:    libraries given: $(2)))
766$$(eval $$(call gb_Output_announce,ERROR:    offending: $$(filter -l% lib% %.so %.lib, $(2))))
767$$(eval $$(call gb_Output_error,  ))
768endif
769
770$(call gb_LinkTarget_get_target,$(1)) : EXTERNAL_LIBS += $(2)
771
772$(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_Library_get_target,$$(lib)))
773$(call gb_LinkTarget_get_external_headers_target,$(1)) : \
774$$(foreach lib,$(2),$$(call gb_Library_get_headers_target,$$(lib)))
775
776endef
777
778
779define gb_LinkTarget_add_asmobject
780$(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS += $(2)
781$(call gb_LinkTarget_get_clean_target,$(1)) : ASMOBJECTS += $(2)
782
783$(call gb_LinkTarget_get_target,$(1)) : $(call gb_AsmObject_get_target,$(2))
784
785endef
786
787define gb_LinkTarget_add_cobject
788$(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
789$(call gb_LinkTarget_get_clean_target,$(1)) : COBJECTS += $(2)
790
791$(call gb_LinkTarget_get_target,$(1)) : $(call gb_CObject_get_target,$(2))
792$(call gb_CObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
793$(call gb_CObject_get_target,$(2)) : T_CFLAGS += $(3)
794
795ifeq ($(gb_FULLDEPS),$(true))
796$(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS += $(2)
797$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CObject_get_dep_target,$(2))
798endif
799
800endef
801
802define gb_LinkTarget_add_cxxobject
803$(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
804$(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
805
806$(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
807$(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
808$(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
809
810ifeq ($(gb_FULLDEPS),$(true))
811$(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS += $(2)
812$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxObject_get_dep_target,$(2))
813endif
814
815endef
816
817define gb_LinkTarget_add_objcxxobject
818$(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
819$(call gb_LinkTarget_get_clean_target,$(1)) : OBJCXXOBJECTS += $(2)
820
821$(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCxxObject_get_target,$(2))
822$(call gb_ObjCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
823$(call gb_ObjCxxObject_get_target,$(2)) : T_OBJCXXFLAGS += $(3)
824
825ifeq ($(gb_FULLDEPS),$(true))
826$(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS += $(2)
827$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCxxObject_get_dep_target,$(2))
828endif
829
830endef
831
832define gb_LinkTarget_add_generated_cobject
833$(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS += $(2)
834$(call gb_LinkTarget_get_clean_target,$(1)) : GENCOBJECTS += $(2)
835
836$(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCObject_get_target,$(2))
837$(call gb_GenCObject_get_source,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
838$(call gb_GenCObject_get_target,$(2)) : T_CFLAGS += $(3)
839
840ifeq ($(gb_FULLDEPS),$(true))
841$(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS += $(2)
842$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCObject_get_dep_target,$(2))
843endif
844
845endef
846
847define gb_LinkTarget_add_generated_cxx_object
848$(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
849$(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
850
851$(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
852$(call gb_GenCxxObject_get_source,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
853$(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
854
855ifeq ($(gb_FULLDEPS),$(true))
856$(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS += $(2)
857$(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxObject_get_dep_target,$(2))
858endif
859
860endef
861
862define gb_LinkTarget_add_noexception_object
863$(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_NOEXCEPTIONFLAGS))
864endef
865
866define gb_LinkTarget_add_exception_object
867$(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS))
868endef
869
870define gb_LinkTarget_add_asmobjects
871$(foreach obj,$(2),$(call gb_LinkTarget_add_asmobject,$(1),$(obj),$(3)))
872endef
873
874define gb_LinkTarget_add_cobjects
875$(foreach obj,$(2),$(call gb_LinkTarget_add_cobject,$(1),$(obj),$(3)))
876endef
877
878define gb_LinkTarget_add_cxxobjects
879$(foreach obj,$(2),$(call gb_LinkTarget_add_cxxobject,$(1),$(obj),$(3)))
880endef
881
882define gb_LinkTarget_add_objcxxobjects
883$(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3)))
884endef
885
886define gb_LinkTarget_add_noexception_objects
887$(foreach obj,$(2),$(call gb_LinkTarget_add_noexception_object,$(1),$(obj)))
888endef
889
890define gb_LinkTarget_add_exception_objects
891$(foreach obj,$(2),$(call gb_LinkTarget_add_exception_object,$(1),$(obj)))
892endef
893
894define gb_LinkTarget_add_generated_cobjects
895$(foreach obj,$(2),$(call gb_Linktarget_add_generated_cobject,$(1),$(obj),$(3)))
896endef
897
898define gb_LinkTarget_add_generated_exception_object
899$(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS))
900endef
901
902define gb_LinkTarget_add_generated_exception_objects
903$(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj)))
904endef
905
906define gb_LinkTarget_set_targettype
907$(call gb_LinkTarget_get_target,$(1)) \
908$(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE := $(2)
909endef
910
911define gb_LinkTarget_set_versionmap
912$(call gb_LinkTarget_get_target,$(1)) \
913$(call gb_LinkTarget_get_dep_target,$(1)) : VERSIONMAP := $(2)
914endef
915
916define gb_LinkTarget_set_dlltarget
917$(call gb_LinkTarget_get_clean_target,$(1)) \
918$(call gb_LinkTarget_get_target,$(1)) : DLLTARGET := $(2)
919endef
920
921define gb_LinkTarget_set_auxtargets
922$(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS := $(2)
923endef
924
925define gb_LinkTarget__add_internal_headers
926$(call gb_LinkTarget_get_headers_target,$(1)) : $(2)
927$(2) :|	$(call gb_LinkTarget_get_external_headers_target,$(1))
928
929endef
930
931define gb_LinkTarget_add_package_headers
932$(foreach package,$(2),$(call gb_LinkTarget__add_internal_headers,$(1),$(call gb_Package_get_target,$(package))))
933$(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach package,$(2),$(call gb_Package_get_clean_target,$(package)))
934
935endef
936
937define gb_LinkTarget_add_sdi_headers
938$(call gb_LinkTarget__add_internal_headers,$(1),$(foreach sdi,$(2),$(call gb_SdiTarget_get_target,$(sdi))))
939$(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_clean_target,$(sdi)))
940endef
941
942define gb_LinkTarget__add_precompiled_header_impl
943$(call gb_LinkTarget__add_internal_headers,$(1),$(call gb_PrecompiledHeader_get_target,$(3)))
944$(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_PrecompiledHeader_get_clean_target,$(3))
945$(call gb_PrecompiledHeader_get_target,$(3)) : $(2).cxx
946
947$(call gb_LinkTarget__add_internal_headers,$(1),$(call gb_NoexPrecompiledHeader_get_target,$(3)))
948$(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_NoexPrecompiledHeader_get_clean_target,$(3))
949$(call gb_NoexPrecompiledHeader_get_target,$(3)) : $(2).cxx
950
951$(call gb_LinkTarget_get_target,$(1)) : PCH_NAME := $(3)
952$(call gb_LinkTarget_get_target,$(1)) : PCHOBJS = $(call gb_PrecompiledHeader_get_target,$(3)).obj $(call gb_NoexPrecompiledHeader_get_target,$(3)).obj
953
954$(call gb_LinkTarget_get_headers_target,$(1)) \
955$(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS = $$(DEFS)
956ifeq ($(gb_FULLDEPS),$(true))
957-include \
958	$(call gb_PrecompiledHeader_get_dep_target,$(3)) \
959	$(call gb_NoexPrecompiledHeader_get_dep_target,$(3))
960$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_NAME := $(3)
961$(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS = $$(DEFS)
962endif
963
964endef
965
966define gb_LinkTarget_add_precompiled_header
967ifeq ($(gb_ENABLE_PCH),$(true))
968$(call gb_LinkTarget__add_precompiled_header_impl,$(1),$(2),$(notdir $(2)))
969endif
970
971endef
972
973# this forwards to functions that must be defined in RepositoryExternal.mk.
974# $(call gb_LinkTarget_use_external,library,external)
975define gb_LinkTarget_use_external
976$(eval $(if $(value gb_LinkTarget__use_$(2)),\
977  $(call gb_LinkTarget__use_$(2),$(1)),\
978  $(error gb_LinkTarget_use_external: unknown external: $(2))))
979endef
980
981# $(call gb_LinkTarget_use_externals,library,externals)
982gb_LinkTarget_use_externals = \
983 $(foreach external,$(2),$(call gb_LinkTarget_use_external,$(1),$(external)))
984
985
986# vim: set noet sw=4 ts=4:
987