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