Subversion Repositories HomeAutomation

Rev

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

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