Subversion Repositories Projects

Rev

Rev 276 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 276 Rev 294
1
#--------------------------------------------------------------------
1
#--------------------------------------------------------------------
2
# MCU name
2
# MCU name
3
MCU = atmega644p
3
MCU = atmega644p
4
F_CPU = 20000000
4
F_CPU = 20000000
5
#-------------------------------------------------------------------
5
#-------------------------------------------------------------------
6
VERSION_MAJOR    =  0
6
VERSION_MAJOR    =  0
7
VERSION_MINOR    =  1
7
VERSION_MINOR    =  1
8
VERSION_PATCH    =  0
8
VERSION_PATCH    =  0
9
 
9
 
10
VERSION_SERIAL_MAJOR = 10	# Serial Protocol Major Version
10
VERSION_SERIAL_MAJOR = 10	# Serial Protocol Major Version
11
VERSION_SERIAL_MINOR = 0	# Serial Protocol Minor Version
11
VERSION_SERIAL_MINOR = 0	# Serial Protocol Minor Version
12
 
12
 
13
#-------------------------------------------------------------------
13
#-------------------------------------------------------------------
14
#OPTIONS
14
#OPTIONS
15
# Use one of the motor setups 
15
# Use one of the motor setups 
16
BOARD = FOLLOWME
16
BOARD = FOLLOWME
17
#BOARD = SDLOGGER
17
#BOARD = SDLOGGER
18
 
18
 
19
#-------------------------------------------------------------------
19
#-------------------------------------------------------------------
20
# get SVN revision
20
# get SVN revision
21
REV := $(shell sh -c "cat .svn/entries | sed -n '4p'")
21
REV := $(shell sh -c "cat .svn/entries | sed -n '4p'")
22
 
22
 
23
ifeq ($(MCU), atmega644p)
23
ifeq ($(MCU), atmega644p)
24
 FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
24
 FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
25
 HEX_NAME = MEGA644p_$(BOARD)
25
 HEX_NAME = MEGA644p_$(BOARD)
26
endif
26
endif
27
 
27
 
28
ifeq ($(F_CPU), 20000000)
28
ifeq ($(F_CPU), 20000000)
29
 QUARZ = 20MHZ
29
 QUARZ = 20MHZ
30
endif
30
endif
31
 
31
 
32
 
32
 
33
# Output format. (can be srec, ihex, binary)
33
# Output format. (can be srec, ihex, binary)
34
FORMAT = ihex
34
FORMAT = ihex
35
 
35
 
36
# Target file name (without extension).
36
# Target file name (without extension).
37
 
37
 
38
ifeq ($(VERSION_PATCH), 0)
38
ifeq ($(VERSION_PATCH), 0)
39
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV)
39
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV)
40
endif
40
endif
41
ifeq ($(VERSION_PATCH), 1)
41
ifeq ($(VERSION_PATCH), 1)
42
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV)
42
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV)
43
endif
43
endif
44
ifeq ($(VERSION_PATCH), 2)
44
ifeq ($(VERSION_PATCH), 2)
45
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV)
45
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV)
46
endif
46
endif
47
ifeq ($(VERSION_PATCH), 3)
47
ifeq ($(VERSION_PATCH), 3)
48
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV)
48
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV)
49
endif
49
endif
50
ifeq ($(VERSION_PATCH), 4)
50
ifeq ($(VERSION_PATCH), 4)
51
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV)
51
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV)
52
endif
52
endif
53
ifeq ($(VERSION_PATCH), 5)
53
ifeq ($(VERSION_PATCH), 5)
54
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV)
54
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV)
55
endif
55
endif
56
ifeq ($(VERSION_PATCH), 6)
56
ifeq ($(VERSION_PATCH), 6)
57
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV)
57
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV)
58
endif
58
endif
59
ifeq ($(VERSION_PATCH), 7)
59
ifeq ($(VERSION_PATCH), 7)
60
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV)
60
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV)
61
endif
61
endif
62
ifeq ($(VERSION_PATCH), 8)
62
ifeq ($(VERSION_PATCH), 8)
63
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV)
63
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV)
64
endif
64
endif
65
ifeq ($(VERSION_PATCH), 9)
65
ifeq ($(VERSION_PATCH), 9)
66
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV)
66
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV)
67
endif
67
endif
68
ifeq ($(VERSION_PATCH), 10)
68
ifeq ($(VERSION_PATCH), 10)
69
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV)
69
TARGET = FollowMe_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV)
70
endif
70
endif
71
 
