Subversion Repositories DevTools

Rev

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