Subversion Repositories DevTools

Rev

Rev 4538 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: mak; -*-
2
###############################################################################
3
# File:         TOOLSET/sunworks.rul[e]
4
# Contents:     SunWorks rules
5
#
4538 dpurdie 6
###############################################################################
227 dpurdie 7
 
8
###############################################################################
9
#..     Remove "undef" warnings
10
#
11
cc_includes	+=
12
cc_defines	+=
13
cxx_includes	+=
14
cxx_defines	+=
15
as_includes	+=
16
as_defines	+=
17
 
18
 
19
###############################################################################
20
#..     Toolset defaults
21
#
22
 
23
###############################################################################
24
#..     Parse user options
25
#       Global options already parsed
26
#       These options extend the global options
27
#
28
CC_PURIFY =
29
 
30
suncc_filter	:= "$(notdir $(wildcard $(GBE_ROOT)/warnings.sunworks))"
31
ifeq ($(strip $(suncc_filter)), "warnings.sunworks")
32
suncc_filter	= $(GBE_ROOT)/warnings.sunworks
33
else
34
suncc_filter	=
35
endif
36
 
37
ifdef OPTIONS
38
 
39
ifneq "$(findstring warnings,$(OPTIONS))" ""	# Show all warnings
40
suncc_filter	=
41
endif
42
 
43
ifneq "$(findstring purify,$(OPTIONS))" ""	# Enable purify
44
CC_PURIFY	 += purify
45
endif
46
 
47
ifneq "$(findstring purecov,$(OPTIONS))" ""	# Enable pure coverage
48
CC_PURIFY	+= purecov
49
endif
50
 
51
ifneq "$(findstring quantify,$(OPTIONS))" ""	# Enable quantify
52
CC_PURIFY	+= quantify
53
endif
54
 
55
ifneq "$(findstring ccdepend,$(OPTIONS))" ""	# Build depends using CC
56
USE_CCDEPEND	= 1
57
endif
58
endif
59
 
60
###############################################################################
313 dpurdie 61
#..	Common compiler and linker flags
62
#
63
ifdef THREADMODE
64
common_flags         += -mt
65
endif
66
ifdef MISALIGN
67
common_flags         += -misalign
68
endif
69
ifdef COMPILE32
70
common_flags         += -xtarget=generic
71
endif
72
ifdef COMPILE64
315 dpurdie 73
common_flags         += -m64 -KPIC
313 dpurdie 74
  ifndef ISA_SPARC
75
  common_flags       += -xmodel=medium
76
  endif
77
endif
78
 
79
 
80
###############################################################################
227 dpurdie 81
#..     C Compiler definition
82
#
83
ifndef SUNWSPRO_SC
84
    $(error Internal: SUNWSPRO_SC has not been defined by the build system)
85
endif
245 dpurdie 86
ifndef AR_PATH
87
    $(error Internal: AR_PATH has not been defined by the build system)
88
endif
227 dpurdie 89
 
245 dpurdie 90
#
91
#	Ensure that AR can be found in the path
92
#	Place the compiler in the path for good measure
93
 
94
#
95
PATH := $(AR_PATH):$(SUNWSPRO_SC)/bin:$(PATH)
96
export PATH
97
 
227 dpurdie 98
CCOMPILER       := cc
99
 
100
ifdef FORCE_C_COMPILE
101
 CCOMPILER      := cc
102
endif
103
 
104
ifdef FORCE_CC_COMPILE
105
 CCOMPILER      := CC
106
endif
107
 
108
ifeq "$(CCOMPILER)" "cc"
363 dpurdie 109
 CFLAGS         := $(CFLAGS) -erroff=E_WHITE_SPACE_IN_DIRECTIVE
227 dpurdie 110
endif
111
 
112
LIBDIRS 	+= $(SUNWSPRO_SC)/lib
113
 
114
SHCFLAGS	+= -KPIC
115
SHCXXFLAGS	+= -KPIC
116
 