71
 
72
 
72
 
73
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
73
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
74
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
74
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
75
OPT = 2
75
OPT = 2
76
 
76
 
77
##########################################################################################################
77
##########################################################################################################
78
# List C source files here. (C dependencies are automatically generated.)
78
# List C source files here. (C dependencies are automatically generated.)
79
SRC = main.c uart0.c uart1.c printf_P.c timer0.c  menu.c led.c ubx.c analog.c button.c
79
SRC = main.c uart0.c uart1.c printf_P.c timer0.c  menu.c led.c ubx.c analog.c button.c crc16.c ssc.c sdc.c fat16.c
80
#ssc.c sdc.c fat16.c
-
 
81
 
80
 
82
##########################################################################################################
81
##########################################################################################################
83
 
82
 
84
 
83
 
85
# List Assembler source files here.
84
# List Assembler source files here.
86
# 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
87
# will not be considered source files but generated files (assembler
86
# will not be considered source files but generated files (assembler
88
# output from the compiler), and will be deleted upon "make clean"!
87
# output from the compiler), and will be deleted upon "make clean"!
89
# 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,
90
# 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
91
# care about how the name is spelled on its command-line.
90
# care about how the name is spelled on its command-line.
92
ASRC = 
91
ASRC = 
93
 
92
 
94
 
93
 
95
 
94
 
96
# List any extra directories to look for include files here.
95
# List any extra directories to look for include files here.
97
#     Each directory must be seperated by a space.
96
#     Each directory must be seperated by a space.
98
EXTRAINCDIRS = 
97
EXTRAINCDIRS = 
99
 
98
 
100
 
99
 
101
# Optional compiler flags.
100
# Optional compiler flags.
102
#  -g:        generate debugging information (for GDB, or for COFF conversion)
101
#  -g:        generate debugging information (for GDB, or for COFF conversion)
103
#  -O*:       optimization level
102
#  -O*:       optimization level
104
#  -f...:     tuning, see gcc manual and avr-libc documentation
103
#  -f...:     tuning, see gcc manual and avr-libc documentation
105
#  -Wall...:  warning level
104
#  -Wall...:  warning level
106
#  -Wa,...:   tell GCC to pass this to the assembler.
105
#  -Wa,...:   tell GCC to pass this to the assembler.
107
#    -ahlms:  create assembler listing
106
#    -ahlms:  create assembler listing
108
CFLAGS = -O$(OPT) \
107
CFLAGS = -O$(OPT) \
109
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
108
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
110
-Wall -Wstrict-prototypes \
109
-Wall -Wstrict-prototypes \
111
-Wa,-adhlns=$(<:.c=.lst) \
110
-Wa,-adhlns=$(<:.c=.lst) \
112
$(patsubst %,-I%,$(EXTRAINCDIRS))
111
$(patsubst %,-I%,$(EXTRAINCDIRS))
113
 
112
 
114
 
113
 
115
# Set a "language standard" compiler flag.
114
# Set a "language standard" compiler flag.
116
#   Unremark just one line below to set the language standard to use.
115
#   Unremark just one line below to set the language standard to use.
117
#   gnu99 = C99 + GNU extensions. See GCC manual for more information.
116
#   gnu99 = C99 + GNU extensions. See GCC manual for more information.
118
#CFLAGS += -std=c89
117
#CFLAGS += -std=c89
119
#CFLAGS += -std=gnu89
118
#CFLAGS += -std=gnu89
120
#CFLAGS += -std=c99
119
#CFLAGS += -std=c99
121
CFLAGS += -std=gnu99
120
CFLAGS += -std=gnu99
122
 
