Subversion Repositories FlightCtrl

Rev

Rev 1031 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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