Subversion Repositories HomeAutomation

Rev

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

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