121
 
123
CFLAGS += -DF_CPU=$(F_CPU) -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_PATCH=$(VERSION_PATCH) -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR)
122
CFLAGS += -DF_CPU=$(F_CPU) -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_PATCH=$(VERSION_PATCH) -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR)
124
 
123
 
125
ifeq ($(BOARD), FOLLOWME)
124
ifeq ($(BOARD), FOLLOWME)
126
 CFLAGS += -DUSE_FOLLOWME	
125
 CFLAGS += -DUSE_FOLLOWME	
127
endif
126
endif
128
ifeq ($(BOARD), SDLOGGER)
127
ifeq ($(BOARD), SDLOGGER)
129
 CFLAGS += -DUSE_SDLOGGER	
128
 CFLAGS += -DUSE_SDLOGGER	
130
endif
129
endif
131
 
130
 
132
 
131
 
133
# Optional assembler flags.
132
# Optional assembler flags.
134
#  -Wa,...:   tell GCC to pass this to the assembler.
133
#  -Wa,...:   tell GCC to pass this to the assembler.
135
#  -ahlms:    create listing
134
#  -ahlms:    create listing
136
#  -gstabs:   have the assembler create line number information; note that
135
#  -gstabs:   have the assembler create line number information; note that
137
#             for use in COFF files, additional information about filenames
136
#             for use in COFF files, additional information about filenames
138
#             and function names needs to be present in the assembler source
137
#             and function names needs to be present in the assembler source
139
#             files -- see avr-libc docs [FIXME: not yet described there]
138
#             files -- see avr-libc docs [FIXME: not yet described there]
140
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
139
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
141
 
140
 
142
 
141
 
143
 
142
 
144
# Optional linker flags.
143
# Optional linker flags.
145
#  -Wl,...:   tell GCC to pass this to linker.
144
#  -Wl,...:   tell GCC to pass this to linker.
146
#  -Map:      create map file
145
#  -Map:      create map file
147
#  --cref:    add cross reference to  map file
146
#  --cref:    add cross reference to  map file
148
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
147
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
149
 
148
 
150
# Additional libraries
149
# Additional libraries
151
 
150
 
152
# Minimalistic printf version
151
# Minimalistic printf version
153
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
152
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
154
 
153
 
155
# Floating point printf version (requires -lm below)
154
# Floating point printf version (requires -lm below)
156
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
155
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
157
 
156
 
158
# -lm = math library
157
# -lm = math library
159
LDFLAGS += -lm
158
LDFLAGS += -lm
160
 
159
 
161
 
160
 
162
##LDFLAGS += -T./linkerfile/avr5.x
161
##LDFLAGS += -T./linkerfile/avr5.x
163
 
162
 
164
 
163
 
165
 
164
 
166
# Programming support using avrdude. Settings and variables.
165
# Programming support using avrdude. Settings and variables.
167
 
166
 
168
# Programming hardware: alf avr910 avrisp bascom bsd 
167
# Programming hardware: alf avr910 avrisp bascom bsd 
169
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
168
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
170
#
169
#
171
# Type: avrdude -c ?
170
# Type: avrdude -c ?
172
# to get a full listing.
171
# to get a full listing.
173
#
172
#
174
#AVRDUDE_PROGRAMMER = dt006
173
#AVRDUDE_PROGRAMMER = dt006
175
#AVRDUDE_PROGRAMMER = stk200
174
#AVRDUDE_PROGRAMMER = stk200
176
#AVRDUDE_PROGRAMMER = ponyser
175
#AVRDUDE_PROGRAMMER = ponyser
177
AVRDUDE_PROGRAMMER = avrispv2
176
AVRDUDE_PROGRAMMER = avrispv2
178
#falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden
177
#falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden
179
 