117
ifdef suncc_filter
118
cc_redirect_stderr = 1
119
cc_error_filter = $(awk) -f $(suncc_filter)
120
endif
121
 
122
cc		= $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/$(CCOMPILER)
123
cc_init 	=
124
cc_o_switch	= -o $@
125
cc_source	= $<
126
cc_flags	= \
127
		$(patsubst %,%,$(CFLAGS)) \
128
		$(patsubst %,-D%,$(cc_defines)) \
129
		$(patsubst %,%,$(suncc_flags)) \
130
		$(patsubst %,-I%,$(INCDIRS)) \
131
		$(patsubst %,-I%,$(cc_includes)) \
132
		$(patsubst %,-I%,$(suncc_includes))
133
 
134
suncc_includes	+=
135
 
136
suncc_flags	= -c
313 dpurdie 137
suncc_flags	+= $(common_flags)
227 dpurdie 138
ifdef suncc_filter
139
suncc_flags	+= +w2
140
else
141
suncc_flags	+= +w
142
endif
143
ifdef USE_DEBUGINFO
144
suncc_flags       += -g -DDEBUG -xs
145
endif
146
ifdef USE_OPTIMISE
147
suncc_flags	+= -xO2
148
endif
149
ifdef ALVL
150
suncc_flags	+= -DALVL=$(ALVL)
151
endif
152
ifdef DLVL
153
suncc_flags	+= -DDLVL=$(DLVL)
154
endif
155
suncc_flags	+= -D__SOURCE__=\"$(notdir $<)\"
156
 
157
define cc_pre
6177 dpurdie 158
	@echo '[$<] compiling..'
227 dpurdie 159
endef
160
 
161
define cc_post
162
endef
163
 
4538 dpurdie 164
###############################################################################
227 dpurdie 165
#..     C/C++ dependencies
166
#
167
suncc_depend	+=
168
ifndef USE_CCDEPEND
169
suncc_depend	+= -MM -D__STDC__ -Dunix -Dsun -D$(HOST_CPU)
170
else
171
suncc_depend	+= -xM1
172
endif
173
ifdef USE_DEBUGINFO
174
suncc_depend	+= -DDEBUG
175
endif
176
ifdef ALVL
177
suncc_depend	+= -DALVL=$(ALVL)
178
endif
179
ifdef DLVL
180
suncc_depend	+= -DDLVL=$(DLVL)
181
endif
182
 
183
ifndef USE_CCDEPEND
184
ccdep		= $(XX_PRE) $(GBE_BIN)/mkdepend
185
ccdep_init	=
186
ccdep_o_switch	= -o.${o} -f -
187
else
245 dpurdie 188
ccdep		= $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
227 dpurdie 189
ccdep_init	=
190
ccdep_o_switch	= -E
191
endif
192
 
4538 dpurdie 193
ccdep_source	= $(filter %.c %.cc %.cpp, $+) > $(subst /,/,$@).tmp 2> $(OBJDIR)/depend.err
227 dpurdie 194
 
195
ccdep_flags	= \
196
                $(patsubst %,%,$(CFLAGS)) \
197
		$(patsubst %,-D%,$(cc_defines)) \
198
		$(patsubst %,%,$(suncc_depend))
199
ifndef USE_CCDEPEND
200
ccdep_flags	+= \
201
		$(patsubst %,-I %,$(INCDIRS)) \
202
		$(patsubst %,-I %,$(cc_includes)) \
203
		$(patsubst %,-Y %,$(suncc_includes)) \
204
		-Y $(SUNWSPRO_SC)/include/CC/Cstd \
205
		-Y $(SUNWSPRO_SC)/include/CC \
206
		-Y /usr/include
207
else
208
ccdep_flags	+= \
209
		$(patsubst %,-I%,$(INCDIRS)) \
210
		$(patsubst %,-I%,$(cc_includes))
211
endif
212
 
213
	#
214
	#   Parse the depend output:
215
	#
216
	#   s/^.*/\(.*\.${o}\:\)/$(OBJDIR)/\1/g
217
	#        replace all object rules which contain / seperated
