bump product version to 4.2.0.1
[LibreOffice.git] / solenv / gbuild / LinkTarget.mk
blob3d3ac6d231afefbf19d7308e3932b5463ceefeb3
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #the following user-defined variables are supported:
21 # YACCFLAGS
22 # LEXFLAGS
23 # CPPFLAGS
24 # CFLAGS
25 # CXXFLAGS
26 # OBJCFLAGS
27 # OBJCXXFLAGS
28 # LDFLAGS
30 # enable if: no "-TARGET" defined AND [module is enabled OR "TARGET" defined]
31 gb_LinkTarget__debug_enabled = \
32 $(and $(if $(filter -$(1),$(ENABLE_DEBUGINFO_FOR)),,$(true)),\
33 $(or $(gb_Module_CURRENTMODULE_DEBUG_ENABLED),\
34 $(filter $(1),$(ENABLE_DEBUGINFO_FOR))))
36 # debug flags, if ENABLE_DEBUG is set and the LinkTarget is named
37 # in the list of libraries of ENABLE_DEBUGINFO_FOR
38 gb_LinkTarget__get_debugcflags=$(if $(call gb_LinkTarget__debug_enabled,$(1)),$(gb_COMPILERNOOPTFLAGS) $(gb_DEBUG_CFLAGS),$(gb_COMPILEROPTFLAGS))
39 gb_LinkTarget__get_debugcxxflags=$(if $(call gb_LinkTarget__debug_enabled,$(1)),$(gb_COMPILERNOOPTFLAGS) $(gb_DEBUG_CFLAGS) $(gb_DEBUG_CXXFLAGS),$(gb_COMPILEROPTFLAGS))
41 # similar for LDFLAGS, use linker optimization flags in non-debug case,
42 # but moreover strip debug from libraries for which debuginfo is not wanted
43 # (some libraries reuse .o files from other libraries, notably unittests)
44 gb_LinkTarget__get_stripldflags=$(if $(strip $(CFLAGS)$(CXXFLAGS)$(OBJCFLAGS)$(OBJCXXFLAGS)$(LDFLAGS)),,$(gb_LINKERSTRIPDEBUGFLAGS))
45 gb_LinkTarget__get_debugldflags=$(if $(call gb_LinkTarget__debug_enabled,$(1)),,$(gb_LINKEROPTFLAGS) $(call gb_LinkTarget__get_stripldflags,$(1)))
47 # generic cflags/cxxflags to use (optimization flags, debug flags)
48 # user supplied CFLAGS/CXXFLAGS override default debug/optimization flags
49 # call gb_LinkTarget__get_cflags,linktargetmakefilename
50 gb_LinkTarget__get_cflags=$(if $(CFLAGS),$(CFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
51 gb_LinkTarget__get_objcflags=$(if $(OBJCFLAGS),$(OBJCFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
52 gb_LinkTarget__get_cxxflags=$(if $(CXXFLAGS),$(CXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
53 gb_LinkTarget__get_objcxxflags=$(if $(OBJCXXFLAGS),$(OBJCXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
54 # call gb_LinkTarget__get_ldflags,linktargetmakefilename
55 gb_LinkTarget__get_ldflags=$(if $(LDFLAGS),$(LDFLAGS),$(call gb_LinkTarget__get_debugldflags,$(1)))
57 gb_LinkTarget_LAYER_LINKPATHS := \
58 URELIB:URELIB. \
59 UREBIN:URELIB. \
60 SDKBIN:URELIB. \
61 OOO:URELIB+OOO. \
62 SHLXTHDL:. \
63 OXT:OXT. \
64 NONE:URELIB+OOO+NONE. \
67 # Overview of dependencies and tasks of LinkTarget
69 # target task depends on
70 # LinkTarget linking AsmObject CObject CxxObject GenCObject GenCxxObject ObjCObject ObjCxxObject
71 # LinkTarget/headers
72 # LinkTarget/dep joined dep file AsmObject/dep CObject/dep CxxObject/dep GenCObject/dep GenCxxObject/dep ObjCObject/dep ObjCxxObject/dep
73 # | LinkTarget/headers
74 # LinkTarget/headers all headers available
75 # including own generated
76 # PCH precompiled headers LinkTarget/headers
77 # CObject plain c compile | LinkTarget/headers
78 # CxxObject c++ compile | LinkTarget/headers PCH
79 # GenCObject plain c compile from | LinkTarget/headers
80 # generated source
81 # GenCxxObject C++ compile from | LinkTarget/headers PCH
82 # generated source
83 # ObjCObject objective c compile | LinkTarget/headers
84 # ObjCxxObject objective c++ compile | LinkTarget/headers
86 # AsmObject asm compile | LinkTarget
88 # CObject/dep dependencies these targets generate empty dep files
89 # CxxObject/dep dependencies that are populated upon compile
90 # GenCObject/dep dependencies
91 # GenCxxObject/dep dependencies
92 # ObjCObject/dep dependencies
93 # ObjCxxObject/dep dependencies
94 # AsmObject/dep dependencies
96 # LinkTarget/headers means gb_LinkTarget_get_headers_target etc.
97 # dependencies prefixed with | are build-order only dependencies
100 # check that objects are only linked into one link target:
101 # multiple linking may cause problems because different link targets may
102 # require different compiler flags
103 define gb_Object__owner
104 $$(if $$(OBJECTOWNER),\
105 $$(call gb_Output_error,fdo#47246: $(1) is linked in by $$(OBJECTOWNER) $(2)))$(2)
106 endef
108 # For every object there is a dep file (if gb_FULLDEPS is active).
109 # The dep file depends on the object: the Object__command also updates the
110 # dep file as a side effect.
111 # In the dep file rule just touch it so it's newer than the object.
113 ifneq ($(FORCE_COMPILE_ALL),)
114 # This one only exists to force .c/.cxx "rebuilds" when running a compiler tool.
115 .PHONY: force_compile_all_target
116 force_compile_all_target:
117 gb_FORCE_COMPILE_ALL_TARGET := force_compile_all_target
118 endif
120 # CObject class
122 gb_CObject_get_source = $(1)/$(2).c
123 # defined by platform
124 # gb_CObject__command
126 ifneq ($(COMPILER_PLUGIN_TOOL),)
127 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
128 $(call gb_CObject__tool_command,$*,$<)
129 else
130 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%)
131 $(call gb_CObject__command,$@,$*,$<,$(call gb_CObject_get_dep_target,$*))
132 endif
134 # Note: if the *Object_dep_target does not exist it will be created by
135 # concat-deps as PHONY
136 ifeq ($(gb_FULLDEPS),$(true))
137 $(call gb_CObject_get_dep_target,%) :
138 $(if $(wildcard $@),touch $@)
140 endif
143 # CxxObject class
145 gb_CxxObject_get_source = $(1)/$(2).cxx
146 # defined by platform
147 # gb_CxxObject__command
149 # Only enable PCH if the PCH_CXXFLAGS and the PCH_DEFS (from the linktarget)
150 # are the same as the T_CXXFLAGS and DEFS we want to use for this object. This
151 # should usually be the case. The DEFS/T_CXXFLAGS would have to be manually
152 # overridden for one object file for them to differ. PCH_CXXFLAGS/PCH_DEFS
153 # should never be overridden on an object -- they should be the same as for the
154 # whole linktarget. In general it should be cleaner to use a static library
155 # compiled with different flags and link that in rather than mixing different
156 # flags in one linktarget.
157 define gb_CxxObject__set_pchflags
158 ifeq ($(gb_ENABLE_PCH),$(true))
159 ifneq ($(strip $$(PCH_NAME)),)
160 ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)),$$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
161 $$@ : PCHFLAGS := $$(call gb_PrecompiledHeader_get_enableflags,$$(PCH_NAME))
162 else
163 $$(info No precompiled header available for $$*.cxx .)
164 $$(info precompiled header flags : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)))
165 $$(info . object flags : $$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
166 $$@ : PCHFLAGS :=
167 endif
168 endif
169 endif
170 endef
172 ifneq ($(COMPILER_PLUGIN_TOOL),)
173 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
174 $(call gb_CxxObject__tool_command,$*,$<)
175 else
176 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
177 $(eval $(gb_CxxObject__set_pchflags))
178 $(call gb_CxxObject__command,$@,$*,$<,$(call gb_CxxObject_get_dep_target,$*))
179 endif
181 ifeq ($(gb_FULLDEPS),$(true))
182 $(dir $(call gb_CxxObject_get_dep_target,%)).dir :
183 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
185 $(dir $(call gb_CxxObject_get_dep_target,%))%/.dir :
186 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
188 $(call gb_CxxObject_get_dep_target,%) :
189 $(if $(wildcard $@),touch $@,\
190 $(eval $(gb_CxxObject__set_pchflags)))
192 endif
195 # GenCObject class
197 gb_GenCObject_get_source = $(WORKDIR)/$(1).c
198 # defined by platform
199 # gb_CObject__command
201 $(call gb_GenCObject_get_target,%) :
202 test -f $(call gb_GenCObject_get_source,$*) || (echo "Missing generated source file $(call gb_GenCObject_get_source,$*)" && false)
203 $(call gb_CObject__command,$@,$*,$(call gb_GenCObject_get_source,$*),$(call gb_GenCObject_get_dep_target,$*))
205 ifeq ($(gb_FULLDEPS),$(true))
206 $(call gb_GenCObject_get_dep_target,%) :
207 $(if $(wildcard $@),touch $@)
209 endif
212 # GenCxxObject class
214 gb_GenCxxObject_get_source = $(WORKDIR)/$(1).$(gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(2)))
215 # defined by platform
216 # gb_CxxObject__command
218 $(call gb_GenCxxObject_get_target,%) :
219 test -f $(GEN_CXX_SOURCE) || (echo "Missing generated source file $(GEN_CXX_SOURCE)" && false)
220 $(eval $(gb_CxxObject__set_pchflags))
221 $(call gb_CxxObject__command,$@,$*,$(GEN_CXX_SOURCE),$(call gb_GenCxxObject_get_dep_target,$*))
223 ifeq ($(gb_FULLDEPS),$(true))
224 $(call gb_GenCxxObject_get_dep_target,%) :
225 $(if $(wildcard $@),touch $@,\
226 $(eval $(gb_CxxObject__set_pchflags)))
228 endif
231 # YaccTarget class
233 # XXX: This is more complicated than necessary, but we cannot just use
234 # the generated C++ file as the main target, because we need to let the
235 # header depend on that to ensure the header is present before anything
236 # tries to use it.
238 gb_YaccTarget_get_source = $(1)/$(2).y
239 # defined by platform
240 # gb_YaccTarget__command(grammar-file, stem-for-message, source-target, include-target)
242 .PHONY : $(call gb_YaccTarget_get_clean_target,%)
243 $(call gb_YaccTarget_get_clean_target,%) :
244 $(call gb_Output_announce,$*,$(false),YAC,3)
245 $(call gb_Helper_abbreviate_dirs,\
246 rm -f $(call gb_YaccTarget_get_grammar_target,$*) $(call gb_YaccTarget_get_header_target,$*) $(call gb_YaccTarget_get_target,$*))
248 $(call gb_YaccTarget_get_target,%) : $(call gb_YaccTarget_get_source,$(SRCDIR),%)
249 $(call gb_YaccTarget__command,$<,$*,$@,$(call gb_YaccTarget_get_header_target,$*),$(call gb_YaccTarget_get_grammar_target,$*))
251 # call gb_YaccTarget_YaccTarget,yacctarget
252 define gb_YaccTarget_YaccTarget
253 $(call gb_YaccTarget_get_grammar_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
254 touch $$@
255 $(call gb_YaccTarget_get_header_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
256 touch $$@
258 endef
260 gb_YACC := bison
263 # LexTarget class
265 gb_LexTarget_get_source = $(1)/$(2).l
267 .PHONY : $(call gb_LexTarget_get_clean_target,%)
268 $(call gb_LexTarget_get_clean_target,%) :
269 $(call gb_Output_announce,$*,$(false),LEX,3)
270 $(call gb_Helper_abbreviate_dirs,\
271 rm -f $(call gb_LexTarget_get_scanner_target,$*) $(call gb_LexTarget_get_target,$*))
273 $(call gb_LexTarget_get_target,%) : $(call gb_LexTarget_get_source,$(SRCDIR),%)
274 $(call gb_LexTarget__command,$<,$*,$@,$(call gb_LexTarget_get_scanner_target,$*))
276 # gb_LexTarget_LexTarget(scanner-file)
277 define gb_LexTarget_LexTarget
278 $(call gb_LexTarget_get_scanner_target,$(1)) : $(call gb_LexTarget_get_target,$(1))
279 touch $$@
281 endef
283 # gb_LexTarget__command(scanner-file, stem-for-message, done-pseudo-target, source-target)
284 define gb_LexTarget__command
285 $(call gb_Output_announce,$(2),$(true),LEX,3)
286 $(call gb_Helper_abbreviate_dirs,\
287 mkdir -p $(dir $(3)) && \
288 $(FLEX) $(T_LEXFLAGS) -o$(4) $(1) && touch $(3) )
289 endef
292 # ObjCxxObject class
295 gb_ObjCxxObject_get_source = $(1)/$(2).mm
296 # defined by platform
297 # gb_ObjCxxObject__command
299 ifneq ($(COMPILER_PLUGIN_TOOL),)
300 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
301 $(call gb_ObjCxxObject__tool_command,$*,$<)
302 else
304 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%)
305 $(call gb_ObjCxxObject__command,$@,$*,$<,$(call gb_ObjCxxObject_get_dep_target,$*))
307 ifeq ($(gb_FULLDEPS),$(true))
308 $(call gb_ObjCxxObject_get_dep_target,%) :
309 $(if $(wildcard $@),touch $@)
311 endif
312 endif
315 # ObjCObject class
318 gb_ObjCObject_get_source = $(1)/$(2).m
319 # defined by platform
320 # gb_ObjCObject__command
322 ifneq ($(COMPILER_PLUGIN_TOOL),)
323 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
324 $(call gb_ObjCObject__tool_command,$*,$<)
325 else
327 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%)
328 $(call gb_ObjCObject__command,$@,$*,$<,$(call gb_ObjCObject_get_dep_target,$*))
330 ifeq ($(gb_FULLDEPS),$(true))
331 $(call gb_ObjCObject_get_dep_target,%) :
332 $(if $(wildcard $@),touch $@)
334 endif
335 endif
338 # AsmObject class
340 # defined by platform
341 # gb_AsmObject_get_source (.asm on Windows, .s elsewhere)
342 # gb_AsmObject__command
344 $(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%)
345 $(call gb_AsmObject__command,$@,$*,$<,$(call gb_AsmObject_get_dep_target,$*))
347 ifeq ($(gb_FULLDEPS),$(true))
348 $(dir $(call gb_AsmObject_get_dep_target,%)).dir :
349 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
351 $(dir $(call gb_AsmObject_get_dep_target,%))%/.dir :
352 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
354 $(call gb_AsmObject_get_dep_target,%) :
355 $(if $(wildcard $@),touch $@)
357 endif
360 # LinkTarget class
362 gb_LinkTarget_DEFAULTDEFS := $(gb_GLOBALDEFS)
364 define gb_LinkTarget_rtl_defs
365 $(if $(filter-out sal salhelper cppu cppuhelper odk, $(gb_Module_CURRENTMODULE_NAME)), -DRTL_USING)
366 endef
368 # defined by platform
369 # gb_LinkTarget_CXXFLAGS
370 # gb_LinkTarget_LDFLAGS
371 # gb_LinkTarget_INCLUDE
373 .PHONY : $(WORKDIR)/Clean/LinkTarget/%
374 $(WORKDIR)/Clean/LinkTarget/% :
375 $(call gb_Output_announce,$*,$(false),LNK,4)
376 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
377 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
378 $(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
379 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
380 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
381 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
382 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object))) \
383 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
384 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
385 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
386 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object))) \
387 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
388 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
389 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
390 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
391 $(call gb_LinkTarget_get_target,$(LINKTARGET)) \
392 $(call gb_LinkTarget_get_dep_target,$(LINKTARGET)) \
393 $(call gb_LinkTarget_get_headers_target,$(LINKTARGET)) \
394 $(call gb_LinkTarget_get_objects_list,$(LINKTARGET)) \
395 $(ILIBTARGET) \
396 $(AUXTARGETS)) && \
397 cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -fr && \
398 rm -f $${RESPONSEFILE}
401 # cat the deps of all objects in one file, then we need only open that one file
402 # call gb_LinkTarget__command_dep,dep_target,linktargetname
403 define gb_LinkTarget__command_dep
404 $(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
405 $(call gb_Helper_abbreviate_dirs,\
406 mkdir -p $(dir $(1)) && \
407 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
408 $(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
409 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
410 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object)))\
411 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
412 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object)))\
413 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
414 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
415 ) && \
416 $(call gb_Executable_get_command,concat-deps) $${RESPONSEFILE} > $(1)) && \
417 rm -f $${RESPONSEFILE}
419 endef
421 # call gb_LinkTarget__command_objectlist,linktarget
422 define gb_LinkTarget__command_objectlist
423 TEMPFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
424 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
425 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
426 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
427 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
428 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
429 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
430 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
431 $(PCHOBJS)) && \
432 $(if $(EXTRAOBJECTLISTS),cat $(EXTRAOBJECTLISTS) >> $${TEMPFILE} && ) \
433 mv $${TEMPFILE} $(1)
435 endef
437 $(WORKDIR)/LinkTarget/%/.dir :
438 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
440 # Target for the .exports of the shared library, to speed up incremental build.
441 # This deliberately does nothing if the file exists; the file is actually
442 # written in gb_LinkTarget__command_dynamiclink.
443 # Put this pattern rule here so it overrides the one below.
444 # (this is rather ugly: because of % the functions cannot be used)
445 $(WORKDIR)/LinkTarget/Library/%.exports :
446 $(if $(wildcard $@),,mkdir -p $(dir $@) && touch $@)
448 # This recipe actually also builds the dep-target as a side-effect, which
449 # is an optimization to reduce incremental build time.
450 # (with exception for concat-dep executable itself which does not exist yet...)
451 $(WORKDIR)/LinkTarget/% : $(gb_Helper_MISCDUMMY)
452 $(call gb_LinkTarget__command_impl,$@,$*)
454 # call gb_LinkTarget__make_installed_rule,linktarget
455 define gb_LinkTarget__make_installed_rule
456 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_LinkTarget_get_headers_target,$(1))
457 $$(call gb_LinkTarget__command_impl,$(call gb_LinkTarget_get_target,$(1)),$(call gb_LinkTarget__get_workdir_linktargetname,$(1)))
459 endef
461 # it's not possible to use a pattern rule for files in INSTDIR because
462 # it would inevitably conflict with the pattern rule for Package
463 # (especially since external libraries are delivered via Package)
464 # call gb_LinkTarget__command_impl,linktargettarget,linktargetname
465 define gb_LinkTarget__command_impl
466 $(if $(gb_FULLDEPS),\
467 $(if $(findstring concat-deps,$(2)),,\
468 $(call gb_LinkTarget__command_dep,$(call gb_LinkTarget_get_dep_target,$(2)),$(2))))
469 $(if $(filter $(2),$(foreach lib,$(gb_MERGEDLIBS) $(gb_URELIBS),$(call gb_Library__get_workdir_linktargetname,$(lib)))),\
470 $(if $(filter $(true),$(call gb_LinkTarget__is_build_lib,$(2))),\
471 $(call gb_LinkTarget__command,$(1),$(2)),\
472 mkdir -p $(dir $(1)) && echo invalid > $(1) \
473 $(if $(SOVERSIONSCRIPT),&& echo invalid > $(WORKDIR)/LinkTarget/$(2))),\
474 $(call gb_LinkTarget__command,$(1),$(2)))
475 $(call gb_LinkTarget__command_objectlist,$(WORKDIR)/LinkTarget/$(2).objectlist)
476 endef
478 ifeq ($(gb_FULLDEPS),$(true))
479 $(call gb_LinkTarget_get_dep_target,%) : $(call gb_Executable_get_runtime_dependencies,concat-deps)
480 $(call gb_LinkTarget__command_dep,$@,$*)
481 endif
483 # Ok, this is some dark voodoo: When declaring a linktarget with
484 # gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
485 # target. When the rule for the headertarget is executed and SELF does not
486 # match the target name, we are depending on a linktarget that was never
487 # declared. In a full build exclusively in gbuild that should never happen.
488 define gb_LinkTarget__get_headers_check
489 ifneq ($$(SELF),$$*)
490 $$(eval $$(call gb_Output_error,used LinkTarget $$* not defined))
491 endif
492 $$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, touch $$@)
494 endef
496 $(WORKDIR)/Headers/%/.dir :
497 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
499 # sadly because of the subdirectories can't have pattern deps on .dir here
500 $(WORKDIR)/Headers/% :
501 $(eval $(gb_LinkTarget__get_headers_check))
502 $(COMMAND)
504 # Explanation of some of the targets:
505 # - gb_LinkTarget_get_headers_target is the target that guarantees all headers
506 # from the linked against libraries and the linktargets own generated headers
507 # are generated.
508 # - gb_LinkTarget_get_target links the objects into a file in WORKDIR.
509 # gb_LinkTarget_get_target depends on gb_LinkTarget_get_headers_target.
510 # gb_LinkTarget_get_target depends additionally on the objects, which in turn
511 # depend build-order only on the gb_LinkTarget_get_headers_target. The build
512 # order-only dependency ensures all headers to be there for compiling and
513 # dependency generation without causing all objects to be rebuild when one
514 # header changes. Only the ones with an explicit dependency in their generated
515 # dependency file will be rebuild.
517 # gb_LinkTarget_get_target is the target that links the objects into a file in
518 # WORKDIR
519 # Explanation of some of the variables:
520 # - AUXTARGETS are the additionally generated files that need to be cleaned out
521 # on clean.
522 # - PCH_CXXFLAGS and PCH_DEFS are the flags that the precompiled headers will
523 # be compiled with. They should never be overridden in a single object
524 # files.
525 # - TARGETTYPE is the type of linktarget as some platforms need very different
526 # command to link different targettypes.
527 # - LIBRARY_X64 is only relevent for building a x64 library on windows.
529 # Since most variables are set on the linktarget and not on the object, the
530 # object learns about these setting via GNU makes scoping of target variables.
531 # Therefore it is important that objects are only directly depended on by the
532 # linktarget. This for example means that you cannot build a single object
533 # alone, because then you would directly depend on the object.
535 # A note about flags: because the overriding the global variables with a target
536 # local variable of the same name is considered obscure, the target local
537 # variables have a T_ prefix.
539 # call gb_LinkTarget_LinkTarget,linktarget,linktargetmakefilename,layer
540 define gb_LinkTarget_LinkTarget
541 $(call gb_LinkTarget_get_clean_target,$(1)) : LINKTARGET := $(1)
542 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
543 $(call gb_LinkTarget_get_headers_target,$(1)) : SELF := $(call gb_LinkTarget__get_workdir_linktargetname,$(1))
544 $(call gb_LinkTarget_get_headers_target,$(1)) : \
545 | $(dir $(call gb_LinkTarget_get_headers_target,$(1))).dir \
546 $(dir $(call gb_LinkTarget_get_target,$(1))).dir \
547 $(dir $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1))).dir
548 $(call gb_LinkTarget_get_target,$(1)) : ILIBTARGET :=
549 $(call gb_LinkTarget_get_clean_target,$(1)) \
550 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
551 $(call gb_LinkTarget_get_clean_target,$(1)) \
552 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
553 $(call gb_LinkTarget_get_clean_target,$(1)) \
554 $(call gb_LinkTarget_get_target,$(1)) : YACCOBJECT :=
555 $(call gb_LinkTarget_get_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
556 $(call gb_LinkTarget_get_clean_target,$(1)) \
557 $(call gb_LinkTarget_get_target,$(1)) : LEXOBJECT :=
558 $(call gb_LinkTarget_get_target,$(1)) : T_LEXFLAGS := $$(gb_LinkTarget_LEXFLAGS) $(LEXFLAGS)
559 $(call gb_LinkTarget_get_clean_target,$(1)) \
560 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
561 $(call gb_LinkTarget_get_clean_target,$(1)) \
562 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
563 $(call gb_LinkTarget_get_clean_target,$(1)) \
564 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS :=
565 $(call gb_LinkTarget_get_clean_target,$(1)) \
566 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS :=
567 $(call gb_LinkTarget_get_clean_target,$(1)) \
568 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS :=
569 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
570 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS_APPEND :=
571 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
572 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS_APPEND :=
573 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
574 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
575 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND :=
576 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
577 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND :=
578 $(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $$(call gb_LinkTarget_rtl_defs,$(1)) $(CPPFLAGS)
579 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
580 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
581 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $$(gb_LinkTarget_LDFLAGS) $(call gb_LinkTarget_get_linksearchpath_for_layer,$(3)) $(call gb_LinkTarget__get_ldflags,$(2))
582 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS :=
583 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS :=
584 $(call gb_LinkTarget_get_target,$(1)) : T_LIBS :=
585 $(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE :=
586 $(call gb_LinkTarget_get_target,$(1)) : LIBRARY_X64 :=
587 $(call gb_LinkTarget_get_target,$(1)) : PCH_NAME :=
588 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS :=
589 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJEX :=
590 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJNOEX :=
591 $(call gb_LinkTarget_get_target,$(1)) : PDBFILE :=
592 $(call gb_LinkTarget_get_target,$(1)) : TARGETGUI :=
593 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS :=
594 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES :=
595 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY :=
596 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS :=
597 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT :=
599 ifeq ($(gb_FULLDEPS),$(true))
600 -include $(call gb_LinkTarget_get_dep_target,$(1))
601 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
602 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
603 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS :=
604 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
605 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS :=
606 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
607 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
608 $(call gb_LinkTarget_get_dep_target,$(1)) : YACCOBJECTS :=
609 endif
611 gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(1)) := cxx
613 # installed linktargets need a rule to build!
614 $(if $(findstring $(INSTDIR),$(1)),$(call gb_LinkTarget__make_installed_rule,$(1)))
616 endef
618 # call gb_LinkTarget_set_soversion_script,linktarget,soversionscript
619 define gb_LinkTarget_set_soversion_script
620 $(call gb_LinkTarget_get_target,$(1)) : $(2)
621 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT := $(2)
623 endef
625 # call gb_LinkTarget_add_defs,linktarget,defines
626 define gb_LinkTarget_add_defs
627 $(call gb_LinkTarget_get_target,$(1)) : DEFS += $(2)
628 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS += $(2)
629 endef
631 # call gb_LinkTarget_add_cflags,linktarget,cflags
632 define gb_LinkTarget_add_cflags
633 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS_APPEND += $(2)
634 endef
636 # call gb_LinkTarget_add_cxxflags,linktarget,cxxflags
637 define gb_LinkTarget_add_cxxflags
638 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS_APPEND += $(2)
639 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS += $(2)
640 endef
642 # call gb_LinkTarget_add_objcxxflags,linktarget,objcxxflags
643 define gb_LinkTarget_add_objcxxflags
644 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND += $(2)
645 endef
647 # call gb_LinkTarget_add_objcflags,linktarget,objcflags
648 define gb_LinkTarget_add_objcflags
649 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND += $(2)
651 endef
653 # call gb_LinkTarget__add_include,linktarget,includes
654 define gb_LinkTarget__add_include
655 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(2)
657 endef
659 # call gb_LinkTarget__check_srcdir_paths,linktarget,includepaths
660 define gb_LinkTarget__check_srcdir_paths
661 $(if $(filter-out $(wildcard $(2)),$(2)),\
662 $(call gb_Output_error,gb_LinkTarget_set_include: include paths $(filter-out $(wildcard $(2)),$(2)) do not exist) \
664 endef
666 # call gb_LinkTarget_set_include,linktarget,includes
667 define gb_LinkTarget_set_include
668 $(call gb_LinkTarget__check_srcdir_paths,$(1),\
669 $(patsubst -I%,%,$(filter -I$(SRCDIR)/%,$(filter-out -I$(WORKDIR)/%,$(2)))))
670 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2)
672 endef
674 # call gb_LinkTarget_add_ldflags,linktarget,ldflags
675 define gb_LinkTarget_add_ldflags
676 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS += $(2)
678 endef
680 # real use in RepositoryExternal.mk
681 # call gb_LinkTarget_set_ldflags,linktarget,ldflags
682 define gb_LinkTarget_set_ldflags
683 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $(2)
685 endef
687 # call gb_LinkTarget_add_libs,linktarget,libs
688 define gb_LinkTarget_add_libs
689 $(call gb_LinkTarget_get_target,$(1)) : T_LIBS += $(2)
691 endef
693 # remove platform specific standard libraries for linktarget $(1)
694 # assumption is that adding these standard libs is always useful, but in very
695 # exceptional cases this disable method may be used
696 # call gb_LinkTarget_disable_standard_system_libs,linktarget
697 define gb_LinkTarget_disable_standard_system_libs
698 $(call gb_LinkTarget_get_target,$(1)) : T_LIBS := $$(filter-out $$(gb_STDLIBS),$$(T_LIBS))
700 endef
702 # call gb_LinkTarget__use_api,linktarget,api
703 define gb_LinkTarget__use_api
704 $(call gb_LinkTarget_get_headers_target,$(1)) : $(call gb_UnoApiHeadersTarget_get_target,$(2))
705 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_dir,$(2)))
707 endef
709 # call gb_LinkTarget_use_api,linktarget,apis
710 define gb_LinkTarget_use_api
711 $(foreach api,$(2),$(call gb_LinkTarget__use_api,$(1),$(api)))
713 endef
715 # call gb_LinkTarget_use_udk_api,linktarget
716 define gb_LinkTarget_use_udk_api
717 $(call gb_LinkTarget__use_api,$(1),udkapi)
718 endef
720 # call gb_LinkTarget_use_sdk_api,linktarget
721 define gb_LinkTarget_use_sdk_api
722 $(call gb_LinkTarget__use_api,$(1),udkapi)
723 $(call gb_LinkTarget__use_api,$(1),offapi)
724 endef
726 # call gb_LinkTarget__use_internal_api_one,linktarget,api,apiprefix
727 define gb_LinkTarget__use_internal_api_one
728 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
729 $(call gb_UnoApiHeadersTarget_get_$(3)target,$(2))
730 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_$(3)dir,$(2)))
732 endef
734 # call gb_LinkTarget__use_internal_api,linktarget,apis,apiprefix
735 define gb_LinkTarget__use_internal_api
736 $(foreach api,$(2),$(call gb_LinkTarget__use_internal_api_one,$(1),$(api),$(3)))
738 endef
740 # call gb_LinkTarget_use_internal_api,linktarget,api
741 define gb_LinkTarget_use_internal_api
742 $(call gb_LinkTarget__use_internal_api,$(1),$(2))
744 endef
746 # call gb_LinkTarget_use_internal_bootstrap_api,linktarget,api
747 define gb_LinkTarget_use_internal_bootstrap_api
748 $(call gb_LinkTarget__use_internal_api,$(1),$(2),bootstrap_)
750 endef
752 # call gb_LinkTarget_use_internal_comprehensive_api,linktarget,api
753 define gb_LinkTarget_use_internal_comprehensive_api
754 $(call gb_LinkTarget__use_internal_api,$(1),$(2),comprehensive_)
756 endef
758 define gb_PrintDeps_info
759 $(info LibraryDep: $(1) links against $(2))
760 endef
762 # avoid problem when a module is built partially but other modules that define
763 # needed libraries is not yet built: prevent invocation of pattern rule
764 # for library with invalid parameters by depending on the header target
765 define gb_LinkTarget__lib_dummy_depend
766 $(call gb_Library_get_target,$(1)) :| $(call gb_Library_get_headers_target,$(1))
768 endef
770 # call gb_LinkTarget__use_libraries,linktarget,requestedlibs,actuallibs,linktargetmakefilename
771 define gb_LinkTarget__use_libraries
773 # used by bin/module-deps.pl
774 ifneq ($(ENABLE_PRINT_DEPS),)
775 # exclude libraries in Library_merged Librery_urelibs
776 ifeq ($(filter $(1),$(foreach lib,$(gb_MERGEDLIBS) $(gb_URELIBS),$(call gb_Library_get_linktarget,$(lib)))),)
777 $$(eval $$(call gb_PrintDeps_info,$(4),$(3)))
778 endif
779 endif
781 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(3)
783 # depend on the exports of the library, not on the library itself
784 # for faster incremental builds when the ABI is unchanged
785 $(call gb_LinkTarget_get_target,$(1)) : \
786 $(foreach lib,$(3),$(call gb_Library_get_exports_target,$(lib)))
787 $(call gb_LinkTarget_get_headers_target,$(1)) : \
788 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
789 $(foreach lib,$(2),$(call gb_LinkTarget__lib_dummy_depend,$(lib)))
791 endef
793 # libraries which are merged but need to be built for gb_BUILD_HELPER_TOOLS
794 gb_BUILD_HELPER_LIBS := basegfx \
795 cppu \
796 cppuhelper \
797 reg \
798 sal \
799 salhelper \
800 store \
801 tl \
802 unoidl \
803 xmlreader \
805 # tools libmerged depends on, so they link against gb_BUILD_HELPER_LIBS
806 gb_BUILD_HELPER_TOOLS := cppumaker \
807 rsc \
808 svidl \
809 unoidl-check \
810 unoidl-write \
812 # call gb_LinkTarget__is_build_lib,linktargetname
813 define gb_LinkTarget__is_build_lib
814 $(if $(filter $(call gb_LinkTarget__get_workdir_linktargetname,$(1)),$(foreach lib,$(gb_BUILD_HELPER_LIBS),$(call gb_Library__get_workdir_linktargetname,$(lib)))),$(true),$(false))
815 endef
817 # call gb_LinkTarget__is_build_tool,linktargetname
818 define gb_LinkTarget__is_build_tool
819 $(if $(filter $(call gb_LinkTarget__get_workdir_linktargetname,$(1)),$(foreach exe,$(gb_BUILD_HELPER_TOOLS),$(call gb_Executable__get_workdir_linktargetname,$(exe)))),$(true),$(false))
820 endef
822 # call gb_LinkTarget_use_libraries,linktarget,libs
823 define gb_LinkTarget_use_libraries
824 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
825 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
826 $$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
827 endif
829 ifeq ($(call gb_LinkTarget__is_build_tool,$(1)),$(true))
830 $(call gb_LinkTarget__use_libraries,$(1),$(2),$(2),$(4))
831 else
832 $(call gb_LinkTarget__use_libraries,$(1),$(2),$(strip \
833 $(if $(filter $(gb_MERGEDLIBS),$(2)), \
834 $(if $(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktarget,$(lib)))), \
835 $(filter $(gb_MERGEDLIBS),$(2)), merged)) \
836 $(if $(filter $(gb_URELIBS),$(2)), \
837 $(if $(filter $(1),$(foreach lib,$(gb_URELIBS),$(call gb_Library_get_linktarget,$(lib)))), \
838 $(filter $(gb_URELIBS),$(2)), urelibs)) \
839 $(filter-out $(gb_MERGEDLIBS) $(gb_URELIBS),$(2)) \
840 ),$(4))
841 endif
843 endef
845 # avoid problem when a module is built partially but other modules that define
846 # needed static libraries is not yet built: prevent invocation of pattern rule
847 # for static library with invalid parameters by depending on the header target
848 define gb_LinkTarget__static_lib_dummy_depend
849 $(call gb_StaticLibrary_get_target,$(1)) :| \
850 $(call gb_StaticLibrary_get_headers_target,$(1))
852 endef
854 # for a StaticLibrary, dependent libraries are not actually linked in
855 # call gb_LinkTarget_use_static_libraries,linktarget,staticlibs
856 define gb_LinkTarget_use_static_libraries
857 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $$(if $$(filter-out StaticLibrary,$$(TARGETTYPE)),$(2))
859 $(call gb_LinkTarget_get_target,$(1)) : $(foreach lib,$(2),$(call gb_StaticLibrary_get_target,$(lib)))
860 $(call gb_LinkTarget_get_headers_target,$(1)) : \
861 $(foreach lib,$(2),$(call gb_StaticLibrary_get_headers_target,$(lib)))
862 $(foreach lib,$(2),$(call gb_LinkTarget__static_lib_dummy_depend,$(lib)))
864 endef
866 # call gb_LinkTarget_add_cobject,linktarget,sourcefile,cflags,linktargetmakefilename
867 define gb_LinkTarget_add_cobject
868 $(if $(wildcard $(call gb_CObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_CObject_get_source,$(SRCDIR),$(2)))))
869 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
870 $(call gb_LinkTarget_get_clean_target,$(1)) : COBJECTS += $(2)
872 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CObject_get_target,$(2))
873 $(call gb_CObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
874 $(call gb_CObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
875 $(call gb_CObject_get_target,$(2)) : \
876 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
878 ifeq ($(gb_FULLDEPS),$(true))
879 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS += $(2)
880 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CObject_get_dep_target,$(2))
881 $(call gb_CObject_get_dep_target,$(2)) :| $(dir $(call gb_CObject_get_dep_target,$(2))).dir
882 endif
884 endef
886 # call gb_LinkTarget_add_cxxobject,linktarget,sourcefile,cxxflags,linktargetmakefilename
887 define gb_LinkTarget_add_cxxobject
888 $(if $(wildcard $(call gb_CxxObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_CxxObject_get_source,$(SRCDIR),$(2)))))
889 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
890 $(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
892 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
893 $(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
894 $(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
895 $(call gb_CxxObject_get_target,$(2)) : \
896 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
897 ifeq ($(gb_ENABLE_PCH),$(true))
898 $(call gb_CxxObject_get_target,$(2)) : $(call gb_PrecompiledHeader_get_timestamp,$(call gb_LinkTarget__get_workdir_linktargetname,$(1)))
899 endif
901 ifeq ($(gb_FULLDEPS),$(true))
902 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS += $(2)
903 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxObject_get_dep_target,$(2))
904 $(call gb_CxxObject_get_dep_target,$(2)) :| $(dir $(call gb_CxxObject_get_dep_target,$(2))).dir
905 endif
907 endef
909 # call gb_LinkTarget_add_objcobject,linktarget,sourcefile,objcflags,linktargetmakefilename
910 define gb_LinkTarget_add_objcobject
911 $(if $(wildcard $(call gb_ObjCObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_ObjCObject_get_source,$(SRCDIR),$(2)))))
912 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS += $(2)
913 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCOBJECTS += $(2)
915 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCObject_get_target,$(2))
916 $(call gb_ObjCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
917 $(call gb_ObjCObject_get_target,$(2)) : T_OBJCFLAGS += $(call gb_LinkTarget__get_objcflags,$(4)) $(3)
918 $(call gb_ObjCObject_get_target,$(2)) : \
919 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
921 ifeq ($(gb_FULLDEPS),$(true))
922 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS += $(2)
923 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCObject_get_dep_target,$(2))
924 $(call gb_ObjCObject_get_dep_target,$(2)) :| $(dir $(call gb_ObjCObject_get_dep_target,$(2))).dir
925 endif
927 endef
929 # call gb_LinkTarget_add_objcxxobject,linktarget,sourcefile,objcxxflags,linktargetmakefilename
930 define gb_LinkTarget_add_objcxxobject
931 $(if $(wildcard $(call gb_ObjCxxObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_ObjCxxObject_get_source,$(SRCDIR),$(2)))))
932 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
933 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCXXOBJECTS += $(2)
935 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCxxObject_get_target,$(2))
936 $(call gb_ObjCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
937 $(call gb_ObjCxxObject_get_target,$(2)) : T_OBJCXXFLAGS += $(call gb_LinkTarget__get_objcxxflags,$(4)) $(3)
938 $(call gb_ObjCxxObject_get_target,$(2)) : \
939 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
941 ifeq ($(gb_FULLDEPS),$(true))
942 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS += $(2)
943 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCxxObject_get_dep_target,$(2))
944 $(call gb_ObjCxxObject_get_dep_target,$(2)) :| $(dir $(call gb_ObjCxxObject_get_dep_target,$(2))).dir
945 endif
947 endef
949 # call gb_LinkTarget_add_asmobject,linktarget,sourcefile
950 define gb_LinkTarget_add_asmobject
951 $(if $(wildcard $(call gb_AsmObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_AsmObject_get_source,$(SRCDIR),$(2)))))
952 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS += $(2)
953 $(call gb_LinkTarget_get_clean_target,$(1)) : ASMOBJECTS += $(2)
955 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_AsmObject_get_target,$(2))
956 $(call gb_AsmObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
957 $(call gb_AsmObject_get_target,$(2)) : \
958 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
960 ifeq ($(gb_FULLDEPS),$(true))
961 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS += $(2)
962 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_AsmObject_get_dep_target,$(2))
963 $(call gb_AsmObject_get_dep_target,$(2)) :| $(dir $(call gb_AsmObject_get_dep_target,$(2))).dir
964 endif
966 endef
968 # call gb_LinkTarget_add_generated_c_object,linktarget,sourcefile,cflags,linktargetmakefilename
969 define gb_LinkTarget_add_generated_c_object
970 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS += $(2)
971 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCOBJECTS += $(2)
973 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCObject_get_target,$(2))
974 $(call gb_GenCObject_get_target,$(2)) : $(call gb_GenCObject_get_source,$(2))
975 # Often gb_GenCObject_get_source does not have its own rule and is only a byproduct.
976 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
977 $(call gb_GenCObject_get_source,$(2)) : | $(gb_Helper_MISCDUMMY)
978 $(call gb_GenCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
979 $(call gb_GenCObject_get_target,$(2)) : WARNINGS_NOT_ERRORS := $(true)
980 $(call gb_GenCObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
981 $(call gb_GenCObject_get_target,$(2)) : \
982 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
984 ifeq ($(gb_FULLDEPS),$(true))
985 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS += $(2)
986 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCObject_get_dep_target,$(2))
987 $(call gb_GenCObject_get_dep_target,$(2)) :| $(dir $(call gb_GenCObject_get_dep_target,$(2))).dir
988 endif
990 endef
992 # call gb_LinkTarget_add_generated_cxx_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
993 define gb_LinkTarget_add_generated_cxx_object
994 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
995 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
997 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
998 $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_GenCxxObject_get_source,$(2),$(1))
999 # Often gb_GenCxxObject_get_source does not have its own rule and is only a byproduct.
1000 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
1001 $(call gb_GenCxxObject_get_source,$(2),$(1)) : | $(gb_Helper_MISCDUMMY)
1002 $(call gb_GenCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1003 $(call gb_GenCxxObject_get_target,$(2)) : WARNINGS_NOT_ERRORS := $(true)
1004 $(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
1005 $(call gb_GenCxxObject_get_target,$(2)) : \
1006 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1007 $(call gb_GenCxxObject_get_target,$(2)) : GEN_CXX_SOURCE := $(call gb_GenCxxObject_get_source,$(2),$(1))
1008 ifeq ($(gb_ENABLE_PCH),$(true))
1009 $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_PrecompiledHeader_get_timestamp,$(call gb_LinkTarget__get_workdir_linktargetname,$(1)))
1010 endif
1012 ifeq ($(gb_FULLDEPS),$(true))
1013 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS += $(2)
1014 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxObject_get_dep_target,$(2))
1015 $(call gb_GenCxxObject_get_dep_target,$(2)) :| $(dir $(call gb_GenCxxObject_get_dep_target,$(2))).dir
1016 endif
1018 endef
1020 # Add a bison grammar to the build.
1021 # call gb_LinkTarget_add_grammar,linktarget,yaccfile,linktargetmakefilename,cxxflags
1022 define gb_LinkTarget_add_grammar
1023 $(call gb_YaccTarget_YaccTarget,$(2))
1024 $(call gb_LinkTarget_add_generated_exception_object,$(1),YaccTarget/$(2),$(3),$(if $(filter GCC,$(COM)),-Wno-unused-macros))
1025 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_YaccTarget_get_clean_target,$(2))
1026 $(call gb_LinkTarget_get_headers_target,$(1)) : $(call gb_YaccTarget_get_header_target,$(2))
1027 $(call gb_LinkTarget__add_include,$(1),$(dir $(call gb_YaccTarget_get_header_target,$(2))))
1029 endef
1031 # Add bison grammars to the build.
1032 # call gb_LinkTarget_add_grammars,linktarget,yaccfiles,ignored,linktargetmakefilename
1033 define gb_LinkTarget_add_grammars
1034 $(foreach grammar,$(2),$(call gb_LinkTarget_add_grammar,$(1),$(grammar),$(4)))
1035 endef
1037 # Add a flex scanner to the build.
1038 # call gb_LinkTarget_add_scanner,linktarget,lexfile,linktargetmakefilename,cxxflags
1039 define gb_LinkTarget_add_scanner
1040 $(call gb_LexTarget_LexTarget,$(2))
1041 $(call gb_LinkTarget_add_generated_exception_object,$(1),LexTarget/$(2),$(3),$(if $(filter GCC,$(COM)),-Wno-unused-macros))
1042 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_LexTarget_get_clean_target,$(2))
1044 endef
1046 # Add flex scanners to the build.
1047 # call gb_LinkTarget_add_scanners,linktarget,lexfiles,ignored,linktargetmakefilename
1048 define gb_LinkTarget_add_scanners
1049 $(foreach scanner,$(2),$(call gb_LinkTarget_add_scanner,$(1),$(scanner),$(4)))
1051 endef
1053 # call gb_LinkTarget_add_exception_object,linktarget,sourcefile,linktargetmakefilename
1054 define gb_LinkTarget_add_exception_object
1055 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)))
1056 endef
1058 # call gb_LinkTarget__use_linktarget_objects,linktarget,linktargets
1059 define gb_LinkTarget__use_linktarget_objects
1060 $(call gb_LinkTarget_get_target,$(1)) : $(foreach linktarget,$(2),$(call gb_LinkTarget_get_target,$(linktarget)))
1061 ifneq ($(OS),IOS)
1062 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS += $(foreach linktarget,$(2),$(call gb_LinkTarget_get_objects_list,$(linktarget)))
1063 endif
1065 endef
1067 # call gb_LinkTarget_use_library_objects,linktarget,libs
1068 define gb_LinkTarget_use_library_objects
1069 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
1070 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
1071 $$(eval $$(call gb_Output_error,Cannot import objects library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
1072 endif
1073 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach lib,$(2),$(call gb_Library_get_linktarget,$(lib))))
1074 $(call gb_LinkTarget_get_headers_target,$(1)) : \
1075 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
1077 endef
1079 # call gb_LinkTarget_use_executable_objects,linktarget,exes
1080 define gb_LinkTarget_use_executable_objects
1081 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach exe,$(2),$(call gb_Executable_get_linktarget,$(exe))))
1083 endef
1085 # call gb_LinkTarget_add_cobjects,linktarget,sourcefiles,cflags,linktargetmakefilename
1086 define gb_LinkTarget_add_cobjects
1087 $(foreach obj,$(2),$(call gb_LinkTarget_add_cobject,$(1),$(obj),$(3),$(4)))
1088 endef
1090 # call gb_LinkTarget_add_cxxobjects,linktarget,sourcefiles,cxxflags,linktargetmakefilename
1091 define gb_LinkTarget_add_cxxobjects
1092 $(foreach obj,$(2),$(call gb_LinkTarget_add_cxxobject,$(1),$(obj),$(3)))
1093 endef
1095 # call gb_LinkTarget_add_objcobjects,linktarget,sourcefiles,objcflags,linktargetmakefilename
1096 define gb_LinkTarget_add_objcobjects
1097 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcobject,$(1),$(obj),$(3),$(4)))
1098 endef
1100 # call gb_LinkTarget_add_objcxxobjects,linktarget,sourcefiles,objcxxflags,linktargetmakefilename
1101 define gb_LinkTarget_add_objcxxobjects
1102 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3),$(4)))
1103 endef
1105 # call gb_LinkTarget_add_asmobjects,linktarget,sourcefiles,asmflags,linktargetmakefilename
1106 define gb_LinkTarget_add_asmobjects
1107 $(foreach obj,$(2),$(call gb_LinkTarget_add_asmobject,$(1),$(obj),$(3)))
1108 endef
1110 # call gb_LinkTarget_add_exception_objects,linktarget,sourcefiles,ignored,linktargetmakefilename
1111 define gb_LinkTarget_add_exception_objects
1112 $(foreach obj,$(2),$(call gb_LinkTarget_add_exception_object,$(1),$(obj),$(4)))
1113 endef
1115 #only useful for building x64 libraries on windows
1116 # call gb_LinkTarget_add_x64_generated_exception_objects,linktarget,sourcefiles,ignored,linktargetmakefilename
1117 define gb_LinkTarget_add_x64_generated_exception_objects
1118 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
1119 $(foreach obj,$(2),$(eval $(call gb_GenCxxObject_get_target,$(obj)) : CXXOBJECT_X64 := YES))
1120 endef
1122 # call gb_LinkTarget_add_generated_cobjects,linktarget,sourcefiles,cflags,linktargetmakefilename
1123 define gb_LinkTarget_add_generated_cobjects
1124 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1125 endef
1127 #only useful for building x64 libraries on windows
1128 # call gb_LinkTarget_add_x64_generated_cobjects,linktarget,sourcefiles,cflags,linktargetmakefilename
1129 define gb_LinkTarget_add_x64_generated_cobjects
1130 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1131 $(foreach obj,$(2),$(eval $(call gb_GenCObject_get_target,$(obj)) : COBJECT_X64 := YES))
1132 endef
1134 # call gb_LinkTarget_add_generated_cxxobjects,linktarget,sourcefiles,cxxflags,linktargetmakefilename
1135 define gb_LinkTarget_add_generated_cxxobjects
1136 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_cxx_object,$(1),$(obj),$(3)))
1137 endef
1139 # call gb_LinkTarget_add_generated_exception_object,linktarget,sourcefile,linktargetmakefilename,cxxflags
1140 define gb_LinkTarget_add_generated_exception_object
1141 $(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)) $(4))
1142 endef
1144 # call gb_LinkTarget_add_generated_exception_objects,linktarget,sourcefile,ignored,linktargetmakefilename
1145 define gb_LinkTarget_add_generated_exception_objects
1146 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
1147 endef
1149 # call gb_LinkTarget_set_targettype,linktarget,targettype
1150 define gb_LinkTarget_set_targettype
1151 $(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE := $(2)
1153 endef
1155 # call gb_LinkTarget_set_x64,linktarget,boolean
1156 define gb_LinkTarget_set_x64
1157 $(call gb_LinkTarget_get_target,$(1)) : LIBRARY_X64 := $(2)
1159 endef
1161 # call gb_LinkTarget_set_ilibtarget,linktarget,ilibfilename
1162 define gb_LinkTarget_set_ilibtarget
1163 $(call gb_LinkTarget_get_clean_target,$(1)) \
1164 $(call gb_LinkTarget_get_target,$(1)) : ILIBTARGET := $(2)
1166 endef
1168 # Add a file that is built by the LinkTarget command and define
1169 # a dummy touch rule for it so it can be tracked via dependencies.
1170 # The assumption is that the file is created by linking; in case it does not
1171 # exist there is some problem. This can be caused on WNT by re-naming DLL
1172 # files (which are aux-targets) but not the import .lib files (which
1173 # are the LinkTargets) and doing an incremental build.
1174 # call gb_LinkTarget_add_auxtarget,linktarget,auxtarget
1175 define gb_LinkTarget_add_auxtarget
1176 $(2) : $(call gb_LinkTarget_get_target,$(1))
1177 if test -e $$@; then \
1178 touch -r $$< $$@; \
1179 else \
1180 rm -f $$<; \
1181 echo "ERROR: aux-target missing, library deleted, please try running make again"; \
1182 false; \
1185 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS += $(2)
1187 endef
1189 # call gb_LinkTarget_add_auxtargets,linktarget,auxtargets
1190 define gb_LinkTarget_add_auxtargets
1191 $(foreach aux,$(2),$(call gb_LinkTarget_add_auxtarget,$(1),$(aux)))
1193 endef
1195 # call gb_LinkTarget__use_custom_headers,linktarget,customtarget
1196 define gb_LinkTarget__use_custom_headers
1197 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
1198 $(call gb_CustomTarget_get_target,$(2))
1199 $(call gb_LinkTarget__add_include,$(1),$(call gb_CustomTarget_get_workdir,$(2)))
1201 endef
1203 # call gb_LinkTarget_use_custom_headers,linktarget,customtargets
1204 define gb_LinkTarget_use_custom_headers
1205 $(foreach customtarget,$(2),$(call gb_LinkTarget__use_custom_headers,$(1),$(customtarget)))
1207 endef
1209 # add SDI (svidl) headers
1210 # call gb_LinkTarget_add_sdi_headers,linktarget,sditargets
1211 define gb_LinkTarget_add_sdi_headers
1212 $(call gb_LinkTarget_get_headers_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_target,$(sdi)))
1213 $(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_clean_target,$(sdi)))
1215 endef
1217 # call gb_LinkTarget__set_precompiled_header_impl,linktarget,pchcxxfile,pchtarget,linktargetmakefilename
1218 define gb_LinkTarget__set_precompiled_header_impl
1219 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_PrecompiledHeader_get_clean_target,$(3))
1220 $(call gb_PrecompiledHeader_get_target,$(3)) : $(2).cxx
1222 $(call gb_PrecompiledHeader_get_target,$(3)) : $(call gb_LinkTarget_get_headers_target,$(1))
1224 $(call gb_LinkTarget_get_target,$(1)) : PCH_NAME := $(3)
1225 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJEX = $(call gb_PrecompiledHeader_get_objectfile, $(call gb_PrecompiledHeader_get_target,$(3)))
1226 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS = $$(PCHOBJEX)
1228 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(DEFS)
1229 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(T_CXXFLAGS) $(call gb_LinkTarget__get_cxxflags,$(4))
1231 $(call gb_PrecompiledHeader_get_target,$(3)) : VISIBILITY :=
1233 $(call gb_PrecompiledHeader_get_timestamp,$(call gb_LinkTarget__get_workdir_linktargetname,$(1))) : $(call gb_PrecompiledHeader_get_target,$(3))
1235 ifeq ($(gb_FULLDEPS),$(true))
1236 -include $(call gb_PrecompiledHeader_get_dep_target,$(3))
1237 endif
1239 endef
1241 # call gb_LinkTarget_set_precompiled_header,linktarget,pchcxxfile,linktargetmakefilename
1242 define gb_LinkTarget_set_precompiled_header
1243 ifeq ($(gb_ENABLE_PCH),$(true))
1244 $(call gb_LinkTarget__set_precompiled_header_impl,$(1),$(2),$(notdir $(2)),$(4))
1245 endif
1247 endef
1249 # use a header package, possibly from another module
1250 # call gb_LinkTarget_use_package,linktarget,package
1251 define gb_LinkTarget_use_package
1252 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
1253 $(call gb_Package_get_target,$(strip $(2)))
1255 endef
1257 # call gb_LinkTarget_use_packages,linktarget,packages
1258 define gb_LinkTarget_use_packages
1259 $(foreach package,$(2),$(call gb_LinkTarget_use_package,$(1),$(package)))
1260 endef
1262 # Use sources from unpacked tarball of an external project
1263 # call gb_LinkTarget_use_unpacked,linktarget,unpackedtarget
1264 define gb_LinkTarget_use_unpacked
1265 $(call gb_LinkTarget_get_headers_target,$(1)) :| $(call gb_UnpackedTarball_get_final_target,$(2))
1267 endef
1269 # Use artifacts from ExternalProject (i. e. configure) of an external project
1270 # example in expat: StaticLibrary depends on ExternalProject outcome
1271 # call gb_LinkTarget_use_external_project,linktarget,externalproject
1272 define gb_LinkTarget_use_external_project
1273 $(call gb_LinkTarget_get_headers_target,$(1)) :| $(call gb_ExternalProject_get_target,$(2))
1275 endef
1277 # Delay linking until a res target has been built. This is needed so that
1278 # unit tests using libraries do not fail if the res target is not yet built.
1280 # call gb_LinkTarget_use_restarget,linktarget,restarget(s)
1281 define gb_LinkTarget_use_restarget
1282 $(call gb_LinkTarget_get_target,$(1)) :| \
1283 $(foreach res,$(2),$(call gb_AllLangResTarget_get_target,$(res)))
1285 endef
1287 # this forwards to functions that must be defined in RepositoryExternal.mk.
1288 # call gb_LinkTarget_use_external,library,external
1289 define gb_LinkTarget_use_external
1290 $(if $(filter undefined,$(origin gb_LinkTarget__use_$(2))),\
1291 $(error gb_LinkTarget_use_external: unknown external: $(2)),\
1292 $(call gb_LinkTarget__use_$(2),$(1)))
1293 endef
1295 # $(call gb_LinkTarget_use_externals,library,externals)
1296 gb_LinkTarget_use_externals = \
1297 $(foreach external,$(2),$(call gb_LinkTarget_use_external,$(1),$(external)))
1299 # call gb_LinkTarget_set_visibility_default,linktarget
1300 define gb_LinkTarget_set_visibility_default
1301 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY := default
1302 ifeq ($(gb_ENABLE_PCH),$(true))
1303 ifneq ($(strip $$(PCH_NAME)),)
1304 $(call gb_PrecompiledHeader_get_target,$$(PCH_NAME)) : VISIBILITY := default
1305 endif
1306 endif
1308 endef
1310 # call gb_LinkTarget_set_warnings_not_errors,linktarget
1311 define gb_LinkTarget_set_warnings_not_errors
1312 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1314 endef
1316 # Set suffix of C++ files, if different from 'cxx'
1318 # This is useful for external libraries.
1320 # call gb_LinkTarget_set_generated_cxx_suffix,linktarget,used-suffix
1321 define gb_LinkTarget_set_generated_cxx_suffix
1322 gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(1)) := $(2)
1324 endef
1326 # vim: set noet sw=4: