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