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