Subversion Repositories HomeAutomation

Rev

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

Rev 239 Rev 255
1
# Hey Emacs, this is a -*- makefile -*-
1
# Hey Emacs, this is a -*- makefile -*-
2
#
2
#
3
# WinAVR makefile written by Eric B. Weddington, J�rg Wunsch, et al.
3
# WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al.
4
# Released to the Public Domain
4
# Released to the Public Domain
5
# Please read the make user manual!
5
# Please read the make user manual!
6
#
6
#
7
# Additional material for this makefile was submitted by:
7
# Additional material for this makefile was submitted by:
8
#  Tim Henigan
8
#  Tim Henigan
9
#  Peter Fleury
9
#  Peter Fleury
10
#  Reiner Patommel
10
#  Reiner Patommel
11
#  Sander Pool
11
#  Sander Pool
12
#  Frederik Rouleau
12
#  Frederik Rouleau
13
#  Markus Pfaff
13
#  Markus Pfaff
14
#
14
#
15
# On command line:
15
# On command line:
16
#
16
#
17
# make all = Make software.
17
# make all = Make software.
18
#
18
#
19
# make clean = Clean out built project files.
19
# make clean = Clean out built project files.
20
#
20
#
21
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
21
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
22
#
22
#
23
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
23
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
24
#                4.07 or greater).
24
#                4.07 or greater).
25
#
25
#
26
# make program = Download the hex file to the device, using avrdude.  Please
26
# make program = Download the hex file to the device, using avrdude.  Please
27
#                customize the avrdude settings below first!
27
#                customize the avrdude settings below first!
28
#
28
#
29
# make filename.s = Just compile filename.c into the assembler code only
29
# make filename.s = Just compile filename.c into the assembler code only
30
#
30
#
31
# To rebuild project do "make clean" then "make all".
31
# To rebuild project do "make clean" then "make all".
32
#
32
#
33
 
33
 
34
########
34
########
35
# Differences from WinAVR 20040720 sample:
35
# Differences from WinAVR 20040720 sample:
36
# - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum)
36
# - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum)
37
# - F_OSC Define in CFLAGS and AFLAGS
37
# - F_OSC Define in CFLAGS and AFLAGS
38
 
38
 
39
 
39
 
40
# MCU name
40
# MCU name
41
#MCU = atmega32
41
#MCU = atmega32
42
MCU = atmega88
42
MCU = atmega88
43
#MCU = atmega16
43
#MCU = atmega16
44
 
44
 
45
 
45
 
46
# Main Oscillator Frequency
46
# Main Oscillator Frequency
47
##F_OSC = 1000000
47
##F_OSC = 1000000
48
##F_OSC = 1843200
48
##F_OSC = 1843200
49
##F_OSC = 2000000
49
##F_OSC = 2000000
50
##F_OSC = 3686400
50
##F_OSC = 3686400
51
##F_OSC = 4000000
51
##F_OSC = 4000000
52
F_OSC = 8000000
52
F_OSC = 8000000
53
##F_OSC = 11059200
53
#F_OSC = 11059200
54
##F_OSC = 16000000
54
##F_OSC = 16000000
55
 
55
 
56
# Output format. (can be srec, ihex, binary)
56
# Output format. (can be srec, ihex, binary)
57
FORMAT = ihex
57
FORMAT = ihex
58
 
58
 
59
 
59
 
60
# Target file name (without extension).
60
# Target file name (without extension).
61
TARGET = main
61
TARGET = main
62
 
62
 
63
LIBDIR = ../lib/src/
63
LIBDIR = ../lib/src/
64
 
-
 
65
 
64
 
66
# List C source files here. (C dependencies are automatically generated.)
65
# List C source files here. (C dependencies are automatically generated.)
67
SRC =	$(TARGET).c\
66
SRC =	$(TARGET).c\
68
		$(LIBDIR)mcu/mcu.c\
67
		$(LIBDIR)mcu/mcu.c\
69
		$(LIBDIR)mcu/serial.c\
68
		$(LIBDIR)mcu/serial.c\
70
		$(LIBDIR)mcu/uart.c\
69
		$(LIBDIR)mcu/uart.c\
71
		$(LIBDIR)mcu/timebase.c\
