Subversion Repositories HomeAutomation

Rev

Rev 484 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 484 Rev 532
1
include bios.inc
1
include bios.inc
2
 
2
 
3
# Target file name (without extension).
3
# Target file name (without extension).
4
TARGET = main
4
TARGET = main
5
 
5
 
6
LIBDIR = ../../avr-lib
6
LIBDIR = ../../avr-lib
7
include $(LIBDIR)/system.inc
7
include $(LIBDIR)/system.inc
8
 
8
 
9
# List C source files here. (C dependencies are automatically generated.)
9
# List C source files here. (C dependencies are automatically generated.)
10
CSRC =	$(TARGET).c\
10
CSRC =	$(TARGET).c\
11
		$(LIBDIR)/drivers/timer/timebase.c\
11
		$(LIBDIR)/drivers/timer/timebase.c\
12
		$(LIBDIR)/drivers/mcu/mcu.c\
12
		$(LIBDIR)/drivers/mcu/mcu.c\
13
		$(LIBDIR)/drivers/ir/receiver/irreceiver.c\
13
		$(LIBDIR)/drivers/ir/receiver/irreceiver.c\
-
 
14
		$(LIBDIR)/drivers/ir/ircommon.c\
14
 
15
 
15
# List Assembler source files here.
16
# List Assembler source files here.
16
# Make them always end in a capital .S.  Files ending in a lowercase .s
17
# Make them always end in a capital .S.  Files ending in a lowercase .s
17
# will not be considered source files but generated files (assembler
18
# will not be considered source files but generated files (assembler
18
# output from the compiler), and will be deleted upon "make clean"!
19
# output from the compiler), and will be deleted upon "make clean"!
19
# Even though the DOS/Win* filesystem matches both .s and .S the same,
20
# Even though the DOS/Win* filesystem matches both .s and .S the same,
20
# it will preserve the spelling of the filenames, and gcc itself does
21
# it will preserve the spelling of the filenames, and gcc itself does
21
# care about how the name is spelled on its command-line.
22
# care about how the name is spelled on its command-line.
22
ASRC = 
23
ASRC = 
23
 
24
 
24
 
25
 
25
# Optimization level, can be [0, 1, 2, 3, s]. 
26
# Optimization level, can be [0, 1, 2, 3, s]. 
26
# 0 = turn off optimization. s = optimize for size.
27
# 0 = turn off optimization. s = optimize for size.
27
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
28
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
28
OPT = s
29
OPT = s
29
#OPT = 3
30
#OPT = 3
30
 
31
 
31
# Debugging format.
32
# Debugging format.
32
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
33
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
33
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
34
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
34
DEBUG = stabs
35
DEBUG = stabs
35
#DEBUG = dwarf-2
36
#DEBUG = dwarf-2
36
 
37
 
37
# List any extra directories to look for include files here.
38
# List any extra directories to look for include files here.
38
#     Each directory must be seperated by a space.
39
#     Each directory must be seperated by a space.
39
EXTRAINCDIRS = $(LIBDIR)
40
EXTRAINCDIRS = $(LIBDIR)
40
 
41
 
41
# Compiler flag to set the C Standard level.
42
# Compiler flag to set the C Standard level.
42
# c89   - "ANSI" C
43
# c89   - "ANSI" C
43
# gnu89 - c89 plus GCC extensions
44
# gnu89 - c89 plus GCC extensions
44
# c99   - ISO C99 standard (not yet fully implemented)
45
# c99   - ISO C99 standard (not yet fully implemented)
45
# gnu99 - c99 plus GCC extensions
46
# gnu99 - c99 plus GCC extensions
46
CSTANDARD = -std=gnu99
47
CSTANDARD = -std=gnu99
47
 
48
 
48
# Place -D or -U options here
49
# Place -D or -U options here
49
CDEFS =
50
CDEFS =
50
 
51
 
51
# Place -I options here
52
# Place -I options here
52
CINCS =
53
CINCS =
53
 
54
 
54
 
55
 
