Subversion Repositories DevTools

Rev

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