bump product version to 4.1.6.2
[LibreOffice.git] / solenv / gbuild / LinkTarget.mk
blobdae37080de168fc44990c6fa7abf352b8167914b
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 gb_LinkTarget__get_cflags=$(if $(CFLAGS),$(CFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
50 gb_LinkTarget__get_objcflags=$(if $(OBJCFLAGS),$(OBJCFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
51 gb_LinkTarget__get_cxxflags=$(if $(CXXFLAGS),$(CXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
52 gb_LinkTarget__get_objcxxflags=$(if $(OBJCXXFLAGS),$(OBJCXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
53 gb_LinkTarget__get_ldflags=$(if $(LDFLAGS),$(LDFLAGS),$(call gb_LinkTarget__get_debugldflags,$(1)))
55 # Overview of dependencies and tasks of LinkTarget
57 # target task depends on
58 # LinkTarget linking AsmObject CObject CxxObject GenCObject GenCxxObject ObjCObject ObjCxxObject
59 # LinkTarget/headers
60 # LinkTarget/dep joined dep file AsmObject/dep CObject/dep CxxObject/dep GenCObject/dep GenCxxObject/dep ObjCObject/dep ObjCxxObject/dep
61 # | LinkTarget/headers
62 # LinkTarget/headers all headers available LinkTarget/external_headers
63 # including own generated own generated headers
64 # PCH precompiled headers LinkTarget/headers
65 # LinkTarget/external_headers all external headers avail. header files of linked libs
67 # CObject plain c compile | LinkTarget/headers
68 # CxxObject c++ compile | LinkTarget/headers PCH
69 # GenCObject plain c compile from | LinkTarget/headers
70 # generated source
71 # GenCxxObject C++ compile from | LinkTarget/headers PCH
72 # generated source
73 # ObjCObject objective c compile | LinkTarget/headers
74 # ObjCxxObject objective c++ compile | LinkTarget/headers
76 # AsmObject asm compile | LinkTarget
78 # CObject/dep dependencies these targets generate empty dep files
79 # CxxObject/dep dependencies that are populated upon compile
80 # GenCObject/dep dependencies
81 # GenCxxObject/dep dependencies
82 # ObjCObject/dep dependencies
83 # ObjCxxObject/dep dependencies
84 # AsmObject/dep dependencies
86 # LinkTarget/headers means gb_LinkTarget_get_headers_target etc.
87 # dependencies prefixed with | are build-order only dependencies
90 # check that objects are only linked into one link target:
91 # multiple linking may cause problems because different link targets may
92 # require different compiler flags
93 define gb_Object__owner
94 $$(if $$(OBJECTOWNER),\
95 $$(call gb_Output_error,fdo#47246: $(1) is linked in by $$(OBJECTOWNER) $(2)))$(2)
96 endef
98 # For every object there is a dep file (if gb_FULLDEPS is active).
99 # The dep file depends on the object: the Object__command also updates the
100 # dep file as a side effect.
101 # In the dep file rule just touch it so it's newer than the object.
103 # The gb_Object__command_dep generates an "always rebuild" dep file;
104 # It is used on first build and in case the user deletes the object dep file.
105 ifeq ($(gb_FULLDEPS),$(true))
106 define gb_Object__command_dep
107 mkdir -p $(dir $(1)) && \
108 echo "$(2) : $(gb_Helper_PHONY)" > $(1)
110 endef
111 else
112 gb_Object__command_dep = \
113 $(call gb_Output_error,gb_Object__command_dep is only for gb_FULLDEPS)
114 endif
116 ifneq ($(FORCE_COMPILE_ALL),)
117 # This one only exists to force .c/.cxx "rebuilds" when running a compiler tool.
118 .PHONY: force_compile_all_target
119 force_compile_all_target:
120 gb_FORCE_COMPILE_ALL_TARGET := force_compile_all_target
121 endif
123 # CObject class
125 gb_CObject_get_source = $(1)/$(2).c
126 # defined by platform
127 # gb_CObject__command
129 ifneq ($(COMPILER_PLUGIN_TOOL),)
130 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
131 $(call gb_CObject__tool_command,$*,$<)
132 else
133 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%)
134 $(call gb_CObject__command,$@,$*,$<,$(call gb_CObject_get_dep_target,$*))
135 endif
137 ifeq ($(gb_FULLDEPS),$(true))
138 $(call gb_CObject_get_dep_target,%) :
139 $(if $(wildcard $@),touch $@,\
140 $(call gb_Object__command_dep,$@,$(call gb_CObject_get_target,$*)))
142 endif
145 # CxxObject class
147 gb_CxxObject_get_source = $(1)/$(2).cxx
148 # defined by platform
149 # gb_CxxObject__command
151 # Only enable PCH if the PCH_CXXFLAGS and the PCH_DEFS (from the linktarget)
152 # are the same as the T_CXXFLAGS and DEFS we want to use for this object. This
153 # should usually be the case. The DEFS/T_CXXFLAGS would have to be manually
154 # overridden for one object file for them to differ. PCH_CXXFLAGS/PCH_DEFS
155 # should never be overridden on an object -- they should be the same as for the
156 # whole linktarget. In general it should be cleaner to use a static library
157 # compiled with different flags and link that in rather than mixing different
158 # flags in one linktarget.
159 define gb_CxxObject__set_pchflags
160 ifeq ($(gb_ENABLE_PCH),$(true))
161 ifneq ($(strip $$(PCH_NAME)),)
162 ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)),$$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
163 $$@ : PCHFLAGS := $$(call gb_PrecompiledHeader_get_enableflags,$$(PCH_NAME))
164 else
165 ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_NOEXCEPTIONFLAGS)),$$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
166 $$@ : PCHFLAGS := $$(call gb_NoexPrecompiledHeader_get_enableflags,$$(PCH_NAME))
167 else
168 $$(info No precompiled header available for $$*.cxx .)
169 $$(info precompiled header flags ( ex) : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)))
170 $$(info precompiled header flags (noex) : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_NOEXCEPTIONFLAGS)))
171 $$(info . object flags : $$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
172 $$@ : PCHFLAGS :=
173 endif
174 endif
175 endif
176 endif
177 endef
179 ifneq ($(COMPILER_PLUGIN_TOOL),)
180 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
181 $(call gb_CxxObject__tool_command,$*,$<)
182 else
183 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
184 $(eval $(gb_CxxObject__set_pchflags))
185 $(call gb_CxxObject__command,$@,$*,$<,$(call gb_CxxObject_get_dep_target,$*))
186 endif
188 ifeq ($(gb_FULLDEPS),$(true))
189 $(call gb_CxxObject_get_dep_target,%) :
190 $(if $(wildcard $@),touch $@,\
191 $(eval $(gb_CxxObject__set_pchflags))\
192 $(call gb_Object__command_dep,$@,$(call gb_CxxObject_get_target,$*)))
194 endif
197 # GenCObject class
199 gb_GenCObject_get_source = $(WORKDIR)/$(1).c
200 # defined by platform
201 # gb_CObject__command
203 $(call gb_GenCObject_get_target,%) :
204 test -f $(call gb_GenCObject_get_source,$*) || (echo "Missing generated source file $(call gb_GenCObject_get_source,$*)" && false)
205 $(call gb_CObject__command,$@,$*,$(call gb_GenCObject_get_source,$*),$(call gb_GenCObject_get_dep_target,$*))
207 ifeq ($(gb_FULLDEPS),$(true))
208 $(call gb_GenCObject_get_dep_target,%) :
209 $(if $(wildcard $@),touch $@,\
210 $(call gb_Object__command_dep,$@,$(call gb_GenCObject_get_target,$*)))
212 endif
215 # GenCxxObject class
217 gb_GenCxxObject_get_source = $(WORKDIR)/$(1).$(gb_LinkTarget_CXX_SUFFIX_$(2))
218 # defined by platform
219 # gb_CxxObject__command
221 $(call gb_GenCxxObject_get_target,%) :
222 test -f $(GEN_CXX_SOURCE) || (echo "Missing generated source file $(GEN_CXX_SOURCE)" && false)
223 $(eval $(gb_CxxObject__set_pchflags))
224 $(call gb_CxxObject__command,$@,$*,$(GEN_CXX_SOURCE),$(call gb_GenCxxObject_get_dep_target,$*))
226 ifeq ($(gb_FULLDEPS),$(true))
227 $(call gb_GenCxxObject_get_dep_target,%) :
228 $(if $(wildcard $@),touch $@,\
229 $(eval $(gb_CxxObject__set_pchflags))\
230 $(call gb_Object__command_dep,$@,$(call gb_GenCxxObject_get_target,$*)))
232 endif
235 # YaccTarget class
237 # XXX: This is more complicated than necessary, but we cannot just use
238 # the generated C++ file as the main target, because we need to let the
239 # header depend on that to ensure the header is present before anything
240 # tries to use it.
242 gb_YaccTarget_get_source = $(1)/$(2).y
243 # defined by platform
244 # gb_YaccTarget__command(grammar-file, stem-for-message, source-target, include-target)
246 .PHONY : $(call gb_YaccTarget_get_clean_target,%)
247 $(call gb_YaccTarget_get_clean_target,%) :
248 $(call gb_Output_announce,$*,$(false),YAC,3)
249 $(call gb_Helper_abbreviate_dirs,\
250 rm -f $(call gb_YaccTarget_get_grammar_target,$*) $(call gb_YaccTarget_get_header_target,$*) $(call gb_YaccTarget_get_target,$*))
252 $(call gb_YaccTarget_get_target,%) : $(call gb_YaccTarget_get_source,$(SRCDIR),%)
253 $(call gb_YaccTarget__command,$<,$*,$@,$(call gb_YaccTarget_get_header_target,$*),$(call gb_YaccTarget_get_grammar_target,$*))
255 define gb_YaccTarget_YaccTarget
256 $(call gb_YaccTarget_get_grammar_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
257 touch $$@
258 $(call gb_YaccTarget_get_header_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
259 touch $$@
261 endef
263 gb_YACC := bison
266 # LexTarget class
268 gb_LexTarget_get_source = $(1)/$(2).l
270 .PHONY : $(call gb_LexTarget_get_clean_target,%)
271 $(call gb_LexTarget_get_clean_target,%) :
272 $(call gb_Output_announce,$*,$(false),LEX,3)
273 $(call gb_Helper_abbreviate_dirs,\
274 rm -f $(call gb_LexTarget_get_scanner_target,$*) $(call gb_LexTarget_get_target,$*))
276 $(call gb_LexTarget_get_target,%) : $(call gb_LexTarget_get_source,$(SRCDIR),%)
277 $(call gb_LexTarget__command,$<,$*,$@,$(call gb_LexTarget_get_scanner_target,$*))
279 # gb_LexTarget_LexTarget(scanner-file)
280 define gb_LexTarget_LexTarget
281 $(call gb_LexTarget_get_scanner_target,$(1)) : $(call gb_LexTarget_get_target,$(1))
282 touch $$@
284 endef
286 # gb_LexTarget__command(scanner-file, stem-for-message, done-pseudo-target, source-target)
287 define gb_LexTarget__command
288 $(call gb_Output_announce,$(2),$(true),LEX,3)
289 $(call gb_Helper_abbreviate_dirs,\
290 mkdir -p $(dir $(3)) && \
291 $(FLEX) $(T_LEXFLAGS) -o$(4) $(1) && touch $(3) )
292 endef
295 # ObjCxxObject class
298 gb_ObjCxxObject_get_source = $(1)/$(2).mm
299 # defined by platform
300 # gb_ObjCxxObject__command
302 ifneq ($(COMPILER_PLUGIN_TOOL),)
303 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
304 $(call gb_ObjCxxObject__tool_command,$*,$<)
305 else
307 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%)
308 $(call gb_ObjCxxObject__command,$@,$*,$<,$(call gb_ObjCxxObject_get_dep_target,$*))
310 ifeq ($(gb_FULLDEPS),$(true))
311 $(call gb_ObjCxxObject_get_dep_target,%) :
312 $(if $(wildcard $@),touch $@,\
313 $(call gb_Object__command_dep,$@,$(call gb_ObjCxxObject_get_target,$*)))
315 endif
316 endif
319 # ObjCObject class
322 gb_ObjCObject_get_source = $(1)/$(2).m
323 # defined by platform
324 # gb_ObjCObject__command
326 ifneq ($(COMPILER_PLUGIN_TOOL),)
327 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
328 $(call gb_ObjCObject__tool_command,$*,$<)
329 else
331 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%)
332 $(call gb_ObjCObject__command,$@,$*,$<,$(call gb_ObjCObject_get_dep_target,$*))
334 ifeq ($(gb_FULLDEPS),$(true))
335 $(call gb_ObjCObject_get_dep_target,%) :
336 $(if $(wildcard $@),touch $@,\
337 $(call gb_Object__command_dep,$@,$(call gb_ObjCObject_get_target,$*)))
339 endif
340 endif
343 # AsmObject class
345 # defined by platform
346 # gb_AsmObject_get_source (.asm on Windows, .s elsewhere)
347 # gb_AsmObject__command
349 $(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%)
350 $(call gb_AsmObject__command,$@,$*,$<,$(call gb_AsmObject_get_dep_target,$*))
352 ifeq ($(gb_FULLDEPS),$(true))
353 $(call gb_AsmObject_get_dep_target,%) :
354 $(if $(wildcard $@),touch $@,\
355 $(call gb_Object__command_dep,$@,$(call gb_AsmObject_get_target,$*)))
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 : $(call gb_LinkTarget_get_clean_target,%)
374 $(call gb_LinkTarget_get_clean_target,%) :
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,$*) \
392 $(call gb_LinkTarget_get_dep_target,$*) \
393 $(call gb_LinkTarget_get_headers_target,$*) \
394 $(call gb_LinkTarget_get_external_headers_target,$*) \
395 $(call gb_LinkTarget_get_objects_list,$*) \
396 $(call gb_LinkTarget_get_target,$*).exports \
397 $(DLLTARGET) \
398 $(AUXTARGETS)) && \
399 cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -fr && \
400 rm -f $${RESPONSEFILE}
403 # cat the deps of all objects in one file, then we need only open that one file
404 define gb_LinkTarget__command_dep
405 $(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
406 $(call gb_Helper_abbreviate_dirs,\
407 mkdir -p $(dir $(1)) && \
408 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
409 $(foreach object,$(3),$(call gb_CObject_get_dep_target,$(object))) \
410 $(foreach object,$(4),$(call gb_CxxObject_get_dep_target,$(object))) \
411 $(foreach object,$(5),$(call gb_ObjCObject_get_dep_target,$(object)))\
412 $(foreach object,$(6),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
413 $(foreach object,$(7),$(call gb_AsmObject_get_dep_target,$(object)))\
414 $(foreach object,$(8),$(call gb_GenCObject_get_dep_target,$(object))) \
415 $(foreach object,$(9),$(call gb_GenCxxObject_get_dep_target,$(object))) \
416 ) && \
417 $(call gb_Executable_get_command,concat-deps) $${RESPONSEFILE} > $(1)) && \
418 rm -f $${RESPONSEFILE}
420 endef
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} $(call gb_LinkTarget_get_objects_list,$(2))
435 endef
437 # Target for the .exports of the shared library, to speed up incremental build.
438 # This deliberately does nothing if the file exists; the file is actually
439 # written in gb_LinkTarget__command_dynamiclink.
440 # Put this pattern rule here so it overrides the one below.
441 # (this is rather ugly: because of % the functions cannot be used)
442 $(call gb_LinkTarget_get_target,Library/%.exports) : $(gb_Library_OUTDIRLOCATION)/%
443 $(if $(wildcard $@),,mkdir -p $(dir $@) && touch $@)
445 $(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_headers_target,%) $(gb_Helper_MISCDUMMY)
446 $(if $(filter $*,$(foreach lib,$(gb_MERGEDLIBS) $(gb_URELIBS),$(call gb_Library_get_linktargetname,$(lib)))),\
447 $(if $(filter $(true),$(call gb_LinkTarget__is_build_lib,$*)),\
448 $(call gb_LinkTarget__command,$@,$*),\
449 mkdir -p $(dir $@) && echo invalid > $@ \
450 $(if $(SOVERSION),&& echo invalid > $@.$(SOVERSION))),$(call gb_LinkTarget__command,$@,$*))
451 $(call gb_LinkTarget__command_objectlist,$@,$*)
453 ifeq ($(gb_FULLDEPS),$(true))
454 $(call gb_LinkTarget_get_dep_target,%) : $(call gb_Executable_get_runtime_dependencies,concat-deps)
456 $(call gb_LinkTarget__command_dep,$@,$*,$(COBJECTS),$(CXXOBJECTS),$(OBJCOBJECTS),$(OBJCXXOBJECTS),$(ASMOBJECTS),$(GENCOBJECTS),$(GENCXXOBJECTS))
457 endif
459 # Ok, this is some dark voodoo: When declaring a linktarget with
460 # gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
461 # target. When the rule for the headertarget is executed and SELF does not
462 # match the target name, we are depending on a linktarget that was never
463 # declared. In a full build exclusively in gbuild that should never happen.
464 # However, partial gbuild build will not know about how to build lower level
465 # linktargets, just as gbuild can not know about linktargets generated in the
466 # old build.pl/dmake system. Once all is migrated, gbuild should error out
467 # when is is told to depend on a linktarget it does not know about and not
468 # only warn.
469 define gb_LinkTarget__get_external_headers_check
470 ifneq ($$(SELF),$$*)
471 $$(eval $$(call gb_Output_info,LinkTarget $$* not defined: Assuming headers to be there!,ALL))
472 endif
473 $$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, mkdir -p $$(dir $$@) && touch $$@ && mkdir -p $(call gb_LinkTarget_get_target,)pdb/$$(dir $$*))
475 endef
477 $(call gb_LinkTarget_get_external_headers_target,%) :
478 $(eval $(gb_LinkTarget__get_external_headers_check))
479 $(COMMAND)
481 $(call gb_LinkTarget_get_headers_target,%) : $(call gb_LinkTarget_get_external_headers_target,%)
482 $(call gb_Helper_abbreviate_dirs,\
483 mkdir -p $(dir $@) && touch $@)
485 # Explanation of some of the targets:
486 # - gb_LinkTarget_get_external_headers_target is the targets that guarantees all
487 # headers from linked against libraries are in OUTDIR.
488 # - gb_LinkTarget_get_headers_target is the target that guarantees all headers
489 # from the linked against the libraries and the linktargets own headers
490 # (including generated headers) are in the OUTDIR.
491 # - gb_LinkTarget_get_target links the objects into a file in WORKDIR.
492 # gb_LinkTarget_get_target depends on gb_LinkTarget_get_headers_target which in
493 # turn depends gb_LinkTarget_get_external_headers_target.
494 # gb_LinkTarget_get_target depends additionally on the objects, which in turn
495 # depend build-order only on the gb_LinkTarget_get_headers_target. The build
496 # order-only dependency ensures all headers to be there for compiling and
497 # dependency generation without causing all objects to be rebuild when one
498 # header changes. Only the ones with an explicit dependency in their generated
499 # dependency file will be rebuild.
501 # gb_LinkTarget_get_target is the target that links the objects into a file in
502 # WORKDIR
503 # Explanation of some of the variables:
504 # - AUXTARGETS are the additionally generated files that need to be cleaned out
505 # on clean.
506 # - PCH_CXXFLAGS and PCH_DEFS are the flags that the precompiled headers will
507 # be compiled with. They should never be overridden in a single object
508 # files.
509 # - TARGETTYPE is the type of linktarget as some platforms need very different
510 # command to link different targettypes.
511 # - LIBRARY_X64 is only relevent for building a x64 library on windows.
513 # Since most variables are set on the linktarget and not on the object, the
514 # object learns about these setting via GNU makes scoping of target variables.
515 # Therefore it is important that objects are only directly depended on by the
516 # linktarget. This for example means that you cannot build a single object
517 # alone, because then you would directly depend on the object.
519 # A note about flags: because the overriding the global variables with a target
520 # local variable of the same name is considered obscure, the target local
521 # variables have a T_ prefix.
522 define gb_LinkTarget_LinkTarget
523 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
524 $(call gb_LinkTarget_get_external_headers_target,$(1)) : SELF := $(1)
525 $(call gb_LinkTarget_get_target,$(1)) : DLLTARGET :=
526 $(call gb_LinkTarget_get_clean_target,$(1)) \
527 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
528 $(call gb_LinkTarget_get_clean_target,$(1)) \
529 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
530 $(call gb_LinkTarget_get_clean_target,$(1)) \
531 $(call gb_LinkTarget_get_target,$(1)) : YACCOBJECT :=
532 $(call gb_LinkTarget_get_clean_target,$(1)) \
533 $(call gb_LinkTarget_get_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
534 $(call gb_LinkTarget_get_clean_target,$(1)) \
535 $(call gb_LinkTarget_get_target,$(1)) : LEXOBJECT :=
536 $(call gb_LinkTarget_get_clean_target,$(1)) \
537 $(call gb_LinkTarget_get_target,$(1)) : T_LEXFLAGS := $$(gb_LinkTarget_LEXFLAGS) $(LEXFLAGS)
538 $(call gb_LinkTarget_get_clean_target,$(1)) \
539 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
540 $(call gb_LinkTarget_get_clean_target,$(1)) \
541 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
542 $(call gb_LinkTarget_get_clean_target,$(1)) \
543 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS :=
544 $(call gb_LinkTarget_get_clean_target,$(1)) \
545 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS :=
546 $(call gb_LinkTarget_get_clean_target,$(1)) \
547 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS :=
548 $(call gb_LinkTarget_get_headers_target,$(1)) \
549 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
550 $(call gb_LinkTarget_get_headers_target,$(1)) \
551 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS_APPEND :=
552 $(call gb_LinkTarget_get_headers_target,$(1)) \
553 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
554 $(call gb_LinkTarget_get_headers_target,$(1)) \
555 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS_APPEND :=
556 $(call gb_LinkTarget_get_headers_target,$(1)) \
557 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
558 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
559 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND :=
560 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
561 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND :=
562 $(call gb_LinkTarget_get_headers_target,$(1)) \
563 $(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $$(call gb_LinkTarget_rtl_defs,$(1)) $(CPPFLAGS)
564 $(call gb_LinkTarget_get_headers_target,$(1)) \
565 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
566 $(call gb_LinkTarget_get_headers_target,$(1)) \
567 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
568 $(call gb_LinkTarget_get_headers_target,$(1)) \
569 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $$(gb_LinkTarget_LDFLAGS) $(call gb_LinkTarget__get_ldflags,$(2))
570 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS :=
571 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS :=
572 $(call gb_LinkTarget_get_target,$(1)) : LIBS :=
573 $(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE :=
574 $(call gb_LinkTarget_get_target,$(1)) : LIBRARY_X64 :=
575 $(call gb_LinkTarget_get_headers_target,$(1)) \
576 $(call gb_LinkTarget_get_target,$(1)) : PCH_NAME :=
577 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS :=
578 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJEX :=
579 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJNOEX :=
580 $(call gb_LinkTarget_get_headers_target,$(1)) \
581 $(call gb_LinkTarget_get_target,$(1)) : PDBFILE :=
582 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS :=
583 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES :=
584 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY :=
585 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS :=
586 $(call gb_LinkTarget_get_target,$(1)) : SOVERSION :=
587 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT :=
589 ifeq ($(gb_FULLDEPS),$(true))
590 -include $(call gb_LinkTarget_get_dep_target,$(1))
591 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
592 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
593 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS :=
594 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
595 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS :=
596 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
597 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
598 $(call gb_LinkTarget_get_dep_target,$(1)) : YACCOBJECTS :=
599 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
600 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
601 $(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
602 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
603 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
604 $(call gb_LinkTarget_get_dep_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
605 $(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
606 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
607 $(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE :=
608 $(call gb_LinkTarget_get_dep_target,$(1)) : LIBRARY_X64 :=
609 $(call gb_LinkTarget_get_dep_target,$(1)) : PCH_NAME :=
610 $(call gb_LinkTarget_get_dep_target,$(1)) : EXTRAOBJECTLISTS :=
611 $(call gb_LinkTarget_get_dep_target,$(1)) : VISIBILITY :=
612 $(call gb_LinkTarget_get_dep_target,$(1)) : WARNINGS_NOT_ERRORS :=
613 $(call gb_LinkTarget_get_dep_target,$(1)) : SOVERSION :=
614 $(call gb_LinkTarget_get_dep_target,$(1)) : SOVERSIONSCRIPT :=
615 endif
617 gb_LinkTarget_CXX_SUFFIX_$(1) := cxx
619 endef
621 define gb_LinkTarget_set_soversion_script
622 $(call gb_LinkTarget_get_target,$(1)) : $(3)
623 $(call gb_LinkTarget_get_target,$(1)) : SOVERSION := $(2)
624 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT := $(3)
626 endef
628 define gb_LinkTarget_add_defs
629 $(call gb_LinkTarget_get_headers_target,$(1)) \
630 $(call gb_LinkTarget_get_target,$(1)) : DEFS += $(2)
631 $(call gb_LinkTarget_get_headers_target,$(1)) \
632 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS += $(2)
633 ifeq ($(gb_FULLDEPS),$(true))
634 $(call gb_LinkTarget_get_dep_target,$(1)) : DEFS += $(2)
635 $(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS += $(2)
636 endif
637 endef
639 define gb_LinkTarget_set_defs
640 $$(call gb_Output_error,\
641 gb_LinkTarget_set_defs: use gb_LinkTarget_add_defs instead.)
642 endif
644 endef
646 define gb_LinkTarget_add_cflags
647 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS_APPEND += $(2)
648 ifeq ($(gb_FULLDEPS),$(true))
649 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS_APPEND += $(2)
650 endif
652 endef
654 define gb_LinkTarget_set_cflags
655 $$(call gb_Output_error,\
656 gb_LinkTarget_set_cflags: use gb_LinkTarget_add_cflags instead.)
657 endif
659 endef
661 define gb_LinkTarget_add_cxxflags
662 $(call gb_LinkTarget_get_headers_target,$(1)) \
663 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS_APPEND += $(2)
664 $(call gb_LinkTarget_get_headers_target,$(1)) \
665 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS += $(2)
666 ifeq ($(gb_FULLDEPS),$(true))
667 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS_APPEND += $(2)
668 $(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS += $(2)
669 endif
670 endef
672 define gb_LinkTarget_set_cxxflags
673 $$(call gb_Output_error,\
674 gb_LinkTarget_set_cxxflags: use gb_LinkTarget_add_cxxflags instead.)
676 endef
678 define gb_LinkTarget_add_objcxxflags
679 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND += $(2)
680 ifeq ($(gb_FULLDEPS),$(true))
681 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS_APPEND += $(2)
682 endif
683 endef
685 define gb_LinkTarget_set_objcxxflags
686 $$(call gb_Output_error,\
687 gb_LinkTarget_set_objcxxflags: use gb_LinkTarget_add_objcxxflags instead.)
689 endef
691 define gb_LinkTarget_set_objcflags
692 $$(call gb_Output_error,\
693 gb_LinkTarget_set_objcflags: use gb_LinkTarget_add_objcflags instead.)
695 endef
697 define gb_LinkTarget_add_objcflags
698 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND += $(2)
699 ifeq ($(gb_FULLDEPS),$(true))
700 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCFLAGS_APPEND += $(2)
701 endif
703 endef
705 define gb_LinkTarget__add_include
706 $(call gb_LinkTarget_get_headers_target,$(1)) \
707 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(2)
708 ifeq ($(gb_FULLDEPS),$(true))
709 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += -I$(2)
710 endif
712 endef
714 define gb_LinkTarget__check_srcdir_paths
715 $(if $(filter-out $(wildcard $(2)),$(2)),\
716 $(call gb_Output_error,gb_LinkTarget_set_include: include paths $(filter-out $(wildcard $(2)),$(2)) do not exist) \
718 endef
720 define gb_LinkTarget_set_include
721 $(call gb_LinkTarget__check_srcdir_paths,$(1),\
722 $(patsubst -I%,%,$(filter -I$(SRCDIR)/%,$(filter-out -I$(OUTDIR)/% -I$(WORKDIR)/%,$(2)))))
723 $(call gb_LinkTarget_get_headers_target,$(1)) \
724 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2)
725 ifeq ($(gb_FULLDEPS),$(true))
726 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $(2)
727 endif
729 endef
731 define gb_LinkTarget_set_include_stl
732 $$(call gb_Output_error,\
733 gb_LinkTarget_set_include_stl: removed, why is anybody calling it?)
734 endef
736 define gb_LinkTarget_add_ldflags
737 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS += $(2)
739 endef
741 # real use in RepositoryExternal.mk
742 define gb_LinkTarget_set_ldflags
743 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $(2)
745 endef
747 define gb_LinkTarget_add_libs
748 $(call gb_LinkTarget_get_target,$(1)) : LIBS += $(2)
750 endef
752 # remove platform specific standard libraries for linktarget $(1)
753 # assumption is that adding these standard libs is always useful, but in very
754 # exceptional cases this disable method may be used
755 define gb_LinkTarget_disable_standard_system_libs
756 $(call gb_LinkTarget_get_target,$(1)) : LIBS := $$(filter-out $$(gb_STDLIBS),$$(LIBS))
758 endef
760 define gb_LinkTarget__use_api
761 $(call gb_LinkTarget_get_external_headers_target,$(1)) : $(call gb_UnoApiHeadersTarget_get_target,$(2))
762 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_dir,$(2)))
764 endef
766 define gb_LinkTarget_use_api
767 $(foreach api,$(2),$(call gb_LinkTarget__use_api,$(1),$(api)))
769 endef
771 define gb_LinkTarget_use_udk_api
772 $(call gb_LinkTarget__use_api,$(1),udkapi)
773 endef
775 define gb_LinkTarget_use_sdk_api
776 $(call gb_LinkTarget__use_api,$(1),udkapi)
777 $(call gb_LinkTarget__use_api,$(1),offapi)
778 endef
780 define gb_LinkTarget__use_internal_api_one
781 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
782 $(call gb_UnoApiHeadersTarget_get_$(3)target,$(2))
783 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_$(3)dir,$(2)))
785 endef
787 define gb_LinkTarget__use_internal_api
788 $(foreach api,$(2),$(call gb_LinkTarget__use_internal_api_one,$(1),$(api),$(3)))
790 endef
792 define gb_LinkTarget_add_internal_api
793 $$(call gb_Output_error,\
794 gb_LinkTarget_add_internal_api: use gb_LinkTarget_use_internal_api instead.)
795 endef
797 define gb_LinkTarget_add_internal_bootstrap_api
798 $$(call gb_Output_error,\
799 gb_LinkTarget_add_internal_bootstrap_api: use gb_LinkTarget_use_internal_bootstrap_api instead.)
800 endef
802 define gb_LinkTarget_add_internal_comprehensive_api
803 $$(call gb_Output_error,\
804 gb_LinkTarget_add_internal_comprehensive_api: use gb_LinkTarget_use_internal_comprehensive_api instead.)
805 endef
808 define gb_LinkTarget_use_internal_api
809 $(call gb_LinkTarget__use_internal_api,$(1),$(2))
811 endef
813 define gb_LinkTarget_use_internal_bootstrap_api
814 $(call gb_LinkTarget__use_internal_api,$(1),$(2),bootstrap_)
816 endef
818 define gb_LinkTarget_use_internal_comprehensive_api
819 $(call gb_LinkTarget__use_internal_api,$(1),$(2),comprehensive_)
821 endef
823 define gb_LinkTarget_add_linked_libs
824 $$(call gb_Output_error,\
825 gb_LinkTarget_add_linked_libs: use gb_LinkTarget_use_libraries instead.)
826 endef
828 define gb_PrintDeps_info
829 $(info LibraryDep: $(1) links against $(2))
830 endef
832 define gb_LinkTarget__use_libraries
834 # used by bin/module-deps.pl
835 ifneq ($(ENABLE_PRINT_DEPS),)
836 # exclude libraries in Library_merged Librery_urelibs
837 ifeq ($(filter $(1),$(foreach lib,$(gb_MERGEDLIBS) $(gb_URELIBS),$(call gb_Library_get_linktargetname,$(lib)))),)
838 $$(eval $$(call gb_PrintDeps_info,$(4),$(3)))
839 endif
840 endif
842 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(3)
844 # depend on the exports of the library, not on the library itself
845 # for faster incremental builds when the ABI is unchanged
846 $(call gb_LinkTarget_get_target,$(1)) : \
847 $(foreach lib,$(3),$(call gb_Library_get_exports_target,$(lib)))
848 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
849 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
851 endef
853 gb_BUILD_HELPER_LIBS := basegfx \
854 cppu \
855 cppuhelper \
856 reg \
857 sal \
858 salhelper \
859 store \
860 tl \
861 unoidl \
862 xmlreader \
864 gb_BUILD_HELPER_TOOLS := cppumaker \
865 idlc \
866 reg2unoidl \
867 regcompare \
868 regmerge \
869 rsc \
870 svidl
872 define gb_LinkTarget__is_build_lib
873 $(if $(filter $(1),$(foreach lib,$(gb_BUILD_HELPER_LIBS),$(call gb_Library_get_linktargetname,$(lib)))),$(true),$(false))
874 endef
876 define gb_LinkTarget__is_build_tool
877 $(if $(filter $(1),$(addprefix Executable/,$(gb_BUILD_HELPER_TOOLS))),$(true),$(false))
878 endef
880 define gb_LinkTarget_use_libraries
881 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
882 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
883 $$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
884 endif
886 ifeq ($(call gb_LinkTarget__is_build_tool,$(1)),$(true))
887 $(call gb_LinkTarget__use_libraries,$(1),$(2),$(2),$(4))
889 else
890 $(call gb_LinkTarget__use_libraries,$(1),$(2),$(strip \
891 $(if $(filter $(gb_MERGEDLIBS),$(2)), \
892 $(if $(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktargetname,$(lib)))), \
893 $(filter $(gb_MERGEDLIBS),$(2)), merged)) \
894 $(if $(filter $(gb_URELIBS),$(2)), \
895 $(if $(filter $(1),$(foreach lib,$(gb_URELIBS),$(call gb_Library_get_linktargetname,$(lib)))), \
896 $(filter $(gb_URELIBS),$(2)), urelibs)) \
897 $(filter-out $(gb_MERGEDLIBS) $(gb_URELIBS),$(2)) \
898 ),$(4))
900 endif
901 endef
903 define gb_LinkTarget_add_linked_static_libs
904 $$(call gb_Output_error,\
905 gb_LinkTarget_add_linked_static_libs: use gb_LinkTarget_use_static_libraries instead.)
906 endef
908 # for a StaticLibrary, dependent libraries are not actually linked in
909 define gb_LinkTarget_use_static_libraries
910 ifneq (,$$(filter-out $(gb_StaticLibrary_KNOWNLIBS),$(2)))
911 $$(eval $$(call gb_Output_info, currently known static libraries are: $(sort $(gb_StaticLibrary_KNOWNLIBS)),ALL))
912 $$(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))
913 endif
915 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $$(if $$(filter-out StaticLibrary,$$(TARGETTYPE)),$(2))
917 $(call gb_LinkTarget_get_target,$(1)) : $(foreach lib,$(2),$(call gb_StaticLibrary_get_target,$(lib)))
918 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
919 $(foreach lib,$(2),$(call gb_StaticLibrary_get_headers_target,$(lib)))
921 endef
923 define gb_LinkTarget_add_cobject
924 $(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)))))
925 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
926 $(call gb_LinkTarget_get_clean_target,$(1)) : COBJECTS += $(2)
928 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CObject_get_target,$(2))
929 $(call gb_CObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
930 $(call gb_CObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
931 $(call gb_CObject_get_target,$(2)) : \
932 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
934 ifeq ($(gb_FULLDEPS),$(true))
935 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS += $(2)
936 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CObject_get_dep_target,$(2))
937 endif
939 endef
941 define gb_LinkTarget_add_cxxobject
942 $(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)))))
943 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
944 $(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
946 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
947 $(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
948 $(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
949 $(call gb_CxxObject_get_target,$(2)) : \
950 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
951 ifeq ($(gb_ENABLE_PCH),$(true))
952 $(call gb_CxxObject_get_target,$(2)) : $(call gb_PrecompiledHeader_get_timestamp,$(1))
953 endif
955 ifeq ($(gb_FULLDEPS),$(true))
956 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS += $(2)
957 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxObject_get_dep_target,$(2))
958 endif
960 endef
962 define gb_LinkTarget_add_objcobject
963 $(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)))))
964 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS += $(2)
965 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCOBJECTS += $(2)
967 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCObject_get_target,$(2))
968 $(call gb_ObjCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
969 $(call gb_ObjCObject_get_target,$(2)) : T_OBJCFLAGS += $(call gb_LinkTarget__get_objcflags,$(4)) $(3)
970 $(call gb_ObjCObject_get_target,$(2)) : \
971 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
973 ifeq ($(gb_FULLDEPS),$(true))
974 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS += $(2)
975 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCObject_get_dep_target,$(2))
976 endif
978 endef
980 define gb_LinkTarget_add_objcxxobject
981 $(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)))))
982 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
983 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCXXOBJECTS += $(2)
985 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCxxObject_get_target,$(2))
986 $(call gb_ObjCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
987 $(call gb_ObjCxxObject_get_target,$(2)) : T_OBJCXXFLAGS += $(call gb_LinkTarget__get_objcxxflags,$(4)) $(3)
988 $(call gb_ObjCxxObject_get_target,$(2)) : \
989 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
991 ifeq ($(gb_FULLDEPS),$(true))
992 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS += $(2)
993 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCxxObject_get_dep_target,$(2))
994 endif
996 endef
998 define gb_LinkTarget_add_asmobject
999 $(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)))))
1000 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS += $(2)
1001 $(call gb_LinkTarget_get_clean_target,$(1)) : ASMOBJECTS += $(2)
1003 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_AsmObject_get_target,$(2))
1004 $(call gb_AsmObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1005 $(call gb_AsmObject_get_target,$(2)) : \
1006 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1008 ifeq ($(gb_FULLDEPS),$(true))
1009 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS += $(2)
1010 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_AsmObject_get_dep_target,$(2))
1011 endif
1013 endef
1015 define gb_LinkTarget_add_generated_c_object
1016 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS += $(2)
1017 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCOBJECTS += $(2)
1019 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCObject_get_target,$(2))
1020 $(call gb_GenCObject_get_target,$(2)) : $(call gb_GenCObject_get_source,$(2))
1021 # Often gb_GenCObject_get_source does not have its own rule and is only a byproduct.
1022 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
1023 $(call gb_GenCObject_get_source,$(2)) : | $(gb_Helper_MISCDUMMY)
1024 $(call gb_GenCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1025 $(call gb_GenCObject_get_target,$(2)) : WARNINGS_NOT_ERRORS := $(true)
1026 $(call gb_GenCObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
1027 $(call gb_GenCObject_get_target,$(2)) : \
1028 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1030 ifeq ($(gb_FULLDEPS),$(true))
1031 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS += $(2)
1032 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCObject_get_dep_target,$(2))
1033 endif
1035 endef
1037 define gb_LinkTarget_add_generated_cxx_object
1038 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
1039 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
1041 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
1042 $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_GenCxxObject_get_source,$(2),$(1))
1043 # Often gb_GenCxxObject_get_source does not have its own rule and is only a byproduct.
1044 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
1045 $(call gb_GenCxxObject_get_source,$(2),$(1)) : | $(gb_Helper_MISCDUMMY)
1046 $(call gb_GenCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1047 $(call gb_GenCxxObject_get_target,$(2)) : WARNINGS_NOT_ERRORS := $(true)
1048 $(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
1049 $(call gb_GenCxxObject_get_target,$(2)) : \
1050 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1051 $(call gb_GenCxxObject_get_target,$(2)) : GEN_CXX_SOURCE := $(call gb_GenCxxObject_get_source,$(2),$(1))
1052 ifeq ($(gb_ENABLE_PCH),$(true))
1053 $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_PrecompiledHeader_get_timestamp,$(1))
1054 endif
1056 ifeq ($(gb_FULLDEPS),$(true))
1057 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS += $(2)
1058 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxObject_get_dep_target,$(2))
1059 endif
1061 endef
1063 # Add a bison grammar to the build.
1064 # gb_LinkTarget_add_grammar(<component>,<grammar file>)
1065 define gb_LinkTarget_add_grammar
1066 $(call gb_YaccTarget_YaccTarget,$(2))
1067 $(call gb_LinkTarget_add_generated_exception_object,$(1),YaccTarget/$(2),$(3),$(if $(filter GCC,$(COM)),-Wno-unused-macros))
1068 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_YaccTarget_get_clean_target,$(2))
1069 $(call gb_LinkTarget_get_headers_target,$(1)) : $(call gb_YaccTarget_get_header_target,$(2))
1070 $(call gb_LinkTarget__add_include,$(1),$(dir $(call gb_YaccTarget_get_header_target,$(2))))
1072 endef
1074 # Add bison grammars to the build.
1075 # gb_LinkTarget_add_grammars(<component>,<grammar file> [<grammar file>*])
1076 define gb_LinkTarget_add_grammars
1077 $(foreach grammar,$(2),$(call gb_LinkTarget_add_grammar,$(1),$(grammar),$(4)))
1078 endef
1080 # Add a flex scanner to the build.
1081 # gb_LinkTarget_add_scanner(<component>,<scanner file>)
1082 define gb_LinkTarget_add_scanner
1083 $(call gb_LexTarget_LexTarget,$(2))
1084 $(call gb_LinkTarget_add_generated_exception_object,$(1),LexTarget/$(2),$(3),$(if $(filter GCC,$(COM)),-Wno-unused-macros))
1085 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_LexTarget_get_clean_target,$(2))
1087 endef
1089 # Add flex scanners to the build.
1090 # gb_LinkTarget_add_scanners(<component>,<scanner file> [<scanner file>*])
1091 define gb_LinkTarget_add_scanners
1092 $(foreach scanner,$(2),$(call gb_LinkTarget_add_scanner,$(1),$(scanner),$(4)))
1094 endef
1096 define gb_LinkTarget_add_noexception_object
1097 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_NOEXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)))
1098 ifeq ($(gb_ENABLE_PCH),$(true))
1099 # noexception objects are rare, so generate matching .pch only when needed
1100 $(call gb_CxxObject_get_target,$(2)) : $(call gb_NoexPrecompiledHeader_get_timestamp,$(1))
1101 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS = $$(PCHOBJEX) $$(PCHOBJNOEX)
1102 endif
1103 endef
1105 define gb_LinkTarget_add_exception_object
1106 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)))
1107 endef
1109 define gb_LinkTarget_add_linktarget_objects
1110 $$(call gb_Output_error,\
1111 gb_LinkTarget_add_linktarget_objects: use gb_LinkTarget__use_linktarget_objects instead.)
1112 endef
1114 define gb_LinkTarget__use_linktarget_objects
1115 $(call gb_LinkTarget_get_target,$(1)) : $(foreach linktarget,$(2),$(call gb_LinkTarget_get_target,$(linktarget)))
1116 ifneq ($(OS),IOS)
1117 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS += $(foreach linktarget,$(2),$(call gb_LinkTarget_get_objects_list,$(linktarget)))
1118 endif
1120 endef
1122 define gb_LinkTarget_add_library_objects
1123 $$(call gb_Output_error,\
1124 gb_LinkTarget_add_library_objects: use gb_LinkTarget_use_library_objects instead.)
1125 endef
1127 define gb_LinkTarget_use_library_objects
1128 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
1129 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
1130 $$(eval $$(call gb_Output_error,Cannot import objects library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
1131 endif
1132 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach lib,$(2),$(call gb_Library_get_linktargetname,$(lib))))
1133 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
1134 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
1136 endef
1138 define gb_LinkTarget_add_executable_objects
1139 $$(call gb_Output_error,\
1140 gb_LinkTarget_add_executable_objects: use gb_LinkTarget_use_executable_objects instead.)
1141 endef
1143 define gb_LinkTarget_use_executable_objects
1144 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach exe,$(2),$(call gb_Executable_get_linktargetname,$(lib))))
1146 endef
1148 define gb_LinkTarget_add_cobjects
1149 $(foreach obj,$(2),$(call gb_LinkTarget_add_cobject,$(1),$(obj),$(3),$(4)))
1150 endef
1152 define gb_LinkTarget_add_cxxobjects
1153 $(foreach obj,$(2),$(call gb_LinkTarget_add_cxxobject,$(1),$(obj),$(3)))
1154 endef
1156 define gb_LinkTarget_add_objcobjects
1157 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcobject,$(1),$(obj),$(3),$(4)))
1158 endef
1160 define gb_LinkTarget_add_objcxxobjects
1161 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3),$(4)))
1162 endef
1164 define gb_LinkTarget_add_asmobjects
1165 $(foreach obj,$(2),$(call gb_LinkTarget_add_asmobject,$(1),$(obj),$(3)))
1166 endef
1168 define gb_LinkTarget_add_noexception_objects
1169 $(foreach obj,$(2),$(call gb_LinkTarget_add_noexception_object,$(1),$(obj),$(4)))
1170 endef
1172 define gb_LinkTarget_add_exception_objects
1173 $(foreach obj,$(2),$(call gb_LinkTarget_add_exception_object,$(1),$(obj),$(4)))
1174 endef
1176 #only useful for building x64 libraries on windows
1177 define gb_LinkTarget_add_x64_generated_exception_objects
1178 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
1179 $(foreach obj,$(2),$(eval $(call gb_GenCxxObject_get_target,$(obj)) : CXXOBJECT_X64 := YES))
1180 endef
1182 define gb_LinkTarget_add_generated_cobjects
1183 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1184 endef
1186 #only useful for building x64 libraries on windows
1187 define gb_LinkTarget_add_x64_generated_cobjects
1188 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1189 $(foreach obj,$(2),$(eval $(call gb_GenCObject_get_target,$(obj)) : COBJECT_X64 := YES))
1190 endef
1192 define gb_LinkTarget_add_generated_cxxobjects
1193 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_cxx_object,$(1),$(obj),$(3)))
1194 endef
1196 define gb_LinkTarget_add_generated_exception_object
1197 $(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)) $(4))
1198 endef
1200 define gb_LinkTarget_add_generated_exception_objects
1201 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
1202 endef
1204 define gb_LinkTarget_set_targettype
1205 $(call gb_LinkTarget_get_target,$(1)) \
1206 $(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE := $(2)
1208 endef
1210 define gb_LinkTarget_set_x64
1211 $(call gb_LinkTarget_get_target,$(1)) \
1212 $(call gb_LinkTarget_get_dep_target,$(1)) : LIBRARY_X64 := $(2)
1214 endef
1216 define gb_LinkTarget_set_dlltarget
1217 $(call gb_LinkTarget_get_clean_target,$(1)) \
1218 $(call gb_LinkTarget_get_target,$(1)) : DLLTARGET := $(2)
1220 endef
1222 define gb_LinkTarget_set_auxtargets
1223 $$(call gb_Output_error,\
1224 gb_LinkTarget_set_auxtargets: use gb_LinkTarget_add_auxtargets instead.)
1225 endef
1227 # Add a file that is built by the LinkTarget command and define
1228 # a dummy touch rule for it so it can be tracked via dependencies.
1229 # gb_LinkTarget_add_auxtarget linktarget auxtarget
1230 # The assumption is that the file is created by linking; in case it does not
1231 # exist there is some problem. This can be caused on WNT by re-naming DLL
1232 # files (which are aux-targets) but not the import .lib files (which
1233 # are the LinkTargets) and doing an incremental build.
1234 define gb_LinkTarget_add_auxtarget
1235 $(2) : $(call gb_LinkTarget_get_target,$(1))
1236 if test -e $$@; then \
1237 touch -r $$< $$@; \
1238 else \
1239 rm -f $$<; \
1240 echo "ERROR: aux-target missing, library deleted, please try running make again"; \
1241 false; \
1244 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS += $(2)
1246 endef
1248 define gb_LinkTarget_add_auxtargets
1249 $(foreach aux,$(2),$(call gb_LinkTarget_add_auxtarget,$(1),$(aux)))
1251 endef
1253 define gb_LinkTarget__add_internal_headers
1254 $(call gb_LinkTarget_get_headers_target,$(1)) : $(2)
1255 $(2) :| $(call gb_LinkTarget_get_external_headers_target,$(1))
1257 endef
1259 define gb_LinkTarget_add_custom_headers
1260 $$(call gb_Output_error,\
1261 gb_LinkTarget_add_custom_headers: use gb_LinkTarget_use_custom_headers instead.)
1262 endef
1264 define gb_LinkTarget__use_custom_headers
1265 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
1266 $(call gb_CustomTarget_get_target,$(2))
1267 $(call gb_LinkTarget__add_include,$(1),$(call gb_CustomTarget_get_workdir,$(2)))
1269 endef
1271 define gb_LinkTarget_use_custom_headers
1272 $(foreach customtarget,$(2),$(call gb_LinkTarget__use_custom_headers,$(1),$(customtarget)))
1274 endef
1276 define gb_LinkTarget_add_package_headers
1277 $$(call gb_Output_error,\
1278 gb_LinkTarget_add_package_headers: use gb_LinkTarget_use_package instead.)
1279 endef
1281 # add SDI (svidl) headers
1282 define gb_LinkTarget_add_sdi_headers
1283 $(call gb_LinkTarget__add_internal_headers,$(1),$(foreach sdi,$(2),$(call gb_SdiTarget_get_target,$(sdi))))
1284 $(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_clean_target,$(sdi)))
1286 endef
1288 define gb_LinkTarget__set_precompiled_header_impl
1289 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_PrecompiledHeader_get_clean_target,$(3))
1290 $(call gb_PrecompiledHeader_get_target,$(3)) : $(2).cxx
1292 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_NoexPrecompiledHeader_get_clean_target,$(3))
1293 $(call gb_NoexPrecompiledHeader_get_target,$(3)) : $(2).cxx
1295 $(call gb_PrecompiledHeader_get_target,$(3)) : $(call gb_LinkTarget_get_headers_target,$(1))
1296 $(call gb_NoexPrecompiledHeader_get_target,$(3)) : $(call gb_LinkTarget_get_headers_target,$(1))
1298 $(call gb_LinkTarget_get_target,$(1)) : PCH_NAME := $(3)
1299 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJEX = $(call gb_PrecompiledHeader_get_objectfile, $(call gb_PrecompiledHeader_get_target,$(3)))
1300 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJNOEX = $(call gb_NoexPrecompiledHeader_get_objectfile, $(call gb_NoexPrecompiledHeader_get_target,$(3)))
1301 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS = $$(PCHOBJEX)
1303 $(call gb_LinkTarget_get_headers_target,$(1)) \
1304 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(DEFS)
1305 $(call gb_LinkTarget_get_headers_target,$(1)) \
1306 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(T_CXXFLAGS) $(call gb_LinkTarget__get_cxxflags,$(1))
1308 $(call gb_PrecompiledHeader_get_target,$(3)) : VISIBILITY :=
1309 $(call gb_NoexPrecompiledHeader_get_target,$(3)) : VISIBILITY :=
1311 $(call gb_PrecompiledHeader_get_timestamp,$(1)) : $(call gb_PrecompiledHeader_get_target,$(3))
1312 $(call gb_NoexPrecompiledHeader_get_timestamp,$(1)) : $(call gb_NoexPrecompiledHeader_get_target,$(3))
1314 ifeq ($(gb_FULLDEPS),$(true))
1315 -include \
1316 $(call gb_PrecompiledHeader_get_dep_target,$(3)) \
1317 $(call gb_NoexPrecompiledHeader_get_dep_target,$(3))
1318 $(call gb_LinkTarget_get_dep_target,$(1)) : PCH_DEFS := $$(DEFS)
1319 $(call gb_LinkTarget_get_dep_target,$(1)) : PCH_CXXFLAGS := $$(T_CXXFLAGS) $(call gb_LinkTarget__get_cxxflags,$(1))
1320 endif
1322 endef
1324 define gb_LinkTarget_set_precompiled_header
1325 ifeq ($(gb_ENABLE_PCH),$(true))
1326 $(call gb_LinkTarget__set_precompiled_header_impl,$(1),$(2),$(notdir $(2)))
1327 endif
1329 endef
1331 define gb_LinkTarget_add_precompiled_header
1332 $$(call gb_Output_error,\
1333 gb_LinkTarget_add_precompiled_header: use gb_LinkTarget_set_precompiled_header instead.)
1334 endef
1336 define gb_LinkTarget_add_external_headers
1337 $$(call gb_Output_error,\
1338 gb_LinkTarget_add_external_headers: use gb_LinkTarget_use_package instead.)
1339 endef
1341 # use a header package, possibly from another module (i.e. via OUTDIR)
1342 define gb_LinkTarget_use_package
1343 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
1344 $(call gb_Package_get_target,$(strip $(2)))
1346 endef
1348 define gb_LinkTarget_use_packages
1349 $(foreach package,$(2),$(call gb_LinkTarget_use_package,$(1),$(package)))
1350 endef
1352 # Use sources from unpacked tarball of an external project
1353 define gb_LinkTarget_use_unpacked
1354 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| $(call gb_UnpackedTarball_get_final_target,$(2))
1356 endef
1358 # Use artifacts from ExternalProject (i. e. configure) of an external project
1359 # example in expat: StaticLibrary depends on ExternalProject outcome
1360 define gb_LinkTarget_use_external_project
1361 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| $(call gb_ExternalProject_get_target,$(2))
1363 endef
1365 # Use headers provided by another link target.
1367 # This function should only be needed to enforce correct build ordering,
1368 # if the link target does not use the other link target.
1370 # gb_LinkTarget_use_headers linktarget other-linktarget(s)
1371 define gb_LinkTarget_use_headers
1372 $(call gb_LinkTarget_get_external_headers_target,$(1)) :\
1373 $(foreach linktarget,$(2),$(call gb_LinkTarget_get_headers_target,$(linktarget)))
1375 endef
1377 # this forwards to functions that must be defined in RepositoryExternal.mk.
1378 # $(eval $(call gb_LinkTarget_use_external,library,external))
1379 define gb_LinkTarget_use_external
1380 $(if $(filter undefined,$(origin gb_LinkTarget__use_$(2))),\
1381 $(error gb_LinkTarget_use_external: unknown external: $(2)),\
1382 $(call gb_LinkTarget__use_$(2),$(1)))
1383 endef
1385 # $(call gb_LinkTarget_use_externals,library,externals)
1386 gb_LinkTarget_use_externals = \
1387 $(foreach external,$(2),$(call gb_LinkTarget_use_external,$(1),$(external)))
1389 define gb_LinkTarget_set_visibility_default
1390 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY := default
1391 ifeq ($(gb_FULLDEPS),$(true))
1392 $(call gb_LinkTarget_get_dep_target,$(1)) : VISIBILITY := default
1393 endif
1394 ifeq ($(gb_ENABLE_PCH),$(true))
1395 ifneq ($(strip $$(PCH_NAME)),)
1396 $(call gb_PrecompiledHeader_get_target,$$(PCH_NAME)) : VISIBILITY := default
1397 $(call gb_NoexPrecompiledHeader_get_target,$$(PCH_NAME)) : VISIBILITY := default
1398 endif
1399 endif
1401 endef
1403 define gb_LinkTarget_set_warnings_not_errors
1404 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1405 ifeq ($(gb_FULLDEPS),$(true))
1406 $(call gb_LinkTarget_get_dep_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1407 endif
1409 endef
1411 # Set suffix of C++ files, if different from 'cxx'
1413 # This is useful for external libraries.
1415 # gb_LinkTarget_set_generated_cxx_suffix linktarget used-suffix
1416 define gb_LinkTarget_set_generated_cxx_suffix
1417 gb_LinkTarget_CXX_SUFFIX_$(1) := $(2)
1419 endef
1421 # vim: set noet sw=4: