]> git.donarmstrong.com Git - qmk_firmware.git/blob - common_features.mk
Change split_common to use RGBLIGHT_SPLIT (#5509)
[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)/rgblight.c
109     CIE1931_CURVE = yes
110     LED_BREATHING_TABLE = yes
111     ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
112         OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
113     else
114         SRC += ws2812.c
115     endif
116 endif
117
118 VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 IS31FL3737 WS2812 custom
119
120 LED_MATRIX_ENABLE ?= no
121 ifneq ($(strip $(LED_MATRIX_ENABLE)), no)
122     ifeq ($(filter $(LED_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
123         $(error LED_MATRIX_ENABLE="$(LED_MATRIX_ENABLE)" is not a valid matrix type)
124     else
125         OPT_DEFS += -DLED_MATRIX_ENABLE -DBACKLIGHT_ENABLE -DBACKLIGHT_CUSTOM_DRIVER
126         SRC += $(QUANTUM_DIR)/led_matrix.c
127         SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
128     endif
129 endif
130
131 ifeq ($(strip $(LED_MATRIX_ENABLE)), IS31FL3731)
132     OPT_DEFS += -DIS31FL3731
133     COMMON_VPATH += $(DRIVER_PATH)/issi
134     SRC += is31fl3731-simple.c
135     SRC += i2c_master.c
136 endif
137
138 RGB_MATRIX_ENABLE ?= no
139
140 ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
141 ifeq ($(filter $(RGB_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
142     $(error RGB_MATRIX_ENABLE="$(RGB_MATRIX_ENABLE)" is not a valid matrix type)
143 endif
144     OPT_DEFS += -DRGB_MATRIX_ENABLE
145     SRC += $(QUANTUM_DIR)/color.c
146     SRC += $(QUANTUM_DIR)/rgb_matrix.c
147     SRC += $(QUANTUM_DIR)/rgb_matrix_drivers.c
148     CIE1931_CURVE = yes
149 endif
150
151 ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
152         RGB_MATRIX_ENABLE = IS31FL3731
153 endif
154
155 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
156     OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
157     COMMON_VPATH += $(DRIVER_PATH)/issi
158     SRC += is31fl3731.c
159     SRC += i2c_master.c
160 endif
161
162 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
163     OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
164     COMMON_VPATH += $(DRIVER_PATH)/issi
165     SRC += is31fl3733.c
166     SRC += i2c_master.c
167 endif
168
169 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3737)
170     OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
171     COMMON_VPATH += $(DRIVER_PATH)/issi
172     SRC += is31fl3737.c
173     SRC += i2c_master.c
174 endif
175
176 ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812)
177     OPT_DEFS += -DWS2812
178     SRC += ws2812.c
179 endif
180
181 ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
182     OPT_DEFS += -DTAP_DANCE_ENABLE
183     SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
184 endif
185
186 ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
187     OPT_DEFS += -DKEY_LOCK_ENABLE
188     SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
189 endif
190
191 ifeq ($(strip $(PRINTING_ENABLE)), yes)
192     OPT_DEFS += -DPRINTING_ENABLE
193     SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
194     SRC += $(TMK_DIR)/protocol/serial_uart.c
195 endif
196
197 ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
198     OPT_DEFS += -DAUTO_SHIFT_ENABLE
199     SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
200     ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
201         OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
202     endif
203 endif
204
205 ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
206     SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
207     OPT_DEFS += $(SERIAL_DEFS)
208     VAPTH += $(SERIAL_PATH)
209 endif
210
211 ifneq ($(strip $(VARIABLE_TRACE)),)
212     SRC += $(QUANTUM_DIR)/variable_trace.c
213     OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
214 ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
215     OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
216 endif
217 endif
218
219 ifeq ($(strip $(LCD_ENABLE)), yes)
220     CIE1931_CURVE = yes
221 endif
222
223 ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
224     ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
225         CIE1931_CURVE = yes
226     endif
227     ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
228         OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
229     endif
230 endif
231
232 ifeq ($(strip $(CIE1931_CURVE)), yes)
233     OPT_DEFS += -DUSE_CIE1931_CURVE
234     LED_TABLES = yes
235 endif
236
237 ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
238     OPT_DEFS += -DUSE_LED_BREATHING_TABLE
239     LED_TABLES = yes
240 endif
241
242 ifeq ($(strip $(LED_TABLES)), yes)
243     SRC += $(QUANTUM_DIR)/led_tables.c
244 endif
245
246 ifeq ($(strip $(TERMINAL_ENABLE)), yes)
247     SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
248     OPT_DEFS += -DTERMINAL_ENABLE
249     OPT_DEFS += -DUSER_PRINT
250 endif
251
252 ifeq ($(strip $(USB_HID_ENABLE)), yes)
253     include $(TMK_DIR)/protocol/usb_hid.mk
254 endif
255
256 ifeq ($(strip $(ENCODER_ENABLE)), yes)
257     SRC += $(QUANTUM_DIR)/encoder.c
258     OPT_DEFS += -DENCODER_ENABLE
259 endif
260
261 ifeq ($(strip $(HAPTIC_ENABLE)), DRV2605L)
262     COMMON_VPATH += $(DRIVER_PATH)/haptic
263     SRC += haptic.c
264     SRC += DRV2605L.c
265     SRC += i2c_master.c
266     OPT_DEFS += -DHAPTIC_ENABLE
267     OPT_DEFS += -DDRV2605L
268 endif
269
270 ifeq ($(strip $(HAPTIC_ENABLE)), SOLENOID)
271     COMMON_VPATH += $(DRIVER_PATH)/haptic
272     SRC += haptic.c
273     SRC += solenoid.c
274     OPT_DEFS += -DHAPTIC_ENABLE
275     OPT_DEFS += -DSOLENOID_ENABLE
276 endif
277
278 ifeq ($(strip $(HD44780_ENABLE)), yes)
279     SRC += drivers/avr/hd44780.c
280     OPT_DEFS += -DHD44780_ENABLE
281 endif
282
283 ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
284     OPT_DEFS += -DVELOCIKEY_ENABLE
285     SRC += $(QUANTUM_DIR)/velocikey.c
286 endif
287
288 ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
289     OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
290     SRC += $(QUANTUM_DIR)/dynamic_keymap.c
291 endif
292
293 ifeq ($(strip $(LEADER_ENABLE)), yes)
294   SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
295   OPT_DEFS += -DLEADER_ENABLE
296 endif
297
298 include $(DRIVER_PATH)/qwiic/qwiic.mk
299
300 QUANTUM_SRC:= \
301     $(QUANTUM_DIR)/quantum.c \
302     $(QUANTUM_DIR)/keymap_common.c \
303     $(QUANTUM_DIR)/keycode_config.c
304
305 # Include the standard or split matrix code if needed
306 ifneq ($(strip $(CUSTOM_MATRIX)), yes)
307     ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
308         QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c
309     else
310         QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
311     endif
312 endif
313
314 DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
315 # Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
316 DEBOUNCE_TYPE?= sym_g
317 ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
318     QUANTUM_SRC += $(DEBOUNCE_DIR)/$(strip $(DEBOUNCE_TYPE)).c
319 endif
320
321 ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
322     POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
323     OPT_DEFS += -DSPLIT_KEYBOARD
324
325     # Include files used by all split keyboards
326     QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
327
328     # Determine which (if any) transport files are required
329     ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
330         QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c
331         # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
332         # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
333         QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/serial.c \
334                            i2c_master.c \
335                            i2c_slave.c
336     endif
337     COMMON_VPATH += $(QUANTUM_PATH)/split_common
338 endif