1 | #~ Copyright 2004-2005 Rene Rivera. |
---|
2 | #~ Distributed under the Boost Software License, Version 1.0. |
---|
3 | #~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
---|
4 | |
---|
5 | # The following #// line will be used by the regression test table generation |
---|
6 | # program as the column heading for HTML tables. Must not include version number. |
---|
7 | #//<a href="http://www.metrowerks.com/MW/Develop/Desktop/default.htm">Metrowerks<br>CodeWarrior</a> |
---|
8 | |
---|
9 | # For adding framwork libraries; like <framework>Python, <framework>Carbon, etc. |
---|
10 | free-feature framework ; |
---|
11 | |
---|
12 | # singleton variables... |
---|
13 | set-as-singleton CW_ROOT CWFOLDER CWFolder CWINSTALL ; |
---|
14 | |
---|
15 | flags cw cw-version : $(CW_VERSION) ; |
---|
16 | flags cw cw-root : $(CW_ROOT) ; |
---|
17 | |
---|
18 | cw-root ?= $(CWFolder) ; |
---|
19 | cw-root ?= $(CWFOLDER) ; |
---|
20 | |
---|
21 | if $(NT) |
---|
22 | { |
---|
23 | for local v in 9.0 8.0 7.0 6.0 |
---|
24 | { |
---|
25 | cw-root-$(v) ?= [ W32_GETREG "HKEY_LOCAL_MACHINE\\SOFTWARE\\Metrowerks\\CodeWarrior for Windows\\$(v)" : "PATH" ] ; |
---|
26 | cw-version ?= [ conditional $(cw-root-$(v)) : $(v) ] ; |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | cw-root ?= $(cw-root-$(cw-version)) ; |
---|
31 | |
---|
32 | flags cw CFLAGS <cflags> ; |
---|
33 | flags cw C++FLAGS <cxxflags> ; |
---|
34 | flags cw DEFINES <define> ; |
---|
35 | flags cw UNDEFS <undef> ; |
---|
36 | flags cw HDRS <include> ; |
---|
37 | flags cw SYSHDRS <sysinclude> ; |
---|
38 | flags cw LINKFLAGS <linkflags> ; |
---|
39 | flags cw ARFLAGS <arflags> ; |
---|
40 | flags cw LIBPATH <library-path> ; |
---|
41 | flags cw NEEDLIBS <library-file> ; |
---|
42 | flags cw FINDLIBS <find-library> ; |
---|
43 | flags cw PREFIX <prefix> ; |
---|
44 | if $(OS) = MACOSX |
---|
45 | { |
---|
46 | flags cw FRAMEWORKS <framework> ; |
---|
47 | } |
---|
48 | |
---|
49 | flags cw cw-errors <errors> ; |
---|
50 | flags cw cw-warnings <warnings> ; |
---|
51 | |
---|
52 | # Debug information |
---|
53 | flags cw CFLAGS <debug-symbols>on : -g ; |
---|
54 | flags cw LINKFLAGS <debug-symbols>on : -g ; |
---|
55 | |
---|
56 | # Optimizations |
---|
57 | flags cw CFLAGS <optimization>off : -O0 ; |
---|
58 | flags cw CFLAGS <optimization>speed : -opt full ; |
---|
59 | flags cw CFLAGS <optimization>space : -O4,s "-opt intrinsics" ; |
---|
60 | |
---|
61 | flags cw CFLAGS <inlining>off : -inline off ; |
---|
62 | flags cw CFLAGS <inlining>on : -inline on ; |
---|
63 | flags cw CFLAGS <inlining>full : -inline auto -inline level=8 ; |
---|
64 | |
---|
65 | # Target type |
---|
66 | flags cw LINKFLAGS <target-type>$(SHARED_TYPES) : -shared ; |
---|
67 | if $(NT) |
---|
68 | { |
---|
69 | flags cw LINKFLAGS <target-type>$(SHARED_TYPES) : "-export dllexport" ; |
---|
70 | } |
---|
71 | |
---|
72 | # Some language related options |
---|
73 | flags cw CFLAGS <eh-model>msvc : -exc ms ; |
---|
74 | flags cw CFLAGS <include-search>directory : "-cwd proj" ; |
---|
75 | flags cw CFLAGS <include-search>source : "-cwd source" ; |
---|
76 | flags cw CFLAGS <include-search>paths : "-cwd explicit" ; |
---|
77 | flags cw CFLAGS <include-search>relative : "-cwd include" ; |
---|
78 | flags cw C++FLAGS <rtti>off : "-RTTI off" ; |
---|
79 | flags cw C++FLAGS <rtti>on : "-RTTI on" ; |
---|
80 | # CodeWarrior on MacOS defaults to wchar_t support off, contrary |
---|
81 | # to what it does on Windows. So "fix" this discrepancy. Don't |
---|
82 | # bother with OS type just set this to on for all. After all it's |
---|
83 | # standard! |
---|
84 | flags cw CFLAGS : "-wchar_t on" ; |
---|
85 | |
---|
86 | # OS subsystem target |
---|
87 | if $(NT) |
---|
88 | { |
---|
89 | flags cw LINKFLAGS <user-interface>console : "-subsystem console" ; |
---|
90 | flags cw LINKFLAGS <user-interface>gui : "-subsystem windows" ; |
---|
91 | flags cw LINKFLAGS <user-interface>wince : "-subsystem wince" ; |
---|
92 | flags cw LINKFLAGS <user-interface>native : "-subsystem native" ; |
---|
93 | flags cw LINKFLAGS <user-interface>auto : "-subsystem auto" ; |
---|
94 | } |
---|
95 | |
---|
96 | # Errors, default to maximum 5 errors |
---|
97 | flags cw FLAGS : [ conditional $(cw-errors) : "-maxerrors $(cw-errors[1])" : "-maxerrors 5" ] ; |
---|
98 | |
---|
99 | # Warnings, default to maximum 20 warnings |
---|
100 | if off in $(cw-warnings) |
---|
101 | { |
---|
102 | flags cw FLAGS : "-warnings off" ; |
---|
103 | } |
---|
104 | else if error in $(cw-warnings) |
---|
105 | { |
---|
106 | flags cw FLAGS : "-warnings error" ; |
---|
107 | } |
---|
108 | else |
---|
109 | { |
---|
110 | flags cw FLAGS : "-warnings on" ; |
---|
111 | } |
---|
112 | if ! ( off in $(cw-warnings) ) |
---|
113 | { |
---|
114 | if [ MATCH "^([0-9]+)" : $(cw-warnings) ] |
---|
115 | { |
---|
116 | local cw-maxwarnings = [ MATCH "^([0-9]+)" : $(cw-warnings) ] ; |
---|
117 | cw-warnings = [ difference $(cw-warnings) : $(cw-maxwarnings) ] ; |
---|
118 | flags cw FLAGS : "-maxwarnings $(cw-maxwarnings[1])" ; |
---|
119 | } |
---|
120 | else |
---|
121 | { |
---|
122 | flags cw FLAGS : "-maxwarnings 20" ; |
---|
123 | } |
---|
124 | } |
---|
125 | cw-warnings = [ difference $(cw-warnings) : on off error ] ; |
---|
126 | if $(cw-warnings) |
---|
127 | { |
---|
128 | flags cw CFLAGS <warnings>no-illegal-pragmas : "-warnings nopragmas" ; |
---|
129 | flags cw CFLAGS <warnings>illegal-pragmas : "-warnings pragmas" ; |
---|
130 | flags cw CFLAGS <warnings>no-empty-declarations : "-warnings noempty" ; |
---|
131 | flags cw CFLAGS <warnings>empty-declarations : "-warnings empty" ; |
---|
132 | flags cw CFLAGS <warnings>no-empty-declarations : "-warnings noempty" ; |
---|
133 | flags cw CFLAGS <warnings>empty-declarations : "-warnings empty" ; |
---|
134 | flags cw CFLAGS <warnings>no-unwanted-effect : "-warnings nounwanted" ; |
---|
135 | flags cw CFLAGS <warnings>unwanted-effect : "-warnings unwanted" ; |
---|
136 | flags cw CFLAGS <warnings>no-unused-arg : "-warnings nounusedarg" ; |
---|
137 | flags cw CFLAGS <warnings>unused-arg : "-warnings unsedarg" ; |
---|
138 | flags cw CFLAGS <warnings>no-unused-var : "-warnings nounusedvar" ; |
---|
139 | flags cw CFLAGS <warnings>unused-var : "-warnings unsedvar" ; |
---|
140 | flags cw CFLAGS <warnings>no-extra-comma : "-warnings nocomma" ; |
---|
141 | flags cw CFLAGS <warnings>extra-comma : "-warnings comma" ; |
---|
142 | flags cw CFLAGS <warnings>no-pedantic : "-warnings nopedantic" ; |
---|
143 | flags cw CFLAGS <warnings>pedantic : "-warnings pedantic" ; |
---|
144 | flags cw CFLAGS <warnings>no-hidden-virtual : "-warnings nohidden" ; |
---|
145 | flags cw CFLAGS <warnings>hidden-virtual : "-warnings hidden" ; |
---|
146 | flags cw CFLAGS <warnings>no-implicit-convert : "-warnings noimplicit" ; |
---|
147 | flags cw CFLAGS <warnings>implicit-convert : "-warnings implicit" ; |
---|
148 | flags cw CFLAGS <warnings>no-not-inlined : "-warnings nonotinlined" ; |
---|
149 | flags cw CFLAGS <warnings>not-inlined : "-warnings notinlined" ; |
---|
150 | flags cw CFLAGS <warnings>no-inconsistent-class : "-warnings nostructclass" ; |
---|
151 | flags cw CFLAGS <warnings>inconsistent-class : "-warnings structclass" ; |
---|
152 | if $(NT) |
---|
153 | { |
---|
154 | flags cw CFLAGS <warnings>no-unused-expresssion : "-warnings nounusedexpr" ; |
---|
155 | flags cw CFLAGS <warnings>unused-expresssion : "-warnings unsedexpr" ; |
---|
156 | flags cw CFLAGS <warnings>no-structure-pad : "-warnings nopadding" ; |
---|
157 | flags cw CFLAGS <warnings>structure-pad : "-warnings padding" ; |
---|
158 | flags cw CFLAGS <warnings>no-unused-return : "-warnings nonotused" ; |
---|
159 | flags cw CFLAGS <warnings>unused-return : "-warnings notused" ; |
---|
160 | flags cw CFLAGS <warnings>no-pointer-conversion : "-warnings noptrintconv" ; |
---|
161 | flags cw CFLAGS <warnings>pointer-conversion : "-warnings ptrintconv" ; |
---|
162 | } |
---|
163 | } |
---|
164 | else |
---|
165 | { |
---|
166 | if $(NT) |
---|
167 | { |
---|
168 | flags cw CFLAGS : "-warnings nounusedexpr,nounused" ; |
---|
169 | } |
---|
170 | else |
---|
171 | { |
---|
172 | flags cw CFLAGS : "-warnings nounused" ; |
---|
173 | } |
---|
174 | } |
---|
175 | |
---|
176 | # Search for files in search paths |
---|
177 | flags cw LINKFLAGS : -search ; |
---|
178 | flags cw ARFLAGS : -search ; |
---|
179 | |
---|
180 | # Version specific options |
---|
181 | if $(cw-version) in 8.0 9.0 |
---|
182 | { |
---|
183 | # Use latest ISO conforming templates |
---|
184 | flags cw C++FLAGS : -iso_templates on ; |
---|
185 | |
---|
186 | if $(NT) |
---|
187 | { |
---|
188 | # The runtime libraries |
---|
189 | flags cw CFLAGS <runtime-link>static/<threading>single/<runtime-build>release : -runtime ss ; |
---|
190 | flags cw CFLAGS <runtime-link>static/<threading>single/<runtime-build>debug : -runtime ssd ; |
---|
191 | |
---|
192 | flags cw CFLAGS <runtime-link>static/<threading>multi/<runtime-build>release : -runtime sm ; |
---|
193 | flags cw CFLAGS <runtime-link>static/<threading>multi/<runtime-build>debug : -runtime smd ; |
---|
194 | |
---|
195 | flags cw CFLAGS <runtime-link>dynamic/<runtime-build>release : -runtime dm ; |
---|
196 | flags cw CFLAGS <runtime-link>dynamic/<runtime-build>debug : -runtime dmd ; |
---|
197 | } |
---|
198 | } |
---|
199 | if $(NT) && $(cw-version) in 6.0 7.0 8.0 |
---|
200 | { |
---|
201 | flags cw PREFIX <user-interface>console/<runtime-link>dynamic : UseDLLPrefix.h ; |
---|
202 | } |
---|
203 | if $(NT) && $(cw-version) in 7.0 |
---|
204 | { |
---|
205 | # The runtime libraries |
---|
206 | flags cw STDLIBS <runtime-link>static/<runtime-build>release : |
---|
207 | MSL_C_x86.lib MSL_Runtime_x86.lib msl_c++_x86.lib gdi32.lib user32.lib kernel32.lib ; |
---|
208 | flags cw STDLIBS <runtime-link>dynamic/<runtime-build>release : |
---|
209 | MSL_All-DLL_x86.lib gdi32.lib user32.lib kernel32.lib ; |
---|
210 | flags cw STDLIBS <runtime-link>static/<runtime-build>debug : |
---|
211 | MSL_C_x86_D.lib MSL_Runtime_x86_D.lib msl_c++_x86_D.lib gdi32.lib user32.lib kernel32.lib ; |
---|
212 | flags cw STDLIBS <runtime-link>dynamic/<runtime-build>debug : |
---|
213 | MSL_All-DLL_x86_D.lib gdi32.lib user32.lib kernel32.lib ; |
---|
214 | } |
---|
215 | if $(NT) && $(cw-version) in 6.0 |
---|
216 | { |
---|
217 | # The runtime libraries |
---|
218 | flags cw STDLIBS <runtime-link>static : |
---|
219 | ansicx86.lib mwcrtl.lib ansicppx86.lib gdi32.lib user32.lib kernel32.lib ; |
---|
220 | flags cw STDLIBS <runtime-link>dynamic : |
---|
221 | mwcrtldll.lib gdi32.lib user32.lib kernel32.lib ; |
---|
222 | } |
---|
223 | |
---|
224 | # The paths to system and runtime libraries |
---|
225 | if $(NT) |
---|
226 | { |
---|
227 | flags cw CW_SETUP : "call \"$(cw-root)\\Other Metrowerks Tools\\Command Line Tools\\cwenv.bat\" -quiet" ; |
---|
228 | # This is needed after the setup because the CW-9 setup erronously sets the |
---|
229 | # ERRORLEVEL pseudo-var directly overriding the real value. The aregument is |
---|
230 | # quoted to prevent the value from getting set to " " because bjam insertes |
---|
231 | # extra spaces at the end of action commands. |
---|
232 | flags cw CW_CLEAR_ERROR : "set \"ERRORLEVEL=\"" ; |
---|
233 | flags cw CW_LINK_SETUP : "set MWWinx86LibraryFiles=" ; |
---|
234 | flags cw CW_IMPLIB_COMMAND : "-implib " ; |
---|
235 | flags cw CW_RUN_PATH : |
---|
236 | "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime" |
---|
237 | "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs\\MSL_All-DLLs" ; |
---|
238 | |
---|
239 | flags cw STDLIBPATH : "$(cw-root)\\Win32-x86 Support\\Libraries\\Win32 SDK" ; |
---|
240 | flags cw STDLIBPATH <runtime-link>static : "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs" ; |
---|
241 | flags cw STDLIBPATH <runtime-link>dynamic : "$(cw-root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs\\MSL_All-DLLs" ; |
---|
242 | } |
---|
243 | |
---|
244 | # Don't wrap tool messages, they just confuse everyone :-) |
---|
245 | flags cw FLAGS : -nowraplines ; |
---|
246 | |
---|
247 | flags cw CW_PREFIX : "-prefix " ; |
---|
248 | |
---|
249 | # CodeWarrior has it's own set of standard headers, so ignore the default. |
---|
250 | flags cw STDHDRS : ; |
---|
251 | |
---|
252 | # MacOSX.. only the MSL/Carbon/Mach-O combination is working. |
---|
253 | if $(OS) = MACOSX |
---|
254 | { |
---|
255 | # We use the compiler for both compiles and link, because we may need |
---|
256 | # to compile the console stubs source. The compiler passes all options |
---|
257 | # down to the linker anyway. |
---|
258 | flags cw MWCC : mwcc ; |
---|
259 | flags cw MWLD : mwcc ; |
---|
260 | # For Carbon we need this prefix file to tell CW that's what we are targetting. |
---|
261 | flags cw PREFIX : MSLCarbonPrefix.h ; |
---|
262 | # We need to add the framework, as it's not added automatically. |
---|
263 | flags cw FRAMEWORKS : Carbon ; |
---|
264 | # For comsole apps we need to compile in the MSL functions that will |
---|
265 | # talk to the MacOSX console. |
---|
266 | flags cw LINKFLAGS <user-interface>console : |
---|
267 | "-prefix MSLCarbonPrefix.h" |
---|
268 | "\"$(CWINSTALL)/MSL/MSL_C/MSL_MacOS/Src/console_OS_X.c\"" ; |
---|
269 | } |
---|
270 | |
---|
271 | if $(NT) |
---|
272 | { |
---|
273 | flags cw MWCC : mwcc ; |
---|
274 | flags cw MWLD : mwld ; |
---|
275 | } |
---|
276 | |
---|
277 | #~ flags cw CFLAGS : -verbose ; |
---|
278 | #~ flags cw LINKFLAGS : -verbose ; |
---|
279 | |
---|
280 | #### Link #### |
---|
281 | rule Link-action |
---|
282 | { |
---|
283 | _ on $(<) = " " ; |
---|
284 | gRUN_PATH($(<)) += $(CW_RUN_PATH) ; |
---|
285 | if $(NT) |
---|
286 | { |
---|
287 | # We can't have the mixture of the same libs going in NEEDLIBS and FINDLIBS. |
---|
288 | # So remove the extras from FINDLIBS. |
---|
289 | local find-libs = |
---|
290 | [ difference |
---|
291 | [ on $(<[1]) return $(FINDLIBS) ] : |
---|
292 | $(gTARGET_BASENAME($(gTARGET_SUBVARIANT($(NEEDLIBS))))) ] ; |
---|
293 | FINDLIBS on $(<) = $(find-libs)$(SUFLIB) ; |
---|
294 | |
---|
295 | CMD on $(<) = "@" ; |
---|
296 | with-command-file cw-Link-action $(<) : $(>) $(NEEDLIBS) $(NEEDIMPS) ; |
---|
297 | } |
---|
298 | else if $(OS) = MACOSX |
---|
299 | { |
---|
300 | local find-libs = [ on $(<[1]) return $(FINDLIBS) ] ; |
---|
301 | FINDLIBS on $(<) = -l$(find-libs) ; |
---|
302 | |
---|
303 | CMD on $(<) = "" ; |
---|
304 | cw-Link-action $(<) : $(>) $(NEEDLIBS) $(NEEDIMPS) ; |
---|
305 | } |
---|
306 | } |
---|
307 | |
---|
308 | actions cw-Link-action |
---|
309 | { |
---|
310 | $(CW_SETUP) |
---|
311 | $(CW_CLEAR_ERROR) |
---|
312 | $(CW_LINK_SETUP)$(STDLIBS:J=;) |
---|
313 | $(MWLD) $(FLAGS) $(LINKFLAGS) "-L$(LIBPATH)" "-L$(STDLIBPATH)" -framework$(_)"$(FRAMEWORKS)" $(CW_IMPLIB_COMMAND)"$(<[2])" -o "$(<[1])" $(CMD)"$(>)" "$(FINDLIBS)" |
---|
314 | } |
---|
315 | |
---|
316 | #### Cc ##### |
---|
317 | rule Cc-action |
---|
318 | { |
---|
319 | _ on $(<) = " " ; |
---|
320 | cw-Cc-action $(<) : $(>) ; |
---|
321 | } |
---|
322 | |
---|
323 | actions cw-Cc-action |
---|
324 | { |
---|
325 | $(CW_SETUP) |
---|
326 | $(CW_CLEAR_ERROR) |
---|
327 | $(MWCC) -c -lang c -U$(UNDEFS) -D$(DEFINES) $(FLAGS) $(CFLAGS) "-I$(HDRS)" -I-$(_)"-I$(STDHDRS)" -I-$(_)"-I$(SYSHDRS)" $(CW_PREFIX)"$(PREFIX)" -o "$(<)" "$(>)" |
---|
328 | } |
---|
329 | |
---|
330 | #### C++ #### |
---|
331 | rule C++-action |
---|
332 | { |
---|
333 | _ on $(<) = " " ; |
---|
334 | cw-C++-action $(<) : $(>) ; |
---|
335 | } |
---|
336 | |
---|
337 | actions cw-C++-action |
---|
338 | { |
---|
339 | $(CW_SETUP) |
---|
340 | $(CW_CLEAR_ERROR) |
---|
341 | $(MWCC) -c -lang c++ -U$(UNDEFS) -D$(DEFINES) $(FLAGS) $(CFLAGS) $(C++FLAGS) "-I$(HDRS)" -I-$(_)"-I$(STDHDRS)" -I-$(_)"-I$(SYSHDRS)" $(CW_PREFIX)"$(PREFIX)" -o "$(<)" "$(>)" |
---|
342 | } |
---|
343 | |
---|
344 | #### Archive #### |
---|
345 | rule Archive-action |
---|
346 | { |
---|
347 | _ on $(<) = " " ; |
---|
348 | if $(NT) |
---|
349 | { |
---|
350 | local find-libs = [ on $(<[1]) return $(FINDLIBS) ] ; |
---|
351 | FINDLIBS on $(<) = $(find-libs)$(SUFLIB) ; |
---|
352 | |
---|
353 | CMD on $(<) = "@" ; |
---|
354 | with-command-file cw-Archive-action $(<) : $(>) [ on $(<) return $(NEEDLIBS) ] ; |
---|
355 | } |
---|
356 | else if $(OS) = MACOSX |
---|
357 | { |
---|
358 | local find-libs = [ on $(<[1]) return $(FINDLIBS) ] ; |
---|
359 | FINDLIBS on $(<) = -l$(find-libs) ; |
---|
360 | |
---|
361 | CMD on $(<) = "" ; |
---|
362 | cw-Archive-action $(<) : $(>) [ on $(<) return $(NEEDLIBS) ] ; |
---|
363 | } |
---|
364 | } |
---|
365 | |
---|
366 | ## CW in general doesn't produce archive that ranlib is intereted in. So |
---|
367 | ## don't run ranlib. |
---|
368 | rule Ranlib-action |
---|
369 | { |
---|
370 | } |
---|
371 | |
---|
372 | actions together cw-Archive-action |
---|
373 | { |
---|
374 | $(CW_SETUP) |
---|
375 | $(CW_CLEAR_ERROR) |
---|
376 | $(MWLD) -library $(FLAGS) $(ARFLAGS) "-L$(LIBPATH)" "-L$(STDLIBPATH)" -o "$(<)" $(CMD)"$(>)" "$(FINDLIBS)" |
---|
377 | } |
---|