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/standard.rul[e]
4
#
5
# Contents:     Toplevel toolset driver for doing stuff
6
#
7
#       CC              Compile a C source file
8
#       CCDEPEND
9
#       CXX             Compile a C++ source file
10
#       CCDEPEND
11
#       AS              Compile an assembler file
12
#       ASDEPEND
13
#       AR              Archive
14
#       LD              Linker
15
#       SHLD            Linked (shared library)
16
#
17
# Revision History:
18
#      `95       JONW   CMOS dev env
19
#       xx/08/99 APY    Ported
20
#       10/03/00 APY    Modified 'cc' output filtering
21
#       13/11/00        ${exe} now embeddes '.' if required.
22
#       29/11/00        SHLD and SHLDDEPEND
23
#       16/11/01        xx_term
24
#       06/05/04        $(show_environment) missing from several rules
25
#       08/07/04        cc_redirect filter now saves the exit code of the compile
26
#                       and uses it after the filter has been processed
27
#                       This will ensure that the user sees any errors
28
#
29
###############################################################################
30
 
31
#
32
#   Global control of compiler filters
33
#   USE_FILTER is defined by default
34
#
35
ifndef USE_FILTER
36
    cc_error_filter =
37
    cxx_error_filter =
38
    as_error_filter =
39
endif
40
 
41
###############################################################################
42
#  Compile a C file.
43
###############################################################################
44
 
45
cc_term		+=
46
 
47
ifdef cc_error_filter
48
 ifdef cc_redirect
49
define CC
50
	@$(cc_pre)
51
	@$(show_environment)
52
	$(cc) $(cc_flags) $(cc_o_switch) $(cc_source) > $(basename $@).err $(cc_term);\
53
	rv=$$?;\
54
	$(cc_error_filter) < $(basename $@).err;\
55
	exit $$rv;
56
	@$(cc_post)
57
endef
58
 else
59
  ifdef cc_redirect_stderr
60
define CC
61
	@$(cc_pre)
62
	@$(show_environment)
63
	$(cc) $(cc_flags) $(cc_o_switch) $(cc_source) 2>&1 | $(cc_error_filter) $(cc_term)
64
	@$(cc_post)
65
endef
66
  else
67
define CC
68
	@$(cc_pre)
69
	@$(show_environment)
70
	$(cc) $(cc_flags) $(cc_o_switch) $(cc_source) | $(cc_error_filter) $(cc_term)
71
	@$(cc_post)
72
endef
73
  endif
74
 endif
75
else
76
define CC
77
	@$(cc_pre)
78
	@$(show_environment)
79
	$(cc) $(cc_flags) $(cc_o_switch) $(cc_source) $(cc_term)
80
	@$(cc_post)
81
endef
82
endif
83
 
84
$(OBJDIR)/%.${o}:	%.c $(cc_init)
85
	$(CC)
86
 
87
ccdep_term +=
88
define CCDEPEND
89
	@$(ccdep_pre)
90
	@$(show_environment)
91
	$(ccdep) $(ccdep_flags) $(ccdep_o_switch) $(ccdep_source) $(ccdep_term)
92
	@$(ccdep_post)
93
endef
94
 
95
 
96
###############################################################################
97
#  Compile a C++ file.
98
###############################################################################
99
 
100
cxx_term	+=
101
 
102
ifdef cxx_error_filter
103
 ifdef cxx_redirect
104
define CXX
105
	@$(cxx_pre)
106
	@$(show_environment)
107
	$(cxx) $(cxx_flags) $(cxx_o_switch) $(cxx_source) > $(basename $@).err $(cxx_term);\
108
        rv=$$?;\
109
	    $(cxx_error_filter) < $(basename $@).err;\
110
        exit $$rv
111
	@$(rm) $(basename $@).err
112
	@$(cxx_post)
113
endef
114
 else
115
  ifdef cxx_redirect_stderr
116
define CXX
117
	@$(cxx_pre)
118
	@$(show_environment)
119
	$(cxx) $(cxx_flags) $(cxx_o_switch) $(cxx_source) 2>&1 | $(cxx_error_filter) $(cxx_term)
120
	@$(cxx_post)
121
endef
122
  else
123
define CXX
124
	@$(cxx_pre)
125
	@$(show_environment)
126
	$(cxx) $(cxx_flags) $(cxx_o_switch) $(cxx_source) | $(cxx_error_filter) $(cxx_term)
