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