55
# Compiler flags.
56
# Compiler flags.
56
#  -g*:          generate debugging information
57
#  -g*:          generate debugging information
57
#  -O*:          optimization level
58
#  -O*:          optimization level
58
#  -f...:        tuning, see GCC manual and avr-libc documentation
59
#  -f...:        tuning, see GCC manual and avr-libc documentation
59
#  -Wall...:     warning level
60
#  -Wall...:     warning level
60
#  -Wa,...:      tell GCC to pass this to the assembler.
61
#  -Wa,...:      tell GCC to pass this to the assembler.
61
#    -adhlns...: create assembler listing
62
#    -adhlns...: create assembler listing
62
CFLAGS = -mmcu=$(MCU) -I.
63
CFLAGS = -mmcu=$(MCU) -I.
63
CFLAGS += -g$(DEBUG)
64
CFLAGS += -g$(DEBUG)
64
CFLAGS += $(CDEFS) $(CINCS)
65
CFLAGS += $(CDEFS) $(CINCS)
65
CFLAGS += -O$(OPT)
66
CFLAGS += -O$(OPT)
66
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
67
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
67
CFLAGS += -Wall -Wstrict-prototypes
68
CFLAGS += -Wall -Wstrict-prototypes
68
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
69
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
69
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
70
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
70
CFLAGS += $(CSTANDARD)
71
CFLAGS += $(CSTANDARD)
71
 
72
 
72
 
73
 
73
 
74
 
74
# Assembler flags.
75
# Assembler flags.
75
#  -Wa,...:   tell GCC to pass this to the assembler.
76
#  -Wa,...:   tell GCC to pass this to the assembler.
76
#  -ahlms:    create listing
77
#  -ahlms:    create listing
77
#  -gstabs:   have the assembler create line number information; note that
78
#  -gstabs:   have the assembler create line number information; note that
78
#             for use in COFF files, additional information about filenames
79
#             for use in COFF files, additional information about filenames
79
#             and function names needs to be present in the assembler source
80
#             and function names needs to be present in the assembler source
80
#             files -- see avr-libc docs [FIXME: not yet described there]
81
#             files -- see avr-libc docs [FIXME: not yet described there]
81
##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
82
##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
82
ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp
83
ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp
83
ASFLAGS += -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)
84
ASFLAGS += -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)
84
 
85
 
85
 
86
 
86
#Additional libraries.
87
#Additional libraries.
87
 
88
 
88
# Minimalistic printf version
89
# Minimalistic printf version
89
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
90
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
90
 
91
 
91
# Floating point printf version (requires MATH_LIB = -lm below)
92
# Floating point printf version (requires MATH_LIB = -lm below)
92
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
93
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
93
 
94
 
94
PRINTF_LIB = 
95
PRINTF_LIB = 
95
 
96
 
96
# Minimalistic scanf version
97
# Minimalistic scanf version
97
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
98
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
98
 
99
 
99
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
100
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
100
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
101
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
101
 
102
 
102
SCANF_LIB = 
103
SCANF_LIB = 
103
 
104
 
104
MATH_LIB = -lm
105
MATH_LIB = -lm
105
 
106
 
106
# External memory options
107
# External memory options
107
 
108
 
108
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
109
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
109
# used for variables (.data/.bss) and heap (malloc()).
110
# used for variables (.data/.bss) and heap (malloc()).
110
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
111
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
111
 
112
 
112
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
113
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
113
# only used for heap (malloc()).
114
# only used for heap (malloc()).
114
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
115
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
115
 
116
 
116
EXTMEMOPTS =
117
EXTMEMOPTS =
117
 
118
 
118
BIOSOPTS = -Wl,-L.,-Tdata,$(BIOS_RAM_END) -lbios
119
BIOSOPTS = -Wl,-L.,-Tdata,$(BIOS_RAM_END) -lbios
119
 
120
 
120
# Linker flags.
121
# Linker flags.
121
#  -Wl,...:     tell GCC to pass this to linker.
122
#  -Wl,...:     tell GCC to pass this to linker.
122
#    -Map:      create map file
123
#    -Map:      create map file
123
#    --cref:    add cross reference to  map file
124
#    --cref:    add cross reference to  map file
124
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
125
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
125
LDFLAGS += $(EXTMEMOPTS)
126
LDFLAGS += $(EXTMEMOPTS)
126
LDFLAGS += $(BIOSOPTS)
127
LDFLAGS += $(BIOSOPTS)
127
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
128
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
128
 
