Subversion Repositories HomeAutomation

Rev

Rev 356 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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