Subversion Repositories HomeAutomation

Rev

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

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