129
 
129
# ---------------------------------------------------------------------------
130
# ---------------------------------------------------------------------------
130
 
131
 
131
# Define directories, if needed.
132
# Define directories, if needed.
132
DIRAVR = c:/progra~1/winavr
133
DIRAVR = c:/progra~1/winavr
133
DIRAVRBIN = $(DIRAVR)/bin
134
DIRAVRBIN = $(DIRAVR)/bin
134
DIRAVRUTILS = $(DIRAVR)/utils/bin
135
DIRAVRUTILS = $(DIRAVR)/utils/bin
135
DIRINC = .
136
DIRINC = .
136
DIRLIB = $(DIRAVR)/avr/lib
137
DIRLIB = $(DIRAVR)/avr/lib
137
 
138
 
138
 
139
 
139
# Define programs and commands.
140
# Define programs and commands.
140
SHELL = sh
141
SHELL = sh
141
CC = avr-gcc
142
CC = avr-gcc
142
AWK = awk
143
AWK = awk
143
OBJCOPY = avr-objcopy
144
OBJCOPY = avr-objcopy
144
OBJDUMP = avr-objdump
145
OBJDUMP = avr-objdump
145
SIZE = avr-size
146
SIZE = avr-size
146
NM = avr-nm
147
NM = avr-nm
147
REMOVE = rm -f
148
REMOVE = rm -f
148
COPY = cp
149
COPY = cp
149
 
150
 
150
 
151
 
151
 
152
 
152
 
153
 
153
# Define Messages
154
# Define Messages
154
# English
155
# English
155
MSG_ERRORS_NONE = Errors: none
156
MSG_ERRORS_NONE = Errors: none
156
MSG_BEGIN = -------- begin --------
157
MSG_BEGIN = -------- begin --------
157
MSG_END = --------  end  --------
158
MSG_END = --------  end  --------
158
MSG_SIZE_BEFORE = Size before: 
159
MSG_SIZE_BEFORE = Size before: 
159
MSG_SIZE_AFTER = Size after:
160
MSG_SIZE_AFTER = Size after:
160
MSG_COFF = Converting to AVR COFF:
161
MSG_COFF = Converting to AVR COFF:
161
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
162
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
162
MSG_FLASH = Creating load file for Flash:
163
MSG_FLASH = Creating load file for Flash:
163
MSG_EEPROM = Creating load file for EEPROM:
164
MSG_EEPROM = Creating load file for EEPROM:
164
MSG_EXTENDED_LISTING = Creating Extended Listing:
165
MSG_EXTENDED_LISTING = Creating Extended Listing:
165
MSG_SYMBOL_TABLE = Creating Symbol Table:
166
MSG_SYMBOL_TABLE = Creating Symbol Table:
166
MSG_LINKING = Linking:
167
MSG_LINKING = Linking:
167
MSG_COMPILING = Compiling:
168
MSG_COMPILING = Compiling:
168
MSG_ASSEMBLING = Assembling:
169
MSG_ASSEMBLING = Assembling:
169
MSG_DEPEND = Generating dependencies:
170
MSG_DEPEND = Generating dependencies:
170
MSG_CLEANING = Cleaning project:
171
MSG_CLEANING = Cleaning project:
171
 
172
 
172
 
173
 
173
 
174
 
174
 
175
 
175
# Define all object files.
176
# Define all object files.
176
OBJ = $(CSRC:.c=.o) $(ASRC:.S=.o) 
177
OBJ = $(CSRC:.c=.o) $(ASRC:.S=.o) 
177
 
178
 
178
# Define all listing files.
179
# Define all listing files.
179
LST = $(ASRC:.S=.lst) $(CSRC:.c=.lst)
180
LST = $(ASRC:.S=.lst) $(CSRC:.c=.lst)
180
 
181
 
181
 
182
 
182
# Compiler flags to generate dependency files.
183
# Compiler flags to generate dependency files.
183
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
184
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
184
GENDEPFLAGS = -M -MG -MP -MT "$(<:.c=.o) $@" -MF $@
185
GENDEPFLAGS = -M -MG -MP -MT "$(<:.c=.o) $@" -MF $@
185
 
186
 
