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