218
	#        subdirs with a stripped prefixed object name.
219
	#
220
	#        eg. subdir/dir/object.o:        $(OBJDIR)/object.o
221
	#
222
	#   s/^\([^/].*\.${o}\:\)/$(OBJDIR)/\1/g
223
	#        prefix all object rules without subdirs.
224
	#
225
	#        eg. object.o:                   $(OBJDIR)/object.o
226
	#..
227
 
4538 dpurdie 228
ccdep_pre	=
227 dpurdie 229
 
230
ccdep_sed	= \
231
	-sed -e 's/^.*\/\(.*\.${o}\:\)/\$$\(OBJDIR\)\/\1/g' \
232
	     -e 's/^\([^/]*\.${o}\:\)/\$$\(OBJDIR\)\/\1/g' \
4538 dpurdie 233
		$(subst /,/,$@).tmp > $@ 2>> $(OBJDIR)/depend.err;
227 dpurdie 234
ifdef SHNAMES
235
ccdep_sedsh	= \
236
	sed  -e 's/^.*\/\(.*\.${o}\:\)/\$$\(OBJDIR\)\/$(shname)\/\1/g' \
237
	     -e 's/^\([^/]*\.${o}\:\)/\$$\(OBJDIR\)\/$(shname)\/\1/g' \
4538 dpurdie 238
		$(subst /,/,$@).tmp >> $@ 2>> $(OBJDIR)/depend.err;
227 dpurdie 239
ccdep_sed	+= \
240
		$(foreach shname,$(SHNAMES),$(ccdep_sedsh))
241
endif
242
 
243
ifndef LEAVETMP
244
define ccdep_post
245
	@$(ccdep_sed)
246
	@rm $(subst /,/,$@).tmp
247
endef
248
else
249
define ccdep_post
250
	@$(ccdep_sed)
251
endef
252
endif
253
 
254
#..     C++ Compiler definition
255
#
256
ifdef suncc_filter
257
cxx_redirect_stderr = 1
258
cxx_error_filter = $(awk) -f $(suncc_filter)
259
endif
260
 
245 dpurdie 261
cxx		= $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/CC
227 dpurdie 262
cxx_init	=
263
cxx_o_switch	= -o $@
264
cxx_source	= $<
265
cxx_flags	= \
266
		$(patsubst %,%,$(CXXFLAGS)) \
267
		$(patsubst %,-d%,$(cxx_defines)) \
268
		$(patsubst %,%,$(suncc_flags)) \
269
		$(patsubst %,-I%,$(INCDIRS)) \
270
		$(patsubst %,-I%,$(cxx_includes)) \
271
		$(patsubst %,-I%,$(suncc_includes))
272
 
273
define cxx_pre
6177 dpurdie 274
	@echo '[$<] compiling..'
227 dpurdie 275
endef
276
 
277
define cxx_post
278
endef
279
 
280
###############################################################################
281
#..     Assembler definition
282
#
283
 
284
#..     Assembler (CC)
285
#
286
as		= $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
287
as_init		=
288
as_i_switch	= -I$(space)
289
as_o_switch	=
290
as_object	= -o $@
291
as_source	= $<
292
as_cmdfile	= $(basename $@).cmd
293
as_flags	= @$(as_cmdfile)
294
 
295
as_flags	= -Wall -x assembler-with-cpp -c
296
ifdef USE_DEBUGINFO
297
as_flags	+= -g -DDEBUG
298
endif
299
ifdef DLVL
300
as_flags	+= -DDLVL=$(DLVL)
301
endif
302
ifdef ALVL
303
as_flags	+= -DALVL=$(ALVL)
304
endif
305
as_defines	:= $(addprefix -D,$(as_defines))
306
as_defines	+= $(as_flags)
307
 
308
define as_pre
6177 dpurdie 309
	@echo '[$@] compiling..'
227 dpurdie 310
	@$(cmdfile) -ko$(as_cmdfile) "\
311
		$(patsubst %,%\\n,$(ASFLAGS)) \
