source: trunk/kBuild/tools/VCC143.kmk@ 3668

Last change on this file since 3668 was 3623, checked in by bird, 9 months ago

tools/VCC143.kmk: Seems vcruntime140_threads.dll isn't always installed, so detect it.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.2 KB
Line 
1# $Id: VCC143.kmk 3623 2024-10-22 08:22:02Z bird $
2## @file
3# kBuild Tool Config - Visual C++ 14.3 (aka Visual 2022 and MSC v19.30+), default target.
4#
5
6#
7# Copyright (c) 2004-2024 knut st. osmundsen <bird-kBuild-spam-xx@anduin.net>
8#
9# This file is part of kBuild.
10#
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.
15#
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.
20#
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
24#
25#
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.
31#
32#
33
34TOOL_VCC143 := Visual C++ 14.3 (aka Visual 2022 and MSC v19.30+), targeting $(KBUILD_TARGET).
35
36ifndef INCLUDED_WIN_COMMON_KMK
37 include $(KBUILD_PATH)/win-common.kmk
38endif
39
40#
41# Tool Specific Properties
42#
43ifndef PATH_TOOL_VCC143
44 PATH_TOOL_VCC143 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win/vcc/v14.[34]*/Tools/MSVC/14.[34]?.*)))
45 ifeq ($(PATH_TOOL_VCC143),)
46 PATH_TOOL_VCC143 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win.amd64/vcc/v14.[34]*/Tools/MSVC/14.[34]?.*)))
47 ifeq ($(PATH_TOOL_VCC143),)
48 PATH_TOOL_VCC143 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win.x86/vcc/v14.[34]*/Tools/MSVC/14.[34]?.*)))
49 ifeq ($(PATH_TOOL_VCC143),)
50 PATH_TOOL_VCC143 := $(firstfile $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win.arm64/vcc/v14.[34]*/Tools/MSVC/14.[34]?.*)))
51 ifeq ($(PATH_TOOL_VCC143),)
52 PATH_TOOL_VCC143 := $(PATH_TOOL_VCC143X86)
53 ifeq ($(PATH_TOOL_VCC143),)
54 PATH_TOOL_VCC143 := $(PATH_TOOL_VCC143AMD64)
55 ifeq ($(PATH_TOOL_VCC143),)
56 PATH_TOOL_VCC143 := $(firstfile $(foreach ver,2022,$(foreachfile progfilesdir,$(WINCMN_PROGRAM_FILES_LIST)\
57 , $(rversortfiles $(qwildcard ,$(progfilesdir)/Microsoft\ Visual\ Studio/$(ver)/BuildTools/VC/Tools/MSVC/14.[34]?.*)))))
58 ifeq ($(PATH_TOOL_VCC143),)
59 $(warning kBuild: PATH_TOOL_VCC143 cannot be determined!)
60 PATH_TOOL_VCC143 := $(KBUILD_DEVTOOLS)/win/vcc/v14.3/Tools/MSVC/14.30.00000
61 endif
62 endif
63 endif
64 endif
65 endif
66 endif
67 endif
68else
69 # Resolve any fancy stuff once and for all.
70 PATH_TOOL_VCC143 := $(PATH_TOOL_VCC143)
71endif
72
73ifndef PATH_TOOL_VCC143_BASE_BIN
74PATH_TOOL_VCC143_BASE_BIN := $(PATH_TOOL_VCC143)/bin
75endif
76ifndef PATH_TOOL_VCC143_HOST_BIN
77PATH_TOOL_VCC143_HOST_BIN := $(PATH_TOOL_VCC143_BASE_BIN)/Host$(WINCMN_MAP_ARCH.$(KBUILD_HOST_ARCH))
78endif
79ifndef PATH_TOOL_VCC143_BIN
80PATH_TOOL_VCC143_BIN := $(PATH_TOOL_VCC143_HOST_BIN)/$(WINCMN_MAP_ARCH.$(KBUILD_TARGET_ARCH))
81endif
82PATH_TOOL_VCC143_BIN_QSH := $(requote sh,$(PATH_TOOL_VCC143_BIN))
83
84# 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.
85ifndef PATH_TOOL_VCC143_HOST_DLL_BIN
86PATH_TOOL_VCC143_HOST_DLL_BIN := $(PATH_TOOL_VCC143_HOST_BIN)/$(WINCMN_MAP_ARCH.$(KBUILD_HOST_ARCH))
87endif
88ifndef PATH_TOOL_VCC143_DLL_BIN
89 ifneq ($(PATH_TOOL_VCC143_HOST_DLL_BIN),$(PATH_TOOL_VCC143_BIN))
90PATH_TOOL_VCC143_DLL_BIN := $(PATH_TOOL_VCC143_HOST_DLL_BIN)
91 endif
92endif
93
94PATH_TOOL_VCC143_LIB.amd64 ?= $(PATH_TOOL_VCC143)/lib/x64
95PATH_TOOL_VCC143_LIB.arm32 ?= $(PATH_TOOL_VCC143)/lib/arm
96PATH_TOOL_VCC143_LIB.arm64 ?= $(PATH_TOOL_VCC143)/lib/arm64
97PATH_TOOL_VCC143_LIB.x86 ?= $(PATH_TOOL_VCC143)/lib/x86
98
99PATH_TOOL_VCC143_ONECORE_LIB.amd64 ?= $(PATH_TOOL_VCC143)/lib/onecore/x64
100PATH_TOOL_VCC143_ONECORE_LIB.arm32 ?= $(PATH_TOOL_VCC143)/lib/onecore/arm
101PATH_TOOL_VCC143_ONECORE_LIB.arm64 ?= $(PATH_TOOL_VCC143)/lib/onecore/arm64
102PATH_TOOL_VCC143_ONECORE_LIB.x86 ?= $(PATH_TOOL_VCC143)/lib/onecore/x86
103
104PATH_TOOL_VCC143_INC ?= $(PATH_TOOL_VCC143)/include
105
106PATH_TOOL_VCC143_ATLMFC ?= $(PATH_TOOL_VCC143)/atlmfc
107PATH_TOOL_VCC143_ATLMFC_INC ?= $(PATH_TOOL_VCC143_ATLMFC)/include
108PATH_TOOL_VCC143_ATLMFC_LIB.x86 ?= $(PATH_TOOL_VCC143_ATLMFC)/lib/x86
109PATH_TOOL_VCC143_ATLMFC_LIB.amd64 ?= $(PATH_TOOL_VCC143_ATLMFC)/lib/x64
110
111TOOL_VCC143_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/cl.exe
112TOOL_VCC143_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/cl.exe
113ifeq ($(KBUILD_TARGET_ARCH),x86)
114TOOL_VCC143_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/ml.exe
115else
116TOOL_VCC143_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/ml64.exe
117endif
118#TOOL_VCC143_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/lib.exe - just an exec wrapper for the below
119TOOL_VCC143_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/link.exe /LIB
120TOOL_VCC143_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/link.exe
121TOOL_VCC143_DUMPBIN ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/dumpbin.exe
122TOOL_VCC143_EDITBIN ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC143_BIN_QSH)/editbin.exe
123
124TOOL_VCC143_RC ?= $(EXEC_X86_WIN32) $(call TOOL_VCC143_FN_FIND_SDK_TOOL,rc.exe,[Rr][Cc].[Ee][Xx][Ee],TOOL_VCC143_RC_CACHED)
125TOOL_VCC143_MT ?= $(TOOL_VCC143_MT_RETRY) $(EXEC_X86_WIN32) $(call TOOL_VCC143_FN_FIND_SDK_TOOL,mt.exe,[Mm][Tt].[Ee][Xx][Ee],TOOL_VCC143_MT_CACHED)
126TOOL_VCC143_MT_RETRY ?= $(WINCMN_MT_RETRY)
127
128ifdef TOOL_VCC143_USE_KSUBMIT
129 ifeq ($(KBUILD_HOST),win)
130 ifeq ($(findstring /HostX86/,$(PATH_TOOL_VCC143AMD64_BIN)),/HostX86/)
131 TOOL_VCC143_KSUBMIT ?= kmk_builtin_kSubmit --32-bit
132 else
133 TOOL_VCC143_KSUBMIT ?= kmk_builtin_kSubmit --64-bit
134 endif
135 ifdef PATH_TOOL_VCC143_DLL_BIN
136 TOOL_VCC143_KSUBMIT := $(TOOL_VCC143_KSUBMIT) --prepend "PATH=$(requote shell-in-dq,$(PATH_TOOL_VCC143_DLL_BIN));"
137 endif
138 TOOL_VCC143_KSUBMIT_DD := $(TOOL_VCC143_KSUBMIT) --
139 endif
140endif
141ifdef PATH_TOOL_VCC143_DLL_BIN
142 TOOL_VCC143_SETUP_ENV := $(REDIRECT) --prepend "PATH=$(requote shell-in-dq,$(PATH_TOOL_VCC143_DLL_BIN));" --$(SP)
143 ifndef TOOL_VCC143_KSUBMIT_DD
144 TOOL_VCC143_KSUBMIT_DD := $(TOOL_VCC143_SETUP_ENV)
145 endif
146endif
147
148
149## Helper for finding rc.exe and mt.exe in the SDK.
150TOOL_VCC143_FN_FIND_SDK_TOOL_SUB = $(eval $3 := $(qfirstfile sh,\
151 $(if-expr defined(PATH_SDK_WINSDK10_BIN) , $(qwildcard ,$(PATH_SDK_WINSDK10_BIN)/$2)) \
152 $(if-expr defined(PATH_SDK_WINPSDK71_BIN), $(qwildcard ,$(PATH_SDK_WINPSDK71_BIN)/$2)) \
153 $(if-expr defined(PATH_SDK_WINPSDK_BIN) , $(qwildcard ,$(PATH_SDK_WINPSDK_BIN)/$2)) \
154 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS)/win/sdk/*/[Bb][Ii][Nn]/*/$(WINCMN_MAP_ARCH.$(KBUILD_HOST_ARCH))/$2)) \
155 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/win/sdk/*/[Bb][Ii][Nn]/*/$(WINCMN_MAP_ARCH.$(KBUILD_HOST_ARCH))/$2)) \
156 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/win/sdk/*/[Bb][Ii][Nn]/*/$(WINCMN_MAP_ARCH.$(KBUILD_HOST_ARCH))/$2)) \
157 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/sdk/*/[Bb][Ii][Nn]/$2)) \
158 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/sdk/*/[Bb][Ii][Nn]/$2)) \
159 $1))
160TOOL_VCC143_FN_FIND_SDK_TOOL = $(if-expr !defined($3),$(TOOL_VCC143_FN_FIND_SDK_TOOL_SUB),)$($3)
161
162## Constructs the correct .pdb name (the name is lowercased).
163# @param $(1) Base name, no extention.
164# @param $(2) The extension.
165TOOL_VCC143_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2)
166
167#
168# Try find the redist directory. A little complicated as the build number
169# doesn't necessarily match that of the compiler.
170#
171ifeq ($(tolower $(substr $(qdir u,$(PATH_TOOL_VCC143)), -12)),/tools/msvc/)
172PATH_TOOL_VCC143_REDIST ?= $(firstfile $(qwildcard ,$(substr $(qdir ,$(PATH_TOOL_VCC143)), 1, -12)/Redist/MSVC/14.[34]*))
173else
174PATH_TOOL_VCC143_REDIST ?= $(qabspath ,$(firstfile $(qwildcard ,\
175 $(PATH_TOOL_VCC143)/Redist \
176 $(PATH_TOOL_VCC143)/../Redist \
177 $(PATH_TOOL_VCC143)/../../Redist \
178 $(PATH_TOOL_VCC143)/../../../Redist \
179 $(PATH_TOOL_VCC143)/../../../../Redist)))
180endif
181PATH_TOOL_VCC143_REDIST_DEBUG ?= $(PATH_TOOL_VCC143_REDIST)/debug_nonredist
182
183## Updates may add more msvcp140_[0-9].dll images as the product matures.
184# This helper locates them (can differ between archs).
185# @param 1 Redist subdirectory.
186# @param 2 The DLL basename (no suffix).
187# @param 3 The VCC architecture name (for constructing the path).
188FN_TOOL_VCC143_FIND_DLLS = $(2).dll \
189 $(versortfiles $(qnotdir ,$(qwildcard ,$(PATH_TOOL_VCC143_REDIST)/$(3)/$(1)/$(2)_?.dll)))
190
191## This is for finding vcruntime140_thread.dll and other one-offs.
192# @param 1 Redist subdirectory.
193# @param 2 The full DLL name.
194# @param 3 The VCC architecture name (for constructing the path).
195FN_TOOL_VCC143_FIND_1_DLL = \
196 $(versortfiles $(qnotdir ,$(qwildcard ,$(PATH_TOOL_VCC143_REDIST)/$(3)/$(1)/$(2))))
197
198TOOL_VCC143_REDIST_CRT_SUBDIR := Microsoft.VC143.CRT
199TOOL_VCC143_REDIST_DEBUG_CRT_SUBDIR := Microsoft.VC143.DebugCRT
200
201TOOL_VCC143_REDIST_CRT_DLLS.x86 = \
202 $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140,x86) \
203 $(call FN_TOOL_VCC143_FIND_1_DLL,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140_threads.dll,x86)
204TOOL_VCC143_REDIST_CRT_DLLS.amd64 = \
205 $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140,x64) \
206 $(call FN_TOOL_VCC143_FIND_1_DLL,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140_threads.dll,x64)
207TOOL_VCC143_REDIST_CRT_DLLS.arm32 = \
208 $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140,arm) \
209 $(call FN_TOOL_VCC143_FIND_1_DLL,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140_threads.dll,arm)
210TOOL_VCC143_REDIST_CRT_DLLS.arm64 = \
211 $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140,arm64) \
212 $(call FN_TOOL_VCC143_FIND_1_DLL,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vcruntime140_threads.dll,arm64)
213TOOL_VCC143_REDIST_CRT_DLLS = $(TOOL_VCC143_REDIST_CRT_DLLS.$(KBUILD_TARGET_ARCH))
214
215TOOL_VCC143_REDIST_CONCRT_DLLS.x86 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),concrt140,x86)
216TOOL_VCC143_REDIST_CONCRT_DLLS.amd64 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),concrt140,x64)
217TOOL_VCC143_REDIST_CONCRT_DLLS.arm32 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),concrt140,arm)
218TOOL_VCC143_REDIST_CONCRT_DLLS.arm64 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),concrt140,arm64)
219TOOL_VCC143_REDIST_CONCRT_DLLS = $(TOOL_VCC143_REDIST_CONCRT_DLLS.$(KBUILD_TARGET_ARCH))
220
221TOOL_VCC143_REDIST_CPP_DLLS.x86 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),msvcp140,x86)
222TOOL_VCC143_REDIST_CPP_DLLS.amd64 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),msvcp140,x64)
223TOOL_VCC143_REDIST_CPP_DLLS.arm32 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),msvcp140,arm)
224TOOL_VCC143_REDIST_CPP_DLLS.arm64 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),msvcp140,arm64)
225TOOL_VCC143_REDIST_CPP_DLLS = $(TOOL_VCC143_REDIST_CPP_DLLS.$(KBUILD_TARGET_ARCH))
226
227TOOL_VCC143_REDIST_WINRT_DLLS.x86 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vccorlib140,x86)
228TOOL_VCC143_REDIST_WINRT_DLLS.amd64 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vccorlib140,x64)
229TOOL_VCC143_REDIST_WINRT_DLLS.arm32 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vccorlib140,arm)
230TOOL_VCC143_REDIST_WINRT_DLLS.arm64 = $(call FN_TOOL_VCC143_FIND_DLLS,$(TOOL_VCC143_REDIST_CRT_SUBDIR),vccorlib140,arm64)
231TOOL_VCC143_REDIST_WINRT_DLLS = $(TOOL_VCC143_REDIST_WINRT_DLLS.$(KBUILD_TARGET_ARCH))
232
233TOOL_VCC143_REDIST_CXXAMP_SUBDIR := Microsoft.VC143.CXXAMP
234TOOL_VCC143_REDIST_MFC_SUBDIR := Microsoft.VC143.MFC
235TOOL_VCC143_REDIST_MFCLOC_SUBDIR := Microsoft.VC143.MFCLOC
236TOOL_VCC143_REDIST_OPENMP_SUBDIR := Microsoft.VC143.OpenMP
237
238
239#
240# Properties used by kBuild
241#
242TOOL_VCC143_COBJSUFF ?= .obj
243TOOL_VCC143_CFLAGS ?= -TC -nologo -Zi -ZH:SHA_256
244TOOL_VCC143_CFLAGS.debug ?=
245TOOL_VCC143_CFLAGS.dbgopt ?= -O2
246TOOL_VCC143_CFLAGS.release ?= -O2
247TOOL_VCC143_CFLAGS.profile ?= -O2
248TOOL_VCC143_CINCS ?= $(PATH_TOOL_VCC143_INC)
249TOOL_VCC143_CDEFS ?=
250
251TOOL_VCC143_CXXOBJSUFF ?= .obj
252TOOL_VCC143_CXXFLAGS ?= -TP -nologo -Zi -ZH:SHA_256
253TOOL_VCC143_CXXFLAGS.debug ?=
254TOOL_VCC143_CXXFLAGS.dbgopt ?= -O2
255TOOL_VCC143_CXXFLAGS.release ?= -O2
256TOOL_VCC143_CXXFLAGS.profile ?= -O2
257TOOL_VCC143_CXXINCS ?= $(PATH_TOOL_VCC143_INC) $(PATH_TOOL_VCC143_ATLMFC_INC)
258TOOL_VCC143_CXXDEFS ?=
259
260TOOL_VCC143_ASOBJSUFF ?= .obj
261
262TOOL_VCC143_RCOBJSUFF ?= .res
263TOOL_VCC143_RCINCS ?= $(PATH_TOOL_VCC143_INC) $(PATH_TOOL_VCC143_ATLMFC_INC)
264
265TOOL_VCC143_ARFLAGS ?= -nologo
266TOOL_VCC143_ARFLAGS.x86 ?= -machine:x86
267TOOL_VCC143_ARFLAGS.amd64 ?= -machine:amd64
268TOOL_VCC143_ARFLAGS.arm32 ?= -machine:arm
269TOOL_VCC143_ARLIBSUFF ?= .lib
270
271TOOL_VCC143_LDFLAGS ?= -nologo
272TOOL_VCC143_LDFLAGS.x86 ?= -machine:x86
273TOOL_VCC143_LDFLAGS.amd64 ?= -machine:amd64
274TOOL_VCC143_LDFLAGS.arm32 ?= -machine:arm
275TOOL_VCC143_LDFLAGS.debug ?= -debug
276TOOL_VCC143_LDFLAGS.dbgopt ?= -debug
277TOOL_VCC143_LDFLAGS.profile ?= -debug
278TOOL_VCC143_LDFLAGS.release ?=
279
280
281
282## Compile C source.
283# @param $(target) Normalized main target name.
284# @param $(source) Source filename (relative).
285# @param $(obj) Object file name. This shall be (re)created by the compilation.
286# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
287# @param $(flags) Flags.
288# @param $(defs) Definitions. No -D or something.
289# @param $(incs) Includes. No -I or something.
290# @param $(dirdep) Directory creation dependency.
291# @param $(deps) Other dependencies.
292#
293# @param $(outbase) Output basename (full). Use this for list files and such.
294# @param $(objsuff) Object suffix.
295# @note The -d1scalableinclude- option disables include directory caching as the cache goes
296# stale in kWorker. Besides, kWorker does it's own caching, so it is not necessary.
297TOOL_VCC143_COMPILE_C_DEPEND =
298TOOL_VCC143_COMPILE_C_DEPORD =
299TOOL_VCC143_COMPILE_C_OUTPUT =
300TOOL_VCC143_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC143_PDB, $(outbase)-obj,pdb) $(call TOOL_VCC143_PDB, $(outbase)-obj,idb)
301ifdef TOOL_VCC143_KSUBMIT
302 TOOL_VCC143_COMPILE_C_DONT_PURGE_OUTPUT := 1 # speed
303 define TOOL_VCC143_COMPILE_C_CMDS
304 $(QUIET)$(TOOL_VCC143_KSUBMIT) -P $(DEP_OBJ_INT) -f -s -q -o $(dep) -t $(obj) $(obj)\
305 -- $(TOOL_VCC143_CC) -c -d1scalableinclude-\
306 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
307 -Fd$(outbase)-obj.pdb \
308 -Fo$(obj)\
309 $(subst /,\\,$(abspath $(source)))
310 endef
311else
312 define TOOL_VCC143_COMPILE_C_CMDS
313 $(QUIET)$(TOOL_VCC143_SETUP_ENV)$(TOOL_VCC143_CC) -c\
314 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
315 -Fd$(outbase)-obj.pdb \
316 -Fo$(obj)\
317 $(subst /,\\,$(abspath $(source)))
318 $(QUIET)$(DEP_OBJ) -f -s -q -o $(dep) -t $(obj) $(obj)
319 endef
320endif # !TOOL_VCC143_KSUBMIT
321
322
323## Compile C++ source.
324# @param $(target) Normalized main target name.
325# @param $(source) Source filename (relative).
326# @param $(obj) Object file name. This shall be (re)created by the compilation.
327# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
328# @param $(flags) Flags.
329# @param $(defs) Definitions. No -D or something.
330# @param $(incs) Includes. No -I or something.
331# @param $(dirdep) Directory creation dependency.
332# @param $(deps) Other dependencies.
333#
334# @param $(outbase) Output basename (full). Use this for list files and such.
335# @param $(objsuff) Object suffix.
336# @note The -d1scalableinclude- option disables include directory caching as the cache goes
337# stale in kWorker. Besides, kWorker does it's own caching, so it is not necessary.
338# ('-d1' means it's passed to c1.dll/c1xx.dll and 'scalableinclude-' is the actual option.)
339TOOL_VCC143_COMPILE_CXX_DEPEND = $($(target)_1_VCC_PCH_FILE)
340TOOL_VCC143_COMPILE_CXX_DEPORD =
341TOOL_VCC143_COMPILE_CXX_OUTPUT =
342TOOL_VCC143_COMPILE_CXX_OUTPUT_MAYBE = $(if-expr defined($(target)_1_VCC_COMMON_OBJ_PDB)\
343 ,,$(call TOOL_VCC143_PDB, $(outbase)-obj,pdb) $(call TOOL_VCC143_PDB, $(outbase)-obj,idb))
344ifdef TOOL_VCC143_KSUBMIT
345 TOOL_VCC143_COMPILE_CXX_DONT_PURGE_OUTPUT := 1 # speed
346 define TOOL_VCC143_COMPILE_CXX_CMDS
347 $(QUIET)$(TOOL_VCC143_KSUBMIT) -P $(DEP_OBJ_INT) -f -s -q -o $(dep) -t $(obj) $(obj)\
348 -- $(TOOL_VCC143_CXX) -c -d1scalableinclude-\
349 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
350 $(if-expr defined($(target)_PCH_HDR)\
351 ,-FI$($(target)_PCH_HDR) -Yu$($(target)_PCH_HDR) -Fp$($(target)_1_VCC_PCH_FILE) -FS,)\
352 -Fd$(if-expr defined($(target)_1_VCC_COMMON_OBJ_PDB),$($(target)_1_VCC_COMMON_OBJ_PDB),$(outbase)-obj.pdb) \
353 -Fo$(obj)\
354 $(subst /,\\,$(abspath $(source)))
355 endef
356else
357 define TOOL_VCC143_COMPILE_CXX_CMDS
358 $(QUIET)$(TOOL_VCC143_SETUP_ENV)$(TOOL_VCC143_CXX) -c\
359 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
360 $(if-expr defined($(target)_PCH_HDR)\
361 ,-FI$($(target)_PCH_HDR) -Yu$($(target)_PCH_HDR) -Fp$($(target)_1_VCC_PCH_FILE) -FS,)\
362 -Fd$(if-expr defined($(target)_1_VCC_COMMON_OBJ_PDB),$($(target)_1_VCC_COMMON_OBJ_PDB),$(outbase)-obj.pdb) \
363 -Fo$(obj)\
364 $(subst /,\\,$(abspath $(source)))
365 $(QUIET)$(DEP_OBJ) -f -s -q -o $(dep) -t $(obj) $(obj)
366 endef
367endif # !TOOL_VCC143_KSUBMIT
368
369
370#
371# Helper tool for creating the precompiled C++ header.
372#
373# It only have the C++ compile bits and it's purpose is to skip bits
374# related _1_VCC_PCH_FILE and add -Yc.
375#
376TOOL_VCC143-PCH := Helper for creating precompiled header using CXX handling.
377TOOL_VCC143-PCH_EXTENDS := VCC143
378TOOL_VCC143-PCH_CXXOBJSUFF := .obj
379TOOL_VCC143-PCH_CXXINCS = $(TOOL_VCC143_CXXINCS)
380TOOL_VCC143-PCH_CXXFLAGS = $(TOOL_VCC143_CXXFLAGS) -FS
381TOOL_VCC143-PCH_CXXFLAGS.debug = $(TOOL_VCC143_CXXFLAGS.debug)
382TOOL_VCC143-PCH_CXXFLAGS.dbgopt = $(TOOL_VCC143_CXXFLAGS.dbgopt)
383TOOL_VCC143-PCH_CXXFLAGS.release = $(TOOL_VCC143_CXXFLAGS.release)
384TOOL_VCC143-PCH_CXXFLAGS.profile = $(TOOL_VCC143_CXXFLAGS.profile)
385TOOL_VCC143-PCH_COMPILE_CXX_DEPEND = $(NO_SUCH_VARIABLE)
386TOOL_VCC143-PCH_COMPILE_CXX_DEPORD = $(NO_SUCH_VARIABLE)
387TOOL_VCC143-PCH_COMPILE_CXX_OUTPUT = $($(target)_1_VCC_PCH_FILE) $($(target)_1_VCC_COMMON_OBJ_PDB)
388TOOL_VCC143-PCH_COMPILE_CXX_OUTPUT_MAYBE = $(NO_SUCH_VARIABLE)
389ifdef TOOL_VCC143_KSUBMIT
390 define TOOL_VCC143-PCH_COMPILE_CXX_CMDS
391 $(QUIET)$(RM) -f -- $($(target)_1_VCC_PCH_FILE) $($(target)_1_VCC_COMMON_OBJ_PDB)
392 $(QUIET)$(TOOL_VCC143_KSUBMIT) --no-pch-caching -P $(DEP_OBJ_INT) -f -s -q -e .pch -o $(dep) -t $(obj) $(obj)\
393 -- $(TOOL_VCC143_CXX) -c -Yc -d1scalableinclude-\
394 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
395 -Fp$($(target)_1_VCC_PCH_FILE) \
396 -Fd$($(target)_1_VCC_COMMON_OBJ_PDB) \
397 -Fo$(obj)\
398 -TP \
399 $(subst /,\\,$(abspath $(source)))
400 endef
401else
402 define TOOL_VCC143-PCH_COMPILE_CXX_CMDS
403 $(QUIET)$(RM) -f -- $($(target)_1_VCC_PCH_FILE) $($(target)_1_VCC_COMMON_OBJ_PDB)
404 $(QUIET)$(TOOL_VCC143_SETUP_ENV)$(TOOL_VCC143_CXX) -c -Yc\
405 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
406 -Fp$($(target)_1_VCC_PCH_FILE) \
407 -Fd$($(target)_1_VCC_COMMON_OBJ_PDB) \
408 -Fo$(obj)\
409 -TP \
410 $(subst /,\\,$(abspath $(source)))
411 $(QUIET)$(DEP_OBJ) -f -s -q -e .pch -o $(dep) -t $(obj) $(obj)
412
413 endef
414endif # !TOOL_VCC143_KSUBMIT
415
416
417## @todo configure the assembler template.
418
419## Compile resource source.
420# @param $(target) Normalized main target name.
421# @param $(source) Source filename (relative).
422# @param $(obj) Object file name. This shall be (re)created by the compilation.
423# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
424# @param $(flags) Flags.
425# @param $(defs) Definitions. No -D or something.
426# @param $(incs) Includes. No -I or something.
427# @param $(dirdep) Directory creation dependency.
428# @param $(deps) Other dependencies.
429#
430# @param $(outbase) Output basename (full). Use this for list files and such.
431# @param $(objsuff) Object suffix.
432TOOL_VCC143_COMPILE_RC_DEPEND =
433TOOL_VCC143_COMPILE_RC_DEPORD =
434TOOL_VCC143_COMPILE_RC_OUTPUT =
435define TOOL_VCC143_COMPILE_RC_CMDS
436 $(QUIET)$(TOOL_VCC143_RC) \
437 $(flags) $(qaddprefix sh,/i, $(subst /,\\,$(incs))) $(qaddprefix sh,/d, $(defs))\
438 /fo$(obj)\
439 $(subst /,\\,$(abspath $(source)))
440endef
441
442
443## Link library
444# @param $(target) Normalized main target name.
445# @param $(out) Library name.
446# @param $(objs) Object files to put in the library.
447# @param $(flags) Flags.
448# @param $(dirdep) Directory creation dependency.
449# @param $(deps) Other dependencies.
450# @param $(othersrc) Unhandled sources.
451# @param $(outbase) Output basename (full). Use this for list files and such.
452#
453TOOL_VCC143_LINK_LIBRARY_DEPEND = $(othersrc)
454TOOL_VCC143_LINK_LIBRARY_DEPORD =
455TOOL_VCC143_LINK_LIBRARY_OUTPUT = $(outbase).rsp
456TOOL_VCC143_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb
457define TOOL_VCC143_LINK_LIBRARY_CMDS
458 $(QUIET)$(APPEND) -tn $(outbase).rsp \
459 $(qforeachfile u,arg, $(objs) $(filter-out %.def,$(othersrc)),$(quote-sh "$(subst /,\,$(arg))")) \
460 $(qforeachfile u,arg, $(filter %.def,$(othersrc)),$(quote-sh "/DEF:$(subst /,\,$(arg))"))
461 $(QUIET)$(TOOL_VCC143_KSUBMIT_DD) $(TOOL_VCC143_AR) $(flags) /OUT:$(out) @$(outbase).rsp
462endef
463
464
465## Link program
466# @param $(target) Normalized main target name.
467# @param $(out) Program name.
468# @param $(objs) Object files to link together.
469# @param $(libs) Libraries to search.
470# @param $(libpath) Library search paths.
471# @param $(flags) Flags.
472# @param $(dirdep) Directory creation dependency.
473# @param $(deps) Other dependencies.
474# @param $(othersrc) Unhandled sources.
475# @param $(custom_pre) Custom step invoked before linking.
476# @param $(custom_post) Custom step invoked after linking.
477# @param $(outbase) Output basename (full). Use this for list files and such.
478#
479TOOL_VCC143_LINK_PROGRAM_DEPEND = $(foreachfile lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
480TOOL_VCC143_LINK_PROGRAM_DEPORD =
481TOOL_VCC143_LINK_PROGRAM_OUTPUT_MAYBE_PRECIOUS = $(outbase).map $(outbase).rsp
482TOOL_VCC143_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
483TOOL_VCC143_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb
484TOOL_VCC143_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
485define TOOL_VCC143_LINK_PROGRAM_CMDS
486 $(QUIET)$(APPEND) -tn $(outbase).rsp \
487 $(qforeachfile u,arg, $(objs) $(libs),$(quote-sh "$(subst /,\,$(arg))"))
488 $(QUIET)$(TOOL_VCC143_KSUBMIT_DD) $(TOOL_VCC143_LD) $(flags) \
489 /OUT:$(out) \
490 /MAPINFO:EXPORTS /INCREMENTAL:NO \
491 /MAP:$(outbase).map \
492 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
493 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
494 $(qaddprefix sh,/LIBPATH:,$(libpath)) \
495 @$(outbase).rsp
496ifndef TOOL_VCC143_NO_AUTO_MANIFEST
497 $(QUIET)$(TEST) -f $(out).manifest -- \
498 $(TOOL_VCC143_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out))
499endif
500endef
501
502
503## Link DLL.
504# @param $(target) Normalized main target name.
505# @param $(out) DLL name.
506# @param $(objs) Object files to link together.
507# @param $(libs) Libraries to search.
508# @param $(libpath) Library search paths.
509# @param $(flags) Flags.
510# @param $(dirdep) Directory creation dependency.
511# @param $(deps) Other dependencies.
512# @param $(othersrc) Unhandled sources.
513# @param $(custom_pre) Custom step invoked before linking.
514# @param $(custom_post) Custom step invoked after linking.
515#
516# @param $(outbase) Output basename (full). Use this for list files and such.
517TOOL_VCC143_LINK_DLL_DEPEND = $(foreachfile lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
518TOOL_VCC143_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB))
519TOOL_VCC143_LINK_DLL_OUTPUT = $(outbase).lib $(outbase).exp
520TOOL_VCC143_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp
521TOOL_VCC143_LINK_DLL_OUTPUT_MAYBE_PRECIOUS = $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(outbase).map $(outbase).rsp
522TOOL_VCC143_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb
523TOOL_VCC143_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
524define TOOL_VCC143_LINK_DLL_CMDS
525 $(QUIET)$(APPEND) -tn $(outbase).rsp \
526 $(qforeachfile u,arg, $(objs) $(libs),$(quote-sh "$(subst /,\,$(arg))"))
527 $(QUIET)$(TOOL_VCC143_KSUBMIT_DD) $(TOOL_VCC143_LD) $(flags) \
528 /OUT:$(out) \
529 /IMPLIB:$(outbase).lib \
530 /MAPINFO:EXPORTS /INCREMENTAL:NO \
531 /MAP:$(outbase).map \
532 /DLL \
533 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
534 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
535 $(qaddprefix sh,/LIBPATH:,$(libpath)) \
536 @$(outbase).rsp
537ifndef TOOL_VCC143_NO_AUTO_MANIFEST
538 $(QUIET)$(TEST) -f $(out).manifest -- \
539 $(TOOL_VCC143_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
540endif
541 $(QUIET)$(TEST) -f $(outbase).lib -- $(KLIBTWEAKER_EXT) --clear-timestamps $(outbase).lib
542 $(QUIET)$(CP) --changed -v --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/
543$(eval _DIRS += $(PATH_STAGE_LIB))
544endef
545
546
547## Link system module (windows aka driver, linux aka kernel module)
548# @param $(target) Normalized main target name.
549# @param $(out) System module name.
550# @param $(objs) Object files to link together.
551# @param $(libs) Libraries to search.
552# @param $(libpath) Library search paths.
553# @param $(flags) Flags.
554# @param $(dirdep) Directory creation dependency.
555# @param $(deps) Other dependencies.
556# @param $(othersrc) Unhandled sources.
557# @param $(custom_pre) Custom step invoked before linking.
558# @param $(custom_post) Custom step invoked after linking.
559#
560# @param $(outbase) Output basename (full). Use this for list files and such.
561TOOL_VCC143_LINK_SYSMOD_DEPEND = $(foreachfile lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
562TOOL_VCC143_LINK_SYSMOD_DEPORD =
563TOOL_VCC143_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
564TOOL_VCC143_LINK_SYSMOD_OUTPUT_MAYBE_PRECIOUS = $(outbase).map $(outbase).rsp
565TOOL_VCC143_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb
566TOOL_VCC143_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
567define TOOL_VCC143_LINK_SYSMOD_CMDS
568 $(QUIET)$(APPEND) -tn $(outbase).rsp \
569 $(qforeachfile u,arg, $(objs) $(libs),$(quote-sh "$(subst /,\,$(arg))"))
570 $(QUIET)$(TOOL_VCC143_KSUBMIT_DD) $(TOOL_VCC143_LD) $(flags) \
571 /OUT:$(out) \
572 /MAPINFO:EXPORTS /INCREMENTAL:NO \
573 /MAP:$(outbase).map \
574 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
575 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
576 $(qaddprefix sh,/LIBPATH:,$(libpath)) \
577 @$(outbase).rsp
578ifndef TOOL_VCC143_NO_AUTO_MANIFEST
579 $(QUIET)$(TEST) -f $(out).manifest -- \
580 $(TOOL_VCC143_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
581endif
582endef
583
Note: See TracBrowser for help on using the repository browser.