Subversion Repositories FlightCtrl

Rev

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

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