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