Rev 478 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 478 | Rev 484 | ||
|---|---|---|---|
| 1 | include bios.inc |
1 | include bios.inc |
| 2 | 2 | ||
| 3 | # Target file name (without extension). |
3 | # Target file name (without extension). |
| 4 | TARGET = main |
4 | TARGET = main |
| 5 | 5 | ||
| 6 | LIBDIR = ../../avr-lib |
6 | LIBDIR = ../../avr-lib |
| 7 | include $(LIBDIR)/system.inc |
7 | include $(LIBDIR)/system.inc |
| 8 | 8 | ||
| 9 | # List C source files here. (C dependencies are automatically generated.) |
9 | # List C source files here. (C dependencies are automatically generated.) |
| 10 | CSRC = $(TARGET).c\ |
10 | CSRC = $(TARGET).c\ |
| 11 | $(LIBDIR)/drivers/timer/timebase.c\ |
11 | $(LIBDIR)/drivers/timer/timebase.c\ |
| 12 | $(LIBDIR)/drivers/uart/serial.c\ |
- | |
| 13 | $(LIBDIR)/drivers/uart/uart.c\ |
- | |
| 14 | $(LIBDIR)/drivers/mcu/mcu.c\ |
12 | $(LIBDIR)/drivers/mcu/mcu.c\ |
| 15 | $(LIBDIR)/drivers/ir/receiver/irreceiver.c\ |
13 | $(LIBDIR)/drivers/ir/receiver/irreceiver.c\ |
| 16 | 14 | ||
| 17 | # List Assembler source files here. |
15 | # List Assembler source files here. |
| 18 | # Make them always end in a capital .S. Files ending in a lowercase .s |
16 | # Make them always end in a capital .S. Files ending in a lowercase .s |
| 19 | # will not be considered source files but generated files (assembler |
17 | # will not be considered source files but generated files (assembler |
| 20 | # output from the compiler), and will be deleted upon "make clean"! |
18 | # output from the compiler), and will be deleted upon "make clean"! |
| 21 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
19 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
| 22 | # it will preserve the spelling of the filenames, and gcc itself does |
20 | # it will preserve the spelling of the filenames, and gcc itself does |
| 23 | # care about how the name is spelled on its command-line. |
21 | # care about how the name is spelled on its command-line. |
| 24 | ASRC = |
22 | ASRC = |
| 25 | 23 | ||
| 26 | 24 | ||
| 27 | # Optimization level, can be [0, 1, 2, 3, s]. |
25 | # Optimization level, can be [0, 1, 2, 3, s]. |
| 28 | # 0 = turn off optimization. s = optimize for size. |
26 | # 0 = turn off optimization. s = optimize for size. |
| 29 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
27 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
| 30 | OPT = s |
28 | OPT = s |
| 31 | #OPT = 3 |
29 | #OPT = 3 |
| 32 | 30 | ||
| 33 | # Debugging format. |
31 | # Debugging format. |
| 34 | # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. |
32 | # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. |
| 35 | # AVR (extended) COFF requires stabs, plus an avr-objcopy run. |
33 | # AVR (extended) COFF requires stabs, plus an avr-objcopy run. |
| 36 | DEBUG = stabs |
34 | DEBUG = stabs |
| 37 | #DEBUG = dwarf-2 |
35 | #DEBUG = dwarf-2 |
| 38 | 36 | ||
| 39 | # List any extra directories to look for include files here. |
37 | # List any extra directories to look for include files here. |
| 40 | # Each directory must be seperated by a space. |
38 | # Each directory must be seperated by a space. |
| 41 | EXTRAINCDIRS = $(LIBDIR) |
39 | EXTRAINCDIRS = $(LIBDIR) |
| 42 | 40 | ||
| 43 | # Compiler flag to set the C Standard level. |
41 | # Compiler flag to set the C Standard level. |
| 44 | # c89 - "ANSI" C |
42 | # c89 - "ANSI" C |
| 45 | # gnu89 - c89 plus GCC extensions |
43 | # gnu89 - c89 plus GCC extensions |
| 46 | # c99 - ISO C99 standard (not yet fully implemented) |
44 | # c99 - ISO C99 standard (not yet fully implemented) |
| 47 | # gnu99 - c99 plus GCC extensions |
45 | # gnu99 - c99 plus GCC extensions |
| 48 | CSTANDARD = -std=gnu99 |
46 | CSTANDARD = -std=gnu99 |
| 49 | 47 | ||
| 50 | # Place -D or -U options here |
48 | # Place -D or -U options here |
| 51 | CDEFS = |
49 | CDEFS = |
| 52 | 50 | ||
| 53 | # Place -I options here |
51 | # Place -I options here |
| 54 | CINCS = |
52 | CINCS = |
| 55 | 53 | ||
| 56 | 54 | ||
| 57 | # Compiler flags. |
55 | # Compiler flags. |
| 58 | # -g*: generate debugging information |
56 | # -g*: generate debugging information |
| 59 | # -O*: optimization level |
57 | # -O*: optimization level |
| 60 | # -f...: tuning, see GCC manual and avr-libc documentation |
58 | # -f...: tuning, see GCC manual and avr-libc documentation |
| 61 | # -Wall...: warning level |
59 | # -Wall...: warning level |
| 62 | # -Wa,...: tell GCC to pass this to the assembler. |
60 | # -Wa,...: tell GCC to pass this to the assembler. |
| 63 | # -adhlns...: create assembler listing |
61 | # -adhlns...: create assembler listing |
| 64 | CFLAGS = -mmcu=$(MCU) -I. |
62 | CFLAGS = -mmcu=$(MCU) -I. |
| 65 | CFLAGS += -g$(DEBUG) |
63 | CFLAGS += -g$(DEBUG) |
| 66 | CFLAGS += $(CDEFS) $(CINCS) |
64 | CFLAGS += $(CDEFS) $(CINCS) |
| 67 | CFLAGS += -O$(OPT) |
65 | CFLAGS += -O$(OPT) |
| 68 | CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
66 | CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
| 69 | CFLAGS += -Wall -Wstrict-prototypes |
67 | CFLAGS += -Wall -Wstrict-prototypes |
| 70 | CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
68 | CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
| 71 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
69 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
| 72 | CFLAGS += $(CSTANDARD) |
70 | CFLAGS += $(CSTANDARD) |
| 73 | 71 | ||
| 74 | 72 | ||
| 75 | 73 | ||
| 76 | # Assembler flags. |
74 | # Assembler flags. |
| 77 | # -Wa,...: tell GCC to pass this to the assembler. |
75 | # -Wa,...: tell GCC to pass this to the assembler. |
| 78 | # -ahlms: create listing |
76 | # -ahlms: create listing |
| 79 | # -gstabs: have the assembler create line number information; note that |
77 | # -gstabs: have the assembler create line number information; note that |
| 80 | # for use in COFF files, additional information about filenames |
78 | # for use in COFF files, additional information about filenames |
| 81 | # and function names needs to be present in the assembler source |
79 | # and function names needs to be present in the assembler source |
| 82 | # files -- see avr-libc docs [FIXME: not yet described there] |
80 | # files -- see avr-libc docs [FIXME: not yet described there] |
| 83 | ##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
81 | ##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
| 84 | ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp |
82 | ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp |
| 85 | ASFLAGS += -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG) |
83 | ASFLAGS += -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG) |
| 86 | 84 | ||
| 87 | 85 | ||
| 88 | #Additional libraries. |
86 | #Additional libraries. |
| 89 | 87 | ||
| 90 | # Minimalistic printf version |
88 | # Minimalistic printf version |
| 91 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
89 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min |
| 92 | 90 | ||
| 93 | # Floating point printf version (requires MATH_LIB = -lm below) |
91 | # Floating point printf version (requires MATH_LIB = -lm below) |
| 94 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
92 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt |
| 95 | 93 | ||
| 96 | PRINTF_LIB = |
94 | PRINTF_LIB = |
| 97 | 95 | ||
| 98 | # Minimalistic scanf version |
96 | # Minimalistic scanf version |
| 99 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
97 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min |
| 100 | 98 | ||
| 101 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
99 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below) |
| 102 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
100 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt |
| 103 | 101 | ||
| 104 | SCANF_LIB = |
102 | SCANF_LIB = |
| 105 | 103 | ||
| 106 | MATH_LIB = -lm |
104 | MATH_LIB = -lm |
| 107 | 105 | ||
| 108 | # External memory options |
106 | # External memory options |
| 109 | 107 | ||
| 110 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
108 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
| 111 | # used for variables (.data/.bss) and heap (malloc()). |
109 | # used for variables (.data/.bss) and heap (malloc()). |
| 112 | #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff |
110 | #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff |
| 113 | 111 | ||
| 114 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
112 | # 64 KB of external RAM, starting after internal RAM (ATmega128!), |
| 115 | # only used for heap (malloc()). |
113 | # only used for heap (malloc()). |
| 116 | #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff |
114 | #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff |
| 117 | 115 | ||
| 118 | EXTMEMOPTS = |
116 | EXTMEMOPTS = |
| 119 | 117 | ||
| 120 | BIOSOPTS = -Wl,-L.,-Tdata,$(BIOS_RAM_END) -lbios |
118 | BIOSOPTS = -Wl,-L.,-Tdata,$(BIOS_RAM_END) -lbios |
| 121 | 119 | ||
| 122 | # Linker flags. |
120 | # Linker flags. |
| 123 | # -Wl,...: tell GCC to pass this to linker. |
121 | # -Wl,...: tell GCC to pass this to linker. |
| 124 | # -Map: create map file |
122 | # -Map: create map file |
| 125 | # --cref: add cross reference to map file |
123 | # --cref: add cross reference to map file |
| 126 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
124 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
| 127 | LDFLAGS += $(EXTMEMOPTS) |
125 | LDFLAGS += $(EXTMEMOPTS) |
| 128 | LDFLAGS += $(BIOSOPTS) |
126 | LDFLAGS += $(BIOSOPTS) |
| 129 | LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
127 | LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) |
| 130 | 128 | ||
| 131 | # --------------------------------------------------------------------------- |
129 | # --------------------------------------------------------------------------- |
| 132 | 130 | ||
| 133 | # Define directories, if needed. |
131 | # Define directories, if needed. |
| 134 | DIRAVR = c:/progra~1/winavr |
132 | DIRAVR = c:/progra~1/winavr |
| 135 | DIRAVRBIN = $(DIRAVR)/bin |
133 | DIRAVRBIN = $(DIRAVR)/bin |
| 136 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
134 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
| 137 | DIRINC = . |
135 | DIRINC = . |
| 138 | DIRLIB = $(DIRAVR)/avr/lib |
136 | DIRLIB = $(DIRAVR)/avr/lib |
| 139 | 137 | ||
| 140 | 138 | ||
| 141 | # Define programs and commands. |
139 | # Define programs and commands. |
| 142 | SHELL = sh |
140 | SHELL = sh |
| 143 | CC = avr-gcc |
141 | CC = avr-gcc |
| 144 | AWK = awk |
142 | AWK = awk |
| 145 | OBJCOPY = avr-objcopy |
143 | OBJCOPY = avr-objcopy |
| 146 | OBJDUMP = avr-objdump |
144 | OBJDUMP = avr-objdump |
| 147 | SIZE = avr-size |
145 | SIZE = avr-size |
| 148 | NM = avr-nm |
146 | NM = avr-nm |
| 149 | REMOVE = rm -f |
147 | REMOVE = rm -f |
| 150 | COPY = cp |
148 | COPY = cp |
| 151 | 149 | ||
| 152 | 150 | ||
| 153 | 151 | ||
| 154 | 152 | ||
| 155 | # Define Messages |
153 | # Define Messages |
| 156 | # English |
154 | # English |
| 157 | MSG_ERRORS_NONE = Errors: none |
155 | MSG_ERRORS_NONE = Errors: none |
| 158 | MSG_BEGIN = -------- begin -------- |
156 | MSG_BEGIN = -------- begin -------- |
| 159 | MSG_END = -------- end -------- |
157 | MSG_END = -------- end -------- |
| 160 | MSG_SIZE_BEFORE = Size before: |
158 | MSG_SIZE_BEFORE = Size before: |
| 161 | MSG_SIZE_AFTER = Size after: |
159 | MSG_SIZE_AFTER = Size after: |
| 162 | MSG_COFF = Converting to AVR COFF: |
160 | MSG_COFF = Converting to AVR COFF: |
| 163 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
161 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
| 164 | MSG_FLASH = Creating load file for Flash: |
162 | MSG_FLASH = Creating load file for Flash: |
| 165 | MSG_EEPROM = Creating load file for EEPROM: |
163 | MSG_EEPROM = Creating load file for EEPROM: |
| 166 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
164 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
| 167 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
165 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
| 168 | MSG_LINKING = Linking: |
166 | MSG_LINKING = Linking: |
| 169 | MSG_COMPILING = Compiling: |
167 | MSG_COMPILING = Compiling: |
| 170 | MSG_ASSEMBLING = Assembling: |
168 | MSG_ASSEMBLING = Assembling: |
| 171 | MSG_DEPEND = Generating dependencies: |
169 | MSG_DEPEND = Generating dependencies: |
| 172 | MSG_CLEANING = Cleaning project: |
170 | MSG_CLEANING = Cleaning project: |
| 173 | 171 | ||
| 174 | 172 | ||
| 175 | 173 | ||
| 176 | 174 | ||
| 177 | # Define all object files. |
175 | # Define all object files. |
| 178 | OBJ = $(CSRC:.c=.o) $(ASRC:.S=.o) |
176 | OBJ = $(CSRC:.c=.o) $(ASRC:.S=.o) |
| 179 | 177 | ||
| 180 | # Define all listing files. |
178 | # Define all listing files. |
| 181 | LST = $(ASRC:.S=.lst) $(CSRC:.c=.lst) |
179 | LST = $(ASRC:.S=.lst) $(CSRC:.c=.lst) |
| 182 | 180 | ||
| 183 | 181 | ||
| 184 | # Compiler flags to generate dependency files. |
182 | # Compiler flags to generate dependency files. |
| 185 | ### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d |
183 | ### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d |
| 186 | GENDEPFLAGS = -M -MG -MP -MT "$(<:.c=.o) $@" -MF $@ |
184 | GENDEPFLAGS = -M -MG -MP -MT "$(<:.c=.o) $@" -MF $@ |
| 187 | 185 | ||
| 188 | # Combine all necessary flags and optional flags. |
186 | # Combine all necessary flags and optional flags. |
| 189 | # Add target processor to flags. |
187 | # Add target processor to flags. |
| 190 | #ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
188 | #ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
| 191 | #ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
189 | #ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
| 192 | 190 | ||
| 193 | 191 | ||
| 194 | 192 | ||
| 195 | 193 | ||
| 196 | 194 | ||
| 197 | # Default target. |
195 | # Default target. |
| 198 | all: begin sizebefore build sizeafter finished end |
196 | all: begin sizebefore build sizeafter finished end |
| 199 | 197 | ||
| 200 | build: elf hex eep lss sym |
198 | build: elf hex eep lss sym |
| 201 | 199 | ||
| 202 | elf: $(TARGET).elf |
200 | elf: $(TARGET).elf |
| 203 | hex: $(TARGET).hex |
201 | hex: $(TARGET).hex |
| 204 | eep: $(TARGET).eep |
202 | eep: $(TARGET).eep |
| 205 | lss: $(TARGET).lss |
203 | lss: $(TARGET).lss |
| 206 | sym: $(TARGET).sym |
204 | sym: $(TARGET).sym |
| 207 | config: config.h |
205 | config: config.h |
| 208 | 206 | ||
| 209 | install: hex |
207 | install: hex |
| 210 | $(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -f $(TARGET).hex -r |
208 | $(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -f $(TARGET).hex -r |
| 211 | 209 | ||
| 212 | reset: |
210 | reset: |
| 213 | $(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -r |
211 | $(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -r |
| 214 | 212 | ||
| 215 | start: |
213 | start: |
| 216 | $(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -s |
214 | $(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -s |
| 217 | 215 | ||
| 218 | # Eye candy. |
216 | # Eye candy. |
| 219 | # AVR Studio 3.x does not check make's exit code but relies on |
217 | # AVR Studio 3.x does not check make's exit code but relies on |
| 220 | # the following magic strings to be generated by the compile job. |
218 | # the following magic strings to be generated by the compile job. |
| 221 | begin: |
219 | begin: |
| 222 | @echo |
220 | @echo |
| 223 | @echo $(MSG_BEGIN) |
221 | @echo $(MSG_BEGIN) |
| 224 | 222 | ||
| 225 | finished: |
223 | finished: |
| 226 | @echo $(MSG_ERRORS_NONE) |
224 | @echo $(MSG_ERRORS_NONE) |
| 227 | 225 | ||
| 228 | end: |
226 | end: |
| 229 | @echo $(MSG_END) |
227 | @echo $(MSG_END) |
| 230 | @echo |
228 | @echo |
| 231 | 229 | ||
| 232 | 230 | ||
| 233 | # Display size of file. |
231 | # Display size of file. |
| 234 | HEXSIZE = $(SIZE) --target=ihex $(TARGET).hex |
232 | HEXSIZE = $(SIZE) --target=ihex $(TARGET).hex |
| 235 | ELFSIZE = $(SIZE) $(TARGET).elf |
233 | ELFSIZE = $(SIZE) $(TARGET).elf |
| 236 | sizebefore: |
234 | sizebefore: |
| 237 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
235 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
| 238 | 236 | ||
| 239 | sizeafter: |
237 | sizeafter: |
| 240 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
238 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
| 241 | 239 | ||
| 242 | 240 | ||
| 243 | # Generate config.h from bios.inc and config.inc |
241 | # Generate config.h from bios.inc and config.inc |
| 244 | config.h: bios.inc config.inc |
242 | config.h: bios.inc config.inc |
| 245 | @echo Generating $@ |
243 | @echo Generating $@ |
| 246 | @echo "/* This file is automatically generated. Do not edit. */\n" > $@ |
244 | @echo "/* This file is automatically generated. Do not edit. */\n" > $@ |
| 247 | @cat $^ | $(AWK) 'BEGIN { FS="="; print "#ifndef CONFIG_H_\n#define CONFIG_H_\n" } /^[^#].*=.*/ { print "#define "$$1,$$2 } END { print "\n#endif /*CONFIG_H_*/" }' >> $@ |
245 | @cat $^ | $(AWK) 'BEGIN { FS="="; print "#ifndef CONFIG_H_\n#define CONFIG_H_\n" } /^[^#].*=.*/ { print "#define "$$1,$$2 } END { print "\n#endif /*CONFIG_H_*/" }' >> $@ |
| 248 | 246 | ||
| 249 | # Display compiler version information. |
247 | # Display compiler version information. |
| 250 | gccversion : |
248 | gccversion : |
| 251 | @$(CC) --version |
249 | @$(CC) --version |
| 252 | 250 | ||
| 253 | # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. |
251 | # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. |
| 254 | COFFCONVERT=$(OBJCOPY) --debugging \ |
252 | COFFCONVERT=$(OBJCOPY) --debugging \ |
| 255 | --change-section-address .data-0x800000 \ |
253 | --change-section-address .data-0x800000 \ |
| 256 | --change-section-address .bss-0x800000 \ |
254 | --change-section-address .bss-0x800000 \ |
| 257 | --change-section-address .noinit-0x800000 \ |
255 | --change-section-address .noinit-0x800000 \ |
| 258 | --change-section-address .eeprom-0x810000 |
256 | --change-section-address .eeprom-0x810000 |
| 259 | 257 | ||
| 260 | 258 | ||
| 261 | coff: $(TARGET).elf |
259 | coff: $(TARGET).elf |
| 262 | @echo |
260 | @echo |
| 263 | @echo $(MSG_COFF) $(TARGET).cof |
261 | @echo $(MSG_COFF) $(TARGET).cof |
| 264 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
262 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
| 265 | 263 | ||
| 266 | 264 | ||
| 267 | extcoff: $(TARGET).elf |
265 | extcoff: $(TARGET).elf |
| 268 | @echo |
266 | @echo |
| 269 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
267 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
| 270 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
268 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
| 271 | - | ||
| 272 | - | ||
| 273 | 269 | ||
| 274 | # Create final output files (.hex, .eep) from ELF output file. |
270 | # Create final output files (.hex, .eep) from ELF output file. |
| 275 | %.hex: %.elf |
271 | %.hex: %.elf |
| 276 | @echo |
272 | @echo |
| 277 | @echo $(MSG_FLASH) $@ |
273 | @echo $(MSG_FLASH) $@ |
| 278 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
274 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
| 279 | 275 | ||
| 280 | %.eep: %.elf |
276 | %.eep: %.elf |
| 281 | @echo |
277 | @echo |
| 282 | @echo $(MSG_EEPROM) $@ |
278 | @echo $(MSG_EEPROM) $@ |
| 283 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
279 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
| 284 | --change-section-lma .eeprom=0 -O ihex $< $@ |
280 | --change-section-lma .eeprom=0 -O ihex $< $@ |
| 285 | 281 | ||
| 286 | # Create extended listing file from ELF output file. |
282 | # Create extended listing file from ELF output file. |
| 287 | %.lss: %.elf |
283 | %.lss: %.elf |
| 288 | @echo |
284 | @echo |
| 289 | @echo $(MSG_EXTENDED_LISTING) $@ |
285 | @echo $(MSG_EXTENDED_LISTING) $@ |
| 290 | $(OBJDUMP) -h -S $< > $@ |
286 | $(OBJDUMP) -h -S $< > $@ |
| 291 | 287 | ||
| 292 | # Create a symbol table from ELF output file. |
288 | # Create a symbol table from ELF output file. |
| 293 | %.sym: %.elf |
289 | %.sym: %.elf |
| 294 | @echo |
290 | @echo |
| 295 | @echo $(MSG_SYMBOL_TABLE) $@ |
291 | @echo $(MSG_SYMBOL_TABLE) $@ |
| 296 | $(NM) -n $< > $@ |
292 | $(NM) -n $< > $@ |
| 297 | 293 | ||
| 298 | 294 | ||
| 299 | 295 | ||
| 300 | # Link: create ELF output file from object files. |
296 | # Link: create ELF output file from object files. |
| 301 | .SECONDARY : $(TARGET).elf |
297 | .SECONDARY : $(TARGET).elf |
| 302 | .PRECIOUS : $(OBJ) |
298 | .PRECIOUS : $(OBJ) |
| 303 | ifneq (,$(filter atmega88 atmega168, $(MCU))) |
299 | ifneq (,$(filter atmega88 atmega168, $(MCU))) |
| 304 | %.elf: $(OBJ) |
300 | %.elf: $(OBJ) |
| 305 | @echo |
301 | @echo |
| 306 | @echo $(MSG_LINKING) $@ |
302 | @echo $(MSG_LINKING) $@ |
| 307 | @echo GCC bug workaround for ATmega88/ATmega168: |
303 | @echo GCC bug workaround for ATmega88/ATmega168: |
| 308 | eval $$($(CC) -v $(CFLAGS) -o $@ $^ $(LDFLAGS) 2>&1 | $(AWK) '{ if (gsub("0x800100","$(BIOS_RAM_END)") == 1) print }') |
304 | eval $$($(CC) -v $(CFLAGS) -o $@ $^ $(LDFLAGS) 2>&1 | $(AWK) '{ if (gsub("0x800100","$(BIOS_RAM_END)") == 1) print }') |
| 309 | else |
305 | else |
| 310 | %.elf: $(OBJ) |
306 | %.elf: $(OBJ) |
| 311 | @echo |
307 | @echo |
| 312 | @echo $(MSG_LINKING) $@ |
308 | @echo $(MSG_LINKING) $@ |
| 313 | $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) |
309 | $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) |
| 314 | endif |
310 | endif |
| 315 | 311 | ||
| 316 | # Compile: create object files from C source files. |
312 | # Compile: create object files from C source files. |
| 317 | %.o : %.c |
313 | %.o : %.c |
| 318 | @echo |
314 | @echo |
| 319 | @echo $(MSG_COMPILING) $< |
315 | @echo $(MSG_COMPILING) $< |
| 320 | $(CC) -c $(CFLAGS) $< -o $@ |
316 | $(CC) -c $(CFLAGS) $< -o $@ |
| 321 | 317 | ||
| 322 | 318 | ||
| 323 | # Compile: create assembler files from C source files. |
319 | # Compile: create assembler files from C source files. |
| 324 | %.s : %.c |
320 | %.s : %.c |
| 325 | $(CC) -S $(CFLAGS) $< -o $@ |
321 | $(CC) -S $(CFLAGS) $< -o $@ |
| 326 | 322 | ||
| 327 | 323 | ||
| 328 | # Assemble: create object files from assembler source files. |
324 | # Assemble: create object files from assembler source files. |
| 329 | %.o : %.S |
325 | %.o : %.S |
| 330 | @echo |
326 | @echo |
| 331 | @echo $(MSG_ASSEMBLING) $< |
327 | @echo $(MSG_ASSEMBLING) $< |
| 332 | $(CC) -c $(ASFLAGS) $< -o $@ |
328 | $(CC) -c $(ASFLAGS) $< -o $@ |
| 333 | 329 | ||
| 334 | # Depends: create dependency files from c source files. |
330 | # Depends: create dependency files from c source files. |
| 335 | %.d : %.c |
331 | %.d : %.c |
| 336 | @echo $(MSG_DEPEND) $< |
332 | @echo $(MSG_DEPEND) $< |
| 337 | @$(CC) -c $(CFLAGS) $(GENDEPFLAGS) $< |
333 | @$(CC) -c $(CFLAGS) $(GENDEPFLAGS) $< |
| 338 | 334 | ||
| 339 | # Target: clean project. |
335 | # Target: clean project. |
| 340 | clean: begin clean_list finished end |
336 | clean: begin clean_list finished end |
| 341 | 337 | ||
| 342 | clean_list : |
338 | clean_list : |
| 343 | @echo |
339 | @echo |
| 344 | @echo $(MSG_CLEANING) |
340 | @echo $(MSG_CLEANING) |
| 345 | $(REMOVE) $(TARGET).hex |
341 | $(REMOVE) $(TARGET).hex |
| 346 | $(REMOVE) $(TARGET).eep |
342 | $(REMOVE) $(TARGET).eep |
| 347 | $(REMOVE) $(TARGET).obj |
343 | $(REMOVE) $(TARGET).obj |
| 348 | $(REMOVE) $(TARGET).cof |
344 | $(REMOVE) $(TARGET).cof |
| 349 | $(REMOVE) $(TARGET).elf |
345 | $(REMOVE) $(TARGET).elf |
| 350 | $(REMOVE) $(TARGET).map |
346 | $(REMOVE) $(TARGET).map |
| 351 | $(REMOVE) $(TARGET).obj |
347 | $(REMOVE) $(TARGET).obj |
| 352 | $(REMOVE) $(TARGET).a90 |
348 | $(REMOVE) $(TARGET).a90 |
| 353 | $(REMOVE) $(TARGET).sym |
349 | $(REMOVE) $(TARGET).sym |
| 354 | $(REMOVE) $(TARGET).lnk |
350 | $(REMOVE) $(TARGET).lnk |
| 355 | $(REMOVE) $(TARGET).lss |
351 | $(REMOVE) $(TARGET).lss |
| 356 | $(REMOVE) $(OBJ) |
352 | $(REMOVE) $(OBJ) |
| 357 | $(REMOVE) $(LST) |
353 | $(REMOVE) $(LST) |
| 358 | $(REMOVE) $(CSRC:.c=.s) |
354 | $(REMOVE) $(CSRC:.c=.s) |
| 359 | $(REMOVE) $(CSRC:.c=.d) |
355 | $(REMOVE) $(CSRC:.c=.d) |
| 360 | $(REMOVE) -r .dep |
356 | $(REMOVE) -r .dep |
| 361 | $(REMOVE) config.h |
357 | $(REMOVE) config.h |
| 362 | 358 | ||
| 363 | 359 | ||
| 364 | 360 | ||
| 365 | # Include the dependency files. |
361 | # Include the dependency files. |
| 366 | -include $(CSRC:%.c=%.d) |
362 | -include $(CSRC:%.c=%.d) |
| 367 | 363 | ||
| 368 | 364 | ||
| 369 | # Listing of phony targets. |
365 | # Listing of phony targets. |
| 370 | .PHONY : all begin finish end sizebefore sizeafter gccversion \ |
366 | .PHONY : all begin finish end sizebefore sizeafter gccversion \ |
| 371 | build elf hex eep lss sym config coff extcoff \ |
367 | build elf hex eep lss sym config coff extcoff \ |
| 372 | clean clean_list program programlock programinit |
368 | clean clean_list program programlock programinit |
| 373 | 369 | ||