Subversion Repositories DevTools

Rev

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

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