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