compiles, but long delay on startup and problems
[jackhill/qmk/firmware.git] / common_features.mk
CommitLineData
1c0fe956
FS
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
16SERIAL_DIR := $(QUANTUM_DIR)/serial_link
17SERIAL_PATH := $(QUANTUM_PATH)/serial_link
18SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
19SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
20SERIAL_DEFS += -DSERIAL_LINK_ENABLE
1aa0be4c 21COMMON_VPATH += $(SERIAL_PATH)
1c0fe956
FS
22
23ifeq ($(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
29endif
30
31MUSIC_ENABLE := 0
32
33ifeq ($(strip $(AUDIO_ENABLE)), yes)
34 OPT_DEFS += -DAUDIO_ENABLE
35 MUSIC_ENABLE := 1
36 SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
33fdd1d2 37 SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
5836d1a0 38 ifeq ($(PLATFORM),AVR)
39 SRC += $(QUANTUM_DIR)/audio/audio.c
40 else
41 SRC += $(QUANTUM_DIR)/audio/audio_arm.c
42 endif
1c0fe956
FS
43 SRC += $(QUANTUM_DIR)/audio/voices.c
44 SRC += $(QUANTUM_DIR)/audio/luts.c
45endif
46
47ifeq ($(strip $(MIDI_ENABLE)), yes)
48 OPT_DEFS += -DMIDI_ENABLE
49 MUSIC_ENABLE := 1
50 SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
51endif
52
53ifeq ($(MUSIC_ENABLE), 1)
54 SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
55endif
56
57ifeq ($(strip $(COMBO_ENABLE)), yes)
58 OPT_DEFS += -DCOMBO_ENABLE
59 SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
60endif
61
5987f679
JW
62ifeq ($(strip $(STENO_ENABLE)), yes)
63 OPT_DEFS += -DSTENO_ENABLE
fdd0f915 64 VIRTSER_ENABLE := yes
65 SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
5987f679
JW
66endif
67
1c0fe956
FS
68ifeq ($(strip $(VIRTSER_ENABLE)), yes)
69 OPT_DEFS += -DVIRTSER_ENABLE
70endif
71
72ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
73 OPT_DEFS += -DFAUXCLICKY_ENABLE
74 SRC += $(QUANTUM_DIR)/fauxclicky.c
75endif
76
ee132284 77ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
fdd0f915 78 OPT_DEFS += -DPOINTING_DEVICE_ENABLE
79 OPT_DEFS += -DMOUSE_ENABLE
80 SRC += $(QUANTUM_DIR)/pointing_device.c
ee132284
S
81endif
82
1c0fe956
FS
83ifeq ($(strip $(UCIS_ENABLE)), yes)
84 OPT_DEFS += -DUCIS_ENABLE
85 UNICODE_COMMON = yes
86 SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
87endif
88
89ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
90 OPT_DEFS += -DUNICODEMAP_ENABLE
91 UNICODE_COMMON = yes
92 SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
93endif
94
95ifeq ($(strip $(UNICODE_ENABLE)), yes)
96 OPT_DEFS += -DUNICODE_ENABLE
97 UNICODE_COMMON = yes
98 SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
99endif
100
101ifeq ($(strip $(UNICODE_COMMON)), yes)
102 SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
103endif
104
105ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
106 OPT_DEFS += -DRGBLIGHT_ENABLE
024f0455 107 SRC += $(QUANTUM_DIR)/rgblight.c
1c0fe956
FS
108 CIE1931_CURVE = yes
109 LED_BREATHING_TABLE = yes
d5486265
LR
110 ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
111 OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
112 else
fdd0f915 113 SRC += ws2812.c
d5486265 114 endif
1c0fe956
FS
115endif
116
e4eeb1eb 117VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 custom
fd698c43 118
119LED_MATRIX_ENABLE ?= no
120ifneq ($(strip $(LED_MATRIX_ENABLE)), no)
121ifeq ($(filter $(LED_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
122 $(error LED_MATRIX_ENABLE="$(LED_MATRIX_ENABLE)" is not a valid matrix type)
123endif
124 OPT_DEFS += -DLED_MATRIX_ENABLE
125 SRC += $(QUANTUM_DIR)/led_matrix.c
126 SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
127endif
128
129ifeq ($(strip $(LED_MATRIX_ENABLE)), IS31FL3731)
130 OPT_DEFS += -DIS31FL3731
131 COMMON_VPATH += $(DRIVER_PATH)/issi
132 SRC += is31fl3731-simple.c
133 SRC += i2c_master.c
134endif
135
136RGB_MATRIX_ENABLE ?= no
f70f45ee
JLW
137ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
138ifeq ($(filter $(RGB_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
139 $(error RGB_MATRIX_ENABLE="$(RGB_MATRIX_ENABLE)" is not a valid matrix type)
140endif
14b7602a 141 OPT_DEFS += -DRGB_MATRIX_ENABLE
14b7602a
JH
142 SRC += $(QUANTUM_DIR)/color.c
143 SRC += $(QUANTUM_DIR)/rgb_matrix.c
f70f45ee 144 SRC += $(QUANTUM_DIR)/rgb_matrix_drivers.c
14b7602a
JH
145 CIE1931_CURVE = yes
146endif
147
f70f45ee
JLW
148ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
149 RGB_MATRIX_ENABLE = IS31FL3731
150endif
151
fdd0f915 152ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
fdd0f915 153 OPT_DEFS += -DIS31FL3731
154 COMMON_VPATH += $(DRIVER_PATH)/issi
155 SRC += is31fl3731.c
156 SRC += i2c_master.c
fdd0f915 157endif
158
159ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
fdd0f915 160 OPT_DEFS += -DIS31FL3733
161 COMMON_VPATH += $(DRIVER_PATH)/issi
162 SRC += is31fl3733.c
163 SRC += i2c_master.c
fdd0f915 164endif
165
1c0fe956
FS
166ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
167 OPT_DEFS += -DTAP_DANCE_ENABLE
168 SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
169endif
170
8e1be7c7
FS
171ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
172 OPT_DEFS += -DKEY_LOCK_ENABLE
173 SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
174endif
175
1c0fe956
FS
176ifeq ($(strip $(PRINTING_ENABLE)), yes)
177 OPT_DEFS += -DPRINTING_ENABLE
178 SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
179 SRC += $(TMK_DIR)/protocol/serial_uart.c
180endif
181
abba393f
JC
182ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
183 OPT_DEFS += -DAUTO_SHIFT_ENABLE
184 SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
00b4dce6
JS
185 ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
186 OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
187 endif
abba393f
JC
188endif
189
1c0fe956
FS
190ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
191 SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
192 OPT_DEFS += $(SERIAL_DEFS)
193 VAPTH += $(SERIAL_PATH)
194endif
195
196ifneq ($(strip $(VARIABLE_TRACE)),)
197 SRC += $(QUANTUM_DIR)/variable_trace.c
198 OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
199ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
200 OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
201endif
202endif
203
204ifeq ($(strip $(LCD_ENABLE)), yes)
205 CIE1931_CURVE = yes
206endif
207
208ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
209 ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
210 CIE1931_CURVE = yes
365b8635 211 endif
fdd0f915 212 ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
365b8635 213 OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
1c0fe956
FS
214 endif
215endif
216
217ifeq ($(strip $(CIE1931_CURVE)), yes)
218 OPT_DEFS += -DUSE_CIE1931_CURVE
219 LED_TABLES = yes
220endif
221
222ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
223 OPT_DEFS += -DUSE_LED_BREATHING_TABLE
224 LED_TABLES = yes
225endif
226
227ifeq ($(strip $(LED_TABLES)), yes)
228 SRC += $(QUANTUM_DIR)/led_tables.c
229endif
230
7ad924ba
JH
231ifeq ($(strip $(TERMINAL_ENABLE)), yes)
232 SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
233 OPT_DEFS += -DTERMINAL_ENABLE
40313cfa 234 OPT_DEFS += -DUSER_PRINT
7ad924ba
JH
235endif
236
800ec55d
JH
237ifeq ($(strip $(USB_HID_ENABLE)), yes)
238 include $(TMK_DIR)/protocol/usb_hid.mk
239endif
240
85688e5b
JH
241ifeq ($(strip $(ENCODER_ENABLE)), yes)
242 SRC += $(QUANTUM_DIR)/encoder.c
243 OPT_DEFS += -DENCODER_ENABLE
244endif
245
4099536c 246ifeq ($(strip $(HAPTIC_ENABLE)), DRV2605L)
247 COMMON_VPATH += $(DRIVER_PATH)/haptic
248 SRC += DRV2605L.c
249 SRC += i2c_master.c
250 OPT_DEFS += -DDRV2605L
251endif
252
bbea9dad
MA
253ifeq ($(strip $(HD44780_ENABLE)), yes)
254 SRC += drivers/avr/hd44780.c
fdd0f915 255 OPT_DEFS += -DHD44780_ENABLE
bbea9dad
MA
256endif
257
48a992f1
W
258ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
259 OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
260 SRC += $(QUANTUM_DIR)/dynamic_keymap.c
261endif
262
74344947
JW
263ifeq ($(strip $(LEADER_ENABLE)), yes)
264 SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
265 OPT_DEFS += -DLEADER_ENABLE
266endif
267
4099536c 268include $(DRIVER_PATH)/qwiic/qwiic.mk
269
1c0fe956
FS
270QUANTUM_SRC:= \
271 $(QUANTUM_DIR)/quantum.c \
272 $(QUANTUM_DIR)/keymap_common.c \
74344947 273 $(QUANTUM_DIR)/keycode_config.c
1c0fe956 274
28929ad0
JC
275# Include the standard or split matrix code if needed
276ifneq ($(strip $(CUSTOM_MATRIX)), yes)
277 ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
278 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c
279 else
280 QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
929065b1 281 endif
28929ad0
JC
282endif
283
284# Include the standard debounce code if needed
285ifneq ($(strip $(CUSTOM_DEBOUNCE)), yes)
286 QUANTUM_SRC += $(QUANTUM_DIR)/debounce.c
287endif
288
289ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
0fab3bbd 290 OPT_DEFS += -DSPLIT_KEYBOARD
28929ad0
JC
291
292 # Include files used by all split keyboards
0fab3bbd 293 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_flags.c \
28929ad0
JC
294 $(QUANTUM_DIR)/split_common/split_util.c
295
296 # Determine which (if any) transport files are required
297 ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
298 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c
299 # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
300 # Unused functions are pruned away, which is why we can add both drivers here without bloat.
301 QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/i2c.c \
302 $(QUANTUM_DIR)/split_common/serial.c
303 endif
7f0def77 304 COMMON_VPATH += $(QUANTUM_PATH)/split_common
8e1be7c7 305endif