summaryrefslogtreecommitdiffstats
path: root/builddefs
diff options
context:
space:
mode:
Diffstat (limited to 'builddefs')
-rw-r--r--builddefs/bootloader.mk49
-rw-r--r--builddefs/build_full_test.mk36
-rw-r--r--builddefs/build_json.mk17
-rw-r--r--builddefs/build_keyboard.mk469
-rw-r--r--builddefs/build_layout.mk32
-rw-r--r--builddefs/build_test.mk84
-rw-r--r--builddefs/common_features.mk816
-rw-r--r--builddefs/common_rules.mk523
-rw-r--r--builddefs/mcu_selection.mk77
-rw-r--r--builddefs/message.mk10
-rw-r--r--builddefs/testlist.mk19
11 files changed, 2128 insertions, 4 deletions
diff --git a/builddefs/bootloader.mk b/builddefs/bootloader.mk
index ccb92392d9..226213297e 100644
--- a/builddefs/bootloader.mk
+++ b/builddefs/bootloader.mk
@@ -30,6 +30,7 @@
# bootloadhid HIDBootFlash compatible (ATmega32A)
# usbasploader USBaspLoader (ATmega328P)
# ARM:
+# halfkay PJRC Teensy
# kiibohd Input:Club Kiibohd bootloader (only used on their boards)
# stm32duino STM32Duino (STM32F103x8)
# stm32-dfu STM32 USB DFU in ROM
@@ -37,12 +38,23 @@
# RISC-V:
# gd32v-dfu GD32V USB DFU in ROM
#
+# If you need to provide your own implementation, you can set inside `rules.mk`
+# `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
+# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
+# which functions may be overridden.
+#
# BOOTLOADER_SIZE can still be defined manually, but it's recommended
# you add any possible configuration to this list
+ifeq ($(strip $(BOOTLOADER)), custom)
+ OPT_DEFS += -DBOOTLOADER_CUSTOM
+ BOOTLOADER_TYPE = custom
+endif
ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
OPT_DEFS += -DBOOTLOADER_DFU
+ BOOTLOADER_TYPE = dfu
+
ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
BOOTLOADER_SIZE = 4096
endif
@@ -53,6 +65,8 @@ endif
ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
OPT_DEFS += -DBOOTLOADER_LUFA_DFU
OPT_DEFS += -DBOOTLOADER_DFU
+ BOOTLOADER_TYPE = dfu
+
ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
BOOTLOADER_SIZE ?= 4096
endif
@@ -63,6 +77,8 @@ endif
ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
OPT_DEFS += -DBOOTLOADER_QMK_DFU
OPT_DEFS += -DBOOTLOADER_DFU
+ BOOTLOADER_TYPE = dfu
+
ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
BOOTLOADER_SIZE ?= 4096
endif
@@ -73,10 +89,14 @@ endif
ifeq ($(strip $(BOOTLOADER)), qmk-hid)
OPT_DEFS += -DBOOTLOADER_QMK_HID
OPT_DEFS += -DBOOTLOADER_HID
+ BOOTLOADER_TYPE = dfu
+
BOOTLOADER_SIZE ?= 4096
endif
ifeq ($(strip $(BOOTLOADER)), halfkay)
OPT_DEFS += -DBOOTLOADER_HALFKAY
+ BOOTLOADER_TYPE = halfkay
+
ifeq ($(strip $(MCU)), atmega32u4)
BOOTLOADER_SIZE = 512
endif
@@ -86,18 +106,26 @@ ifeq ($(strip $(BOOTLOADER)), halfkay)
endif
ifeq ($(strip $(BOOTLOADER)), caterina)
OPT_DEFS += -DBOOTLOADER_CATERINA
+ BOOTLOADER_TYPE = caterina
+
BOOTLOADER_SIZE = 4096
endif
ifneq (,$(filter $(BOOTLOADER), bootloadhid bootloadHID))
OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
+ BOOTLOADER_TYPE = bootloadhid
+
BOOTLOADER_SIZE = 4096
endif
ifneq (,$(filter $(BOOTLOADER), usbasploader USBasp))
OPT_DEFS += -DBOOTLOADER_USBASP
+ BOOTLOADER_TYPE = usbasploader
+
BOOTLOADER_SIZE = 4096
endif
ifeq ($(strip $(BOOTLOADER)), lufa-ms)
OPT_DEFS += -DBOOTLOADER_MS
+ BOOTLOADER_TYPE = dfu
+
BOOTLOADER_SIZE ?= 8192
FIRMWARE_FORMAT = bin
cpfirmware: lufa_warning
@@ -115,6 +143,7 @@ endif
ifeq ($(strip $(BOOTLOADER)), stm32-dfu)
OPT_DEFS += -DBOOTLOADER_STM32_DFU
+ BOOTLOADER_TYPE = stm32_dfu
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
@@ -122,6 +151,7 @@ ifeq ($(strip $(BOOTLOADER)), stm32-dfu)
endif
ifeq ($(strip $(BOOTLOADER)), apm32-dfu)
OPT_DEFS += -DBOOTLOADER_APM32_DFU
+ BOOTLOADER_TYPE = stm32_dfu
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave
@@ -129,6 +159,7 @@ ifeq ($(strip $(BOOTLOADER)), apm32-dfu)
endif
ifeq ($(strip $(BOOTLOADER)), gd32v-dfu)
OPT_DEFS += -DBOOTLOADER_GD32V_DFU
+ BOOTLOADER_TYPE = gd32v_dfu
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 28E9:0189 -a 0 -s 0x08000000:leave
@@ -136,6 +167,8 @@ ifeq ($(strip $(BOOTLOADER)), gd32v-dfu)
endif
ifeq ($(strip $(BOOTLOADER)), kiibohd)
OPT_DEFS += -DBOOTLOADER_KIIBOHD
+ BOOTLOADER_TYPE = kiibohd
+
ifeq ($(strip $(MCU_ORIG)), MK20DX128)
MCU_LDSCRIPT = MK20DX128BLDR4
endif
@@ -151,8 +184,7 @@ ifeq ($(strip $(BOOTLOADER)), stm32duino)
OPT_DEFS += -DBOOTLOADER_STM32DUINO
MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader
BOARD = STM32_F103_STM32DUINO
- # STM32F103 does NOT have an USB bootloader in ROM (only serial), so setting anything here does not make much sense
- STM32_BOOTLOADER_ADDRESS = 0x80000000
+ BOOTLOADER_TYPE = stm32duino
# Options to pass to dfu-util when flashing
DFU_ARGS = -d 1EAF:0003 -a 2 -R
@@ -160,4 +192,17 @@ ifeq ($(strip $(BOOTLOADER)), stm32duino)
endif
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
OPT_DEFS += -DBOOTLOADER_TINYUF2
+ BOOTLOADER_TYPE = tinyuf2
+endif
+ifeq ($(strip $(BOOTLOADER)), halfkay)
+ OPT_DEFS += -DBOOTLOADER_HALFKAY
+ BOOTLOADER_TYPE = halfkay
+endif
+ifeq ($(strip $(BOOTLOADER)), md-boot)
+ OPT_DEFS += -DBOOTLOADER_MD_BOOT
+ BOOTLOADER_TYPE = md_boot
+endif
+
+ifeq ($(strip $(BOOTLOADER_TYPE)),)
+ $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate 'BOOTLOADER' in your keyboard's 'rules.mk' file.)
endif
diff --git a/builddefs/build_full_test.mk b/builddefs/build_full_test.mk
new file mode 100644
index 0000000000..4e4b4e4bfd
--- /dev/null
+++ b/builddefs/build_full_test.mk
@@ -0,0 +1,36 @@
+# Copyright 2017 Fred Sundvik
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+$(TEST)_INC := \
+ tests/test_common/common_config.h
+
+$(TEST)_SRC := \
+ $(TMK_COMMON_SRC) \
+ $(QUANTUM_SRC) \
+ $(SRC) \
+ tests/test_common/keymap.c \
+ tests/test_common/matrix.c \
+ tests/test_common/test_driver.cpp \
+ tests/test_common/keyboard_report_util.cpp \
+ tests/test_common/test_fixture.cpp \
+ tests/test_common/test_keymap_key.cpp \
+ tests/test_common/test_logger.cpp \
+ $(patsubst $(ROOTDIR)/%,%,$(wildcard $(TEST_PATH)/*.cpp))
+
+$(TEST)_DEFS := $(TMK_COMMON_DEFS) $(OPT_DEFS)
+
+$(TEST)_CONFIG := $(TEST_PATH)/config.h
+
+VPATH += $(TOP_DIR)/tests/test_common
diff --git a/builddefs/build_json.mk b/builddefs/build_json.mk
new file mode 100644
index 0000000000..0c034eb2ae
--- /dev/null
+++ b/builddefs/build_json.mk
@@ -0,0 +1,17 @@
+# Look for a json keymap file
+ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.json)","")
+ KEYMAP_JSON := $(MAIN_KEYMAP_PATH_5)/keymap.json
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
+else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.json)","")
+ KEYMAP_JSON := $(MAIN_KEYMAP_PATH_4)/keymap.json
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
+else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.json)","")
+ KEYMAP_JSON := $(MAIN_KEYMAP_PATH_3)/keymap.json
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
+else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.json)","")
+ KEYMAP_JSON := $(MAIN_KEYMAP_PATH_2)/keymap.json
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
+else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.json)","")
+ KEYMAP_JSON := $(MAIN_KEYMAP_PATH_1)/keymap.json
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
+endif
diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk
new file mode 100644
index 0000000000..d5efcb4193
--- /dev/null
+++ b/builddefs/build_keyboard.mk
@@ -0,0 +1,469 @@
+# Determine what keyboard we are building and setup the build environment.
+#
+# We support folders up to 5 levels deep below `keyboards/`. This file is
+# responsible for determining which folder is being used and doing the
+# corresponding environment setup.
+
+ifndef VERBOSE
+.SILENT:
+endif
+
+.DEFAULT_GOAL := all
+
+include paths.mk
+include $(BUILDDEFS_PATH)/message.mk
+
+# Set the qmk cli to use
+QMK_BIN ?= qmk
+
+# Set the filename for the final firmware binary
+KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
+TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP)
+KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE)
+
+# Force expansion
+TARGET := $(TARGET)
+
+ifneq ($(FORCE_LAYOUT),)
+ TARGET := $(TARGET)_$(FORCE_LAYOUT)
+endif
+
+# Object files and generated keymap directory
+# To put object files in current directory, use a dot (.), do NOT make
+# this an empty or blank macro!
+KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
+
+ifdef SKIP_VERSION
+ OPT_DEFS += -DSKIP_VERSION
+endif
+
+# Generate the version.h file
+ifdef SKIP_VERSION
+VERSION_H_FLAGS := --skip-all
+endif
+ifdef SKIP_GIT
+VERSION_H_FLAGS := --skip-git
+endif
+
+# Generate the board's version.h file.
+$(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o $(KEYMAP_OUTPUT)/src/version.h)
+
+# Determine which subfolders exist.
+KEYBOARD_FOLDER_PATH_1 := $(KEYBOARD)
+KEYBOARD_FOLDER_PATH_2 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_1)))
+KEYBOARD_FOLDER_PATH_3 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_2)))
+KEYBOARD_FOLDER_PATH_4 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_3)))
+KEYBOARD_FOLDER_PATH_5 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_4)))
+KEYBOARD_FOLDER_1 := $(notdir $(KEYBOARD_FOLDER_PATH_1))
+KEYBOARD_FOLDER_2 := $(notdir $(KEYBOARD_FOLDER_PATH_2))
+KEYBOARD_FOLDER_3 := $(notdir $(KEYBOARD_FOLDER_PATH_3))
+KEYBOARD_FOLDER_4 := $(notdir $(KEYBOARD_FOLDER_PATH_4))
+KEYBOARD_FOLDER_5 := $(notdir $(KEYBOARD_FOLDER_PATH_5))
+KEYBOARD_PATHS :=
+KEYBOARD_PATH_1 := keyboards/$(KEYBOARD_FOLDER_PATH_1)
+KEYBOARD_PATH_2 := keyboards/$(KEYBOARD_FOLDER_PATH_2)
+KEYBOARD_PATH_3 := keyboards/$(KEYBOARD_FOLDER_PATH_3)
+KEYBOARD_PATH_4 := keyboards/$(KEYBOARD_FOLDER_PATH_4)
+KEYBOARD_PATH_5 := keyboards/$(KEYBOARD_FOLDER_PATH_5)
+
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/)","")
+ KEYBOARD_PATHS += $(KEYBOARD_PATH_5)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/)","")
+ KEYBOARD_PATHS += $(KEYBOARD_PATH_4)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/)","")
+ KEYBOARD_PATHS += $(KEYBOARD_PATH_3)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/)","")
+ KEYBOARD_PATHS += $(KEYBOARD_PATH_2)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/)","")
+ KEYBOARD_PATHS += $(KEYBOARD_PATH_1)
+endif
+
+
+# Pull in rules.mk files from all our subfolders
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/rules.mk)","")
+ include $(KEYBOARD_PATH_5)/rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/rules.mk)","")
+ include $(KEYBOARD_PATH_4)/rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/rules.mk)","")
+ include $(KEYBOARD_PATH_3)/rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/rules.mk)","")
+ include $(KEYBOARD_PATH_2)/rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/rules.mk)","")
+ include $(KEYBOARD_PATH_1)/rules.mk
+endif
+
+MAIN_KEYMAP_PATH_1 := $(KEYBOARD_PATH_1)/keymaps/$(KEYMAP)
+MAIN_KEYMAP_PATH_2 := $(KEYBOARD_PATH_2)/keymaps/$(KEYMAP)
+MAIN_KEYMAP_PATH_3 := $(KEYBOARD_PATH_3)/keymaps/$(KEYMAP)
+MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
+MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
+
+# Pull in rules from info.json
+INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_rules.mk)
+include $(INFO_RULES_MK)
+
+# Check for keymap.json first, so we can regenerate keymap.c
+include $(BUILDDEFS_PATH)/build_json.mk
+
+# Pull in keymap level rules.mk
+ifeq ("$(wildcard $(KEYMAP_PATH))", "")
+ # Look through the possible keymap folders until we find a matching keymap.c
+ ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
+ -include $(MAIN_KEYMAP_PATH_5)/rules.mk
+ KEYMAP_C := $(MAIN_KEYMAP_PATH_5)/keymap.c
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
+ else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.c)","")
+ -include $(MAIN_KEYMAP_PATH_4)/rules.mk
+ KEYMAP_C := $(MAIN_KEYMAP_PATH_4)/keymap.c
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
+ else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.c)","")
+ -include $(MAIN_KEYMAP_PATH_3)/rules.mk
+ KEYMAP_C := $(MAIN_KEYMAP_PATH_3)/keymap.c
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
+ else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.c)","")
+ -include $(MAIN_KEYMAP_PATH_2)/rules.mk
+ KEYMAP_C := $(MAIN_KEYMAP_PATH_2)/keymap.c
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
+ else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
+ -include $(MAIN_KEYMAP_PATH_1)/rules.mk
+ KEYMAP_C := $(MAIN_KEYMAP_PATH_1)/keymap.c
+ KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
+ else ifneq ($(LAYOUTS),)
+ # If we haven't found a keymap yet fall back to community layouts
+ include $(BUILDDEFS_PATH)/build_layout.mk
+ else
+ $(call CATASTROPHIC_ERROR,Invalid keymap,Could not find keymap)
+ # this state should never be reached
+ endif
+endif
+
+# Have we found a keymap.json?
+ifneq ("$(wildcard $(KEYMAP_JSON))", "")
+ KEYMAP_C := $(KEYMAP_OUTPUT)/src/keymap.c
+ KEYMAP_H := $(KEYMAP_OUTPUT)/src/config.h
+
+ # Load the keymap-level rules.mk if exists
+ -include $(KEYMAP_PATH)/rules.mk
+
+ # Load any rules.mk content from keymap.json
+ INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --keymap $(KEYMAP) --output $(KEYMAP_OUTPUT)/src/rules.mk)
+ include $(INFO_RULES_MK)
+
+# Add rules to generate the keymap files - indentation here is important
+$(KEYMAP_OUTPUT)/src/keymap.c: $(KEYMAP_JSON)
+ $(QMK_BIN) json2c --quiet --output $(KEYMAP_C) $(KEYMAP_JSON)
+
+$(KEYMAP_OUTPUT)/src/config.h: $(KEYMAP_JSON)
+ $(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --keymap $(KEYMAP) --output $(KEYMAP_H)
+
+generated-files: $(KEYMAP_OUTPUT)/src/config.h $(KEYMAP_OUTPUT)/src/keymap.c
+
+endif
+
+ifeq ($(strip $(CTPC)), yes)
+ CONVERT_TO_PROTON_C=yes
+endif
+
+ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
+ include platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk
+endif
+
+include $(BUILDDEFS_PATH)/mcu_selection.mk
+
+# Find all the C source files to be compiled in subfolders.
+KEYBOARD_SRC :=
+
+KEYBOARD_C_1 := $(KEYBOARD_PATH_1)/$(KEYBOARD_FOLDER_1).c
+KEYBOARD_C_2 := $(KEYBOARD_PATH_2)/$(KEYBOARD_FOLDER_2).c
+KEYBOARD_C_3 := $(KEYBOARD_PATH_3)/$(KEYBOARD_FOLDER_3).c
+KEYBOARD_C_4 := $(KEYBOARD_PATH_4)/$(KEYBOARD_FOLDER_4).c
+KEYBOARD_C_5 := $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).c
+
+ifneq ("$(wildcard $(KEYBOARD_C_5))","")
+ KEYBOARD_SRC += $(KEYBOARD_C_5)
+endif
+ifneq ("$(wildcard $(KEYBOARD_C_4))","")
+ KEYBOARD_SRC += $(KEYBOARD_C_4)
+endif
+ifneq ("$(wildcard $(KEYBOARD_C_3))","")
+ KEYBOARD_SRC += $(KEYBOARD_C_3)
+endif
+ifneq ("$(wildcard $(KEYBOARD_C_2))","")
+ KEYBOARD_SRC += $(KEYBOARD_C_2)
+endif
+ifneq ("$(wildcard $(KEYBOARD_C_1))","")
+ KEYBOARD_SRC += $(KEYBOARD_C_1)
+endif
+
+# Generate KEYBOARD_name_subname for all levels of the keyboard folder
+KEYBOARD_FILESAFE_1 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_1)))
+KEYBOARD_FILESAFE_2 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_2)))
+KEYBOARD_FILESAFE_3 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_3)))
+KEYBOARD_FILESAFE_4 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_4)))
+KEYBOARD_FILESAFE_5 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_5)))
+
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/)","")
+ OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_5)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/)","")
+ OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_4)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/)","")
+ OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_3)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/)","")
+ OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_2)
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/)","")
+ OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_1)
+endif
+
+# Setup the define for QMK_KEYBOARD_H. This is used inside of keymaps so
+# that the same keymap may be used on multiple keyboards.
+#
+# We grab the most top-level include file that we can. That file should
+# use #ifdef statements to include all the neccesary subfolder includes,
+# as described here:
+#
+# https://docs.qmk.fm/#/feature_layouts?id=tips-for-making-layouts-keyboard-agnostic
+#
+QMK_KEYBOARD_H = $(KEYBOARD_OUTPUT)/src/default_keyboard.h
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/$(KEYBOARD_FOLDER_1).h)","")
+ QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_1).h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/$(KEYBOARD_FOLDER_2).h)","")
+ QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_2).h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/$(KEYBOARD_FOLDER_3).h)","")
+ QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_3).h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/$(KEYBOARD_FOLDER_4).h)","")
+ QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_4).h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).h)","")
+ QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_5).h
+endif
+
+# Determine and set parameters based on the keyboard's processor family.
+# We can assume a ChibiOS target When MCU_FAMILY is defined since it's
+# not used for LUFA
+ifdef MCU_FAMILY
+ PLATFORM=CHIBIOS
+ PLATFORM_KEY=chibios
+ FIRMWARE_FORMAT?=bin
+ OPT_DEFS += -DMCU_$(MCU_FAMILY)
+else ifdef ARM_ATSAM
+ PLATFORM=ARM_ATSAM
+ PLATFORM_KEY=arm_atsam
+ FIRMWARE_FORMAT=bin
+else
+ PLATFORM=AVR
+ PLATFORM_KEY=avr
+ FIRMWARE_FORMAT?=hex
+endif
+
+# Find all of the config.h files and add them to our CONFIG_H define.
+CONFIG_H :=
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/config.h)","")
+ CONFIG_H += $(KEYBOARD_PATH_5)/config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/config.h)","")
+ CONFIG_H += $(KEYBOARD_PATH_4)/config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/config.h)","")
+ CONFIG_H += $(KEYBOARD_PATH_3)/config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/config.h)","")
+ CONFIG_H += $(KEYBOARD_PATH_2)/config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/config.h)","")
+ CONFIG_H += $(KEYBOARD_PATH_1)/config.h
+endif
+
+POST_CONFIG_H :=
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_config.h)","")
+ POST_CONFIG_H += $(KEYBOARD_PATH_1)/post_config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_config.h)","")
+ POST_CONFIG_H += $(KEYBOARD_PATH_2)/post_config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_config.h)","")
+ POST_CONFIG_H += $(KEYBOARD_PATH_3)/post_config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_config.h)","")
+ POST_CONFIG_H += $(KEYBOARD_PATH_4)/post_config.h
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_config.h)","")
+ POST_CONFIG_H += $(KEYBOARD_PATH_5)/post_config.h
+endif
+
+# Pull in stuff from info.json
+INFO_JSON_FILES :=
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_1)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_2)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_3)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_4)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_5)/info.json
+endif
+
+CONFIG_H += $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/layouts.h
+
+$(KEYBOARD_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES)
+ $(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_config.h
+
+$(KEYBOARD_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES)
+ $(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h
+
+$(KEYBOARD_OUTPUT)/src/layouts.h: $(INFO_JSON_FILES)
+ $(QMK_BIN) generate-layouts --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/layouts.h
+
+generated-files: $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/default_keyboard.h $(KEYBOARD_OUTPUT)/src/layouts.h
+
+.INTERMEDIATE : generated-files
+
+# Userspace setup and definitions
+ifeq ("$(USER_NAME)","")
+ USER_NAME := $(KEYMAP)
+endif
+USER_PATH := users/$(USER_NAME)
+
+# Pull in user level rules.mk
+-include $(USER_PATH)/rules.mk
+ifneq ("$(wildcard $(USER_PATH)/config.h)","")
+ CONFIG_H += $(USER_PATH)/config.h
+endif
+ifneq ("$(wildcard $(USER_PATH)/post_config.h)","")
+ POST_CONFIG_H += $(USER_PATH)/post_config.h
+endif
+
+# Disable features that a keyboard doesn't support
+-include $(BUILDDEFS_PATH)/disable_features.mk
+
+# Pull in post_rules.mk files from all our subfolders
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_rules.mk)","")
+ include $(KEYBOARD_PATH_1)/post_rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_rules.mk)","")
+ include $(KEYBOARD_PATH_2)/post_rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_rules.mk)","")
+ include $(KEYBOARD_PATH_3)/post_rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_rules.mk)","")
+ include $(KEYBOARD_PATH_4)/post_rules.mk
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_rules.mk)","")
+ include $(KEYBOARD_PATH_5)/post_rules.mk
+endif
+
+ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
+ CONFIG_H += $(KEYMAP_PATH)/config.h
+endif
+ifneq ("$(KEYMAP_H)","")
+ CONFIG_H += $(KEYMAP_H)
+endif
+
+# project specific files
+SRC += \
+ $(KEYBOARD_SRC) \
+ $(KEYMAP_C) \
+ $(QUANTUM_SRC) \
+ $(QUANTUM_DIR)/main.c \
+
+# Optimize size but this may cause error "relocation truncated to fit"
+#EXTRALDFLAGS = -Wl,--relax
+
+# Search Path
+VPATH += $(KEYMAP_PATH)
+VPATH += $(USER_PATH)
+VPATH += $(KEYBOARD_PATHS)
+VPATH += $(COMMON_VPATH)
+VPATH += $(KEYBOARD_OUTPUT)/src
+VPATH += $(KEYMAP_OUTPUT)/src
+
+include $(BUILDDEFS_PATH)/common_features.mk
+include $(BUILDDEFS_PATH)/generic_features.mk
+include $(TMK_PATH)/protocol.mk
+include $(PLATFORM_PATH)/common.mk
+include $(BUILDDEFS_PATH)/bootloader.mk
+
+SRC += $(patsubst %.c,%.clib,$(LIB_SRC))
+SRC += $(patsubst %.c,%.clib,$(QUANTUM_LIB_SRC))
+SRC += $(TMK_COMMON_SRC)
+OPT_DEFS += $(TMK_COMMON_DEFS)
+EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS)
+
+SKIP_COMPILE := no
+ifneq ($(REQUIRE_PLATFORM_KEY),)
+ ifneq ($(REQUIRE_PLATFORM_KEY),$(PLATFORM_KEY))
+ SKIP_COMPILE := yes
+ endif
+endif
+
+include $(PLATFORM_PATH)/$(PLATFORM_KEY)/platform.mk
+-include $(PLATFORM_PATH)/$(PLATFORM_KEY)/flash.mk
+
+ifneq ($(strip $(PROTOCOL)),)
+ include $(TMK_PATH)/protocol/$(strip $(shell echo $(PROTOCOL) | tr '[:upper:]' '[:lower:]')).mk
+else
+ include $(TMK_PATH)/protocol/$(PLATFORM_KEY).mk
+endif
+
+# TODO: remove this bodge?
+PROJECT_DEFS := $(OPT_DEFS)
+PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYBOARD_PATHS)
+PROJECT_CONFIG := $(CONFIG_H)
+
+CONFIG_H += $(POST_CONFIG_H)
+ALL_CONFIGS := $(PROJECT_CONFIG) $(CONFIG_H)
+
+OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
+$(KEYMAP_OUTPUT)_SRC := $(SRC)
+$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) \
+-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(QMK_KEYBOARD_H)\" \
+-DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\"
+$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
+$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
+$(KEYBOARD_OUTPUT)_SRC := $(PLATFORM_SRC)
+$(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS)
+$(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC)
+$(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG)
+
+# Default target.
+ifeq ($(SKIP_COMPILE),no)
+all: build check-size
+else
+all:
+ echo "skipped" >&2
+endif
+
+build: elf cpfirmware
+check-size: build
+check-md5: build
+objs-size: build
+
+include $(BUILDDEFS_PATH)/show_options.mk
+include $(BUILDDEFS_PATH)/common_rules.mk
+
+# Ensure we have generated files available for each of the objects
+define GEN_FILES
+$1: generated-files
+endef
+$(foreach O,$(OBJ),$(eval $(call GEN_FILES,$(patsubst %.a,%.o,$(O)))))
diff --git a/builddefs/build_layout.mk b/builddefs/build_layout.mk
new file mode 100644
index 0000000000..6166bd847c
--- /dev/null
+++ b/builddefs/build_layout.mk
@@ -0,0 +1,32 @@
+LAYOUTS_PATH := layouts
+LAYOUTS_REPOS := $(patsubst %/,%,$(sort $(dir $(wildcard $(LAYOUTS_PATH)/*/))))
+
+define SEARCH_LAYOUTS_REPO
+ LAYOUT_KEYMAP_PATH := $$(LAYOUTS_REPO)/$$(LAYOUT)/$$(KEYMAP)
+ LAYOUT_KEYMAP_JSON := $$(LAYOUT_KEYMAP_PATH)/keymap.json
+ LAYOUT_KEYMAP_C := $$(LAYOUT_KEYMAP_PATH)/keymap.c
+ ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_JSON))","")
+ -include $$(LAYOUT_KEYMAP_PATH)/rules.mk
+ KEYMAP_JSON := $$(LAYOUT_KEYMAP_JSON)
+ KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
+ else ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_C))","")
+ -include $$(LAYOUT_KEYMAP_PATH)/rules.mk
+ KEYMAP_C := $$(LAYOUT_KEYMAP_C)
+ KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
+ endif
+endef
+
+define SEARCH_LAYOUTS
+ $$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
+endef
+
+ifneq ($(FORCE_LAYOUT),)
+ ifneq (,$(findstring $(FORCE_LAYOUT),$(LAYOUTS)))
+ $(info Forcing layout: $(FORCE_LAYOUT))
+ LAYOUTS := $(FORCE_LAYOUT)
+ else
+ $(call CATASTROPHIC_ERROR,Invalid layout,Forced layout does not exist)
+ endif
+endif
+
+$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))
diff --git a/builddefs/build_test.mk b/builddefs/build_test.mk
new file mode 100644
index 0000000000..7226004aab
--- /dev/null
+++ b/builddefs/build_test.mk
@@ -0,0 +1,84 @@
+ifndef VERBOSE
+.SILENT:
+endif
+
+.DEFAULT_GOAL := all
+
+include paths.mk
+include $(BUILDDEFS_PATH)/message.mk
+
+TARGET=test/$(TEST)
+
+GTEST_OUTPUT = $(BUILD_DIR)/gtest
+
+TEST_OBJ = $(BUILD_DIR)/test_obj
+
+OUTPUTS := $(TEST_OBJ)/$(TEST) $(GTEST_OUTPUT)
+
+GTEST_INC := \
+ $(LIB_PATH)/googletest/googletest/include \
+ $(LIB_PATH)/googletest/googlemock/include
+
+GTEST_INTERNAL_INC := \
+ $(LIB_PATH)/googletest/googletest \
+ $(LIB_PATH)/googletest/googlemock
+
+$(GTEST_OUTPUT)_SRC := \
+ googletest/src/gtest-all.cc\
+ googlemock/src/gmock-all.cc
+
+$(GTEST_OUTPUT)_DEFS :=
+$(GTEST_OUTPUT)_INC := $(GTEST_INC) $(GTEST_INTERNAL_INC)
+
+LDFLAGS += -lstdc++ -lpthread -shared-libgcc
+CREATE_MAP := no
+
+VPATH += \
+ $(LIB_PATH)/googletest \
+ $(LIB_PATH)/googlemock \
+ $(LIB_PATH)/printf
+
+all: elf
+
+VPATH += $(COMMON_VPATH)
+PLATFORM:=TEST
+PLATFORM_KEY:=test
+BOOTLOADER_TYPE:=none
+
+ifeq ($(strip $(DEBUG)), 1)
+CONSOLE_ENABLE = yes
+endif
+
+ifneq ($(filter $(FULL_TESTS),$(TEST)),)
+include tests/test_common/build.mk
+include $(TEST_PATH)/test.mk
+endif
+
+include $(BUILDDEFS_PATH)/common_features.mk
+include $(BUILDDEFS_PATH)/generic_features.mk
+include $(PLATFORM_PATH)/common.mk
+include $(TMK_PATH)/protocol.mk
+include $(QUANTUM_PATH)/debounce/tests/rules.mk
+include $(QUANTUM_PATH)/encoder/tests/rules.mk
+include $(QUANTUM_PATH)/sequencer/tests/rules.mk
+include $(PLATFORM_PATH)/test/rules.mk
+ifneq ($(filter $(FULL_TESTS),$(TEST)),)
+include $(BUILDDEFS_PATH)/build_full_test.mk
+endif
+
+$(TEST)_SRC += \
+ tests/test_common/main.c \
+ $(LIB_PATH)/printf/printf.c \
+ $(QUANTUM_PATH)/logging/print.c
+
+$(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC)
+$(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC)
+$(TEST_OBJ)/$(TEST)_DEFS := $($(TEST)_DEFS)
+$(TEST_OBJ)/$(TEST)_CONFIG := $($(TEST)_CONFIG)
+
+include $(PLATFORM_PATH)/$(PLATFORM_KEY)/platform.mk
+include $(BUILDDEFS_PATH)/common_rules.mk
+
+
+$(shell mkdir -p $(BUILD_DIR)/test 2>/dev/null)
+$(shell mkdir -p $(TEST_OBJ) 2>/dev/null)
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
new file mode 100644
index 0000000000..08d186d656
--- /dev/null
+++ b/builddefs/common_features.mk
@@ -0,0 +1,816 @@
+# Copyright 2017 Fred Sundvik
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+QUANTUM_SRC += \
+ $(QUANTUM_DIR)/quantum.c \
+ $(QUANTUM_DIR)/send_string.c \
+ $(QUANTUM_DIR)/bitwise.c \
+ $(QUANTUM_DIR)/led.c \
+ $(QUANTUM_DIR)/action.c \
+ $(QUANTUM_DIR)/action_layer.c \
+ $(QUANTUM_DIR)/action_tapping.c \
+ $(QUANTUM_DIR)/action_util.c \
+ $(QUANTUM_DIR)/eeconfig.c \
+ $(QUANTUM_DIR)/keyboard.c \
+ $(QUANTUM_DIR)/keymap_common.c \
+ $(QUANTUM_DIR)/keycode_config.c \
+ $(QUANTUM_DIR)/sync_timer.c \
+ $(QUANTUM_DIR)/logging/debug.c \
+ $(QUANTUM_DIR)/logging/sendchar.c \
+
+VPATH += $(QUANTUM_DIR)/logging
+# Fall back to lib/printf if there is no platform provided print
+ifeq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk)","")
+ include $(QUANTUM_PATH)/logging/print.mk
+else
+ include $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk
+endif
+
+ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), yes)
+ OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
+ CONSOLE_ENABLE = yes
+else ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), api)
+ OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
+endif
+
+AUDIO_ENABLE ?= no
+ifeq ($(strip $(AUDIO_ENABLE)), yes)
+ ifeq ($(PLATFORM),CHIBIOS)
+ AUDIO_DRIVER ?= dac_basic
+ ifeq ($(strip $(AUDIO_DRIVER)), dac_basic)
+ OPT_DEFS += -DAUDIO_DRIVER_DAC
+ else ifeq ($(strip $(AUDIO_DRIVER)), dac_additive)
+ OPT_DEFS += -DAUDIO_DRIVER_DAC
+ ## stm32f2 and above have a usable DAC unit, f1 do not, and need to use pwm instead
+ else ifeq ($(strip $(AUDIO_DRIVER)), pwm_software)
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ else ifeq ($(strip $(AUDIO_DRIVER)), pwm_hardware)
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ endif
+ else
+ # fallback for all other platforms is pwm
+ AUDIO_DRIVER ?= pwm_hardware
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ endif
+ OPT_DEFS += -DAUDIO_ENABLE
+ MUSIC_ENABLE = yes
+ SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
+ SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
+ SRC += $(QUANTUM_DIR)/audio/audio.c ## common audio code, hardware agnostic
+ SRC += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/audio_$(strip $(AUDIO_DRIVER)).c
+ SRC += $(QUANTUM_DIR)/audio/voices.c
+ SRC += $(QUANTUM_DIR)/audio/luts.c
+endif
+
+ifeq ($(strip $(SEQUENCER_ENABLE)), yes)
+ OPT_DEFS += -DSEQUENCER_ENABLE
+ MUSIC_ENABLE = yes
+ SRC += $(QUANTUM_DIR)/sequencer/sequencer.c
+ SRC += $(QUANTUM_DIR)/process_keycode/process_sequencer.c
+endif
+
+ifeq ($(strip $(MIDI_ENABLE)), yes)
+ OPT_DEFS += -DMIDI_ENABLE
+ MUSIC_ENABLE = yes
+ SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
+endif
+
+MUSIC_ENABLE ?= no
+ifeq ($(MUSIC_ENABLE), yes)
+ SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
+endif
+
+ifeq ($(strip $(STENO_ENABLE)), yes)
+ OPT_DEFS += -DSTENO_ENABLE
+ VIRTSER_ENABLE ?= yes
+ SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
+endif
+
+ifeq ($(strip $(VIRTSER_ENABLE)), yes)
+ OPT_DEFS += -DVIRTSER_ENABLE
+endif
+
+ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
+ OPT_DEFS += -DMOUSEKEY_ENABLE
+ MOUSE_ENABLE := yes
+ SRC += $(QUANTUM_DIR)/mousekey.c
+endif
+
+VALID_POINTING_DEVICE_DRIVER_TYPES := adns5050 adns9800 analog_joystick cirque_pinnacle_i2c cirque_pinnacle_spi pmw3360 pmw3389 pimoroni_trackball custom
+ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
+ ifeq ($(filter $(POINTING_DEVICE_DRIVER),$(VALID_POINTING_DEVICE_DRIVER_TYPES)),)
+ $(call CATASTROPHIC_ERROR,Invalid POINTING_DEVICE_DRIVER,POINTING_DEVICE_DRIVER="$(POINTING_DEVICE_DRIVER)" is not a valid pointing device type)
+ else
+ OPT_DEFS += -DPOINTING_DEVICE_ENABLE
+ MOUSE_ENABLE := yes
+ SRC += $(QUANTUM_DIR)/pointing_device.c
+ SRC += $(QUANTUM_DIR)/pointing_device_drivers.c
+ ifneq ($(strip $(POINTING_DEVICE_DRIVER)), custom)
+ SRC += drivers/sensors/$(strip $(POINTING_DEVICE_DRIVER)).c
+ OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(shell echo $(POINTING_DEVICE_DRIVER) | tr '[:lower:]' '[:upper:]'))
+ endif
+ OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(POINTING_DEVICE_DRIVER))
+ ifeq ($(strip $(POINTING_DEVICE_DRIVER)), adns9800)
+ OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
+ QUANTUM_LIB_SRC += spi_master.c
+ else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), analog_joystick)
+ OPT_DEFS += -DSTM32_ADC -DHAL_USE_ADC=TRUE
+ LIB_SRC += analog.c
+ else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_i2c)
+ OPT_DEFS += -DSTM32_I2C -DHAL_USE_I2C=TRUE
+ SRC += drivers/sensors/cirque_pinnacle.c
+ QUANTUM_LIB_SRC += i2c_master.c
+ else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_spi)
+ OPT_DEFS += -DSTM32_