70
		$(LIBDIR)mcu/timebase.c\
72
		$(LIBDIR)can/can.c\
71
		$(LIBDIR)can/can.c\
73
		$(LIBDIR)can/mcp2515/mcp2515.c\
72
		$(LIBDIR)can/mcp2515/mcp2515.c\
74
		$(LIBDIR)sensor/ds18s20/onewire.c\
-
 
75
		$(LIBDIR)sensor/ds18s20/delay.c\
-
 
76
		$(LIBDIR)sensor/ds18s20/ds18x20.c\
73
		$(LIBDIR)sensor/ds18s20/ds18x20.c\
77
		$(LIBDIR)sensor/ds18s20/crc8.c\
74
		$(LIBDIR)sensor/ds18s20/crc8.c\
-
 
75
		$(LIBDIR)sensor/ds18s20/delay.c\
-
 
76
		$(LIBDIR)sensor/ds18s20/onewire.c\
78
		$(LIBDIR)sensor/tc1047/tc1047.c\
77
		$(LIBDIR)sensor/tc1047/tc1047.c\
79
		$(LIBDIR)sensor/sht7x/sht7x.c
-
 
80
 
78
 
81
# List Assembler source files here.
79
# List Assembler source files here.
82
# Make them always end in a capital .S.  Files ending in a lowercase .s
80
# Make them always end in a capital .S.  Files ending in a lowercase .s
83
# will not be considered source files but generated files (assembler
81
# will not be considered source files but generated files (assembler
84
# output from the compiler), and will be deleted upon "make clean"!
82
# output from the compiler), and will be deleted upon "make clean"!
85
# Even though the DOS/Win* filesystem matches both .s and .S the same,
83
# Even though the DOS/Win* filesystem matches both .s and .S the same,
86
# it will preserve the spelling of the filenames, and gcc itself does
84
# it will preserve the spelling of the filenames, and gcc itself does
87
# care about how the name is spelled on its command-line.
85
# care about how the name is spelled on its command-line.
88
ASRC = 
86
ASRC = 
89
 
87
 
90
 
88
 
91
# Optimization level, can be [0, 1, 2, 3, s]. 
89
# Optimization level, can be [0, 1, 2, 3, s]. 
92
# 0 = turn off optimization. s = optimize for size.
90
# 0 = turn off optimization. s = optimize for size.
93
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
91
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
94
OPT = s
92
OPT = s
95
#OPT = 3
93
#OPT = 3
96
 
94
 
97
# Debugging format.
95
# Debugging format.
98
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
96
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
99
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
97
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
100
#DEBUG = stabs
98
#DEBUG = stabs
101
DEBUG = 
99
DEBUG = dwarf-2
102
 
100
 
103
# List any extra directories to look for include files here.
101
# List any extra directories to look for include files here.
104
#     Each directory must be seperated by a space.
102
#     Each directory must be seperated by a space.
105
EXTRAINCDIRS = $(LIBDIR)/can $(LIBDIR)/can/mcp2515 $(LIBDIR)/mcu $(LIBDIR)/sensor/ds18s20 $(LIBDIR)/sensor/tc1047 $(LIBDIR)/sensor/sht7x $(LIBDIR)/../funcdefs
103
EXTRAINCDIRS = 	$(LIBDIR)/can\
-
 
104
				$(LIBDIR)/can/mcp2515\
-
 
105
				$(LIBDIR)/mcu\
-
 
106
				$(LIBDIR)/../funcdefs\
-
 
107
				$(LIBDIR)/sensor/ds18s20 \
-
 
108
				$(LIBDIR)/sensor/tc1047 \
106
 
109
 
107
# Compiler flag to set the C Standard level.
110
# Compiler flag to set the C Standard level.
108
# c89   - "ANSI" C
111
# c89   - "ANSI" C
109
# gnu89 - c89 plus GCC extensions
112
# gnu89 - c89 plus GCC extensions
110
# c99   - ISO C99 standard (not yet fully implemented)
113
# c99   - ISO C99 standard (not yet fully implemented)
111
# gnu99 - c99 plus GCC extensions
114
# gnu99 - c99 plus GCC extensions
112
CSTANDARD = -std=gnu99
115
CSTANDARD = -std=gnu99
113
 
