Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / solenv / gbuild / LinkTarget.mk
blobf2a5cfa67603aff1ee7c7da90043dae6ee69e4cc
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_DEBUGINFO_FOR)),,$(true)),\
42 $(or $(gb_Module_CURRENTMODULE_DEBUG_ENABLED),\
43 $(filter $(1),$(ENABLE_DEBUGINFO_FOR))))
45 # debug flags, if ENABLE_DEBUG is set and the LinkTarget is named
46 # in the list of libraries of ENABLE_DEBUGINFO_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 # similar for LDFLAGS, use linker optimization flags in non-debug case,
51 # but moreover strip debug from libraries for which debuginfo is not wanted
52 # (some libraries reuse .o files from other libraries, notably unittests)
53 gb_LinkTarget__get_stripldflags=$(if $(strip $(CFLAGS)$(CXXFLAGS)$(OBJCFLAGS)$(OBJCXXFLAGS)$(LDFLAGS)),,$(gb_LINKERSTRIPDEBUGFLAGS))
54 gb_LinkTarget__get_debugldflags=$(if $(call gb_LinkTarget__debug_enabled,$(1)),,$(gb_LINKEROPTFLAGS) $(call gb_LinkTarget__get_stripldflags,$(1)))
56 # generic cflags/cxxflags to use (optimization flags, debug flags)
57 # user supplied CFLAGS/CXXFLAGS override default debug/optimization flags
58 gb_LinkTarget__get_cflags=$(if $(CFLAGS),$(CFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
59 gb_LinkTarget__get_objcflags=$(if $(OBJCFLAGS),$(OBJCFLAGS),$(call gb_LinkTarget__get_debugcflags,$(1)))
60 gb_LinkTarget__get_cxxflags=$(if $(CXXFLAGS),$(CXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
61 gb_LinkTarget__get_objcxxflags=$(if $(OBJCXXFLAGS),$(OBJCXXFLAGS),$(call gb_LinkTarget__get_debugcxxflags,$(1)))
62 gb_LinkTarget__get_ldflags=$(if $(LDFLAGS),$(LDFLAGS),$(call gb_LinkTarget__get_debugldflags,$(1)))
64 # Overview of dependencies and tasks of LinkTarget
66 # target task depends on
67 # LinkTarget linking AsmObject CObject CxxObject GenCObject GenCxxObject ObjCObject ObjCxxObject
68 # LinkTarget/headers
69 # LinkTarget/dep joined dep file AsmObject/dep CObject/dep CxxObject/dep GenCObject/dep GenCxxObject/dep ObjCObject/dep ObjCxxObject/dep
70 # | LinkTarget/headers
71 # LinkTarget/headers all headers available LinkTarget/external_headers
72 # including own generated own generated headers
73 # LinkTarget/external_headers all external headers avail. header files of linked libs
75 # CObject plain c compile | LinkTarget/headers
76 # CxxObject c++ compile | LinkTarget/headers
77 # GenCObject plain c compile from | LinkTarget/headers
78 # generated source
79 # GenCxxObject C++ compile from | LinkTarget/headers
80 # generated source
81 # ObjCObject objective c compile | LinkTarget/headers
82 # ObjCxxObject objective c++ compile | LinkTarget/headers
84 # AsmObject asm compile | LinkTarget
86 # CObject/dep dependencies these targets generate empty dep files
87 # CxxObject/dep dependencies that are populated upon compile
88 # GenCObject/dep dependencies
89 # GenCxxObject/dep dependencies
90 # ObjCObject/dep dependencies
91 # ObjCxxObject/dep dependencies
92 # AsmObject/dep dependencies
94 # LinkTarget/headers means gb_LinkTarget_get_headers_target etc.
95 # dependencies prefixed with | are build-order only dependencies
98 # check that objects are only linked into one link target:
99 # multiple linking may cause problems because different link targets may
100 # require different compiler flags
101 define gb_Object__owner
102 $$(if $$(OBJECTOWNER),\
103 $$(call gb_Output_error,fdo#47246: $(1) is linked in by $$(OBJECTOWNER) $(2)))$(2)
104 endef
106 # For every object there is a dep file (if gb_FULLDEPS is active).
107 # The dep file depends on the object: the Object__command also updates the
108 # dep file as a side effect.
109 # In the dep file rule just touch it so it's newer than the object.
111 # The gb_Object__command_dep generates an "always rebuild" dep file;
112 # It is used on first build and in case the user deletes the object dep file.
113 ifeq ($(gb_FULLDEPS),$(true))
114 define gb_Object__command_dep
115 mkdir -p $(dir $(1)) && \
116 echo '$(2) : $$(gb_Helper_PHONY)' > $(1)
118 endef
119 else
120 gb_Object__command_dep = \
121 $(call gb_Output_error,gb_Object__command_dep is only for gb_FULLDEPS)
122 endif
124 # This one only exists to force .c/.cxx "rebuilds" when running a compiler tool.
125 .PHONY: force_compiler_tool_run
126 force_compiler_tool_run:
128 # CObject class
130 gb_CObject_get_source = $(1)/$(2).c
131 # defined by platform
132 # gb_CObject__command
134 ifneq ($(COMPILER_PLUGIN_TOOL),)
135 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%) force_compiler_tool_run
136 $(call gb_CObject__tool_command,$*,$<)
137 else
138 $(call gb_CObject_get_target,%) : $(call gb_CObject_get_source,$(SRCDIR),%)
139 $(call gb_CObject__command,$@,$*,$<,$(call gb_CObject_get_dep_target,$*))
140 endif
142 ifeq ($(gb_FULLDEPS),$(true))
143 $(call gb_CObject_get_dep_target,%) :
144 $(if $(wildcard $@),touch $@,\
145 $(call gb_Object__command_dep,$@,$(call gb_CObject_get_target,$*)))
147 endif
150 # CxxObject class
152 gb_CxxObject_get_source = $(1)/$(2).cxx
153 # defined by platform
154 # gb_CxxObject__command
156 ifneq ($(COMPILER_PLUGIN_TOOL),)
157 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%) force_compiler_tool_run
158 $(call gb_CxxObject__tool_command,$*,$<)
159 else
160 $(call gb_CxxObject_get_target,%) : $(call gb_CxxObject_get_source,$(SRCDIR),%)
161 $(call gb_CxxObject__command,$@,$*,$<,$(call gb_CxxObject_get_dep_target,$*))
162 endif
164 ifeq ($(gb_FULLDEPS),$(true))
165 $(call gb_CxxObject_get_dep_target,%) :
166 $(if $(wildcard $@),touch $@,\
167 $(call gb_Object__command_dep,$@,$(call gb_CxxObject_get_target,$*)))
169 endif
172 # GenCObject class
174 gb_GenCObject_get_source = $(WORKDIR)/$(1).c
175 # defined by platform
176 # gb_CObject__command
178 $(call gb_GenCObject_get_target,%) :
179 test -f $(call gb_GenCObject_get_source,$*) || (echo "Missing generated source file $(call gb_GenCObject_get_source,$*)" && false)
180 $(call gb_CObject__command,$@,$*,$(call gb_GenCObject_get_source,$*),$(call gb_GenCObject_get_dep_target,$*))
182 ifeq ($(gb_FULLDEPS),$(true))
183 $(call gb_GenCObject_get_dep_target,%) :
184 $(if $(wildcard $@),touch $@,\
185 $(call gb_Object__command_dep,$@,$(call gb_GenCObject_get_target,$*)))
187 endif
190 # GenCxxObject class
192 gb_GenCxxObject_get_source = $(WORKDIR)/$(1).$(gb_LinkTarget_CXX_SUFFIX_$(2))
193 # defined by platform
194 # gb_CxxObject__command
196 $(call gb_GenCxxObject_get_target,%) :
197 test -f $(GEN_CXX_SOURCE) || (echo "Missing generated source file $(GEN_CXX_SOURCE)" && false)
198 $(call gb_CxxObject__command,$@,$*,$(GEN_CXX_SOURCE),$(call gb_GenCxxObject_get_dep_target,$*))
200 ifeq ($(gb_FULLDEPS),$(true))
201 $(call gb_GenCxxObject_get_dep_target,%) :
202 $(if $(wildcard $@),touch $@,\
203 $(call gb_Object__command_dep,$@,$(call gb_GenCxxObject_get_target,$*)))
205 endif
208 # YaccTarget class
210 # XXX: This is more complicated than necessary, but we cannot just use
211 # the generated C++ file as the main target, because we need to let the
212 # header depend on that to ensure the header is present before anything
213 # tries to use it.
215 gb_YaccTarget_get_source = $(1)/$(2).y
216 # defined by platform
217 # gb_YaccTarget__command(grammar-file, stem-for-message, source-target, include-target)
219 .PHONY : $(call gb_YaccTarget_get_clean_target,%)
220 $(call gb_YaccTarget_get_clean_target,%) :
221 $(call gb_Output_announce,$*,$(false),YAC,3)
222 $(call gb_Helper_abbreviate_dirs,\
223 rm -f $(call gb_YaccTarget_get_grammar_target,$*) $(call gb_YaccTarget_get_header_target,$*) $(call gb_YaccTarget_get_target,$*))
225 $(call gb_YaccTarget_get_target,%) : $(call gb_YaccTarget_get_source,$(SRCDIR),%)
226 $(call gb_YaccTarget__command,$<,$*,$@,$(call gb_YaccTarget_get_header_target,$*),$(call gb_YaccTarget_get_grammar_target,$*))
228 define gb_YaccTarget_YaccTarget
229 $(call gb_YaccTarget_get_grammar_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
230 touch $$@
231 $(call gb_YaccTarget_get_header_target,$(1)) : $(call gb_YaccTarget_get_target,$(1))
232 touch $$@
234 endef
236 gb_YACC := bison
239 # LexTarget class
241 gb_LexTarget_get_source = $(1)/$(2).l
243 .PHONY : $(call gb_LexTarget_get_clean_target,%)
244 $(call gb_LexTarget_get_clean_target,%) :
245 $(call gb_Output_announce,$*,$(false),LEX,3)
246 $(call gb_Helper_abbreviate_dirs,\
247 rm -f $(call gb_LexTarget_get_scanner_target,$*) $(call gb_LexTarget_get_target,$*))
249 $(call gb_LexTarget_get_target,%) : $(call gb_LexTarget_get_source,$(SRCDIR),%)
250 $(call gb_LexTarget__command,$<,$*,$@,$(call gb_LexTarget_get_scanner_target,$*))
252 # gb_LexTarget_LexTarget(scanner-file)
253 define gb_LexTarget_LexTarget
254 $(call gb_LexTarget_get_scanner_target,$(1)) : $(call gb_LexTarget_get_target,$(1))
255 touch $$@
257 endef
259 # gb_LexTarget__command(scanner-file, stem-for-message, done-pseudo-target, source-target)
260 define gb_LexTarget__command
261 $(call gb_Output_announce,$(2),$(true),LEX,3)
262 $(call gb_Helper_abbreviate_dirs,\
263 mkdir -p $(dir $(3)) && \
264 $(FLEX) $(T_LEXFLAGS) -o$(4) $(1) && touch $(3) )
265 endef
268 # ObjCxxObject class
271 gb_ObjCxxObject_get_source = $(1)/$(2).mm
272 # defined by platform
273 # gb_ObjCxxObject__command
275 ifneq ($(COMPILER_PLUGIN_TOOL),)
276 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%) force_compiler_tool_run
277 $(call gb_ObjCxxObject__tool_command,$*,$<)
278 else
280 $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDIR),%)
281 $(call gb_ObjCxxObject__command,$@,$*,$<,$(call gb_ObjCxxObject_get_dep_target,$*))
283 ifeq ($(gb_FULLDEPS),$(true))
284 $(call gb_ObjCxxObject_get_dep_target,%) :
285 $(if $(wildcard $@),touch $@,\
286 $(call gb_Object__command_dep,$@,$(call gb_ObjCxxObject_get_target,$*)))
288 endif
289 endif
292 # ObjCObject class
295 gb_ObjCObject_get_source = $(1)/$(2).m
296 # defined by platform
297 # gb_ObjCObject__command
299 ifneq ($(COMPILER_PLUGIN_TOOL),)
300 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%) force_compiler_tool_run
301 $(call gb_ObjCObject__tool_command,$*,$<)
302 else
304 $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),%)
305 $(call gb_ObjCObject__command,$@,$*,$<,$(call gb_ObjCObject_get_dep_target,$*))
307 ifeq ($(gb_FULLDEPS),$(true))
308 $(call gb_ObjCObject_get_dep_target,%) :
309 $(if $(wildcard $@),touch $@,\
310 $(call gb_Object__command_dep,$@,$(call gb_ObjCObject_get_target,$*)))
312 endif
313 endif
316 # AsmObject class
318 # defined by platform
319 # gb_AsmObject_get_source (.asm on Windows, .s elsewhere)
320 # gb_AsmObject__command
322 $(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%)
323 $(call gb_AsmObject__command,$@,$*,$<,$(call gb_AsmObject_get_dep_target,$*))
325 ifeq ($(gb_FULLDEPS),$(true))
326 $(call gb_AsmObject_get_dep_target,%) :
327 $(if $(wildcard $@),touch $@,\
328 $(call gb_Object__command_dep,$@,$(call gb_AsmObject_get_target,$*)))
330 endif
333 # LinkTarget class
335 gb_LinkTarget_DEFAULTDEFS := $(gb_GLOBALDEFS)
337 define gb_LinkTarget_rtl_defs
338 $(if $(filter-out sal salhelper cppu cppuhelper, $(gb_Module_CURRENTMODULE_NAME)), -DRTL_USING)
339 endef
341 # defined by platform
342 # gb_LinkTarget_CXXFLAGS
343 # gb_LinkTarget_LDFLAGS
344 # gb_LinkTarget_INCLUDE
346 .PHONY : $(call gb_LinkTarget_get_clean_target,%)
347 $(call gb_LinkTarget_get_clean_target,%) :
348 $(call gb_Output_announce,$*,$(false),LNK,4)
349 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
350 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
351 $(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \
352 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
353 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \
354 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
355 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object))) \
356 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
357 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \
358 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
359 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object))) \
360 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
361 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \
362 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
363 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \
364 $(call gb_LinkTarget_get_target,$*) \
365 $(call gb_LinkTarget_get_dep_target,$*) \
366 $(call gb_LinkTarget_get_headers_target,$*) \
367 $(call gb_LinkTarget_get_external_headers_target,$*) \
368 $(call gb_LinkTarget_get_objects_list,$*) \
369 $(DLLTARGET) \
370 $(AUXTARGETS)) && \
371 cat $${RESPONSEFILE} /dev/null | xargs -n 200 rm -fr && \
372 rm -f $${RESPONSEFILE}
375 # cat the deps of all objects in one file, then we need only open that one file
376 define gb_LinkTarget__command_dep
377 $(call gb_Output_announce,LNK:$(2),$(true),DEP,1)
378 $(call gb_Helper_abbreviate_dirs,\
379 mkdir -p $(dir $(1)) && \
380 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
381 $(foreach object,$(3),$(call gb_CObject_get_dep_target,$(object))) \
382 $(foreach object,$(4),$(call gb_CxxObject_get_dep_target,$(object))) \
383 $(foreach object,$(5),$(call gb_ObjCObject_get_dep_target,$(object)))\
384 $(foreach object,$(6),$(call gb_ObjCxxObject_get_dep_target,$(object)))\
385 $(foreach object,$(7),$(call gb_AsmObject_get_dep_target,$(object)))\
386 $(foreach object,$(8),$(call gb_GenCObject_get_dep_target,$(object))) \
387 $(foreach object,$(9),$(call gb_GenCxxObject_get_dep_target,$(object))) \
388 ) && \
389 $(call gb_Executable_get_target_for_build,concat-deps) $${RESPONSEFILE} > $(1)) && \
390 rm -f $${RESPONSEFILE}
392 endef
394 define gb_LinkTarget__command_objectlist
395 TEMPFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\
396 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
397 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
398 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
399 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
400 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
401 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
402 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object)))) && \
403 $(if $(EXTRAOBJECTLISTS),cat $(EXTRAOBJECTLISTS) >> $${TEMPFILE} && ) \
404 mv $${TEMPFILE} $(call gb_LinkTarget_get_objects_list,$(2))
406 endef
408 # If object files from this library are merged, create just empty file
409 $(call gb_LinkTarget_get_target,%) : $(call gb_LinkTarget_get_headers_target,%) $(gb_Helper_MISCDUMMY)
410 $(if $(filter $*,$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktargetname,$(lib)))), \
411 touch $@, $(call gb_LinkTarget__command,$@,$*))
412 $(call gb_LinkTarget__command_objectlist,$@,$*)
414 ifeq ($(gb_FULLDEPS),$(true))
415 $(call gb_LinkTarget_get_dep_target,%) :
416 $(call gb_LinkTarget__command_dep,$@,$*,$(COBJECTS),$(CXXOBJECTS),$(OBJCOBJECTS),$(OBJCXXOBJECTS),$(ASMOBJECTS),$(GENCOBJECTS),$(GENCXXOBJECTS))
417 endif
419 # Ok, this is some dark voodoo: When declaring a linktarget with
420 # gb_LinkTarget_LinkTarget we set SELF in the headertarget to name of the
421 # target. When the rule for the headertarget is executed and SELF does not
422 # match the target name, we are depending on a linktarget that was never
423 # declared. In a full build exclusively in gbuild that should never happen.
424 # However, partial gbuild build will not know about how to build lower level
425 # linktargets, just as gbuild can not know about linktargets generated in the
426 # old build.pl/dmake system. Once all is migrated, gbuild should error out
427 # when is is told to depend on a linktarget it does not know about and not
428 # only warn.
429 define gb_LinkTarget__get_external_headers_check
430 ifneq ($$(SELF),$$*)
431 $$(eval $$(call gb_Output_info,LinkTarget $$* not defined: Assuming headers to be there!,ALL))
432 endif
433 $$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, mkdir -p $$(dir $$@) && touch $$@ && mkdir -p $(call gb_LinkTarget_get_target,)pdb/$$(dir $$*))
435 endef
437 $(call gb_LinkTarget_get_external_headers_target,%) :
438 $(eval $(gb_LinkTarget__get_external_headers_check))
439 $(COMMAND)
441 $(call gb_LinkTarget_get_headers_target,%) : $(call gb_LinkTarget_get_external_headers_target,%)
442 $(call gb_Helper_abbreviate_dirs,\
443 mkdir -p $(dir $@) && touch $@)
445 # Explanation of some of the targets:
446 # - gb_LinkTarget_get_external_headers_target is the targets that guarantees all
447 # headers from linked against libraries are in OUTDIR.
448 # - gb_LinkTarget_get_headers_target is the target that guarantees all headers
449 # from the linked against the libraries and the linktargets own headers
450 # (including generated headers) are in the OUTDIR.
451 # - gb_LinkTarget_get_target links the objects into a file in WORKDIR.
452 # gb_LinkTarget_get_target depends on gb_LinkTarget_get_headers_target which in
453 # turn depends gb_LinkTarget_get_external_headers_target.
454 # gb_LinkTarget_get_target depends additionally on the objects, which in turn
455 # depend build-order only on the gb_LinkTarget_get_headers_target. The build
456 # order-only dependency ensures all headers to be there for compiling and
457 # dependency generation without causing all objects to be rebuild when one
458 # header changes. Only the ones with an explicit dependency in their generated
459 # dependency file will be rebuild.
461 # gb_LinkTarget_get_target is the target that links the objects into a file in
462 # WORKDIR
463 # Explanation of some of the variables:
464 # - AUXTARGETS are the additionally generated files that need to be cleaned out
465 # on clean.
466 # - TARGETTYPE is the type of linktarget as some platforms need very different
467 # command to link different targettypes.
468 # - LIBRARY_X64 is only relevent for building a x64 library on windows.
470 # Since most variables are set on the linktarget and not on the object, the
471 # object learns about these setting via GNU makes scoping of target variables.
472 # Therefore it is important that objects are only directly depended on by the
473 # linktarget. This for example means that you cannot build a single object
474 # alone, because then you would directly depend on the object.
476 # A note about flags: because the overriding the global variables with a target
477 # local variable of the same name is considered obscure, the target local
478 # variables have a T_ prefix.
479 define gb_LinkTarget_LinkTarget
480 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
481 $(call gb_LinkTarget_get_external_headers_target,$(1)) : SELF := $(1)
482 $(call gb_LinkTarget_get_target,$(1)) : DLLTARGET :=
483 $(call gb_LinkTarget_get_clean_target,$(1)) \
484 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
485 $(call gb_LinkTarget_get_clean_target,$(1)) \
486 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS :=
487 $(call gb_LinkTarget_get_clean_target,$(1)) \
488 $(call gb_LinkTarget_get_target,$(1)) : YACCOBJECT :=
489 $(call gb_LinkTarget_get_clean_target,$(1)) \
490 $(call gb_LinkTarget_get_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
491 $(call gb_LinkTarget_get_clean_target,$(1)) \
492 $(call gb_LinkTarget_get_target,$(1)) : LEXOBJECT :=
493 $(call gb_LinkTarget_get_clean_target,$(1)) \
494 $(call gb_LinkTarget_get_target,$(1)) : T_LEXFLAGS := $$(gb_LinkTarget_LEXFLAGS) $(LEXFLAGS)
495 $(call gb_LinkTarget_get_clean_target,$(1)) \
496 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS :=
497 $(call gb_LinkTarget_get_clean_target,$(1)) \
498 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS :=
499 $(call gb_LinkTarget_get_clean_target,$(1)) \
500 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS :=
501 $(call gb_LinkTarget_get_clean_target,$(1)) \
502 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS :=
503 $(call gb_LinkTarget_get_clean_target,$(1)) \
504 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS :=
505 $(call gb_LinkTarget_get_headers_target,$(1)) \
506 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
507 $(call gb_LinkTarget_get_headers_target,$(1)) \
508 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
509 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
510 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
511 $(call gb_LinkTarget_get_headers_target,$(1)) \
512 $(call gb_LinkTarget_get_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $$(call gb_LinkTarget_rtl_defs,$(1)) $(CPPFLAGS)
513 $(call gb_LinkTarget_get_headers_target,$(1)) \
514 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
515 $(call gb_LinkTarget_get_headers_target,$(1)) \
516 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $$(gb_LinkTarget_LDFLAGS) $(call gb_LinkTarget__get_ldflags,$(2))
517 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS :=
518 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS :=
519 $(call gb_LinkTarget_get_target,$(1)) : LIBS :=
520 $(call gb_LinkTarget_get_target,$(1)) : TARGETTYPE :=
521 $(call gb_LinkTarget_get_target,$(1)) : LIBRARY_X64 :=
522 $(call gb_LinkTarget_get_headers_target,$(1)) \
523 $(call gb_LinkTarget_get_target,$(1)) : PDBFILE :=
524 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS :=
525 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES :=
526 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY :=
527 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS :=
528 $(call gb_LinkTarget_get_target,$(1)) : SOVERSION :=
529 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT :=
531 ifeq ($(gb_FULLDEPS),$(true))
532 -include $(call gb_LinkTarget_get_dep_target,$(1))
533 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS :=
534 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS :=
535 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS :=
536 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS :=
537 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS :=
538 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS :=
539 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS :=
540 $(call gb_LinkTarget_get_dep_target,$(1)) : YACCOBJECTS :=
541 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS := $$(gb_LinkTarget_CFLAGS)
542 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS := $$(gb_LinkTarget_CXXFLAGS)
543 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS := $$(gb_LinkTarget_OBJCXXFLAGS)
544 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCFLAGS := $$(gb_LinkTarget_OBJCFLAGS)
545 $(call gb_LinkTarget_get_dep_target,$(1)) : T_YACCFLAGS := $$(gb_LinkTarget_YYACFLAGS) $(YACCFLAGS)
546 $(call gb_LinkTarget_get_dep_target,$(1)) : DEFS := $$(gb_LinkTarget_DEFAULTDEFS) $$(call gb_LinkTarget_rtl_defs,$(1)) $(CPPFLAGS)
547 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $$(gb_LinkTarget_INCLUDE)
548 $(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE :=
549 $(call gb_LinkTarget_get_dep_target,$(1)) : LIBRARY_X64 :=
550 $(call gb_LinkTarget_get_dep_target,$(1)) : EXTRAOBJECTLISTS :=
551 $(call gb_LinkTarget_get_dep_target,$(1)) : VISIBILITY :=
552 $(call gb_LinkTarget_get_dep_target,$(1)) : WARNINGS_NOT_ERRORS :=
553 $(call gb_LinkTarget_get_dep_target,$(1)) : SOVERSION :=
554 $(call gb_LinkTarget_get_dep_target,$(1)) : SOVERSIONSCRIPT :=
555 endif
557 gb_LinkTarget_CXX_SUFFIX_$(1) := cxx
559 endef
561 define gb_LinkTarget_set_soversion_script
562 $(call gb_LinkTarget_get_target,$(1)) : $(3)
563 $(call gb_LinkTarget_get_target,$(1)) : SOVERSION := $(2)
564 $(call gb_LinkTarget_get_target,$(1)) : SOVERSIONSCRIPT := $(3)
566 endef
568 define gb_LinkTarget_add_defs
569 $(call gb_LinkTarget_get_headers_target,$(1)) \
570 $(call gb_LinkTarget_get_target,$(1)) : DEFS += $(2)
571 ifeq ($(gb_FULLDEPS),$(true))
572 $(call gb_LinkTarget_get_dep_target,$(1)) : DEFS += $(2)
573 endif
574 endef
576 define gb_LinkTarget_set_defs
577 $$(call gb_Output_error,\
578 gb_LinkTarget_set_defs: use gb_LinkTarget_add_defs instead.)
579 endif
581 endef
583 define gb_LinkTarget_add_cflags
584 $(call gb_LinkTarget_get_target,$(1)) : T_CFLAGS += $(2)
585 ifeq ($(gb_FULLDEPS),$(true))
586 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CFLAGS += $(2)
587 endif
589 endef
591 define gb_LinkTarget_set_cflags
592 $$(call gb_Output_error,\
593 gb_LinkTarget_set_cflags: use gb_LinkTarget_add_cflags instead.)
594 endif
596 endef
598 define gb_LinkTarget_add_cxxflags
599 $(call gb_LinkTarget_get_headers_target,$(1)) \
600 $(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS += $(2)
601 ifeq ($(gb_FULLDEPS),$(true))
602 $(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS += $(2)
603 endif
604 endef
606 define gb_LinkTarget_set_cxxflags
607 $$(call gb_Output_error,\
608 gb_LinkTarget_set_cxxflags: use gb_LinkTarget_add_cxxflags instead.)
610 endef
612 define gb_LinkTarget_add_objcxxflags
613 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCXXFLAGS += $(2)
614 ifeq ($(gb_FULLDEPS),$(true))
615 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCXXFLAGS += $(2)
616 endif
617 endef
619 define gb_LinkTarget_set_objcxxflags
620 $$(call gb_Output_error,\
621 gb_LinkTarget_set_objcxxflags: use gb_LinkTarget_add_objcxxflags instead.)
623 endef
625 define gb_LinkTarget_set_objcflags
626 $$(call gb_Output_error,\
627 gb_LinkTarget_set_objcflags: use gb_LinkTarget_add_objcflags instead.)
629 endef
631 define gb_LinkTarget_add_objcflags
632 $(call gb_LinkTarget_get_target,$(1)) : T_OBJCFLAGS += $(2)
633 ifeq ($(gb_FULLDEPS),$(true))
634 $(call gb_LinkTarget_get_dep_target,$(1)) : T_OBJCFLAGS += $(2)
635 endif
637 endef
639 define gb_LinkTarget__add_include
640 $(call gb_LinkTarget_get_headers_target,$(1)) \
641 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE += -I$(2)
642 ifeq ($(gb_FULLDEPS),$(true))
643 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE += -I$(2)
644 endif
646 endef
648 define gb_LinkTarget_set_include
649 $(call gb_LinkTarget_get_headers_target,$(1)) \
650 $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2)
651 ifeq ($(gb_FULLDEPS),$(true))
652 $(call gb_LinkTarget_get_dep_target,$(1)) : INCLUDE := $(2)
653 endif
655 endef
657 define gb_LinkTarget_set_include_stl
658 $$(call gb_Output_error,\
659 gb_LinkTarget_set_include_stl: removed, why is anybody calling it?)
660 endef
662 define gb_LinkTarget_add_ldflags
663 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS += $(2)
665 endef
667 # real use in RepositoryExternal.mk
668 define gb_LinkTarget_set_ldflags
669 $(call gb_LinkTarget_get_target,$(1)) : T_LDFLAGS := $(2)
671 endef
673 define gb_LinkTarget_add_libs
674 $(call gb_LinkTarget_get_target,$(1)) : LIBS += $(2)
676 endef
678 # remove platform specific standard libraries for linktarget $(1)
679 # assumption is that adding these standard libs is always useful, but in very
680 # exceptional cases this disable method may be used
681 define gb_LinkTarget_disable_standard_system_libs
682 $(call gb_LinkTarget_get_target,$(1)) : LIBS := $$(filter-out $$(gb_STDLIBS),$$(LIBS))
684 endef
686 define gb_LinkTarget_add_api
687 $$(call gb_Output_error,\
688 gb_LinkTarget_add_api: use gb_LinkTarget_use_api instead.)
689 endef
691 define gb_LinkTarget__use_api
692 $(call gb_LinkTarget_get_target,$(1)) :| $(call gb_UnoApi_get_target,$(2))
693 $(call gb_LinkTarget_use_package,$(1),$(2)_inc)
694 $(call gb_LinkTarget__add_include,$(1),$(OUTDIR)/inc/$(2))
696 endef
698 define gb_LinkTarget_use_api
699 $(foreach api,$(2),$(call gb_LinkTarget__use_api,$(1),$(api)))
701 endef
703 define gb_LinkTarget_use_udk_api
704 $(call gb_LinkTarget__use_api,$(1),udkapi)
705 endef
707 define gb_LinkTarget_use_sdk_api
708 $(call gb_LinkTarget__use_api,$(1),udkapi)
709 $(call gb_LinkTarget__use_api,$(1),offapi)
710 endef
712 define gb_LinkTarget__use_internal_api_one
713 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
714 $(call gb_UnoApiHeadersTarget_get_$(3)target,$(2))
715 $(call gb_LinkTarget__add_include,$(1),$(call gb_UnoApiHeadersTarget_get_$(3)dir,$(2)))
717 endef
719 define gb_LinkTarget__use_internal_api
720 $(foreach api,$(2),$(call gb_LinkTarget__use_internal_api_one,$(1),$(api),$(3)))
722 endef
724 define gb_LinkTarget_add_internal_api
725 $$(call gb_Output_error,\
726 gb_LinkTarget_add_internal_api: use gb_LinkTarget_use_internal_api instead.)
727 endef
729 define gb_LinkTarget_add_internal_bootstrap_api
730 $$(call gb_Output_error,\
731 gb_LinkTarget_add_internal_bootstrap_api: use gb_LinkTarget_use_internal_bootstrap_api instead.)
732 endef
734 define gb_LinkTarget_add_internal_comprehensive_api
735 $$(call gb_Output_error,\
736 gb_LinkTarget_add_internal_comprehensive_api: use gb_LinkTarget_use_internal_comprehensive_api instead.)
737 endef
740 define gb_LinkTarget_use_internal_api
741 $(call gb_LinkTarget__use_internal_api,$(1),$(2))
743 endef
745 define gb_LinkTarget_use_internal_bootstrap_api
746 $(call gb_LinkTarget__use_internal_api,$(1),$(2),bootstrap_)
748 endef
750 define gb_LinkTarget_use_internal_comprehensive_api
751 $(call gb_LinkTarget__use_internal_api,$(1),$(2),comprehensive_)
753 endef
755 define gb_LinkTarget_add_linked_libs
756 $$(call gb_Output_error,\
757 gb_LinkTarget_add_linked_libs: use gb_LinkTarget_use_libraries instead.)
758 endef
760 define gb_LinkTarget_use_libraries
761 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
762 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
763 $$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
764 endif
766 gb_LINKED_LIBS := $(if $(filter $(gb_MERGEDLIBS),$(2)), \
767 $(if $(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktargetname,$(lib)))),, merged)) \
768 $(filter-out $(gb_MERGEDLIBS),$(2))
770 $(call gb_LinkTarget_get_target,$(1)) : LINKED_LIBS += $$(gb_LINKED_LIBS)
772 $(call gb_LinkTarget_get_target,$(1)) : $$(foreach lib,$$(gb_LINKED_LIBS),$$(call gb_Library_get_target,$$(lib)))
773 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
774 $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib)))
776 endef
778 define gb_LinkTarget_add_linked_static_libs
779 $$(call gb_Output_error,\
780 gb_LinkTarget_add_linked_static_libs: use gb_LinkTarget_use_static_libraries instead.)
781 endef
783 # for a StaticLibrary, dependent libraries are not actually linked in
784 define gb_LinkTarget_use_static_libraries
785 ifneq (,$$(filter-out $(gb_StaticLibrary_KNOWNLIBS),$(2)))
786 $$(eval $$(call gb_Output_info, currently known static libraries are: $(sort $(gb_StaticLibrary_KNOWNLIBS)),ALL))
787 $$(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))
788 endif
790 $(call gb_LinkTarget_get_target,$(1)) : LINKED_STATIC_LIBS += $$(if $$(filter-out StaticLibrary,$$(TARGETTYPE)),$(2))
792 $(call gb_LinkTarget_get_target,$(1)) : $(foreach lib,$(2),$(call gb_StaticLibrary_get_target,$(lib)))
793 $(call gb_LinkTarget_get_external_headers_target,$(1)) : \
794 $(foreach lib,$(2),$(call gb_StaticLibrary_get_headers_target,$(lib)))
796 endef
798 define gb_LinkTarget_add_cobject
799 $(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)))))
800 $(call gb_LinkTarget_get_target,$(1)) : COBJECTS += $(2)
801 $(call gb_LinkTarget_get_clean_target,$(1)) : COBJECTS += $(2)
803 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CObject_get_target,$(2))
804 $(call gb_CObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
805 $(call gb_CObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
806 $(call gb_CObject_get_target,$(2)) : \
807 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
809 ifeq ($(gb_FULLDEPS),$(true))
810 $(call gb_LinkTarget_get_dep_target,$(1)) : COBJECTS += $(2)
811 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CObject_get_dep_target,$(2))
812 endif
814 endef
816 define gb_LinkTarget_add_cxxobject
817 $(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)))))
818 $(call gb_LinkTarget_get_target,$(1)) : CXXOBJECTS += $(2)
819 $(call gb_LinkTarget_get_clean_target,$(1)) : CXXOBJECTS += $(2)
821 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_CxxObject_get_target,$(2))
822 $(call gb_CxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
823 $(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
824 $(call gb_CxxObject_get_target,$(2)) : \
825 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
827 ifeq ($(gb_FULLDEPS),$(true))
828 $(call gb_LinkTarget_get_dep_target,$(1)) : CXXOBJECTS += $(2)
829 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_CxxObject_get_dep_target,$(2))
830 endif
832 endef
834 define gb_LinkTarget_add_objcobject
835 $(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)))))
836 $(call gb_LinkTarget_get_target,$(1)) : OBJCOBJECTS += $(2)
837 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCOBJECTS += $(2)
839 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCObject_get_target,$(2))
840 $(call gb_ObjCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
841 $(call gb_ObjCObject_get_target,$(2)) : T_OBJCFLAGS += $(call gb_LinkTarget__get_objcflags,$(4)) $(3)
842 $(call gb_ObjCObject_get_target,$(2)) : \
843 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
845 ifeq ($(gb_FULLDEPS),$(true))
846 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCOBJECTS += $(2)
847 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCObject_get_dep_target,$(2))
848 endif
850 endef
852 define gb_LinkTarget_add_objcxxobject
853 $(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)))))
854 $(call gb_LinkTarget_get_target,$(1)) : OBJCXXOBJECTS += $(2)
855 $(call gb_LinkTarget_get_clean_target,$(1)) : OBJCXXOBJECTS += $(2)
857 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_ObjCxxObject_get_target,$(2))
858 $(call gb_ObjCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
859 $(call gb_ObjCxxObject_get_target,$(2)) : T_OBJCXXFLAGS += $(call gb_LinkTarget__get_objcxxflags,$(4)) $(3)
860 $(call gb_ObjCxxObject_get_target,$(2)) : \
861 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
863 ifeq ($(gb_FULLDEPS),$(true))
864 $(call gb_LinkTarget_get_dep_target,$(1)) : OBJCXXOBJECTS += $(2)
865 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_ObjCxxObject_get_dep_target,$(2))
866 endif
868 endef
870 define gb_LinkTarget_add_asmobject
871 $(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)))))
872 $(call gb_LinkTarget_get_target,$(1)) : ASMOBJECTS += $(2)
873 $(call gb_LinkTarget_get_clean_target,$(1)) : ASMOBJECTS += $(2)
875 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_AsmObject_get_target,$(2))
876 $(call gb_AsmObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
877 $(call gb_AsmObject_get_target,$(2)) : \
878 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
880 ifeq ($(gb_FULLDEPS),$(true))
881 $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS += $(2)
882 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_AsmObject_get_dep_target,$(2))
883 endif
885 endef
887 define gb_LinkTarget_add_generated_c_object
888 $(call gb_LinkTarget_get_target,$(1)) : GENCOBJECTS += $(2)
889 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCOBJECTS += $(2)
891 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCObject_get_target,$(2))
892 $(call gb_GenCObject_get_target,$(2)) : $(call gb_GenCObject_get_source,$(2))
893 # Often gb_GenCObject_get_source does not have its own rule and is only a byproduct.
894 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
895 $(call gb_GenCObject_get_source,$(2)) : | $(gb_Helper_MISCDUMMY)
896 $(call gb_GenCObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
897 $(call gb_GenCObject_get_target,$(2)) : T_CFLAGS += $(call gb_LinkTarget__get_cflags,$(4)) $(3)
898 $(call gb_GenCObject_get_target,$(2)) : \
899 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
901 ifeq ($(gb_FULLDEPS),$(true))
902 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCOBJECTS += $(2)
903 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCObject_get_dep_target,$(2))
904 endif
906 endef
908 define gb_LinkTarget_add_generated_cxx_object
909 $(call gb_LinkTarget_get_target,$(1)) : GENCXXOBJECTS += $(2)
910 $(call gb_LinkTarget_get_clean_target,$(1)) : GENCXXOBJECTS += $(2)
912 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_GenCxxObject_get_target,$(2))
913 $(call gb_GenCxxObject_get_target,$(2)) : $(call gb_GenCxxObject_get_source,$(2),$(1))
914 # Often gb_GenCxxObject_get_source does not have its own rule and is only a byproduct.
915 # That's why we need this order-only dependency on gb_Helper_MISCDUMMY
916 $(call gb_GenCxxObject_get_source,$(2),$(1)) : | $(gb_Helper_MISCDUMMY)
917 $(call gb_GenCxxObject_get_target,$(2)) : | $(call gb_LinkTarget_get_headers_target,$(1))
918 $(call gb_GenCxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
919 $(call gb_GenCxxObject_get_target,$(2)) : \
920 OBJECTOWNER := $(call gb_Object__owner,$(2),$(1))
921 $(call gb_GenCxxObject_get_target,$(2)) : GEN_CXX_SOURCE := $(call gb_GenCxxObject_get_source,$(2),$(1))
923 ifeq ($(gb_FULLDEPS),$(true))
924 $(call gb_LinkTarget_get_dep_target,$(1)) : GENCXXOBJECTS += $(2)
925 $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_GenCxxObject_get_dep_target,$(2))
926 endif
928 endef
930 # Add a bison grammar to the build.
931 # gb_LinkTarget_add_grammar(<component>,<grammar file>)
932 define gb_LinkTarget_add_grammar
933 $(call gb_YaccTarget_YaccTarget,$(2))
934 $(call gb_LinkTarget_add_generated_exception_object,$(1),YaccTarget/$(2),$(3))
935 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_YaccTarget_get_clean_target,$(2))
936 $(call gb_LinkTarget_get_headers_target,$(1)) : $(call gb_YaccTarget_get_header_target,$(2))
937 $(call gb_LinkTarget__add_include,$(1),$(dir $(call gb_YaccTarget_get_header_target,$(2))))
939 endef
941 # Add bison grammars to the build.
942 # gb_LinkTarget_add_grammars(<component>,<grammar file> [<grammar file>*])
943 define gb_LinkTarget_add_grammars
944 $(foreach grammar,$(2),$(call gb_LinkTarget_add_grammar,$(1),$(grammar),$(4)))
945 endef
947 # Add a flex scanner to the build.
948 # gb_LinkTarget_add_scanner(<component>,<scanner file>)
949 define gb_LinkTarget_add_scanner
950 $(call gb_LexTarget_LexTarget,$(2))
951 $(call gb_LinkTarget_add_generated_exception_object,$(1),LexTarget/$(2),$(3))
952 $(call gb_GenCxxObject_get_target,LexTarget/$(2)) : WARNINGS_NOT_ERRORS := $(true)
953 $(call gb_LinkTarget_get_clean_target,$(1)) : $(call gb_LexTarget_get_clean_target,$(2))
955 endef
957 # Add flex scanners to the build.
958 # gb_LinkTarget_add_scanners(<component>,<scanner file> [<scanner file>*])
959 define gb_LinkTarget_add_scanners
960 $(foreach scanner,$(2),$(call gb_LinkTarget_add_scanner,$(1),$(scanner),$(4)))
962 endef
964 define gb_LinkTarget_add_noexception_object
965 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_NOEXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)))
966 endef
968 define gb_LinkTarget_add_exception_object
969 $(call gb_LinkTarget_add_cxxobject,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)))
970 endef
972 define gb_LinkTarget_add_linktarget_objects
973 $$(call gb_Output_error,\
974 gb_LinkTarget_add_linktarget_objects: use gb_LinkTarget__use_linktarget_objects instead.)
975 endef
977 define gb_LinkTarget__use_linktarget_objects
978 $(call gb_LinkTarget_get_target,$(1)) : $(foreach linktarget,$(2),$(call gb_LinkTarget_get_target,$(linktarget)))
979 ifneq ($(OS),IOS)
980 $(call gb_LinkTarget_get_target,$(1)) : EXTRAOBJECTLISTS += $(foreach linktarget,$(2),$(call gb_LinkTarget_get_objects_list,$(linktarget)))
981 endif
983 endef
985 define gb_LinkTarget_add_library_objects
986 $$(call gb_Output_error,\
987 gb_LinkTarget_add_library_objects: use gb_LinkTarget_use_library_objects instead.)
988 endef
990 define gb_LinkTarget_use_library_objects
991 ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
992 $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
993 $$(eval $$(call gb_Output_error,Cannot import objects library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
994 endif
995 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach lib,$(2),$(call gb_Library_get_linktargetname,$(lib))))
997 endef
999 define gb_LinkTarget_add_executable_objects
1000 $$(call gb_Output_error,\
1001 gb_LinkTarget_add_executable_objects: use gb_LinkTarget_use_executable_objects instead.)
1002 endef
1004 define gb_LinkTarget_use_executable_objects
1005 $(call gb_LinkTarget__use_linktarget_objects,$(1),$(foreach exe,$(2),$(call gb_Executable_get_linktargetname,$(lib))))
1007 endef
1009 define gb_LinkTarget_add_cobjects
1010 $(foreach obj,$(2),$(call gb_LinkTarget_add_cobject,$(1),$(obj),$(3),$(4)))
1011 endef
1013 define gb_LinkTarget_add_cxxobjects
1014 $(foreach obj,$(2),$(call gb_LinkTarget_add_cxxobject,$(1),$(obj),$(3)))
1015 endef
1017 define gb_LinkTarget_add_objcobjects
1018 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcobject,$(1),$(obj),$(3),$(4)))
1019 endef
1021 define gb_LinkTarget_add_objcxxobjects
1022 $(foreach obj,$(2),$(call gb_LinkTarget_add_objcxxobject,$(1),$(obj),$(3),$(4)))
1023 endef
1025 define gb_LinkTarget_add_asmobjects
1026 $(foreach obj,$(2),$(call gb_LinkTarget_add_asmobject,$(1),$(obj),$(3)))
1027 endef
1029 define gb_LinkTarget_add_noexception_objects
1030 $(foreach obj,$(2),$(call gb_LinkTarget_add_noexception_object,$(1),$(obj),$(4)))
1031 endef
1033 define gb_LinkTarget_add_exception_objects
1034 $(foreach obj,$(2),$(call gb_LinkTarget_add_exception_object,$(1),$(obj),$(4)))
1035 endef
1037 #only useful for building x64 libraries on windows
1038 define gb_LinkTarget_add_x64_generated_exception_objects
1039 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
1040 $(foreach obj,$(2),$(eval $(call gb_GenCxxObject_get_target,$(obj)) : CXXOBJECT_X64 := YES))
1041 endef
1043 define gb_LinkTarget_add_generated_cobjects
1044 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1045 endef
1047 #only useful for building x64 libraries on windows
1048 define gb_LinkTarget_add_x64_generated_cobjects
1049 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_c_object,$(1),$(obj),$(3),$(4)))
1050 $(foreach obj,$(2),$(eval $(call gb_GenCObject_get_target,$(obj)) : COBJECT_X64 := YES))
1051 endef
1053 define gb_LinkTarget_add_generated_cxxobjects
1054 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_cxx_object,$(1),$(obj),$(3)))
1055 endef
1057 define gb_LinkTarget_add_generated_exception_object
1058 $(call gb_LinkTarget_add_generated_cxx_object,$(1),$(2),$(gb_LinkTarget_EXCEPTIONFLAGS) $(call gb_LinkTarget__get_cxxflags,$(3)) $(4))
1059 endef
1061 define gb_LinkTarget_add_generated_exception_objects
1062 $(foreach obj,$(2),$(call gb_LinkTarget_add_generated_exception_object,$(1),$(obj),$(4)))
1063 endef
1065 define gb_LinkTarget_set_targettype
1066 $(call gb_LinkTarget_get_target,$(1)) \
1067 $(call gb_LinkTarget_get_dep_target,$(1)) : TARGETTYPE := $(2)
1069 endef
1071 define gb_LinkTarget_set_x64
1072 $(call gb_LinkTarget_get_target,$(1)) \
1073 $(call gb_LinkTarget_get_dep_target,$(1)) : LIBRARY_X64 := $(2)
1075 endef
1077 define gb_LinkTarget_set_dlltarget
1078 $(call gb_LinkTarget_get_clean_target,$(1)) \
1079 $(call gb_LinkTarget_get_target,$(1)) : DLLTARGET := $(2)
1081 endef
1083 define gb_LinkTarget_set_auxtargets
1084 $$(call gb_Output_error,\
1085 gb_LinkTarget_set_auxtargets: use gb_LinkTarget_add_auxtargets instead.)
1086 endef
1088 # Add a file that is built by the LinkTarget command and define
1089 # a dummy touch rule for it so it can be tracked via dependencies.
1090 # gb_LinkTarget_add_auxtarget linktarget auxtarget
1091 define gb_LinkTarget_add_auxtarget
1092 $(2) : $(call gb_LinkTarget_get_target,$(1))
1093 touch $$@
1095 $(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS += $(2)
1097 endef
1099 define gb_LinkTarget_add_auxtargets
1100 $(foreach aux,$(2),$(call gb_LinkTarget_add_auxtarget,$(1),$(aux)))
1102 endef
1104 define gb_LinkTarget__add_internal_headers
1105 $(call gb_LinkTarget_get_headers_target,$(1)) : $(2)
1106 $(2) :| $(call gb_LinkTarget_get_external_headers_target,$(1))
1108 endef
1110 define gb_LinkTarget_add_custom_headers
1111 $$(call gb_Output_error,\
1112 gb_LinkTarget_add_custom_headers: use gb_LinkTarget_use_custom_headers instead.)
1113 endef
1115 define gb_LinkTarget__use_custom_headers
1116 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
1117 $(call gb_CustomTarget_get_target,$(2))
1118 $(call gb_LinkTarget__add_include,$(1),$(call gb_CustomTarget_get_workdir,$(2)))
1120 endef
1122 define gb_LinkTarget_use_custom_headers
1123 $(foreach customtarget,$(2),$(call gb_LinkTarget__use_custom_headers,$(1),$(customtarget)))
1125 endef
1127 define gb_LinkTarget_add_package_headers
1128 $$(call gb_Output_error,\
1129 gb_LinkTarget_add_package_headers: use gb_LinkTarget_use_package instead.)
1130 endef
1132 # add SDI (svidl) headers
1133 define gb_LinkTarget_add_sdi_headers
1134 $(call gb_LinkTarget__add_internal_headers,$(1),$(foreach sdi,$(2),$(call gb_SdiTarget_get_target,$(sdi))))
1135 $(call gb_LinkTarget_get_clean_target,$(1)) : $(foreach sdi,$(2),$(call gb_SdiTarget_get_clean_target,$(sdi)))
1137 endef
1139 define gb_LinkTarget_add_external_headers
1140 $$(call gb_Output_error,\
1141 gb_LinkTarget_add_external_headers: use gb_LinkTarget_use_package instead.)
1142 endef
1144 # use a header package, possibly from another module (i.e. via OUTDIR)
1145 define gb_LinkTarget_use_package
1146 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| \
1147 $(call gb_Package_get_target,$(strip $(2)))
1149 endef
1151 define gb_LinkTarget_use_packages
1152 $(foreach package,$(2),$(call gb_LinkTarget_use_package,$(1),$(package)))
1153 endef
1155 # Use sources from unpacked tarball of an external project
1156 define gb_LinkTarget_use_unpacked
1157 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| $(call gb_UnpackedTarball_get_final_target,$(2))
1159 endef
1161 # Use artifacts from ExternalProject (i. e. configure) of an external project
1162 # example in expat: StaticLibrary depends on ExternalProject outcome
1163 define gb_LinkTarget_use_external_project
1164 $(call gb_LinkTarget_get_external_headers_target,$(1)) :| $(call gb_ExternalProject_get_target,$(2))
1166 endef
1169 # this forwards to functions that must be defined in RepositoryExternal.mk.
1170 # $(eval $(call gb_LinkTarget_use_external,library,external))
1171 define gb_LinkTarget_use_external
1172 $(if $(filter undefined,$(origin gb_LinkTarget__use_$(2))),\
1173 $(error gb_LinkTarget_use_external: unknown external: $(2)),\
1174 $(call gb_LinkTarget__use_$(2),$(1)))
1175 endef
1177 # $(call gb_LinkTarget_use_externals,library,externals)
1178 gb_LinkTarget_use_externals = \
1179 $(foreach external,$(2),$(call gb_LinkTarget_use_external,$(1),$(external)))
1181 define gb_LinkTarget_set_visibility_default
1182 $(call gb_LinkTarget_get_target,$(1)) : VISIBILITY := default
1183 ifeq ($(gb_FULLDEPS),$(true))
1184 $(call gb_LinkTarget_get_dep_target,$(1)) : VISIBILITY := default
1185 endif
1187 endef
1189 define gb_LinkTarget_set_warnings_not_errors
1190 $(call gb_LinkTarget_get_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1191 ifeq ($(gb_FULLDEPS),$(true))
1192 $(call gb_LinkTarget_get_dep_target,$(1)) : WARNINGS_NOT_ERRORS := $(true)
1193 endif
1195 endef
1197 # Set suffix of C++ files, if different from 'cxx'
1199 # This is useful for external libraries.
1201 # gb_LinkTarget_set_generated_cxx_suffix linktarget used-suffix
1202 define gb_LinkTarget_set_generated_cxx_suffix
1203 gb_LinkTarget_CXX_SUFFIX_$(1) := $(2)
1205 endef
1207 # vim: set noet sw=4: