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
245 dpurdie 74
ifndef AR_PATH
75
    $(error Internal: AR_PATH has not been defined by the build system)
76
endif
227 dpurdie 77
 
245 dpurdie 78
#
79
#	Ensure that AR can be found in the path
80
#	Place the compiler in the path for good measure
81
 
82
#
83
PATH := $(AR_PATH):$(SUNWSPRO_SC)/bin:$(PATH)
84
export PATH
85
 
227 dpurdie 86
CCOMPILER       := cc
87
 
88
ifdef FORCE_C_COMPILE
89
 CCOMPILER      := cc
90
endif
91
 
92
ifdef FORCE_CC_COMPILE
93
 CCOMPILER      := CC
94
endif
95
 
96
ifeq "$(CCOMPILER)" "cc"
97
 CFLAGS         := $(CFLAGS) -erroff E_WHITE_SPACE_IN_DIRECTIVE
98
endif
99
 
100
LIBDIRS 	+= $(SUNWSPRO_SC)/lib
101
 
102
SHCFLAGS	+= -KPIC
103
SHCXXFLAGS	+= -KPIC
104
 
105
ifdef suncc_filter
106
cc_redirect_stderr = 1
107
cc_error_filter = $(awk) -f $(suncc_filter)
108
endif
109
 
110
cc		= $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/$(CCOMPILER)
111
cc_init 	=
112
cc_o_switch	= -o $@
113
cc_source	= $<
114
cc_flags	= \
115
		$(patsubst %,%,$(CFLAGS)) \
116
		$(patsubst %,-D%,$(cc_defines)) \
117
		$(patsubst %,%,$(suncc_flags)) \
118
		$(patsubst %,-I%,$(INCDIRS)) \
119
		$(patsubst %,-I%,$(cc_includes)) \
120
		$(patsubst %,-I%,$(suncc_includes))
121
 
122
suncc_includes	+=
123
 
124
suncc_flags	= -c
125
ifdef THREADMODE
126
suncc_flags         += -mt
127
endif
128
ifdef MISALIGN
129
suncc_flags         += -misalign
130
endif
131
ifdef COMPILE32
132
suncc_flags         += -xtarget=generic
133
endif
134
ifdef COMPILE64
135
suncc_flags         += -xtarget=generic64
136
endif
137
ifdef suncc_filter
138
suncc_flags	+= +w2
139
else
140
suncc_flags	+= +w
141
endif
142
ifdef USE_DEBUGINFO
143
suncc_flags       += -g -DDEBUG -xs
144
endif
145
ifdef USE_OPTIMISE
146
suncc_flags	+= -xO2
147
endif
148
ifdef ALVL
149
suncc_flags	+= -DALVL=$(ALVL)
150
endif
151
ifdef DLVL
152
suncc_flags	+= -DDLVL=$(DLVL)
153
endif
154
suncc_flags	+= -D__SOURCE__=\"$(notdir $<)\"
155
 
156
define cc_pre
157
	@echo [$<] compiling..
158
endef
159
 
160
define cc_post
161
endef
162
 
163
#..     C/C++ dependencies
164
#
165
suncc_depend	+=
166
ifndef USE_CCDEPEND
167
suncc_depend	+= -MM -D__STDC__ -Dunix -Dsun -D$(HOST_CPU)
168
else
169
suncc_depend	+= -xM1
170
endif
171
ifdef USE_DEBUGINFO
172
suncc_depend	+= -DDEBUG
173
endif
174
ifdef ALVL
175
suncc_depend	+= -DALVL=$(ALVL)
176
endif
177
ifdef DLVL
178
suncc_depend	+= -DDLVL=$(DLVL)
179
endif
180
 
181
ifndef USE_CCDEPEND
182
ccdep		= $(XX_PRE) $(GBE_BIN)/mkdepend
183
ccdep_init	=
184
ccdep_o_switch	= -o.${o} -f -
185
else
245 dpurdie 186
ccdep		= $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
227 dpurdie 187
ccdep_init	=
188
ccdep_o_switch	= -E
189
endif
190
 
191
ccdep_source	= $(filter %.c %.cc %.cpp, $+) > $(subst /,/,$@).tmp 2> depend.err
192
 
193
ccdep_flags	= \
194
                $(patsubst %,%,$(CFLAGS)) \
195
		$(patsubst %,-D%,$(cc_defines)) \
196
		$(patsubst %,%,$(suncc_depend))
197
ifndef USE_CCDEPEND
198
ccdep_flags	+= \
199
		$(patsubst %,-I %,$(INCDIRS)) \
200
		$(patsubst %,-I %,$(cc_includes)) \
201
		$(patsubst %,-Y %,$(suncc_includes)) \
202
		-Y $(SUNWSPRO_SC)/include/CC/Cstd \
203
		-Y $(SUNWSPRO_SC)/include/CC \
204
		-Y /usr/include
205
else
206
ccdep_flags	+= \
207
		$(patsubst %,-I%,$(INCDIRS)) \
208
		$(patsubst %,-I%,$(cc_includes))
209
endif
210
 
211
	#
212
	#   Parse the depend output:
213
	#
214
	#   s/^.*/\(.*\.${o}\:\)/$(OBJDIR)/\1/g
215
	#        replace all object rules which contain / seperated
216
	#        subdirs with a stripped prefixed object name.
217
	#
218
	#        eg. subdir/dir/object.o:        $(OBJDIR)/object.o