312
		$(patsubst %,%\\n,$(as_defines)) \
313
		$(patsubst %,$(as_i_switch)%\\n,$(INCDIRS)) \
314
		$(patsubst %,$(as_i_switch)%\\n,$(as_includes)) \
315
		$(as_object)\\n"
316
endef
317
 
318
ifndef LEAVETMP
319
define as_post
320
	@$(rm) -f $(as_cmdfile)
321
endef
322
else
323
define as_post
324
endef
325
endif
326
 
4538 dpurdie 327
###############################################################################
328
#..     Archiver definition
329
#
227 dpurdie 330
 
331
#..     Archiver
332
#
333
ar		= $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
334
ar_init 	=
335
ar_flags	= -xar -o
336
ar_o_switch	= $@ $^
337
 
338
define ar_pre
6177 dpurdie 339
	@echo '[$@] Building library ..'
227 dpurdie 340
endef
341
 
342
define ar_post
343
endef
344
 
345
 
346
#..     Archive Merge
347
#
348
armerge		= $(XX_PRE) $(GBE_TOOLS)/armerge
349
armerge_init	=
261 dpurdie 350
armerge_flags	= -d $(MLIBDIR) -t unix
227 dpurdie 351
armerge_o_switch= $@ $^
352
 
353
define armerge_pre
6177 dpurdie 354
	@echo '[$@] Building merged library ..'
227 dpurdie 355
	-@$(rm) -f $@
356
endef
357
 
358
armerge_post	=
359
 
360
#..     Linked (shared library support)
361
#
362
#       The following are detailed within the context of TARGET definition:
363
#
339 dpurdie 364
#       SHNAME  Defines the shared library soname (eg lib.so.1.1)
365
#       SHBASE  Defines the base library linkname (eg lib.so)
227 dpurdie 366
#
367
shld		= $(CC_PRE) $(SUNWSPRO_SC)/bin/CC
368
shld_init	=
369
shld_o_switch	= -o $@
370
 
339 dpurdie 371
shld_flags	+= +w -G -h'$(SHNAME)'
227 dpurdie 372
ifdef USE_DEBUGINFO
373
shld_flags	+= -g
374
endif
313 dpurdie 375
shld_flags      += $(common_flags)
227 dpurdie 376
shld_flags	+= \
377
		$(patsubst %,-L%,$(LIBDIRS)) \
378
		$(patsubst %,-%,$(LDFLAGS)) \
339 dpurdie 379
		$($(notdir $(SHBASE))_shld)
227 dpurdie 380
 
381
define shld_pre
6177 dpurdie 382
	@echo '[$@] Linking shared library ..'
227 dpurdie 383
endef
384
 
385
define shld_post
386
endef
387
 
388
define SHLDDEPEND
341 dpurdie 389
	$(AA_PRE)export CC_LIB; \
227 dpurdie 390
		CC_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 391
	$(cmdfile) -o$@ "$($(DPLIST))"
227 dpurdie 392
endef
393
 
394
#..     Linker
395
#
396
ld		= $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/CC
397
ld_init		=
398
ld_o_switch	= -o $@
399
 
400
ld_flags	+= +w
401
ifdef USE_DEBUGINFO
402
ld_flags	+= -g
403
endif
313 dpurdie 404
ld_flags        += $(common_flags)
227 dpurdie 405
ld_flags	+= \
406
		$(patsubst %,-L%,$(LIBDIRS)) \
407
		$(patsubst %,-%,$(LDFLAGS)) \
408
		$($(notdir $(basename $@))_ld)
409
 
410
define ld_pre
6177 dpurdie 411
	@echo '[$@] Linking application ..'
227 dpurdie 412
endef
413
 
414
define ld_post
415
endef
416
 
417
define LDDEPEND
341 dpurdie 418
	$(AA_PRE)export CC_LIB; \
227 dpurdie 419
		CC_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 420
	$(cmdfile) -o$@ "$($(DPLIST))"
227 dpurdie 421
endef
422
 
423
#