116
 
114
# Place -D or -U options here
117
# Place -D or -U options here
115
CDEFS =
118
CDEFS =
116
 
119
 
117
# Place -I options here
120
# Place -I options here
118
CINCS =
121
CINCS =
119
 
122
 
120
 
123
 
121
# Compiler flags.
124
# Compiler flags.
122
#  -g*:          generate debugging information
125
#  -g*:          generate debugging information
123
#  -O*:          optimization level
126
#  -O*:          optimization level
124
#  -f...:        tuning, see GCC manual and avr-libc documentation
127
#  -f...:        tuning, see GCC manual and avr-libc documentation
125
#  -Wall...:     warning level
128
#  -Wall...:     warning level
126
#  -Wa,...:      tell GCC to pass this to the assembler.
129
#  -Wa,...:      tell GCC to pass this to the assembler.
127
#    -adhlns...: create assembler listing
130
#    -adhlns...: create assembler listing
-
 
131
CFLAGS = 
128
CFLAGS = -g$(DEBUG)
132
#CFLAGS += -g$(DEBUG)
129
CFLAGS += $(CDEFS) $(CINCS)
133
CFLAGS += $(CDEFS) $(CINCS)
130
CFLAGS += -O$(OPT)
134
CFLAGS += -O$(OPT)
131
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
135
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
132
CFLAGS += -Wall -Wstrict-prototypes
136
CFLAGS += -Wall -Wstrict-prototypes
133
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
137
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
134
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
138
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
135
CFLAGS += $(CSTANDARD)
139
CFLAGS += $(CSTANDARD)
136
CFLAGS += -DF_OSC=$(F_OSC)
140
CFLAGS += -DF_OSC=$(F_OSC)
137
 
-
 
138
 
141
 
139
 
142
 
140
# Assembler flags.
143
# Assembler flags.
141
#  -Wa,...:   tell GCC to pass this to the assembler.
144
#  -Wa,...:   tell GCC to pass this to the assembler.
142
#  -ahlms:    create listing
145
#  -ahlms:    create listing
143
#  -gstabs:   have the assembler create line number information; note that
146
#  -gstabs:   have the assembler create line number information; note that
144
#             for use in COFF files, additional information about filenames
147
#             for use in COFF files, additional information about filenames
145
#             and function names needs to be present in the assembler source
148
#             and function names needs to be present in the assembler source
146
#             files -- see avr-libc docs [FIXME: not yet described there]
149
#             files -- see avr-libc docs [FIXME: not yet described there]
147
##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
150
##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
148
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)
151
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)
149
ASFLAGS += -DF_OSC=$(F_OSC)
152
ASFLAGS += -DF_OSC=$(F_OSC)
150
 
153
 
151
 
154
 
152
#Additional libraries.
155
#Additional libraries.
153
 
156
 
154
# Minimalistic printf version
157
# Minimalistic printf version
155
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
158
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
156
 
159
 
157
# Floating point printf version (requires MATH_LIB = -lm below)
160
# Floating point printf version (requires MATH_LIB = -lm below)
158
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
161
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
159
 
162
 
160
PRINTF_LIB = 
163
PRINTF_LIB = $(PRINTF_LIB_MIN)
161
 
164
 
162
# Minimalistic scanf version
165
# Minimalistic scanf version
163
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
166
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
164
 
167
 
165
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
168
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
166
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
169
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
167
 
170
 
168
SCANF_LIB = 
171
SCANF_LIB = 
169
 
172
 
170
MATH_LIB = -lm
173
MATH_LIB = -lm
171
 
174
 
172
# External memory options
175
# External memory options
173
 
176
 
174
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
177
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
175
# used for variables (.data/.bss) and heap (malloc()).
178
# used for variables (.data/.bss) and heap (malloc()).
176
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
179
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
177
 
180
 
178
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
181
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
179
# only used for heap (malloc()).
182
# only used for heap (malloc()).
180
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
183
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
181
 
184
 
182
EXTMEMOPTS =
185
EXTMEMOPTS =
183
 
186
 
