Bump for 3.6-28
[LibreOffice.git] / solenv / gbuild / LinkTarget.mk
blobccdfe492b9f52dca8d9ef94708ae079c60dea7d8
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 # Copyright 2000, 2011 Oracle and/or its affiliates.
8 # OpenOffice.org - a multi-platform office productivity suite
10 # This file is part of OpenOffice.org.
12 # OpenOffice.org is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License version 3
14 # only, as published by the Free Software Foundation.
16 # OpenOffice.org is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU Lesser General Public License version 3 for more details
20 # (a copy is included in the LICENSE file that accompanied this code).
22 # You should have received a copy of the GNU Lesser General Public License
23 # version 3 along with OpenOffice.org. If not, see
24 # <http://www.openoffice.org/license.html>
25 # for a copy of the LGPLv3 License.
27 #*************************************************************************
29 #the following user-defined variables are supported:
30 # YACCFLAGS
31 # LEXFLAGS
32 # CPPFLAGS
33 # CFLAGS
34 # CXXFLAGS
35 # OBJCFLAGS
36 # OBJCXXFLAGS
37 # LDFLAGS
39 # enable if: no "-TARGET" defined AND [module is enabled OR "TARGET" defined]
40 gb_LinkTarget__debug_enabled = \
41 $(and $(if $(filter -$(1),$(ENABLE_DEBUG_FOR)),,$(true)),\
42 $(or $(gb_Module_CURRENTMODULE_DEBUG_ENABLED),\
43 $(filter $(1),$(ENABLE_DEBUG_FOR))))
45 # debug flags, if ENABLE_DEBUG is set and the LinkTarget is named
46 # in the list of libraries of ENABLE_DEBUG_FOR
47 gb_LinkTarget__get_debugcflags=$(if $(call gb_LinkTarget__debug_enabled,$(1)),$(gb_COMPILERNOOPTFLAGS) $(gb_DEBUG_CFLAGS),$(gb_COMPILEROPTFLAGS))
48 gb_LinkTarget__get_debugcxxflags=$(if $(call gb_LinkTarget__debug_enabled,$(1)),$(gb_COMPILERNOOPTFLAGS) $(gb_DEBUG_CFLAGS) $(gb_DEBUG_CXXFLAGS),$(gb_COMPILEROPTFLAGS))
50 # generic cflags/cxxflags to use (optimization flags, debug flags)
51 # user supplied CFLAGS/CXXFLAGS override default debug/optimization flags
52 gb_LinkTarget__get_cflags=$(if $(CFLAGS),$(CFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
53 gb_LinkTarget__get_objcflags=$(if $(OBJCFLAGS),$(OBJCFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
54 gb_LinkTarget__get_cxxflags=$(if $(CXXFLAGS),$(CXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
55 gb_LinkTarget__get_objcxxflags=$(if $(OBJCXXFLAGS),$(OBJCXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
57 # Overview of dependencies and tasks of LinkTarget
59 # target task depends on
60 # LinkTarget linking AsmObject CObject CxxObject GenCObject GenCxxObject ObjCObject ObjCxxObject
61 # LinkTarget/headers
62 # LinkTarget/dep joined dep file AsmObject/dep CObject/dep CxxObject/dep GenCObject/dep GenCxxObject/dep ObjCObject/dep ObjCxxObject/dep
63 # | LinkTarget/headers
64 # LinkTarget/headers all headers available LinkTarget/external_headers
65 # including own generated own generated headers
66 # LinkTarget/external_headers all external headers avail. header files of linked libs
68 # CObject plain c compile | LinkTarget/headers
69 # CxxObject c++ compile | LinkTarget/headers
70 # GenCObject plain c compile from | LinkTarget/headers
71 # generated source
72 # GenCxxObject C++ compile from | LinkTarget/headers
73 # generated source
74 # ObjCObject objective c compile | LinkTarget/headers
75 # ObjCxxObject objective c++ compile | LinkTarget/headers
77 # AsmObject asm compile | LinkTarget
79 # CObject/dep dependencies these targets generate empty dep files
80 # CxxObject/dep dependencies that are populated upon compile
81 # GenCObject/dep dependencies
82 # GenCxxObject/dep dependencies
83 # ObjCObject/dep dependencies
84 # ObjCxxObject/dep dependencies
85 # AsmObject/dep dependencies
87 # LinkTarget/headers means gb_LinkTarget_get_headers_target etc.
88 # dependencies prefixed with | are build-order only dependencies
91 # check that objects are only linked into one link target:
92 # multiple linking may cause problems because different link targets may
93 # require different compiler flags
94 define gb_Object__owner
95 $$(if $$(OBJECTOWNER),\
96 $$(call gb_Output_error,fdo#47246: $(1) is linked in by $$(OBJECTOWNER) $(2)))$(2)
97 endef
99 # For every object there is a dep file (if gb_FULLDEPS is active).
100 # The dep file depends on the object: the Object__command also updates the
101 # dep file as a side effect.
102 # In the dep file rule just touch it so it's newer than the object.
104 # The gb_Object__command_dep generates an "always rebuild" dep file;
105 # It is used on first build and in case the user deletes the object dep file.
106 ifeq ($(gb_FULLDEPS),$(true))
107 define gb_Object__command_dep
108 mkdir -p $(dir $(1)) && \
109 echo '$(2) : $$(gb_Helper_PHONY)' > $(1)
111 endef
112 else
113 gb_Object__command_dep = \
114 $(call gb_Output_error,gb_Object__command_dep is only for gb_FULLDEPS)
115 endif
118 # CObject class
120 gb_CObject_get_source = $(1)/$(2).c
121 # defined by platform
122 # gb_CObject__command
124 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%)
125 $(call gb_CObject__command,$@,$*,$<,$(call gb_CObject_get_dep_target,$*))
127 ifeq ($(gb_FULLDEPS),$(true))
128 $(call gb_CObject_get_dep_target,%) :
129 $(if $(wildcard $@),touch $@,\
130 $(call gb_Object__command_dep,$@,$(call gb_CObject_get_target,$*)))
132 endif
135 # CxxObject class
137 gb_CxxObject_get_source = $(1)/$(2).cxx
138 # defined by platform
139 # gb_CxxObject__command
141 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
142 $(call gb_CxxObject__command,$@,$*,$<,$(call gb_CxxObject_get_dep_target,$*))
144 ifeq ($(gb_FULLDEPS),$(true))
145 $(call gb_CxxObject_get_dep_target,%) :
146 $(if $(wildcard $@),touch $@,\
147 $(call gb_Object__command_dep,$@,$(call gb_CxxObject_get_target,$*)))
149 endif
152 # GenCObject class
154 gb_GenCObject_get_source = $(WORKDIR)/$(1).c
155 # defined by platform
156 # gb_CObject__command
158 $(call gb_GenCObject_get_target,%) : $(call gb_GenCObject_get_source,%)
159 test -f $< || (echo "Missing generated source file $<" && false)
160 $(call gb_CObject__command,$@,$*,$<,$(call gb_GenCObject_get_dep_target,$*))
162 ifeq ($(gb_FULLDEPS),$(true))
163 $(call gb_GenCObject_get_dep_target,%) :
164 $(if $(wildcard $@),touch $@,\
165 $(call gb_Object__command_dep,$@,$(call gb_GenCObject_get_target,$*)))
167 endif
170 # GenCxxObject class
172 gb_GenCxxObject_get_source = $(WORKDIR)/$(1).cxx
173 # defined by platform
174 # gb_CxxObject__command
176 $(call gb_GenCxxObject_get_target,%) : $(call gb_GenCxxObject_get_source,%)
177 test -f $< || (echo "Missing generated source file $<" && false)
178 $(call gb_CxxObject__command,$@,$*,$<,$(call gb_GenCxxObject_get_dep_target,$*))
180 ifeq ($(gb_FULLDEPS),$(true))
181 $(call gb_GenCxxObject_get_dep_target,%) :
182 $(if $(wildcard $@),touch $@,\
183 $(call gb_Object__command_dep,$@,$(call gb_GenCxxObject_get_target,$*)))
185 endif
188 # YaccTarget class
190 # XXX: This is more complicated than necessary, but we cannot just use
191 # the generated C++ file as the main target, because we need to let the
192 # header depend on that to ensure the header is present before anything
193 # tries to use it.
195 gb_YaccTarget_get_source = $(1)/$(2).y
196 # defined by platform
197 # gb_YaccTarget__command(grammar-file, stem-for-message, source-target, include-target)
199 .PHONY : $(call gb_YaccTarget_get_clean_target,%)
200 $(call gb_YaccTarget_get_clean_target,%) :
201 $(call gb_Output_announce,$*,$(false),YAC,3)
202 $(call gb_Helper_abbreviate_dirs,\
203 rm -f $(call gb_YaccTarget_get_grammar_target,$*) $(call gb_YaccTarget_get_header_target,$*) $(call gb_YaccTarget_get_target,$*))
205 $(call gb_YaccTarget_get_target,%) : $(call gb_YaccTarget_get_source,$(SRCDIR),%)
206 $(call gb_YaccTarget__command,$<,$*,$@,$(call gb_YaccTarget_get_header_target,$*),$(call gb_YaccTarget_get_grammar_target,$*))
208 define gb_YaccTarget_YaccTarget
209 $(call gb_YaccTarget_get_grammar_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
210 touch $$@
211 $(call gb_YaccTarget_get_header_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
212 touch $$@
214 endef
216 gb_YACC := bison
219 # LexTarget class
221 gb_LexTarget_get_source = $(1)/$(2).l
223 .PHONY : $(call gb_LexTarget_get_clean_target,%)
224 $(call gb_LexTarget_get_clean_target,%) :
225 $(call gb_Output_announce,$*,$(false),LEX,3)
226 $(call gb_Helper_abbreviate_dirs,\
227 rm -f $(call gb_LexTarget_get_scanner_target,$*) $(call gb_LexTarget_get_target,$*))
229 $(call gb_LexTarget_get_target,%) : $(call gb_LexTarget_get_source,$(SRCDIR),%)
230 $(call gb_LexTarget__command,$<,$*,$@,$(call gb_LexTarget_get_scanner_target,$*))
232 # gb_LexTarget_LexTarget(scanner-file)
233 define gb_LexTarget_LexTarget
234 $(call gb_LexTarget_get_scanner_target,$(1)) : $(call gb_LexTarget_get_target,$(1))
235 touch $$@
237 endef
239 # gb_LexTarget__command(scanner-file, stem-for-message, done-pseudo-target, source-target)
240 define gb_LexTarget__command
241 $(call gb_Output_announce,$(2),$(true),LEX,3)
242 $(call gb_Helper_abbreviate_dirs,\
243 mkdir -p $(dir $(3)) && \
244 $(FLEX) $(T_LEXFLAGS) -o$(4) $(1) && touch $(3) )
245 endef
248 # ObjCxxObject class
251 gb_ObjCxxObject_get_source = $(1)/$(2).mm
252 # defined by platform
253 # gb_ObjCxxObject__command
255 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%)
256 $(call gb_ObjCxxObject__command,$@,$*,$<,$(call gb_ObjCxxObject_get_dep_target,$*))
258 ifeq ($(gb_FULLDEPS),$(true))
259 $(call gb_ObjCxxObject_get_dep_target,%) :
260 $(if $(wildcard $@),touch $@,\
261 $(call gb_Object__command_dep,$@,$(call gb_ObjCxxObject_get_target,$*)))
263 endif
266 # ObjCObject class
269 gb_ObjCObject_get_source = $(1)/$(2).m
270 # defined by platform
271 # gb_ObjCObject__command
273 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%)
274 $(call gb_ObjCObject__command,$@,$*,$<,$(call gb_ObjCObject_get_dep_target,$*))
276 ifeq ($(gb_FULLDEPS),$(true))
277 $(call gb_ObjCObject_get_dep_target,%) :
278 $(if $(wildcard $@),touch $@,\
279 $(call gb_Object__command_dep,$@,$(call gb_ObjCObject_get_target,$*)))
281 endif
284 # AsmObject class
286 # defined by platform
287 # gb_AsmObject_get_source (.asm on Windows, .s elsewhere)
288 # gb_AsmObject__command
290 $(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%)
291 $(call gb_AsmObject__command,$@,$*,$<,$(call gb_AsmObject_get_dep_target,$*))
293 ifeq ($(gb_FULLDEPS),$(true))
294 $(call gb_AsmObject_get_dep_target,%) :
295 $(if $(wildcard $@),touch $@,\
296 $(call gb_Object__command_dep,$@,$(call gb_AsmObject_get_target,$*)))
298 endif
301 # LinkTarget class
303 gb_LinkTarget_DEFAULTDEFS := $(gb_GLOBALDEFS)
305 # defined by platform
306 # gb_LinkTarget_CXXFLAGS
307 # gb_LinkTarget_LDFLAGS
308 # gb_LinkTarget_INCLUDE
309 # gb_LinkTarget_INCLUDE_STL
311 .PHONY : $(call gb_LinkTarget_get_clean_target,%)
312 $(call gb_LinkTarget_get_clean_target,%) :
313 $(call gb_Output_announce,$*,$(false),LNK,4)
314 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
315 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
316 $(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
317 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
318 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
319 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
320 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object))) \
321 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
322 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
323 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
324 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object))) \
325 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
326 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
327 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
328 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
329 $(call gb_LinkTarget_get_target,$*) \
330 $(call gb_LinkTarget_get_dep_target,$*) \
331 $(call gb_LinkTarget_get_headers_target,$*) \
332 $(call gb_LinkTarget_get_external_headers_target,$*) \
333 $(call gb_LinkTarget_get_objects_list,$*) \
334 $(DLLTARGET) \
335 $(AUXTARGETS)) && \
336 cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -fr && \
337 rm -f $${RESPONSEFILE}
340 # cat the deps of all objects in one file, then we need only open that one file
341 define gb_LinkTarget__command_dep
342 $(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
343 $(call gb_Helper_abbreviate_dirs,\
344 mkdir -p $(dir $(1)) && \
345 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
346 $(foreach object,$(3),$(call gb_CObject_get_dep_target,$(object))) \
347 $(foreach object,$(4),$(call gb_CxxObject_get_dep_target,$(object))) \
348 $(foreach object,$(5),$(call gb_ObjCObject_get_dep_target,$(object)))\
349 $(foreach object,$(6),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
350 $(foreach object,$(7),$(call gb_AsmObject_get_dep_target,$(object)))\
351 $(foreach object,$(8),$(call gb_GenCObject_get_dep_target,$(object))) \
352 $(foreach object,$(9),$(call gb_GenCxxObject_get_dep_target,$(object))) \
353 ) && \
354 $(SOLARENV)/bin/concat-deps $${RESPONSEFILE} > $(1)) && \
355 rm -f $${RESPONSEFILE}
357 endef
359 define gb_LinkTarget__command_objectlist
360 TEMPFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
361 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
362 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
363 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
364 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
365 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
366 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
367 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object)))) && \
368 $(if $(EXTRAOBJECTLISTS),cat $(EXTRAOBJECTLISTS) >> $${TEMPFILE} && ) \
369 mv $${TEMPFILE} $(call gb_LinkTarget_get_objects_list,$(2))
371 endef
373 # If object files from this library are merged, create just empty file
374 $(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_headers_target,%) $(gb_Helper_MISCDUMMY)
375 $(if $(filter $*,$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktargetname,$(lib)))), \
376 touch $@, $(call gb_LinkTarget__command,$@,$*))
377 $(call gb_LinkTarget__command_objectlist,$@,$*)
379 ifeq ($(gb_FULLDEPS),$(true))
380 $(call gb_LinkTarget_get_dep_target,%) :
381 $(call gb_LinkTarget__command_dep,$@,$*,$(COBJECTS),$(CXXOBJECTS),$(OBJCOBJECTS),$(OBJCXXOBJECTS),$(ASMOBJECTS),$(GENCOBJECTS),$(GENCXXOBJECTS))
382 endif
384 # Ok, this is some dark voodoo: When declaring a linktarget with
385 # gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
386 # target. When the rule for the headertarget is executed and SELF does not
387 # match the target name, we are depending on a linktarget that was never
388 # declared. In a full build exclusively in gbuild that should never happen.
389 # However, partial gbuild build will not know about how to build lower level
390 # linktargets, just as gbuild can not know about linktargets generated in the
391 # old build.pl/dmake system. Once all is migrated, gbuild should error out
392 # when is is told to depend on a linktarget it does not know about and not
393 # only warn.
394 define gb_LinkTarget__get_external_headers_check
395 ifneq ($$(SELF),$$*)
396 $$(eval $$(call gb_Output_info,LinkTarget $$* not defined: Assuming headers to be there!,ALL))
397 endif
398 $$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, mkdir -p $$(dir $$@) && touch $$@ && mkdir -p $(call gb_LinkTarget_get_target,)pdb/$$(dir $$*))
400 endef
402 $(call gb_LinkTarget_get_external_headers_target,%) :
403 $(eval $(gb_LinkTarget__get_external_headers_check))
404 $(COMMAND)
406 $(call gb_LinkTarget_get_headers_target,%) : $(call gb_LinkTarget_get_external_headers_target,%)
407 $(call gb_Helper_abbreviate_dirs,\
408 mkdir -p $(dir $@) && touch $@)
410 # Explanation of some of the targets:
411 # - gb_LinkTarget_get_external_headers_target is the targets that guarantees all
412 # headers from linked against libraries are in OUTDIR.
413 # - gb_LinkTarget_get_headers_target is the target that guarantees all headers
414 # from the linked against the libraries and the linktargets own headers
415 # (including generated headers) are in the OUTDIR.
416 # - gb_LinkTarget_get_target links the objects into a file in WORKDIR.
417 # gb_LinkTarget_get_target depends on gb_LinkTarget_get_headers_target which in
418 # turn depends gb_LinkTarget_get_external_headers_target.
419 # gb_LinkTarget_get_target depends additionally on the objects, which in turn
420 # depend build-order only on the gb_LinkTarget_get_headers_target. The build
421 # order-only dependency ensures all headers to be there for compiling and
422 # dependency generation without causing all objects to be rebuild when one
423 # header changes. Only the ones with an explicit dependency in their generated
424 # dependency file will be rebuild.
426 # gb_LinkTarget_get_target is the target that links the objects into a file in
427 # WORKDIR
428 # Explanation of some of the variables:
429 # - AUXTARGETS are the additionally generated files that need to be cleaned out
430 # on clean.
431 # - TARGETTYPE is the type of linktarget as some platforms need very different
432 # command to link different targettypes.
433 # - LIBRARY_X64 is only relevent for building a x64 library on windows.
435 # Since most variables are set on the linktarget and not on the object, the
436 # object learns about these setting via GNU makes scoping of target variables.
437 # Therefore it is important that objects are only directly depended on by the
438 # linktarget. This for example means that you cannot build a single object
439 # alone, because then you would directly depend on the object.
441 # A note about flags: because the overriding the global variables with a target
442 # local variable of the same name is considered obscure, the target local
443 # variables have a T_ prefix.
444 define gb_LinkTarget_LinkTarget
445 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
446 $(call gb_LinkTarget_get_external_headers_target,$(1)) : SELF := $(1)
447 $(call gb_LinkTarget_get_target,$(1)) : DLLTARGET :=
448 $(call gb_LinkTarget_get_clean_target,$(1)) \
449 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
450 $(call gb_LinkTarget_get_clean_target,$(1)) \
451 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
452 $(call gb_LinkTarget_get_clean_target,$(1)) \
453 $(call gb_LinkTarget_get_target,$(1)) : YACCOBJECT :=
454 $(call gb_LinkTarget_get_clean_target,$(1)) \
455 $(call gb_LinkTarget_get_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
456 $(call gb_LinkTarget_get_clean_target,$(1)) \
457 $(call gb_LinkTarget_get_target,$(1)) : LEXOBJECT :=
458 $(call gb_LinkTarget_get_clean_target,$(1)) \
459 $(call gb_LinkTarget_get_target,$(1)) : T_LEXFLAGS := $$(gb_LinkTarget_LEXFLAGS) $(LEXFLAGS)
460 $(call gb_LinkTarget_get_clean_target,$(1)) \
461 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
462 $(call gb_LinkTarget_get_clean_target,$(1)) \
463 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
464 $(call gb_LinkTarget_get_clean_target,$(1)) \
465 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS :=
466 $(call gb_LinkTarget_get_clean_target,$(1)) \
467 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS :=
468 $(call gb_LinkTarget_get_clean_target,$(1)) \
469 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS :=
470 $(call gb_LinkTarget_get_headers_target,$(1)) \
471 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
472 $(call gb_LinkTarget_get_headers_target,$(1)) \
473 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
474 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
475 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
476 $(call gb_LinkTarget_get_headers_target,$(1)) \
477 $(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
478 $(call gb_LinkTarget_get_headers_target,$(1)) \
479 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
480 $(call gb_LinkTarget_get_headers_target,$(1)) \
481 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE_STL := $$(gb_LinkTarget_INCLUDE_STL)
482 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $$(gb_LinkTarget_LDFLAGS) $(LDFLAGS)
483 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS :=
484 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS :=
485 $(call gb_LinkTarget_get_target,$(1)) : LIBS :=
486 $(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE :=
487 $(call gb_LinkTarget_get_target,$(1)) : LIBRARY_X64 :=
488 $(call gb_LinkTarget_get_headers_target,$(1)) \
489 $(call gb_LinkTarget_get_target,$(1)) : PDBFILE :=
490 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS :=
491 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES :=
492 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS :=
494 ifeq ($(gb_FULLDEPS),$(true))
495 -include $(call gb_LinkTarget_get_dep_target,$(1))
496 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
497 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
498 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS :=
499 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
500 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS :=
501 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
502 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
503 $(call gb_LinkTarget_get_dep_target,$(1)) : YACCOBJECTS :=
504 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
505 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
506 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
507 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
508 $(call gb_LinkTarget_get_dep_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
509 $(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $(CPPFLAGS)
510 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
511 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE_STL := $$(gb_LinkTarget_INCLUDE_STL)
512 $(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE :=
513 $(call gb_LinkTarget_get_dep_target,$(1)) : LIBRARY_X64 :=
514 $(call gb_LinkTarget_get_dep_target,$(1)) : EXTRAOBJECTLISTS :=
515 $(call gb_LinkTarget_get_dep_target,$(1)) : WARNINGS_NOT_ERRORS :=
516 endif
518 endef
520 define gb_LinkTarget_add_defs
521 $(call gb_LinkTarget_get_headers_target,$(1)) \
522 $(call gb_LinkTarget_get_target,$(1)) : DEFS += $(2)
523 ifeq ($(gb_FULLDEPS),$(true))
524 $(call gb_LinkTarget_get_dep_target,$(1)) : DEFS += $(2)
525 endif
526 endef
528 define gb_LinkTarget_set_defs
529 $$(call gb_Output_error,\
530 gb_LinkTarget_set_defs: use gb_LinkTarget_add_defs instead.)
531 endif
533 endef
535 define gb_LinkTarget_add_cflags
536 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS += $(2)
537 ifeq ($(gb_FULLDEPS),$(true))
538 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS += $(2)
539 endif
541 endef
543 define gb_LinkTarget_set_cflags
544 $$(call gb_Output_error,\
545 gb_LinkTarget_set_cflags: use gb_LinkTarget_add_cflags instead.)
546 endif
548 endef
550 define gb_LinkTarget_add_cxxflags
551 $(call gb_LinkTarget_get_headers_target,$(1)) \
552 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS += $(2)
553 ifeq ($(gb_FULLDEPS),$(true))
554 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS += $(2)
555 endif
556 endef
558 define gb_LinkTarget_set_cxxflags
559 $$(call gb_Output_error,\
560 gb_LinkTarget_set_cxxflags: use gb_LinkTarget_add_cxxflags instead.)
562 endef
564 define gb_LinkTarget_add_objcxxflags
565 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS += $(2)
566 ifeq ($(gb_FULLDEPS),$(true))
567 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS += $(2)
568 endif
569 endef
571 define gb_LinkTarget_set_objcxxflags
572 $$(call gb_Output_error,\
573 gb_LinkTarget_set_objcxxflags: use gb_LinkTarget_add_objcxxflags instead.)
575 endef
577 define gb_LinkTarget_set_objcflags
578 $$(call gb_Output_error,\
579 gb_LinkTarget_set_objcflags: use gb_LinkTarget_add_objcflags instead.)
581 endef
583 define gb_LinkTarget_add_objcflags
584 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS += $(2)
585 ifeq ($(gb_FULLDEPS),$(true))
586 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCFLAGS += $(2)
587 endif
589 endef
591 define gb_LinkTarget__add_include
592 $(call gb_LinkTarget_get_headers_target,$(1)) \
593 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(2)
594 ifeq ($(gb_FULLDEPS),$(true))
595 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += -I$(2)
596 endif
598 endef
600 define gb_LinkTarget_set_include
601 $(call gb_LinkTarget_get_headers_target,$(1)) \
602 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2)
603 ifeq ($(gb_FULLDEPS),$(true))
604 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $(2)
605 endif
607 endef
609 define gb_LinkTarget_set_include_stl
610 $(call gb_LinkTarget_get_headers_target,$(1)) \
611 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE_STL := $(2)
612 ifeq ($(gb_FULLDEPS),$(true))
613 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE_STL := $(2)
614 endif
616 endef
618 define gb_LinkTarget_add_ldflags
619 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS += $(2)
620 endef
622 # real use in RepositoryExternal.mk
623 define gb_LinkTarget_set_ldflags
624 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $(2)
625 endef
627 define gb_LinkTarget_add_libs
628 $(call gb_LinkTarget_get_target,$(1)) : LIBS += $(2)
629 endef
631 define gb_LinkTarget_add_api
632 $$(call gb_Output_error,\
633 gb_LinkTarget_add_api: use gb_LinkTarget_use_api instead.)
634 endef
636 define gb_LinkTarget__use_api
637 $(call gb_LinkTarget_get_target,$(1)) :| $(call gb_UnoApi_get_target,$(2))
638 $(call gb_LinkTarget_use_package,$(1),$(2)_inc)
639 $(call gb_LinkTarget__add_include,$(1),$(OUTDIR)/inc/$(2))
641 endef
643 define gb_LinkTarget_use_api
644 $(foreach api,$(2),$(call gb_LinkTarget__use_api,$(1),$(api)))
646 endef
648 define gb_LinkTarget__use_internal_api_one
649 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
650 $(call gb_UnoApiHeadersTarget_get_$(3)target,$(2))
651 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_$(3)dir,$(2)))
653 endef
655 define gb_LinkTarget__use_internal_api
656 $(foreach api,$(2),$(call gb_LinkTarget__use_internal_api_one,$(1),$(api),$(3)))
658 endef
660 define gb_LinkTarget_add_internal_api
661 $$(call gb_Output_error,\
662 gb_LinkTarget_add_internal_api: use gb_LinkTarget_use_internal_api instead.)
663 endef
665 define gb_LinkTarget_add_internal_bootstrap_api
666 $$(call gb_Output_error,\
667 gb_LinkTarget_add_internal_bootstrap_api: use gb_LinkTarget_use_internal_bootstrap_api instead.)
668 endef
670 define gb_LinkTarget_add_internal_comprehensive_api
671 $$(call gb_Output_error,\
672 gb_LinkTarget_add_internal_comprehensive_api: use gb_LinkTarget_use_internal_comprehensive_api instead.)
673 endef
676 define gb_LinkTarget_use_internal_api
677 $(call gb_LinkTarget__use_internal_api,$(1),$(2))
679 endef
681 define gb_LinkTarget_use_internal_bootstrap_api
682 $(call gb_LinkTarget__use_internal_api,$(1),$(2),bootstrap_)
684 endef
686 define gb_LinkTarget_use_internal_comprehensive_api
687 $(call gb_LinkTarget__use_internal_api,$(1),$(2),comprehensive_)
689 endef
691 define gb_LinkTarget_add_linked_libs
692 $$(call gb_Output_error,\
693 gb_LinkTarget_add_linked_libs: use gb_LinkTarget_use_libraries instead.)
694 endef
696 define gb_LinkTarget_use_libraries
697 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
698 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
699 $$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
700 endif
702 gb_LINKED_LIBS := $(if $(filter $(gb_MERGEDLIBS),$(2)), \
703 $(if $(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktargetname,$(lib)))),, merged)) \
704 $(filter-out $(gb_MERGEDLIBS),$(2))
706 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $$(gb_LINKED_LIBS)
708 $(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$$(gb_LINKED_LIBS),$$(call gb_Library_get_target,$$(lib)))
709 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
710 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
712 endef
714 define gb_LinkTarget_add_linked_static_libs
715 $$(call gb_Output_error,\
716 gb_LinkTarget_add_linked_static_libs: use gb_LinkTarget_use_static_libraries instead.)
717 endef
719 define gb_LinkTarget_use_static_libraries
720 ifneq (,$$(filter-out $(gb_StaticLibrary_KNOWNLIBS),$(2)))
721 $$(eval $$(call gb_Output_info, currently known static libraries are: $(sort $(gb_StaticLibrary_KNOWNLIBS)),ALL))
722 $$(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))
723 endif
725 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $(2)
727 $(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_StaticLibrary_get_target,$$(lib)))
728 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
729 $$(foreach lib,$(2),$$(call gb_StaticLibrary_get_headers_target,$$(lib)))
731 endef
733 define gb_LinkTarget_add_linked_static_external_libs
734 $$(call gb_Output_error,\
735 gb_LinkTarget_add_linked_static_external_libs: use gb_LinkTarget_use_static_external_libraries instead.)
736 endef
738 # TODO: why do we need this?
739 define gb_LinkTarget_use_static_external_libraries
741 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $(2)
743 $(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$(2),$$(call gb_ExternalLibs_get_target,$$(lib)))
744 $(call gb_LinkTarget_get_external_headers_target,$(1)) : $$(foreach lib,$(2),$$(call gb_ExternalLibs_get_target,$$(lib)))
746 endef
748 define gb_LinkTarget_add_cobject
749 $(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)))))
750 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
751 $(call gb_LinkTarget_get_clean_target,$(1)) : COBJECTS += $(2)
753 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CObject_get_target,$(2))
754 $(call gb_CObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
755 $(call gb_CObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
756 $(call gb_CObject_get_target,$(2)) : \
757 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
759 ifeq ($(gb_FULLDEPS),$(true))
760 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS += $(2)
761 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CObject_get_dep_target,$(2))
762 endif
764 endef
766 define gb_LinkTarget_add_cxxobject
767 $(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)))))
768 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
769 $(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
771 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
772 $(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
773 $(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
774 $(call gb_CxxObject_get_target,$(2)) : \
775 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
777 ifeq ($(gb_FULLDEPS),$(true))
778 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS += $(2)
779 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxObject_get_dep_target,$(2))
780 endif
782 endef
784 define gb_LinkTarget_add_objcobject
785 $(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)))))
786 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS += $(2)
787 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCOBJECTS += $(2)
789 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCObject_get_target,$(2))
790 $(call gb_ObjCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
791 $(call gb_ObjCObject_get_target,$(2)) : T_OBJCFLAGS += $(call gb_LinkTarget__get_objcflags,$(4)) $(3)
792 $(call gb_ObjCObject_get_target,$(2)) : \
793 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
795 ifeq ($(gb_FULLDEPS),$(true))
796 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS += $(2)
797 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCObject_get_dep_target,$(2))
798 endif
800 endef
802 define gb_LinkTarget_add_objcxxobject
803 $(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)))))
804 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
805 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCXXOBJECTS += $(2)
807 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCxxObject_get_target,$(2))
808 $(call gb_ObjCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
809 $(call gb_ObjCxxObject_get_target,$(2)) : T_OBJCXXFLAGS += $(call gb_LinkTarget__get_objcxxflags,$(4)) $(3)
810 $(call gb_ObjCxxObject_get_target,$(2)) : \
811 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
813 ifeq ($(gb_FULLDEPS),$(true))
814 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS += $(2)
815 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCxxObject_get_dep_target,$(2))
816 endif
818 endef
820 define gb_LinkTarget_add_asmobject
821 $(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)))))
822 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS += $(2)
823 $(call gb_LinkTarget_get_clean_target,$(1)) : ASMOBJECTS += $(2)
825 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_AsmObject_get_target,$(2))
826 $(call gb_AsmObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
827 $(call gb_AsmObject_get_target,$(2)) : \
828 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
830 ifeq ($(gb_FULLDEPS),$(true))
831 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS += $(2)
832 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_AsmObject_get_dep_target,$(2))
833 endif
835 endef
837 define gb_LinkTarget_add_generated_c_object
838 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS += $(2)
839 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCOBJECTS += $(2)
841 # Make just needs to know gb_GenCObject_get_source is a real target.
842 # Then it can use implicit rule for gb_GenCObject_get_target.
843 $(call gb_GenCObject_get_source,$(2)) : | $(gb_Helper_MISCDUMMY)
844 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCObject_get_target,$(2))
845 $(call gb_GenCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
846 $(call gb_GenCObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
847 $(call gb_GenCObject_get_target,$(2)) : \
848 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
850 ifeq ($(gb_FULLDEPS),$(true))
851 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS += $(2)
852 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCObject_get_dep_target,$(2))
853 endif
855 endef
857 define gb_LinkTarget_add_generated_cxx_object
858 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
859 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
861 # Make just needs to know gb_GenCxxObject_get_source is a real target.
862 # Then it can use implicit rule for gb_GenCxxObject_get_target.
863 $(call gb_GenCxxObject_get_source,$(2)) : | $(gb_Helper_MISCDUMMY)
864 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
865 $(call gb_GenCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
866 $(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
867 $(call gb_GenCxxObject_get_target,$(2)) : \
868 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
870 ifeq ($(gb_FULLDEPS),$(true))
871 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS += $(2)
872 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxObject_get_dep_target,$(2))
873 endif
875 endef
877 # Add a bison grammar to the build.
878 # gb_LinkTarget_add_grammar(<component>,<grammar file>)
879 define gb_LinkTarget_add_grammar
880 $(call gb_YaccTarget_YaccTarget,$(2))
881 $(call gb_LinkTarget_add_generated_exception_object,$(1),YaccTarget/$(2),$(3))
882 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_YaccTarget_get_clean_target,$(2))
883 $(call gb_LinkTarget_get_headers_target,$(1)) : $(call gb_YaccTarget_get_header_target,$(2))
884 $(call gb_LinkTarget__add_include,$(1),$(dir $(call gb_YaccTarget_get_header_target,$(2))))
886 endef
888 # Add bison grammars to the build.
889 # gb_LinkTarget_add_grammars(<component>,<grammar file> [<grammar file>*])
890 define gb_LinkTarget_add_grammars
891 $(foreach grammar,$(2),$(call gb_LinkTarget_add_grammar,$(1),$(grammar),$(4)))
892 endef
894 # Add a flex scanner to the build.
895 # gb_LinkTarget_add_scanner(<component>,<scanner file>)
896 define gb_LinkTarget_add_scanner
897 $(call gb_LexTarget_LexTarget,$(2))
898 ifeq ($(OS),MACOSX)
899 $(call gb_LinkTarget_add_generated_exception_object,$(1),LexTarget/$(2),$(3),-Wno-error)
900 else
901 $(call gb_LinkTarget_add_generated_exception_object,$(1),LexTarget/$(2),$(3))
902 endif
903 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_LexTarget_get_clean_target,$(2))
905 endef
907 # Add flex scanners to the build.
908 # gb_LinkTarget_add_scanners(<component>,<scanner file> [<scanner file>*])
909 define gb_LinkTarget_add_scanners
910 $(foreach scanner,$(2),$(call gb_LinkTarget_add_scanner,$(1),$(scanner),$(4)))
912 endef
914 define gb_LinkTarget_add_noexception_object
915 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_NOEXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)))
916 endef
918 define gb_LinkTarget_add_exception_object
919 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)))
920 endef
922 define gb_LinkTarget_add_linktarget_objects
923 $$(call gb_Output_error,\
924 gb_LinkTarget_add_linktarget_objects: use gb_LinkTarget__use_linktarget_objects instead.)
925 endef
927 define gb_LinkTarget__use_linktarget_objects
928 $(call gb_LinkTarget_get_target,$(1)) : $(foreach linktarget,$(2),$(call gb_LinkTarget_get_target,$(linktarget)))
929 ifneq ($(OS),IOS)
930 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS += $(foreach linktarget,$(2),$(call gb_LinkTarget_get_objects_list,$(linktarget)))
931 endif
933 endef
935 define gb_LinkTarget_add_library_objects
936 $$(call gb_Output_error,\
937 gb_LinkTarget_add_library_objects: use gb_LinkTarget_use_library_objects instead.)
938 endef
940 define gb_LinkTarget_use_library_objects
941 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
942 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
943 $$(eval $$(call gb_Output_error,Cannot import objects library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
944 endif
945 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach lib,$(2),$(call gb_Library_get_linktargetname,$(lib))))
947 endef
949 define gb_LinkTarget_add_executable_objects
950 $$(call gb_Output_error,\
951 gb_LinkTarget_add_executable_objects: use gb_LinkTarget_use_executable_objects instead.)
952 endef
954 define gb_LinkTarget_use_executable_objects
955 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach exe,$(2),$(call gb_Executable_get_linktargetname,$(lib))))
957 endef
959 define gb_LinkTarget_add_cobjects
960 $(foreach obj,$(2),$(call gb_LinkTarget_add_cobject,$(1),$(obj),$(3),$(4)))
961 endef
963 define gb_LinkTarget_add_cxxobjects
964 $(foreach obj,$(2),$(call gb_LinkTarget_add_cxxobject,$(1),$(obj),$(3)))
965 endef
967 define gb_LinkTarget_add_objcobjects
968 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcobject,$(1),$(obj),$(3),$(4)))
969 endef
971 define gb_LinkTarget_add_objcxxobjects
972 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3),$(4)))
973 endef
975 define gb_LinkTarget_add_asmobjects
976 $(foreach obj,$(2),$(call gb_LinkTarget_add_asmobject,$(1),$(obj),$(3)))
977 endef
979 define gb_LinkTarget_add_noexception_objects
980 $(foreach obj,$(2),$(call gb_LinkTarget_add_noexception_object,$(1),$(obj),$(4)))
981 endef
983 define gb_LinkTarget_add_exception_objects
984 $(foreach obj,$(2),$(call gb_LinkTarget_add_exception_object,$(1),$(obj),$(4)))
985 endef
987 #only useful for building x64 libraries on windows
988 define gb_LinkTarget_add_x64_generated_exception_objects
989 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
990 $(foreach obj,$(2),$(eval $(call gb_GenCxxObject_get_target,$(obj)) : CXXOBJECT_X64 := YES))
991 endef
993 define gb_LinkTarget_add_generated_cobjects
994 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
995 endef
997 define gb_LinkTarget_add_generated_cxxobjects
998 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_cxx_object,$(1),$(obj),$(3)))
999 endef
1001 define gb_LinkTarget_add_generated_exception_object
1002 $(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)) $(4))
1003 endef
1005 define gb_LinkTarget_add_generated_exception_objects
1006 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
1007 endef
1009 define gb_LinkTarget_set_targettype
1010 $(call gb_LinkTarget_get_target,$(1)) \
1011 $(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE := $(2)
1012 endef
1014 define gb_LinkTarget_set_x64
1015 $(call gb_LinkTarget_get_target,$(1)) \
1016 $(call gb_LinkTarget_get_dep_target,$(1)) : LIBRARY_X64 := $(2)
1017 endef
1019 define gb_LinkTarget_set_dlltarget
1020 $(call gb_LinkTarget_get_clean_target,$(1)) \
1021 $(call gb_LinkTarget_get_target,$(1)) : DLLTARGET := $(2)
1022 endef
1024 define gb_LinkTarget_set_auxtargets
1025 $$(call gb_Output_error,\
1026 gb_LinkTarget_set_auxtargets: use gb_LinkTarget_add_auxtargets instead.)
1027 endef
1029 define gb_LinkTarget_add_auxtargets
1030 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS += $(2)
1032 endef
1034 define gb_LinkTarget__add_internal_headers
1035 $(call gb_LinkTarget_get_headers_target,$(1)) : $(2)
1036 $(2) :| $(call gb_LinkTarget_get_external_headers_target,$(1))
1038 endef
1040 define gb_LinkTarget_add_custom_headers
1041 $$(call gb_Output_error,\
1042 gb_LinkTarget_add_custom_headers: use gb_LinkTarget_use_custom_headers instead.)
1043 endef
1045 define gb_LinkTarget__use_custom_headers
1046 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
1047 $(call gb_CustomTarget_get_target,$(2))
1048 $(call gb_LinkTarget__add_include,$(1),$(call gb_CustomTarget_get_workdir,$(2)))
1050 endef
1052 define gb_LinkTarget_use_custom_headers
1053 $(foreach customtarget,$(2),$(call gb_LinkTarget__use_custom_headers,$(1),$(customtarget)))
1055 endef
1057 define gb_LinkTarget_add_package_headers
1058 $$(call gb_Output_error,\
1059 gb_LinkTarget_add_package_headers: use gb_LinkTarget_use_package instead.)
1060 endef
1062 # add SDI (svidl) headers
1063 define gb_LinkTarget_add_sdi_headers
1064 $(call gb_LinkTarget__add_internal_headers,$(1),$(foreach sdi,$(2),$(call gb_SdiTarget_get_target,$(sdi))))
1065 $(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_clean_target,$(sdi)))
1066 endef
1068 define gb_LinkTarget_add_external_headers
1069 $$(call gb_Output_error,\
1070 gb_LinkTarget_add_external_headers: use gb_LinkTarget_use_package instead.)
1071 endef
1073 # use a header package, possibly from another module (i.e. via OUTDIR)
1074 define gb_LinkTarget_use_package
1075 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
1076 $(call gb_Package_get_target,$(strip $(2)))
1078 endef
1080 define gb_LinkTarget_use_packages
1081 $(foreach package,$(2),$(call gb_LinkTarget_use_package,$(1),$(package)))
1082 endef
1084 # this forwards to functions that must be defined in RepositoryExternal.mk.
1085 # $(eval $(call gb_LinkTarget_use_external,library,external))
1086 define gb_LinkTarget_use_external
1087 $(if $(filter undefined,$(origin gb_LinkTarget__use_$(2))),\
1088 $(error gb_LinkTarget_use_external: unknown external: $(2)),\
1089 $(call gb_LinkTarget__use_$(2),$(1)))
1090 endef
1092 # $(call gb_LinkTarget_use_externals,library,externals)
1093 gb_LinkTarget_use_externals = \
1094 $(foreach external,$(2),$(call gb_LinkTarget_use_external,$(1),$(external)))
1096 define gb_LinkTarget_set_warnings_not_errors
1097 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1098 ifeq ($(gb_FULLDEPS),$(true))
1099 $(call gb_LinkTarget_get_dep_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1100 endif
1102 endef
1104 # vim: set noet sw=4: