1 # Copyright 2017 Fred Sundvik
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.
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.
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/>.
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)
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
33 ifeq ($(strip $(AUDIO_ENABLE)), yes)
34 OPT_DEFS += -DAUDIO_ENABLE
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
41 SRC += $(QUANTUM_DIR)/audio/audio_arm.c
43 SRC += $(QUANTUM_DIR)/audio/voices.c
44 SRC += $(QUANTUM_DIR)/audio/luts.c
47 ifeq ($(strip $(MIDI_ENABLE)), yes)
48 OPT_DEFS += -DMIDI_ENABLE
50 SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
53 ifeq ($(MUSIC_ENABLE), 1)
54 SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
57 ifeq ($(strip $(COMBO_ENABLE)), yes)
58 OPT_DEFS += -DCOMBO_ENABLE
59 SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
62 ifeq ($(strip $(STENO_ENABLE)), yes)
63 OPT_DEFS += -DSTENO_ENABLE
65 SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
68 ifeq ($(strip $(VIRTSER_ENABLE)), yes)
69 OPT_DEFS += -DVIRTSER_ENABLE
72 ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
73 OPT_DEFS += -DFAUXCLICKY_ENABLE
74 SRC += $(QUANTUM_DIR)/fauxclicky.c
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
83 ifeq ($(strip $(UCIS_ENABLE)), yes)
84 OPT_DEFS += -DUCIS_ENABLE
86 SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
89 ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
90 OPT_DEFS += -DUNICODEMAP_ENABLE
92 SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
95 ifeq ($(strip $(UNICODE_ENABLE)), yes)
96 OPT_DEFS += -DUNICODE_ENABLE
98 SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
101 ifeq ($(strip $(UNICODE_COMMON)), yes)
102 SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
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
111 LED_BREATHING_TABLE = yes
112 ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
113 OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
119 VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 IS31FL3737 WS2812 custom
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)
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
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
139 RGB_MATRIX_ENABLE ?= no
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)
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
152 ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
153 RGB_MATRIX_ENABLE = IS31FL3731
156 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
157 OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
158 COMMON_VPATH += $(DRIVER_PATH)/issi
160 QUANTUM_LIB_SRC += i2c_master.c
163 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
164 OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
165 COMMON_VPATH += $(DRIVER_PATH)/issi
167 QUANTUM_LIB_SRC += i2c_master.c
170 ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3737)
171 OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
172 COMMON_VPATH += $(DRIVER_PATH)/issi
174 QUANTUM_LIB_SRC += i2c_master.c
177 ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812)
182 ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
183 OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB
186 ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes)
187 OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
190 ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
191 OPT_DEFS += -DTAP_DANCE_ENABLE
192 SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
195 ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
196 OPT_DEFS += -DKEY_LOCK_ENABLE
197 SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
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
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
214 ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
215 SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
216 OPT_DEFS += $(SERIAL_DEFS)
217 VAPTH += $(SERIAL_PATH)
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))
228 ifeq ($(strip $(LCD_ENABLE)), yes)
233 ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
234 BACKLIGHT_ENABLE = custom
237 VALID_BACKLIGHT_TYPES := yes custom
239 BACKLIGHT_ENABLE ?= no
240 ifneq ($(strip $(BACKLIGHT_ENABLE)), no)
241 ifeq ($(filter $(BACKLIGHT_ENABLE),$(VALID_BACKLIGHT_TYPES)),)
242 $(error BACKLIGHT_ENABLE="$(BACKLIGHT_ENABLE)" is not a valid backlight type)
245 ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
250 COMMON_VPATH += $(QUANTUM_DIR)/backlight
251 SRC += $(QUANTUM_DIR)/backlight/backlight.c
252 OPT_DEFS += -DBACKLIGHT_ENABLE
254 ifeq ($(strip $(BACKLIGHT_ENABLE)), custom)
255 OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
258 ifeq ($(PLATFORM),AVR)
259 SRC += $(QUANTUM_DIR)/backlight/backlight_avr.c
261 SRC += $(QUANTUM_DIR)/backlight/backlight_arm.c
265 ifeq ($(strip $(CIE1931_CURVE)), yes)
266 OPT_DEFS += -DUSE_CIE1931_CURVE
270 ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
271 OPT_DEFS += -DUSE_LED_BREATHING_TABLE
275 ifeq ($(strip $(LED_TABLES)), yes)
276 SRC += $(QUANTUM_DIR)/led_tables.c
279 ifeq ($(strip $(TERMINAL_ENABLE)), yes)
280 SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
281 OPT_DEFS += -DTERMINAL_ENABLE
282 OPT_DEFS += -DUSER_PRINT
285 ifeq ($(strip $(USB_HID_ENABLE)), yes)
286 include $(TMK_DIR)/protocol/usb_hid.mk
289 ifeq ($(strip $(ENCODER_ENABLE)), yes)
290 SRC += $(QUANTUM_DIR)/encoder.c
291 OPT_DEFS += -DENCODER_ENABLE
295 ifneq ($(strip $(HAPTIC_ENABLE)),no)
296 COMMON_VPATH += $(DRIVER_PATH)/haptic
298 OPT_DEFS += -DHAPTIC_ENABLE
301 ifneq ($(filter DRV2605L, $(HAPTIC_ENABLE)), )
303 QUANTUM_LIB_SRC += i2c_master.c
304 OPT_DEFS += -DDRV2605L
307 ifneq ($(filter SOLENOID, $(HAPTIC_ENABLE)), )
309 OPT_DEFS += -DSOLENOID_ENABLE
312 ifeq ($(strip $(HD44780_ENABLE)), yes)
313 SRC += drivers/avr/hd44780.c
314 OPT_DEFS += -DHD44780_ENABLE
317 ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
318 OPT_DEFS += -DVELOCIKEY_ENABLE
319 SRC += $(QUANTUM_DIR)/velocikey.c
322 ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
323 OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
324 SRC += $(QUANTUM_DIR)/dynamic_keymap.c
327 ifeq ($(strip $(LEADER_ENABLE)), yes)
328 SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
329 OPT_DEFS += -DLEADER_ENABLE
332 include $(DRIVER_PATH)/qwiic/qwiic.mk
335 $(QUANTUM_DIR)/quantum.c \
336 $(QUANTUM_DIR)/keymap_common.c \
337 $(QUANTUM_DIR)/keycode_config.c
339 # Include the standard or split matrix code if needed
340 ifneq ($(strip $(CUSTOM_MATRIX)), yes)
341 ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
342 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c
344 QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
348 DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
349 # Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
350 DEBOUNCE_TYPE?= sym_g
351 ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
352 QUANTUM_SRC += $(DEBOUNCE_DIR)/$(strip $(DEBOUNCE_TYPE)).c
355 ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
356 POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
357 OPT_DEFS += -DSPLIT_KEYBOARD
359 # Include files used by all split keyboards
360 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
362 # Determine which (if any) transport files are required
363 ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
364 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c
365 # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
366 # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
367 QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/serial.c \
371 COMMON_VPATH += $(QUANTUM_PATH)/split_common
374 ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
375 OPT_DEFS += -DOLED_DRIVER_ENABLE
376 COMMON_VPATH += $(DRIVER_PATH)/oled
377 QUANTUM_LIB_SRC += i2c_master.c
381 SPACE_CADET_ENABLE ?= yes
382 ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
383 SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
384 OPT_DEFS += -DSPACE_CADET_ENABLE
388 ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
389 SRC += $(QUANTUM_DIR)/dip_switch.c
390 OPT_DEFS += -DDIP_SWITCH_ENABLE