Subversion Repositories FlightCtrl

Rev

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

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