Subversion Repositories Projects

Rev

Rev 1307 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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