diff --git a/Makefile b/Makefile index a6c3ee35b7a7..3c754c8fd34d 100644 --- a/Makefile +++ b/Makefile @@ -288,6 +288,13 @@ define PARSE_RULE endif endef +# different from the common.mk version because this needs extra $ because +# it's used in PARSE_KEYBOARD which is already really magic +define USE_RULES + $$(if $$(filter $(1),$$(RULES_MK_LIST)),,$$(eval RULES_MK_LIST += $(1)))\ + $$(eval include $(1)) +endef + # $1 = Keyboard # Parses a rule in the format : # the keyboard is already known when entering this function @@ -301,9 +308,9 @@ define PARSE_KEYBOARD DEFAULT_FOLDER := $$(CURRENT_KB) # We assume that every rules.mk will contain the full default value - $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk) + $(call USE_RULES,$(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk) ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB)) - $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk) + $(call USE_RULES,$(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk) endif CURRENT_KB := $$(DEFAULT_FOLDER) @@ -328,27 +335,27 @@ define PARSE_KEYBOARD KEYBOARD_LAYOUTS := ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/rules.mk)","") LAYOUTS := - $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/rules.mk) + $(call USE_RULES,$(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/rules.mk) KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) endif ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/rules.mk)","") LAYOUTS := - $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/rules.mk) + $(call USE_RULES,$(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/rules.mk) KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) endif ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/rules.mk)","") LAYOUTS := - $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/rules.mk) + $(call USE_RULES,$(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/rules.mk) KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) endif ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/rules.mk)","") LAYOUTS := - $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/rules.mk) + $(call USE_RULES,$(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/rules.mk) KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) endif ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/rules.mk)","") LAYOUTS := - $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/rules.mk) + $(call USE_RULES,$(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/rules.mk) KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) endif @@ -357,6 +364,8 @@ define PARSE_KEYBOARD KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS)) + $$(eval include $$(foreach RULES_MK,$$(RULES_MK_LIST),$$(wildcard $$(subst rules.mk,build.mk,$$(RULES_MK))))) + # if the rule after removing the start of it is empty (we haven't specified a kemap or target) # compile all the keymaps ifeq ($$(RULE),) diff --git a/build_keyboard.mk b/build_keyboard.mk index b086420653f4..dcb41fa3fef7 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -76,19 +76,19 @@ endif # Pull in rules.mk files from all our subfolders ifneq ("$(wildcard $(KEYBOARD_PATH_5)/rules.mk)","") - include $(KEYBOARD_PATH_5)/rules.mk + $(call USE_RULES,$(KEYBOARD_PATH_5)/rules.mk) endif ifneq ("$(wildcard $(KEYBOARD_PATH_4)/rules.mk)","") - include $(KEYBOARD_PATH_4)/rules.mk + $(call USE_RULES,$(KEYBOARD_PATH_4)/rules.mk) endif ifneq ("$(wildcard $(KEYBOARD_PATH_3)/rules.mk)","") - include $(KEYBOARD_PATH_3)/rules.mk + $(call USE_RULES,$(KEYBOARD_PATH_3)/rules.mk) endif ifneq ("$(wildcard $(KEYBOARD_PATH_2)/rules.mk)","") - include $(KEYBOARD_PATH_2)/rules.mk + $(call USE_RULES,$(KEYBOARD_PATH_2)/rules.mk) endif ifneq ("$(wildcard $(KEYBOARD_PATH_1)/rules.mk)","") - include $(KEYBOARD_PATH_1)/rules.mk + $(call USE_RULES,$(KEYBOARD_PATH_1)/rules.mk) endif @@ -315,7 +315,8 @@ ifeq ("$(USER_NAME)","") endif USER_PATH := users/$(USER_NAME) --include $(USER_PATH)/rules.mk +$(call USE_RULES,$(USER_PATH)/rules.mk,-) +$(eval include $(foreach RULES_MK,$(RULES_MK_LIST),$(wildcard $(subst rules.mk,build.mk,$(RULES_MK))))) ifneq ("$(wildcard $(USER_PATH)/config.h)","") CONFIG_H += $(USER_PATH)/config.h endif diff --git a/common.mk b/common.mk index aea29a7a20e2..5bce3121a0d2 100644 --- a/common.mk +++ b/common.mk @@ -22,3 +22,8 @@ COMMON_VPATH += $(QUANTUM_PATH)/audio COMMON_VPATH += $(QUANTUM_PATH)/process_keycode COMMON_VPATH += $(QUANTUM_PATH)/api COMMON_VPATH += $(DRIVER_PATH) + +define USE_RULES + $(if $(filter $(1),$(RULES_MK_LIST)),,$(eval RULES_MK_LIST += $(1)))\ + $(eval $(2)include $(1)) +endef diff --git a/keyboards/ergodox_ez/build.mk b/keyboards/ergodox_ez/build.mk new file mode 100644 index 000000000000..b40fe310f784 --- /dev/null +++ b/keyboards/ergodox_ez/build.mk @@ -0,0 +1,3 @@ +ifeq ($(strip $(RGB_MATRIX_ENABLE)), no) + SRC += i2c_master.c +endif diff --git a/keyboards/ergodox_ez/rules.mk b/keyboards/ergodox_ez/rules.mk index 2882072a627d..2db6cdd30ca5 100644 --- a/keyboards/ergodox_ez/rules.mk +++ b/keyboards/ergodox_ez/rules.mk @@ -84,6 +84,7 @@ SLEEP_LED_ENABLE = no API_SYSEX_ENABLE = no RGBLIGHT_ENABLE = yes RGB_MATRIX_ENABLE = no # enable later + DEBOUNCE_TYPE = eager_pr LAYOUTS = ergodox