Subversion Repositories DevTools

Rev

Rev 4928 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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