Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: mak; -*-
2
###############################################################################
3
# File:         TOOLSET/vcwce.rul[e]
4
# Contents:     eMbedded C++ rules
5
#
6
# Version   Who      Date        Description#
7
#           APY      26/04/04    Created
8
#
9
# $Source: /cvsroot/etm/devl/CFG/TOOLSET/VCWCE.RUL,v $
10
# $Revision: 1.8 $ $Date: 2004/06/29 06:40:24 $ $State: Exp $
11
# $Author: ayoung $ $Locker:  $
12
#............................................................................#
13
 
14
###############################################################################
15
#..     Remove "undef" warnings
16
#
17
cc_includes	+=
18
cc_defines	+=
19
cxx_includes	+=
20
cxx_defines	+=
21
 
22
###############################################################################
23
#..     Parse user options
24
#       Global options already parsed
25
#       These options extend the global options
26
#
27
 
28
ifdef OPTIONS
29
 
30
ifneq "$(findstring purify,$(OPTIONS))" ""	# Enable purify
31
else
32
ifneq "$(findstring purecov,$(OPTIONS))" ""	# Enable pure coverage
33
endif
34
endif
35
 
36
ifneq "$(findstring ignoreenv,$(OPTIONS))" ""	# Ignore WCE_LIB and WCE_INCLUDE vars
37
IGNOREENV	= 1
38
endif
39
 
40
ifneq "$(findstring ccdepend,$(OPTIONS))" ""	# Build depends using CC
41
endif
42
 
43
ifneq "$(findstring wall,$(OPTIONS))" ""	# Enable all warnings
44
USE_WALL	= 1
45
endif
46
 
47
ifneq "$(findstring gensbr,$(OPTIONS))" ""     # Generate Source Browser Files
48
GEN_SBR_FILES	= 1
49
endif
50
 
51
endif
52
 
53
###############################################################################
54
#..     Compiler definitions
55
#
56
 
57
#..     C Compiler definition
58
#
59
 
60
	# Standard defines
61
	#
62
	#..
63
vc_defines	+= -DUNDER_CE=$(WCE_VERSION) -D_WIN32_WCE=$(WCE_VERSION) -D$(WCE_PLATFORM_SDK_DEF)
64
vc_defines	+= -D "$(WCE_PLATFORM)" -D "$(WCE_TARGETCPU)"
65
 
66
ifdef WCE_DEFINES
67
vc_defines	+= $(WCE_DEFINES)
68
endif
69
 
70
vc_defines	+= -D "UNICODE" -D "_UNICODE"
71
 
72
ifdef ALVL
73
vc_defines	+= -DALVL=$(ALVL)
74
endif
75
 
76
ifdef DLVL
77
vc_defines	+= -DDLVL=$(DLVL)
78
endif
79
 
267 dpurdie 80
#
81
#	__SOURCE__ interferes with Windows Precompiled headers
82
#	It can be disabled, but its not for backward compatability
83
#
84
ifndef DISABLE__SOURCE__
227 dpurdie 85
vc_defines	+= -D__SOURCE__=\"$(notdir $<)\"
267 dpurdie 86
endif
227 dpurdie 87
 
88
	# Standard flags
89
	#
90
	# Both compilers now use the same front end - you must still define either
91
	# _X86_ or _ALPHA_.  These have replaced the i386 and ALPHA definitions
92
	# which are not ANSI compliant.
93
	#
94
	# Common compiler flags:
95
	#   -c   - compile without linking
96
	#   -W3  - Set warning level to level 3
97
	#   -Zi  - generate debugging information
98
	#   -Zd  - generate only public symbols and line numbers for debugging
99
	#   -Od  - disable all optimizations
100
	#   -Ox  - use maximum optimizations
101
	#   -Ge  - enable stack checks
102
	#   -GZ  - enable runtime debug checks
103
	#   -Gm  - enable min builds
104
	#   -GX  - enable C++ EH (same as /EHsc)
105
	#   -YX  - generate precompiled headers
106
	#   -Yd  - Place debug info within objects.
107
	#   -GF  - enable read-only string pooling
108
	# Output options:
109
	#   -Fo<file>      name object file
110
	#   -Fp<file>      name precompiled header file
111
	#   -Fd[file]      name .PDB file
112
	#   -Fm[file]      name map file
113
	#   -FR[file]      name source browser file (Complete)
114
	#   -Fr[file]      name source browser file (No locals)
115
	#
116
	# i386 specific compiler flags:
117
	#   -Gz  - stdcall
118
	#   -Gd  - cdecl
