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