178
 
180
#AVRDUDE_PORT = com1    # programmer connected to serial device
179
#AVRDUDE_PORT = com1    # programmer connected to serial device
181
#AVRDUDE_PORT = lpt1    # programmer connected to parallel port
180
#AVRDUDE_PORT = lpt1    # programmer connected to parallel port
182
AVRDUDE_PORT = usb # programmer connected to USB
181
AVRDUDE_PORT = usb # programmer connected to USB
183
 
182
 
184
#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex 
183
#AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex 
185
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS)
184
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS)
186
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
185
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
187
 
186
 
188
#avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex
187
#avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex
189
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
188
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
190
 
189
 
191
# Uncomment the following if you want avrdude's erase cycle counter.
190
# Uncomment the following if you want avrdude's erase cycle counter.
192
# Note that this counter needs to be initialized first using -Yn,
191
# Note that this counter needs to be initialized first using -Yn,
193
# see avrdude manual.
192
# see avrdude manual.
194
#AVRDUDE_ERASE += -y
193
#AVRDUDE_ERASE += -y
195
 
194
 
196
# Uncomment the following if you do /not/ wish a verification to be
195
# Uncomment the following if you do /not/ wish a verification to be
197
# performed after programming the device.
196
# performed after programming the device.
198
AVRDUDE_FLAGS += -V
197
AVRDUDE_FLAGS += -V
199
 
198
 
200
# Increase verbosity level.  Please use this when submitting bug
199
# Increase verbosity level.  Please use this when submitting bug
201
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
200
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
202
# to submit bug reports.
201
# to submit bug reports.
203
#AVRDUDE_FLAGS += -v -v
202
#AVRDUDE_FLAGS += -v -v
204
 
203
 
205
# ---------------------------------------------------------------------------
204
# ---------------------------------------------------------------------------
206
# Define directories, if needed.
205
# Define directories, if needed.
207
DIRAVR = c:/winavr
206
DIRAVR = c:/winavr
208
DIRAVRBIN = $(DIRAVR)/bin
207
DIRAVRBIN = $(DIRAVR)/bin
209
DIRAVRUTILS = $(DIRAVR)/utils/bin
208
DIRAVRUTILS = $(DIRAVR)/utils/bin
210
DIRINC = .
209
DIRINC = .
211
DIRLIB = $(DIRAVR)/avr/lib
210
DIRLIB = $(DIRAVR)/avr/lib
212
 
211
 
213
 
212
 
214
# Define programs and commands.
213
# Define programs and commands.
215
SHELL = sh
214
SHELL = sh
216
 
215
 
217
CC = avr-gcc
216
CC = avr-gcc
218
 
217
 
219
OBJCOPY = avr-objcopy
218
OBJCOPY = avr-objcopy
220
OBJDUMP = avr-objdump
219
OBJDUMP = avr-objdump
221
SIZE = avr-size
220
SIZE = avr-size
222
 
221
 
223
# Programming support using avrdude.
222
# Programming support using avrdude.
224
AVRDUDE = avrdude
223
AVRDUDE = avrdude
225
 
224
 
226
REMOVE = rm -f
225
REMOVE = rm -f
227
COPY = cp
226
COPY = cp
228
 
227
 
229
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
228
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
230
ELFSIZE = $(SIZE) -A $(TARGET).elf
229
ELFSIZE = $(SIZE) -A $(TARGET).elf
231
 
230
 
