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