184
# Linker flags.
187
# Linker flags.
185
#  -Wl,...:     tell GCC to pass this to linker.
188
#  -Wl,...:     tell GCC to pass this to linker.
186
#    -Map:      create map file
189
#    -Map:      create map file
187
#    --cref:    add cross reference to  map file
190
#    --cref:    add cross reference to  map file
188
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
191
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
189
LDFLAGS += $(EXTMEMOPTS)
192
LDFLAGS += $(EXTMEMOPTS)
190
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
193
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
191
 
194
 
192
 
195
 
193
 
196
 
194
 
197
 
195
# Programming support using avrdude. Settings and variables.
198
# Programming support using avrdude. Settings and variables.
196
 
199
 
197
# Programming hardware: alf avr910 avrisp bascom bsd 
200
# Programming hardware: alf avr910 avrisp bascom bsd 
198
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
201
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
199
#
202
#
200
# Type: avrdude -c ?
203
# Type: avrdude -c ?
201
# to get a full listing.
204
# to get a full listing.
202
#
205
#
203
AVRDUDE_PROGRAMMER = avrispv2
206
AVRDUDE_PROGRAMMER = avrispv2
204
 
207
 
205
# com1 = serial port. Use lpt1 to connect to parallel port.
208
# com1 = serial port. Use lpt1 to connect to parallel port.
206
AVRDUDE_PORT = /dev/ttyUSB0    # programmer connected to serial device
209
AVRDUDE_PORT = /dev/ttyUSB0    # programmer connected to serial device
-
 
210
AVRDUDE_BAUD = 115200
207
 
211
 
208
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
212
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
209
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
213
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
210
 
214
 
211
 
215
 
212
# Uncomment the following if you want avrdude's erase cycle counter.
216
# Uncomment the following if you want avrdude's erase cycle counter.
213
# Note that this counter needs to be initialized first using -Yn,
217
# Note that this counter needs to be initialized first using -Yn,
214
# see avrdude manual.
218
# see avrdude manual.
215
#AVRDUDE_ERASE_COUNTER = -y
219
#AVRDUDE_ERASE_COUNTER = -y
216
 
220
 
217
# Uncomment the following if you do /not/ wish a verification to be
221
# Uncomment the following if you do /not/ wish a verification to be
218
# performed after programming the device.
222
# performed after programming the device.
219
#AVRDUDE_NO_VERIFY = -V
223
#AVRDUDE_NO_VERIFY = -V
220
 
224
 
221
# Increase verbosity level.  Please use this when submitting bug
225
# Increase verbosity level.  Please use this when submitting bug
222
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
226
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
223
# to submit bug reports.
227
# to submit bug reports.
224
#AVRDUDE_VERBOSE = -v -v
228
#AVRDUDE_VERBOSE = -v -v
225
#-b $(AVRDUDE_BAUD)
-
 
-
 
229
 
226
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) 
230
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -b $(AVRDUDE_BAUD)
227
#AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
231
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
228
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
232
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
229
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
233
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
230
 
234
 
231
 
235
 
232
 
236
 
233
# ---------------------------------------------------------------------------
237
# ---------------------------------------------------------------------------
234
 
238
 
235
# Define directories, if needed.
239
# Define directories, if needed.
236
DIRAVR = c:/progra~1/winavr
240
DIRAVR = c:/progra~1/winavr
237
DIRAVRBIN = $(DIRAVR)/bin
241
DIRAVRBIN = $(DIRAVR)/bin
238
DIRAVRUTILS = $(DIRAVR)/utils/bin
242
DIRAVRUTILS = $(DIRAVR)/utils/bin
239
DIRINC = .
243
DIRINC = .
240
DIRLIB = $(DIRAVR)/avr/lib
244
DIRLIB = $(DIRAVR)/avr/lib
241
 
245
 
242
 
246
 
243
# Define programs and commands.
247
# Define programs and commands.
244
SHELL = sh
248
SHELL = sh
245
CC = avr-gcc
249
CC = avr-gcc
246
OBJCOPY = avr-objcopy
250
OBJCOPY = avr-objcopy
247
OBJDUMP = avr-objdump
251
OBJDUMP = avr-objdump
248
SIZE = avr-size
252
SIZE = avr-size
249
NM = avr-nm
253
NM = avr-nm
250
AVRDUDE = avrdude
254
AVRDUDE = avrdude
251
REMOVE = rm -f
255
REMOVE = rm -f
252
COPY = cp
256
COPY = cp
253
 
