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