Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
2
# File:         TOOLSET/csharp.rul[e]
3
# Contents:     Visual C/C++ CSHARP rules
4
#
5
#............................................................................#
6
 
7
###############################################################################
8
#..     Remove "undef" warnings
9
#
10
 
11
###############################################################################
12
#..     Parse user options
13
#       Global options already parsed
14
#       These options extend the global options
15
#
16
 
17
ifdef OPTIONS
18
 
19
ifneq "$(findstring wall,$(OPTIONS))" ""        # Enable all warnings
20
USE_WALL	= 1
21
endif
22
 
23
endif
24
 
25
###############################################################################
26
#   Standard library paths
255 dpurdie 27
#   Export CS_LIB as this is used by the library generation process to determine
28
#   the locations of libraries. cmdfile will use 'CS_LIB" for vglob resolving
29
#   process.
227 dpurdie 30
#
255 dpurdie 31
#	VC_LIB	    - Lib paths from Compiler toolkit
32
#		    - ';' seperated path list
33
#		    - Uses \ or / as a dir sep
34
#		    - Uses real spaces in pathnames
35
#		    - Should be Absolute Paths
36
#                   
37
#	LIBDIRS	    - Lib paths from JATS
38
#		    - Space seperated path list
39
#		    - Uses / as dir sep
40
#		    - Must not contain spaces
41
#		    - Will be Relative
227 dpurdie 42
#
255 dpurdie 43
#	ALL_LIBDIRS and LIB
44
#		    - Only contain valid paths
45
#		      VS2005 will complain about bad LIB entries
46
#		      Use $(wildcard ...) to limit to test for existence
47
#		    - Contain absolute paths
48
#		      msdev/devenv don't work with relative paths
49
#		      Use $(abspath ...) to convert
50
#
51
#	ALL_LIBDIRS - Used internally
52
#		    - Space seperated path list
53
#		    - Uses / as dir sep
54
#		    - Uses %20 as a altspace in pathnames
55
#                   
56
#	LIB         - Exported to tools
57
#		    - ';' seperated path list
58
#		    - Uses \ as a dir sep
59
#		    - Uses real spaces in pathnames
227 dpurdie 60
#..
61
 
255 dpurdie 62
#
63
#   Work around for a bug in make 3.81 where abspath assumes that the input
64
#   is a relative path. The work around checks for paths that have a : or start
65
#   with a '/ - and assumes these are absolute.
66
#   It will only call makes 'abspath' for relative paths.
67
#
68
myabspath = $(foreach dir,$1,$(call myabs1path,$(dir)))
69
myabs1path = $(if $(or $(findstring :,$1),$(filter /%,$1)),$1,$(abspath $1))
227 dpurdie 70
 
255 dpurdie 71
vc_libs     := $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(VC_LIB))))
72
ALL_LIBDIRS := $(wildcard $(call myabspath,$(LIBDIRS))) $(vc_libs)
73
CS_LIB      := $(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,%;,$(subst /,\,$(ALL_LIBDIRS)))))
74
export CS_LIB
75
 
76
#one_per_line = $(foreach aa,$2,$(info $1 :: $(subst $(spacealt),$(space),$(aa))))
77
#$(call one_per_line,Good LIBDIRS,$(ALL_LIBDIRS))
78
 
227 dpurdie 79
###############################################################################
80
#
255 dpurdie 81
#.. Resource Generator
227 dpurdie 82
#
83
define RESGEN
84
	@$(echo) [$@] Compile Resource ..
85
	@$(show_environment)
86
	$(XX_PRE) resgen $(subst /,\\,$(filter %.resx,$^)) $(subst /,\\,$@)
87
endef
88
 
89
#
90
#.. CSharp Compiler
91
#   Used to create Programs a DLLs
92
#
93
define CSC
94
	$(AA_PRE)$(csc_pre)
95
	@$(show_environment)
96
	$(csc) $(csc_flags) $(csc_o_switch)
97
	$(AA_PRE)$(csc_post)
98
endef
99
 