257
 
254
 
258
 
255
 
259
 
256
 
260
 
257
# Define Messages
261
# Define Messages
258
# English
262
# English
259
MSG_ERRORS_NONE = Errors: none
263
MSG_ERRORS_NONE = Errors: none
260
MSG_BEGIN = -------- begin --------
264
MSG_BEGIN = -------- begin --------
261
MSG_END = --------  end  --------
265
MSG_END = --------  end  --------
262
MSG_SIZE_BEFORE = Size before: 
266
MSG_SIZE_BEFORE = Size before: 
263
MSG_SIZE_AFTER = Size after:
267
MSG_SIZE_AFTER = Size after:
264
MSG_COFF = Converting to AVR COFF:
268
MSG_COFF = Converting to AVR COFF:
265
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
269
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
266
MSG_FLASH = Creating load file for Flash:
270
MSG_FLASH = Creating load file for Flash:
267
MSG_EEPROM = Creating load file for EEPROM:
271
MSG_EEPROM = Creating load file for EEPROM:
268
MSG_EXTENDED_LISTING = Creating Extended Listing:
272
MSG_EXTENDED_LISTING = Creating Extended Listing:
269
MSG_SYMBOL_TABLE = Creating Symbol Table:
273
MSG_SYMBOL_TABLE = Creating Symbol Table:
270
MSG_LINKING = Linking:
274
MSG_LINKING = Linking:
271
MSG_COMPILING = Compiling:
275
MSG_COMPILING = Compiling:
272
MSG_ASSEMBLING = Assembling:
276
MSG_ASSEMBLING = Assembling:
273
MSG_CLEANING = Cleaning project:
277
MSG_CLEANING = Cleaning project:
274
 
278
 
275
 
279
 
276
 
280
 
277
 
281
 
278
# Define all object files.
282
# Define all object files.
279
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
283
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
280
 
284
 
281
# Define all listing files.
285
# Define all listing files.
282
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
286
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
283
 
287
 
284
 
288
 
285
# Compiler flags to generate dependency files.
289
# Compiler flags to generate dependency files.
286
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
290
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
287
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
291
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
288
 
292
 
289
# Combine all necessary flags and optional flags.
293
# Combine all necessary flags and optional flags.
290
# Add target processor to flags.
294
# Add target processor to flags.
291
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
295
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
292
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
296
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
293
 
297
 
294
 
298
 
295
 
299
 
296
 
300
 
297
 
301
 
298
# Default target.
302
# Default target.
299
all: begin gccversion sizebefore build sizeafter finished end
303
all: begin gccversion sizebefore build sizeafter finished end
300
 
304
 
301
build: elf hex eep lss sym
305
build: elf hex eep lss sym
302
 
306
 
303
elf: $(TARGET).elf
307
elf: $(TARGET).elf
304
hex: $(TARGET).hex
308
hex: $(TARGET).hex
305
eep: $(TARGET).eep
309
eep: $(TARGET).eep
306
lss: $(TARGET).lss 
310
lss: $(TARGET).lss 
307
sym: $(TARGET).sym
311
sym: $(TARGET).sym
308
 
312
 
309
 
313
 
310
 
314
 
311
# Eye candy.
315
# Eye candy.
312
# AVR Studio 3.x does not check make's exit code but relies on
316
# AVR Studio 3.x does not check make's exit code but relies on
313
# the following magic strings to be generated by the compile job.
317
# the following magic strings to be generated by the compile job.
314
begin:
318
begin:
315
	@echo
319
	@echo
316
	@echo $(MSG_BEGIN)
320
	@echo $(MSG_BEGIN)
317
 
321
 
318
finished:
322
finished:
319
	@echo $(MSG_ERRORS_NONE)
323
	@echo $(MSG_ERRORS_NONE)
320
 
324
 
321
end:
325
end:
322
	@echo $(MSG_END)
326
	@echo $(MSG_END)
323
	@echo
327
	@echo
324
 
328
 
325
 
329
 
