Rev 187 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 187 | Rev 245 | ||
|---|---|---|---|
| 1 | # Hey Emacs, this is a -*- makefile -*- |
1 | # Hey Emacs, this is a -*- makefile -*- |
| 2 | # |
2 | # |
| 3 | # WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al. |
3 | # WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al. |
| 4 | # Released to the Public Domain |
4 | # Released to the Public Domain |
| 5 | # Please read the make user manual! |
5 | # Please read the make user manual! |
| 6 | # |
6 | # |
| 7 | # Additional material for this makefile was submitted by: |
7 | # Additional material for this makefile was submitted by: |
| 8 | # Tim Henigan |
8 | # Tim Henigan |
| 9 | # Peter Fleury |
9 | # Peter Fleury |
| 10 | # Reiner Patommel |
10 | # Reiner Patommel |
| 11 | # Sander Pool |
11 | # Sander Pool |
| 12 | # Frederik Rouleau |
12 | # Frederik Rouleau |
| 13 | # Markus Pfaff |
13 | # Markus Pfaff |
| 14 | # |
14 | # |
| 15 | # On command line: |
15 | # On command line: |
| 16 | # |
16 | # |
| 17 | # make all = Make software. |
17 | # make all = Make software. |
| 18 | # |
18 | # |
| 19 | # make clean = Clean out built project files. |
19 | # make clean = Clean out built project files. |
| 20 | # |
20 | # |
| 21 | # make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB). |
21 | # make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB). |
| 22 | # |
22 | # |
| 23 | # make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio |
23 | # make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio |
| 24 | # 4.07 or greater). |
24 | # 4.07 or greater). |
| 25 | # |
25 | # |
| 26 | # make program = Download the hex file to the device, using avrdude. Please |
26 | # make program = Download the hex file to the device, using avrdude. Please |
| 27 | # customize the avrdude settings below first! |
27 | # customize the avrdude settings below first! |
| 28 | # |
28 | # |
| 29 | # make filename.s = Just compile filename.c into the assembler code only |
29 | # make filename.s = Just compile filename.c into the assembler code only |
| 30 | # |
30 | # |
| 31 | # To rebuild project do "make clean" then "make all". |
31 | # To rebuild project do "make clean" then "make all". |
| 32 | # |
32 | # |
| 33 | 33 | ||
| 34 | ######## |
34 | ######## |
| 35 | # Differences from WinAVR 20040720 sample: |
35 | # Differences from WinAVR 20040720 sample: |
| 36 | # - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum) |
36 | # - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum) |
| 37 | # - F_OSC Define in CFLAGS and AFLAGS |
37 | # - F_OSC Define in CFLAGS and AFLAGS |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | # MCU name |
40 | # MCU name |
| 41 | #MCU = atmega32 |
41 | #MCU = atmega32 |
| 42 | MCU = atmega88 |
42 | MCU = atmega88 |
| 43 | #MCU = atmega16 |
43 | #MCU = atmega16 |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | # Main Oscillator Frequency |
46 | # Main Oscillator Frequency |
| 47 | ##F_OSC = 1000000 |
47 | ##F_OSC = 1000000 |
| 48 | ##F_OSC = 1843200 |
48 | ##F_OSC = 1843200 |
| 49 | ##F_OSC = 2000000 |
49 | ##F_OSC = 2000000 |
| 50 | ##F_OSC = 3686400 |
50 | ##F_OSC = 3686400 |
| 51 | ##F_OSC = 4000000 |
51 | ##F_OSC = 4000000 |
| 52 | F_OSC = 8000000 |
52 | F_OSC = 8000000 |
| 53 | #F_OSC = 11059200 |
53 | #F_OSC = 11059200 |
| 54 | ##F_OSC = 16000000 |
54 | ##F_OSC = 16000000 |
| 55 | 55 | ||
| 56 | # Output format. (can be srec, ihex, binary) |
56 | # Output format. (can be srec, ihex, binary) |
| 57 | FORMAT = ihex |
57 | FORMAT = ihex |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | # Target file name (without extension). |
60 | # Target file name (without extension). |
| 61 | TARGET = main |
61 | TARGET = main |
| 62 | 62 | ||
| 63 | LIBDIR = ../lib/src/ |
63 | LIBDIR = ../lib/src/ |
| 64 | 64 | ||
| 65 | # List C source files here. (C dependencies are automatically generated.) |
65 | # List C source files here. (C dependencies are automatically generated.) |
| 66 | SRC = $(TARGET).c\ |
66 | SRC = $(TARGET).c\ |
| 67 | $(LIBDIR)mcu/mcu.c\ |
67 | $(LIBDIR)mcu/mcu.c\ |
| 68 | $(LIBDIR)mcu/serial.c\ |
68 | $(LIBDIR)mcu/serial.c\ |
| 69 | $(LIBDIR)mcu/uart.c\ |
69 | $(LIBDIR)mcu/uart.c\ |
| 70 | $(LIBDIR)mcu/timebase.c\ |
70 | $(LIBDIR)mcu/timebase.c\ |
| 71 | $(LIBDIR)can/can.c\ |
71 | $(LIBDIR)can/can.c\ |
| 72 | $(LIBDIR)can/mcp2515/mcp2515.c\ |
72 | $(LIBDIR)can/mcp2515/mcp2515.c\ |
| 73 | $(LIBDIR) |
73 | $(LIBDIR)sensor/tc1047/tc1047.c\ |
| 74 | 74 | ||
| 75 | # List Assembler source files here. |
75 | # List Assembler source files here. |
| 76 | # Make them always end in a capital .S. Files ending in a lowercase .s |
76 | # Make them always end in a capital .S. Files ending in a lowercase .s |
| 77 | # will not be considered source files but generated files (assembler |
77 | # will not be considered source files but generated files (assembler |
| 78 | # output from the compiler), and will be deleted upon "make clean"! |
78 | # output from the compiler), and will be deleted upon "make clean"! |
| 79 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
79 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
| 80 | # it will preserve the spelling of the filenames, and gcc itself does |
80 | # it will preserve the spelling of the filenames, and gcc itself does |
| 81 | # care about how the name is spelled on its command-line. |
81 | # care about how the name is spelled on its command-line. |
| 82 | ASRC = |
82 | ASRC = |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | # Optimization level, can be [0, 1, 2, 3, s]. |
85 | # Optimization level, can be [0, 1, 2, 3, s]. |
| 86 | # 0 = turn off optimization. s = optimize for size. |
86 | # 0 = turn off optimization. s = optimize for size. |
| 87 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
87 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
| 88 | OPT = s |
88 | OPT = s |
| 89 | #OPT = 3 |
89 | #OPT = 3 |
| 90 | 90 | ||
| 91 | # Debugging format. |
91 | # Debugging format. |
| 92 | # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. |
92 | # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. |
| 93 | # AVR (extended) COFF requires stabs, plus an avr-objcopy run. |
93 | # AVR (extended) COFF requires stabs, plus an avr-objcopy run. |
| 94 | #DEBUG = stabs |
94 | #DEBUG = stabs |
| 95 | DEBUG = dwarf-2 |
95 | DEBUG = dwarf-2 |
| 96 | 96 | ||
| 97 | # List any extra directories to look for include files here. |
97 | # List any extra directories to look for include files here. |
| 98 | # Each directory must be seperated by a space. |
98 | # Each directory must be seperated by a space. |
| 99 | EXTRAINCDIRS = $(LIBDIR)/ |
99 | EXTRAINCDIRS = $(LIBDIR)/can\ |
| - | 100 | $(LIBDIR)/can/mcp2515\ |
|
| - | 101 | $(LIBDIR)/mcu\ |
|
| - | 102 | $(LIBDIR)/lcd\ |
|
| - | 103 | $(LIBDIR)/../funcdefs\ |
|
| - | 104 | $(LIBDIR)/sensor/tc1047 |
|
| 100 | 105 | ||
| 101 | # Compiler flag to set the C Standard level. |
106 | # Compiler flag to set the C Standard level. |
| 102 | # c89 - "ANSI" C |
107 | # c89 - "ANSI" C |
| 103 | # gnu89 - c89 plus GCC extensions |
108 | # gnu89 - c89 plus GCC extensions |
| 104 | # c99 - ISO C99 standard (not yet fully implemented) |
109 | # c99 - ISO C99 standard (not yet fully implemented) |
| 105 | # gnu99 - c99 plus GCC extensions |
110 | # gnu99 - c99 plus GCC extensions |
| 106 | CSTANDARD = -std=gnu99 |
111 | CSTANDARD = -std=gnu99 |
| 107 | 112 | ||
| 108 | # Place -D or -U options here |
113 | # Place -D or -U options here |
| 109 | CDEFS = |
114 | CDEFS = |
| 110 | 115 | ||
| 111 | # Place -I options here |
116 | # Place -I options here |
| 112 | CINCS = |
117 | CINCS = |
| 113 | 118 | ||
| 114 | 119 | ||
| 115 | # Compiler flags. |
120 | # Compiler flags. |
| 116 | # -g*: generate debugging information |
121 | # -g*: generate debugging information |
| 117 | # -O*: optimization level |
122 | # -O*: optimization level |
| 118 | # -f...: tuning, see GCC manual and avr-libc documentation |
123 | # -f...: tuning, see GCC manual and avr-libc documentation |
| 119 | # -Wall...: warning level |
124 | # -Wall...: warning level |
| 120 | # -Wa,...: tell GCC to pass this to the assembler. |
125 | # -Wa,...: tell GCC to pass this to the assembler. |
| 121 | # -adhlns...: create assembler listing |
126 | # -adhlns...: create assembler listing |
| 122 | CFLAGS = |
127 | CFLAGS = |
| 123 | #CFLAGS += -g$(DEBUG) |
128 | #CFLAGS += -g$(DEBUG) |
| 124 | CFLAGS += $(CDEFS) $(CINCS) |
129 | CFLAGS += $(CDEFS) $(CINCS) |
| 125 | CFLAGS += -O$(OPT) |
130 | CFLAGS += -O$(OPT) |
| 126 | CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
131 | CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
| 127 | CFLAGS += -Wall -Wstrict-prototypes |
132 | CFLAGS += -Wall -Wstrict-prototypes |
| 128 | CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
133 | CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
| 129 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
134 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
| 130 | CFLAGS += $(CSTANDARD) |
135 | CFLAGS += $(CSTANDARD) |
| 131 | CFLAGS += -DF_OSC=$(F_OSC) |
136 | CFLAGS += -DF_OSC=$(F_OSC) |
| 132 | 137 | ||
| 133 | 138 | ||
| 134 | 139 | ||
| 135 | # Assembler flags. |
140 | # Assembler flags. |
| 136 | # -Wa,...: tell GCC to pass this to the assembler. |
141 | # -Wa,...: tell GCC to pass this to the assembler. |
| 137 | # -ahlms: create listing |
142 | # -ahlms: create listing |
| 138 | # -gstabs: have the assembler create line number information; note that |
143 | # -gstabs: have the assembler create line number information; note that |
| 139 | # for use in COFF files, additional information about filenames |
144 | # for use in COFF files, additional information about filenames |
| 140 | # and function names needs to be present in the assembler source |
145 | # and function names needs to be present in the assembler source |
| 141 | # files -- see avr-libc docs [FIXME: not yet described there] |
146 | # files -- see avr-libc docs [FIXME: not yet described there] |
| 142 | ##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
147 | ##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
| 143 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG) |
148 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG) |
| 144 | ASFLAGS += -DF_OSC=$(F_OSC) |
149 | ASFLAGS += -DF_OSC=$(F_OSC) |
| 145 | 150 | ||
| 146 | 151 | ||
| 147 | #Additional libraries. |
152 | #Additional libraries. |
| 148 | 153 | ||
| 149 | # Minimalistic printf version |
154 | # Minimalistic printf version |
| 150 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
155 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
| 151 | 156 | ||
| 152 | # Floating point printf version (requires MATH_LIB = -lm below) |
157 | # Floating point printf version (requires MATH_LIB = -lm below) |
| 153 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
158 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
| 154 | 159 | ||
| 155 | PRINTF_LIB = $(PRINTF_LIB_MIN) |
160 | PRINTF_LIB = $(PRINTF_LIB_MIN) |
| 156 | 161 | ||
| 157 | # Minimalistic scanf version |
162 | # Minimalistic scanf version |
| 158 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
163 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
| 159 | 164 | ||
| 160 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
165 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
| 161 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
166 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
| 162 | 167 | ||
| 163 | SCANF_LIB = |
168 | SCANF_LIB = |
| 164 | 169 | ||
| 165 | MATH_LIB = -lm |
170 | MATH_LIB = -lm |
| 166 | 171 | ||
| 167 | # External memory options |
172 | # External memory options |
| 168 | 173 | ||
| 169 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
174 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
| 170 | # used for variables (.data/.bss) and heap (malloc()). |
175 | # used for variables (.data/.bss) and heap (malloc()). |
| 171 | #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff |
176 | #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff |
| 172 | 177 | ||
| 173 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
178 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
| 174 | # only used for heap (malloc()). |
179 | # only used for heap (malloc()). |
| 175 | #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff |
180 | #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff |
| 176 | 181 | ||
| 177 | EXTMEMOPTS = |
182 | EXTMEMOPTS = |
| 178 | 183 | ||
| 179 | # Linker flags. |
184 | # Linker flags. |
| 180 | # -Wl,...: tell GCC to pass this to linker. |
185 | # -Wl,...: tell GCC to pass this to linker. |
| 181 | # -Map: create map file |
186 | # -Map: create map file |
| 182 | # --cref: add cross reference to map file |
187 | # --cref: add cross reference to map file |
| 183 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
188 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
| 184 | LDFLAGS += $(EXTMEMOPTS) |
189 | LDFLAGS += $(EXTMEMOPTS) |
| 185 | LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
190 | LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
| 186 | 191 | ||
| 187 | 192 | ||
| 188 | 193 | ||
| 189 | 194 | ||
| 190 | # Programming support using avrdude. Settings and variables. |
195 | # Programming support using avrdude. Settings and variables. |
| 191 | 196 | ||
| 192 | # Programming hardware: alf avr910 avrisp bascom bsd |
197 | # Programming hardware: alf avr910 avrisp bascom bsd |
| 193 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
198 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
| 194 | # |
199 | # |
| 195 | # Type: avrdude -c ? |
200 | # Type: avrdude -c ? |
| 196 | # to get a full listing. |
201 | # to get a full listing. |
| 197 | # |
202 | # |
| 198 | AVRDUDE_PROGRAMMER = avrispv2 |
203 | AVRDUDE_PROGRAMMER = avrispv2 |
| 199 | 204 | ||
| 200 | # com1 = serial port. Use lpt1 to connect to parallel port. |
205 | # com1 = serial port. Use lpt1 to connect to parallel port. |
| 201 | AVRDUDE_PORT = |
206 | AVRDUDE_PORT = /dev/ttyUSB0 # programmer connected to serial device |
| 202 | AVRDUDE_BAUD = 115200 |
207 | AVRDUDE_BAUD = 115200 |
| 203 | 208 | ||
| 204 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
209 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
| 205 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
210 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
| 206 | 211 | ||
| 207 | 212 | ||
| 208 | # Uncomment the following if you want avrdude's erase cycle counter. |
213 | # Uncomment the following if you want avrdude's erase cycle counter. |
| 209 | # Note that this counter needs to be initialized first using -Yn, |
214 | # Note that this counter needs to be initialized first using -Yn, |
| 210 | # see avrdude manual. |
215 | # see avrdude manual. |
| 211 | #AVRDUDE_ERASE_COUNTER = -y |
216 | #AVRDUDE_ERASE_COUNTER = -y |
| 212 | 217 | ||
| 213 | # Uncomment the following if you do /not/ wish a verification to be |
218 | # Uncomment the following if you do /not/ wish a verification to be |
| 214 | # performed after programming the device. |
219 | # performed after programming the device. |
| 215 | #AVRDUDE_NO_VERIFY = -V |
220 | #AVRDUDE_NO_VERIFY = -V |
| 216 | 221 | ||
| 217 | # Increase verbosity level. Please use this when submitting bug |
222 | # Increase verbosity level. Please use this when submitting bug |
| 218 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
223 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
| 219 | # to submit bug reports. |
224 | # to submit bug reports. |
| 220 | #AVRDUDE_VERBOSE = -v -v |
225 | #AVRDUDE_VERBOSE = -v -v |
| 221 | 226 | ||
| 222 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -b $(AVRDUDE_BAUD) |
227 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -b $(AVRDUDE_BAUD) |
| 223 | AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) |
228 | AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) |
| 224 | AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) |
229 | AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) |
| 225 | AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) |
230 | AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) |
| 226 | 231 | ||
| 227 | 232 | ||
| 228 | 233 | ||
| 229 | # --------------------------------------------------------------------------- |
234 | # --------------------------------------------------------------------------- |
| 230 | 235 | ||
| 231 | # Define directories, if needed. |
236 | # Define directories, if needed. |
| 232 | DIRAVR = c:/progra~1/winavr |
237 | DIRAVR = c:/progra~1/winavr |
| 233 | DIRAVRBIN = $(DIRAVR)/bin |
238 | DIRAVRBIN = $(DIRAVR)/bin |
| 234 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
239 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
| 235 | DIRINC = . |
240 | DIRINC = . |
| 236 | DIRLIB = $(DIRAVR)/avr/lib |
241 | DIRLIB = $(DIRAVR)/avr/lib |
| 237 | 242 | ||
| 238 | 243 | ||
| 239 | # Define programs and commands. |
244 | # Define programs and commands. |
| 240 | SHELL = sh |
245 | SHELL = sh |
| 241 | CC = avr-gcc |
246 | CC = avr-gcc |
| 242 | OBJCOPY = avr-objcopy |
247 | OBJCOPY = avr-objcopy |
| 243 | OBJDUMP = avr-objdump |
248 | OBJDUMP = avr-objdump |
| 244 | SIZE = avr-size |
249 | SIZE = avr-size |
| 245 | NM = avr-nm |
250 | NM = avr-nm |
| 246 | AVRDUDE = avrdude |
251 | AVRDUDE = avrdude |
| 247 | REMOVE = rm -f |
252 | REMOVE = rm -f |
| 248 | COPY = cp |
253 | COPY = cp |
| 249 | 254 | ||
| 250 | 255 | ||
| 251 | 256 | ||
| 252 | 257 | ||
| 253 | # Define Messages |
258 | # Define Messages |
| 254 | # English |
259 | # English |
| 255 | MSG_ERRORS_NONE = Errors: none |
260 | MSG_ERRORS_NONE = Errors: none |
| 256 | MSG_BEGIN = -------- begin -------- |
261 | MSG_BEGIN = -------- begin -------- |
| 257 | MSG_END = -------- end -------- |
262 | MSG_END = -------- end -------- |
| 258 | MSG_SIZE_BEFORE = Size before: |
263 | MSG_SIZE_BEFORE = Size before: |
| 259 | MSG_SIZE_AFTER = Size after: |
264 | MSG_SIZE_AFTER = Size after: |
| 260 | MSG_COFF = Converting to AVR COFF: |
265 | MSG_COFF = Converting to AVR COFF: |
| 261 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
266 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
| 262 | MSG_FLASH = Creating load file for Flash: |
267 | MSG_FLASH = Creating load file for Flash: |
| 263 | MSG_EEPROM = Creating load file for EEPROM: |
268 | MSG_EEPROM = Creating load file for EEPROM: |
| 264 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
269 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
| 265 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
270 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
| 266 | MSG_LINKING = Linking: |
271 | MSG_LINKING = Linking: |
| 267 | MSG_COMPILING = Compiling: |
272 | MSG_COMPILING = Compiling: |
| 268 | MSG_ASSEMBLING = Assembling: |
273 | MSG_ASSEMBLING = Assembling: |
| 269 | MSG_CLEANING = Cleaning project: |
274 | MSG_CLEANING = Cleaning project: |
| 270 | 275 | ||
| 271 | 276 | ||
| 272 | 277 | ||
| 273 | 278 | ||
| 274 | # Define all object files. |
279 | # Define all object files. |
| 275 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
280 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
| 276 | 281 | ||
| 277 | # Define all listing files. |
282 | # Define all listing files. |
| 278 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
283 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
| 279 | 284 | ||
| 280 | 285 | ||
| 281 | # Compiler flags to generate dependency files. |
286 | # Compiler flags to generate dependency files. |
| 282 | ### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d |
287 | ### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d |
| 283 | GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d |
288 | GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d |
| 284 | 289 | ||
| 285 | # Combine all necessary flags and optional flags. |
290 | # Combine all necessary flags and optional flags. |
| 286 | # Add target processor to flags. |
291 | # Add target processor to flags. |
| 287 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) |
292 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) |
| 288 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
293 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
| 289 | 294 | ||
| 290 | 295 | ||
| 291 | 296 | ||
| 292 | 297 | ||
| 293 | 298 | ||
| 294 | # Default target. |
299 | # Default target. |
| 295 | all: begin gccversion sizebefore build sizeafter finished end |
300 | all: begin gccversion sizebefore build sizeafter finished end |
| 296 | 301 | ||
| 297 | build: elf hex eep lss sym |
302 | build: elf hex eep lss sym |
| 298 | 303 | ||
| 299 | elf: $(TARGET).elf |
304 | elf: $(TARGET).elf |
| 300 | hex: $(TARGET).hex |
305 | hex: $(TARGET).hex |
| 301 | eep: $(TARGET).eep |
306 | eep: $(TARGET).eep |
| 302 | lss: $(TARGET).lss |
307 | lss: $(TARGET).lss |
| 303 | sym: $(TARGET).sym |
308 | sym: $(TARGET).sym |
| 304 | 309 | ||
| 305 | 310 | ||
| 306 | 311 | ||
| 307 | # Eye candy. |
312 | # Eye candy. |
| 308 | # AVR Studio 3.x does not check make's exit code but relies on |
313 | # AVR Studio 3.x does not check make's exit code but relies on |
| 309 | # the following magic strings to be generated by the compile job. |
314 | # the following magic strings to be generated by the compile job. |
| 310 | begin: |
315 | begin: |
| 311 | @echo |
316 | @echo |
| 312 | @echo $(MSG_BEGIN) |
317 | @echo $(MSG_BEGIN) |
| 313 | 318 | ||
| 314 | finished: |
319 | finished: |
| 315 | @echo $(MSG_ERRORS_NONE) |
320 | @echo $(MSG_ERRORS_NONE) |
| 316 | 321 | ||
| 317 | end: |
322 | end: |
| 318 | @echo $(MSG_END) |
323 | @echo $(MSG_END) |
| 319 | @echo |
324 | @echo |
| 320 | 325 | ||
| 321 | 326 | ||
| 322 | # Display size of file. |
327 | # Display size of file. |
| 323 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
328 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
| 324 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
329 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
| 325 | sizebefore: |
330 | sizebefore: |
| 326 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
331 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
| 327 | 332 | ||
| 328 | sizeafter: |
333 | sizeafter: |
| 329 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
334 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
| 330 | 335 | ||
| 331 | 336 | ||
| 332 | 337 | ||
| 333 | # Display compiler version information. |
338 | # Display compiler version information. |
| 334 | gccversion : |
339 | gccversion : |
| 335 | @$(CC) --version |
340 | @$(CC) --version |
| 336 | 341 | ||
| 337 | 342 | ||
| 338 | 343 | ||
| 339 | # Program the device. |
344 | # Program the device. |
| 340 | program: $(TARGET).hex $(TARGET).eep |
345 | program: $(TARGET).hex $(TARGET).eep |
| 341 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
346 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
| 342 | 347 | ||
| 343 | #programlock: |
348 | #programlock: |
| 344 | # $(AVRDUDE) $(AVRDUDE_FLAGS) -U lock:w:0x00:m |
349 | # $(AVRDUDE) $(AVRDUDE_FLAGS) -U lock:w:0x00:m |
| 345 | 350 | ||
| 346 | #programinit: |
351 | #programinit: |
| 347 | # $(AVRDUDE) $(AVRDUDE_FLAGS) -U hfuse:w:0xd9:m -U lfuse:w:0xe4:m |
352 | # $(AVRDUDE) $(AVRDUDE_FLAGS) -U hfuse:w:0xd9:m -U lfuse:w:0xe4:m |
| 348 | 353 | ||
| 349 | # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. |
354 | # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. |
| 350 | COFFCONVERT=$(OBJCOPY) --debugging \ |
355 | COFFCONVERT=$(OBJCOPY) --debugging \ |
| 351 | --change-section-address .data-0x800000 \ |
356 | --change-section-address .data-0x800000 \ |
| 352 | --change-section-address .bss-0x800000 \ |
357 | --change-section-address .bss-0x800000 \ |
| 353 | --change-section-address .noinit-0x800000 \ |
358 | --change-section-address .noinit-0x800000 \ |
| 354 | --change-section-address .eeprom-0x810000 |
359 | --change-section-address .eeprom-0x810000 |
| 355 | 360 | ||
| 356 | 361 | ||
| 357 | coff: $(TARGET).elf |
362 | coff: $(TARGET).elf |
| 358 | @echo |
363 | @echo |
| 359 | @echo $(MSG_COFF) $(TARGET).cof |
364 | @echo $(MSG_COFF) $(TARGET).cof |
| 360 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
365 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
| 361 | 366 | ||
| 362 | 367 | ||
| 363 | extcoff: $(TARGET).elf |
368 | extcoff: $(TARGET).elf |
| 364 | @echo |
369 | @echo |
| 365 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
370 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
| 366 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
371 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
| 367 | 372 | ||
| 368 | 373 | ||
| 369 | 374 | ||
| 370 | # Create final output files (.hex, .eep) from ELF output file. |
375 | # Create final output files (.hex, .eep) from ELF output file. |
| 371 | %.hex: %.elf |
376 | %.hex: %.elf |
| 372 | @echo |
377 | @echo |
| 373 | @echo $(MSG_FLASH) $@ |
378 | @echo $(MSG_FLASH) $@ |
| 374 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
379 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
| 375 | 380 | ||
| 376 | %.eep: %.elf |
381 | %.eep: %.elf |
| 377 | @echo |
382 | @echo |
| 378 | @echo $(MSG_EEPROM) $@ |
383 | @echo $(MSG_EEPROM) $@ |
| 379 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
384 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
| 380 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
385 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
| 381 | 386 | ||
| 382 | # Create extended listing file from ELF output file. |
387 | # Create extended listing file from ELF output file. |
| 383 | %.lss: %.elf |
388 | %.lss: %.elf |
| 384 | @echo |
389 | @echo |
| 385 | @echo $(MSG_EXTENDED_LISTING) $@ |
390 | @echo $(MSG_EXTENDED_LISTING) $@ |
| 386 | $(OBJDUMP) -h -S $< > $@ |
391 | $(OBJDUMP) -h -S $< > $@ |
| 387 | 392 | ||
| 388 | # Create a symbol table from ELF output file. |
393 | # Create a symbol table from ELF output file. |
| 389 | %.sym: %.elf |
394 | %.sym: %.elf |
| 390 | @echo |
395 | @echo |
| 391 | @echo $(MSG_SYMBOL_TABLE) $@ |
396 | @echo $(MSG_SYMBOL_TABLE) $@ |
| 392 | $(NM) -n $< > $@ |
397 | $(NM) -n $< > $@ |
| 393 | 398 | ||
| 394 | 399 | ||
| 395 | 400 | ||
| 396 | # Link: create ELF output file from object files. |
401 | # Link: create ELF output file from object files. |
| 397 | .SECONDARY : $(TARGET).elf |
402 | .SECONDARY : $(TARGET).elf |
| 398 | .PRECIOUS : $(OBJ) |
403 | .PRECIOUS : $(OBJ) |
| 399 | %.elf: $(OBJ) |
404 | %.elf: $(OBJ) |
| 400 | @echo |
405 | @echo |
| 401 | @echo $(MSG_LINKING) $@ |
406 | @echo $(MSG_LINKING) $@ |
| 402 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
407 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
| 403 | 408 | ||
| 404 | 409 | ||
| 405 | # Compile: create object files from C source files. |
410 | # Compile: create object files from C source files. |
| 406 | %.o : %.c |
411 | %.o : %.c |
| 407 | @echo |
412 | @echo |
| 408 | @echo $(MSG_COMPILING) $< |
413 | @echo $(MSG_COMPILING) $< |
| 409 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
414 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
| 410 | 415 | ||
| 411 | 416 | ||
| 412 | # Compile: create assembler files from C source files. |
417 | # Compile: create assembler files from C source files. |
| 413 | %.s : %.c |
418 | %.s : %.c |
| 414 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
419 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
| 415 | 420 | ||
| 416 | 421 | ||
| 417 | # Assemble: create object files from assembler source files. |
422 | # Assemble: create object files from assembler source files. |
| 418 | %.o : %.S |
423 | %.o : %.S |
| 419 | @echo |
424 | @echo |
| 420 | @echo $(MSG_ASSEMBLING) $< |
425 | @echo $(MSG_ASSEMBLING) $< |
| 421 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
426 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
| 422 | 427 | ||
| 423 | 428 | ||
| 424 | 429 | ||
| 425 | # Target: clean project. |
430 | # Target: clean project. |
| 426 | clean: begin clean_list finished end |
431 | clean: begin clean_list finished end |
| 427 | 432 | ||
| 428 | clean_list : |
433 | clean_list : |
| 429 | @echo |
434 | @echo |
| 430 | @echo $(MSG_CLEANING) |
435 | @echo $(MSG_CLEANING) |
| 431 | $(REMOVE) $(TARGET).hex |
436 | $(REMOVE) $(TARGET).hex |
| 432 | $(REMOVE) $(TARGET).eep |
437 | $(REMOVE) $(TARGET).eep |
| 433 | $(REMOVE) $(TARGET).obj |
438 | $(REMOVE) $(TARGET).obj |
| 434 | $(REMOVE) $(TARGET).cof |
439 | $(REMOVE) $(TARGET).cof |
| 435 | $(REMOVE) $(TARGET).elf |
440 | $(REMOVE) $(TARGET).elf |
| 436 | $(REMOVE) $(TARGET).map |
441 | $(REMOVE) $(TARGET).map |
| 437 | $(REMOVE) $(TARGET).obj |
442 | $(REMOVE) $(TARGET).obj |
| 438 | $(REMOVE) $(TARGET).a90 |
443 | $(REMOVE) $(TARGET).a90 |
| 439 | $(REMOVE) $(TARGET).sym |
444 | $(REMOVE) $(TARGET).sym |
| 440 | $(REMOVE) $(TARGET).lnk |
445 | $(REMOVE) $(TARGET).lnk |
| 441 | $(REMOVE) $(TARGET).lss |
446 | $(REMOVE) $(TARGET).lss |
| 442 | $(REMOVE) $(OBJ) |
447 | $(REMOVE) $(OBJ) |
| 443 | $(REMOVE) $(LST) |
448 | $(REMOVE) $(LST) |
| 444 | $(REMOVE) $(SRC:.c=.s) |
449 | $(REMOVE) $(SRC:.c=.s) |
| 445 | $(REMOVE) $(SRC:.c=.d) |
450 | $(REMOVE) $(SRC:.c=.d) |
| 446 | $(REMOVE) .dep/* |
451 | $(REMOVE) .dep/* |
| 447 | 452 | ||
| 448 | 453 | ||
| 449 | 454 | ||
| 450 | # Include the dependency files. |
455 | # Include the dependency files. |
| 451 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) |
456 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) |
| 452 | 457 | ||
| 453 | 458 | ||
| 454 | # Listing of phony targets. |
459 | # Listing of phony targets. |
| 455 | .PHONY : all begin finish end sizebefore sizeafter gccversion \ |
460 | .PHONY : all begin finish end sizebefore sizeafter gccversion \ |
| 456 | build elf hex eep lss sym coff extcoff \ |
461 | build elf hex eep lss sym coff extcoff \ |
| 457 | clean clean_list program programlock programinit |
462 | clean clean_list program programlock programinit |
| 458 | 463 | ||