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