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