100
#
101
#   Definitions for the CSharp Compiler Macro
102
#       csc_pre                 - Before the CSC command
103
#       csc                     - The CSC command
104
#       csc_flags               - Command line options (visible)
105
#       csc_o_switch            - Command line output options (visible)
106
#       csc_post                - CSC command cleanup
107
#       csc_cmdfile             - Name of the generated response file
108
#       csc_defines             - Local definitions will be placed on cmd line
109
#
110
csc_pre =
111
csc = $(CC_PRE) csc
112
csc_flags =
255 dpurdie 113
csc_o_switch = @$(csc_cmdfile)
227 dpurdie 114
csc_post =
115
csc_cmdfile	= $(basename $@).ld
116
csc_defines =
117
 
118
define csc_pre
119
	$(cmdfile) -wkWeo$(csc_cmdfile) \
120
		"$(vc_ldflags)$($(notdir $(basename $@))_ld)"; \
121
	echo [$@] Compile CSharp Program ..;
122
endef
123
 
124
#
125
#   Command line flags
126
#
127
csc_flags += /nologo
128
csc_flags += /out:$@
129
 
130
ifndef ADDLINKLIBS
131
csc_flags += /noconfig
132
endif
133
 
134
ifdef NOWARNLIST
135
csc_flags += /nowarn:$(NOWARNLIST)
136
endif
137
 
138
#
139
#   Command line flags
140
#
141
ifdef ALVL
142
csc_defines	+= -DALVL=$(ALVL)
143
endif
144
ifdef DLVL
145
csc_defines	+= -DDLVL=$(DLVL)
146
endif
147
 
148
ifdef USE_WALL
149
csc_flags	+= /warn:4
150
else
151
csc_flags	+= /warn:3
152
endif
153
 
154
ifdef USE_OPTIMISE				# default for production
155
csc_flags	+=                  # Don't optimise production code. Ship what we test
156
else
157
csc_flags	+=
158
endif
159
 
160
ifdef USE_DEBUGINFO				# default for debug
161
csc_flags	+= /debug /debug:full
162
csc_defines	+= -DDEBUG
163
else
164
csc_flags	+= /debug /debug:pdbonly
165
csc_flags	+=
166
endif
167
 
168
ifeq "$(DEBUG)" "1"				# debug/prod specific
169
csc_defines	+= -D_DEBUG
170
else
171
csc_defines	+= -DNDEBUG
172
endif
173
 
174
#
175
#   Convert Definitions to a suitable format
176
#   Many users use -Dxxxx for Compiler definitions
177
#   Maintain this and convert them to a correct form
178
#
179
csc_flags += $(patsubst -D%,/define:%,$(CFLAGS)$(csc_defines))
180
 
181
 
182
#
183
#   Insert the library search paths into the start of the command file
255 dpurdie 184
#   Create lines of the form: "/lib:<pathname>"
185
#       Put all in quotes to allow for paths with spaces
227 dpurdie 186
#
255 dpurdie 187
vc_ldflags	= $(subst $(spacealt),$(space),$(patsubst %,\"/lib:%\"\\n,$(subst /,\\\\,$(ALL_LIBDIRS))))
227 dpurdie 188
 
189
#
190
#   Cleanup definitions
191
#
192
ifndef LEAVETMP
193
define csc_post
194
	$(rm) -f $(csc_cmdfile)
195
endef
196
else
197
define csc_post
198
endef
199
endif
200
 
201
 
202
#
203
#   Recipes to support the creation of Linker Dependency files
204
#   These will generate .dep files
205
#
206
#   The dependancy list is based an a makefile definition
207
#   The definition is named after the target
208
#
209
define LDDEPEND
210
	$(AA_PRE)$(cmdfile) -wkWeo$(@) \
211
		"$($(notdir $(basename $@))_dp)";
212
endef
213
 
214
define SHLDDEPEND
215
	$(AA_PRE)$(cmdfile) -wkWeo$(@) \
216
		"$($(notdir $(SHNAME))_shdp)";
217
endef
218
 
219
 
220
#
221
#       Recipe to create a file that contains the StrongNameKey assembly
222
#       Args:   $1 Tag of the definitiosn that will go into the file
223
#
224
#
225
define GenSnkWrapper
226
    @$(echo) "[$@] Create StrongKey Wrapper.."
227
    $(AA_PRE)$(cmdfile) -wkWeo$(@) "$($1)";
228
endef
229