Subversion Repositories MK3Mag

Rev

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

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