Subversion Repositories FlightCtrl

Rev

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

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