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