Subversion Repositories FlightCtrl

Rev

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

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