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