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