Subversion Repositories HomeAutomation

Rev

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

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