326
# Display size of file.
330
# Display size of file.
327
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
331
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
328
ELFSIZE = $(SIZE) -A $(TARGET).elf
332
ELFSIZE = $(SIZE) -A $(TARGET).elf
329
sizebefore:
333
sizebefore:
330
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
334
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
331
 
335
 
332
sizeafter:
336
sizeafter:
333
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
337
	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
334
 
338
 
335
 
339
 
336
 
340
 
337
# Display compiler version information.
341
# Display compiler version information.
338
gccversion : 
342
gccversion : 
339
	@$(CC) --version
343
	@$(CC) --version
340
 
344
 
341
 
345
 
342
 
346
 
343
# Program the device.  
347
# Program the device.  
344
program: $(TARGET).hex $(TARGET).eep
348
program: $(TARGET).hex $(TARGET).eep
345
	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
349
	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
346
 
350
 
347
#programlock: 
351
#programlock: 
348
#	$(AVRDUDE) $(AVRDUDE_FLAGS) -U lock:w:0x00:m
352
#	$(AVRDUDE) $(AVRDUDE_FLAGS) -U lock:w:0x00:m
349
 
353
 
350
#programinit: 
354
#programinit: 
351
#	$(AVRDUDE) $(AVRDUDE_FLAGS) -U hfuse:w:0xd9:m -U lfuse:w:0xe4:m
355
#	$(AVRDUDE) $(AVRDUDE_FLAGS) -U hfuse:w:0xd9:m -U lfuse:w:0xe4:m
352
 
356
 
353
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
357
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
354
COFFCONVERT=$(OBJCOPY) --debugging \
358
COFFCONVERT=$(OBJCOPY) --debugging \
355
--change-section-address .data-0x800000 \
359
--change-section-address .data-0x800000 \
356
--change-section-address .bss-0x800000 \
360
--change-section-address .bss-0x800000 \
357
--change-section-address .noinit-0x800000 \
361
--change-section-address .noinit-0x800000 \
358
--change-section-address .eeprom-0x810000 
362
--change-section-address .eeprom-0x810000 
359
 
363
 
360
 
364
 
361
coff: $(TARGET).elf
365
coff: $(TARGET).elf
362
	@echo
366
	@echo
363
	@echo $(MSG_COFF) $(TARGET).cof
367
	@echo $(MSG_COFF) $(TARGET).cof
364
	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
368
	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
365
 
369
 
366
 
370
 
367
extcoff: $(TARGET).elf
371
extcoff: $(TARGET).elf
368
	@echo
372
	@echo
369
	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
373
	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
370
	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
374
	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
371
 
375
 
372
 
376
 
373
 
377
 
374
# Create final output files (.hex, .eep) from ELF output file.
378
# Create final output files (.hex, .eep) from ELF output file.
375
%.hex: %.elf
379
%.hex: %.elf
376
	@echo
380
	@echo
377
	@echo $(MSG_FLASH) $@
381
	@echo $(MSG_FLASH) $@
378
	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
382
	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
379
 
383
 
380
%.eep: %.elf
384
%.eep: %.elf
381
	@echo
385
	@echo
382
	@echo $(MSG_EEPROM) $@
386
	@echo $(MSG_EEPROM) $@
383
	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
387
	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
384
	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
388
	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
385
 
389
 
386
# Create extended listing file from ELF output file.
390
# Create extended listing file from ELF output file.
387
%.lss: %.elf
391
%.lss: %.elf
388
	@echo
392
	@echo
389
	@echo $(MSG_EXTENDED_LISTING) $@
393
	@echo $(MSG_EXTENDED_LISTING) $@
390
	$(OBJDUMP) -h -S $< > $@
394
	$(OBJDUMP) -h -S $< > $@
391
 
395
 
392
# Create a symbol table from ELF output file.
396
# Create a symbol table from ELF output file.
393
%.sym: %.elf
397
%.sym: %.elf
394
	@echo
398
	@echo
395
	@echo $(MSG_SYMBOL_TABLE) $@
399
	@echo $(MSG_SYMBOL_TABLE) $@
396
	$(NM) -n $< > $@
400
	$(NM) -n $< > $@
397
 
401
 
398
 
402
 
399
 
403
 
