Subversion Repositories FlightCtrl

Rev

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

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