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