119
	#
120
	# Plus:
121
	#   -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl
122
	#   _X86_ | _MIPS_ | _PPC_
123
	#   WINNT | WIN95
124
	#   WINVER=0x0500 (5.0) | WINVER=0x0400 (4.0) | WINVER=0x030A (3.51)
125
	#   _MT
126
	#
127
	# Linker
128
	#   -MT[d]  using MT safe C library
129
	#
130
	# ! Warning !
131
	#   If you are going to call C run-time routines from a program
132
	#   built with LIBCMT.LIB, you must start your threads with the
133
	#   _beginthread function.  Do not use the Win32 functions
134
	#   ExitThread and CreateThread.  Using SuspendThread can lead to
135
	#   a deadlock when more than one thread is blocked waiting for
136
	#   the suspend thread to complete its access to a C run-time
137
	#   data structure.
138
	#..
139
vc_flags	+= -c
140
vc_flags	+= -nologo
141
ifdef USE_WALL
142
vc_flags	+= -W4
143
else
144
vc_flags	+= -W3
145
endif
146
 
147
ifdef WCE_CFLAGS
148
vc_flags	+= $(WCE_CFLAGS)
149
endif
150
 
151
vc_compile_flags = -TC          # Force C unless otherwise demanded
152
ifdef FORCE_C_COMPILE
153
vc_compile_flags = -TC
154
endif
155
 
156
ifdef FORCE_CC_COMPILE
157
vc_compile_flags = -TP
158
endif
159
 
160
ifdef USE_OPTIMISE				# default for production
161
vc_flags	+= -Od              # Don't optimise production code. Too many problems. Ship what we test
162
else
163
vc_flags	+= -Od
164
endif
165
 
166
ifdef USE_DEBUGINFO				# default for debug
167
vc_defines	+= -DDEBUG
168
else
169
vc_flags	+=
170
endif
171
 
172
ifdef LEAVETMP                  # Create an assembly listing
173
vc_flags       += -FAs  -Fa$(subst /,\\,$(basename $@).src)
174
endif
175
 
176
ifeq "$(DEBUG)" "1"				# debug/prod specific
177
vc_defines	+= -D_DEBUG
178
ifdef WCE_CFLAGSD
179
vc_flags	+= $(WCE_CFLAGSD)
180
endif
181
else
182
vc_defines	+= -DNDEBUG
183
ifdef WCE_CFLAGSP
184
vc_flags	+= $(WCE_CFLAGSP)
185
endif
186
endif
187
 
188
ifdef USE_STRICT_ANSI				# default OFF
189
vc_flags	+= -Za
190
else
191
vc_flags	+=
192
endif
193
 
194
ifdef USE_RTTI
195
vc_flags	+= -GR
196
endif
197
 
198
ifndef PDB_NONE                 # Supress PDB generation
199
vc_flags	+= -Zi
200
endif
201
vc_flags	+= -YX
202
vc_flags	+= -Fp$(subst /,\\,$(OBJDIR)/)
203
vc_flags	+= -Fd$(subst /,\\,$(PDB))
204
 
205
ifdef GEN_SBR_FILES
206
vc_flags	+= -FR$(subst /,\\,$(basename $@).sbr)
207
endif
208
 
209
SHCFLAGS	+=
210
SHCXXFLAGS	+=
211
ifeq "\$(WCE_CC)" "cl"
212
SHCFLAGS	+= -GD
213
SHCXXFLAGS	+= -GD
214
endif
215
 
216
	# Standard includes
217
	#
218
	#..
219
ifndef IGNOREENV
220
ifdef WCE_INCLUDE
221
vc_includes	=\
222
		$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(WCE_INCLUDE))))
223
endif
224
endif
225
ifndef vc_includes
226
vc_includes	=\
227
		$(sdkroot)/Include/$(WCE_TARGETCPU)\
228
		$(sdkroot)/MFC/Include\
229
		$(sdkroot)/ATL/Include
230
WCE_INCLUDE	=
231
export WCE_INCLUDE	# Zap env image
232
endif
233
ifdef MSVCDir
234
INCLUDE		=
235
export INCLUDE		# Dual installtion, clean env
236
endif
237
 
238
	# Command
239
	#
240
	#..
241
cc		= $(CC_PRE) $(WCE_CC)
242
cc_init 	=
243
cc_o_switch	= $(subst /,\\,-Fo$@)
244
cc_source	= $(subst /,\\,$<)
245
cc_flags	= \
246
		$(strip $(vc_compile_flags)) \
