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
###############################################################################
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
 
277
ifndef PDB_NONE                 # Supress PDB generation
278
vc_flags	+= -Zi
279
endif
303 dpurdie 280
vc_flags	+= $(call select_co,-YX,--)
227 dpurdie 281
vc_flags	+= -Fp$(subst /,\\,$(OBJDIR)/)
282
vc_flags	+= -Fd$(subst /,\\,$(PDB))
283
 
284
ifdef GEN_SBR_FILES
285
vc_flags	+= -FR$(subst /,\\,$(basename $@).sbr)
286
endif
287
 
288
SHCFLAGS	+=
289
SHCXXFLAGS	+=
290
ifeq "\$(WCE_CC)" "cl"
291
SHCFLAGS	+= -GD
292
SHCXXFLAGS	+= -GD
293
endif
294
 
303 dpurdie 295
# Command
296
#
297
#..
227 dpurdie 298
cc		= $(CC_PRE) $(WCE_CC)
299
cc_init 	=
300
cc_o_switch	= $(subst /,\\,-Fo$@)
301
cc_source	= $(subst /,\\,$<)
302
cc_flags	= \
303
		$(strip $(vc_compile_flags)) \
304
		$(strip $(patsubst %,%,$(vc_flags))) \
305
		$(strip $(patsubst %,%,$(vc_defines))) \
306
		$(patsubst %,%,$(CFLAGS)) \
307
		$(patsubst %,-D%,$(cc_defines)) \
303 dpurdie 308
                $(call decodepath,-I","$(spacealt),$(INCLUDE_LIST))
227 dpurdie 309
cc_term		=
310
 
311
define cc_pre
312
	@$(echo) [$<] compiling..;
313
endef
314
 
315
define cc_post
316
endef
317
 
318
cc_filter	:= "$(notdir $(wildcard $(GBE_ROOT)/warnings.vcembedded))"
319
ifeq ($(strip $(cc_filter)), "warnings.vcembedded")
320
cc_filter	= $(GBE_ROOT)/warnings.vcembedded
321
else
322
cc_filter	=
323
endif
324
 
325
ifdef cc_filter
326
cc_redirect_stderr = 1
327
cc_error_filter = $(awk) -f $(cc_filter)
328
endif
329
 
330
 
331
###############################################################################
332
#..     C/C++ dependencies
333
#       depend and depend.err
334
#
335
vc_depend	+= -D_MSC_VER=1200
336
vc_depend	+= -DWIN32 -D_WIN32
337
vc_depend	+= -D_M_CEE
338
 
339
ccdep		= $(XX_PRE) $(GBE_BIN)/mkdepend
340
ccdep_init	=
341
ccdep_o_switch	= -f -
342
ccdep_source	= $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err
343
ccdep_flags	= -MM -b -We -p '$$(OBJDIR)/' \
344
		$(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
345
		-o ".$(o)" \
346
		$(patsubst %,%,$(vc_depend)) \
347
		$(patsubst %,%,$(vc_defines)) \
348
		$(patsubst %,%,$(CFLAGS)) \
349
		$(patsubst %,%,$(CXXFLAGS)) \
350
		$(patsubst %,-D%,$(cc_defines)) \
351
		$(patsubst %,-D%,$(cxx_defines)) \
303 dpurdie 352
                $(call decodepath,-I","$(spacealt),$(INCDIRS) $(cc_includes)) \
353
                $(call decodepath,-Y","$(spacealt),$(vc_includes)) \
227 dpurdie 354
		$(patsubst %,-Y %,$(NODEPDIRS))
355
 
356
ccdep_pre	=
357
ccdep_post	=
358
 
359
#..     C/C++ Lint definitions
360
#       -D Definition is not allowed: PCLINT does not like the space
361
#
362
lint_flags	+= \
363
	$(patsubst %,%,$(vc_depend)) \
364
	$(subst -D$(space),-D,$(patsubst %,%,$(vc_defines))) \
365
	$(patsubst %,%,$(CLINTFLAGS)) \
366
	$(patsubst %,-D%,$(cc_defines)) \
303 dpurdie 367
        $(call decodepath,-I","$(spacealt),$(INCLUDE_LIST))
227 dpurdie 368
 
303 dpurdie 369
lint_libpath	= $(LIB)
227 dpurdie 370
 
371
#..     C++ Compiler definitions
372
#
373
cxx		= $(CC_PRE) $(WCE_CC)
374
cxx_init	=
375
cxx_o_switch	= $(subst /,\\,-Fo$@)
376
cxx_source	= $(subst /,\\,$<)
377
cxx_flags	= -TP \
378
		$(patsubst %,%,$(vc_flags)) \
379
		$(patsubst %,%,$(vc_defines)) \
380
		$(patsubst %,%,$(CXXFLAGS)) \
381
		$(patsubst %,-D%,$(cxx_defines)) \
303 dpurdie 382
                $(call decodepath,-I","$(spacealt),$(INCLUDE_LIST))
227 dpurdie 383
cxx_term	=
384
 
385
define cxx_pre
386
	@echo [$<] compiling..;
387
endef
388
 
389
define cxx_post
390
endef
391
 
392
 
393
###############################################################################
394
#..     Assembler definition
395
#
396
 
397
#..     Assembler (Microsoft 6.11)
398
#
399
as		= $(XX_PRE) ml
400
as_init 	=
401
as_i_switch	= /I
402
as_o_switch	= /Fo$(subst /,\\,$@)
403
as_source	= $(subst /,\\,$<)
404
as_cmdfile	= $(subst /,\\,$(basename $@).cmd)
405
as_flags	= @$(as_cmdfile)
406
as_term		=
407
 
408
as_includes	+= $(masm)/include
409
as_defines	+=
410
 
411
ml_flags	= /c /Zm /Cp /X
412
ifeq "$(DEBUG)" "1"
413
ml_flags	+= /W2 /Zd /DDEBUG
414
endif
415
ifdef DLVL
416
ml_flags	+= /DDLVL=$(DLVL)
417
endif
418
ifdef ALVL
419
ml_flags	+= /DALVL=$(ALVL)
420
endif
421
as_defines	:= $(addprefix /D,$(as_defines))
422
as_defines	+= $(ml_flags)
423
 
424
define as_pre
425
	@$(cmdfile) -wkWeo$(as_cmdfile) "\
426
		$(patsubst %,%\\n,$(ASFLAGS)) \
427
		$(patsubst %,%\\n,$(as_defines)) \
428
		$(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(INCLUDES))) \
