Subversion Repositories HomeAutomation

Rev

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

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