400
# Link: create ELF output file from object files.
404
# Link: create ELF output file from object files.
401
.SECONDARY : $(TARGET).elf
405
.SECONDARY : $(TARGET).elf
402
.PRECIOUS : $(OBJ)
406
.PRECIOUS : $(OBJ)
403
%.elf: $(OBJ)
407
%.elf: $(OBJ)
404
	@echo
408
	@echo
405
	@echo $(MSG_LINKING) $@
409
	@echo $(MSG_LINKING) $@
406
	$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
410
	$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
407
 
411
 
408
 
412
 
409
# Compile: create object files from C source files.
413
# Compile: create object files from C source files.
410
%.o : %.c
414
%.o : %.c
411
	@echo
415
	@echo
412
	@echo $(MSG_COMPILING) $<
416
	@echo $(MSG_COMPILING) $<
413
	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
417
	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
414
 
418
 
415
 
419
 
416
# Compile: create assembler files from C source files.
420
# Compile: create assembler files from C source files.
417
%.s : %.c
421
%.s : %.c
418
	$(CC) -S $(ALL_CFLAGS) $< -o $@
422
	$(CC) -S $(ALL_CFLAGS) $< -o $@
419
 
423
 
420
 
424
 
421
# Assemble: create object files from assembler source files.
425
# Assemble: create object files from assembler source files.
422
%.o : %.S
426
%.o : %.S
423
	@echo
427
	@echo
424
	@echo $(MSG_ASSEMBLING) $<
428
	@echo $(MSG_ASSEMBLING) $<
425
	$(CC) -c $(ALL_ASFLAGS) $< -o $@
429
	$(CC) -c $(ALL_ASFLAGS) $< -o $@
426
 
430
 
427
 
431
 
428
 
432
 
429
# Target: clean project.
433
# Target: clean project.
430
clean: begin clean_list finished end
434
clean: begin clean_list finished end
431
 
435
 
432
clean_list :
436
clean_list :
433
	@echo
437
	@echo
434
	@echo $(MSG_CLEANING)
438
	@echo $(MSG_CLEANING)
435
	$(REMOVE) $(TARGET).hex
439
	$(REMOVE) $(TARGET).hex
436
	$(REMOVE) $(TARGET).eep
440
	$(REMOVE) $(TARGET).eep
437
	$(REMOVE) $(TARGET).obj
441
	$(REMOVE) $(TARGET).obj
438
	$(REMOVE) $(TARGET).cof
442
	$(REMOVE) $(TARGET).cof
439
	$(REMOVE) $(TARGET).elf
443
	$(REMOVE) $(TARGET).elf
440
	$(REMOVE) $(TARGET).map
444
	$(REMOVE) $(TARGET).map
441
	$(REMOVE) $(TARGET).obj
445
	$(REMOVE) $(TARGET).obj
442
	$(REMOVE) $(TARGET).a90
446
	$(REMOVE) $(TARGET).a90
443
	$(REMOVE) $(TARGET).sym
447
	$(REMOVE) $(TARGET).sym
444
	$(REMOVE) $(TARGET).lnk
448
	$(REMOVE) $(TARGET).lnk
445
	$(REMOVE) $(TARGET).lss
449
	$(REMOVE) $(TARGET).lss
446
	$(REMOVE) $(OBJ)
450
	$(REMOVE) $(OBJ)
447
	$(REMOVE) $(LST)
451
	$(REMOVE) $(LST)
448
	$(REMOVE) $(SRC:.c=.s)
452
	$(REMOVE) $(SRC:.c=.s)
449
	$(REMOVE) $(SRC:.c=.d)
453
	$(REMOVE) $(SRC:.c=.d)
450
	$(REMOVE) .dep/*
454
	$(REMOVE) .dep/*
451
 
455
 
452
 
456
 
453
 
457
 
454
# Include the dependency files.
458
# Include the dependency files.
455
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
459
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
456
 
460
 
457
 
461
 
458
# Listing of phony targets.
462
# Listing of phony targets.
459
.PHONY : all begin finish end sizebefore sizeafter gccversion \
463
.PHONY : all begin finish end sizebefore sizeafter gccversion \
460
build elf hex eep lss sym coff extcoff \
464
build elf hex eep lss sym coff extcoff \
461
clean clean_list program programlock programinit
465
clean clean_list program programlock programinit
462
 
466