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