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

Last change on this file since 2557 was 2557, checked in by bird, 14 years ago

tools/VCC*.kmk: Use response files when linking.

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