]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/lets_split/uno-slave/Makefile
84e67de113b148a5fd982b3645c4314582a9d684
[qmk_firmware.git] / keyboards / lets_split / uno-slave / Makefile
1 # Hey Emacs, this is a -*- makefile -*-
2
3 # AVR-GCC Makefile template, derived from the WinAVR template (which
4 # is public domain), believed to be neutral to any flavor of "make"
5 # (GNU make, BSD make, SysV make)
6
7
8 MCU = atmega328p
9 FORMAT = ihex
10 TARGET = keyboard-i2c-slave
11 SRC = \
12         $(TARGET).c \
13         uno-matrix.c \
14         ../serial.c \
15         ../i2c-slave.c
16
17 ASRC =
18 OPT = s
19
20 # Programming support using avrdude. Settings and variables.
21
22 AVRDUDE_PROGRAMMER = arduino
23 AVRDUDE_PORT = /dev/ttyACM0
24
25 # Name of this Makefile (used for "make depend").
26 MAKEFILE = Makefile
27
28 # Debugging format.
29 # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
30 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
31 DEBUG = stabs
32
33 # Compiler flag to set the C Standard level.
34 # c89   - "ANSI" C
35 # gnu89 - c89 plus GCC extensions
36 # c99   - ISO C99 standard (not yet fully implemented)
37 # gnu99 - c99 plus GCC extensions
38 CSTANDARD = -std=gnu99
39
40 # Place -D or -U options here
41 CDEFS =
42
43 # Place -I options here
44 CINCS =
45
46
47 CDEBUG = -g$(DEBUG)
48 CWARN = -Wall -Wstrict-prototypes
49 CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
50 #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
51 CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) \
52         -fno-aggressive-loop-optimizations
53
54 #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
55
56
57 #Additional libraries.
58
59 # Minimalistic printf version
60 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
61
62 # Floating point printf version (requires MATH_LIB = -lm below)
63 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
64
65 PRINTF_LIB =
66
67 # Minimalistic scanf version
68 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
69
70 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
71 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
72
73 SCANF_LIB =
74
75 MATH_LIB = -lm
76
77 # External memory options
78
79 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
80 # used for variables (.data/.bss) and heap (malloc()).
81 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
82
83 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
84 # only used for heap (malloc()).
85 #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
86
87 EXTMEMOPTS =
88
89 #LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
90 LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
91
92
93 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
94 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
95
96
97 # Uncomment the following if you want avrdude's erase cycle counter.
98 # Note that this counter needs to be initialized first using -Yn,
99 # see avrdude manual.
100 #AVRDUDE_ERASE_COUNTER = -y
101
102 # Uncomment the following if you do /not/ wish a verification to be
103 # performed after programming the device.
104 #AVRDUDE_NO_VERIFY = -V
105
106 # Increase verbosity level.  Please use this when submitting bug
107 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
108 # to submit bug reports.
109 #AVRDUDE_VERBOSE = -v -v
110
111 AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
112 AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
113
114
115 CC = avr-gcc
116 OBJCOPY = avr-objcopy
117 OBJDUMP = avr-objdump
118 SIZE = avr-size
119 NM = avr-nm
120 AVRDUDE = avrdude
121 REMOVE = rm -f
122 MV = mv -f
123
124 # Define all object files.
125 OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
126
127 # Define all listing files.
128 LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
129
130 # Combine all necessary flags and optional flags.
131 # Add target processor to flags.
132 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
133 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
134
135
136 # Default target.
137 all: build
138
139 build: elf hex eep
140
141 elf: $(TARGET).elf
142 hex: $(TARGET).hex
143 eep: $(TARGET).eep
144 lss: $(TARGET).lss
145 sym: $(TARGET).sym
146
147
148 # Program the device.
149 program: $(TARGET).hex $(TARGET).eep
150         $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
151
152
153 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
154 COFFCONVERT=$(OBJCOPY) --debugging \
155 --change-section-address .data-0x800000 \
156 --change-section-address .bss-0x800000 \
157 --change-section-address .noinit-0x800000 \
158 --change-section-address .eeprom-0x810000
159
160
161 coff: $(TARGET).elf
162         $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
163
164
165 extcoff: $(TARGET).elf
166         $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
167
168
169 .SUFFIXES: .elf .hex .eep .lss .sym
170
171 .elf.hex:
172         $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
173
174 .elf.eep:
175         -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
176         --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
177
178 # Create extended listing file from ELF output file.
179 .elf.lss:
180         $(OBJDUMP) -h -S $< > $@
181
182 # Create a symbol table from ELF output file.
183 .elf.sym:
184         $(NM) -n $< > $@
185
186
187
188 # Link: create ELF output file from object files.
189 $(TARGET).elf: $(OBJ)
190         $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
191
192
193 # Compile: create object files from C source files.
194 .c.o:
195         $(CC) -c $(ALL_CFLAGS) $< -o $@
196
197
198 # Compile: create assembler files from C source files.
199 .c.s:
200         $(CC) -S $(ALL_CFLAGS) $< -o $@
201
202
203 # Assemble: create object files from assembler source files.
204 .S.o:
205         $(CC) -c $(ALL_ASFLAGS) $< -o $@
206
207
208
209 # Target: clean project.
210 clean:
211         $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
212         $(TARGET).map $(TARGET).sym $(TARGET).lss \
213         $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)
214
215 depend:
216         if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
217         then \
218                 sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
219                         $(MAKEFILE).$$$$ && \
220                 $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
221         fi
222         echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
223                 >> $(MAKEFILE); \
224         $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
225
226 .PHONY: all build elf hex eep lss sym program coff extcoff clean depend