Subversion Repositories DevTools

Rev

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