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