247
		$(strip $(patsubst %,%,$(vc_flags))) \
248
		$(strip $(patsubst %,%,$(vc_defines))) \
249
		$(patsubst %,%,$(CFLAGS)) \
250
		$(patsubst %,-D%,$(cc_defines)) \
251
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(INCDIRS)))) \
252
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(cc_includes)))) \
253
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(vc_includes))))
254
cc_term		=
255
 
256
define cc_pre
257
	@$(echo) [$<] compiling..;
258
endef
259
 
260
define cc_post
261
endef
262
 
263
cc_filter	:= "$(notdir $(wildcard $(GBE_ROOT)/warnings.vcembedded))"
264
ifeq ($(strip $(cc_filter)), "warnings.vcembedded")
265
cc_filter	= $(GBE_ROOT)/warnings.vcembedded
266
else
267
cc_filter	=
268
endif
269
 
270
ifdef cc_filter
271
cc_redirect_stderr = 1
272
cc_error_filter = $(awk) -f $(cc_filter)
273
endif
274
 
275
 
276
###############################################################################
277
#..     C/C++ dependencies
278
#       depend and depend.err
279
#
280
vc_depend	+= -D_MSC_VER=1200
281
vc_depend	+= -DWIN32 -D_WIN32
282
vc_depend	+= -D_M_CEE
283
 
284
ccdep		= $(XX_PRE) $(GBE_BIN)/mkdepend
285
ccdep_init	=
286
ccdep_o_switch	= -f -
287
ccdep_source	= $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err
288
ccdep_flags	= -MM -b -We -p '$$(OBJDIR)/' \
289
		$(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
290
		-o ".$(o)" \
291
		$(patsubst %,%,$(vc_depend)) \
292
		$(patsubst %,%,$(vc_defines)) \
293
		$(patsubst %,%,$(CFLAGS)) \
294
		$(patsubst %,%,$(CXXFLAGS)) \
295
		$(patsubst %,-D%,$(cc_defines)) \
296
		$(patsubst %,-D%,$(cxx_defines)) \
297
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(INCDIRS)))) \
298
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(cc_includes)))) \
299
		$(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(subst /,\,$(vc_includes)))) \
300
		$(patsubst %,-Y %,$(NODEPDIRS))
301
 
302
ccdep_pre	=
303
ccdep_post	=
304
 
305
#..     C/C++ Lint definitions
306
#       -D Definition is not allowed: PCLINT does not like the space
307
#
308
lint_flags	+= \
309
	$(patsubst %,%,$(vc_depend)) \
310
	$(subst -D$(space),-D,$(patsubst %,%,$(vc_defines))) \
311
	$(patsubst %,%,$(CLINTFLAGS)) \
312
	$(patsubst %,-D%,$(cc_defines)) \
313
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(INCDIRS))) \
314
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(cc_includes))) \
315
	$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(vc_includes)))
316
 
317
lint_libpath	= $(VC_LIB)
318
 
319
#..     C++ Compiler definitions
320
#
321
cxx		= $(CC_PRE) $(WCE_CC)
322
cxx_init	=
323
cxx_o_switch	= $(subst /,\\,-Fo$@)
324
cxx_source	= $(subst /,\\,$<)
325
cxx_flags	= -TP \
326
		$(patsubst %,%,$(vc_flags)) \
327
		$(patsubst %,%,$(vc_defines)) \
328
		$(patsubst %,%,$(CXXFLAGS)) \
329
		$(patsubst %,-D%,$(cxx_defines)) \
330
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(INCDIRS)))) \
331
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(cxx_includes)))) \
332
		$(subst $(spacealt),$(space),$(patsubst %,-I"%",$(subst /,\,$(vc_includes))))
333
cxx_term	=
334
 
335
define cxx_pre
336
	@echo [$<] compiling..;
337
endef
338
 
339
define cxx_post
340
endef
341
 
342
 
343
###############################################################################
344
#..     Assembler definition
345
#
346
 
347
#..     Assembler (Microsoft 6.11)
348
#
349
as		= $(XX_PRE) ml
350
as_init 	=
351
as_i_switch	= /I
352
as_o_switch	= /Fo$(subst /,\\,$@)
353
as_source	= $(subst /,\\,$<)
354
as_cmdfile	= $(subst /,\\,$(basename $@).cmd)
355
as_flags	= @$(as_cmdfile)
356
as_term		=
357
 
358
as_includes	+= $(masm)/include
359
as_defines	+=
360
 
