Subversion Repositories HomeAutomation

Rev

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

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