232
# Define Messages
231
# Define Messages
233
# English
232
# English
234
MSG_ERRORS_NONE = Errors: none
233
MSG_ERRORS_NONE = Errors: none
235
MSG_BEGIN = -------- begin --------
234
MSG_BEGIN = -------- begin --------
236
MSG_END = --------  end  --------
235
MSG_END = --------  end  --------
237
MSG_SIZE_BEFORE = Size before: 
236
MSG_SIZE_BEFORE = Size before: 
238
MSG_SIZE_AFTER = Size after:
237
MSG_SIZE_AFTER = Size after:
239
MSG_COFF = Converting to AVR COFF:
238
MSG_COFF = Converting to AVR COFF:
240
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
239
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
241
MSG_FLASH = Creating load file for Flash:
240
MSG_FLASH = Creating load file for Flash:
242
MSG_EEPROM = Creating load file for EEPROM:
241
MSG_EEPROM = Creating load file for EEPROM:
243
MSG_EXTENDED_LISTING = Creating Extended Listing:
242
MSG_EXTENDED_LISTING = Creating Extended Listing:
244
MSG_SYMBOL_TABLE = Creating Symbol Table:
243
MSG_SYMBOL_TABLE = Creating Symbol Table:
245
MSG_LINKING = Linking:
244
MSG_LINKING = Linking:
246
MSG_COMPILING = Compiling:
245
MSG_COMPILING = Compiling:
247
MSG_ASSEMBLING = Assembling:
246
MSG_ASSEMBLING = Assembling:
248
MSG_CLEANING = Cleaning project:
247
MSG_CLEANING = Cleaning project:
249
 
248
 
250
 
249
 
251
# Define all object files.
250
# Define all object files.
252
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
251
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
253
 
252
 
254
# Define all listing files.
253
# Define all listing files.
255
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
254
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
256
 
255
 
257
# Combine all necessary flags and optional flags.
256
# Combine all necessary flags and optional flags.
258
# Add target processor to flags.
257
# Add target processor to flags.
259
#ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS)
258
#ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS)
260
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
259
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
261
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
260
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
262
 
261
 
263
 
262
 
264
# Default target.
263
# Default target.
265
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
264
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
266
	$(TARGET).lss $(TARGET).sym sizeafter finished end
265
	$(TARGET).lss $(TARGET).sym sizeafter finished end
267
 
266
 
268
 
267
 
269
# Eye candy.
268
# Eye candy.
270
# AVR Studio 3.x does not check make's exit code but relies on
269
# AVR Studio 3.x does not check make's exit code but relies on
271
# the following magic strings to be generated by the compile job.
270
# the following magic strings to be generated by the compile job.
272
begin:
271
begin:
273
	@echo
272
	@echo
274
	@echo $(MSG_BEGIN)
273
	@echo $(MSG_BEGIN)
275
 
274
 
276
finished:
275
finished:
277
	@echo $(MSG_ERRORS_NONE)
276
	@echo $(MSG_ERRORS_NONE)
278
 
277
 
279
end:
278
end:
280
	@echo $(MSG_END)
279
	@echo $(MSG_END)
281
	@echo
280
	@echo
282
 
281
 
283
 
282
 
284
# Display size of file.
283
# Display size of file.
285
sizebefore:
284
sizebefore:
286
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
285
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
287
 
286
 
288
sizeafter:
287
sizeafter:
289
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
288
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
290
 
289
 
291
 
290
 
292
 
291
 
293
# Display compiler version information.
292
# Display compiler version information.
294
gccversion : 
293
gccversion : 
295
	@$(CC) --version
294
	@$(CC) --version
296
 
295
 
297
 
296
 
298
# Convert ELF to COFF for use in debugging / simulating in
297
# Convert ELF to COFF for use in debugging / simulating in
299
# AVR Studio or VMLAB.
298
# AVR Studio or VMLAB.
300
COFFCONVERT=$(OBJCOPY) --debugging \
299
COFFCONVERT=$(OBJCOPY) --debugging \
301
	--change-section-address .data-0x800000 \
300
	--change-section-address .data-0x800000 \
302
	--change-section-address .bss-0x800000 \
301
	--change-section-address .bss-0x800000 \
303
	--change-section-address .noinit-0x800000 \
302
	--change-section-address .noinit-0x800000 \
304
	--change-section-address .eeprom-0x810000 
