Subversion Repositories DevTools

Rev

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