Subversion Repositories HomeAutomation

Rev

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

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