source: trunk/kBuild/tools/VCC100.kmk@ 2604

Last change on this file since 2604 was 2604, checked in by bird, 13 years ago

VCC110*: fixes and adjustments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.5 KB
Line 
1# $Id: VCC100.kmk 2604 2012-07-13 15:37:18Z bird $
2## @file
3# kBuild Tool Config - Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting $(KBUILD_TARGET).
4#
5
6#
7# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@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_VCC100 := Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting $(KBUILD_TARGET).
35
36# Tool Specific Properties
37ifndef PATH_TOOL_VCC100
38 PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS_TRG)/vcc/v10*)
39 ifeq ($(PATH_TOOL_VCC100),)
40 PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS)/win.x86/vcc/v10*)
41 endif
42 ifeq ($(PATH_TOOL_VCC100),)
43 PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS)/x86.win32/vcc/v10*)
44 endif
45 ifeq ($(PATH_TOOL_VCC100),)
46 PATH_TOOL_VCC100 := $(wildcard $(PATH_DEVTOOLS)/win.amd64/vcc/v10*)
47 endif
48 ifeq ($(PATH_TOOL_VCC100),)
49 PATH_TOOL_VCC100 := $(lastword $(sort $(PATH_TOOL_VCC100)))
50 endif
51 # if not found, we'll enter 'pathless' mode.
52else
53 # Resolve any fancy stuff once and for all.
54 PATH_TOOL_VCC100 := $(PATH_TOOL_VCC100)
55endif
56ifneq ($(PATH_TOOL_VCC100),)
57 ifeq ($(KBUILD_HOST).$(KBUILD_HOST_ARCH),win.amd64)
58 PATH_TOOL_VCC100_BIN.amd64 ?= $(PATH_TOOL_VCC100)/bin/amd64
59 else
60 PATH_TOOL_VCC100_BIN.amd64 ?= $(PATH_TOOL_VCC100)/bin/x86_amd64
61 endif
62 PATH_TOOL_VCC100_BIN.x86 ?= $(PATH_TOOL_VCC100)/bin
63 PATH_TOOL_VCC100_BIN ?= $(PATH_TOOL_VCC100_BIN.$(KBUILD_TARGET_ARCH))
64 PATH_TOOL_VCC100_LIB.amd64 ?= $(PATH_TOOL_VCC100)/lib/amd64
65 PATH_TOOL_VCC100_LIB.x86 ?= $(PATH_TOOL_VCC100)/lib
66 PATH_TOOL_VCC100_LIB ?= $(PATH_TOOL_VCC100_LIB.$(KBUILD_TARGET_ARCH))
67 PATH_TOOL_VCC100_INC ?= $(PATH_TOOL_VCC100)/include
68 PATH_TOOL_VCC100_ATLMFC ?= $(PATH_TOOL_VCC100X86)/atlmfc
69 PATH_TOOL_VCC100_ATLMFC_INC ?= $(PATH_TOOL_VCC100_ATLMFC)/include
70 PATH_TOOL_VCC100_ATLMFC_LIB.amd64 ?= $(PATH_TOOL_VCC100_ATLMFC)/lib
71 PATH_TOOL_VCC100_ATLMFC_LIB.x86 ?= $(PATH_TOOL_VCC100_ATLMFC)/lib/amd64
72 PATH_TOOL_VCC100_ATLMFC_LIB ?= $(PATH_TOOL_VCC100_ATLMFC_LIB.$(KBUILD_TARGET_ARCH))
73 TOOL_VCC100_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/cl.exe
74 TOOL_VCC100_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/cl.exe
75 TOOL_VCC100_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/ml64.exe
76 TOOL_VCC100_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/lib.exe
77 TOOL_VCC100_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100_BIN)/link.exe
78else
79 # Pathless, relies on the environment.
80 TOOL_VCC100_CC ?= $(EXEC_X86_WIN32) cl.exe
81 TOOL_VCC100_CXX ?= $(EXEC_X86_WIN32) cl.exe
82 TOOL_VCC100_AS ?= $(EXEC_X86_WIN32) ml64.exe
83 TOOL_VCC100_AR ?= $(EXEC_X86_WIN32) lib.exe
84 TOOL_VCC100_LD ?= $(EXEC_X86_WIN32) link.exe
85endif
86TOOL_VCC100_RC ?= $(EXEC_X86_WIN32) $(call TOOL_VCC100_FN_FIND_SDK_TOOL,rc.exe,TOOL_VCC100_RC_CACHED)
87#TOOL_VCC100_MT ?= $(EXEC_X86_WIN32) $(call TOOL_VCC100_FN_FIND_SDK_TOOL,mt.exe,TOOL_VCC100_MT_CACHED)
88
89# The following in duplicated in VCC100.kmk and VCC100X86.kmk.
90TOOL_VCC100_FN_FIND_SDK_TOOL_SUB = $(eval $2 := $(firstword \
91 $(if-expr defined(PATH_SDK_WINPSDK71_BIN), $(wildcard $(PATH_SDK_WINPSDK71_BIN)/$1)) \
92 $(if-expr defined(PATH_SDK_WINPSDK_BIN) , $(wildcard $(PATH_SDK_WINPSDK_BIN)/$1)) \
93 $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/sdk/*/[Bb][Ii][Nn]/$1)) \
94 $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/sdk/*/[Bb][Ii][Nn]/$1)) \
95 $1))
96TOOL_VCC100_FN_FIND_SDK_TOOL = $(if-expr !defined($2),$(TOOL_VCC100_FN_FIND_SDK_TOOL_SUB),)$($2)
97
98## Disabled fast DEP_IDB based dependencies.
99#VCC100_OLD_DEPS = 1
100
101## Constructs the correct .pdb name (the name is lowercased).
102# @param $(1) Base name, no extention.
103# @param $(2) The extension.
104TOOL_VCC100_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2)
105
106TOOL_VCC100_COBJSUFF ?= .obj
107TOOL_VCC100_CFLAGS ?= -TC -c -nologo
108TOOL_VCC100_CFLAGS.debug ?= -Od -Zi
109TOOL_VCC100_CFLAGS.release ?= -O2
110TOOL_VCC100_CFLAGS.profile ?= -O2
111TOOL_VCC100_CINCS ?= $(PATH_TOOL_VCC100_INC)
112TOOL_VCC100_CDEFS ?=
113
114TOOL_VCC100_CXXOBJSUFF ?= .obj
115TOOL_VCC100_CXXFLAGS ?= -TP -c -nologo
116TOOL_VCC100_CXXFLAGS.debug ?= -Od -Zi
117TOOL_VCC100_CXXFLAGS.release ?= -O2
118TOOL_VCC100_CXXFLAGS.profile ?= -O2
119TOOL_VCC100_CXXINCS ?= $(PATH_TOOL_VCC100_INC) $(PATH_TOOL_VCC100_ATLMFC_INC)
120TOOL_VCC100_CXXDEFS ?=
121
122TOOL_VCC100_ASOBJSUFF ?= .obj
123
124TOOL_VCC100_RCOBJSUFF ?= .res
125TOOL_VCC100_RCINCS ?= $(PATH_TOOL_VCC100_INC) $(PATH_TOOL_VCC100_ATLMFC_INC)
126
127TOOL_VCC100_ARFLAGS.amd64 ?= -machine:amd64
128TOOL_VCC100_ARFLAGS.x86 ?= -machine:x86
129TOOL_VCC100_ARFLAGS ?= -nologo
130TOOL_VCC100_ARLIBSUFF ?= .lib
131
132TOOL_VCC100_LDFLAGS.amd64 ?= -machine:amd64
133TOOL_VCC100_LDFLAGS.x86 ?= -machine:x86
134TOOL_VCC100_LDFLAGS ?= -nologo
135TOOL_VCC100_LDFLAGS.debug ?= -debug
136TOOL_VCC100_LDFLAGS.release ?=
137TOOL_VCC100_LIBPATH.amd64 ?= $(PATH_TOOL_VCC100_LIB.amd64) $(PATH_TOOL_VCC100_ATLMFC_LIB.amd64)
138TOOL_VCC100_LIBPATH.x86 ?= $(PATH_TOOL_VCC100_LIB.x86) $(PATH_TOOL_VCC100_ATLMFC_LIB.x86)
139
140
141
142## Compile C source.
143# @param $(target) Normalized main target name.
144# @param $(source) Source filename (relative).
145# @param $(obj) Object file name. This shall be (re)created by the compilation.
146# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
147# @param $(flags) Flags.
148# @param $(defs) Definitions. No -D or something.
149# @param $(incs) Includes. No -I or something.
150# @param $(dirdep) Directory creation dependency.
151# @param $(deps) Other dependencies.
152#
153# @param $(outbase) Output basename (full). Use this for list files and such.
154# @param $(objsuff) Object suffix.
155TOOL_VCC100_COMPILE_C_DEPEND =
156TOOL_VCC100_COMPILE_C_DEPORD =
157TOOL_VCC100_COMPILE_C_OUTPUT = $(call TOOL_VCC100_PDB, $(outbase)-obj,idb)
158TOOL_VCC100_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC100_PDB, $(outbase)-obj,pdb)
159define TOOL_VCC100_COMPILE_C_CMDS
160 $(QUIET)$(TOOL_VCC100_CC) -c\
161 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
162 -Fd$(outbase)-obj.pdb \
163 -FD\
164 -Fo$(obj)\
165 $(subst /,\\,$(abspath $(source)))
166 $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100_PDB,$(outbase)-obj,idb)
167endef
168
169
170## Compile C++ source.
171# @param $(target) Normalized main target name.
172# @param $(source) Source filename (relative).
173# @param $(obj) Object file name. This shall be (re)created by the compilation.
174# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
175# @param $(flags) Flags.
176# @param $(defs) Definitions. No -D or something.
177# @param $(incs) Includes. No -I or something.
178# @param $(dirdep) Directory creation dependency.
179# @param $(deps) Other dependencies.
180#
181# @param $(outbase) Output basename (full). Use this for list files and such.
182# @param $(objsuff) Object suffix.
183TOOL_VCC100_COMPILE_CXX_DEPEND =
184TOOL_VCC100_COMPILE_CXX_DEPORD =
185TOOL_VCC100_COMPILE_CXX_OUTPUT = $(call TOOL_VCC100_PDB, $(outbase)-obj,idb)
186TOOL_VCC100_COMPILE_CXX_OUTPUT_MAYBE = $(call TOOL_VCC100_PDB, $(outbase)-obj,pdb)
187define TOOL_VCC100_COMPILE_CXX_CMDS
188 $(QUIET)$(TOOL_VCC100_CXX) -c\
189 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
190 -Fd$(outbase)-obj.pdb \
191 -FD\
192 -Fo$(obj)\
193 $(subst /,\\,$(abspath $(source)))
194 $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100_PDB,$(outbase)-obj,idb)
195endef
196
197
198## Compile resource source.
199# @param $(target) Normalized main target name.
200# @param $(source) Source filename (relative).
201# @param $(obj) Object file name. This shall be (re)created by the compilation.
202# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
203# @param $(flags) Flags.
204# @param $(defs) Definitions. No -D or something.
205# @param $(incs) Includes. No -I or something.
206# @param $(dirdep) Directory creation dependency.
207# @param $(deps) Other dependencies.
208#
209# @param $(outbase) Output basename (full). Use this for list files and such.
210# @param $(objsuff) Object suffix.
211TOOL_VCC100_COMPILE_RC_OUTPUT =
212TOOL_VCC100_COMPILE_RC_DEPEND =
213TOOL_VCC100_COMPILE_RC_DEPORD =
214define TOOL_VCC100_COMPILE_RC_CMDS
215 $(QUIET)$(TOOL_VCC100_RC) \
216 $(flags) $(addprefix /i, $(subst /,\\,$(incs))) $(addprefix /d, $(defs))\
217 /fo$(obj)\
218 $(subst /,\\,$(abspath $(source)))
219endef
220
221
222## Link library
223# @param $(target) Normalized main target name.
224# @param $(out) Library name.
225# @param $(objs) Object files to put in the library.
226# @param $(flags) Flags.
227# @param $(dirdep) Directory creation dependency.
228# @param $(deps) Other dependencies.
229# @param $(othersrc) Unhandled sources.
230# @param $(outbase) Output basename (full). Use this for list files and such.
231#
232TOOL_VCC100_LINK_LIBRARY_DEPEND = $(othersrc)
233TOOL_VCC100_LINK_LIBRARY_DEPORD =
234TOOL_VCC100_LINK_LIBRARY_OUTPUT = $(outbase).rsp
235TOOL_VCC100_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb
236define TOOL_VCC100_LINK_LIBRARY_CMDS
237 $(QUIET)$(APPEND) -tn $(outbase).rsp \
238 $(foreach arg,\
239 $(subst /,\\,$(objs) \
240 $(filter-out %.def,$(othersrc))) \
241 $(addprefix /DEF:,$(filter %.def,$(othersrc))) \
242 ,\"$(arg)\")
243 $(QUIET)$(TOOL_VCC100_AR) $(flags) /OUT:$(out) @$(outbase).rsp
244endef
245
246
247
248
249## Link program
250# @param $(target) Normalized main target name.
251# @param $(out) Program name.
252# @param $(objs) Object files to link together.
253# @param $(libs) Libraries to search.
254# @param $(libpath) Library search paths.
255# @param $(flags) Flags.
256# @param $(dirdep) Directory creation dependency.
257# @param $(deps) Other dependencies.
258# @param $(othersrc) Unhandled sources.
259# @param $(custom_pre) Custom step invoked before linking.
260# @param $(custom_post) Custom step invoked after linking.
261# @param $(outbase) Output basename (full). Use this for list files and such.
262#
263TOOL_VCC100_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
264TOOL_VCC100_LINK_PROGRAM_DEPORD =
265TOOL_VCC100_LINK_PROGRAM_OUTPUT = $(outbase).map $(outbase).rsp
266TOOL_VCC100_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
267TOOL_VCC100_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb
268TOOL_VCC100_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
269define TOOL_VCC100_LINK_PROGRAM_CMDS
270 $(QUIET)$(APPEND) -tn $(outbase).rsp \
271 $(foreach arg,\
272 $(subst /,\\,$(objs)) \
273 $(subst /,\\,$(libs)) \
274 ,\"$(arg)\")
275 $(QUIET)$(TOOL_VCC100_LD) $(flags) \
276 /OUT:$(out) \
277 /MAPINFO:EXPORTS /INCREMENTAL:NO \
278 /MAP:$(outbase).map \
279 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
280 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
281 $(foreach p,$(libpath), /LIBPATH:$(p)) \
282 @$(outbase).rsp
283 $(QUIET)$(TEST) -f $(out).manifest -- \
284 $(TOOL_VCC100_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out))
285endef
286
287
288## Link DLL.
289# @param $(target) Normalized main target name.
290# @param $(out) DLL name.
291# @param $(objs) Object files to link together.
292# @param $(libs) Libraries to search.
293# @param $(libpath) Library search paths.
294# @param $(flags) Flags.
295# @param $(dirdep) Directory creation dependency.
296# @param $(deps) Other dependencies.
297# @param $(othersrc) Unhandled sources.
298# @param $(custom_pre) Custom step invoked before linking.
299# @param $(custom_post) Custom step invoked after linking.
300#
301# @param $(outbase) Output basename (full). Use this for list files and such.
302TOOL_VCC100_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
303TOOL_VCC100_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB))
304TOOL_VCC100_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).rsp
305TOOL_VCC100_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp
306TOOL_VCC100_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb
307TOOL_VCC100_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
308define TOOL_VCC100_LINK_DLL_CMDS
309 $(QUIET)$(APPEND) -tn $(outbase).rsp \
310 $(foreach arg,\
311 $(subst /,\\,$(objs)) \
312 $(subst /,\\,$(libs)) \
313 ,\"$(arg)\")
314 $(QUIET)$(TOOL_VCC100_LD) $(flags) \
315 /OUT:$(out) \
316 /IMPLIB:$(outbase).lib \
317 /MAPINFO:EXPORTS /INCREMENTAL:NO \
318 /MAP:$(outbase).map \
319 /DLL \
320 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
321 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
322 $(foreach p,$(libpath), /LIBPATH:$(p)) \
323 @$(outbase).rsp
324 $(QUIET)$(TEST) -f $(out).manifest -- \
325 $(TOOL_VCC100_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
326 $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/
327$(eval _DIRS += $(PATH_STAGE_LIB))
328endef
329
330
331## Link system module (windows aka driver, linux aka kernel module)
332# @param $(target) Normalized main target name.
333# @param $(out) System module name.
334# @param $(objs) Object files to link together.
335# @param $(libs) Libraries to search.
336# @param $(libpath) Library search paths.
337# @param $(flags) Flags.
338# @param $(dirdep) Directory creation dependency.
339# @param $(deps) Other dependencies.
340# @param $(othersrc) Unhandled sources.
341# @param $(custom_pre) Custom step invoked before linking.
342# @param $(custom_post) Custom step invoked after linking.
343#
344# @param $(outbase) Output basename (full). Use this for list files and such.
345TOOL_VCC100_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
346TOOL_VCC100_LINK_SYSMOD_DEPORD =
347TOOL_VCC100_LINK_SYSMOD_OUTPUT = $(outbase).map $(outbase).rsp
348TOOL_VCC100_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
349TOOL_VCC100_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb
350TOOL_VCC100_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
351define TOOL_VCC100_LINK_SYSMOD_CMDS
352 $(QUIET)$(APPEND) -tn $(outbase).rsp \
353 $(foreach arg,\
354 $(subst /,\\,$(objs)) \
355 $(subst /,\\,$(libs)) \
356 ,\"$(arg)\")
357 $(QUIET)$(TOOL_VCC100_LD) $(flags) \
358 /OUT:$(out) \
359 /MAPINFO:EXPORTS /INCREMENTAL:NO \
360 /MAP:$(outbase).map \
361 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
362 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
363 $(foreach p,$(libpath), /LIBPATH:$(p)) \
364 @$(outbase).rsp
365 $(QUIET)$(TEST) -f $(out).manifest -- \
366 $(TOOL_VCC100_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
367endef
368
Note: See TracBrowser for help on using the repository browser.