]> git.donarmstrong.com Git - qmk_firmware.git/blob - common_features.mk
Update our style guide (#5500)
[qmk_firmware.git] / common_features.mk
1 # Copyright 2017 Fred Sundvik
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 SERIAL_DIR := $(QUANTUM_DIR)/serial_link
17 SERIAL_PATH := $(QUANTUM_PATH)/serial_link
18 SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
19 SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
20 SERIAL_DEFS += -DSERIAL_LINK_ENABLE
21 COMMON_VPATH += $(SERIAL_PATH)
22
23 ifeq ($(strip $(API_SYSEX_ENABLE)), yes)
24     OPT_DEFS += -DAPI_SYSEX_ENABLE
25     SRC += $(QUANTUM_DIR)/api/api_sysex.c
26     OPT_DEFS += -DAPI_ENABLE
27     SRC += $(QUANTUM_DIR)/api.c
28     MIDI_ENABLE=yes
29 endif
30
31 MUSIC_ENABLE := 0
32
33 ifeq ($(strip $(AUDIO_ENABLE)), yes)
34     OPT_DEFS += -DAUDIO_ENABLE
35     MUSIC_ENABLE := 1
36     SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
37     SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
38     ifeq ($(PLATFORM),AVR)
39         SRC += $(QUANTUM_DIR)/audio/audio.c
40     else
41         SRC += $(QUANTUM_DIR)/audio/audio_arm.c
42     endif
43     SRC += $(QUANTUM_DIR)/audio/voices.c
44     SRC += $(QUANTUM_DIR)/audio/luts.c
45 endif
46
47 ifeq ($(strip $(MIDI_ENABLE)), yes)
48     OPT_DEFS += -DMIDI_ENABLE
49     MUSIC_ENABLE := 1
50     SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
51 endif
52
53 ifeq ($(MUSIC_ENABLE), 1)
54     SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
55 endif
56
57 ifeq ($(strip $(COMBO_ENABLE)), yes)
58     OPT_DEFS += -DCOMBO_ENABLE
59     SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
60 endif
61
62 ifeq ($(strip $(STENO_ENABLE)), yes)
63     OPT_DEFS += -DSTENO_ENABLE
64     VIRTSER_ENABLE := yes
65     SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
66 endif
67
68 ifeq ($(strip $(VIRTSER_ENABLE)), yes)
69     OPT_DEFS += -DVIRTSER_ENABLE
70 endif
71
72 ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
73     OPT_DEFS += -DFAUXCLICKY_ENABLE
74     SRC += $(QUANTUM_DIR)/fauxclicky.c
75 endif
76
77 ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
78     OPT_DEFS += -DPOINTING_DEVICE_ENABLE
79     OPT_DEFS += -DMOUSE_ENABLE
80     SRC += $(QUANTUM_DIR)/pointing_device.c
81 endif
82
83 ifeq ($(strip $(UCIS_ENABLE)), yes)
84     OPT_DEFS += -DUCIS_ENABLE
85     UNICODE_COMMON = yes
86     SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
87 endif
88
89 ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
90     OPT_DEFS += -DUNICODEMAP_ENABLE
91     UNICODE_COMMON = yes
92     SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
93 endif
94
95 ifeq ($(strip $(UNICODE_ENABLE)), yes)
96     OPT_DEFS += -DUNICODE_ENABLE
97     UNICODE_COMMON = yes
98     SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
99 endif
100
101 ifeq ($(strip $(UNICODE_COMMON)), yes)
102     SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
103 endif
104
105 ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
106     OPT_DEFS += -DRGBLIGHT_ENABLE
107     SRC += $(QUANTUM_DIR)/rgblight.c
108     CIE1931_CURVE = yes
109     LED_BREATHING_TABLE = yes
110     ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
111         OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
112     else
113         SRC += ws2812.c
114     endif
115 endif
116
117 VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 IS31FL3737 WS2812 custom
118
119 LED_MATRIX_ENABLE ?= no
120 ifneq ($(strip $(LED_MATRIX_ENABLE)), no)
121     ifeq ($(filter $(LED_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
122         $(error LED_MATRIX_ENABLE="$(LED_MATRIX_ENABLE)" is not a valid matrix type)
123     else
124         OPT_DEFS += -DLED_MATRIX_ENABLE -DBACKLIGHT_ENABLE -DBACKLIGHT_CUSTOM_DRIVER
125         SRC += $(QUANTUM_DIR)/led_matrix.c
126         SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
127     endif
128 endif
129
130 ifeq ($(strip $(LED_MATRIX_ENABLE)), IS31FL3731)
131     OPT_DEFS += -DIS31FL3731
132     COMMON_VPATH += $(DRIVER_PATH)/issi
133     SRC += is31fl3731-simple.c
134     SRC += i2c_master.c
135 endif
136
137 RGB_MATRIX_ENABLE ?= no
138
139 ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
140 ifeq ($(filter $(RGB_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
141     $(error RGB_MATRIX_ENABLE="$(RGB_MATRIX_ENABLE)" is not a valid matrix type)
142 endif
143     OPT_DEFS += -DRGB_MATRIX_ENABLE
144     SRC += $(QUANTUM_DIR)/color.c
145     SRC += $(QUANTUM_DIR)/rgb_matrix.c
146     SRC += $(QUANTUM_DIR)/rgb_matrix_drivers.c
147     CIE1931_CURVE = yes
148 endif
149
150 ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
151         RGB_MATRIX_ENABLE = IS31FL3731
152 endif
153
154 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
155     OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
156     COMMON_VPATH += $(DRIVER_PATH)/issi
157     SRC += is31fl3731.c
158     SRC += i2c_master.c
159 endif
160
161 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
162     OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
163     COMMON_VPATH += $(DRIVER_PATH)/issi
164     SRC += is31fl3733.c
165     SRC += i2c_master.c
166 endif
167
168 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3737)
169     OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
170     COMMON_VPATH += $(DRIVER_PATH)/issi
171     SRC += is31fl3737.c
172     SRC += i2c_master.c
173 endif
174
175 ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812)
176     OPT_DEFS += -DWS2812
177     SRC += ws2812.c
178 endif
179
180 ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
181     OPT_DEFS += -DTAP_DANCE_ENABLE
182     SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
183 endif
184
185 ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
186     OPT_DEFS += -DKEY_LOCK_ENABLE
187     SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
188 endif
189
190 ifeq ($(strip $(PRINTING_ENABLE)), yes)
191     OPT_DEFS += -DPRINTING_ENABLE
192     SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
193     SRC += $(TMK_DIR)/protocol/serial_uart.c
194 endif
195
196 ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
197     OPT_DEFS += -DAUTO_SHIFT_ENABLE
198     SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
199     ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
200         OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
201     endif
202 endif
203
204 ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
205     SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
206     OPT_DEFS += $(SERIAL_DEFS)
207     VAPTH += $(SERIAL_PATH)
208 endif
209
210 ifneq ($(strip $(VARIABLE_TRACE)),)
211     SRC += $(QUANTUM_DIR)/variable_trace.c
212     OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
213 ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
214     OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
215 endif
216 endif
217
218 ifeq ($(strip $(LCD_ENABLE)), yes)
219     CIE1931_CURVE = yes
220 endif
221
222 ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
223     ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
224         CIE1931_CURVE = yes
225     endif
226     ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
227         OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
228     endif
229 endif
230
231 ifeq ($(strip $(CIE1931_CURVE)), yes)
232     OPT_DEFS += -DUSE_CIE1931_CURVE
233     LED_TABLES = yes
234 endif
235
236 ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
237     OPT_DEFS += -DUSE_LED_BREATHING_TABLE
238     LED_TABLES = yes
239 endif
240
241 ifeq ($(strip $(LED_TABLES)), yes)
242     SRC += $(QUANTUM_DIR)/led_tables.c
243 endif
244
245 ifeq ($(strip $(TERMINAL_ENABLE)), yes)
246     SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
247     OPT_DEFS += -DTERMINAL_ENABLE
248     OPT_DEFS += -DUSER_PRINT
249 endif
250
251 ifeq ($(strip $(USB_HID_ENABLE)), yes)
252     include $(TMK_DIR)/protocol/usb_hid.mk
253 endif
254
255 ifeq ($(strip $(ENCODER_ENABLE)), yes)
256     SRC += $(QUANTUM_DIR)/encoder.c
257     OPT_DEFS += -DENCODER_ENABLE
258 endif
259
260 ifeq ($(strip $(HAPTIC_ENABLE)), DRV2605L)
261     COMMON_VPATH += $(DRIVER_PATH)/haptic
262     SRC += haptic.c
263     SRC += DRV2605L.c
264     SRC += i2c_master.c
265     OPT_DEFS += -DHAPTIC_ENABLE
266     OPT_DEFS += -DDRV2605L
267 endif
268
269 ifeq ($(strip $(HAPTIC_ENABLE)), SOLENOID)
270     COMMON_VPATH += $(DRIVER_PATH)/haptic
271     SRC += haptic.c
272     SRC += solenoid.c
273     OPT_DEFS += -DHAPTIC_ENABLE
274     OPT_DEFS += -DSOLENOID_ENABLE
275 endif
276
277 ifeq ($(strip $(HD44780_ENABLE)), yes)
278     SRC += drivers/avr/hd44780.c
279     OPT_DEFS += -DHD44780_ENABLE
280 endif
281
282 ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
283     OPT_DEFS += -DVELOCIKEY_ENABLE
284     SRC += $(QUANTUM_DIR)/velocikey.c
285 endif
286
287 ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
288     OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
289     SRC += $(QUANTUM_DIR)/dynamic_keymap.c
290 endif
291
292 ifeq ($(strip $(LEADER_ENABLE)), yes)
293   SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
294   OPT_DEFS += -DLEADER_ENABLE
295 endif
296
297 include $(DRIVER_PATH)/qwiic/qwiic.mk
298
299 QUANTUM_SRC:= \
300     $(QUANTUM_DIR)/quantum.c \
301     $(QUANTUM_DIR)/keymap_common.c \
302     $(QUANTUM_DIR)/keycode_config.c
303
304 # Include the standard or split matrix code if needed
305 ifneq ($(strip $(CUSTOM_MATRIX)), yes)
306     ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
307         QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c
308     else
309         QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
310     endif
311 endif
312
313 DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
314 # Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
315 DEBOUNCE_TYPE?= sym_g
316 ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
317     QUANTUM_SRC += $(DEBOUNCE_DIR)/$(strip $(DEBOUNCE_TYPE)).c
318 endif
319
320 ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
321     OPT_DEFS += -DSPLIT_KEYBOARD
322
323     # Include files used by all split keyboards
324     QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
325
326     # Determine which (if any) transport files are required
327     ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
328         QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c
329         # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
330         # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
331         QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/serial.c \
332                            i2c_master.c \
333                            i2c_slave.c
334     endif
335     COMMON_VPATH += $(QUANTUM_PATH)/split_common
336 endif