127
	@$(cxx_post)
128
endef
129
  endif
130
 endif
131
else
132
define CXX
133
	@$(cxx_pre)
134
	@$(show_environment)
135
	$(cxx) $(cxx_flags) $(cxx_o_switch) $(cxx_source) $(cxx_term)
136
	@$(cxx_post)
137
endef
138
endif
139
 
140
ifdef cxx_init
141
$(OBJDIR)/%.${o}:	%.cc $(cxx_init)
142
	$(CXX)
143
 
144
$(OBJDIR)/%.${o}:	%.cpp $(cxx_init)
145
	$(CXX)
146
endif
147
 
148
###############################################################################
149
#  Assemble a file of assembler.
150
###############################################################################
151
 
152
as_term		+=
153
 
154
 
155
ifdef as_error_filter
156
 ifdef as_redirect
157
define AS
158
	@$(as_pre)
159
	@$(show_environment)
160
	$(as) $(as_flags) $(as_o_switch) $(as_source) > $(basename $@).as $(as_term)
161
	@$(as_error_filter) < $(basename $@).as
162
	@$(rm) $(basename $@).as
163
	@$(as_post)
164
  endef
165
 else
166
define AS
167
	@$(as_pre)
168
	@$(show_environment)
169
	$(as) $(as_flags) $(as_o_switch) $(as_source) | $(as_error_filer) $(as_term)
170
	@$(as_post)
171
endef
172
 endif
173
else
174
define AS
175
	@$(as_pre)
176
	@$(show_environment)
177
	$(as) $(as_flags) $(as_o_switch) $(as_source) $(as_term)
178
	@$(as_post)
179
endef
180
endif
181
 
182
ifdef as_init
183
$(OBJDIR)/%.${o}:	%.${s} $(as_init)
184
	$(AS)
185
endif
186
 
187
###############################################################################
188
#  Build a library
189
###############################################################################
190
 
191
ar_term		+=
192
 
193
define AR
194
	@$(ar_pre)
195
	@$(show_environment)
196
	$(ar) $(ar_flags) $(ar_o_switch) $(ar_term)
197
	@$(ar_post)
198
endef
199
 
200
ifdef ar_depend
201
$(BINDIR)/%.${a}:	$(ar_depend) $(ar_init)
202
	$(AR)
203
endif
204
 
205
###############################################################################
206
#  Merge libraries
207
###############################################################################
208
 
209
define ARMERGE
210
	@$(armerge_pre)
211
	@$(show_environment)
212
	$(armerge) $(armerge_flags) $(armerge_o_switch)
213
	@$(armerge_post)
214
endef
215
 
216
ifdef armerge_depend
217
$(BINDIR)/%.${a}:	$(armerge_depend) $(armerge_init)
218
	$(ARMERGE)
219
endif
220
 
221
 
222
###############################################################################
223
# Generate a large relocatable object module from a bunch of object
224
# modules. Only bother with this if the compiler suite defines a
225
# `rel' extension for file names.
226
###############################################################################
227
 
228
rel_ld_term	+=
229
 
230
ifdef rel
231
ifneq (${a},${rel})
232
#
233
#       Only have the rules for a large relocatable build if it's not
234
#       the same as a normal library build.
235
#
236
$(BINDIR)/%.$(rel):	$(rel_ld_init)
237
	@$(rel_ld_pre)
238
	@$(show_environment)
239
	$(rel_ld) $(rel_ldflags) $(rel_ld_o_switch) $(rel_ld_term)
240
	@$(rel_ld_post)
241
endif
242
endif
243
 
244
###############################################################################
245
#  Link a shared library
246
###############################################################################
247
 
248
shld_term	+=
249
 
250
ifdef shld
251
define SHLD
252
	@$(shld_pre)
253
	@$(show_environment)
254
	$(shld) $(shld_flags) $(shld_o_switch) $(shld_term)
255
	@$(shld_post)
256
endef
257
endif
258
 
259
###############################################################################
260
#  Link an executable
261
###############################################################################
262
 
263
ld_term		+=
264
 
265
define LD
266
	@$(ld_pre)
267
	@$(show_environment)
268
	$(ld) $(ld_flags) $(ld_o_switch) $(ld_term)
269
	@$(ld_post)
270
endef
271
 
272
ifdef ld_depend
273
$(BINDIR)/%$(exe):	$(ld_depend) $(ld_init)
274
	$(LD)
275
endif
276
 
277
#