219
	#
220
	#   s/^\([^/].*\.${o}\:\)/$(OBJDIR)/\1/g
221
	#        prefix all object rules without subdirs.
222
	#
223
	#        eg. object.o:                   $(OBJDIR)/object.o
224
	#..
225
 
226
#	-(sed s/\^/\$$\(OBJDIR\)\\// $(subst /,/,$@).tmp; \
227
 
228
ccdep_sed	= \
229
	-sed -e 's/^.*\/\(.*\.${o}\:\)/\$$\(OBJDIR\)\/\1/g' \
230
	     -e 's/^\([^/]*\.${o}\:\)/\$$\(OBJDIR\)\/\1/g' \
231
		$(subst /,/,$@).tmp > $@ 2> depend.err;
232
ifdef SHNAMES
233
ccdep_sedsh	= \
234
	sed  -e 's/^.*\/\(.*\.${o}\:\)/\$$\(OBJDIR\)\/$(shname)\/\1/g' \
235
	     -e 's/^\([^/]*\.${o}\:\)/\$$\(OBJDIR\)\/$(shname)\/\1/g' \
236
		$(subst /,/,$@).tmp >> $@ 2>> depend.err;
237
ccdep_sed	+= \
238
		$(foreach shname,$(SHNAMES),$(ccdep_sedsh))
239
endif
240
 
241
ccdep_pre	=
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
274
	@echo [$<] compiling..
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
309
	@echo [$@] compiling
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
 
327
 
328
#..     Archiver
329
#
330
ar		= $(XX_PRE) $(SUNWSPRO_SC)/bin/CC
331
ar_init 	=
332
ar_flags	= -xar -o
333
ar_o_switch	= $@ $^
334
 
335
define ar_pre
336
	@echo [$@] Building library..
337
endef
338
 
339
define ar_post
340
endef
341
 
342
 
343
#..     Archive Merge
344
#
345
armerge		= $(XX_PRE) $(GBE_TOOLS)/armerge
346
armerge_init	=
347
armerge_flags	= -d $(OBJDIR) -t unix
348
armerge_o_switch= $@ $^
349
 
350
define armerge_pre
351
	@echo [$@] Building merged library..
352
	-@$(rm) -f $@
353
endef
354
 
355
armerge_post	=
356
 
357
#..     Linked (shared library support)
358
#
359
#       The following are detailed within the context of TARGET definition:
360
#
361
#       SHNAME  Defines the shared library name (eg lib.so.1.1)
362
#       SHBASE  Defines the base library name (eg lib.so)
363
#
364
shld		= $(CC_PRE) $(SUNWSPRO_SC)/bin/CC
365
shld_init	=
366
shld_o_switch	= -o $@
367
 
368
shld_flags	+= +w -G -h'$(SHBASE)$(GBE_TYPE).so'
369
ifdef THREADMODE
370
shld_flags         += -mt
371
endif
372
ifdef MISALIGN
373
shld_flags         += -misalign
374
endif
375
ifdef USE_DEBUGINFO
376
shld_flags	+= -g
377
endif
378
ifdef COMPILE32
379
shld_flags         += -xtarget=generic
380
endif
381
ifdef COMPILE64
382
shld_flags         += -xtarget=generic64
383
endif
384
 
385
 
386
shld_flags	+= \
387
		$(patsubst %,-L%,$(LIBDIRS)) \
388
		$(patsubst %,-%,$(LDFLAGS)) \
389
		$($(notdir $(SHBASE))_ld)
390
 
391
define shld_pre
392
	@echo [$@] Linking shared library ..
393
endef
394
 
395
define shld_post
396
endef
397
 
398
define SHLDDEPEND
399
	@export CC_LIB; \
400
		CC_LIB="$(subst $(space),;,$(LIBDIRS))"; \
401
	$(cmdfile) -o$(LIBDIR)/$(notdir $(basename $@)).dep \
402
		"$($(notdir $(basename $@))_dp)"
403
endef
404
 
405
#..     Linker
406
#
407
ld		= $(CC_PRE)$(CC_PURIFY) $(SUNWSPRO_SC)/bin/CC
408
ld_init		=
409
ld_o_switch	= -o $@
410
 
411
ld_flags	+= +w
412
ifdef THREADMODE
413
ld_flags         += -mt
414
endif
415
ifdef MISALIGN
416
ld_flags         += -misalign
417
endif
418
ifdef USE_DEBUGINFO
419
ld_flags	+= -g
420
endif
421
ifdef COMPILE32
422
ld_flags         += -xtarget=generic
423
endif
424
ifdef COMPILE64
425
ld_flags         += -xtarget=generic64
426
endif
427
 
428
ld_flags	+= \
429
		$(patsubst %,-L%,$(LIBDIRS)) \
430
		$(patsubst %,-%,$(LDFLAGS)) \
431
		$($(notdir $(basename $@))_ld)
432
 
433
define ld_pre
434
	@echo [$@] Linking application ..
435
endef
436
 
437
define ld_post
438
endef
439
 
440
define LDDEPEND
441
	@export CC_LIB; \
442
		CC_LIB="$(subst $(space),;,$(LIBDIRS))"; \
443
	$(cmdfile) -o$(BINDIR)/$(notdir $(basename $@)).dep \
444
		"$($(notdir $(basename $@))_dp)"
445
endef
446
 
447
#