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