Subversion Repositories FlightCtrl

Rev

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

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