source: trunk/kBuild/tools/VCC100X86.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: 14.8 KB
Line 
1# $Id: VCC100X86.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 x86.
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_VCC100X86 := Visual C++ 10.0 (aka Visual 2010 and MSC v16), targeting x86.
35
36# Tool Specific Properties
37ifndef PATH_TOOL_VCC100X86
38 PATH_TOOL_VCC100X86 := $(wildcard $(PATH_DEVTOOLS)/win.x86/vcc/v10*)
39 ifeq ($(PATH_TOOL_VCC100X86),)
40 PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100)
41 endif
42 ifeq ($(PATH_TOOL_VCC100X86),)
43 PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100AMD64)
44 endif
45 ifeq ($(PATH_TOOL_VCC100X86),)
46 PATH_TOOL_VCC100X86 := $(wildcard $(PATH_DEVTOOLS)/x86.win32/vcc/v10*)
47 endif
48 ifeq ($(PATH_TOOL_VCC100X86),)
49 PATH_TOOL_VCC100X86 := $(wildcard $(PATH_DEVTOOLS)/win.amd64/vcc/v10*)
50 endif
51 ifneq ($(PATH_TOOL_VCC100X86),)
52 PATH_TOOL_VCC100X86 := $(lastword $(sort $(PATH_TOOL_VCC100X86)))
53 else
54 $(warning kBuild: PATH_TOOL_VCC100X86 cannot be determined!)
55 PATH_TOOL_VCC100X86 := $(PATH_DEVTOOLS)/x86.win/vcc/v10
56 endif
57else
58 # Resolve any fancy stuff once and for all.
59 PATH_TOOL_VCC100X86 := $(PATH_TOOL_VCC100X86)
60endif
61PATH_TOOL_VCC100X86_BIN ?= $(PATH_TOOL_VCC100X86)/bin
62PATH_TOOL_VCC100X86_LIB ?= $(PATH_TOOL_VCC100X86)/lib
63PATH_TOOL_VCC100X86_INC ?= $(PATH_TOOL_VCC100X86)/include
64PATH_TOOL_VCC100X86_ATLMFC ?= $(PATH_TOOL_VCC100X86)/atlmfc
65PATH_TOOL_VCC100X86_ATLMFC_INC ?= $(PATH_TOOL_VCC100X86_ATLMFC)/include
66PATH_TOOL_VCC100X86_ATLMFC_LIB ?= $(PATH_TOOL_VCC100X86_ATLMFC)/lib
67TOOL_VCC100X86_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/cl.exe
68TOOL_VCC100X86_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/cl.exe
69TOOL_VCC100X86_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/ml.exe
70TOOL_VCC100X86_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/lib.exe
71TOOL_VCC100X86_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/link.exe
72TOOL_VCC100X86_MT ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC100X86_BIN)/mt.exe
73TOOL_VCC100X86_RC ?= $(EXEC_X86_WIN32) $(call TOOL_VCC100_FN_FIND_SDK_TOOL,rc.exe,TOOL_VCC100_RC_CACHED)
74TOOL_VCC100X86_MT ?= $(EXEC_X86_WIN32) $(call TOOL_VCC100_FN_FIND_SDK_TOOL,mt.exe,TOOL_VCC100_MT_CACHED)
75
76# The following in duplicated in VCC100.kmk and VCC100X86.kmk.
77TOOL_VCC100_FN_FIND_SDK_TOOL_SUB = $(eval $2 := $(firstword \
78 $(if-expr defined(PATH_SDK_WINPSDK71_BIN), $(wildcard $(PATH_SDK_WINPSDK71_BIN)/$1)) \
79 $(if-expr defined(PATH_SDK_WINPSDK_BIN) , $(wildcard $(PATH_SDK_WINPSDK_BIN)/$1)) \
80 $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/sdk/*/[Bb][Ii][Nn]/$1)) \
81 $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/sdk/*/[Bb][Ii][Nn]/$1)) \
82 $1))
83TOOL_VCC100_FN_FIND_SDK_TOOL = $(if-expr !defined($2),$(TOOL_VCC100_FN_FIND_SDK_TOOL_SUB),)$($2)
84
85## Disabled fast DEP_IDB based dependencies.
86#VCC100X86_OLD_DEPS = 1
87
88## Constructs the correct .pdb name (the name is lowercased).
89# @param $(1) Base name, no extention.
90# @param $(2) The extension.
91TOOL_VCC100X86_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2)
92
93
94# General Properties used by kBuild
95TOOL_VCC100X86_COBJSUFF ?= .obj
96TOOL_VCC100X86_CFLAGS ?= -TC -c -nologo
97TOOL_VCC100X86_CFLAGS.debug ?= -Zi
98TOOL_VCC100X86_CFLAGS.release ?= -O2
99TOOL_VCC100X86_CFLAGS.profile ?= -O2
100TOOL_VCC100X86_CINCS ?= $(PATH_TOOL_VCC100X86_INC)
101TOOL_VCC100X86_CDEFS ?=
102
103TOOL_VCC100X86_CXXOBJSUFF ?= .obj
104TOOL_VCC100X86_CXXFLAGS ?= -TP -c -nologo
105TOOL_VCC100X86_CXXFLAGS.debug ?= -Zi
106TOOL_VCC100X86_CXXFLAGS.release ?= -O2
107TOOL_VCC100X86_CXXFLAGS.profile ?= -O2
108TOOL_VCC100X86_CXXINCS ?= $(PATH_TOOL_VCC100X86_INC) $(PATH_TOOL_VCC100X86_ATLMFC_INC)
109TOOL_VCC100X86_CXXDEFS ?=
110
111TOOL_VCC100X86_ASOBJSUFF ?= .obj
112
113TOOL_VCC100X86_RCOBJSUFF ?= .res
114TOOL_VCC100X86_RCINCS ?= $(PATH_TOOL_VCC100X86_INC) $(PATH_TOOL_VCC100X86_ATLMFC_INC)
115
116TOOL_VCC100X86_ARFLAGS ?= -nologo
117TOOL_VCC100X86_ARLIBSUFF ?= .lib
118
119TOOL_VCC100X86_LDFLAGS ?= -nologo -machine:x86
120TOOL_VCC100X86_LDFLAGS.debug ?= -debug
121TOOL_VCC100X86_LDFLAGS.release ?=
122
123
124
125## Compile C source.
126# @param $(target) Normalized main target name.
127# @param $(source) Source filename (relative).
128# @param $(obj) Object file name. This shall be (re)created by the compilation.
129# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
130# @param $(flags) Flags.
131# @param $(defs) Definitions. No -D or something.
132# @param $(incs) Includes. No -I or something.
133# @param $(dirdep) Directory creation dependency.
134# @param $(deps) Other dependencies.
135#
136# @param $(outbase) Output basename (full). Use this for list files and such.
137# @param $(objsuff) Object suffix.
138TOOL_VCC100X86_COMPILE_C_DEPEND =
139TOOL_VCC100X86_COMPILE_C_DEPORD =
140TOOL_VCC100X86_COMPILE_C_OUTPUT = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,idb)
141TOOL_VCC100X86_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,pdb)
142define TOOL_VCC100X86_COMPILE_C_CMDS
143 $(QUIET)$(TOOL_VCC100X86_CC) -c\
144 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
145 -Fd$(outbase)-obj.pdb \
146 -FD\
147 -Fo$(obj)\
148 $(subst /,\\,$(abspath $(source)))
149 $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100X86_PDB,$(outbase)-obj,idb)
150endef
151
152
153## Compile C++ source.
154# @param $(target) Normalized main target name.
155# @param $(source) Source filename (relative).
156# @param $(obj) Object file name. This shall be (re)created by the compilation.
157# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
158# @param $(flags) Flags.
159# @param $(defs) Definitions. No -D or something.
160# @param $(incs) Includes. No -I or something.
161# @param $(dirdep) Directory creation dependency.
162# @param $(deps) Other dependencies.
163#
164# @param $(outbase) Output basename (full). Use this for list files and such.
165# @param $(objsuff) Object suffix.
166TOOL_VCC100X86_COMPILE_CXX_DEPEND =
167TOOL_VCC100X86_COMPILE_CXX_DEPORD =
168TOOL_VCC100X86_COMPILE_CXX_OUTPUT = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,idb)
169TOOL_VCC100X86_COMPILE_CXX_OUTPUT_MAYBE = $(call TOOL_VCC100X86_PDB, $(outbase)-obj,pdb)
170define TOOL_VCC100X86_COMPILE_CXX_CMDS
171 $(QUIET)$(TOOL_VCC100X86_CXX) -c\
172 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
173 -Fd$(outbase)-obj.pdb \
174 -FD\
175 -Fo$(obj)\
176 $(subst /,\\,$(abspath $(source)))
177 $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC100X86_PDB,$(outbase)-obj,idb)
178endef
179
180## @todo configure the assembler template.
181
182## Compile resource source.
183# @param $(target) Normalized main target name.
184# @param $(source) Source filename (relative).
185# @param $(obj) Object file name. This shall be (re)created by the compilation.
186# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
187# @param $(flags) Flags.
188# @param $(defs) Definitions. No -D or something.
189# @param $(incs) Includes. No -I or something.
190# @param $(dirdep) Directory creation dependency.
191# @param $(deps) Other dependencies.
192#
193# @param $(outbase) Output basename (full). Use this for list files and such.
194# @param $(objsuff) Object suffix.
195TOOL_VCC100X86_COMPILE_RC_DEPEND =
196TOOL_VCC100X86_COMPILE_RC_DEPORD =
197TOOL_VCC100X86_COMPILE_RC_OUTPUT =
198define TOOL_VCC100X86_COMPILE_RC_CMDS
199 $(QUIET)$(TOOL_VCC100X86_RC) \
200 $(flags) $(addprefix /i, $(subst /,\\,$(incs))) $(addprefix /d, $(defs))\
201 /fo$(obj)\
202 $(subst /,\\,$(abspath $(source)))
203endef
204
205
206## Link library
207# @param $(target) Normalized main target name.
208# @param $(out) Library name.
209# @param $(objs) Object files to put in the library.
210# @param $(flags) Flags.
211# @param $(dirdep) Directory creation dependency.
212# @param $(deps) Other dependencies.
213# @param $(othersrc) Unhandled sources.
214# @param $(outbase) Output basename (full). Use this for list files and such.
215#
216TOOL_VCC100X86_LINK_LIBRARY_DEPEND = $(othersrc)
217TOOL_VCC100X86_LINK_LIBRARY_DEPORD =
218TOOL_VCC100X86_LINK_LIBRARY_OUTPUT = $(outbase).rsp
219TOOL_VCC100X86_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb
220define TOOL_VCC100X86_LINK_LIBRARY_CMDS
221 $(QUIET)$(APPEND) -tn $(outbase).rsp \
222 $(foreach arg,\
223 $(subst /,\\,$(objs) \
224 $(filter-out %.def,$(othersrc))) \
225 $(addprefix /DEF:,$(filter %.def,$(othersrc))) \
226 ,\"$(arg)\")
227 $(QUIET)$(TOOL_VCC100X86_AR) $(flags) /OUT:$(out) @$(outbase).rsp
228endef
229
230
231## Link program
232# @param $(target) Normalized main target name.
233# @param $(out) Program name.
234# @param $(objs) Object files to link together.
235# @param $(libs) Libraries to search.
236# @param $(libpath) Library search paths.
237# @param $(flags) Flags.
238# @param $(dirdep) Directory creation dependency.
239# @param $(deps) Other dependencies.
240# @param $(othersrc) Unhandled sources.
241# @param $(custom_pre) Custom step invoked before linking.
242# @param $(custom_post) Custom step invoked after linking.
243# @param $(outbase) Output basename (full). Use this for list files and such.
244#
245TOOL_VCC100X86_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
246TOOL_VCC100X86_LINK_PROGRAM_DEPORD =
247TOOL_VCC100X86_LINK_PROGRAM_OUTPUT = $(outbase).map $(outbase).rsp
248TOOL_VCC100X86_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
249TOOL_VCC100X86_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb
250TOOL_VCC100X86_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
251define TOOL_VCC100X86_LINK_PROGRAM_CMDS
252 $(QUIET)$(APPEND) -tn $(outbase).rsp \
253 $(foreach arg,\
254 $(subst /,\\,$(objs)) \
255 $(subst /,\\,$(libs)) \
256 ,\"$(arg)\")
257 $(QUIET)$(TOOL_VCC100X86_LD) $(flags) \
258 /OUT:$(out) \
259 /MAPINFO:EXPORTS /INCREMENTAL:NO \
260 /MAP:$(outbase).map \
261 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
262 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
263 $(foreach p,$(libpath), /LIBPATH:$(p)) \
264 @$(outbase).rsp
265 $(QUIET)$(TEST) -f $(out).manifest -- \
266 $(TOOL_VCC100X86_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out))
267endef
268
269
270## Link DLL.
271# @param $(target) Normalized main target name.
272# @param $(out) DLL name.
273# @param $(objs) Object files to link together.
274# @param $(libs) Libraries to search.
275# @param $(libpath) Library search paths.
276# @param $(flags) Flags.
277# @param $(dirdep) Directory creation dependency.
278# @param $(deps) Other dependencies.
279# @param $(othersrc) Unhandled sources.
280# @param $(custom_pre) Custom step invoked before linking.
281# @param $(custom_post) Custom step invoked after linking.
282#
283# @param $(outbase) Output basename (full). Use this for list files and such.
284TOOL_VCC100X86_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
285TOOL_VCC100X86_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB))
286TOOL_VCC100X86_LINK_DLL_OUTPUT = $(outbase).map $(outbase).lib $(outbase).exp $(outbase).rsp
287TOOL_VCC100X86_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp
288TOOL_VCC100X86_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb
289TOOL_VCC100X86_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
290define TOOL_VCC100X86_LINK_DLL_CMDS
291 $(QUIET)$(APPEND) -tn $(outbase).rsp \
292 $(foreach arg,\
293 $(subst /,\\,$(objs)) \
294 $(subst /,\\,$(libs)) \
295 ,\"$(arg)\")
296 $(QUIET)$(TOOL_VCC100X86_LD) $(flags) \
297 /OUT:$(out) \
298 /IMPLIB:$(outbase).lib \
299 /MAPINFO:EXPORTS /INCREMENTAL:NO \
300 /MAP:$(outbase).map \
301 /DLL \
302 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
303 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
304 $(foreach p,$(libpath), /LIBPATH:$(p)) \
305 @$(outbase).rsp
306 $(QUIET)$(TEST) -f $(out).manifest -- \
307 $(TOOL_VCC100X86_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
308 $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/
309$(eval _DIRS += $(PATH_STAGE_LIB))
310endef
311
312
313## Link system module (windows aka driver, linux aka kernel module)
314# @param $(target) Normalized main target name.
315# @param $(out) System module name.
316# @param $(objs) Object files to link together.
317# @param $(libs) Libraries to search.
318# @param $(libpath) Library search paths.
319# @param $(flags) Flags.
320# @param $(dirdep) Directory creation dependency.
321# @param $(deps) Other dependencies.
322# @param $(othersrc) Unhandled sources.
323# @param $(custom_pre) Custom step invoked before linking.
324# @param $(custom_post) Custom step invoked after linking.
325#
326# @param $(outbase) Output basename (full). Use this for list files and such.
327TOOL_VCC100X86_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
328TOOL_VCC100X86_LINK_SYSMOD_DEPORD =
329TOOL_VCC100X86_LINK_SYSMOD_OUTPUT = $(outbase).map $(outbase).rsp
330TOOL_VCC100X86_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
331TOOL_VCC100X86_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb
332TOOL_VCC100X86_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
333define TOOL_VCC100X86_LINK_SYSMOD_CMDS
334 $(QUIET)$(APPEND) -tn $(outbase).rsp \
335 $(foreach arg,\
336 $(subst /,\\,$(objs)) \
337 $(subst /,\\,$(libs)) \
338 ,\"$(arg)\")
339 $(QUIET)$(TOOL_VCC100X86_LD) $(flags) \
340 /OUT:$(out) \
341 /MAPINFO:EXPORTS /INCREMENTAL:NO \
342 /MAP:$(outbase).map \
343 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
344 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
345 $(foreach p,$(libpath), /LIBPATH:$(p)) \
346 @$(outbase).rsp
347 $(QUIET)$(TEST) -f $(out).manifest -- \
348 $(TOOL_VCC100X86_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
349endef
350
Note: See TracBrowser for help on using the repository browser.