361
ml_flags	= /c /Zm /Cp /X
362
ifeq "$(DEBUG)" "1"
363
ml_flags	+= /W2 /Zd /DDEBUG
364
endif
365
ifdef DLVL
366
ml_flags	+= /DDLVL=$(DLVL)
367
endif
368
ifdef ALVL
369
ml_flags	+= /DALVL=$(ALVL)
370
endif
371
as_defines	:= $(addprefix /D,$(as_defines))
372
as_defines	+= $(ml_flags)
373
 
374
define as_pre
375
	@$(cmdfile) -wkWeo$(as_cmdfile) "\
376
		$(patsubst %,%\\n,$(ASFLAGS)) \
377
		$(patsubst %,%\\n,$(as_defines)) \
378
		$(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(INCLUDES))) \
379
		$(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(as_includes)))"
380
endef
381
 
382
ifndef LEAVETMP
383
define as_post
384
	@$(rm) -f $(as_cmdfile)
385
endef
386
else
387
define as_post
388
endef
389
endif
390
 
391
 
392
###############################################################################
393
#..     Archiver definition
394
#
395
 
396
#..     Archiver
397
#       Need to set up LIB to allow the librarian to locate libraries
398
#       This feature is needed when building DLL stub libraries
399
#
400
#
401
ar		= $(XX_PRE)export LIB; LIB="$(VC_LIB)"; lib
402
ar_init 	=
403
ar_flags	= -nologo $(WCE_LIBFLAGS)
404
ifeq "$(DEBUG)" "1"
405
ar_flags	+= -debugtype:cv
406
endif
407
 
408
LIBDEF		+=
409
ar_flags	+= $(patsubst %,-def:%,$(LIBDEF))
410
LIBNAME     +=
411
ar_flags	+= $(patsubst %,-name:%,$(LIBNAME))
412
ar_o_switch	= -out:$(subst /,\\,$@) $(subst /,\\,$(filter %.obj,$^)) $(subst /,\\,$(filter %.res,$^))
413
ar_term		=
414
 
415
define ar_pre
416
	echo [$@] Building library ..;
417
endef
418
 
419
define ar_post
420
endef
421
 
422
 
423
#..     Archive Merge
424
#
425
armerge		= $(XX_PRE) $(GBE_TOOLS)/armerge
426
armerge_init	=
427
armerge_cmdfile =
261 dpurdie 428
armerge_flags	= -d $(MLIBDIR) -t MSVC
227 dpurdie 429
armerge_o_switch= $(subst /,\\,$@) $(subst /,\\,$^)
430
 
431
define armerge_pre
432
	-echo [$@] Merging library ..; $(rm) -f $@
433
endef
434
armerge_post	=
435
 
436
 
437
###############################################################################
438
#..     Linker
439
#
440
 
441
	# Standard library paths
442
	#
443
	#..
444
ifndef IGNOREENV
445
ifdef WCE_LIB
446
vc_libs		=\
447
		$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(WCE_LIB))))
448
endif
449
endif
450
ifndef vc_libs
451
ifdef WCE_EMULATOR
452
vc_libs		=\
453
		$(sdkroot)/Lib/$(WCE_TARGETCPU)\
454
		$(sdkroot)/MFC/Lib/$(WCE_HOSTCPU)\
455
		$(sdkroot)/ATL/Lib/$(WCE_HOSTCPU)
456
else
457
vc_libs		=\
458
		$(sdkroot)/Lib/$(WCE_TARGETCPU)\
459
		$(sdkroot)/MFC/Lib/$(WCE_TARGETCPU)\
460
		$(sdkroot)/ATL/Lib/$(WCE_TARGETCPU)
461
endif
462
WCE_LIB		=
463
export WCE_LIB		# Zap env image
464
endif
465
ifdef MSVCDir
466
LIB		=
467
export LIB		# Dual installation, clean env
468
endif
469
 
470
ALL_LIBDIRS = $(LIBDIRS);$(vc_libs)
471
VC_LIB		=\
472
		$(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,%;,$(subst /,\,$(ALL_LIBDIRS)))))
473
 
474
	# Standard flags
475
	#
476
	#..
477
vc_ldflags	= \
478
		-nologo\\n\
479
		-incremental:no\\n\
480
		-debug:full\\n
481
 
482
ifdef WCE_LDFLAGS				# Platform specific
483
vc_ldflags	+= $(patsubst %,%\\n,$(WCE_LDFLAGS))              
484
endif
485
 
