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