]> git.donarmstrong.com Git - qmk_firmware.git/blob - common_features.mk
Move kwerdenker's personal keymap from RGB (#7645)
[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     POST_CONFIG_H += $(QUANTUM_DIR)/rgblight_post_config.h
107     OPT_DEFS += -DRGBLIGHT_ENABLE
108     SRC += $(QUANTUM_DIR)/color.c
109     SRC += $(QUANTUM_DIR)/rgblight.c
110     CIE1931_CURVE = yes
111     LED_BREATHING_TABLE = yes
112     ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
113         OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
114     else
115         WS2812_DRIVER_REQUIRED = yes
116     endif
117 endif
118
119 VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 IS31FL3737 WS2812 custom
120
121 LED_MATRIX_ENABLE ?= no
122 ifneq ($(strip $(LED_MATRIX_ENABLE)), no)
123     ifeq ($(filter $(LED_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
124         $(error LED_MATRIX_ENABLE="$(LED_MATRIX_ENABLE)" is not a valid matrix type)
125     else
126         OPT_DEFS += -DLED_MATRIX_ENABLE -DBACKLIGHT_ENABLE -DBACKLIGHT_CUSTOM_DRIVER
127         SRC += $(QUANTUM_DIR)/led_matrix.c
128         SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
129     endif
130 endif
131
132 ifeq ($(strip $(LED_MATRIX_ENABLE)), IS31FL3731)
133     OPT_DEFS += -DIS31FL3731
134     COMMON_VPATH += $(DRIVER_PATH)/issi
135     SRC += is31fl3731-simple.c
136     QUANTUM_LIB_SRC += i2c_master.c
137 endif
138
139 RGB_MATRIX_ENABLE ?= no
140
141 ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
142 ifeq ($(filter $(RGB_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
143     $(error RGB_MATRIX_ENABLE="$(RGB_MATRIX_ENABLE)" is not a valid matrix type)
144 endif
145     OPT_DEFS += -DRGB_MATRIX_ENABLE
146     SRC += $(QUANTUM_DIR)/color.c
147     SRC += $(QUANTUM_DIR)/rgb_matrix.c
148     SRC += $(QUANTUM_DIR)/rgb_matrix_drivers.c
149     CIE1931_CURVE = yes
150 endif
151
152 ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
153         RGB_MATRIX_ENABLE = IS31FL3731
154 endif
155
156 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
157     OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
158     COMMON_VPATH += $(DRIVER_PATH)/issi
159     SRC += is31fl3731.c
160     QUANTUM_LIB_SRC += i2c_master.c
161 endif
162
163 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
164     OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
165     COMMON_VPATH += $(DRIVER_PATH)/issi
166     SRC += is31fl3733.c
167     QUANTUM_LIB_SRC += i2c_master.c
168 endif
169
170 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3737)
171     OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
172     COMMON_VPATH += $(DRIVER_PATH)/issi
173     SRC += is31fl3737.c
174     QUANTUM_LIB_SRC += i2c_master.c
175 endif
176
177 ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812)
178     OPT_DEFS += -DWS2812
179     WS2812_DRIVER_REQUIRED = yes
180 endif
181
182 ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
183     OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB
184 endif
185
186 ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes)
187     OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
188 endif
189
190 ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
191     OPT_DEFS += -DTAP_DANCE_ENABLE
192     SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
193 endif
194
195 ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
196     OPT_DEFS += -DKEY_LOCK_ENABLE
197     SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
198 endif
199
200 ifeq ($(strip $(PRINTING_ENABLE)), yes)
201     OPT_DEFS += -DPRINTING_ENABLE
202     SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
203     SRC += $(TMK_DIR)/protocol/serial_uart.c
204 endif
205
206 ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
207     OPT_DEFS += -DAUTO_SHIFT_ENABLE
208     SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
209     ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
210         OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
211     endif
212 endif
213
214 ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
215     SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
216     OPT_DEFS += $(SERIAL_DEFS)
217     VAPTH += $(SERIAL_PATH)
218 endif
219
220 ifneq ($(strip $(VARIABLE_TRACE)),)
221     SRC += $(QUANTUM_DIR)/variable_trace.c
222     OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
223 ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
224     OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
225 endif
226 endif
227
228 ifeq ($(strip $(LCD_ENABLE)), yes)
229     CIE1931_CURVE = yes
230 endif
231
232 # backward compat
233 ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
234     BACKLIGHT_DRIVER = custom
235 endif
236
237 VALID_BACKLIGHT_TYPES := pwm software custom
238
239 BACKLIGHT_ENABLE ?= no
240 BACKLIGHT_DRIVER ?= pwm
241 ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
242     ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
243         $(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
244     endif
245
246     ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
247         CIE1931_CURVE = yes
248     endif
249
250     COMMON_VPATH += $(QUANTUM_DIR)/backlight
251     SRC += $(QUANTUM_DIR)/backlight/backlight.c
252     OPT_DEFS += -DBACKLIGHT_ENABLE
253
254     ifeq ($(strip $(BACKLIGHT_DRIVER)), software)
255         SRC += $(QUANTUM_DIR)/backlight/backlight_soft.c
256     else
257         ifeq ($(strip $(BACKLIGHT_DRIVER)), custom)
258             OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
259         endif
260
261         ifeq ($(PLATFORM),AVR)
262             SRC += $(QUANTUM_DIR)/backlight/backlight_avr.c
263         else
264             SRC += $(QUANTUM_DIR)/backlight/backlight_arm.c
265         endif
266     endif
267 endif
268
269 VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c
270
271 WS2812_DRIVER ?= bitbang
272 ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
273     ifeq ($(filter $(WS2812_DRIVER),$(VALID_WS2812_DRIVER_TYPES)),)
274         $(error WS2812_DRIVER="$(WS2812_DRIVER)" is not a valid WS2812 driver)
275     endif
276
277     ifeq ($(strip $(WS2812_DRIVER)), bitbang)
278         SRC += ws2812.c
279     else
280         SRC += ws2812_$(strip $(WS2812_DRIVER)).c
281     endif
282
283     # add extra deps
284     ifeq ($(strip $(WS2812_DRIVER)), i2c)
285         QUANTUM_LIB_SRC += i2c_master.c
286     endif
287 endif
288
289 ifeq ($(strip $(CIE1931_CURVE)), yes)
290     OPT_DEFS += -DUSE_CIE1931_CURVE
291     LED_TABLES = yes
292 endif
293
294 ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
295     OPT_DEFS += -DUSE_LED_BREATHING_TABLE
296     LED_TABLES = yes
297 endif
298
299 ifeq ($(strip $(LED_TABLES)), yes)
300     SRC += $(QUANTUM_DIR)/led_tables.c
301 endif
302
303 ifeq ($(strip $(TERMINAL_ENABLE)), yes)
304     SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
305     OPT_DEFS += -DTERMINAL_ENABLE
306     OPT_DEFS += -DUSER_PRINT
307 endif
308
309 ifeq ($(strip $(USB_HID_ENABLE)), yes)
310     include $(TMK_DIR)/protocol/usb_hid.mk
311 endif
312
313 ifeq ($(strip $(ENCODER_ENABLE)), yes)
314     SRC += $(QUANTUM_DIR)/encoder.c
315     OPT_DEFS += -DENCODER_ENABLE
316 endif
317
318 HAPTIC_ENABLE ?= no
319 ifneq ($(strip $(HAPTIC_ENABLE)),no)
320         COMMON_VPATH += $(DRIVER_PATH)/haptic
321         SRC += haptic.c
322         OPT_DEFS += -DHAPTIC_ENABLE
323 endif
324
325 ifneq ($(filter DRV2605L, $(HAPTIC_ENABLE)), )
326     SRC += DRV2605L.c
327     QUANTUM_LIB_SRC += i2c_master.c
328     OPT_DEFS += -DDRV2605L
329 endif
330
331 ifneq ($(filter SOLENOID, $(HAPTIC_ENABLE)), )
332     SRC += solenoid.c
333     OPT_DEFS += -DSOLENOID_ENABLE
334 endif
335
336 ifeq ($(strip $(HD44780_ENABLE)), yes)
337     SRC += drivers/avr/hd44780.c
338     OPT_DEFS += -DHD44780_ENABLE
339 endif
340
341 ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
342     OPT_DEFS += -DVELOCIKEY_ENABLE
343     SRC += $(QUANTUM_DIR)/velocikey.c
344 endif
345
346 ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
347     OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
348     SRC += $(QUANTUM_DIR)/dynamic_keymap.c
349 endif
350
351 ifeq ($(strip $(LEADER_ENABLE)), yes)
352   SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
353   OPT_DEFS += -DLEADER_ENABLE
354 endif
355
356 include $(DRIVER_PATH)/qwiic/qwiic.mk
357
358 QUANTUM_SRC:= \
359     $(QUANTUM_DIR)/quantum.c \
360     $(QUANTUM_DIR)/keymap_common.c \
361     $(QUANTUM_DIR)/keycode_config.c
362
363 # Include the standard or split matrix code if needed
364 ifneq ($(strip $(CUSTOM_MATRIX)), yes)
365     ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
366         QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c
367     else
368         QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
369     endif
370 endif
371
372 DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
373 # Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
374 DEBOUNCE_TYPE?= sym_g
375 ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
376     QUANTUM_SRC += $(DEBOUNCE_DIR)/$(strip $(DEBOUNCE_TYPE)).c
377 endif
378
379 ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
380     POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
381     OPT_DEFS += -DSPLIT_KEYBOARD
382
383     # Include files used by all split keyboards
384     QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
385
386     # Determine which (if any) transport files are required
387     ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
388         QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c
389         # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
390         # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
391         QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/serial.c \
392                            i2c_master.c \
393                            i2c_slave.c
394     endif
395     COMMON_VPATH += $(QUANTUM_PATH)/split_common
396 endif
397
398 ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
399     OPT_DEFS += -DOLED_DRIVER_ENABLE
400     COMMON_VPATH += $(DRIVER_PATH)/oled
401     QUANTUM_LIB_SRC += i2c_master.c
402     SRC += oled_driver.c
403 endif
404
405 SPACE_CADET_ENABLE ?= yes
406 ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
407   SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
408   OPT_DEFS += -DSPACE_CADET_ENABLE
409 endif
410
411 MAGIC_ENABLE ?= yes
412 ifeq ($(strip $(MAGIC_ENABLE)), yes)
413     SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c
414     OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
415 endif
416
417 ifeq ($(strip $(DYNAMIC_MACRO_ENABLE)), yes)
418     SRC += $(QUANTUM_DIR)/process_keycode/process_dynamic_macro.c
419     OPT_DEFS += -DDYNAMIC_MACRO_ENABLE
420 endif
421
422 ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
423   SRC += $(QUANTUM_DIR)/dip_switch.c
424   OPT_DEFS += -DDIP_SWITCH_ENABLE
425 endif