486
ifeq "$(DEBUG)" "1"				# debug/prod specific                         
487
ifdef WCE_LDFLAGSD
488
vc_ldflags	+= $(patsubst %,%\\n,$(WCE_LDFLAGSD))
489
endif
490
else
491
ifdef WCE_LDFLAGSP
492
vc_ldflags	+= $(patsubst %,%\\n,$(WCE_LDFLAGSP))
493
endif
494
endif
495
 
496
vc_ldflags	+= \
497
		$(subst $(spacealt),$(space),$(patsubst %,-libpath:\"%\"\\n,$(subst /,\\\\,$(LIBDIRS))))\
498
		$(subst $(spacealt),$(space),$(patsubst %,-libpath:\"%\"\\n,$(subst /,\\\\,$(vc_libs))))\
499
		$(patsubst %,-%\\n,$(LDFLAGS))
500
 
501
 
502
#..     Shared library (dll)
503
#
504
 
505
shld		= $(CC_PRE) link
506
shld_cmdfile	= $(subst /,\\,$(basename $@).ld)
507
shld_flags	=
508
shld_o_switch	= @$(shld_cmdfile)
509
shld_term	=
510
 
511
define shld_pre
512
	@export VC_LIB; VC_LIB="$(VC_LIB)"; \
513
	$(cmdfile) -wkWeo$(shld_cmdfile) \
514
		"$(vc_ldflags) $($(notdir $(SHBASE))_shld)"; \
515
	echo [$@] Linking shared library ..;
516
endef
517
 
518
ifndef LEAVETMP
519
define shld_post
520
	@$(rm) -f $(shld_cmdfile)
521
endef
522
else
523
define shld_post
524
endef
525
endif
526
 
527
define SHLDDEPEND
528
	@export VC_LIB; VC_LIB="$(VC_LIB)"; \
529
	$(cmdfile) -wkWeo$(@) \
530
		"$($(notdir $(SHNAME))_shdp)";
531
endef
532
 
533
#..      Application
534
#
535
 
536
ld		= $(CC_PRE) link
537
ld_cmdfile	= $(subst /,\\,$(basename $@).ld)
538
ld_depfile	= $(subst /,\\,$(basename $@).dep)
539
ld_flags	=
540
ld_o_switch	= @$(ld_cmdfile)
541
ld_term		=
542
 
543
define ld_pre
544
	@export VC_LIB; VC_LIB="$(VC_LIB)"; \
545
	$(cmdfile) -wkWeo$(ld_cmdfile) \
546
		"$(vc_ldflags) $($(notdir $(basename $@))_ld)"; \
547
	echo [$@] Linking application ..
548
endef
549
 
550
ifndef LEAVETMP
551
define ld_post
552
	@$(rm) -f $(ld_cmdfile)
553
endef
554
else
555
define ld_post
556
endef
557
endif
558
 
559
define LDDEPEND
560
	@export VC_LIB; VC_LIB="$(VC_LIB)"; \
561
	$(cmdfile) -wkWeo$(ld_depfile) \
562
		"$($(notdir $(basename $@))_dp)";
563
endef
564
 
565
#.. Resource Compiler
566
#   Convert a .rc file into a .res file
567
#       Set up the INCLUDE envar to conatin the path to locate required
568
#       files and the local and interface directories then the compiler directories
569
#
570
#       Currently RC has a limit of 100 include paths to seach
571
#       Simply limit the list to the system paths and the directories
572
#       required by the prerequisite files
573
#
574
rc_defines = $(subst -D,/d ,$(vc_defines))
575
rc_dirs = $(subst /,\,$(sort $(dir $^)))
576
rc_dirs += $(LINCDIRS)
577
rc_dirs += $(vc_includes)
578
rc_include = $(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,%;,$(subst /,\,$(rc_dirs)))))
579
rc_include1 = $(subst \;,;,$(rc_include))
580
 
581
define RC
582
	@$(echo) [$@] Compile Resource File ..
583
	@$(show_environment)
584
	$(XX_PRE) export INCLUDE; INCLUDE="$(rc_include1)"; \
585
	RC /l 0xC09 $(rc_defines) /fo $(subst /,\\,$@) $(subst /,\\,$<)
586
endef
587
 
588
#.. Browser Information
589
#   Create a .BSC file from many .SBR files
590
#   Filter out non .SBR files to assist in rule creation
591
#
592
define BSCMAKE
593
	@$(echo) [$@] Create Source Browser Information ..
594
	@$(show_environment)
595
	$(XX_PRE) bscmake -nologo -n -o $(subst /,\\,$@) $(subst /,\\,$(filter %.sbr,$^))
596
endef
597
 
598
#