303 dpurdie 429
		$(patsubst %,$(as_i_switch)%\\n,$(subst /,\\\\,$(as_includes)))";\
430
	        $(call show_cmdfile,$(as_cmdfile))
431
 
227 dpurdie 432
endef
433
 
434
ifndef LEAVETMP
435
define as_post
436
	@$(rm) -f $(as_cmdfile)
437
endef
438
else
439
define as_post
440
endef
441
endif
442
 
443
 
444
###############################################################################
445
#..     Archiver definition
446
#
447
 
448
#..     Archiver
449
#       Need to set up LIB to allow the librarian to locate libraries
450
#       This feature is needed when building DLL stub libraries
451
#
452
#
303 dpurdie 453
ar		= $(XX_PRE)lib
227 dpurdie 454
ar_init 	=
455
ar_flags	= -nologo $(WCE_LIBFLAGS)
456
ifeq "$(DEBUG)" "1"
305 dpurdie 457
ar_flags	+= $(call select_co,-debugtype:cv,--)
227 dpurdie 458
endif
459
 
460
LIBDEF		+=
461
ar_flags	+= $(patsubst %,-def:%,$(LIBDEF))
462
LIBNAME     +=
463
ar_flags	+= $(patsubst %,-name:%,$(LIBNAME))
464
ar_o_switch	= -out:$(subst /,\\,$@) $(subst /,\\,$(filter %.obj,$^)) $(subst /,\\,$(filter %.res,$^))
465
ar_term		=
466
 
467
define ar_pre
468
	echo [$@] Building library ..;
469
endef
470
 
471
define ar_post
472
endef
473
 
474
 
475
#..     Archive Merge
476
#
477
armerge		= $(XX_PRE) $(GBE_TOOLS)/armerge
478
armerge_init	=
479
armerge_cmdfile =
261 dpurdie 480
armerge_flags	= -d $(MLIBDIR) -t MSVC
227 dpurdie 481
armerge_o_switch= $(subst /,\\,$@) $(subst /,\\,$^)
482
 
483
define armerge_pre
484
	-echo [$@] Merging library ..; $(rm) -f $@
485
endef
486
armerge_post	=
487
 
488
 
489
###############################################################################
490
#..     Linker
491
#
492
 
493
	# Standard flags
494
	#
495
	#..
496
vc_ldflags	= \
497
		-nologo\\n\
303 dpurdie 498
		-incremental:no\\n
227 dpurdie 499
 
500
ifdef WCE_LDFLAGS				# Platform specific
501
vc_ldflags	+= $(patsubst %,%\\n,$(WCE_LDFLAGS))              
502
endif
503
 
