src/Makefile.kmk: new sed on windows
[kbuild-mirror.git] / kBuild / tools / VCC142.kmk
blob074568e99e97c4a6af087d4f63d3441cf92ad7a3
1 # $Id$
2 ## @file
3 # kBuild Tool Config - Visual C++ 14.2 (aka Visual 2019 and MSC v19.20), default target.
7 # Copyright (c) 2004-2020 knut st. osmundsen <bird-kBuild-spam-xx@anduin.net>
9 # This file is part of kBuild.
11 # kBuild is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # kBuild 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 General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with kBuild; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 # As a special exception you are granted permission to include this file, via
27 # the kmk include directive, as you wish without this in itself causing the
28 # resulting makefile, program or whatever to be covered by the GPL license.
29 # This exception does not however invalidate any other reasons why the makefile,
30 # program, whatever should not be covered the GPL.
34 TOOL_VCC142 := Visual C++ 14.2 (aka Visual 2019 and MSC v19.20), targeting $(KBUILD_TARGET).
36 ifndef INCLUDED_WIN_COMMON_KMK
37 include $(KBUILD_PATH)/win-common.kmk
38 endif
41 # Tool Specific Properties
43 ifndef PATH_TOOL_VCC142
44 PATH_TOOL_VCC142 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win.amd64/vcc/v14.2*/Tools/MSVC/14.2?.*)))
45 ifeq ($(PATH_TOOL_VCC142),)
46 PATH_TOOL_VCC142 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win.x86/vcc/v14.2*/Tools/MSVC/14.2?.*)))
47 endif
48 ifeq ($(PATH_TOOL_VCC142),)
49 PATH_TOOL_VCC142 := $(PATH_TOOL_VCC142X86)
50 endif
51 ifeq ($(PATH_TOOL_VCC142),)
52 PATH_TOOL_VCC142 := $(PATH_TOOL_VCC142)
53 endif
54 ifeq ($(PATH_TOOL_VCC142),)
55 PATH_TOOL_VCC142 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win.x86/vcc/v14.2*/Tools/MSVC/14.2?.*)))
56 ifeq ($(PATH_TOOL_VCC142),)
57 PATH_TOOL_VCC142 := $(firstfile $(foreach ver,2019,$(foreachfile progfilesdir,$(WINCMN_PROGRAM_FILES_LIST)\
58 , $(rversortfiles $(qwildcard ,$(progfilesdir)/Microsoft\ Visual\ Studio/$(ver)/BuildTools/VC/Tools/MSVC/14.2?.*)))))
59 ifeq ($(PATH_TOOL_VCC142),)
60 $(warning kBuild: PATH_TOOL_VCC142 cannot be determined!)
61 PATH_TOOL_VCC142 := $(KBUILD_DEVTOOLS)/win.x86/vcc/v142
62 endif
63 endif
64 endif
65 else
66 # Resolve any fancy stuff once and for all.
67 PATH_TOOL_VCC142 := $(PATH_TOOL_VCC142)
68 endif
70 ifndef PATH_TOOL_VCC142_BASE_BIN
71 PATH_TOOL_VCC142_BASE_BIN := $(PATH_TOOL_VCC142)/bin
72 endif
73 ifndef PATH_TOOL_VCC142_HOST_BIN
74 PATH_TOOL_VCC142_HOST_BIN := $(PATH_TOOL_VCC142_BASE_BIN)/Host$(WINCMN_MAP_ARCH.$(KBUILD_HOST_ARCH))
75 endif
76 ifndef PATH_TOOL_VCC142_BIN
77 PATH_TOOL_VCC142_BIN := $(PATH_TOOL_VCC142_HOST_BIN)/$(WINCMN_MAP_ARCH.$(KBUILD_TARGET_ARCH))
78 endif
79 PATH_TOOL_VCC142_BIN_QSH := $(requote sh,$(PATH_TOOL_VCC142_BIN))
81 # A bunch of DLLs are only in the subdir matching the host one, so we need to add it to the PATH when cross compiling.
82 ifndef PATH_TOOL_VCC142_HOST_DLL_BIN
83 PATH_TOOL_VCC142_HOST_DLL_BIN := $(PATH_TOOL_VCC142_HOST_BIN)/$(WINCMN_MAP_ARCH.$(KBUILD_HOST_ARCH))
84 endif
85 ifndef PATH_TOOL_VCC142_DLL_BIN
86 ifneq ($(PATH_TOOL_VCC142_HOST_DLL_BIN),$(PATH_TOOL_VCC142_BIN))
87 PATH_TOOL_VCC142_DLL_BIN := $(PATH_TOOL_VCC142_HOST_DLL_BIN)
88 endif
89 endif
91 PATH_TOOL_VCC142_LIB.amd64 ?= $(PATH_TOOL_VCC142)/lib/x64
92 PATH_TOOL_VCC142_LIB.arm32 ?= $(PATH_TOOL_VCC142)/lib/arm
93 PATH_TOOL_VCC142_LIB.arm64 ?= $(PATH_TOOL_VCC142)/lib/arm64
94 PATH_TOOL_VCC142_LIB.x86 ?= $(PATH_TOOL_VCC142)/lib/x86
96 PATH_TOOL_VCC142_ONECORE_LIB.amd64 ?= $(PATH_TOOL_VCC142)/lib/onecore/x64
97 PATH_TOOL_VCC142_ONECORE_LIB.arm32 ?= $(PATH_TOOL_VCC142)/lib/onecore/arm
98 PATH_TOOL_VCC142_ONECORE_LIB.arm64 ?= $(PATH_TOOL_VCC142)/lib/onecore/arm64
99 PATH_TOOL_VCC142_ONECORE_LIB.x86 ?= $(PATH_TOOL_VCC142)/lib/onecore/x86
101 PATH_TOOL_VCC142_INC ?= $(PATH_TOOL_VCC142)/include
103 PATH_TOOL_VCC142_ATLMFC ?= $(PATH_TOOL_VCC142)/atlmfc
104 PATH_TOOL_VCC142_ATLMFC_INC ?= $(PATH_TOOL_VCC142_ATLMFC)/include
105 PATH_TOOL_VCC142_ATLMFC_LIB.x86 ?= $(PATH_TOOL_VCC142_ATLMFC)/lib/x86
106 PATH_TOOL_VCC142_ATLMFC_LIB.amd64 ?= $(PATH_TOOL_VCC142_ATLMFC)/lib/x64
108 TOOL_VCC142_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/cl.exe
109 TOOL_VCC142_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/cl.exe
110 ifeq ($(KBUILD_TARGET_ARCH),x86)
111 TOOL_VCC142_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/ml.exe
112 else
113 TOOL_VCC142_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/ml64.exe
114 endif
115 #TOOL_VCC142_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/lib.exe - just an exec wrapper for the below
116 TOOL_VCC142_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/link.exe /LIB
117 TOOL_VCC142_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/link.exe
118 TOOL_VCC142_DUMPBIN ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/dumpbin.exe
119 TOOL_VCC142_EDITBIN ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC142_BIN_QSH)/editbin.exe
121 TOOL_VCC142_RC ?= $(EXEC_X86_WIN32) $(call TOOL_VCC142_FN_FIND_SDK_TOOL,rc.exe,[Rr][Cc].[Ee][Xx][Ee],TOOL_VCC142_RC_CACHED)
122 TOOL_VCC142_MT ?= $(TOOL_VCC142_MT_RETRY) $(EXEC_X86_WIN32) $(call TOOL_VCC142_FN_FIND_SDK_TOOL,mt.exe,[Mm][Tt].[Ee][Xx][Ee],TOOL_VCC142_MT_CACHED)
123 TOOL_VCC142_MT_RETRY ?= $(WINCMN_MT_RETRY)
125 ifdef TOOL_VCC142_USE_KSUBMIT
126 ifeq ($(KBUILD_HOST),win)
127 ifeq ($(findstring /HostX86/,$(PATH_TOOL_VCC142AMD64_BIN)),/HostX86/)
128 TOOL_VCC142_KSUBMIT ?= kmk_builtin_kSubmit --32-bit
129 else
130 TOOL_VCC142_KSUBMIT ?= kmk_builtin_kSubmit --64-bit
131 endif
132 ifdef PATH_TOOL_VCC142_DLL_BIN
133 TOOL_VCC142_KSUBMIT := $(TOOL_VCC142_KSUBMIT) --prepend "PATH=$(requote shell-in-dq,$(PATH_TOOL_VCC142_DLL_BIN));"
134 endif
135 TOOL_VCC142_KSUBMIT_DD := $(TOOL_VCC142_KSUBMIT) --
136 endif
137 endif
138 ifdef PATH_TOOL_VCC142_DLL_BIN
139 TOOL_VCC142_SETUP_ENV := $(REDIRECT) --prepend "PATH=$(requote shell-in-dq,$(PATH_TOOL_VCC142_DLL_BIN));" --$(SP)
140 ifndef TOOL_VCC142_KSUBMIT_DD
141 TOOL_VCC142_KSUBMIT_DD := $(TOOL_VCC142_SETUP_ENV)
142 endif
143 endif
146 ## Helper for finding rc.exe and mt.exe in the SDK.
147 TOOL_VCC142_FN_FIND_SDK_TOOL_SUB = $(eval $3 := $(qfirstfile sh,\
148 $(if-expr defined(PATH_SDK_WINSDK10_BIN) , $(qwildcard ,$(PATH_SDK_WINSDK10_BIN)/$2)) \
149 $(if-expr defined(PATH_SDK_WINPSDK71_BIN), $(qwildcard ,$(PATH_SDK_WINPSDK71_BIN)/$2)) \
150 $(if-expr defined(PATH_SDK_WINPSDK_BIN) , $(qwildcard ,$(PATH_SDK_WINPSDK_BIN)/$2)) \
151 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/sdk/*/[Bb][Ii][Nn]/$2)) \
152 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/sdk/*/[Bb][Ii][Nn]/$2)) \
153 $1))
154 TOOL_VCC142_FN_FIND_SDK_TOOL = $(if-expr !defined($3),$(TOOL_VCC142_FN_FIND_SDK_TOOL_SUB),)$($3)
156 ## Constructs the correct .pdb name (the name is lowercased).
157 # @param $(1) Base name, no extention.
158 # @param $(2) The extension.
159 TOOL_VCC142_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2)
162 # Try find the redist directory. A little complicated as the build number
163 # doesn't necessarily match that of the compiler.
165 ifeq ($(tolower $(substr $(qdir u,$(PATH_TOOL_VCC142)), -12)),/tools/msvc/)
166 PATH_TOOL_VCC142_REDIST ?= $(firstfile $(qwildcard ,$(substr $(qdir ,$(PATH_TOOL_VCC142)), 1, -12)/Redist/MSVC/14.2*))
167 else
168 PATH_TOOL_VCC142_REDIST ?= $(qabspath ,$(firstfile $(qwildcard ,\
169 $(PATH_TOOL_VCC142)/Redist \
170 $(PATH_TOOL_VCC142)/../Redist \
171 $(PATH_TOOL_VCC142)/../../Redist \
172 $(PATH_TOOL_VCC142)/../../../Redist \
173 $(PATH_TOOL_VCC142)/../../../../Redist)))
174 endif
175 PATH_TOOL_VCC142_REDIST_DEBUG ?= $(PATH_TOOL_VCC142_REDIST)/debug_nonredist
177 ## Updates may add more msvcp140_[0-9].dll images as the product matures.
178 # This helper locates them (can differ between archs).
179 # @param 1 Redist subdirectory.
180 # @param 2 The DLL basename (no suffix).
181 # @param 3 The VCC architecture name (for constructing the path).
182 FN_TOOL_VCC142_FIND_DLLS = $(2).dll \
183 $(versortfiles $(qnotdir ,$(qwildcard ,$(PATH_TOOL_VCC142_REDIST)/$(3)/$(1)/$(2)_?.dll)))
185 TOOL_VCC142_REDIST_CRT_SUBDIR := Microsoft.VC142.CRT
186 TOOL_VCC142_REDIST_DEBUG_CRT_SUBDIR := Microsoft.VC142.DebugCRT
188 TOOL_VCC142_REDIST_CRT_DLLS.x86 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vcruntime140,x86)
189 TOOL_VCC142_REDIST_CRT_DLLS.amd64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vcruntime140,x64)
190 TOOL_VCC142_REDIST_CRT_DLLS.arm32 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vcruntime140,arm)
191 TOOL_VCC142_REDIST_CRT_DLLS.arm64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vcruntime140,arm64)
192 TOOL_VCC142_REDIST_CRT_DLLS = $(TOOL_VCC142_REDIST_CRT_DLLS.$(KBUILD_TARGET_ARCH))
194 TOOL_VCC142_REDIST_CONCRT_DLLS.x86 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),concrt140,x86)
195 TOOL_VCC142_REDIST_CONCRT_DLLS.amd64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),concrt140,x64)
196 TOOL_VCC142_REDIST_CONCRT_DLLS.arm32 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),concrt140,arm)
197 TOOL_VCC142_REDIST_CONCRT_DLLS.arm64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),concrt140,arm64)
198 TOOL_VCC142_REDIST_CONCRT_DLLS = $(TOOL_VCC142_REDIST_CONCRT_DLLS.$(KBUILD_TARGET_ARCH))
200 TOOL_VCC142_REDIST_CPP_DLLS.x86 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),msvcp140,x86)
201 TOOL_VCC142_REDIST_CPP_DLLS.amd64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),msvcp140,x64)
202 TOOL_VCC142_REDIST_CPP_DLLS.arm32 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),msvcp140,arm)
203 TOOL_VCC142_REDIST_CPP_DLLS.arm64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),msvcp140,arm64)
204 TOOL_VCC142_REDIST_CPP_DLLS = $(TOOL_VCC142_REDIST_CPP_DLLS.$(KBUILD_TARGET_ARCH))
206 TOOL_VCC142_REDIST_WINRT_DLLS.x86 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vccorlib140,x86)
207 TOOL_VCC142_REDIST_WINRT_DLLS.amd64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vccorlib140,x64)
208 TOOL_VCC142_REDIST_WINRT_DLLS.arm32 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vccorlib140,arm)
209 TOOL_VCC142_REDIST_WINRT_DLLS.arm64 = $(call FN_TOOL_VCC142_FIND_DLLS,$(TOOL_VCC142_REDIST_CRT_SUBDIR),vccorlib140,arm64)
210 TOOL_VCC142_REDIST_WINRT_DLLS = $(TOOL_VCC142_REDIST_WINRT_DLLS.$(KBUILD_TARGET_ARCH))
212 TOOL_VCC142_REDIST_CXXAMP_SUBDIR := Microsoft.VC142.CXXAMP
213 TOOL_VCC142_REDIST_MFC_SUBDIR := Microsoft.VC142.MFC
214 TOOL_VCC142_REDIST_MFCLOC_SUBDIR := Microsoft.VC142.MFCLOC
215 TOOL_VCC142_REDIST_OPENMP_SUBDIR := Microsoft.VC142.OpenMP
219 # Properties used by kBuild
221 TOOL_VCC142_COBJSUFF ?= .obj
222 TOOL_VCC142_CFLAGS ?= -TC -nologo -Zi -ZH:SHA_256
223 TOOL_VCC142_CFLAGS.debug ?=
224 TOOL_VCC142_CFLAGS.dbgopt ?= -O2
225 TOOL_VCC142_CFLAGS.release ?= -O2
226 TOOL_VCC142_CFLAGS.profile ?= -O2
227 TOOL_VCC142_CINCS ?= $(PATH_TOOL_VCC142_INC)
228 TOOL_VCC142_CDEFS ?=
230 TOOL_VCC142_CXXOBJSUFF ?= .obj
231 TOOL_VCC142_CXXFLAGS ?= -TP -nologo -Zi -ZH:SHA_256
232 TOOL_VCC142_CXXFLAGS.debug ?=
233 TOOL_VCC142_CXXFLAGS.dbgopt ?= -O2
234 TOOL_VCC142_CXXFLAGS.release ?= -O2
235 TOOL_VCC142_CXXFLAGS.profile ?= -O2
236 TOOL_VCC142_CXXINCS ?= $(PATH_TOOL_VCC142_INC) $(PATH_TOOL_VCC142_ATLMFC_INC)
237 TOOL_VCC142_CXXDEFS ?=
239 TOOL_VCC142_ASOBJSUFF ?= .obj
241 TOOL_VCC142_RCOBJSUFF ?= .res
242 TOOL_VCC142_RCINCS ?= $(PATH_TOOL_VCC142_INC) $(PATH_TOOL_VCC142_ATLMFC_INC)
244 TOOL_VCC142_ARFLAGS ?= -nologo
245 TOOL_VCC142_ARFLAGS.x86 ?= -machine:x86
246 TOOL_VCC142_ARFLAGS.amd64 ?= -machine:amd64
247 TOOL_VCC142_ARFLAGS.arm32 ?= -machine:arm
248 TOOL_VCC142_ARLIBSUFF ?= .lib
250 TOOL_VCC142_LDFLAGS ?= -nologo
251 TOOL_VCC142_LDFLAGS.x86 ?= -machine:x86
252 TOOL_VCC142_LDFLAGS.amd64 ?= -machine:amd64
253 TOOL_VCC142_LDFLAGS.arm32 ?= -machine:arm
254 TOOL_VCC142_LDFLAGS.debug ?= -debug
255 TOOL_VCC142_LDFLAGS.dbgopt ?= -debug
256 TOOL_VCC142_LDFLAGS.profile ?= -debug
257 TOOL_VCC142_LDFLAGS.release ?=
261 ## Compile C source.
262 # @param $(target) Normalized main target name.
263 # @param $(source) Source filename (relative).
264 # @param $(obj) Object file name. This shall be (re)created by the compilation.
265 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
266 # @param $(flags) Flags.
267 # @param $(defs) Definitions. No -D or something.
268 # @param $(incs) Includes. No -I or something.
269 # @param $(dirdep) Directory creation dependency.
270 # @param $(deps) Other dependencies.
272 # @param $(outbase) Output basename (full). Use this for list files and such.
273 # @param $(objsuff) Object suffix.
274 # @note The -d1scalableinclude- option disables include directory caching as the cache goes
275 # stale in kWorker. Besides, kWorker does it's own caching, so it is not necessary.
276 TOOL_VCC142_COMPILE_C_DEPEND =
277 TOOL_VCC142_COMPILE_C_DEPORD =
278 TOOL_VCC142_COMPILE_C_OUTPUT =
279 TOOL_VCC142_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC142_PDB, $(outbase)-obj,pdb) $(call TOOL_VCC142_PDB, $(outbase)-obj,idb)
280 ifdef TOOL_VCC142_KSUBMIT
281 TOOL_VCC142_COMPILE_C_DONT_PURGE_OUTPUT := 1 # speed
282 define TOOL_VCC142_COMPILE_C_CMDS
283 $(QUIET)$(TOOL_VCC142_KSUBMIT) -P $(DEP_OBJ_INT) -f -s -q -o $(dep) -t $(obj) $(obj)\
284 -- $(TOOL_VCC142_CC) -c -d1scalableinclude-\
285 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
286 -Fd$(outbase)-obj.pdb \
287 -Fo$(obj)\
288 $(subst /,\\,$(abspath $(source)))
289 endef
290 else
291 define TOOL_VCC142_COMPILE_C_CMDS
292 $(QUIET)$(TOOL_VCC142_SETUP_ENV)$(TOOL_VCC142_CC) -c\
293 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
294 -Fd$(outbase)-obj.pdb \
295 -Fo$(obj)\
296 $(subst /,\\,$(abspath $(source)))
297 $(QUIET)$(DEP_OBJ) -f -s -q -o $(dep) -t $(obj) $(obj)
298 endef
299 endif # !TOOL_VCC142_KSUBMIT
302 ## Compile C++ source.
303 # @param $(target) Normalized main target name.
304 # @param $(source) Source filename (relative).
305 # @param $(obj) Object file name. This shall be (re)created by the compilation.
306 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
307 # @param $(flags) Flags.
308 # @param $(defs) Definitions. No -D or something.
309 # @param $(incs) Includes. No -I or something.
310 # @param $(dirdep) Directory creation dependency.
311 # @param $(deps) Other dependencies.
313 # @param $(outbase) Output basename (full). Use this for list files and such.
314 # @param $(objsuff) Object suffix.
315 # @note The -d1scalableinclude- option disables include directory caching as the cache goes
316 # stale in kWorker. Besides, kWorker does it's own caching, so it is not necessary.
317 # ('-d1' means it's passed to c1.dll/c1xx.dll and 'scalableinclude-' is the actual option.)
318 TOOL_VCC142_COMPILE_CXX_DEPEND = $($(target)_1_VCC_PCH_FILE)
319 TOOL_VCC142_COMPILE_CXX_DEPORD =
320 TOOL_VCC142_COMPILE_CXX_OUTPUT =
321 TOOL_VCC142_COMPILE_CXX_OUTPUT_MAYBE = $(if-expr defined($(target)_1_VCC_COMMON_OBJ_PDB)\
322 ,,$(call TOOL_VCC142_PDB, $(outbase)-obj,pdb) $(call TOOL_VCC142_PDB, $(outbase)-obj,idb))
323 ifdef TOOL_VCC142_KSUBMIT
324 TOOL_VCC142_COMPILE_CXX_DONT_PURGE_OUTPUT := 1 # speed
325 define TOOL_VCC142_COMPILE_CXX_CMDS
326 $(QUIET)$(TOOL_VCC142_KSUBMIT) -P $(DEP_OBJ_INT) -f -s -q -o $(dep) -t $(obj) $(obj)\
327 -- $(TOOL_VCC142_CXX) -c -d1scalableinclude-\
328 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
329 $(if-expr defined($(target)_PCH_HDR)\
330 ,-FI$($(target)_PCH_HDR) -Yu$($(target)_PCH_HDR) -Fp$($(target)_1_VCC_PCH_FILE) -FS,)\
331 -Fd$(if-expr defined($(target)_1_VCC_COMMON_OBJ_PDB),$($(target)_1_VCC_COMMON_OBJ_PDB),$(outbase)-obj.pdb) \
332 -Fo$(obj)\
333 $(subst /,\\,$(abspath $(source)))
334 endef
335 else
336 define TOOL_VCC142_COMPILE_CXX_CMDS
337 $(QUIET)$(TOOL_VCC142_SETUP_ENV)$(TOOL_VCC142_CXX) -c\
338 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
339 $(if-expr defined($(target)_PCH_HDR)\
340 ,-FI$($(target)_PCH_HDR) -Yu$($(target)_PCH_HDR) -Fp$($(target)_1_VCC_PCH_FILE) -FS,)\
341 -Fd$(if-expr defined($(target)_1_VCC_COMMON_OBJ_PDB),$($(target)_1_VCC_COMMON_OBJ_PDB),$(outbase)-obj.pdb) \
342 -Fo$(obj)\
343 $(subst /,\\,$(abspath $(source)))
344 $(QUIET)$(DEP_OBJ) -f -s -q -o $(dep) -t $(obj) $(obj)
345 endef
346 endif # !TOOL_VCC142_KSUBMIT
350 # Helper tool for creating the precompiled C++ header.
352 # It only have the C++ compile bits and it's purpose is to skip bits
353 # related _1_VCC_PCH_FILE and add -Yc.
355 TOOL_VCC142-PCH := Helper for creating precompiled header using CXX handling.
356 TOOL_VCC142-PCH_EXTENDS := VCC142
357 TOOL_VCC142-PCH_CXXOBJSUFF := .obj
358 TOOL_VCC142-PCH_CXXINCS = $(TOOL_VCC142_CXXINCS)
359 TOOL_VCC142-PCH_CXXFLAGS = $(TOOL_VCC142_CXXFLAGS) -FS
360 TOOL_VCC142-PCH_CXXFLAGS.debug = $(TOOL_VCC142_CXXFLAGS.debug)
361 TOOL_VCC142-PCH_CXXFLAGS.dbgopt = $(TOOL_VCC142_CXXFLAGS.dbgopt)
362 TOOL_VCC142-PCH_CXXFLAGS.release = $(TOOL_VCC142_CXXFLAGS.release)
363 TOOL_VCC142-PCH_CXXFLAGS.profile = $(TOOL_VCC142_CXXFLAGS.profile)
364 TOOL_VCC142-PCH_COMPILE_CXX_DEPEND = $(NO_SUCH_VARIABLE)
365 TOOL_VCC142-PCH_COMPILE_CXX_DEPORD = $(NO_SUCH_VARIABLE)
366 TOOL_VCC142-PCH_COMPILE_CXX_OUTPUT = $($(target)_1_VCC_PCH_FILE) $($(target)_1_VCC_COMMON_OBJ_PDB)
367 TOOL_VCC142-PCH_COMPILE_CXX_OUTPUT_MAYBE = $(NO_SUCH_VARIABLE)
368 ifdef TOOL_VCC142_KSUBMIT
369 define TOOL_VCC142-PCH_COMPILE_CXX_CMDS
370 $(QUIET)$(RM) -f -- $($(target)_1_VCC_PCH_FILE) $($(target)_1_VCC_COMMON_OBJ_PDB)
371 $(QUIET)$(TOOL_VCC142_KSUBMIT) --no-pch-caching -P $(DEP_OBJ_INT) -f -s -q -e .pch -o $(dep) -t $(obj) $(obj)\
372 -- $(TOOL_VCC142_CXX) -c -Yc -d1scalableinclude-\
373 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
374 -Fp$($(target)_1_VCC_PCH_FILE) \
375 -Fd$($(target)_1_VCC_COMMON_OBJ_PDB) \
376 -Fo$(obj)\
377 -TP \
378 $(subst /,\\,$(abspath $(source)))
379 endef
380 else
381 define TOOL_VCC142-PCH_COMPILE_CXX_CMDS
382 $(QUIET)$(RM) -f -- $($(target)_1_VCC_PCH_FILE) $($(target)_1_VCC_COMMON_OBJ_PDB)
383 $(QUIET)$(TOOL_VCC142_SETUP_ENV)$(TOOL_VCC142_CXX) -c -Yc\
384 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
385 -Fp$($(target)_1_VCC_PCH_FILE) \
386 -Fd$($(target)_1_VCC_COMMON_OBJ_PDB) \
387 -Fo$(obj)\
388 -TP \
389 $(subst /,\\,$(abspath $(source)))
390 $(QUIET)$(DEP_OBJ) -f -s -q -e .pch -o $(dep) -t $(obj) $(obj)
392 endef
393 endif # !TOOL_VCC142_KSUBMIT
396 ## @todo configure the assembler template.
398 ## Compile resource source.
399 # @param $(target) Normalized main target name.
400 # @param $(source) Source filename (relative).
401 # @param $(obj) Object file name. This shall be (re)created by the compilation.
402 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
403 # @param $(flags) Flags.
404 # @param $(defs) Definitions. No -D or something.
405 # @param $(incs) Includes. No -I or something.
406 # @param $(dirdep) Directory creation dependency.
407 # @param $(deps) Other dependencies.
409 # @param $(outbase) Output basename (full). Use this for list files and such.
410 # @param $(objsuff) Object suffix.
411 TOOL_VCC142_COMPILE_RC_DEPEND =
412 TOOL_VCC142_COMPILE_RC_DEPORD =
413 TOOL_VCC142_COMPILE_RC_OUTPUT =
414 define TOOL_VCC142_COMPILE_RC_CMDS
415 $(QUIET)$(TOOL_VCC142_RC) \
416 $(flags) $(qaddprefix sh,/i, $(subst /,\\,$(incs))) $(qaddprefix sh,/d, $(defs))\
417 /fo$(obj)\
418 $(subst /,\\,$(abspath $(source)))
419 endef
422 ## Link library
423 # @param $(target) Normalized main target name.
424 # @param $(out) Library name.
425 # @param $(objs) Object files to put in the library.
426 # @param $(flags) Flags.
427 # @param $(dirdep) Directory creation dependency.
428 # @param $(deps) Other dependencies.
429 # @param $(othersrc) Unhandled sources.
430 # @param $(outbase) Output basename (full). Use this for list files and such.
432 TOOL_VCC142_LINK_LIBRARY_DEPEND = $(othersrc)
433 TOOL_VCC142_LINK_LIBRARY_DEPORD =
434 TOOL_VCC142_LINK_LIBRARY_OUTPUT = $(outbase).rsp
435 TOOL_VCC142_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb
436 define TOOL_VCC142_LINK_LIBRARY_CMDS
437 $(QUIET)$(APPEND) -tn $(outbase).rsp \
438 $(qforeachfile u,arg, $(objs) $(filter-out %.def,$(othersrc)),$(quote-sh "$(subst /,\,$(arg))")) \
439 $(qforeachfile u,arg, $(filter %.def,$(othersrc)),$(quote-sh "/DEF:$(subst /,\,$(arg))"))
440 $(QUIET)$(TOOL_VCC142_KSUBMIT_DD) $(TOOL_VCC142_AR) $(flags) /OUT:$(out) @$(outbase).rsp
441 endef
444 ## Link program
445 # @param $(target) Normalized main target name.
446 # @param $(out) Program name.
447 # @param $(objs) Object files to link together.
448 # @param $(libs) Libraries to search.
449 # @param $(libpath) Library search paths.
450 # @param $(flags) Flags.
451 # @param $(dirdep) Directory creation dependency.
452 # @param $(deps) Other dependencies.
453 # @param $(othersrc) Unhandled sources.
454 # @param $(custom_pre) Custom step invoked before linking.
455 # @param $(custom_post) Custom step invoked after linking.
456 # @param $(outbase) Output basename (full). Use this for list files and such.
458 TOOL_VCC142_LINK_PROGRAM_DEPEND = $(foreachfile lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
459 TOOL_VCC142_LINK_PROGRAM_DEPORD =
460 TOOL_VCC142_LINK_PROGRAM_OUTPUT_MAYBE_PRECIOUS = $(outbase).map $(outbase).rsp
461 TOOL_VCC142_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
462 TOOL_VCC142_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb
463 TOOL_VCC142_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
464 define TOOL_VCC142_LINK_PROGRAM_CMDS
465 $(QUIET)$(APPEND) -tn $(outbase).rsp \
466 $(qforeachfile u,arg, $(objs) $(libs),$(quote-sh "$(subst /,\,$(arg))"))
467 $(QUIET)$(TOOL_VCC142_KSUBMIT_DD) $(TOOL_VCC142_LD) $(flags) \
468 /OUT:$(out) \
469 /MAPINFO:EXPORTS /INCREMENTAL:NO \
470 /MAP:$(outbase).map \
471 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
472 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
473 $(qaddprefix sh,/LIBPATH:,$(libpath)) \
474 @$(outbase).rsp
475 ifndef TOOL_VCC142_NO_AUTO_MANIFEST
476 $(QUIET)$(TEST) -f $(out).manifest -- \
477 $(TOOL_VCC142_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out))
478 endif
479 endef
482 ## Link DLL.
483 # @param $(target) Normalized main target name.
484 # @param $(out) DLL name.
485 # @param $(objs) Object files to link together.
486 # @param $(libs) Libraries to search.
487 # @param $(libpath) Library search paths.
488 # @param $(flags) Flags.
489 # @param $(dirdep) Directory creation dependency.
490 # @param $(deps) Other dependencies.
491 # @param $(othersrc) Unhandled sources.
492 # @param $(custom_pre) Custom step invoked before linking.
493 # @param $(custom_post) Custom step invoked after linking.
495 # @param $(outbase) Output basename (full). Use this for list files and such.
496 TOOL_VCC142_LINK_DLL_DEPEND = $(foreachfile lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
497 TOOL_VCC142_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB))
498 TOOL_VCC142_LINK_DLL_OUTPUT = $(outbase).lib $(outbase).exp
499 TOOL_VCC142_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp
500 TOOL_VCC142_LINK_DLL_OUTPUT_MAYBE_PRECIOUS = $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(outbase).map $(outbase).rsp
501 TOOL_VCC142_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb
502 TOOL_VCC142_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
503 define TOOL_VCC142_LINK_DLL_CMDS
504 $(QUIET)$(APPEND) -tn $(outbase).rsp \
505 $(qforeachfile u,arg, $(objs) $(libs),$(quote-sh "$(subst /,\,$(arg))"))
506 $(QUIET)$(TOOL_VCC142_KSUBMIT_DD) $(TOOL_VCC142_LD) $(flags) \
507 /OUT:$(out) \
508 /IMPLIB:$(outbase).lib \
509 /MAPINFO:EXPORTS /INCREMENTAL:NO \
510 /MAP:$(outbase).map \
511 /DLL \
512 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
513 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
514 $(qaddprefix sh,/LIBPATH:,$(libpath)) \
515 @$(outbase).rsp
516 ifndef TOOL_VCC142_NO_AUTO_MANIFEST
517 $(QUIET)$(TEST) -f $(out).manifest -- \
518 $(TOOL_VCC142_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
519 endif
520 $(QUIET)$(TEST) -f $(outbase).lib -- $(KLIBTWEAKER_EXT) --clear-timestamps $(outbase).lib
521 $(QUIET)$(CP) --changed -v --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/
522 $(eval _DIRS += $(PATH_STAGE_LIB))
523 endef
526 ## Link system module (windows aka driver, linux aka kernel module)
527 # @param $(target) Normalized main target name.
528 # @param $(out) System module name.
529 # @param $(objs) Object files to link together.
530 # @param $(libs) Libraries to search.
531 # @param $(libpath) Library search paths.
532 # @param $(flags) Flags.
533 # @param $(dirdep) Directory creation dependency.
534 # @param $(deps) Other dependencies.
535 # @param $(othersrc) Unhandled sources.
536 # @param $(custom_pre) Custom step invoked before linking.
537 # @param $(custom_post) Custom step invoked after linking.
539 # @param $(outbase) Output basename (full). Use this for list files and such.
540 TOOL_VCC142_LINK_SYSMOD_DEPEND = $(foreachfile lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
541 TOOL_VCC142_LINK_SYSMOD_DEPORD =
542 TOOL_VCC142_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
543 TOOL_VCC142_LINK_SYSMOD_OUTPUT_MAYBE_PRECIOUS = $(outbase).map $(outbase).rsp
544 TOOL_VCC142_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb
545 TOOL_VCC142_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
546 define TOOL_VCC142_LINK_SYSMOD_CMDS
547 $(QUIET)$(APPEND) -tn $(outbase).rsp \
548 $(qforeachfile u,arg, $(objs) $(libs),$(quote-sh "$(subst /,\,$(arg))"))
549 $(QUIET)$(TOOL_VCC142_KSUBMIT_DD) $(TOOL_VCC142_LD) $(flags) \
550 /OUT:$(out) \
551 /MAPINFO:EXPORTS /INCREMENTAL:NO \
552 /MAP:$(outbase).map \
553 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
554 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
555 $(qaddprefix sh,/LIBPATH:,$(libpath)) \
556 @$(outbase).rsp
557 ifndef TOOL_VCC142_NO_AUTO_MANIFEST
558 $(QUIET)$(TEST) -f $(out).manifest -- \
559 $(TOOL_VCC142_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
560 endif
561 endef