303
	--change-section-address .eeprom-0x810000 
305
 
304
 
306
 
305
 
307
coff: $(TARGET).elf
306
coff: $(TARGET).elf
308
	@echo
307
	@echo
309
	@echo $(MSG_COFF) $(TARGET).cof
308
	@echo $(MSG_COFF) $(TARGET).cof
310
	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
309
	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
311
 
310
 
312
 
311
 
313
extcoff: $(TARGET).elf
312
extcoff: $(TARGET).elf
314
	@echo
313
	@echo
315
	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
314
	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
316
	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
315
	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
317
 
316
 
318
 
317
 
319
 
318
 
320
 
319
 
321
# Program the device.  
320
# Program the device.  
322
program: $(TARGET).hex $(TARGET).eep
321
program: $(TARGET).hex $(TARGET).eep
323
	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
322
	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
324
 
323
 
325
 
324
 
326
 
325
 
327
 
326
 
328
# Create final output files (.hex, .eep) from ELF output file.
327
# Create final output files (.hex, .eep) from ELF output file.
329
%.hex: %.elf
328
%.hex: %.elf
330
	@echo
329
	@echo
331
	@echo $(MSG_FLASH) $@
330
	@echo $(MSG_FLASH) $@
332
	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
331
	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
333
 
332
 
334
%.eep: %.elf
333
%.eep: %.elf
335
	@echo
334
	@echo
336
	@echo $(MSG_EEPROM) $@
335
	@echo $(MSG_EEPROM) $@
337
	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
336
	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
338
	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
337
	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
339
 
338
 
340
# Create extended listing file from ELF output file.
339
# Create extended listing file from ELF output file.
341
%.lss: %.elf
340
%.lss: %.elf
342
	@echo
341
	@echo
343
	@echo $(MSG_EXTENDED_LISTING) $@
342
	@echo $(MSG_EXTENDED_LISTING) $@
344
	$(OBJDUMP) -h -S $< > $@
343
	$(OBJDUMP) -h -S $< > $@
345
 
344
 
346
# Create a symbol table from ELF output file.
345
# Create a symbol table from ELF output file.
347
%.sym: %.elf
346
%.sym: %.elf
348
	@echo
347
	@echo
349
	@echo $(MSG_SYMBOL_TABLE) $@
348
	@echo $(MSG_SYMBOL_TABLE) $@
350
	avr-nm -n $< > $@
349
	avr-nm -n $< > $@
351
 
350
 
352
 
351
 
353
 
352
 
354
# Link: create ELF output file from object files.
353
# Link: create ELF output file from object files.
355
.SECONDARY : $(TARGET).elf
354
.SECONDARY : $(TARGET).elf
356
.PRECIOUS : $(OBJ)
355
.PRECIOUS : $(OBJ)
357
%.elf: $(OBJ)
356
%.elf: $(OBJ)
358
	@echo
357
	@echo
359
	@echo $(MSG_LINKING) $@
358
	@echo $(MSG_LINKING) $@
360
	$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
359
	$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
361
 
360
 
362
 
361
 
363
# Compile: create object files from C source files.
362
# Compile: create object files from C source files.
364
%.o : %.c
363
%.o : %.c
365
	@echo
364
	@echo
366
	@echo $(MSG_COMPILING) $<
365
	@echo $(MSG_COMPILING) $<
367
	$(CC) -c $(ALL_CFLAGS) $< -o $@
366
	$(CC) -c $(ALL_CFLAGS) $< -o $@
368
 
367
 
369
 
368
 
370
# Compile: create assembler files from C source files.
369
# Compile: create assembler files from C source files.
371
%.s : %.c
370
%.s : %.c
372
	$(CC) -S $(ALL_CFLAGS) $< -o $@
371
	$(CC) -S $(ALL_CFLAGS) $< -o $@
373
 
372
 
374
 
373
 
