Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
###############################################################################
2
# Copyright (c) 1996-2004 ERG Transit Systems.
3
#
4
# File:         TOOLSET/AVR_IAR.rul[e]
5
# Contents:     IAR rules as used for the AVR
6
#               Make definitions for the IAR tools.
7
#
8
# Description:
9
#       This file provides Toolset rules for the target makefiles
10
#       The file is dropped into the target makefile
11
#
12
# Revision History:
13
#       16-Aug-04   DDP     Created
14
###############################################################################
15
 
16
###############################################################################
17
#..     Remove "undef" warnings
18
#
19
cc_includes     +=
20
cc_defines      +=
21
as_includes     +=
22
as_defines      +=
23
cxx_includes    +=
24
cxx_defines     +=
25
 
26
###############################################################################
27
#..     Parse user options
28
#       Global options already parsed
29
#       These options extend the global options
30
#
31
ifdef OPTIONS
32
endif
33
 
34
###############################################################################
35
#..     C Compiler definition
36
#
37
#
38
#   Compiler flags
39
#       --cpu=cpu                   Specify cpu type
40
#       -D Symbol                   Define a symbol
41
#       --debug                     Include debug information
42
#       -e                          Enables language extensions
43
#       --ec++                      Default language is C++
44
#       --eprom_size=N              Set eeprom size
45
#       --enhanced_core             Allow enhanced core instructions
46
#       -f file                     Read commands from a file
47
#       --initializers_in_flash     Places aggregate initializers in flash memory
48
#       --no_clustering             Disables clustering of variables
49
#       --no_code_motion            Disables code motion optimization
50
#       --no_cross_call             Disables cross-call optimization
51
#       --no_cse                    Disables common sub-expression elimination
52
#       --no_inline                 Disables function inlining
53
#       -lA file/dir                Generate a list file
54
#       -lC file/dir                Generate a list file
55
#       -m[stl]                     Memory model
56
#       -o filename                 Output filename
57
#       --require_prototypes        Verifies that prototypes are proper
58
#       -s[2369]                    Optimise code for speed, none,Low,Med,Hi
59
#       --strict_ansi
60
#       --silent                    Supress banner
61
#       -v[0-6]                     Specify processor variant
62
#       -y                          Places constants and literals
63
#       -z[2369]                    Optimise code for size, none,Low,Med,Hi
64
#
65
#
66
cc              = $(CC_PRE) $(avr_iar_compiler)
67
cc_init         =
68
cc_o_switch     =
69
cc_object       = -o $@
70
cc_source       = $<
71
cc_cmdfile      = $(basename $@).cmd
72
cc_flags        = --silent -f $(cc_cmdfile)
73
cc_defines      = $(AVR_IAR_DEFINES)
74
iar_includes    = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES)))))
75
iar_flags       = $(AVR_IAR_FLAGS)
76
 
77
cc_filter      := "$(notdir $(wildcard $(GBE_ROOT)/warnings.iar*))"
78
ifeq ($(strip $(cc_filter)), "warnings.iar")
79
cc_redirect     = 1
80
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.iar
81
endif
82
 
83
ifdef LEAVETMP
84
iar_flags       += -lC=$(basename $@).lst
85
endif
86
 
87
ifdef USE_STRICT_ANSI
88
iar_flags       += --strict_ansi
89
else
90
iar_flags       += -e
91
endif
92
 
93
 
94
ifdef USE_OPTIMISE
95
iar_flags       +=
96
else
97
iar_flags       += 
98
endif
99
 
100
ifdef USE_DEBUGINFO
101
cc_defines       += DEBUG
102
else
103
cc_defines       += NDEBUG
104
endif
105
 
106
ifeq "$(DEBUG)" "1"
107
iar_flags       += --debug
108
else
109
iar_flags       +=
110
endif
111
 
112
ifdef ALVL
113
cc_defines       += ALVL=$(ALVL)
114
endif
115
 
116
ifdef DLVL
117
cc_defines       += DLVL=$(DLVL)
118
endif
119
 
120
cc_defines      += __SOURCE__=$(notdir $<)
121
 
122
define cc_pre
123
        @$(echo) "[$<] compiling.."; \
124
        $(cmdfile) -ko$(cc_cmdfile) "\
125
                $(patsubst %,%\\n,$(CFLAGS)) \
126
                $(patsubst %,-D%\\n,$(cc_defines)) \
127
                $(subst =,$(space),$(patsubst %,%\\n,$(iar_flags))) \
128
                -I $(dir $<)\\n \
129
                $(patsubst %,-I %\\n,$(INCDIRS)) \
130
                $(patsubst %,-I %\\n,$(cc_includes)) \
131
                $(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_includes))) \
132
                $(cc_object)"
133
endef
134
 
135
ifndef LEAVETMP
136
define cc_post
137
        @$(rm) -f $(cc_cmdfile)
138
endef
139
else
140
define cc_post
141
endef
142
endif
143
 
144
###############################################################################
145
#..     C/C++ dependencies
146
#       depend and depend.err
147
#
148
iar_depend      = -D__STDC__
149
ifeq "$(DEBUG)" "1"
150
iar_depend      += -DDEBUG
151
endif
152
ifdef ALVL
153
iar_depend      += -DALVL=$(ALVL)
154
endif
155
ifdef DLVL
156
iar_depend      += -DDLVL=$(DLVL)
157
endif
158
iar_depend      += -D__SOURCE__=$(notdir $<)
159
 
160
ccdep           = $(XX_PRE)$(GBE_BIN)/mkdepend
161
ccdep_init      =
162
ccdep_o_switch  = -f -
163
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
164
ccdep_flags     = -MM -b -We -p \$$\(OBJDIR\)/ -o .$(o) \
165
                  $(filter -D%, $(CFLAGS)) \
166
                  $(filter -U%, $(CFLAGS)) \
167
                  $(patsubst %,-D%,$(cc_defines)) \
168
                  $(patsubst %,%,$(iar_depend)) \
169
                  $(patsubst %,-I %,$(INCDIRS)) \
170
                  $(patsubst %,-Y %,$(cc_includes)) \
171
                  $(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(iar_includes))) \
172
                  $(patsubst %,-Y %,$(NODEPDIRS))
173
 
174
ccdep_pre       =
175
ccdep_post      =
176
 
177
 
178
#..     C++ Compiler definition
179
#
180
cxx             = $(CC_PRE) $(iar_cpp_compiler)
181
cxx_init        =
182
cxx_o_switch    =
183
cxx_object      = -o $@
184
cxx_source      = $<
185
cxx_cmdfile     = $(basename $@).cmd
186
cxx_flags       = --ec++ -f $(cxx_cmdfile)
187
 
188
define cxx_pre
189
        @$(echo) [\$<] compiling.. ; \
190
        $(cmdfile) -ko$(cxx_cmdfile) "\
191
                $(patsubst %,%\\n,$(CFLAGS)) \
192
                $(patsubst %,-D%\\n,$(cc_defines)) \
193
                $(subst =,$(space),$(patsubst %,%\\n,$(iar_flags))) \
194
                -I $(dir $<)\\n \
195
                $(patsubst %,-I %\\n,$(INCDIRS)) \
196
                $(patsubst %,-I %\\n,$(cc_includes)) \
197
                $(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_includes))) \
198
                $(cxx_object)"
199
endef
200
 
201
ifndef LEAVETMP
202
define cxx_post
203
        @$(rm) -f $(cxx_cmdfile)
204
endef
205
else
206
define cxx_post
207
endef
208
endif
209
 
210
 
211
###############################################################################
212
#..     Assembler definition
213
#
214
# Note:  All the options go on the command line at present so this
215
#        passes a minimal set of definitions. (v4.3)
216
#
217
#       Assembler switches
218
#           -Ifile              Extend include path
219
#           -o file             Specfify output file
220
#           -S                  No messages
221
#           -r                  Generate symbolic debug info
222
#           -D symbol           Define a symbol
223
#           -f cmd_file         Take options from a command file
224
#
225
 
226
as              = $(XX_PRE) "$(avr_iar_assembler)"
227
as_init         =
228
as_o_switch     = -o $@
229
as_source       = $<
230
as_cmdfile      =
231
 
232
as_includes     =
233
as_flags        = -S $(AVR_IAR_ASFLAGS)
234
as_defines      = $(AVR_IAR_ASDEFINES)
235
 
236
#ifdef ASFLAGS
237
as_flags        += $(ASFLAGS)
238
#endif
239
 
240
ifeq "$(DEBUG)" "1"
241
as_flags        += -r
242
else
243
as_flags        +=
244
endif
245
 
246
ifdef as_defines
247
as_flags    += $(addprefix -D,$(as_defines))
248
endif
249
 
250
#ifdef INCDIRS
251
as_flags      += $(patsubst %,-I%,$(strip $(INCDIRS)))
252
#endif
253
 
254
ifdef as_includes
255
as_flags      += $(patsubst %,-I%,$(strip $(as_includes)))
256
endif
257
 
258
#ifdef AVR_IAR_INCLUDES
259
as_flags      += $(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES))))) ))
260
#endif
261
 
262
define as_pre
263
    @$(echo) [$@] Assembling file
264
endef
265
define as_post
266
endef
267
 
268
 
269
###############################################################################
270
#..     Archiver
271
#
272
#       Swicthes
273
#           -V              Verbose
274
#           -o file         Output file
275
#
276
ar              = $(XX_PRE) "$(avr_iar_librarian)"
277
ar_init         =
278
ar_flags        = $^
279
ar_o_switch     = -o $@
280
ar_term         =
281
 
282
 
283
 
284
define ar_pre
285
        @$(echo) [\$@] Creating library archive.. ; \
286
        $(rm) -f $@
287
endef
288
 
289
ifndef LEAVETMP
290
define ar_post
291
endef
292
else
293
define ar_post
294
endef
295
endif
296
 
297
 
298
###############################################################################
299
#..     Archive Merge
300
#
301
armerge              = $(XX_PRE) "$(avr_iar_librarian)"
302
armerge_init         =
303
armerge_flags        = $^
304
armerge_o_switch     = -o $@
305
 
306
define armerge_pre
307
        @$(echo) [\$@] Creating a Merged library.. ; \
308
        $(rm) -f $@
309
endef
310
 
311
ifndef LEAVETMP
312
define armerge_post
313
endef
314
else
315
define armerge_post
316
endef
317
endif
318
 
319
 
320
###############################################################################
321
#..     Linker
322
#
323
ld              = $(XX_PRE) $(avr_iar_linker)
324
ld_cmdfile      = $(basename $@).ld
325
ld_flags        = -f $(ld_cmdfile)
326
 
327
define ld_pre
328
        $(XX_PRE)$(echo) [$@] Linking program .. ;\
329
        export IAR_LIB; \
330
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
331
        $(cmdfile) -W2ko$(ld_cmdfile) "$($(notdir $(basename $@))_ld)"
332
endef
333
 
334
ifndef LEAVETMP
335
define ld_post
336
        @$(rm) -f $(ld_cmdfile)
337
endef
338
else
339
define ld_post
340
endef
341
endif
342
 
343
define LD_IAR
344
        $(show_environment)
345
        $(ld_pre)
346
        $(ld) $(ld_flags)
347
        $(ld_post)
348
endef
349
 
350
#
351
#   Create Library dependency file
352
#
353
define LDDEPEND
354
        $(XX_PRE) export IAR_LIB; \
355
                IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
335 dpurdie 356
        $(cmdfile) -W1ko$(@) "$($(DPLIST))" 
227 dpurdie 357
endef
358
 
359
 
360
#
361
#   Program Loader processing
362
#   Args:   $1 Path to the exe
363
#           $2 Path to the ProgLoader
364
#
365
#   The process
366
#       Remove 1st line from the executable
367
#       Remove the last 2 lines from the ProgLoader
368
#       Concatenate the exe + progloader to the original file name
369
#
370
define  LD_IAR_PROCESS
371
    $(XX_PRE) $(echo) "[$@]Process Program Loader .." ;\
372
    sed '-e$$d' $1 >$1.ed ;\
373
    sed '-e1,2d' $2 >$2.ed ;\
374
    rm -f $1.keep ;\
375
    mv $1 $1.keep ;\
376
    cat $1.ed $2.ed >$1   ;\
377
    rm $1.ed $2.ed
378
endef
379
 
380
#
381
#   Generate SXML file
382
#   Args:   $1  Path to the S19 file
383
#           $2  Path to the SXML file (output)
384
#           $3  Payload Type
385
#           $4  Major version
386
#           $5  Minor version
387
#           $6  Patch
388
#           $7  Build
389
#
390
define GENERATE_SXML
391
    $(XX_PRE) $(echo) "[$@]Generate SXML .." ;\
392
    rm -f $2;\
393
    echo "<Atmel_Image>" >$2;\
394
    echo "  <Header>" >>$2;\
395
    echo "    <version>0</version>" >>$2;\
396
    echo "    <builddate>$$(date +%c)</builddate>" >>$2;\
397
    echo "    <buildtime>$$(date +%s)</buildtime>" >>$2;\
398
    echo "    <platform>$(GBE_PLATFORM)</platform>" >>$2;\
399
    echo "    <type>$3</type>" >>$2;\
400
    echo "    <major>$4</major>" >>$2;\
401
    echo "    <minor>$5</minor>" >>$2;\
402
    echo "    <patch>$6</patch>" >>$2;\
403
    echo "    <build>$7</build>" >>$2;\
404
    echo "    <encrypted>false</encrypted>" >>$2;\
405
    echo "    <binary>false</binary>" >>$2;\
406
    echo "  </Header>" >>$2;\
407
    echo "  <Data>" >>$2;\
408
    cat $1 >>$2;\
409
    echo "  </Data>" >>$2;\
410
    echo "</Atmel_Image>" >>$2
411
endef
412
 
413
#