1 | # Microsoft Visual C++ |
---|
2 | |
---|
3 | # (C) Copyright David Abrahams 2001. |
---|
4 | # Distributed under the Boost Software License, Version 1.0. |
---|
5 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
---|
6 | |
---|
7 | # The following #// line will be used by the regression test table generation |
---|
8 | # program as the column heading for HTML tables. Must not include version number. |
---|
9 | #//<a href="http://msdn.microsoft.com/vstudio/default.asp">Micro-<br>soft<br>VC++</a> |
---|
10 | |
---|
11 | # singleton variables... |
---|
12 | set-as-singleton MSVCDir VISUALC MSVC_ROOT VC_TOOL_PATH VC_SETUP ; |
---|
13 | |
---|
14 | # Get these variable set on the targets so that we can re-use the |
---|
15 | # build actions for other toolsets using this one as a base. |
---|
16 | flags msvc VC_TOOL_PATH ; |
---|
17 | flags msvc VC_SETUP ; |
---|
18 | flags msvc VC_COMPILER ; |
---|
19 | flags msvc VC_LINKER ; |
---|
20 | flags msvc VC_PDB_NAME ; |
---|
21 | |
---|
22 | # compute MSVC tool path |
---|
23 | # You can either put the msvc bin directory in your PATH, or you can set |
---|
24 | # MSVCDir to point at the msvc installation directory |
---|
25 | |
---|
26 | # Some installations set MSVCDIR instead of MSVCDir; who knows why? |
---|
27 | MSVCDir ?= $(MSVCDIR) ; |
---|
28 | |
---|
29 | # If MSVCDir is not set the user hasn't run VCVARS32.BAT |
---|
30 | if ! $(MSVCDir) |
---|
31 | { |
---|
32 | # In case someone set VISUALC in order to build Jam, we can just use that. |
---|
33 | MSVC_ROOT ?= $(VISUALC) ; |
---|
34 | # Otherwise, guess a standard installation directory |
---|
35 | |
---|
36 | ProgramFiles ?= $(PROGRAMFILES) ; |
---|
37 | MSVC_ROOT ?= $(ProgramFiles:J=" ")"\\Microsoft Visual Studio\\VC98" ; |
---|
38 | |
---|
39 | # Reconstitutes paths containing spaces |
---|
40 | MSVC_ROOT = $(MSVC_ROOT:J=" ") ; |
---|
41 | |
---|
42 | # The tools are provisionallly located in the msvc6 bin |
---|
43 | # directory. This may be overridden by toolsets which extend this |
---|
44 | # one. |
---|
45 | VC_TOOL_PATH = "$(MSVC_ROOT)"$(SLASH)bin$(SLASH) ; |
---|
46 | |
---|
47 | # Always call VCVARS32.BAT before invoking the tools |
---|
48 | VC_SETUP = "CALL \"$(VC_TOOL_PATH)VCVARS32.BAT\" >nul" ; |
---|
49 | } |
---|
50 | else |
---|
51 | { |
---|
52 | # Reconstitutes paths containing spaces |
---|
53 | MSVCDir = $(MSVCDir:J=" ") ; |
---|
54 | |
---|
55 | # Don't clobber adjoining text or use explicit paths if MSVCDir is already set |
---|
56 | VC_TOOL_PATH = "" ; |
---|
57 | } |
---|
58 | |
---|
59 | VC_COMPILER = cl ; |
---|
60 | VC_LINKER = link ; |
---|
61 | VC_PDB_NAME = vc60 ; |
---|
62 | VC_STDLIB_PATH = ; |
---|
63 | |
---|
64 | flags msvc CFLAGS <debug-symbols>on/<debug-store>object : /Z7 ; |
---|
65 | flags msvc CFLAGS <debug-symbols>on/<debug-store>database : /Zi ; |
---|
66 | flags msvc PDB_CFLAG <debug-symbols>on/<debug-store>database : /Fd ; |
---|
67 | flags msvc PDB_LINKFLAG <debug-symbols>on/<debug-store>database : /PDB: ; |
---|
68 | flags msvc LINKFLAGS <debug-symbols>on : /DEBUG ; |
---|
69 | # The linker disables the default optimizations when using /DEBUG. Whe have |
---|
70 | # to enable them manually for release builds with debug symbols. |
---|
71 | flags msvc LINKFLAGS <debug-symbols>on/<runtime-build>release : /OPT:REF,ICF ; |
---|
72 | |
---|
73 | flags msvc CFLAGS <optimization>off : /Od ; |
---|
74 | flags msvc CFLAGS <optimization>speed : /Ogity /O2 /Gs ; |
---|
75 | flags msvc CFLAGS <optimization>space : /Ogisy /O1 /Gs ; |
---|
76 | flags msvc CFLAGS <inlining>off : /Ob0 ; |
---|
77 | flags msvc CFLAGS <inlining>on : /Ob1 ; |
---|
78 | flags msvc CFLAGS <inlining>full : /Ob2 ; |
---|
79 | flags msvc CFLAGS <exception-handling>on : /EHsc ; |
---|
80 | flags msvc CFLAGS <rtti>on : /GR ; |
---|
81 | |
---|
82 | # Note that these two options actually imply multithreading support on MSVC |
---|
83 | # because there is no single-threaded dynamic runtime library. Specifying |
---|
84 | # <threading>multi would be a bad idea, though, because no option would be |
---|
85 | # matched when the build uses the default settings of <runtime-link>dynamic |
---|
86 | # and <threading>single. |
---|
87 | flags msvc CFLAGS <runtime-build>release/<runtime-link>dynamic : /MD ; |
---|
88 | flags msvc CFLAGS <runtime-build>debug/<runtime-link>dynamic : /MDd ; |
---|
89 | |
---|
90 | flags msvc CFLAGS <runtime-build>release/<runtime-link>static/<threading>single : /ML ; |
---|
91 | flags msvc CFLAGS <runtime-build>debug/<runtime-link>static/<threading>single : /MLd ; |
---|
92 | flags msvc CFLAGS <runtime-build>release/<runtime-link>static/<threading>multi : /MT ; |
---|
93 | flags msvc CFLAGS <runtime-build>debug/<runtime-link>static/<threading>multi : /MTd ; |
---|
94 | |
---|
95 | flags msvc CFLAGS <cflags> ; |
---|
96 | flags msvc C++FLAGS <cxxflags> ; |
---|
97 | flags msvc DEFINES <define> ; |
---|
98 | flags msvc UNDEFS <undef> ; |
---|
99 | flags msvc HDRS <include> ; |
---|
100 | flags msvc SYSHDRS <sysinclude> ; |
---|
101 | flags msvc LINKFLAGS <linkflags> ; |
---|
102 | flags msvc ARFLAGS <arflags> ; |
---|
103 | |
---|
104 | flags msvc STDHDRS : $(MSVCDir)$(SLASH)include ; |
---|
105 | flags msvc STDLIBPATH : $(MSVCDir)$(SLASH)lib ; |
---|
106 | flags msvc LIBPATH <library-path> ; |
---|
107 | flags msvc NEEDLIBS <library-file> ; |
---|
108 | flags msvc FINDLIBS <find-library> ; |
---|
109 | flags msvc LINKFLAGS <target-type>$(SHARED_TYPES) : /DLL ; |
---|
110 | |
---|
111 | flags msvc LINKFLAGS <user-interface>console : /subsystem:console ; |
---|
112 | flags msvc LINKFLAGS <user-interface>gui : /subsystem:windows ; |
---|
113 | flags msvc LINKFLAGS <user-interface>wince : /subsystem:windowsce ; |
---|
114 | flags msvc LINKFLAGS <user-interface>native : /subsystem:native ; |
---|
115 | flags msvc LINKFLAGS <user-interface>auto : /subsystem:posix ; |
---|
116 | |
---|
117 | |
---|
118 | rule vc-set-pdb-file ( targets + : name ) |
---|
119 | { |
---|
120 | local pdb = $(targets[1]:B=$(name):S=.pdb) ; |
---|
121 | VC_PDB_FILE on $(targets) = $(pdb:G=:R=$(LOCATE_TARGET)) ; |
---|
122 | LOCATE on $(pdb) = $(LOCATE_TARGET) ; |
---|
123 | Clean clean : $(pdb) ; |
---|
124 | } |
---|
125 | |
---|
126 | #### Link #### |
---|
127 | |
---|
128 | rule Link-action ( target implib ? : sources + : target-type ? ) |
---|
129 | { |
---|
130 | with-command-file vc-Link $(<) : $(sources) $(NEEDLIBS) ; |
---|
131 | |
---|
132 | if $(target-type) in $(SHARED_TYPES) |
---|
133 | { |
---|
134 | MANIFEST on $(target) = $(VC_MANIFEST) ; |
---|
135 | OUTPUTRESOURCE on $(target) = $(VC_OUTPUTRESOURCE) ; |
---|
136 | } |
---|
137 | |
---|
138 | gRUN_PATH($(<)) += $(VC_STDLIB_PATH) ; |
---|
139 | if $(implib) |
---|
140 | { |
---|
141 | # incremental linking a DLL causes no end of problems: if the |
---|
142 | # actual exports don't change, the import .lib file is never |
---|
143 | # updated. Therefore, the .lib is always out-of-date and gets |
---|
144 | # rebuilt every time. I'm not sure that incremental linking is |
---|
145 | # such a great idea in general, but in this case I'm sure we |
---|
146 | # don't want it. |
---|
147 | NOINCREMENTAL on $(<) = /INCREMENTAL:NO ; |
---|
148 | } |
---|
149 | vc-set-pdb-file $(<) : $(target:B) ; |
---|
150 | } |
---|
151 | |
---|
152 | VC_MANIFEST = ; |
---|
153 | VC_OUTPUTRESOURCE = ; |
---|
154 | |
---|
155 | actions together vc-Link |
---|
156 | { |
---|
157 | $(VC_SETUP) |
---|
158 | "$(VC_TOOL_PATH)$(VC_LINKER)" /nologo $(NOINCREMENTAL) $(LINKFLAGS) $(PDB_LINKFLAG)"$(VC_PDB_FILE)" /out:"$(<[1])" /IMPLIB:"$(<[2])" /LIBPATH:"$(LIBPATH)" /LIBPATH:"$(STDLIBPATH)" "$(FINDLIBS:S=.lib)" @"$(>)" |
---|
159 | $(MANIFEST)$(<[1]).manifest $(OUTPUTRESOURCE)$(<[1]);#2 |
---|
160 | } |
---|
161 | |
---|
162 | #### Cc ##### |
---|
163 | |
---|
164 | rule Cc-action |
---|
165 | { |
---|
166 | vc-set-pdb-file $(<) : $(VC_PDB_NAME) ; |
---|
167 | vc-Cc $(<) : $(>) ; |
---|
168 | } |
---|
169 | |
---|
170 | actions vc-Cc |
---|
171 | { |
---|
172 | $(VC_SETUP) |
---|
173 | "$(VC_TOOL_PATH)$(VC_COMPILER)" /Zm800 -nologo -c -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -I"$(SYSHDRS)" $(PDB_CFLAG)"$(VC_PDB_FILE)" -Fo"$(<)" "$(>)" |
---|
174 | } |
---|
175 | |
---|
176 | #### C++ #### |
---|
177 | rule C++-action |
---|
178 | { |
---|
179 | vc-set-pdb-file $(<) : $(VC_PDB_NAME) ; |
---|
180 | vc-C++ $(<) : $(>) ; |
---|
181 | } |
---|
182 | |
---|
183 | actions vc-C++ |
---|
184 | { |
---|
185 | $(VC_SETUP) |
---|
186 | "$(VC_TOOL_PATH)$(VC_COMPILER)" /Zm800 -nologo /EHsc -c -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -I"$(SYSHDRS)" $(PDB_CFLAG)"$(VC_PDB_FILE)" -Fo"$(<)" -Tp"$(>)" |
---|
187 | } |
---|
188 | |
---|
189 | #### Archive #### |
---|
190 | rule Archive-action |
---|
191 | { |
---|
192 | vc-set-pdb-file $(<) : $(<:B) ; |
---|
193 | with-command-file vc-Archive $(<) : $(>) ; |
---|
194 | } |
---|
195 | |
---|
196 | actions vc-Archive |
---|
197 | { |
---|
198 | $(VC_SETUP) |
---|
199 | if exist "$(<)" DEL "$(<)" |
---|
200 | "$(VC_TOOL_PATH)$(VC_LINKER)" /lib $(ARFLAGS) $(PDB_LINKFLAG)"$(VC_PDB_FILE)" /out:"$(<)" @"$(>)" |
---|
201 | } |
---|
202 | |
---|
203 | |
---|