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