504
ifeq "$(DEBUG)" "1"				# debug/prod specific                         
505
ifdef WCE_LDFLAGSD
506
vc_ldflags	+= $(patsubst %,%\\n,$(WCE_LDFLAGSD))
507
endif
508
else
509
ifdef WCE_LDFLAGSP
510
vc_ldflags	+= $(patsubst %,%\\n,$(WCE_LDFLAGSP))
511
endif
512
endif
513
 
514
vc_ldflags	+= \
303 dpurdie 515
		$(call decodepath,-libpath:\",\"\\n,$(LIB_LIST)) \
227 dpurdie 516
		$(patsubst %,-%\\n,$(LDFLAGS))
517
 
518
 
519
#..     Shared library (dll)
520
#
521
 
522
shld		= $(CC_PRE) link
523
shld_cmdfile	= $(subst /,\\,$(basename $@).ld)
524
shld_flags	=
525
shld_o_switch	= @$(shld_cmdfile)
526
shld_term	=
527
 
528
define shld_pre
303 dpurdie 529
	@$(cmdfile) -wkWeo$(shld_cmdfile) \
227 dpurdie 530
		"$(vc_ldflags) $($(notdir $(SHBASE))_shld)"; \
303 dpurdie 531
	echo [$@] Linking shared library ..;\
532
        $(call show_cmdfile,$(shld_cmdfile))
533
 
227 dpurdie 534
endef
535
 
536
ifndef LEAVETMP
537
define shld_post
538
	@$(rm) -f $(shld_cmdfile)
539
endef
540
else
541
define shld_post
542
endef
543
endif
544
 
545
define SHLDDEPEND
303 dpurdie 546
	@$(cmdfile) -wkWeo$(@) \
227 dpurdie 547
		"$($(notdir $(SHNAME))_shdp)";
548
endef
549
 
550
#..      Application
551
#
552
 
553
ld		= $(CC_PRE) link
554
ld_cmdfile	= $(subst /,\\,$(basename $@).ld)
555
ld_depfile	= $(subst /,\\,$(basename $@).dep)
556
ld_flags	=
557
ld_o_switch	= @$(ld_cmdfile)
558
ld_term		=
559
 
560
define ld_pre
303 dpurdie 561
	@$(cmdfile) -wkWeo$(ld_cmdfile) \
227 dpurdie 562
		"$(vc_ldflags) $($(notdir $(basename $@))_ld)"; \
303 dpurdie 563
	echo [$@] Linking application ..;\
564
        $(call show_cmdfile,$(ld_cmdfile))
227 dpurdie 565
endef
566
 
567
ifndef LEAVETMP
568
define ld_post
569
	@$(rm) -f $(ld_cmdfile)
570
endef
571
else
572
define ld_post
573
endef
574
endif
575
 
576
define LDDEPEND
303 dpurdie 577
	@$(cmdfile) -wkWeo$(ld_depfile) \
227 dpurdie 578
		"$($(notdir $(basename $@))_dp)";
579
endef
580
 
581
#.. Resource Compiler
582
#   Convert a .rc file into a .res file
583
#       Set up the INCLUDE envar to conatin the path to locate required
584
#       files and the local and interface directories then the compiler directories
585
#
586
#       Currently RC has a limit of 100 include paths to seach
587
#       Simply limit the list to the system paths and the directories
588
#       required by the prerequisite files
589
#
590
rc_defines = $(subst -D,/d ,$(vc_defines))
591
rc_dirs = $(subst /,\,$(sort $(dir $^)))
592
rc_dirs += $(LINCDIRS)
593
rc_dirs += $(vc_includes)
303 dpurdie 594
rc_include = $(call decodepath,,;,$(rc_dirs))
227 dpurdie 595
rc_include1 = $(subst \;,;,$(rc_include))
596
 
597
define RC
598
	@$(echo) [$@] Compile Resource File ..
599
	@$(show_environment)
600
	$(XX_PRE) export INCLUDE; INCLUDE="$(rc_include1)"; \
601
	RC /l 0xC09 $(rc_defines) /fo $(subst /,\\,$@) $(subst /,\\,$<)
602
endef
603
 
604
#.. Browser Information
605
#   Create a .BSC file from many .SBR files
606
#   Filter out non .SBR files to assist in rule creation
607
#
608
define BSCMAKE
609
	@$(echo) [$@] Create Source Browser Information ..
610
	@$(show_environment)
611
	$(XX_PRE) bscmake -nologo -n -o $(subst /,\\,$@) $(subst /,\\,$(filter %.sbr,$^))
612
endef
613
 
614
#