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