Subversion Repositories HomeAutomation

Rev

Rev 658 | Rev 693 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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