375
# Assemble: create object files from assembler source files.
374
# Assemble: create object files from assembler source files.
376
%.o : %.S
375
%.o : %.S
377
	@echo
376
	@echo
378
	@echo $(MSG_ASSEMBLING) $<
377
	@echo $(MSG_ASSEMBLING) $<
379
	$(CC) -c $(ALL_ASFLAGS) $< -o $@
378
	$(CC) -c $(ALL_ASFLAGS) $< -o $@
380
 
379
 
381
 
380
 
382
 
381
 
383
 
382
 
384
 
383
 
385
 
384
 
386
# Target: clean project.
385
# Target: clean project.
387
clean: begin clean_list finished end
386
clean: begin clean_list finished end
388
 
387
 
389
clean_list :
388
clean_list :
390
	@echo
389
	@echo
391
	@echo $(MSG_CLEANING)
390
	@echo $(MSG_CLEANING)
392
#	$(REMOVE) $(TARGET).hex
391
#	$(REMOVE) $(TARGET).hex
393
	$(REMOVE) $(TARGET).eep
392
	$(REMOVE) $(TARGET).eep
394
	$(REMOVE) $(TARGET).obj
393
	$(REMOVE) $(TARGET).obj
395
	$(REMOVE) $(TARGET).cof
394
	$(REMOVE) $(TARGET).cof
396
	$(REMOVE) $(TARGET).elf
395
	$(REMOVE) $(TARGET).elf
397
	$(REMOVE) $(TARGET).map
396
	$(REMOVE) $(TARGET).map
398
	$(REMOVE) $(TARGET).obj
397
	$(REMOVE) $(TARGET).obj
399
	$(REMOVE) $(TARGET).a90
398
	$(REMOVE) $(TARGET).a90
400
	$(REMOVE) $(TARGET).sym
399
	$(REMOVE) $(TARGET).sym
401
	$(REMOVE) $(TARGET).lnk
400
	$(REMOVE) $(TARGET).lnk
402
	$(REMOVE) $(TARGET).lss
401
	$(REMOVE) $(TARGET).lss
403
	$(REMOVE) $(OBJ)
402
	$(REMOVE) $(OBJ)
404
	$(REMOVE) $(LST)
403
	$(REMOVE) $(LST)
405
	$(REMOVE) $(SRC:.c=.s)
404
	$(REMOVE) $(SRC:.c=.s)
406
	$(REMOVE) $(SRC:.c=.d)
405
	$(REMOVE) $(SRC:.c=.d)
407
 
406
 
408
 
407
 
409
# Automatically generate C source code dependencies. 
408
# Automatically generate C source code dependencies. 
410
# (Code originally taken from the GNU make user manual and modified 
409
# (Code originally taken from the GNU make user manual and modified 
411
# (See README.txt Credits).)
410
# (See README.txt Credits).)
412
#
411
#
413
# Note that this will work with sh (bash) and sed that is shipped with WinAVR
412
# Note that this will work with sh (bash) and sed that is shipped with WinAVR
414
# (see the SHELL variable defined above).
413
# (see the SHELL variable defined above).
415
# This may not work with other shells or other seds.
414
# This may not work with other shells or other seds.
416
#
415
#
417
%.d: %.c
416
%.d: %.c
418
	set -e; $(CC) -MM $(ALL_CFLAGS) $< \
417
	set -e; $(CC) -MM $(ALL_CFLAGS) $< \
419
	| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
418
	| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
420
	[ -s $@ ] || rm -f $@
419
	[ -s $@ ] || rm -f $@
421
 
420
 
422
 
421
 
423
# Remove the '-' if you want to see the dependency files generated.
422
# Remove the '-' if you want to see the dependency files generated.
424
-include $(SRC:.c=.d)
423
-include $(SRC:.c=.d)
425
 
424
 
426
 
425
 
427
 
426
 
428
# Listing of phony targets.
427
# Listing of phony targets.
429
.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
428
.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
430
	clean clean_list program
429
	clean clean_list program
431
 
430