186
# Combine all necessary flags and optional flags.
187
# Combine all necessary flags and optional flags.
187
# Add target processor to flags.
188
# Add target processor to flags.
188
#ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
189
#ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
189
#ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
190
#ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
190
 
191
 
191
 
192
 
192
 
193
 
193
 
194
 
194
 
195
 
195
# Default target.
196
# Default target.
196
all: begin sizebefore build sizeafter finished end
197
all: begin sizebefore build sizeafter finished end
197
 
198
 
198
build: elf hex eep lss sym
199
build: elf hex eep lss sym
199
 
200
 
200
elf: $(TARGET).elf
201
elf: $(TARGET).elf
201
hex: $(TARGET).hex
202
hex: $(TARGET).hex
202
eep: $(TARGET).eep
203
eep: $(TARGET).eep
203
lss: $(TARGET).lss 
204
lss: $(TARGET).lss 
204
sym: $(TARGET).sym
205
sym: $(TARGET).sym
205
config: config.h
206
config: config.h
206
 
207
 
207
install: hex
208
install: hex
208
	$(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -f $(TARGET).hex -r
209
	$(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -f $(TARGET).hex -r
209
 
210
 
210
reset: 
211
reset: 
211
	$(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -r
212
	$(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -r
212
 
213
 
213
start: 
214
start: 
214
	$(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -s
215
	$(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -s
215
 
216
 
216
# Eye candy.
217
# Eye candy.
217
# AVR Studio 3.x does not check make's exit code but relies on
218
# AVR Studio 3.x does not check make's exit code but relies on
218
# the following magic strings to be generated by the compile job.
219
# the following magic strings to be generated by the compile job.
219
begin:
220
begin:
220
	@echo
221
	@echo
221
	@echo $(MSG_BEGIN)
222
	@echo $(MSG_BEGIN)
222
 
223
 
223
finished:
224
finished:
224
	@echo $(MSG_ERRORS_NONE)
225
	@echo $(MSG_ERRORS_NONE)
225
 
226
 
226
end:
227
end:
227
	@echo $(MSG_END)
228
	@echo $(MSG_END)
228
	@echo
229
	@echo
229
 
230
 
230
 
231
 
231
# Display size of file.
232
# Display size of file.
232
HEXSIZE = $(SIZE) --target=ihex $(TARGET).hex
233
HEXSIZE = $(SIZE) --target=ihex $(TARGET).hex
233
ELFSIZE = $(SIZE) $(TARGET).elf
234
ELFSIZE = $(SIZE) $(TARGET).elf
234
sizebefore:
235
sizebefore:
235
	@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
236
 
237
 
237
sizeafter:
238
sizeafter:
238
	@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
239
 
240
 
240
 
241
 
241
# Generate config.h from bios.inc and config.inc
242
# Generate config.h from bios.inc and config.inc
242
config.h: bios.inc config.inc
243
config.h: bios.inc config.inc
243
	@echo Generating $@
244
	@echo Generating $@
244
	@echo "/* This file is automatically generated. Do not edit. */\n" > $@
245
	@echo "/* This file is automatically generated. Do not edit. */\n" > $@
245
	@cat $^ | $(AWK) 'BEGIN { FS="="; print "#ifndef CONFIG_H_\n#define CONFIG_H_\n" } /^[^#].*=.*/ { print "#define "$$1,$$2 } END { print "\n#endif /*CONFIG_H_*/" }' >> $@
246
	@cat $^ | $(AWK) 'BEGIN { FS="="; print "#ifndef CONFIG_H_\n#define CONFIG_H_\n" } /^[^#].*=.*/ { print "#define "$$1,$$2 } END { print "\n#endif /*CONFIG_H_*/" }' >> $@
246
 
247
 
247
# Display compiler version information.
248
# Display compiler version information.
248
gccversion : 
249
gccversion : 
249
	@$(CC) --version
250
	@$(CC) --version
250
 
251
 
251
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
252
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
252
COFFCONVERT=$(OBJCOPY) --debugging \
253
COFFCONVERT=$(OBJCOPY) --debugging \
253
--change-section-address .data-0x800000 \
254
--change-section-address .data-0x800000 \
254
--change-section-address .bss-0x800000 \
255
--change-section-address .bss-0x800000 \
255
--change-section-address .noinit-0x800000 \
256
--change-section-address .noinit-0x800000 \
256
--change-section-address .eeprom-0x810000 
257
--change-section-address .eeprom-0x810000 
257
 
258
 
258
 
259
 
259
coff: $(TARGET).elf
260
coff: $(TARGET).elf
260
	@echo
261
	@echo
261
	@echo $(MSG_COFF) $(TARGET).cof
262
	@echo $(MSG_COFF) $(TARGET).cof
262
	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
263
	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
263
 
264
 
264
 
265
 
265
extcoff: $(TARGET).elf
266
extcoff: $(TARGET).elf
266
	@echo
267
	@echo
267
	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
268
	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
268
	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
269
	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
269
 
270
 
270
# Create final output files (.hex, .eep) from ELF output file.
271
# Create final output files (.hex, .eep) from ELF output file.
271
%.hex: %.elf
272
%.hex: %.elf
272
	@echo
273
	@echo
273
	@echo $(MSG_FLASH) $@
274
	@echo $(MSG_FLASH) $@
274
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
275
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
275
 
276
 
276
%.eep: %.elf
277
%.eep: %.elf
277
	@echo
278
	@echo
278
	@echo $(MSG_EEPROM) $@
279
	@echo $(MSG_EEPROM) $@
279
	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
280
	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
280
	--change-section-lma .eeprom=0 -O ihex $< $@
281
	--change-section-lma .eeprom=0 -O ihex $< $@
281
 
282
 
282
# Create extended listing file from ELF output file.
283
# Create extended listing file from ELF output file.
283
%.lss: %.elf
284
%.lss: %.elf
284
	@echo
285
	@echo
285
	@echo $(MSG_EXTENDED_LISTING) $@
286
	@echo $(MSG_EXTENDED_LISTING) $@
286
	$(OBJDUMP) -h -S $< > $@
287
	$(OBJDUMP) -h -S $< > $@
287
 
288
 
288
# Create a symbol table from ELF output file.
289
# Create a symbol table from ELF output file.
289
%.sym: %.elf
290
%.sym: %.elf
290
	@echo
291
	@echo
291
	@echo $(MSG_SYMBOL_TABLE) $@
292
	@echo $(MSG_SYMBOL_TABLE) $@
292
	$(NM) -n $< > $@
293
	$(NM) -n $< > $@
293
 
294
 
294
 
295
 
295
 
296
 
296
# Link: create ELF output file from object files.
297
# Link: create ELF output file from object files.
297
.SECONDARY : $(TARGET).elf
298
.SECONDARY : $(TARGET).elf
298
.PRECIOUS : $(OBJ)
299
.PRECIOUS : $(OBJ)
299
ifneq (,$(filter atmega88 atmega168, $(MCU)))
300
ifneq (,$(filter atmega88 atmega168, $(MCU)))
300
%.elf: $(OBJ)
301
%.elf: $(OBJ)
301
	@echo
302
	@echo
302
	@echo $(MSG_LINKING) $@
303
	@echo $(MSG_LINKING) $@
303
	@echo GCC bug workaround for ATmega88/ATmega168:
304
	@echo GCC bug workaround for ATmega88/ATmega168:
304
	eval $$($(CC) -v $(CFLAGS) -o $@ $^ $(LDFLAGS) 2>&1 | $(AWK) '{ if (gsub("0x800100","$(BIOS_RAM_END)") == 1) print }')
305
	eval $$($(CC) -v $(CFLAGS) -o $@ $^ $(LDFLAGS) 2>&1 | $(AWK) '{ if (gsub("0x800100","$(BIOS_RAM_END)") == 1) print }')
305
else
306
else
306
%.elf: $(OBJ)
307
%.elf: $(OBJ)
307
	@echo
308
	@echo
308
	@echo $(MSG_LINKING) $@
309
	@echo $(MSG_LINKING) $@
309
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
310
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
310
endif
311
endif
311
 
312
 
312
# Compile: create object files from C source files.
313
# Compile: create object files from C source files.
313
%.o : %.c
314
%.o : %.c
314
	@echo
315
	@echo
315
	@echo $(MSG_COMPILING) $<
316
	@echo $(MSG_COMPILING) $<
316
	$(CC) -c $(CFLAGS) $< -o $@ 
317
	$(CC) -c $(CFLAGS) $< -o $@ 
317
 
318
 
318
 
319
 
319
# Compile: create assembler files from C source files.
320
# Compile: create assembler files from C source files.
320
%.s : %.c
321
%.s : %.c
321
	$(CC) -S $(CFLAGS) $< -o $@
322
	$(CC) -S $(CFLAGS) $< -o $@
322
 
323
 
323
 
324
 
324
# Assemble: create object files from assembler source files.
325
# Assemble: create object files from assembler source files.
325
%.o : %.S
326
%.o : %.S
326
	@echo
327
	@echo
327
	@echo $(MSG_ASSEMBLING) $<
328
	@echo $(MSG_ASSEMBLING) $<
328
	$(CC) -c $(ASFLAGS) $< -o $@
329
	$(CC) -c $(ASFLAGS) $< -o $@
329
 
330
 
330
# Depends: create dependency files from c source files.
331
# Depends: create dependency files from c source files.
331
%.d : %.c
332
%.d : %.c
332
	@echo $(MSG_DEPEND) $<
333
	@echo $(MSG_DEPEND) $<
333
	@$(CC) -c $(CFLAGS) $(GENDEPFLAGS) $<
334
	@$(CC) -c $(CFLAGS) $(GENDEPFLAGS) $<
334
 
335
 
335
# Target: clean project.
336
# Target: clean project.
336
clean: begin clean_list finished end
337
clean: begin clean_list finished end
337
 
338
 
338
clean_list :
339
clean_list :
339
	@echo
340
	@echo
340
	@echo $(MSG_CLEANING)
341
	@echo $(MSG_CLEANING)
341
	$(REMOVE) $(TARGET).hex
342
	$(REMOVE) $(TARGET).hex
342
	$(REMOVE) $(TARGET).eep
343
	$(REMOVE) $(TARGET).eep
343
	$(REMOVE) $(TARGET).obj
344
	$(REMOVE) $(TARGET).obj
344
	$(REMOVE) $(TARGET).cof
345
	$(REMOVE) $(TARGET).cof
345
	$(REMOVE) $(TARGET).elf
346
	$(REMOVE) $(TARGET).elf
346
	$(REMOVE) $(TARGET).map
347
	$(REMOVE) $(TARGET).map
347
	$(REMOVE) $(TARGET).obj
348
	$(REMOVE) $(TARGET).obj
348
	$(REMOVE) $(TARGET).a90
349
	$(REMOVE) $(TARGET).a90
349
	$(REMOVE) $(TARGET).sym
350
	$(REMOVE) $(TARGET).sym
350
	$(REMOVE) $(TARGET).lnk
351
	$(REMOVE) $(TARGET).lnk
351
	$(REMOVE) $(TARGET).lss
352
	$(REMOVE) $(TARGET).lss
352
	$(REMOVE) $(OBJ)
353
	$(REMOVE) $(OBJ)
353
	$(REMOVE) $(LST)
354
	$(REMOVE) $(LST)
354
	$(REMOVE) $(CSRC:.c=.s)
355
	$(REMOVE) $(CSRC:.c=.s)
355
	$(REMOVE) $(CSRC:.c=.d)
356
	$(REMOVE) $(CSRC:.c=.d)
356
	$(REMOVE) -r .dep
357
	$(REMOVE) -r .dep
357
	$(REMOVE) config.h
358
	$(REMOVE) config.h
358
 
359
 
359
 
360
 
360
 
361
 
361
# Include the dependency files.
362
# Include the dependency files.
362
-include $(CSRC:%.c=%.d)
363
-include $(CSRC:%.c=%.d)
363
 
364
 
364
 
365
 
365
# Listing of phony targets.
366
# Listing of phony targets.
366
.PHONY : all begin finish end sizebefore sizeafter gccversion \
367
.PHONY : all begin finish end sizebefore sizeafter gccversion \
367
build elf hex eep lss sym config coff extcoff \
368
build elf hex eep lss sym config coff extcoff \
368
clean clean_list program programlock programinit
369
clean clean_list program programlock programinit
369
 
370