bump product version to 6.3.0.0.beta1
[LibreOffice.git] / solenv / gbuild / LinkTarget.mk
blobe1c55969a2570b7e0aadaa079913d6c97eabe0eb
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 # defined by platform
31 # gb_AsmObject_get_source (.asm on Windows, .s elsewhere)
32 # gb_AsmObject__command
33 # gb_CObject__command_pattern
34 # gb_LinkTarget_CXXFLAGS
35 # gb_LinkTarget_LDFLAGS
36 # gb_LinkTarget_INCLUDE
37 # gb_YaccTarget__command(grammar-file, stem-for-message, source-target, include-target)
39 # Detect whether symbols should be enabled for the given gbuild target.
40 # enable if: no "-TARGET" defined AND [module is enabled OR "TARGET" defined]
41 gb_LinkTarget__symbols_enabled = \
42 $(and $(if $(filter -$(1),$(ENABLE_SYMBOLS_FOR)),,$(true)),\
43 $(or $(gb_Module_CURRENTMODULE_SYMBOLS_ENABLED),\
44 $(filter $(1),$(ENABLE_SYMBOLS_FOR))))
46 # debug flags, if the LinkTarget is named in the list of libraries of ENABLE_SYMBOLS_FOR
47 gb_LinkTarget__get_debugflags=$(if $(ENABLE_OPTIMIZED),$(gb_COMPILEROPTFLAGS),$(gb_COMPILERNOOPTFLAGS)) $(if $(call gb_LinkTarget__symbols_enabled,$(1)),$(gb_DEBUGINFO_FLAGS))
49 # similar for LDFLAGS, use linker optimization flags in non-debug case,
50 # but moreover strip debug from libraries for which debuginfo is not wanted
51 # (some libraries reuse .o files from other libraries, notably unittests)
52 gb_LinkTarget__get_stripldflags=$(if $(strip $(CFLAGS)$(CXXFLAGS)$(OBJCFLAGS)$(OBJCXXFLAGS)$(LDFLAGS)),,$(gb_LINKERSTRIPDEBUGFLAGS))
53 gb_LinkTarget__get_debugldflags=$(if $(call gb_LinkTarget__symbols_enabled,$(1)),$(gb_LINKER_DEBUGINFO_FLAGS),$(gb_LINKEROPTFLAGS) $(call gb_LinkTarget__get_stripldflags,$(1)))
55 # generic cflags/cxxflags to use (optimization flags, debug flags)
56 # user supplied CFLAGS/CXXFLAGS override default debug/optimization flags
57 # call gb_LinkTarget__get_cflags,linktargetmakefilename
58 gb_LinkTarget__get_cflags=$(if $(CFLAGS),$(CFLAGS),$(call gb_LinkTarget__get_debugflags,$(1)))
59 gb_LinkTarget__get_objcflags=$(if $(OBJCFLAGS),$(OBJCFLAGS),$(call gb_LinkTarget__get_debugflags,$(1)))
60 gb_LinkTarget__get_cxxflags=$(if $(CXXFLAGS),$(CXXFLAGS),$(call gb_LinkTarget__get_debugflags,$(1)))
61 gb_LinkTarget__get_objcxxflags=$(if $(OBJCXXFLAGS),$(OBJCXXFLAGS),$(call gb_LinkTarget__get_debugflags,$(1)))
62 gb_LinkTarget__get_cxxclrflags=$(call gb_LinkTarget__get_debugflags,$(1))
63 # call gb_LinkTarget__get_ldflags,linktargetmakefilename
64 gb_LinkTarget__get_ldflags=$(if $(LDFLAGS),$(LDFLAGS),$(call gb_LinkTarget__get_debugldflags,$(1)))
66 gb_LinkTarget_LAYER_LINKPATHS := \
67 URELIB:URELIB. \
68 UREBIN:URELIB. \
69 SDKBIN:URELIB. \
70 OOO:URELIB+OOO. \
71 SHLXTHDL:. \
72 OXT:OXT. \
73 NONE:URELIB+OOO+NONE. \
76 # Used to run a compiler plugin tool.
78 # At least for now, these definitions are generic enough so that they can be
79 # shared across all current use cases (COMPILER_EXTERNAL_TOOL,
80 # COMPILER_PLUGIN_TOOL) on all relevant toolchains (GCC?, Clang, clang-cl). If
81 # it ever becomes necessary, they can be moved to e.g.
82 # platform/com_{GCC,MSC}_class.mk and made different there.
84 # $(call gb_CObject__tool_command,relative-source,source)
85 define gb_CObject__tool_command
86 $(call gb_Output_announce,$(1).c,$(true),C ,3)
87 $(call gb_Helper_abbreviate_dirs,\
88 ICECC=no CCACHE_DISABLE=1 \
89 $(gb_CC) \
90 $(DEFS) \
91 $(gb_LTOFLAGS) \
92 $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
93 $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
94 $(gb_COMPILER_PLUGINS) \
95 $(T_CFLAGS) $(T_CFLAGS_APPEND) \
96 $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
97 -c $(2) \
98 -I$(dir $(2)) \
99 $(INCLUDE) \
101 endef
102 define gb_ObjCObject__tool_command
103 $(call gb_Output_announce,$(1).m,$(true),OCC,3)
104 $(call gb_Helper_abbreviate_dirs,\
105 ICECC=no CCACHE_DISABLE=1 \
106 $(gb_CC) \
107 $(DEFS) \
108 $(gb_LTOFLAGS) \
109 $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
110 $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
111 $(gb_COMPILER_PLUGINS) \
112 $(T_OBJCFLAGS) $(T_OBJCFLAGS_APPEND) \
113 $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
114 -c $(2) \
115 -I$(dir $(2)) \
116 $(INCLUDE) \
118 endef
119 define gb_CxxObject__tool_command
120 $(call gb_Output_announce,$(1).cxx,$(true),CXX,3)
121 $(call gb_Helper_abbreviate_dirs,\
122 ICECC=no CCACHE_DISABLE=1 \
123 $(gb_CXX) \
124 $(DEFS) \
125 $(gb_LTOFLAGS) \
126 $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
127 $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
128 $(gb_COMPILER_PLUGINS) \
129 $(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) \
130 $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
131 -c $(2) \
132 -I$(dir $(2)) \
133 $(INCLUDE) \
135 endef
136 define gb_ObjCxxObject__tool_command
137 $(call gb_Output_announce,$(1).mm,$(true),OCX,3)
138 $(call gb_Helper_abbreviate_dirs,\
139 ICECC=no CCACHE_DISABLE=1 \
140 $(gb_CXX) \
141 $(DEFS) \
142 $(gb_LTOFLAGS) \
143 $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
144 $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
145 $(gb_COMPILER_PLUGINS) \
146 $(T_OBJCXXFLAGS) $(T_OBJCXXFLAGS_APPEND) \
147 $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
148 -c $(2) \
149 -I$(dir $(2)) \
150 $(INCLUDE) \
152 endef
153 define gb_CxxClrObject__tool_command
154 $(call gb_Output_announce,$(1).cxx,$(true),CLR,3)
155 $(call gb_Helper_abbreviate_dirs,\
156 ICECC=no CCACHE_DISABLE=1 \
157 $(gb_CXX) \
158 $(DEFS) \
159 $(gb_LTOFLAGS) \
160 $(if $(VISIBILITY),,$(gb_VISIBILITY_FLAGS)) \
161 $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
162 $(gb_COMPILER_PLUGINS) \
163 $(T_CXXCLRFLAGS) $(T_CXXCLRFLAGS_APPEND) \
164 $(if $(EXTERNAL_CODE),$(gb_CXXFLAGS_Wundef),$(gb_DEFS_INTERNAL)) \
165 -c $(2) \
166 -I$(dir $(2)) \
167 $(INCLUDE) \
169 endef
172 # Overview of dependencies and tasks of LinkTarget
174 # target task depends on
175 # LinkTarget linking AsmObject CObject CxxObject GenCObject GenCxxObject ObjCObject ObjCxxObject CxxClrObject GenCxxClrObject
176 # LinkTarget/headers
177 # LinkTarget/dep joined dep file AsmObject/dep CObject/dep CxxObject/dep GenCObject/dep GenCxxObject/dep ObjCObject/dep ObjCxxObject/dep CxxClrObject/dep GenCxxClrObject/dep
178 # | LinkTarget/headers
179 # LinkTarget/headers all headers available
180 # including own generated
181 # PCH precompiled headers LinkTarget/headers
182 # CObject plain c compile | LinkTarget/headers
183 # CxxObject c++ compile | LinkTarget/headers PCH
184 # GenCObject plain c compile from | LinkTarget/headers
185 # generated source
186 # GenCxxObject C++ compile from | LinkTarget/headers PCH
187 # generated source
188 # ObjCObject objective c compile | LinkTarget/headers
189 # ObjCxxObject objective c++ compile | LinkTarget/headers
190 # CxxClrObject C++ CLR compile | LinkTarget/headers
191 # GenCxxClrObject C++ CLR compile from | LinkTarget/headers
192 # generated source
194 # AsmObject asm compile | LinkTarget
196 # CObject/dep dependencies these targets generate empty dep files
197 # CxxObject/dep dependencies that are populated upon compile
198 # GenCObject/dep dependencies
199 # GenCxxObject/dep dependencies
200 # ObjCObject/dep dependencies
201 # ObjCxxObject/dep dependencies
202 # CxxClrObject/dep dependencies
203 # GenCxxClrObject/dep dependencies
204 # AsmObject/dep dependencies
206 # LinkTarget/headers means gb_LinkTarget_get_headers_target etc.
207 # dependencies prefixed with | are build-order only dependencies
210 # check that objects are only linked into one link target:
211 # multiple linking may cause problems because different link targets may
212 # require different compiler flags
213 define gb_Object__owner
214 $$(if $$(OBJECTOWNER),\
215 $$(call gb_Output_error,fdo#47246: $(1) is linked in by $$(OBJECTOWNER) $(2)))$(2)
216 endef
218 # For every object there is a dep file (if gb_FULLDEPS is active).
219 # The dep file depends on the object: the Object__command also updates the
220 # dep file as a side effect.
221 # In the dep file rule just touch it so it's newer than the object.
223 ifneq ($(FORCE_COMPILE_ALL),)
224 # This one only exists to force .c/.cxx "rebuilds" when running a compiler tool.
225 .PHONY: force_compile_all_target
226 force_compile_all_target:
227 gb_FORCE_COMPILE_ALL_TARGET := force_compile_all_target
228 endif
230 # CObject class
232 gb_CObject_get_source = $(1)/$(2).c
234 ifneq ($(COMPILER_EXTERNAL_TOOL)$(COMPILER_PLUGIN_TOOL),)
235 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
236 $(call gb_CObject__tool_command,$*,$<)
237 else
238 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%)
239 $(call gb_Output_announce,$*.c,$(true),$(if $(COMPILER_TEST),C? ,C ),3)
240 $(call gb_CObject__command_pattern,$@,$(T_CFLAGS) $(T_CFLAGS_APPEND),$<,$(call gb_CObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
241 endif
243 # Note: if the *Object_dep_target does not exist it will be created by
244 # concat-deps as PHONY
245 ifeq ($(gb_FULLDEPS),$(true))
246 $(dir $(call gb_CObject_get_dep_target,%)).dir :
247 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
249 $(dir $(call gb_CObject_get_dep_target,%))%/.dir :
250 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
252 $(call gb_CObject_get_dep_target,%) :
253 $(if $(wildcard $@),touch $@)
255 endif
258 # CxxObject class
260 gb_CxxObject_get_source = $(1)/$(2).cxx
262 # Only enable PCH if the PCH_CXXFLAGS and the PCH_DEFS (from the linktarget)
263 # are the same as the T_CXXFLAGS and DEFS we want to use for this object. This
264 # should usually be the case. The DEFS/T_CXXFLAGS would have to be manually
265 # overridden for one object file for them to differ. PCH_CXXFLAGS/PCH_DEFS
266 # should never be overridden on an object -- they should be the same as for the
267 # whole linktarget. In general it should be cleaner to use a static library
268 # compiled with different flags and link that in rather than mixing different
269 # flags in one linktarget.
270 define gb_CxxObject__set_pchflags
271 ifneq ($(gb_ENABLE_PCH),)
272 ifneq ($(strip $$(PCH_NAME)),)
273 ifeq ($$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)),$$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
274 $$@ : PCHFLAGS := $$(call gb_PrecompiledHeader_get_enableflags,$$(PCH_NAME),$$(PCH_LINKTARGETMAKEFILENAME))
275 else
276 $$(warning No precompiled header available for $$*.cxx .)
277 $$(info precompiled header flags : $$(sort $$(PCH_CXXFLAGS) $$(PCH_DEFS) $$(gb_LinkTarget_EXCEPTIONFLAGS)))
278 $$(info . object flags : $$(sort $$(T_CXXFLAGS) $$(T_CXXFLAGS_APPEND) $$(DEFS)))
279 $$(error Incorrect precompiled header setup or internal gbuild error.)
280 $$@ : PCHFLAGS :=
281 endif
282 endif
283 endif
284 endef
286 ifneq ($(COMPILER_EXTERNAL_TOOL)$(COMPILER_PLUGIN_TOOL),)
287 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
288 $(call gb_CxxObject__tool_command,$*,$<)
289 else
290 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
291 $(call gb_Output_announce,$*.cxx,$(true),$(if $(COMPILER_TEST),CPT,CXX),3)
292 $(eval $(gb_CxxObject__set_pchflags))
293 $(call gb_CObject__command_pattern,$@,$(T_CXXFLAGS) $(T_CXXFLAGS_APPEND) $(if $(COMPILER_TEST),$(gb_COMPILER_TEST_FLAGS)),$<,$(call gb_CxxObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
294 endif
296 ifeq ($(gb_FULLDEPS),$(true))
297 $(dir $(call gb_CxxObject_get_dep_target,%)).dir :
298 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
300 $(dir $(call gb_CxxObject_get_dep_target,%))%/.dir :
301 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
303 $(call gb_CxxObject_get_dep_target,%) :
304 $(if $(wildcard $@),touch $@,\
305 $(eval $(gb_CxxObject__set_pchflags)))
307 endif
310 # GenCObject class
312 gb_GenCObject_get_source = $(WORKDIR)/$(1).c
314 $(call gb_GenCObject_get_target,%) : $(gb_FORCE_COMPILE_ALL_TARGET)
315 $(call gb_Output_announce,$*.c,$(true),C ,3)
316 test -f $(call gb_GenCObject_get_source,$*) || (echo "Missing generated source file $(call gb_GenCObject_get_source,$*)" && false)
317 $(call gb_CObject__command_pattern,$@,$(T_CFLAGS) $(T_CFLAGS_APPEND),$(call gb_GenCObject_get_source,$*),$(call gb_GenCObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
319 ifeq ($(gb_FULLDEPS),$(true))
320 $(dir $(call gb_GenCObject_get_dep_target,%)).dir :
321 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
323 $(dir $(call gb_GenCObject_get_dep_target,%))%/.dir :
324 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
326 $(call gb_GenCObject_get_dep_target,%) :
327 $(if $(wildcard $@),touch $@)
329 endif
332 # GenCxxObject class
334 gb_GenCxxObject_get_source = $(WORKDIR)/$(1).$(gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(2)))
336 $(call gb_GenCxxObject_get_target,%) : $(gb_FORCE_COMPILE_ALL_TARGET)
337 $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$(GEN_CXX_SOURCE)),$(true),CXX,3)
338 test -f $(GEN_CXX_SOURCE) || (echo "Missing generated source file $(GEN_CXX_SOURCE)" && false)
339 $(eval $(gb_CxxObject__set_pchflags))
340 $(call gb_CObject__command_pattern,$@,$(T_CXXFLAGS) $(T_CXXFLAGS_APPEND),$(GEN_CXX_SOURCE),$(call gb_GenCxxObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
342 ifeq ($(gb_FULLDEPS),$(true))
343 $(dir $(call gb_GenCxxObject_get_dep_target,%)).dir :
344 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
346 $(dir $(call gb_GenCxxObject_get_dep_target,%))%/.dir :
347 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
349 $(call gb_GenCxxObject_get_dep_target,%) :
350 $(if $(wildcard $@),touch $@,\
351 $(eval $(gb_CxxObject__set_pchflags)))
353 endif
356 # GenCxxClrObject class
358 gb_GenCxxClrObject_get_source = $(WORKDIR)/$(1).$(gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(2)))
360 $(call gb_GenCxxClrObject_get_target,%) : $(gb_FORCE_COMPILE_ALL_TARGET)
361 $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$(GEN_CXXCLR_SOURCE)),$(true),CLR,3)
362 test -f $(GEN_CXXCLR_SOURCE) || (echo "Missing generated source file $(GEN_CXXCLR_SOURCE)" && false)
363 $(call gb_CObject__command_pattern,$@,$(T_CXXCLRFLAGS) $(T_CXXCLRFLAGS_APPEND),$(GEN_CXXCLR_SOURCE),$(call gb_GenCxxClrObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
365 ifeq ($(gb_FULLDEPS),$(true))
366 $(dir $(call gb_GenCxxClrObject_get_dep_target,%)).dir :
367 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
369 $(dir $(call gb_GenCxxClrObject_get_dep_target,%))%/.dir :
370 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
372 $(call gb_GenCxxClrObject_get_dep_target,%) :
373 $(if $(wildcard $@),touch $@)
375 endif
378 # YaccTarget class
380 # XXX: This is more complicated than necessary, but we cannot just use
381 # the generated C++ file as the main target, because we need to let the
382 # header depend on that to ensure the header is present before anything
383 # tries to use it.
385 gb_YaccTarget_get_source = $(1)/$(2).y
387 .PHONY : $(call gb_YaccTarget_get_clean_target,%)
388 $(call gb_YaccTarget_get_clean_target,%) :
389 $(call gb_Output_announce,$*,$(false),YAC,3)
390 $(call gb_Helper_abbreviate_dirs,\
391 rm -f $(call gb_YaccTarget_get_grammar_target,$*) $(call gb_YaccTarget_get_header_target,$*) $(call gb_YaccTarget_get_target,$*))
393 $(call gb_YaccTarget_get_target,%) : $(call gb_YaccTarget_get_source,$(SRCDIR),%)
394 $(call gb_YaccTarget__command,$<,$*,$@,$(call gb_YaccTarget_get_header_target,$*),$(call gb_YaccTarget_get_grammar_target,$*))
396 # call gb_YaccTarget_YaccTarget,yacctarget
397 define gb_YaccTarget_YaccTarget
398 $(call gb_YaccTarget_get_grammar_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
399 touch $$@
400 $(call gb_YaccTarget_get_header_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
401 touch $$@
403 endef
405 gb_YACC := bison
408 # LexTarget class
410 gb_LexTarget_get_source = $(1)/$(2).l
412 .PHONY : $(call gb_LexTarget_get_clean_target,%)
413 $(call gb_LexTarget_get_clean_target,%) :
414 $(call gb_Output_announce,$*,$(false),LEX,3)
415 $(call gb_Helper_abbreviate_dirs,\
416 rm -f $(call gb_LexTarget_get_scanner_target,$*) $(call gb_LexTarget_get_target,$*))
418 $(call gb_LexTarget_get_target,%) : $(call gb_LexTarget_get_source,$(SRCDIR),%)
419 $(call gb_LexTarget__command,$<,$*,$@,$(call gb_LexTarget_get_scanner_target,$*))
421 # gb_LexTarget_LexTarget(scanner-file)
422 define gb_LexTarget_LexTarget
423 $(call gb_LexTarget_get_scanner_target,$(1)) : $(call gb_LexTarget_get_target,$(1))
424 touch $$@
426 endef
428 # gb_LexTarget__command(scanner-file, stem-for-message, done-pseudo-target, source-target)
429 define gb_LexTarget__command
430 $(call gb_Output_announce,$(2),$(true),LEX,3)
431 $(call gb_Helper_abbreviate_dirs,\
432 mkdir -p $(dir $(3)) && \
433 $(FLEX) $(T_LEXFLAGS) -o$(4) $(1) && touch $(3) )
434 endef
437 # ObjCxxObject class
440 gb_ObjCxxObject_get_source = $(1)/$(2).mm
442 ifneq ($(COMPILER_EXTERNAL_TOOL)$(COMPILER_PLUGIN_TOOL),)
443 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
444 $(call gb_ObjCxxObject__tool_command,$*,$<)
445 else
446 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%)
447 $(call gb_Output_announce,$*.mm,$(true),$(if $(COMPILER_TEST),O?X,OCX),3)
448 $(call gb_CObject__command_pattern,$@,$(T_OBJCXXFLAGS) $(T_OBJCXXFLAGS_APPEND),$<,$(call gb_ObjCxxObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
449 endif
451 ifeq ($(gb_FULLDEPS),$(true))
452 $(dir $(call gb_ObjCxxObject_get_dep_target,%)).dir :
453 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
455 $(dir $(call gb_ObjCxxObject_get_dep_target,%))%/.dir :
456 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
458 $(call gb_ObjCxxObject_get_dep_target,%) :
459 $(if $(wildcard $@),touch $@)
461 endif
464 # ObjCObject class
467 gb_ObjCObject_get_source = $(1)/$(2).m
469 ifneq ($(COMPILER_EXTERNAL_TOOL)$(COMPILER_PLUGIN_TOOL),)
470 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
471 $(call gb_ObjCObject__tool_command,$*,$<)
472 else
473 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%)
474 $(call gb_Output_announce,$*.m,$(true),$(if $(COMPILER_TEST),O?C,OCC),3)
475 $(call gb_CObject__command_pattern,$@,$(T_OBJCFLAGS) $(T_OBJCFLAGS_APPEND),$<,$(call gb_ObjCObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
476 endif
478 ifeq ($(gb_FULLDEPS),$(true))
479 $(dir $(call gb_ObjCObject_get_dep_target,%)).dir :
480 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
482 $(dir $(call gb_ObjCObject_get_dep_target,%))%/.dir :
483 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
485 $(call gb_ObjCObject_get_dep_target,%) :
486 $(if $(wildcard $@),touch $@)
488 endif
491 # CxxClrObject class
494 gb_CxxClrObject_get_source = $(1)/$(2).cxx
496 ifneq ($(COMPILER_EXTERNAL_TOOL)$(COMPILER_PLUGIN_TOOL),)
497 $(call gb_CxxClrObject_get_target,%) : $(call gb_CxxClrObject_get_source,$(SRCDIR),%) $(gb_FORCE_COMPILE_ALL_TARGET)
498 $(call gb_CxxClrObject__tool_command,$*,$<)
499 else
500 $(call gb_CxxClrObject_get_target,%) : $(call gb_CxxClrObject_get_source,$(SRCDIR),%)
501 $(call gb_Output_announce,$*.cxx,$(true),$(if $(COMPILER_TEST),C?R,CLR),3)
502 $(call gb_CObject__command_pattern,$@,$(T_CXXCLRFLAGS) $(T_CXXCLRFLAGS_APPEND),$<,$(call gb_CxxClrObject_get_dep_target,$*),$(COMPILER_PLUGINS),$(T_SYMBOLS))
503 endif
505 ifeq ($(gb_FULLDEPS),$(true))
506 $(dir $(call gb_CxxClrObject_get_dep_target,%)).dir :
507 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
509 $(dir $(call gb_CxxClrObject_get_dep_target,%))%/.dir :
510 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
512 $(call gb_CxxClrObject_get_dep_target,%) :
513 $(if $(wildcard $@),touch $@)
515 endif
518 # AsmObject class
520 $(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%)
521 $(call gb_AsmObject__command,$@,$*,$<,$(call gb_AsmObject_get_dep_target,$*))
523 ifeq ($(gb_FULLDEPS),$(true))
524 $(dir $(call gb_AsmObject_get_dep_target,%)).dir :
525 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
527 $(dir $(call gb_AsmObject_get_dep_target,%))%/.dir :
528 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
530 $(call gb_AsmObject_get_dep_target,%) :
531 $(if $(wildcard $@),touch $@)
533 endif
536 # LinkTarget class
538 gb_LinkTarget_DEFAULTDEFS := $(gb_GLOBALDEFS)
540 .PHONY : $(WORKDIR)/Clean/LinkTarget/%
541 $(WORKDIR)/Clean/LinkTarget/% :
542 $(call gb_Output_announce,$*,$(false),LNK,4)
543 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
544 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
545 $(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
546 $(foreach object,$(COBJECTS),$(call gb_CObject_get_dwo_target,$(object))) \
547 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
548 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
549 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dwo_target,$(object))) \
550 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
551 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object))) \
552 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dwo_target,$(object))) \
553 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
554 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
555 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dwo_target,$(object))) \
556 $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \
557 $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_dep_target,$(object))) \
558 $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_dwo_target,$(object))) \
559 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
560 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object))) \
561 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dwo_target,$(object))) \
562 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
563 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
564 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dwo_target,$(object))) \
565 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
566 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
567 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dwo_target,$(object))) \
568 $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_target,$(object))) \
569 $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_dep_target,$(object))) \
570 $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_dwo_target,$(object))) \
571 $(call gb_LinkTarget_get_target,$(LINKTARGET)) \
572 $(call gb_LinkTarget_get_dep_target,$(LINKTARGET)) \
573 $(call gb_LinkTarget_get_headers_target,$(LINKTARGET)) \
574 $(call gb_LinkTarget_get_objects_list,$(LINKTARGET)) \
575 $(ILIBTARGET) \
576 $(AUXTARGETS)) && \
577 cat $${RESPONSEFILE} /dev/null | $(if $(filter WNT,$(OS)),env -i PATH="$$PATH") xargs -n 200 rm -fr && \
578 rm -f $${RESPONSEFILE}
581 # cat the deps of all objects in one file, then we need only open that one file
582 # call gb_LinkTarget__command_dep,dep_target,linktargetname
583 define gb_LinkTarget__command_dep
584 $(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
585 $(call gb_Helper_abbreviate_dirs,\
586 mkdir -p $(dir $(1)) && \
587 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
588 $(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
589 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
590 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object)))\
591 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
592 $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_dep_target,$(object)))\
593 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object)))\
594 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
595 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
596 $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_dep_target,$(object))) \
597 ) && \
598 $(call gb_Executable_get_command,concat-deps) $${RESPONSEFILE} > $(1)) && \
599 rm -f $${RESPONSEFILE}
601 endef
603 # call gb_LinkTarget__command_objectlist,linktarget
604 define gb_LinkTarget__command_objectlist
605 TEMPFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
606 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
607 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
608 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
609 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
610 $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \
611 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
612 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
613 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
614 $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_target,$(object))) \
615 $(PCHOBJS)) && \
616 $(if $(EXTRAOBJECTLISTS),cat $(EXTRAOBJECTLISTS) >> $${TEMPFILE} && ) \
617 mv $${TEMPFILE} $(1)
619 endef
621 $(WORKDIR)/LinkTarget/%/.dir :
622 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
624 # Target for the .exports of the shared library, to speed up incremental build.
625 # This deliberately does nothing if the file exists; the file is actually
626 # written in gb_LinkTarget__command_dynamiclink.
627 # Put this pattern rule here so it overrides the one below.
628 # (this is rather ugly: because of % the functions cannot be used)
629 $(WORKDIR)/LinkTarget/Library/%.exports :
630 $(if $(wildcard $@),,mkdir -p $(dir $@) && touch $@)
632 # This recipe actually also builds the dep-target as a side-effect, which
633 # is an optimization to reduce incremental build time.
634 # (with exception for concat-dep executable itself which does not exist yet...)
635 $(WORKDIR)/LinkTarget/% : $(gb_Helper_MISCDUMMY)
636 $(call gb_LinkTarget__command_impl,$@,$*)
638 # call gb_LinkTarget__make_installed_rule,linktarget
639 define gb_LinkTarget__make_installed_rule
640 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_LinkTarget_get_headers_target,$(1))
641 $$(call gb_LinkTarget__command_impl,$(call gb_LinkTarget_get_target,$(1)),$(call gb_LinkTarget__get_workdir_linktargetname,$(1)))
643 endef
645 # it's not possible to use a pattern rule for files in INSTDIR because
646 # it would inevitably conflict with the pattern rule for Package
647 # (especially since external libraries are delivered via Package)
648 # call gb_LinkTarget__command_impl,linktargettarget,linktargetname
649 define gb_LinkTarget__command_impl
650 $(if $(gb_FULLDEPS),\
651 $(if $(findstring concat-deps,$(2)),,\
652 $(call gb_LinkTarget__command_dep,$(call gb_LinkTarget_get_dep_target,$(2)).tmp,$(2)) \
653 mv $(call gb_LinkTarget_get_dep_target,$(2)).tmp $(call gb_LinkTarget_get_dep_target,$(2))))
654 $(if $(filter $(2),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library__get_workdir_linktargetname,$(lib)))),\
655 $(if $(filter $(true),$(call gb_LinkTarget__is_build_lib,$(2))),\
656 $(call gb_LinkTarget__command,$(1),$(2)),\
657 mkdir -p $(dir $(1)) && echo invalid - merged lib > $(1) \
658 $(if $(SOVERSIONSCRIPT),&& echo invalid - merged lib > $(WORKDIR)/LinkTarget/$(2))),\
659 $(if $(filter-out CompilerTest,$(TARGETTYPE)), \
660 $(call gb_LinkTarget__command,$(1),$(2))))
661 $(call gb_LinkTarget__command_objectlist,$(WORKDIR)/LinkTarget/$(2).objectlist)
662 endef
664 ifeq ($(gb_FULLDEPS),$(true))
665 $(call gb_LinkTarget_get_dep_target,%) : $(call gb_Executable_get_runtime_dependencies,concat-deps)
666 $(call gb_LinkTarget__command_dep,$@,$*)
667 endif
669 # Ok, this is some dark voodoo: When declaring a linktarget with
670 # gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
671 # target. When the rule for the headertarget is executed and SELF does not
672 # match the target name, we are depending on a linktarget that was never
673 # declared. In a full build exclusively in gbuild that should never happen.
674 define gb_LinkTarget__get_headers_check
675 ifneq ($$(SELF),$$*)
676 $$(eval $$(call gb_Output_error,used LinkTarget $$* not defined))
677 endif
678 $$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, touch $$@)
680 endef
682 $(WORKDIR)/Headers/%/.dir :
683 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
685 # sadly because of the subdirectories can't have pattern deps on .dir here
686 $(WORKDIR)/Headers/% :
687 $(eval $(gb_LinkTarget__get_headers_check))
688 $(COMMAND)
690 # Explanation of some of the targets:
691 # - gb_LinkTarget_get_headers_target is the target that guarantees all headers
692 # from the linked against libraries and the linktargets own generated headers
693 # are generated.
694 # - gb_LinkTarget_get_target links the objects into a file in WORKDIR.
695 # gb_LinkTarget_get_target depends on gb_LinkTarget_get_headers_target.
696 # gb_LinkTarget_get_target depends additionally on the objects, which in turn
697 # depend build-order only on the gb_LinkTarget_get_headers_target. The build
698 # order-only dependency ensures all headers to be there for compiling and
699 # dependency generation without causing all objects to be rebuild when one
700 # header changes. Only the ones with an explicit dependency in their generated
701 # dependency file will be rebuild.
703 # gb_LinkTarget_get_target is the target that links the objects into a file in
704 # WORKDIR
705 # Explanation of some of the variables:
706 # - AUXTARGETS are the additionally generated files that need to be cleaned out
707 # on clean.
708 # - PCH_CXXFLAGS and PCH_DEFS are the flags that the precompiled headers will
709 # be compiled with. They should never be overridden in a single object
710 # files.
711 # - TARGETTYPE is the type of linktarget as some platforms need very different
712 # command to link different targettypes.
713 # - LIBRARY_X64 is only relevant for building a x64 library on windows.
714 # - PE_X86 is only relevant for building a x86 binaries on Windows.
716 # Since most variables are set on the linktarget and not on the object, the
717 # object learns about these setting via GNU makes scoping of target variables.
718 # Therefore it is important that objects are only directly depended on by the
719 # linktarget. This for example means that you cannot build a single object
720 # alone, because then you would directly depend on the object.
722 # A note about flags: because the overriding the global variables with a target
723 # local variable of the same name is considered obscure, the target local
724 # variables have a T_ prefix.
726 # call gb_LinkTarget_LinkTarget,linktarget,linktargetmakefilename,layer
727 define gb_LinkTarget_LinkTarget
728 $(call gb_LinkTarget_get_clean_target,$(1)) : LINKTARGET := $(1)
729 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
730 $(call gb_LinkTarget_get_headers_target,$(1)) : SELF := $(call gb_LinkTarget__get_workdir_linktargetname,$(1))
731 $(call gb_LinkTarget_get_headers_target,$(1)) : \
732 | $(dir $(call gb_LinkTarget_get_headers_target,$(1))).dir \
733 $(dir $(call gb_LinkTarget_get_target,$(1))).dir \
734 $(dir $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1))).dir
735 $(call gb_LinkTarget_get_target,$(1)) : ILIBTARGET :=
736 $(call gb_LinkTarget_get_clean_target,$(1)) \
737 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
738 $(call gb_LinkTarget_get_clean_target,$(1)) \
739 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
740 $(call gb_LinkTarget_get_clean_target,$(1)) \
741 $(call gb_LinkTarget_get_target,$(1)) : YACCOBJECT :=
742 $(call gb_LinkTarget_get_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
743 $(call gb_LinkTarget_get_clean_target,$(1)) \
744 $(call gb_LinkTarget_get_target,$(1)) : LEXOBJECT :=
745 $(call gb_LinkTarget_get_target,$(1)) : T_LEXFLAGS := $$(gb_LinkTarget_LEXFLAGS) $(LEXFLAGS)
746 $(call gb_LinkTarget_get_clean_target,$(1)) \
747 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
748 $(call gb_LinkTarget_get_clean_target,$(1)) \
749 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
750 $(call gb_LinkTarget_get_clean_target,$(1)) \
751 $(call gb_LinkTarget_get_target,$(1)) : CXXCLROBJECTS :=
752 $(call gb_LinkTarget_get_clean_target,$(1)) \
753 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS :=
754 $(call gb_LinkTarget_get_clean_target,$(1)) \
755 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS :=
756 $(call gb_LinkTarget_get_clean_target,$(1)) \
757 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS :=
758 $(call gb_LinkTarget_get_clean_target,$(1)) \
759 $(call gb_LinkTarget_get_target,$(1)) : GENCXXCLROBJECTS :=
760 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
761 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS_APPEND :=
762 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
763 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS_APPEND :=
764 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
765 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
766 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND :=
767 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
768 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND :=
769 $(call gb_LinkTarget_get_target,$(1)) : T_CXXCLRFLAGS := $$(gb_LinkTarget_CXXCLRFLAGS)
770 $(call gb_LinkTarget_get_target,$(1)) : T_CXXCLRFLAGS_APPEND :=
771 $(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
772 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
773 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
774 $(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))
775 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS :=
776 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS :=
777 $(call gb_LinkTarget_get_target,$(1)) : T_LIBS :=
778 $(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE :=
779 $(call gb_LinkTarget_get_target,$(1)) : LIBRARY_X64 :=
780 $(call gb_LinkTarget_get_target,$(1)) : PCH_NAME :=
781 $(call gb_LinkTarget_get_target,$(1)) : PCH_LINKTARGETMAKEFILENAME :=
782 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS :=
783 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJEX :=
784 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJNOEX :=
785 $(call gb_LinkTarget_get_target,$(1)) : PE_X86 :=
786 $(call gb_LinkTarget_get_target,$(1)) : PDBFILE :=
787 $(call gb_LinkTarget_get_target,$(1)) : TARGETGUI :=
788 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS :=
789 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES :=
790 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY :=
791 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS :=
792 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_DISABLED :=
793 $(call gb_LinkTarget_get_target,$(1)) : PLUGIN_WARNINGS_AS_ERRORS :=
794 $(call gb_LinkTarget_get_target,$(1)) : EXTERNAL_CODE :=
795 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT :=
796 $(call gb_LinkTarget_get_target,$(1)) : COMPILER_TEST :=
797 $(call gb_LinkTarget_get_target,$(1)) : T_SYMBOLS := $(if $(call gb_LinkTarget__symbols_enabled,$(2)),$(true),$(false))
799 ifeq ($(gb_FULLDEPS),$(true))
800 ifeq (depcache:,$(filter depcache,$(.FEATURES)):$(gb_PARTIAL_BUILD))
801 -includedepcache $(call gb_LinkTarget_get_dep_target,$(1))
802 else
803 -include $(call gb_LinkTarget_get_dep_target,$(1))
804 endif
805 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
806 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
807 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS :=
808 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
809 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXCLROBJECTS :=
810 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS :=
811 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
812 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
813 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXCLROBJECTS :=
814 $(call gb_LinkTarget_get_dep_target,$(1)) : YACCOBJECTS :=
815 endif
817 gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(1)) := cxx
819 # installed linktargets need a rule to build!
820 $(if $(findstring $(INSTDIR),$(1)),$(call gb_LinkTarget__make_installed_rule,$(1)))
822 $(call gb_PrecompiledHeader_generate_timestamp_rule,$(2))
824 endef
826 # call gb_LinkTarget_set_soversion_script,linktarget,soversionscript
827 define gb_LinkTarget_set_soversion_script
828 $(call gb_LinkTarget_get_target,$(1)) : $(2)
829 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT := $(2)
831 endef
833 # call gb_LinkTarget_add_defs,linktarget,defines
834 define gb_LinkTarget_add_defs
835 $(call gb_LinkTarget_get_target,$(1)) : DEFS += $(2)
836 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS += $(2)
837 endef
839 # call gb_LinkTarget_add_cflags,linktarget,cflags
840 define gb_LinkTarget_add_cflags
841 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS_APPEND += $(2)
842 endef
844 # call gb_LinkTarget_add_cxxflags,linktarget,cxxflags
845 define gb_LinkTarget_add_cxxflags
846 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS_APPEND += $(2)
847 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS += $(2)
848 endef
850 # call gb_LinkTarget_add_objcxxflags,linktarget,objcxxflags
851 define gb_LinkTarget_add_objcxxflags
852 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS_APPEND += $(2)
853 endef
855 # call gb_LinkTarget_add_objcflags,linktarget,objcflags
856 define gb_LinkTarget_add_objcflags
857 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS_APPEND += $(2)
859 endef
861 # call gb_LinkTarget_add_cxxclrflags,linktarget,cxxclrflags
862 define gb_LinkTarget_add_cxxclrflags
863 $(call gb_LinkTarget_get_target,$(1)) : T_CXXCLRFLAGS_APPEND += $(2)
864 endef
866 # call gb_LinkTarget__add_include,linktarget,includes
867 define gb_LinkTarget__add_include
868 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(2)
870 endef
872 # call gb_LinkTarget__check_srcdir_paths,linktarget,includepaths
873 define gb_LinkTarget__check_srcdir_paths
874 $(if $(filter-out $(wildcard $(2)),$(2)),\
875 $(call gb_Output_error,gb_LinkTarget_set_include: include paths $(filter-out $(wildcard $(2)),$(2)) do not exist) \
877 endef
879 # call gb_LinkTarget_set_include,linktarget,includes
880 define gb_LinkTarget_set_include
881 $(call gb_LinkTarget__check_srcdir_paths,$(1),\
882 $(patsubst -I%,%,$(filter -I$(SRCDIR)/%,$(filter-out -I$(WORKDIR)/%,$(2)))))
883 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2)
885 endef
887 # call gb_LinkTarget_add_ldflags,linktarget,ldflags
888 define gb_LinkTarget_add_ldflags
889 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS += $(2)
891 endef
893 # real use in RepositoryExternal.mk
894 # call gb_LinkTarget_set_ldflags,linktarget,ldflags
895 define gb_LinkTarget_set_ldflags
896 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $(2)
898 endef
900 # call gb_LinkTarget_add_libs,linktarget,libs
901 define gb_LinkTarget_add_libs
902 $(call gb_LinkTarget_get_target,$(1)) : T_LIBS += $(2)
903 $(if $(call gb_LinkTarget__is_merged,$(1)),\
904 $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,merged)) : T_LIBS += $(2))
906 endef
908 # remove platform specific standard libraries for linktarget $(1)
909 # assumption is that adding these standard libs is always useful, but in very
910 # exceptional cases this disable method may be used
911 # call gb_LinkTarget_disable_standard_system_libs,linktarget
912 define gb_LinkTarget_disable_standard_system_libs
913 $(call gb_LinkTarget_get_target,$(1)) : T_LIBS := $$(filter-out $$(gb_STDLIBS),$$(T_LIBS))
915 endef
917 # call gb_LinkTarget__use_api,linktarget,api
918 define gb_LinkTarget__use_api
919 $(call gb_LinkTarget_get_headers_target,$(1)) : $(call gb_UnoApiHeadersTarget_get_target,$(2))
920 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_dir,$(2)))
922 endef
924 # call gb_LinkTarget_use_api,linktarget,apis
925 define gb_LinkTarget_use_api
926 $(foreach api,$(2),$(call gb_LinkTarget__use_api,$(1),$(api)))
928 endef
930 # call gb_LinkTarget_use_udk_api,linktarget
931 define gb_LinkTarget_use_udk_api
932 $(call gb_LinkTarget__use_api,$(1),udkapi)
933 endef
935 # call gb_LinkTarget_use_sdk_api,linktarget
936 define gb_LinkTarget_use_sdk_api
937 $(call gb_LinkTarget__use_api,$(1),udkapi)
938 $(call gb_LinkTarget__use_api,$(1),offapi)
939 endef
941 # call gb_LinkTarget__use_internal_api_one,linktarget,api,apiprefix
942 define gb_LinkTarget__use_internal_api_one
943 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
944 $(call gb_UnoApiHeadersTarget_get_$(3)target,$(2))
945 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_$(3)dir,$(2)))
947 endef
949 # call gb_LinkTarget__use_internal_api,linktarget,apis,apiprefix
950 define gb_LinkTarget__use_internal_api
951 $(foreach api,$(2),$(call gb_LinkTarget__use_internal_api_one,$(1),$(api),$(3)))
953 endef
955 # call gb_LinkTarget_use_internal_api,linktarget,api
956 define gb_LinkTarget_use_internal_api
957 $(call gb_LinkTarget__use_internal_api,$(1),$(2))
959 endef
961 # call gb_LinkTarget_use_internal_bootstrap_api,linktarget,api
962 define gb_LinkTarget_use_internal_bootstrap_api
963 $(call gb_LinkTarget__use_internal_api,$(1),$(2),bootstrap_)
965 endef
967 # call gb_LinkTarget_use_internal_comprehensive_api,linktarget,api
968 define gb_LinkTarget_use_internal_comprehensive_api
969 $(call gb_LinkTarget__use_internal_api,$(1),$(2),comprehensive_)
971 endef
973 define gb_PrintDeps_info
974 $(info LibraryDep: $(1) links against $(2))
975 endef
977 # avoid problem when a module is built partially but other modules that define
978 # needed libraries is not yet built: prevent invocation of pattern rule
979 # for library with invalid parameters by depending on the header target
980 define gb_LinkTarget__lib_dummy_depend
981 $(call gb_Library_get_target,$(1)) :| $(call gb_Library_get_headers_target,$(1))
983 endef
985 # call gb_LinkTarget__use_libraries,linktarget,requestedlibs,actuallibs,linktargetmakefilename
986 define gb_LinkTarget__use_libraries
988 # used by bin/module-deps.pl
989 ifneq ($(ENABLE_PRINT_DEPS),)
990 # exclude libraries in Library_merged
991 ifeq ($(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktarget,$(lib)))),)
992 $$(eval $$(call gb_PrintDeps_info,$(4),$(3)))
993 endif
994 endif
996 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $(3)
998 # depend on the exports of the library, not on the library itself
999 # for faster incremental builds when the ABI is unchanged
1000 ifeq ($(DISABLE_DYNLOADING),)
1001 $(call gb_LinkTarget_get_target,$(1)) : \
1002 $(foreach lib,$(3),$(call gb_Library_get_exports_target,$(lib)))
1003 endif
1004 $(call gb_LinkTarget_get_headers_target,$(1)) : \
1005 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
1006 $(foreach lib,$(2),$(call gb_LinkTarget__lib_dummy_depend,$(lib)))
1008 endef
1010 # libraries which are merged but need to be built for gb_BUILD_HELPER_TOOLS
1011 gb_BUILD_HELPER_LIBS := basegfx \
1012 comphelper \
1013 cppu \
1014 cppuhelper \
1015 i18nlangtag \
1016 reg \
1017 sal \
1018 salhelper \
1019 sax \
1020 store \
1021 tl \
1022 ucbhelper \
1023 unoidl \
1024 xmlreader \
1026 # tools libmerged depends on, so they link against gb_BUILD_HELPER_LIBS
1027 gb_BUILD_HELPER_TOOLS := $(foreach exe,\
1028 cppumaker \
1029 svidl \
1030 unoidl-check \
1031 unoidl-write \
1032 , $(call gb_Executable__get_workdir_linktargetname,$(exe)))
1034 # call gb_LinkTarget__is_build_lib,linktargetname
1035 define gb_LinkTarget__is_build_lib
1036 $(if $(filter $(call gb_LinkTarget__get_workdir_linktargetname,$(1)),$(foreach lib,$(gb_BUILD_HELPER_LIBS),$(call gb_Library__get_workdir_linktargetname,$(lib)))),$(true),$(false))
1037 endef
1039 # call gb_LinkTarget__is_build_tool,linktargetname
1040 define gb_LinkTarget__is_build_tool
1041 $(if $(filter $(call gb_LinkTarget__get_workdir_linktargetname,$(1)),$(call gb_BUILD_HELPER_TOOLS)),$(true),$(false))
1042 endef
1044 define gb_LinkTarget__is_merged
1045 $(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktarget,$(lib))))
1046 endef
1048 # call gb_LinkTarget_use_libraries,linktarget,libs
1049 define gb_LinkTarget_use_libraries
1050 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
1051 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
1052 $$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk or RepositoryExternal.mk))
1053 endif
1055 ifeq ($(call gb_LinkTarget__is_build_tool,$(1)),$(true))
1056 $(call gb_LinkTarget__use_libraries,$(1),$(2),$(2),$(4))
1057 else
1058 $(call gb_LinkTarget__use_libraries,$(1),$(2),$(strip \
1059 $(if $(filter $(gb_MERGEDLIBS),$(2)), \
1060 $(if $(call gb_LinkTarget__is_merged,$(1)), \
1061 $(filter $(gb_MERGEDLIBS),$(2)), merged)) \
1062 $(filter-out $(gb_MERGEDLIBS),$(2)) \
1063 ),$(4))
1064 endif
1066 endef
1068 # avoid problem when a module is built partially but other modules that define
1069 # needed static libraries is not yet built: prevent invocation of pattern rule
1070 # for static library with invalid parameters by depending on the header target
1071 define gb_LinkTarget__static_lib_dummy_depend
1072 $(call gb_StaticLibrary_get_target,$(1)) :| \
1073 $(call gb_StaticLibrary_get_headers_target,$(1))
1075 endef
1077 # for a StaticLibrary, dependent libraries are not actually linked in
1078 # call gb_LinkTarget_use_static_libraries,linktarget,staticlibs
1079 define gb_LinkTarget_use_static_libraries
1080 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $$(if $$(filter-out StaticLibrary,$$(TARGETTYPE)),$(2))
1081 $(if $(call gb_LinkTarget__is_merged,$(1)),\
1082 $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,merged)) : \
1083 LINKED_STATIC_LIBS += $$(if $$(filter-out StaticLibrary,$$(TARGETTYPE)),$(2)))
1085 ifeq ($(DISABLE_DYNLOADING),)
1086 $(call gb_LinkTarget_get_target,$(1)) : $(foreach lib,$(2),$(call gb_StaticLibrary_get_target,$(lib)))
1087 endif
1088 $(call gb_LinkTarget_get_headers_target,$(1)) : \
1089 $(foreach lib,$(2),$(call gb_StaticLibrary_get_headers_target,$(lib)))
1090 $(foreach lib,$(2),$(call gb_LinkTarget__static_lib_dummy_depend,$(lib)))
1092 endef
1094 # call gb_LinkTarget_add_cobject,linktarget,sourcefile,cflags,linktargetmakefilename
1095 define gb_LinkTarget_add_cobject
1096 $(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)))))
1097 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
1098 $(call gb_LinkTarget_get_clean_target,$(1)) : COBJECTS += $(2)
1100 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CObject_get_target,$(2))
1101 $(call gb_CObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1102 $(call gb_CObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
1103 $(call gb_CObject_get_target,$(2)) : \
1104 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1106 ifeq ($(gb_FULLDEPS),$(true))
1107 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS += $(2)
1108 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CObject_get_dep_target,$(2))
1109 $(call gb_CObject_get_dep_target,$(2)) :| $(dir $(call gb_CObject_get_dep_target,$(2))).dir
1110 $(call gb_CObject_get_target,$(2)) :| $(dir $(call gb_CObject_get_dep_target,$(2))).dir
1111 endif
1113 endef
1115 # call gb_LinkTarget_add_cxxobject,linktarget,sourcefile,cxxflags,linktargetmakefilename
1116 define gb_LinkTarget_add_cxxobject
1117 $(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)))))
1118 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
1119 $(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
1121 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
1122 $(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1123 $(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
1124 $(call gb_CxxObject_get_target,$(2)) : \
1125 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1126 ifneq ($(gb_ENABLE_PCH),)
1127 $(call gb_CxxObject_get_target,$(2)) : $(call gb_PrecompiledHeader_get_timestamp,$(4))
1128 endif
1130 ifeq ($(gb_FULLDEPS),$(true))
1131 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS += $(2)
1132 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxObject_get_dep_target,$(2))
1133 $(call gb_CxxObject_get_dep_target,$(2)) :| $(dir $(call gb_CxxObject_get_dep_target,$(2))).dir
1134 $(call gb_CxxObject_get_target,$(2)) :| $(dir $(call gb_CxxObject_get_dep_target,$(2))).dir
1135 endif
1137 endef
1139 # call gb_LinkTarget_add_objcobject,linktarget,sourcefile,objcflags,linktargetmakefilename
1140 define gb_LinkTarget_add_objcobject
1141 $(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)))))
1142 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS += $(2)
1143 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCOBJECTS += $(2)
1145 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCObject_get_target,$(2))
1146 $(call gb_ObjCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1147 $(call gb_ObjCObject_get_target,$(2)) : T_OBJCFLAGS += $(call gb_LinkTarget__get_objcflags,$(4)) $(3)
1148 $(call gb_ObjCObject_get_target,$(2)) : \
1149 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1151 ifeq ($(gb_FULLDEPS),$(true))
1152 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS += $(2)
1153 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCObject_get_dep_target,$(2))
1154 $(call gb_ObjCObject_get_dep_target,$(2)) :| $(dir $(call gb_ObjCObject_get_dep_target,$(2))).dir
1155 $(call gb_ObjCObject_get_target,$(2)) :| $(dir $(call gb_ObjCObject_get_dep_target,$(2))).dir
1156 endif
1158 endef
1160 # call gb_LinkTarget_add_objcxxobject,linktarget,sourcefile,objcxxflags,linktargetmakefilename
1161 define gb_LinkTarget_add_objcxxobject
1162 $(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)))))
1163 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
1164 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCXXOBJECTS += $(2)
1166 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCxxObject_get_target,$(2))
1167 $(call gb_ObjCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1168 $(call gb_ObjCxxObject_get_target,$(2)) : T_OBJCXXFLAGS += $(call gb_LinkTarget__get_objcxxflags,$(4)) $(3)
1169 $(call gb_ObjCxxObject_get_target,$(2)) : \
1170 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1172 ifeq ($(gb_FULLDEPS),$(true))
1173 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS += $(2)
1174 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCxxObject_get_dep_target,$(2))
1175 $(call gb_ObjCxxObject_get_dep_target,$(2)) :| $(dir $(call gb_ObjCxxObject_get_dep_target,$(2))).dir
1176 $(call gb_ObjCxxObject_get_target,$(2)) :| $(dir $(call gb_ObjCxxObject_get_dep_target,$(2))).dir
1177 endif
1179 endef
1181 # call gb_LinkTarget_add_cxxclrobject,linktarget,sourcefile,cxxclrflags,linktargetmakefilename
1182 define gb_LinkTarget_add_cxxclrobject
1183 $(if $(wildcard $(call gb_CxxClrObject_get_source,$(SRCDIR),$(2))),,$(eval $(call gb_Output_error,No such source file $(call gb_CxxClrObject_get_source,$(SRCDIR),$(2)))))
1184 $(call gb_LinkTarget_get_target,$(1)) : CXXCLROBJECTS += $(2)
1185 $(call gb_LinkTarget_get_clean_target,$(1)) : CXXCLROBJECTS += $(2)
1187 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxClrObject_get_target,$(2))
1188 $(call gb_CxxClrObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1189 $(call gb_CxxClrObject_get_target,$(2)) : T_CXXCLRFLAGS += $(call gb_LinkTarget__get_cxxclrflags,$(4)) $(3)
1190 $(call gb_CxxClrObject_get_target,$(2)) : \
1191 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1193 ifeq ($(gb_FULLDEPS),$(true))
1194 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXCLROBJECTS += $(2)
1195 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxClrObject_get_dep_target,$(2))
1196 $(call gb_CxxClrObject_get_dep_target,$(2)) :| $(dir $(call gb_CxxClrObject_get_dep_target,$(2))).dir
1197 $(call gb_CxxClrObject_get_target,$(2)) :| $(dir $(call gb_CxxClrObject_get_dep_target,$(2))).dir
1198 endif
1200 endef
1202 # call gb_LinkTarget_add_asmobject,linktarget,sourcefile
1203 define gb_LinkTarget_add_asmobject
1204 $(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)))))
1205 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS += $(2)
1206 $(call gb_LinkTarget_get_clean_target,$(1)) : ASMOBJECTS += $(2)
1208 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_AsmObject_get_target,$(2))
1209 $(call gb_AsmObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1210 $(call gb_AsmObject_get_target,$(2)) : \
1211 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1213 ifeq ($(gb_FULLDEPS),$(true))
1214 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS += $(2)
1215 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_AsmObject_get_dep_target,$(2))
1216 $(call gb_AsmObject_get_dep_target,$(2)) :| $(dir $(call gb_AsmObject_get_dep_target,$(2))).dir
1217 $(call gb_AsmObject_get_target,$(2)) :| $(dir $(call gb_AsmObject_get_dep_target,$(2))).dir
1218 endif
1220 endef
1222 # call gb_LinkTarget_add_generated_c_object,linktarget,sourcefile,cflags,linktargetmakefilename
1223 define gb_LinkTarget_add_generated_c_object
1224 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS += $(2)
1225 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCOBJECTS += $(2)
1227 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCObject_get_target,$(2))
1228 $(call gb_GenCObject_get_target,$(2)) : $(call gb_GenCObject_get_source,$(2))
1229 # Often gb_GenCObject_get_source does not have its own rule and is only a byproduct.
1230 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
1231 $(call gb_GenCObject_get_source,$(2)) : | $(gb_Helper_MISCDUMMY)
1232 $(call gb_GenCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1233 $(call gb_GenCObject_get_target,$(2)) : WARNINGS_NOT_ERRORS := $(true)
1234 $(call gb_GenCObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
1235 $(call gb_GenCObject_get_target,$(2)) : \
1236 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1238 ifeq ($(gb_FULLDEPS),$(true))
1239 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS += $(2)
1240 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCObject_get_dep_target,$(2))
1241 $(call gb_GenCObject_get_dep_target,$(2)) :| $(dir $(call gb_GenCObject_get_dep_target,$(2))).dir
1242 $(call gb_GenCObject_get_target,$(2)) :| $(dir $(call gb_GenCObject_get_dep_target,$(2))).dir
1243 endif
1245 endef
1247 # call gb_LinkTarget_add_generated_cxx_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
1248 define gb_LinkTarget_add_generated_cxx_object
1249 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
1250 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
1252 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
1253 $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_GenCxxObject_get_source,$(2),$(1))
1254 # Often gb_GenCxxObject_get_source does not have its own rule and is only a byproduct.
1255 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
1256 $(call gb_GenCxxObject_get_source,$(2),$(1)) : | $(gb_Helper_MISCDUMMY)
1257 $(call gb_GenCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1258 $(call gb_GenCxxObject_get_target,$(2)) : WARNINGS_NOT_ERRORS := $(true)
1259 $(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
1260 $(call gb_GenCxxObject_get_target,$(2)) : \
1261 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1262 $(call gb_GenCxxObject_get_target,$(2)) : GEN_CXX_SOURCE := $(call gb_GenCxxObject_get_source,$(2),$(1))
1263 ifneq ($(gb_ENABLE_PCH),)
1264 $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_PrecompiledHeader_get_timestamp,$(4))
1265 endif
1267 ifeq ($(gb_FULLDEPS),$(true))
1268 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS += $(2)
1269 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxObject_get_dep_target,$(2))
1270 $(call gb_GenCxxObject_get_dep_target,$(2)) :| $(dir $(call gb_GenCxxObject_get_dep_target,$(2))).dir
1271 $(call gb_GenCxxObject_get_target,$(2)) :| $(dir $(call gb_GenCxxObject_get_dep_target,$(2))).dir
1272 endif
1274 endef
1276 # call gb_LinkTarget_add_generated_cxxclrobject,linktarget,sourcefile,cxxclrflags,linktargetmakefilename
1277 define gb_LinkTarget_add_generated_cxxclrobject
1278 $(call gb_LinkTarget_get_target,$(1)) : GENCXXCLROBJECTS += $(2)
1279 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXCLROBJECTS += $(2)
1281 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxClrObject_get_target,$(2))
1282 $(call gb_GenCxxClrObject_get_target,$(2)) : $(call gb_GenCxxClrObject_get_source,$(2),$(1))
1283 $(call gb_GenCxxClrObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
1284 $(call gb_GenCxxClrObject_get_target,$(2)) : T_CXXCLRFLAGS += $(call gb_LinkTarget__get_cxxclrflags,$(4)) $(3)
1285 $(call gb_GenCxxClrObject_get_target,$(2)) : \
1286 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
1287 $(call gb_GenCxxClrObject_get_target,$(2)) : GEN_CXXCLR_SOURCE := $(call gb_GenCxxClrObject_get_source,$(2),$(1))
1289 ifeq ($(gb_FULLDEPS),$(true))
1290 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXCLROBJECTS += $(2)
1291 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxClrObject_get_dep_target,$(2))
1292 $(call gb_GenCxxClrObject_get_dep_target,$(2)) :| $(dir $(call gb_GenCxxClrObject_get_dep_target,$(2))).dir
1293 $(call gb_GenCxxClrObject_get_target,$(2)) :| $(dir $(call gb_GenCxxClrObject_get_dep_target,$(2))).dir
1294 endif
1296 endef
1298 # Add a bison grammar to the build.
1299 # call gb_LinkTarget_add_grammar,linktarget,yaccfile,cxxflags,linktargetmakefilename
1300 define gb_LinkTarget_add_grammar
1301 $(call gb_YaccTarget_YaccTarget,$(2))
1302 $(call gb_LinkTarget_add_generated_exception_object,$(1),YaccTarget/$(2),$(3) $(if $(filter GCC,$(COM)),-Wno-unused-macros),$(4))
1303 $(call gb_GenCxxObject_get_target,YaccTarget/$(2)): PLUGIN_WARNINGS_AS_ERRORS := $(true)
1304 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_YaccTarget_get_clean_target,$(2))
1305 $(call gb_LinkTarget_get_headers_target,$(1)) : $(call gb_YaccTarget_get_header_target,$(2))
1306 $(call gb_LinkTarget__add_include,$(1),$(dir $(call gb_YaccTarget_get_header_target,$(2))))
1308 endef
1310 # Add bison grammars to the build.
1311 # call gb_LinkTarget_add_grammars,linktarget,yaccfiles,cxxflags,linktargetmakefilename
1312 define gb_LinkTarget_add_grammars
1313 $(foreach grammar,$(2),$(call gb_LinkTarget_add_grammar,$(1),$(grammar),$(3),$(4)))
1314 endef
1316 # Add a flex scanner to the build.
1317 # call gb_LinkTarget_add_scanner,linktarget,lexfile,cxxflags,linktargetmakefilename
1318 define gb_LinkTarget_add_scanner
1319 $(call gb_LexTarget_LexTarget,$(2))
1320 $(call gb_LinkTarget_add_generated_exception_object,$(1),LexTarget/$(2),$(3) $(if $(filter GCC,$(COM)),-Wno-unused-macros),$(4))
1321 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_LexTarget_get_clean_target,$(2))
1323 endef
1325 # Add flex scanners to the build.
1326 # call gb_LinkTarget_add_scanners,linktarget,lexfiles,cxxflags,linktargetmakefilename
1327 define gb_LinkTarget_add_scanners
1328 $(foreach scanner,$(2),$(call gb_LinkTarget_add_scanner,$(1),$(scanner),$(3),$(4)))
1330 endef
1332 # call gb_LinkTarget_add_exception_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
1333 define gb_LinkTarget_add_exception_object
1334 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(4)) $(3),$(4))
1335 endef
1337 # call gb_LinkTarget__use_linktarget_objects,linktarget,linktargets
1338 define gb_LinkTarget__use_linktarget_objects
1339 $(call gb_LinkTarget_get_target,$(1)) : $(foreach linktarget,$(2),$(call gb_LinkTarget_get_target,$(linktarget)))
1340 ifneq ($(OS),iOS)
1341 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS += $(foreach linktarget,$(2),$(call gb_LinkTarget_get_objects_list,$(linktarget)))
1342 endif
1344 endef
1346 # call gb_LinkTarget_use_library_objects,linktarget,libs
1347 define gb_LinkTarget_use_library_objects
1348 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
1349 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
1350 $$(eval $$(call gb_Output_error,Cannot import objects library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk or RepositoryExternal.mk))
1351 endif
1352 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach lib,$(2),$(call gb_Library_get_linktarget,$(lib))))
1353 $(call gb_LinkTarget_get_headers_target,$(1)) : \
1354 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
1356 endef
1358 # call gb_LinkTarget_use_executable_objects,linktarget,exes
1359 define gb_LinkTarget_use_executable_objects
1360 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach exe,$(2),$(call gb_Executable_get_linktarget,$(exe))))
1362 endef
1364 # call gb_LinkTarget_add_cobjects,linktarget,sourcefiles,cflags,linktargetmakefilename
1365 define gb_LinkTarget_add_cobjects
1366 $(foreach obj,$(2),$(call gb_LinkTarget_add_cobject,$(1),$(obj),$(3),$(4)))
1367 endef
1369 # call gb_LinkTarget_add_cxxobjects,linktarget,sourcefiles,cxxflags,linktargetmakefilename
1370 define gb_LinkTarget_add_cxxobjects
1371 $(foreach obj,$(2),$(call gb_LinkTarget_add_cxxobject,$(1),$(obj),$(3),$(4)))
1372 endef
1374 # call gb_LinkTarget_add_objcobjects,linktarget,sourcefiles,objcflags,linktargetmakefilename
1375 define gb_LinkTarget_add_objcobjects
1376 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcobject,$(1),$(obj),$(3),$(4)))
1377 endef
1379 # call gb_LinkTarget_add_objcxxobjects,linktarget,sourcefiles,objcxxflags,linktargetmakefilename
1380 define gb_LinkTarget_add_objcxxobjects
1381 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3),$(4)))
1382 endef
1384 # call gb_LinkTarget_add_cxxclrobjects,linktarget,sourcefiles,cxxclrflags,linktargetmakefilename
1385 define gb_LinkTarget_add_cxxclrobjects
1386 $(foreach obj,$(2),$(call gb_LinkTarget_add_cxxclrobject,$(1),$(obj),$(3),$(4)))
1387 endef
1389 # call gb_LinkTarget_add_asmobjects,linktarget,sourcefiles,asmflags,linktargetmakefilename
1390 define gb_LinkTarget_add_asmobjects
1391 $(foreach obj,$(2),$(call gb_LinkTarget_add_asmobject,$(1),$(obj),$(3),$(4)))
1392 endef
1394 # call gb_LinkTarget_add_exception_objects,linktarget,sourcefiles,cxxflags,linktargetmakefilename
1395 define gb_LinkTarget_add_exception_objects
1396 $(foreach obj,$(2),$(call gb_LinkTarget_add_exception_object,$(1),$(obj),$(3),$(4)))
1397 endef
1399 #only useful for building x64 libraries on windows
1400 # call gb_LinkTarget_add_x64_generated_exception_objects,linktarget,sourcefiles,cxxflags,linktargetmakefilename
1401 define gb_LinkTarget_add_x64_generated_exception_objects
1402 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(3),$(4)))
1403 $(foreach obj,$(2),$(eval $(call gb_GenCxxObject_get_target,$(obj)) : CXXOBJECT_X64 := YES))
1404 endef
1406 # call gb_LinkTarget_add_generated_cobjects,linktarget,sourcefiles,cflags,linktargetmakefilename
1407 define gb_LinkTarget_add_generated_cobjects
1408 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1409 endef
1411 #only useful for building x64 libraries on windows
1412 # call gb_LinkTarget_add_x64_generated_cobjects,linktarget,sourcefiles,cflags,linktargetmakefilename
1413 define gb_LinkTarget_add_x64_generated_cobjects
1414 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1415 endef
1417 # call gb_LinkTarget_add_generated_exception_object,linktarget,sourcefile,cxxflags,linktargetmakefilename
1418 define gb_LinkTarget_add_generated_exception_object
1419 $(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(4)) $(3),$(4))
1420 endef
1422 # call gb_LinkTarget_add_generated_exception_objects,linktarget,sourcefile,cxxflags,linktargetmakefilename
1423 define gb_LinkTarget_add_generated_exception_objects
1424 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(3),$(4)))
1425 endef
1427 # call gb_LinkTarget_add_generated_cxxclrobjects,linktarget,sourcefiles,cxxclrflags,linktargetmakefilename
1428 define gb_LinkTarget_add_generated_cxxclrobjects
1429 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_cxxclrobject,$(1),$(obj),$(3),$(4)))
1430 endef
1432 # call gb_LinkTarget_set_targettype,linktarget,targettype
1433 define gb_LinkTarget_set_targettype
1434 $(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE := $(2)
1436 endef
1438 # call gb_LinkTarget_set_x64,linktarget,boolean
1439 define gb_LinkTarget_set_x64
1440 $(call gb_LinkTarget_get_target,$(1)) : LIBRARY_X64 := $(2)
1442 endef
1444 # call gb_LinkTarget_set_x86,linktarget,boolean
1445 define gb_LinkTarget_set_x86
1446 $(call gb_LinkTarget_get_target,$(1)) : PE_X86 := $(2)
1448 endef
1450 # call gb_LinkTarget_set_ilibtarget,linktarget,ilibfilename
1451 define gb_LinkTarget_set_ilibtarget
1452 $(call gb_LinkTarget_get_clean_target,$(1)) \
1453 $(call gb_LinkTarget_get_target,$(1)) : ILIBTARGET := $(2)
1455 endef
1457 # Add a file that is built by the LinkTarget command and define
1458 # a dummy touch rule for it so it can be tracked via dependencies.
1459 # The assumption is that the file is created by linking; in case it does not
1460 # exist there is some problem. This can be caused on WNT by re-naming DLL
1461 # files (which are aux-targets) but not the import .lib files (which
1462 # are the LinkTargets) and doing an incremental build.
1463 # call gb_LinkTarget_add_auxtarget,linktarget,auxtarget
1464 define gb_LinkTarget_add_auxtarget
1465 $(2) : $(call gb_LinkTarget_get_target,$(1))
1466 if test -e $$@; then \
1467 touch -r $$< $$@; \
1468 else \
1469 rm -f $$<; \
1470 echo "ERROR: aux-target missing, library deleted, please try running make again"; \
1471 false; \
1474 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS += $(2)
1476 endef
1478 # call gb_LinkTarget_add_auxtargets,linktarget,auxtargets
1479 define gb_LinkTarget_add_auxtargets
1480 $(foreach aux,$(2),$(call gb_LinkTarget_add_auxtarget,$(1),$(aux)))
1482 endef
1484 # call gb_LinkTarget__use_custom_headers,linktarget,customtarget
1485 define gb_LinkTarget__use_custom_headers
1486 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
1487 $(call gb_CustomTarget_get_target,$(2))
1488 $(call gb_LinkTarget__add_include,$(1),$(call gb_CustomTarget_get_workdir,$(2)))
1490 endef
1492 # call gb_LinkTarget_use_custom_headers,linktarget,customtargets
1493 define gb_LinkTarget_use_custom_headers
1494 $(foreach customtarget,$(2),$(call gb_LinkTarget__use_custom_headers,$(1),$(customtarget)))
1496 endef
1498 # add SDI (svidl) headers
1499 # call gb_LinkTarget_add_sdi_headers,linktarget,sditargets
1500 define gb_LinkTarget_add_sdi_headers
1501 $(call gb_LinkTarget_get_headers_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_target,$(sdi)))
1502 $(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_clean_target,$(sdi)))
1504 endef
1506 # call gb_LinkTarget__set_precompiled_header_impl,linktarget,pchcxxfile,pchtarget,linktargetmakefilename
1507 define gb_LinkTarget__set_precompiled_header_impl
1508 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_PrecompiledHeader_get_clean_target,$(3))
1509 $(call gb_PrecompiledHeader_get_target,$(3),$(4)) : $(2).cxx
1511 $(call gb_PrecompiledHeader_get_target,$(3),$(4)) : $(call gb_LinkTarget_get_headers_target,$(1))
1513 $(call gb_LinkTarget_get_target,$(1)) : PCH_NAME := $(3)
1514 $(call gb_LinkTarget_get_target,$(1)) : PCH_LINKTARGETMAKEFILENAME := $(4)
1515 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJEX = $(call gb_PrecompiledHeader_get_objectfile, $(call gb_PrecompiledHeader_get_target,$(3),$(4)))
1516 $(call gb_LinkTarget_get_target,$(1)) : PCHOBJS = $$(PCHOBJEX)
1518 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS := $$(DEFS)
1519 $(call gb_LinkTarget_get_target,$(1)) : PCH_CXXFLAGS := $$(T_CXXFLAGS) $(call gb_LinkTarget__get_cxxflags,$(4))
1521 $(call gb_LinkTarget_get_target,$(1)) : DEFS += -DPCH_LEVEL=$(gb_ENABLE_PCH)
1522 $(call gb_LinkTarget_get_target,$(1)) : PCH_DEFS += -DPCH_LEVEL=$(gb_ENABLE_PCH)
1524 $(call gb_PrecompiledHeader_get_target,$(3),$(4)) : VISIBILITY :=
1526 $(call gb_PrecompiledHeader_get_timestamp,$(4)) : $(call gb_PrecompiledHeader_get_target,$(3),$(4))
1528 ifeq ($(gb_FULLDEPS),$(true))
1529 -include $(call gb_PrecompiledHeader_get_dep_target,$(3),$(4))
1530 endif
1532 endef
1534 # call gb_LinkTarget_set_precompiled_header,linktarget,pchcxxfile,,linktargetmakefilename
1535 define gb_LinkTarget_set_precompiled_header
1536 ifneq ($(gb_ENABLE_PCH),)
1537 $(call gb_LinkTarget__set_precompiled_header_impl,$(1),$(2),$(notdir $(2)),$(4))
1538 $(call gb_PrecompiledHeader_generate_rules,$(notdir $(2)),$(4))
1539 endif
1541 endef
1543 # use a header package, possibly from another module
1544 # call gb_LinkTarget_use_package,linktarget,package
1545 define gb_LinkTarget_use_package
1546 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
1547 $(call gb_Package_get_target,$(strip $(2)))
1549 endef
1551 # call gb_LinkTarget_use_packages,linktarget,packages
1552 define gb_LinkTarget_use_packages
1553 $(foreach package,$(2),$(call gb_LinkTarget_use_package,$(1),$(package)))
1554 endef
1556 # use a GeneratedPackage, possibly from another module
1557 # call gb_LinkTarget_use_generated_package,linktarget,package
1558 define gb_LinkTarget_use_generated_package
1559 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
1560 $(call gb_GeneratedPackage_get_target,$(strip $(2)))
1562 endef
1564 # Use sources from unpacked tarball of an external project
1565 # call gb_LinkTarget_use_unpacked,linktarget,unpackedtarget
1566 define gb_LinkTarget_use_unpacked
1567 $(call gb_LinkTarget_get_headers_target,$(1)) :| $(call gb_UnpackedTarball_get_final_target,$(2))
1569 endef
1571 # Use artifacts from ExternalProject (i. e. configure) of an external project
1572 # example in expat: StaticLibrary depends on ExternalProject outcome
1573 # call gb_LinkTarget_use_external_project,linktarget,externalproject,full-dep
1574 define gb_LinkTarget_use_external_project
1575 $(call gb_LinkTarget_get_target,$(1)) :| $(call gb_ExternalProject_get_target,$(2))
1576 $(call gb_LinkTarget_get_headers_target,$(1)) :| \
1577 $(if $(3),$(call gb_ExternalProject_get_target,$(2)),$(call gb_UnpackedTarball_get_final_target,$(2)))
1579 endef
1581 # this forwards to functions that must be defined in RepositoryExternal.mk.
1582 # Automatically forward for libmerged library too when linktarget is merged.
1584 # call gb_LinkTarget_use_external,linktarget,external
1585 define gb_LinkTarget_use_external
1586 $(if $(filter undefined,$(origin gb_LinkTarget__use_$(2))),\
1587 $(error gb_LinkTarget_use_external: unknown external: $(2)),\
1588 $(if $(call gb_LinkTarget__is_merged,$(1)),$(call gb_LinkTarget__use_$(2),$(call gb_Library_get_linktarget,merged))) \
1589 $(call gb_LinkTarget__use_$(2),$(1)) \
1591 endef
1593 # $(call gb_LinkTarget_use_externals,library,externals)
1594 gb_LinkTarget_use_externals = \
1595 $(foreach external,$(2),$(call gb_LinkTarget_use_external,$(1),$(external)))
1597 # call gb_LinkTarget_set_visibility_default,linktarget
1598 define gb_LinkTarget_set_visibility_default
1599 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY := default
1600 ifneq ($(gb_ENABLE_PCH),)
1601 ifneq ($(strip $$(PCH_NAME)),)
1602 $(call gb_PrecompiledHeader_get_target,$$(PCH_NAME),$$(PCH_LINKTARGETMAKEFILENAME)) : VISIBILITY := default
1603 endif
1604 endif
1606 endef
1608 # call gb_LinkTarget_set_warnings_not_errors,linktarget
1609 define gb_LinkTarget_set_warnings_not_errors
1610 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1612 endef
1614 # call gb_LinkTarget_set_warnings_disabled,linktarget
1615 define gb_LinkTarget_set_warnings_disabled
1616 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_DISABLED := $(true)
1618 endef
1620 # call gb_LinkTarget_set_external_code,linktarget
1621 define gb_LinkTarget_set_external_code
1622 $(call gb_LinkTarget_get_target,$(1)) : EXTERNAL_CODE := $(true)
1624 endef
1626 # Set suffix of C++ files, if different from 'cxx'
1628 # This is useful for external libraries.
1630 # call gb_LinkTarget_set_generated_cxx_suffix,linktarget,used-suffix
1631 define gb_LinkTarget_set_generated_cxx_suffix
1632 gb_LinkTarget_CXX_SUFFIX_$(call gb_LinkTarget__get_workdir_linktargetname,$(1)) := $(2)
1634 endef
1636 # vim: set noet sw=4: