OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src-c/] [dhrystone_4mcu/] [original_files/] [Makefile] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 olivier.gi
# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
2
# Released to the Public Domain
3
# Please read the make user manual!
4
#
5
# Additional material for this makefile was submitted by:
6
#  Tim Henigan
7
#  Peter Fleury
8
#  Reiner Patommel
9
#  Sander Pool
10
#  Frederik Rouleau
11
#  Markus Pfaff
12
#
13
# On command line:
14
#
15
# make all = Make software.
16
#
17
# make clean = Clean out built project files.
18
#
19
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
20
#
21
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
22
#                4.07 or greater).
23
#
24
# make program = Download the hex file to the device, using avrdude.  Please
25
#                customize the avrdude settings below first!
26
#
27
# make filename.s = Just compile filename.c into the assembler code only
28
#
29
# To rebuild project do "make clean" then "make all".
30
#
31
 
32
 
33
# MCU name
34
MCU = atmega64
35
 
36
# Output format. (can be srec, ihex, binary)
37
FORMAT = ihex
38
 
39
# Target file name (without extension).
40
TARGET = Dhrystone
41
 
42
 
43
# List C source files here. (C dependencies are automatically generated.)
44
SRC = dhry21a.c dhry21b.c timers_b.c estubs.c
45
 
46
 
47
# List Assembler source files here.
48
# Make them always end in a capital .S.  Files ending in a lowercase .s
49
# will not be considered source files but generated files (assembler
50
# output from the compiler), and will be deleted upon "make clean"!
51
# Even though the DOS/Win* filesystem matches both .s and .S the same,
52
# it will preserve the spelling of the filenames, and gcc itself does
53
# care about how the name is spelled on its command-line.
54
ASRC =
55
 
56
 
57
# Optimization level, can be [0, 1, 2, 3, s].
58
# 0 = turn off optimization. s = optimize for size.
59
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
60
OPT = s
61
 
62
 
63
# List any extra directories to look for include files here.
64
#     Each directory must be seperated by a space.
65
EXTRAINCDIRS =
66
 
67
 
68
# Compiler flag to set the C Standard level.
69
CSTANDARD_C89 = c89
70
CSTANDARD_GNU89 = gnu89
71
CSTANDARD_C99 = c99
72
CSTANDARD_GNU99 = gnu99
73
CSTANDARD = -std=$(CSTANDARD_GNU99)
74
 
75
 
76
 
77
# Compiler flags.
78
#  -g:           generate debugging information
79
#  -O*:          optimization level
80
#  -f...:        tuning, see GCC manual and avr-libc documentation
81
#  -Wall...:     warning level
82
#  -Wa,...:      tell GCC to pass this to the assembler.
83
#    -adhlns...: create assembler listing
84
CFLAGS = -g
85
CFLAGS += -O$(OPT)
86
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct
87
CFLAGS += -Wall -Wstrict-prototypes
88
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
89
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
90
CFLAGS += $(CSTANDARD)
91
 
92
 
93
 
94
# Assembler flags.
95
#  -Wa,...:   tell GCC to pass this to the assembler.
96
#  -ahlms:    create listing
97
#  -gstabs:   have the assembler create line number information; note that
98
#             for use in COFF files, additional information about filenames
99
#             and function names needs to be present in the assembler source
100
#             files -- see avr-libc docs [FIXME: not yet described there]
101
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
102
 
103
 
104
 
105
#Additional libraries.
106
 
107
PRINTF_LIB_NONE =
108
 
109
# Minimalistic printf version
110
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
111
 
112
# Floating point printf version (requires MATH_LIB = -lm below)
113
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
114
 
115
PRINTF_LIB = $(PRINTF_LIB_NONE)
116
 
117
MATH_LIB = -lm
118
 
119
 
120
 
121
# Linker flags.
122
#  -Wl,...:     tell GCC to pass this to linker.
123
#    -Map:      create map file
124
#    --cref:    add cross reference to  map file
125
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref $(PRINTF_LIB) $(MATH_LIB)
126
 
127
 
128
 
129
 
130
# Programming support using avrdude. Settings and variables.
131
 
132
# Programming hardware: alf avr910 avrisp bascom bsd
133
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
134
#
135
# Type: avrdude -c ?
136
# to get a full listing.
137
#
138
AVRDUDE_PROGRAMMER = stk500
139
 
140
# com1 = serial port. Use lpt1 to connect to parallel port.
141
AVRDUDE_PORT = com1    # programmer connected to serial device
142
 
143
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
144
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
145
 
146
 
147
# Uncomment the following if you want avrdude's erase cycle counter.
148
# Note that this counter needs to be initialized first using -Yn,
149
# see avrdude manual.
150
#AVRDUDE_ERASE_COUNTER = -y
151
 
152
# Uncomment the following if you do /not/ wish a verification to be
153
# performed after programming the device.
154
#AVRDUDE_NO_VERIFY = -V
155
 
156
# Increase verbosity level.  Please use this when submitting bug
157
# reports about avrdude. See 
158
# to submit bug reports.
159
#AVRDUDE_VERBOSE = -v -v
160
 
161
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
162
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
163
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
164
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
165
 
166
 
167
 
168
# ---------------------------------------------------------------------------
169
 
170
# Define directories, if needed.
171
DIRAVR = C:/CygWin/WinAVR
172
DIRAVRBIN = $(DIRAVR)/bin
173
DIRAVRUTILS = $(DIRAVR)/utils/bin
174
DIRINC = .
175
DIRLIB = $(DIRAVR)/avr/lib
176
 
177
 
178
# Define programs and commands.
179
SHELL = sh
180
CC = avr-gcc
181
OBJCOPY = avr-objcopy
182
OBJDUMP = avr-objdump
183
SIZE = avr-size
184
NM = avr-nm
185
AVRDUDE = avrdude
186
REMOVE = rm -f
187
COPY = cp
188
 
189
 
190
 
191
 
192
# Define Messages
193
# English
194
MSG_ERRORS_NONE = Errors: none
195
MSG_BEGIN = -------- begin --------
196
MSG_END = --------  end  --------
197
MSG_SIZE_BEFORE = Size before:
198
MSG_SIZE_AFTER = Size after:
199
MSG_COFF = Converting to AVR COFF:
200
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
201
MSG_FLASH = Creating load file for Flash:
202
MSG_EEPROM = Creating load file for EEPROM:
203
MSG_EXTENDED_LISTING = Creating Extended Listing:
204
MSG_SYMBOL_TABLE = Creating Symbol Table:
205
MSG_LINKING = Linking:
206
MSG_COMPILING = Compiling:
207
MSG_ASSEMBLING = Assembling:
208
MSG_CLEANING = Cleaning project:
209
 
210
 
211
 
212
 
213
# Define all object files.
214
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
215
 
216
# Define all listing files.
217
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
218
 
219
 
220
# Compiler flags to generate dependency files.
221
GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
222
 
223
 
224
# Combine all necessary flags and optional flags.
225
# Add target processor to flags.
226
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
227
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
228
 
229
 
230
 
231
 
232
 
233
# Default target.
234
all: begin gccversion sizebefore build sizeafter finished end
235
 
236
build: elf hex eep lss sym
237
 
238
elf: $(TARGET).elf
239
hex: $(TARGET).hex
240
eep: $(TARGET).eep
241
lss: $(TARGET).lss
242
sym: $(TARGET).sym
243
 
244
 
245
 
246
# Eye candy.
247
# AVR Studio 3.x does not check make's exit code but relies on
248
# the following magic strings to be generated by the compile job.
249
begin:
250
        @echo
251
        @echo $(MSG_BEGIN)
252
 
253
finished:
254
        @echo $(MSG_ERRORS_NONE)
255
 
256
end:
257
        @echo $(MSG_END)
258
        @echo
259
 
260
 
261
# Display size of file.
262
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
263
ELFSIZE = $(SIZE) -A $(TARGET).elf
264
sizebefore:
265
        @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
266
 
267
sizeafter:
268
        @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
269
 
270
 
271
 
272
# Display compiler version information.
273
gccversion :
274
        @$(CC) --version
275
 
276
 
277
 
278
# Program the device.
279
program: $(TARGET).hex $(TARGET).eep
280
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
281
 
282
 
283
 
284
 
285
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
286
COFFCONVERT=$(OBJCOPY) --debugging \
287
--change-section-address .data-0x800000 \
288
--change-section-address .bss-0x800000 \
289
--change-section-address .noinit-0x800000 \
290
--change-section-address .eeprom-0x810000
291
 
292
 
293
coff: $(TARGET).elf
294
        @echo
295
        @echo $(MSG_COFF) $(TARGET).cof
296
        $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
297
 
298
 
299
extcoff: $(TARGET).elf
300
        @echo
301
        @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
302
        $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
303
 
304
 
305
 
306
# Create final output files (.hex, .eep) from ELF output file.
307
%.hex: %.elf
308
        @echo
309
        @echo $(MSG_FLASH) $@
310
        $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
311
 
312
%.eep: %.elf
313
        @echo
314
        @echo $(MSG_EEPROM) $@
315
        -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
316
        --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
317
 
318
# Create extended listing file from ELF output file.
319
%.lss: %.elf
320
        @echo
321
        @echo $(MSG_EXTENDED_LISTING) $@
322
        $(OBJDUMP) -h -S $< > $@
323
 
324
# Create a symbol table from ELF output file.
325
%.sym: %.elf
326
        @echo
327
        @echo $(MSG_SYMBOL_TABLE) $@
328
        $(NM) -n $< > $@
329
 
330
 
331
 
332
# Link: create ELF output file from object files.
333
.SECONDARY : $(TARGET).elf
334
.PRECIOUS : $(OBJ)
335
%.elf: $(OBJ)
336
        @echo
337
        @echo $(MSG_LINKING) $@
338
        $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
339
 
340
 
341
# Compile: create object files from C source files.
342
%.o : %.c
343
        @echo
344
        @echo $(MSG_COMPILING) $<
345
        $(CC) -c $(ALL_CFLAGS) $< -o $@
346
 
347
 
348
# Compile: create assembler files from C source files.
349
%.s : %.c
350
        $(CC) -S $(ALL_CFLAGS) $< -o $@
351
 
352
 
353
# Assemble: create object files from assembler source files.
354
%.o : %.S
355
        @echo
356
        @echo $(MSG_ASSEMBLING) $<
357
        $(CC) -c $(ALL_ASFLAGS) $< -o $@
358
 
359
 
360
 
361
# Target: clean project.
362
clean: begin clean_list finished end
363
 
364
clean_list :
365
        @echo
366
        @echo $(MSG_CLEANING)
367
        $(REMOVE) $(TARGET).hex
368
        $(REMOVE) $(TARGET).eep
369
        $(REMOVE) $(TARGET).obj
370
        $(REMOVE) $(TARGET).cof
371
        $(REMOVE) $(TARGET).elf
372
        $(REMOVE) $(TARGET).map
373
        $(REMOVE) $(TARGET).obj
374
        $(REMOVE) $(TARGET).a90
375
        $(REMOVE) $(TARGET).sym
376
        $(REMOVE) $(TARGET).lnk
377
        $(REMOVE) $(TARGET).lss
378
        $(REMOVE) $(OBJ)
379
        $(REMOVE) $(LST)
380
        $(REMOVE) $(SRC:.c=.s)
381
        $(REMOVE) $(SRC:.c=.d)
382
        $(REMOVE) .dep/*
383
 
384
 
385
 
386
# Include the dependency files.
387
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
388
 
389
 
390
# Listing of phony targets.
391
.PHONY : all begin finish end sizebefore sizeafter gccversion \
392
build elf hex eep lss sym coff extcoff \
393
clean clean_list program
394
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.