Subversion Repositories FlightCtrl

Rev

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

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