source: trunk/kBuild/tools/VCC80X86.kmk@ 3403

Last change on this file since 3403 was 3303, checked in by bird, 6 years ago

VCC*.kmk,OPENWATCOM*.kmk: Try preserve .map and .rsp files so they can be inspected if linking fails. Fixed mssing .rsp cleaning up in OPENWATCOM.kmk for the archiver.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.1 KB
Line 
1# $Id: VCC80X86.kmk 3303 2020-01-14 15:09:44Z bird $
2## @file
3# kBuild Tool Config - Visual C++ 8.0 (aka Visual .NET 2005, or MSC v14), targeting x86.
4#
5
6#
7# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@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_VCC80X86 := Visual C++ 8.0 (aka Visual .NET 2005, or MSC v14), targeting x86.
35
36# Tool Specific Properties
37ifndef PATH_TOOL_VCC80X86
38 PATH_TOOL_VCC80X86 := $(wildcard $(KBUILD_DEVTOOLS)/win.x86/vcc/v8*)
39 ifeq ($(PATH_TOOL_VCC80X86),)
40 PATH_TOOL_VCC80X86 := $(PATH_TOOL_VCC80)
41 endif
42 ifeq ($(PATH_TOOL_VCC80X86),)
43 PATH_TOOL_VCC80X86 := $(PATH_TOOL_VCC80AMD64)
44 endif
45 ifeq ($(PATH_TOOL_VCC80X86),)
46 PATH_TOOL_VCC80X86 := $(wildcard $(KBUILD_DEVTOOLS)/x86.win32/vcc/v8*)
47 endif
48 ifeq ($(PATH_TOOL_VCC80X86),)
49 PATH_TOOL_VCC80X86 := $(wildcard $(KBUILD_DEVTOOLS)/win.amd64/vcc/v8*)
50 endif
51 ifneq ($(PATH_TOOL_VCC80X86),)
52 PATH_TOOL_VCC80X86 := $(lastword $(sort $(PATH_TOOL_VCC80X86)))
53 else
54 $(warning kBuild: PATH_TOOL_VCC80X86 cannot be determined!)
55 PATH_TOOL_VCC80X86 := $(KBUILD_DEVTOOLS)/x86.win/vcc/v8
56 endif
57else
58 # Resolve any fancy stuff once and for all.
59 PATH_TOOL_VCC80X86 := $(PATH_TOOL_VCC80X86)
60endif
61PATH_TOOL_VCC80X86_BIN ?= $(PATH_TOOL_VCC80X86)/bin
62PATH_TOOL_VCC80X86_LIB ?= $(PATH_TOOL_VCC80X86)/lib
63PATH_TOOL_VCC80X86_INC ?= $(PATH_TOOL_VCC80X86)/include
64PATH_TOOL_VCC80X86_ATLMFC ?= $(PATH_TOOL_VCC80X86)/atlmfc
65PATH_TOOL_VCC80X86_ATLMFC_INC ?= $(PATH_TOOL_VCC80X86_ATLMFC)/include
66PATH_TOOL_VCC80X86_ATLMFC_LIB ?= $(PATH_TOOL_VCC80X86_ATLMFC)/lib
67TOOL_VCC80X86_CC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80X86_BIN)/cl.exe
68TOOL_VCC80X86_CXX ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80X86_BIN)/cl.exe
69TOOL_VCC80X86_AS ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80X86_BIN)/ml.exe
70TOOL_VCC80X86_RC ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80X86_BIN)/rc.exe
71TOOL_VCC80X86_AR ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80X86_BIN)/lib.exe
72TOOL_VCC80X86_LD ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80X86_BIN)/link.exe
73TOOL_VCC80X86_MT ?= $(EXEC_X86_WIN32) $(PATH_TOOL_VCC80X86_BIN)/mt.exe
74## Disabled fast DEP_IDB based dependencies.
75#VCC80X86_OLD_DEPS = 1
76
77## Constructs the correct .pdb name (the name is lowercased).
78# @param $(1) Base name, no extention.
79# @param $(2) The extension.
80TOOL_VCC80X86_PDB = $(dir $(1))$(tolower $(notdir $(1))).$(2)
81
82
83# General Properties used by kBuild
84TOOL_VCC80X86_COBJSUFF ?= .obj
85TOOL_VCC80X86_CFLAGS ?= -TC -c -nologo
86TOOL_VCC80X86_CFLAGS.debug ?= -Zi
87TOOL_VCC80X86_CFLAGS.release ?= -O2
88TOOL_VCC80X86_CFLAGS.profile ?= -O2
89TOOL_VCC80X86_CINCS ?= $(PATH_TOOL_VCC80X86_INC)
90TOOL_VCC80X86_CDEFS ?=
91
92TOOL_VCC80X86_CXXOBJSUFF ?= .obj
93TOOL_VCC80X86_CXXFLAGS ?= -TP -c -nologo
94TOOL_VCC80X86_CXXFLAGS.debug ?= -Zi
95TOOL_VCC80X86_CXXFLAGS.release ?= -O2
96TOOL_VCC80X86_CXXFLAGS.profile ?= -O2
97TOOL_VCC80X86_CXXINCS ?= $(PATH_TOOL_VCC80X86_INC) $(PATH_TOOL_VCC80X86_ATLMFC_INC)
98TOOL_VCC80X86_CXXDEFS ?=
99
100TOOL_VCC80X86_ASOBJSUFF ?= .obj
101
102TOOL_VCC80X86_RCOBJSUFF ?= .res
103TOOL_VCC80X86_RCINCS ?= $(PATH_TOOL_VCC80X86_INC) $(PATH_TOOL_VCC80X86_ATLMFC_INC)
104
105TOOL_VCC80X86_ARFLAGS ?= -nologo
106TOOL_VCC80X86_ARLIBSUFF ?= .lib
107
108TOOL_VCC80X86_LDFLAGS ?= -nologo -machine:x86
109TOOL_VCC80X86_LDFLAGS.debug ?= -debug
110TOOL_VCC80X86_LDFLAGS.release ?=
111
112
113
114## Compile C source.
115# @param $(target) Normalized main target name.
116# @param $(source) Source filename (relative).
117# @param $(obj) Object file name. This shall be (re)created by the compilation.
118# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
119# @param $(flags) Flags.
120# @param $(defs) Definitions. No -D or something.
121# @param $(incs) Includes. No -I or something.
122# @param $(dirdep) Directory creation dependency.
123# @param $(deps) Other dependencies.
124#
125# @param $(outbase) Output basename (full). Use this for list files and such.
126# @param $(objsuff) Object suffix.
127TOOL_VCC80X86_COMPILE_C_DEPEND =
128TOOL_VCC80X86_COMPILE_C_DEPORD =
129TOOL_VCC80X86_COMPILE_C_OUTPUT = $(call TOOL_VCC80X86_PDB, $(outbase)-obj,idb)
130TOOL_VCC80X86_COMPILE_C_OUTPUT_MAYBE = $(call TOOL_VCC80X86_PDB, $(outbase)-obj,pdb)
131define TOOL_VCC80X86_COMPILE_C_CMDS
132 $(QUIET)$(TOOL_VCC80X86_CC) -c\
133 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
134 -Fd$(outbase)-obj.pdb \
135 -FD\
136 -Fo$(obj)\
137 $(subst /,\\,$(abspath $(source)))
138 $(QUIET)$(DEP_IDB) -f -s -q -o $(dep) -t $(obj) $(call TOOL_VCC80X86_PDB,$(outbase)-obj,idb)
139endef
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_VCC80X86_COMPILE_CXX_DEPEND =
156TOOL_VCC80X86_COMPILE_CXX_DEPORD =
157TOOL_VCC80X86_COMPILE_CXX_OUTPUT = $(call TOOL_VCC80X86_PDB, $(outbase)-obj,idb)
158TOOL_VCC80X86_COMPILE_CXX_OUTPUT_MAYBE = $(call TOOL_VCC80X86_PDB, $(outbase)-obj,pdb)
159define TOOL_VCC80X86_COMPILE_CXX_CMDS
160 $(QUIET)$(TOOL_VCC80X86_CXX) -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_VCC80X86_PDB,$(outbase)-obj,idb)
167endef
168
169## @todo configure the assembler template.
170
171## Compile resource source.
172# @param $(target) Normalized main target name.
173# @param $(source) Source filename (relative).
174# @param $(obj) Object file name. This shall be (re)created by the compilation.
175# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
176# @param $(flags) Flags.
177# @param $(defs) Definitions. No -D or something.
178# @param $(incs) Includes. No -I or something.
179# @param $(dirdep) Directory creation dependency.
180# @param $(deps) Other dependencies.
181#
182# @param $(outbase) Output basename (full). Use this for list files and such.
183# @param $(objsuff) Object suffix.
184TOOL_VCC80X86_COMPILE_RC_DEPEND =
185TOOL_VCC80X86_COMPILE_RC_DEPORD =
186TOOL_VCC80X86_COMPILE_RC_OUTPUT =
187define TOOL_VCC80X86_COMPILE_RC_CMDS
188 $(QUIET)$(TOOL_VCC80X86_RC) \
189 $(flags) $(addprefix /i, $(subst /,\\,$(incs))) $(addprefix /d, $(defs))\
190 /fo$(obj)\
191 $(subst /,\\,$(abspath $(source)))
192endef
193
194
195## Link library
196# @param $(target) Normalized main target name.
197# @param $(out) Library name.
198# @param $(objs) Object files to put in the library.
199# @param $(flags) Flags.
200# @param $(dirdep) Directory creation dependency.
201# @param $(deps) Other dependencies.
202# @param $(othersrc) Unhandled sources.
203# @param $(outbase) Output basename (full). Use this for list files and such.
204#
205TOOL_VCC80X86_LINK_LIBRARY_DEPEND = $(othersrc)
206TOOL_VCC80X86_LINK_LIBRARY_DEPORD =
207TOOL_VCC80X86_LINK_LIBRARY_OUTPUT = $(outbase).rsp
208TOOL_VCC80X86_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).lst $(outbase).exp $(outbase).pdb
209define TOOL_VCC80X86_LINK_LIBRARY_CMDS
210 $(QUIET)$(APPEND) -tn $(outbase).rsp \
211 $(foreach arg,\
212 $(subst /,\\,$(objs) \
213 $(filter-out %.def,$(othersrc))) \
214 $(addprefix /DEF:,$(filter %.def,$(othersrc))) \
215 ,\"$(arg)\")
216 $(QUIET)$(TOOL_VCC80X86_AR) $(flags) /OUT:$(out) @$(outbase).rsp
217endef
218
219
220## Link program
221# @param $(target) Normalized main target name.
222# @param $(out) Program name.
223# @param $(objs) Object files to link together.
224# @param $(libs) Libraries to search.
225# @param $(libpath) Library search paths.
226# @param $(flags) Flags.
227# @param $(dirdep) Directory creation dependency.
228# @param $(deps) Other dependencies.
229# @param $(othersrc) Unhandled sources.
230# @param $(custom_pre) Custom step invoked before linking.
231# @param $(custom_post) Custom step invoked after linking.
232# @param $(outbase) Output basename (full). Use this for list files and such.
233#
234TOOL_VCC80X86_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
235TOOL_VCC80X86_LINK_PROGRAM_DEPORD =
236TOOL_VCC80X86_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
237TOOL_VCC80X86_LINK_PROGRAM_OUTPUT_MAYBE_PRECIOUS = $(outbase).map $(outbase).rsp
238TOOL_VCC80X86_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).pdb
239TOOL_VCC80X86_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
240define TOOL_VCC80X86_LINK_PROGRAM_CMDS
241 $(QUIET)$(APPEND) -tn $(outbase).rsp \
242 $(foreach arg,\
243 $(subst /,\\,$(objs)) \
244 $(subst /,\\,$(libs)) \
245 ,\"$(arg)\")
246 $(QUIET)$(TOOL_VCC80X86_LD) $(flags) \
247 /OUT:$(out) \
248 /MAPINFO:EXPORTS /INCREMENTAL:NO \
249 /MAP:$(outbase).map \
250 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
251 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
252 $(foreach p,$(libpath), /LIBPATH:$(p)) \
253 @$(outbase).rsp
254 $(QUIET)$(TEST) -f $(out).manifest -- \
255 $(TOOL_VCC80X86_MT) -manifest $(subst /,\\,$(out)).manifest -outputresource:$(subst /,\\,$(out))
256endef
257
258
259## Link DLL.
260# @param $(target) Normalized main target name.
261# @param $(out) DLL name.
262# @param $(objs) Object files to link together.
263# @param $(libs) Libraries to search.
264# @param $(libpath) Library search paths.
265# @param $(flags) Flags.
266# @param $(dirdep) Directory creation dependency.
267# @param $(deps) Other dependencies.
268# @param $(othersrc) Unhandled sources.
269# @param $(custom_pre) Custom step invoked before linking.
270# @param $(custom_post) Custom step invoked after linking.
271#
272# @param $(outbase) Output basename (full). Use this for list files and such.
273TOOL_VCC80X86_LINK_DLL_DEPEND = $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
274TOOL_VCC80X86_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_STAGE_LIB))
275TOOL_VCC80X86_LINK_DLL_OUTPUT = $(outbase).lib $(outbase).exp
276TOOL_VCC80X86_LINK_DLL_OUTPUT_MAYBE = $(outbase).ilk $(out).manifest
277TOOL_VCC80X86_LINK_DLL_OUTPUT_MAYBE_PRECIOUS = $(PATH_STAGE_LIB)/$(notdir $(outbase)).lib $(PATH_STAGE_LIB)/$(notdir $(outbase)).exp $(outbase).map $(outbase).rsp
278TOOL_VCC80X86_LINK_DLL_OUTPUT_DEBUG = $(outbase).pdb
279TOOL_VCC80X86_LINK_DLL_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
280define TOOL_VCC80X86_LINK_DLL_CMDS
281 $(QUIET)$(APPEND) -tn $(outbase).rsp \
282 $(foreach arg,\
283 $(subst /,\\,$(objs)) \
284 $(subst /,\\,$(libs)) \
285 ,\"$(arg)\")
286 $(QUIET)$(TOOL_VCC80X86_LD) $(flags) \
287 /OUT:$(out) \
288 /IMPLIB:$(outbase).lib \
289 /MAPINFO:EXPORTS /INCREMENTAL:NO \
290 /MAP:$(outbase).map \
291 /DLL \
292 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
293 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
294 $(foreach p,$(libpath), /LIBPATH:$(p)) \
295 @$(outbase).rsp
296 $(QUIET)$(TEST) -f $(out).manifest -- \
297 $(TOOL_VCC80X86_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
298 $(QUIET)$(CP) --changed --ignore-non-existing $(outbase).exp $(outbase).lib $(PATH_STAGE_LIB)/
299$(eval _DIRS += $(PATH_STAGE_LIB))
300endef
301
302
303## Link system module (windows aka driver, linux aka kernel module)
304# @param $(target) Normalized main target name.
305# @param $(out) System module name.
306# @param $(objs) Object files to link together.
307# @param $(libs) Libraries to search.
308# @param $(libpath) Library search paths.
309# @param $(flags) Flags.
310# @param $(dirdep) Directory creation dependency.
311# @param $(deps) Other dependencies.
312# @param $(othersrc) Unhandled sources.
313# @param $(custom_pre) Custom step invoked before linking.
314# @param $(custom_post) Custom step invoked after linking.
315#
316# @param $(outbase) Output basename (full). Use this for list files and such.
317TOOL_VCC80X86_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(othersrc)
318TOOL_VCC80X86_LINK_SYSMOD_DEPORD =
319TOOL_VCC80X86_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).lib $(outbase).exp $(outbase).ilk $(out).manifest
320TOOL_VCC80X86_LINK_SYSMOD_OUTPUT_MAYBE_PRECIOUS = $(outbase).map $(outbase).rsp
321TOOL_VCC80X86_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).pdb
322TOOL_VCC80X86_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).pdb=>$(basename $(3)).pdb
323define TOOL_VCC80X86_LINK_SYSMOD_CMDS
324 $(QUIET)$(APPEND) -tn $(outbase).rsp \
325 $(foreach arg,\
326 $(subst /,\\,$(objs)) \
327 $(subst /,\\,$(libs)) \
328 ,\"$(arg)\")
329 $(QUIET)$(TOOL_VCC80X86_LD) $(flags) \
330 /OUT:$(out) \
331 /MAPINFO:EXPORTS /INCREMENTAL:NO \
332 /MAP:$(outbase).map \
333 $(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
334 $(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
335 $(foreach p,$(libpath), /LIBPATH:$(p)) \
336 @$(outbase).rsp
337 $(QUIET)$(TEST) -f $(out).manifest -- \
338 $(TOOL_VCC80X86_MT) -manifest $(subst /,\\,$(out)).manifest '-outputresource:$(subst /,\\,$(out));#2'
339endef
340
Note: See TracBrowser for help on using the repository browser.